.TITLE CATRUN - Run A Task/Command file. .IDENT /2.0/ .ENABL LC ;+ ; ; Free software BY ; Project Software & Development, Inc. ; ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided or ; otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by PROJECT SOFTWARE ; AND DEVELOPMENT, INC. ; ; PROJECT SOFTWARE assumes no responsibility for the use or reliability ; of this software on any equipment whatsoever. ; ; Project Software & Development, Inc. ; 14 Story St. ; Cambridge, Ma. 02138 ; 617-661-1444 ; ; ; Title: CATRUN.MAC ; Author: Robin Miller ; Date: September 22. 1982 ; ; Description: ; ; This routine attempts to run a program from either the system ; UIC (normally [1,54]) or the libary UIC (normally [3,54]) or start ; a command file from LB:[1,2]. ; ; Modification History: ; ; September 10, 1984 by Robin Miller. Version 2.0. ; Modified to make compatible with Digital's TDX task: ; o Look for command files/task images in the login UIC instead ; of the default UIC. ; o Look for global command files in [libuic] instead of [1,2]. ; o Add check for [loguic]CATCHALL.CMD and [libuic]CATCHALL.CMD. ; ;- .NLIST BEX .MCALL ALUN$S, GLUN$S ; Local equates: DS.LEN = 0 ; Offset to dataset length. DS.ADR = 2 ; Offset to dataset address. ; Data strings for flying RUN/INSTALL: RUN0: .ASCIZ ^RUN ^ INS0: .ASCIZ ^INS ^ RUN1: .ASCIZ ^/TASK=^ RUN2: .ASCIZ ^/CMD="^ CATSTR: .ASCIZ %CATCHALL% .EVEN ; Local storage for SY and LB unit numbers. SY0NAM: .WORD 0 ; The SY0 ASCII device name SY0NUM: .WORD 0 ; and the binary unit number. LB0NAM: .WORD 0 ; The LB0 ASCII device name LB0NUM: .WORD 0 ; and the binary unit number. SYUNIT: .WORD 0 ; Default/alternate SY unit number. LBUNIT: .WORD 0 ; Default/alternate LB unit number. SCBUFF: .BLKW 6 ; Buffer for get lun information. ; ; "SYSDDS" and "LIBDDS" are padded with "0"'s so enough space is ; allocated to dynamically change them to UIC's set by System Manager ; via the "SET /SYSUIC and SET /LIBUIC" MCR commands. ; SYSDSW: .WORD SYSLEN,SYSDDS SYSDDS: .ASCIZ "[ggg,mmm]" SYSLEN = <.-SYSDDS>-1 .EVEN LIBDSW: .WORD LIBLEN,LIBDDS LIBDDS: .ASCIZ "[ggg,mmm]" LIBLEN = <.-LIBDDS>-1 .EVEN UICDSW: .WORD UICLEN,UICDDS UICDDS::.ASCIZ "[ggg,mmm]" UICLEN = <.-UICDDS>-1 .EVEN .IFDF DEBUG ; Define these when debugging since we're not mapped with the Executive. $SYUIC::.BYTE 54,1 ; Default mapped system UIC. $LBUIC::.BYTE 54,3 ; Default library UIC. $NTUIC::.BYTE 54,1 ; Default network UIC. .ENDC ; .IFT DEBUG ;+ ; ; FLYRUN - Attempt a running run of the target task. ; ; A line is constructed of the form: ; ; "INS $xxxxxx/TASK=XXXTnn"/CMD="command_line" ; or ; "RUN $xxxxxx/TASK=XXXTnn" if there is no command line. ; ; Where: ; "xxxxxx" is the command as typed, ; "XXXTnn" are the first 3 letters of the command, and Tnn ; is the terminal number, ; /CMD="text" is the command line (if any). ; ; The command line to be passed can be between 46 to 52 characters, ; depending on the size of the task name. The reason for this is because ; of the following bytes being used by the INS command: ; ; INS $xxxxxxxxx - 14. bytes (ranges from 8 to 14) ; /TASK=XXXTnn - 12. byte. ; /CMD="..." - 8. bytes (if a command line is specified) ; --- ; 34. ; ; Maximum size of MCR command line is 79. bytes (+ terminator) via Spawn. ; ; This routine will check the following directories for the file to execute: ; ; 1.) Check the login UIC for a .CMD (conditionalized) ; 2.) Check the login UIC for a .TSK (conditionalized) ; 3.) Check the library UIC (LB:[3,54]) for a .CMD file. ; 4.) Check the system UIC (LB:[1,54]) for a .TSK file. ; 5.) Check the library UIC (LB:[3,54]) for a .TSK file. ; 6.) Check the login UIC for a CATCHALL.CMD file. ; 7.) Check the library UIC for a CATCHALL.CMD file. ; ;- FLYRUN::MOV #RUNENT,SAVTBL ; SETUP RUN COMMAND TABLE ENTRY MOV SAVTBL,R5 ; COPY THE TABLE ENTRY ADDRESS MOV #ASCNAM,(R5) ; SET ADDRESS OF THE KEYWORD BR FLYMO ; GO FLY SOME MORE FLYALT:: ; ALTERNATE ENTRY FOR FLYING RUN MOV SAVTBL,R5 ; COPY THE TABLE ENTRY ADDRESS FLYMO: MOV #CATFDB,R0 ; SCRATCH FDB (PRESERVE FOR MOV #CATFNB,R1 ; DEFAULT FNB .GTDIR & .FIND) CALL DOLUNS ; Setup device names/unit numbers. .SBTTL CMDUIC - Check for command file in login UIC. ; Check for login UIC for a "xxx.CMD" command file. CMDUIC::MOV #UICDSW,R2 ; Set dataset descriptor address. MOV TSKBUF+G.TSDU,R3 ; Copy the login binary UIC. CALL CVTUIC ; CONVERT THE UIC TO ASCII MOV #"SY,N.DVNM(R1) ; SET FOR DEVICE SY and MOV SYUNIT,N.UNIT(R1) ; the system disk unit number. MOV #^RCMD,N.FTYP(R1) ; SET THE FILE EXTENSION TO .CMD CALL .GTDIR ; INSERT DIRECTORY INFO IN FNB CALL .FIND ; DOES THE FILE EXIST ? BCS TSKUIC ; IF CS, NO (LOOK FOR .TSK) CLR R2 ; Show no alternate file name. JMP DOSIND ; Construct and spawn indirect. .SBTTL TSKUIC - Check for task image in login UIC. ; Check for login UIC for "xxx.TSK" task image. TSKUIC::MOV #^RTSK,N.FTYP(R1) ; SET FILE TYPE TO .TSK CALL .GTDIR ; INSERT DIRECTORY INFO IN FDB CALL .FIND ; FIND IT ? BCS LIBCMD ; IF CS, NO MOV R1,R4 ; Save the file name block address. MOV #RUN0,R0 ; SET TO MOVE "RUN " TSTB STATUS ; WAS A COMMAND LINE SPECIFIED ? BPL 10$ ; IF PL, NO MOV #INS0,R0 ; YES, SET TO MOVE "INS $" 10$: CALL MOVE ; MOVE IT TO SPAWN BUFFER CALL CHKSY0 ; Check for alternate system disk. CALL CHKLOG ; Check for same login/default UIC. ; Append the file name to run. MOV (R5),R0 ; COPY THE KEYWORD ADDRESS CALL MOVEC ; MOVE IT MOV #RUN1,R0 ; SET TO MOVE "/TASK=" CALL MOVEC ; MOVE IT TO SPAWN BUFFER MOV (R5),R0 ; COPY THE KEYWORD ADDRESS MOV #6,R2 ; MOVE A MAXIMUM OF 6 CHAR. 30$: TSTB (R0) ; END OF THE KEYWORD ? BEQ 40$ ; IF EQ, YES MOVB (R0)+,(R1)+ ; COPY THE NEXT CHARACTER SOB R2,30$ ; AND LOOP UNTIL DONE 40$: JMP DORUNC ; CONTINUE RUN PROCESSING .SBTTL LIBCMD - Check for command file in library UIC. ; Check for a global command file in LB:[libuic]. LIBCMD::MOV #LIBDSW,R2 ; Set dataset descriptor address. MOV $LBUIC,R3 ; COPY THE BINARY UIC CALL CVTUIC ; CONVERT THE UIC TO ASCII MOV #"LB,N.DVNM(R1) ; SET DEVICE NAME TO LB and MOV LBUNIT,N.UNIT(R1) ; the library disk unit number. MOV #^RCMD,N.FTYP(R1) ; SET THE FILE TYPE TO .CMD CALL .GTDIR ; INSERT DIRECTORY INFO IN FDB CALL .FIND ; DID WE FIND THE FILE ? BCS SYSTSK ; If CS, no. CLR R2 ; Show no alternate file name. JMP DOLIND ; Construct and spawn indirect. .SBTTL SYSTSK - Check for task image in system UIC. ; Check System UIC (usually LB:[1,54]) for a task image. SYSTSK::MOV #SYSDSW,R2 ; Set dataset descriptor address. MOV $SYUIC,R3 ; COPY THE BINARY UIC CALL CVTUIC ; CONVERT THE UIC TO ASCII MOV #^RTSK,N.FTYP(R1) ; SET FILE TYPE TO .TSK MOV #SYSDSW,R2 ; SET TO LOOK UP IN SYSUIC CALL .GTDIR ; INSERT DIRECTORY INFO IN FNB CALL .FIND ; DOES THE FILE EXIST ? BCS LIBTSK ; IF CS, NO JMP DORUN ; YES, USE "RUN $" .SBTTL LIBTSK - Check for task image in library UIC. ; Check Library UIC (usually LB:[3,54]) for a task image. LIBTSK::MOV #LIBDSW,R2 ; SET TO LOOK UP IN LIBUIC CALL .GTDIR ; INSERT DIRECTORY INFO IN FNB CALL .FIND ; DOES THE FILE EXIST ? BCS CATUIC ; IF CS, NO JMP DORUN ; YES, USE "RUN $" .SBTTL CATUIC - Check for login UIC "CATCHALL.CMD". ; Check for command file SY0:[loguic]CATCHALL.CMD. CATUIC::MOV #"SY,N.DVNM(R1) ; Set the device name to "SY" MOV SYUNIT,N.UNIT(R1) ; the system disk unit number. MOV #^RCAT,N.FNAM(R1) ; Set the MOV #^RCHA,N.FNAM+2(R1) ; file name MOV #^RLL ,N.FNAM+4(R1) ; to CATCHALL MOV #^RCMD,N.FTYP(R1) ; Set the file type to .CMD MOV #UICDSW,R2 ; Login UIC dataset descriptor. CALL .GTDIR ; Insert directory info in FDB. CALL .FIND ; Did we find the file ? BCS CATLIB ; If CS, no. MOV #CATSTR,R2 ; Set alternate file name address. JMP DOSIND ; Construct and spawn indirect. .SBTTL CATLIB - Check for library UIC "CATCHALL.CMD". ; Check for command file LB0:[libuic]CATCHALL.CMD. CATLIB::MOV #"LB,N.DVNM(R1) ; Set the device name to "LB" MOV LBUNIT,N.UNIT(R1) ; the library disk unit number. MOV #LIBDSW,R2 ; Login UIC dataset descriptor. CALL .GTDIR ; Insert directory info in FDB. CALL .FIND ; Did we find the file ? BCS 10$ ; If CS, no. MOV #CATSTR,R2 ; Set alternate file name address. BR DOLIND ; Construct and spawn indirect. 10$: JMP ERR2 ; PRINT "Task is not in the system" .SBTTL DOLIND - Construct library "@" command line. ;+ ; ; DOLIND - Construct command for library indirect command file. ; ; This routine constructs a command line of the form: ; ; @dd:[uic]xxx parameters ... ; ; Inputs: ; R1 = The file name block address. ; R2 = The alternate file name address (0 if none). ; ; Outputs: ; Jumps to common routine to spawn command line. ; ;- DOLIND::MOV R1,R4 ; Save the FNB address. MOV #SPNBUF,R1 ; Set the output buffer address. MOVB #'@,(R1)+ ; Set up to execute "...AT." task. CALL CHKLB0 ; Check for alternate library name. ; Always add the library UIC string. MOV #LIBDDS,R0 ; Set address of library UIC string. CALL MOVEC ; Append the UIC to the spawn buffer. ; Append the alternate file name (used for CATCHALL.CMD). MOV R2,R0 ; Copy the alternate file address. BEQ 30$ ; If EQ, there is none. CALL MOVEC ; Copy it to the spawn buffer. MOVB #SPACE,(R1)+ ; Insert space before command line. 30$: MOV #CMDBUF,R0 ; Set address of the command line. CALL MOVEC ; Append it to the spawn buffer. JMP GO ; Go to common routine to spawn. .SBTTL DOSIND - Construct system "@" command line. ;+ ; ; DOSIND - Construct command for system indirect command file. ; ; This routine constructs a command line of the form: ; ; @dd:[uic]xxx parameters ... ; ; Inputs: ; R1 = The file name block address. ; R2 = The alternate file name address (0 if none). ; ; Outputs: ; Jumps to common routine to spawn command line. ; ;- DOSIND::MOV R1,R4 ; Copy the file name block address. MOV #SPNBUF,R1 ; Set the output buffer address. MOVB #'@,(R1)+ ; Set up to execute "...AT." task. CALL CHKSY0 ; Check for alternate system disk. CALL CHKLOG ; Check for same login/default UIC. ; Append the alternate file name (used for CATCHALL.CMD). MOV R2,R0 ; Copy the alternate file address. BEQ 40$ ; If EQ, there is none. CALL MOVEC ; Copy it to the spawn buffer. MOVB #SPACE,(R1)+ ; Insert space before command line. ; Append the file name and command line (if any). 40$: MOV #CMDBUF,R0 ; Set address of the command line. CALL MOVEC ; Append it to the spawn buffer. JMP GO ; Go to common routine to spawn. .SBTTL DORUN - Construct RUN task image command line. ;+ ; ; DORUN - Construct the RUN task image command line. ; ; This routine constructs a command line of the form: ; ; INS $xxx/TASK=xxxTnn/CMD="command_line" ; or ; RUN $xxx/TASK=xxxTnn ! If no command line specified. ; ; Inputs: ; R1 = The file name block address. ; R5 = The table entry address. ; ; Outputs: ; R0 = The exit status from the spawned task. ; ; Effects: ; Jumps to the exit routine. ; ;- DORUN:: MOV R1,R4 ; Save the file name block address. MOV #RUN0,R0 ; SET TO MOVE "RUN " TSTB STATUS ; WAS A COMMAND LINE SPECIFIED ? BPL 10$ ; IF PL, NO MOV #INS0,R0 ; YES, SET TO MOVE "INS " 10$: CALL MOVE ; MOVE "RUN/INS " TO SPAWN BUFFER CALL CHKLB0 ; Check for alternate library name. MOVB #'$,(R1)+ ; Insert "$" for SYSUIC/LIBUIC. MOV (R5),R0 ; COPY THE KEYWORD ADDRESS MOV R0,R2 ; SAVE POINTER FOR SECOND PART OF RUN CALL MOVEC ; MOVE TASK NAME TO SPAWN BUFFER MOV #RUN1,R0 ; POINT TO NEXT PART OF RUN STRING CALL MOVEC ; MOVE "/TASK=" TO BUFFER MOVB (R2)+,(R1)+ ; GET FIRST THREE MOVB (R2)+,(R1)+ ; CHARACTERS MOVB (R2)+,(R1)+ ; OF TASK NAME MOV #ASCTTY,R0 ; POINT TO ASCII TERMINAL # CALL MOVEC ; AND MOVE IT DORUNC::TSTB STATUS ; IS THERE A COMMAND LINE ? BPL GO ; IF PL, NO MOV #RUN2,R0 ; POINT TO NEXT PART OF RUN STRING CALL MOVEC ; MOVE '/CMD="' TO BUFFER MOV SCMD,R0 ; COPY THE COMMAND LINE ADDRESS CALL MOVEC ; AND MOVE IT TO SPANE BUFFER MOVB #'",(R1)+ ; MOVE IN TERMINATING CHARACTER ; Spawn the command set up in Spawn buffer (SPNBUF). GO:: CALL SPAWN ; SPAWN THE COMMAND LINE JMP EXST ; AND EXIT WITH STATUS .SBTTL CHKLOG - Check The Login/Default UIC. ;+ ; ; CHKLOG - Check the login/default UIC. ; ; This routine inserts the login UIC if the default UIC is not the ; same. The UIC is only inserted if different so the command line ; doesn't get longer than neccessary. ; ; Inputs: ; R1 = The output buffer address. ; ; Outputs: ; R1 = The updated buffer address. ; R0 is destroyed, all other registers are preserved. ; ;- CHKLOG: CMP TSKBUF+G.TSPC,TSKBUF+G.TSDU ; Default and login UIC the same ? BEQ 10$ ; If EQ, yes (don't append the UIC). MOV #UICDDS,R0 ; Set address of ASCIZ login UIC. CALL MOVEC ; Copy it to the spawn buffer. 10$: RETURN .SBTTL CHKLB0 - Check The Library Disk Name. ;+ ; ; CHKLB0 - Check the library disk name. ; ; This routine is used to check for an alternate library disk name. ; If there isn't an alternate library disk, then we compare the system ; disk with the library disk and if different insert the device name. ; The device name is only inserted if different so the command line ; doesn't get longer than neccessary. ; ; Inputs: ; R1 = The output buffer address. ; R4 = The file name block address. ; ; Outputs: ; R1 = The updated buffer address. ; R3 is destroyed, all other registers are preserved. ; ;- CHKLB0: CMP LB0NAM,N.DVNM(R4) ; Library disk names the same ? BNE 10$ ; If NE, no. CMP LB0NUM,N.UNIT(R4) ; Maybe, is unit number the same ? BEQ 20$ ; If EQ, yes (skip device name). ; Add the device name if using alternate library disk. 10$: MOVB N.DVNM(R4),(R1)+ ; Copy the device name MOVB N.DVNM+1(R4),(R1)+ ; from the file name block. MOV N.UNIT(R4),R3 ; Copy the device unit number. ADD #60,R3 ; Convert it to ASCII (single digit). MOVB R3,(R1)+ ; Save the device unit number. MOVB #':,(R1)+ ; Terminate the device name. 20$: RETURN .SBTTL CHKSY0 - Check The System Disk Name. ;+ ; ; CHKSY0 - Check the system disk name. ; ; This routine is used to check for an alternate system disk name. ; The device name is only inserted if different so the command line ; doesn't get longer than neccessary. ; ; Inputs: ; R1 = The output buffer address. ; R4 = The file name block address. ; ; Outputs: ; R1 = The updated buffer address. ; R3 is destroyed, all other registers are preserved. ; ;- CHKSY0: CMP SY0NAM,N.DVNM(R4) ; System disk names the same ? BNE 10$ ; If NE, no (insert device name). CMP SY0NUM,N.UNIT(R4) ; Maybe, is unit number the same ? BEQ 20$ ; If EQ, yes (skip the device name). ; Add the device name if using alternate system disk. 10$: MOVB N.DVNM(R4),(R1)+ ; Copy the device name MOVB N.DVNM+1(R4),(R1)+ ; from the file name block. MOV N.UNIT(R4),R3 ; Copy the device unit number. ADD #60,R3 ; Convert it to ASCII (single digit). MOVB R3,(R1)+ ; Save the device unit number. MOVB #':,(R1)+ ; Terminate the device name. 20$: RETURN .SBTTL CVTUIC - Convert Binary UIC To ASCII ;+ ; ; CVTUIC - Convert binary UIC to ASCII. ; ; Inputs: ; R2 = The dataset descriptor address. ; Format: .word len ; Store length here. ; .word address ; Address for ASCII string. ; R3 = The binary UIC to convert. ; ; Outputs: ; All registers are preserved. ; ;- CVTUIC::CALL $SAVAL ; SAVE ALL REGISTERS MOV R2,R0 ; Copy the dataset address. MOV DS.ADR(R0),R2 ; Get address to store string. MOV R2,R1 ; Save for later calculation. CLR R4 ; Suppress zeros/insert separators. CALL .PPASC ; CONVERT IT TO ASCII CLRB (R2) ; Terminate string with a null. SUB R1,R2 ; Calculate the string length. MOV R2,DS.LEN(R0) ; Save length in the descriptor. RETURN .SBTTL DOLUNS - Setup device names/unit numbers. ;+ ; ; DOLUNS - Setup device names/unit numbers for SY0 and LB0. ; ; Inputs: ; None. ; ; Outputs: ; All registers are preserved. ; ;- DOLUNS: JSR R2,$SAVVR ; Save R0 - R2. MOV #SCBUFF,R0 ; Set address for get lun info. ; Save device name/unit number for SY0: ALUN$S #SCLUN,#"SY,#0 ; Assign LUN to system disk. GLUN$S #SCLUN,R0 ; Get LUN info for system disk. MOV G.LUNA(R0),SY0NAM ; Save the device name for MOVB G.LUNU(R0),SY0NUM ; and the unit number for SY0: ; Save device name/unit number for LB0: ALUN$S #SCLUN,#"LB,#0 ; Assign LUN to library disk. GLUN$S #SCLUN,R0 ; Get LUN info for library disk. MOV G.LUNA(R0),LB0NAM ; Save the device name for MOVB G.LUNU(R0),LB0NUM ; and the unit number for LB0: ; Save the unit number for alternate system disk (SY1:). MOV SY0NUM,SYUNIT ; Setup the default unit number. ALUN$S #SCLUN,#"SY,#1 ; Alternate system disk name ? BCS 10$ ; If CS, no. MOV #1,SYUNIT ; Yes, set system disk unit number. ; Save the unit number for alternate library disk (SY2:). 10$: MOV LB0NUM,LBUNIT ; Setup the default unit number. ALUN$S #SCLUN,#"SY,#2 ; Alternate library disk name ? BCS 100$ ; If CS, no. MOV #1,LBUNIT ; Yes, set system disk unit number. 100$: RETURN .END