Text File

.MCALL .MODULE .MODULE FORCE,RELEASE=X01,VERSION=03,COMMENT=<Force terminal input>

; Copyright (C) 1986, 1989 By Megan B Gentry. All Rights Reserved ; ; This software is provided for personal use only and may be used and ; copied only with the inclusion of the above copyright notice. ; ; The author assumes no responsibility for the use or reliability of ; this software.

.SBTTL Abstract and Edit History

;+ ; ; FORCE ; ; The purpose of this program is to allow a background user to ; force a string into the input buffer of a specified job. ; ; X01 (000) dd-mmm-yy Initial coding, based on terminal number ; MBG ; ; X01 (001) 31-May-89 Recoding to place characters in the input ; MBG buffer for a specific job. ; ; X01 (002) 05-Jun-89 Code to prevent forcing commands to same ; MBG program forcing commands. ; ; X01 (003) 21-Jun-89 Program prompt string under .NLCSI control ; MBG ; ;-

.SBTTL Definitions

; Specify system library

.LIBRARY "SRC:SYSTEM.MLB"

; System communcations area

.MCALL .SYCDF, .JSWDF

.SYCDF .JSWDF ;Job status word

; RMON Fixed offsets

.MCALL .FIXDF, .CF1DF, .SGNDF

.FIXDF .CF1DF ;Configuration word 1 .SGNDF ;System generation features word

; Impure area offsets

.MCALL .IMPDF

.IMPDF

; RT-11 Programmed requests we'll be using

.MCALL .GVAL, .RCTRL, .GTLIN .MCALL .PRINT, .GTJB, .EXIT

; Characters

LF =: 12 ;Line feed CR =: 15 ;Carriage return

.SBTTL Local Macro Definitions

; Error message reporting macro

.MACRO ERROR. SEVER,TEXT,CR=YES ..MASK = 0 ..FLAG = 0 .IRPC XXX,<IWEFU> .IF EQ ..FLAG .IF IDN SEVER,XXX ..FLAG = 1 .IFF .IIF EQ ..MASK ..MASK = 1 ..MASK = ..MASK*2 .ENDC .ENDC .ENDR .IF NE ..FLAG .SAVE .PSECT .TEXT. ... = . .NLIST BEX .BYTE ..MASK .ASCII |'SEVER'TEXT| .IF IDN CR,YES .BYTE 0 .IFF .BYTE 200 .ENDC .LIST BEX .RESTORE MOV #...,R0 CALL ERRPRO .IFF .ERROR ;Invalid severity - ''sever'' .ENDC .ENDM

.SBTTL PSECT Ordering

.PSECT .CODE. ;Pure code .PSECT .TEXT. ;Pure/impure text .PSECT .DATA. ;Impure data

.SBTTL Start of utility

.PSECT .CODE.

.ENABL LSB

FORCE: .GVAL #AREA,# ;Get system configuration word 1 BIT #FBMON$,R0 ;Running under SJ? BNE 10$ ;Nope... ERROR. F,<No other jobs in SJ> .EXIT

10$: BIS #TTLC$,@# ;Enable lower case .RCTRL ; and make sure it takes effect 20$: CALL GETCOM ;Get a valid command CALL PROCOM ; and go process it BR 20$ ;Do until when?

.DSABL LSB

.SBTTL GETCOM - Get a valid command from the user

;+ ; ; GETCOM ; Prompts the user for a command line of the form ; ; job_name:text ; ; where 'job_name' is the name of the job to which 'text' ; is to be forced ; ; Implicit output: ; JOBNAM contains <NUL>-terminated ascii jobname string ; LINBUF contains <NUL>-terminated ascii text string ; LINLEN contains count of characters in text ; ;-

.ENABL LSB

GETCOM: MOV #ARGBLK,R5 ;R5 -> GTLIN argument block CALL GTLIN ;Get a line from chain area or tty

; .GTLIN #LINBUF,#M.FORC ;Prompt the user for something MOV #LINBUF,R1 ;R1 -> User's response TSTB (R1) ;Was user response simply a <RETURN>? BNE 10$ ;Nope... .PRINT #M.ID ;Yes, respond with program info BR GETCOM

10$: MOV #JOBNAM,R2 ;R2 -> Where to put job name MOV #6,R3 ;R3 = Maximum job name string length 20$: CMPB (R1),#': ;Have we hit the delimiter? BEQ 30$ ;Yep... MOVB (R1)+,(R2)+ ;Nope, move a character SOB R3,20$ ;Loop for valid job_name string length CMPB (R1),#': ;We've gotten all the characters ; allowed, have we hit the delimiter? BEQ 30$ ;Yep... ERROR. F,<Invalid command line> BR GETCOM

30$: CLRB (R2)+ ;Terminate job_name with <NUL> TSTB (R1)+ ;Skip the delimiter MOV #LINBUF,R2 ;R2 -> Line buffer 40$: MOVB (R1)+,(R2)+ ;Move the characters in the buffer BNE 40$ DEC R2 ;Back up to <NUL> MOVB #CR,(R2)+ ; and replace with <CR>, MOVB #LF,(R2)+ ; <LF> CLRB (R2) ; and <NUL> SUB #LINBUF,R2 ;R2 = Character count for 'text' MOV R2,LINLEN ;Save it RETURN

.DSABL LSB

.SBTTL PROCOM - Process command

;+ ; ; PROCOM ; Processes the command, forcing the text to the input buffer ; of the specified job. ; ;-

.ENABL LSB

PROCOM: .GTJB #AREA,#JOBINF ;Get info on this job MOV JOBINF,R1 ;Save its number .GTJB #AREA,#JOBINF,#JOBNAM ;Locate the specified job BCC 10$ ;Got it ERROR. F,<No such job >,CR=NO 5$: .PRINT #JOBNAM BR 100$

10$: CMP JOBINF,R1 ;Same target as current job? BNE 15$ ;Nope... ERROR. F,<Invalid target job >,CR=NO BR 5$

15$: MOV #JOBINF,R0 ;R0 -> Job info area MOV JB.IMP(R0),R1 ;R1 -> Impure area for job

; Now determine the location of the input ring structure within ; the impure area.

MOV #I.BLOK+2,R2 ;R2 = I.JID (last fixed impure offset) ADD #10,R2 ;R2 = I.NAME (non-system tasking) .GVAL #AREA,# ;R0 = Sysgen features BIT #STASK$,R0 ;Monitor support system tasks? BEQ 20$ ;Nope... ADD #<14-10>,R2 ;Yes, then job prompts are longer ADD #6,R2 ; and we must account for I.LNAM

20$: ;R2 = I.NAME ADD #10,R2 ;R2 = I.SPLS ADD #2,R2 ;R2 = I.TRAP ADD #2,R2 ;R2 = I.SWAP (if non-XM without ; FPU support) BIT #FPU11$,R0 ;Do we have FPU support? BEQ 30$ ;Nope... ADD #2,R2 ;Yes, then account for I.FPP 30$: BIT #MMGT$,R0 ;Running under XM? BEQ 40$ ;Nope... ADD #2,R2 ;Yes, then account for I.SPSV 40$: ;R2 = I.SWAP ADD #4,R2 ;R2 = I.SP ADD #2,R2 ;R2 = I.BITM ADD #<->,R2 ;R2 = I.IRNG (if non-multiterminal) BIT #MTTY$,R0 ;Do we have Multi-terminal support? BEQ 50$ ;Nope... ADD <2+2>,R2 ;Yes, then account for I.CLUN ; and I.TTLC 50$: ADD R1,R2 ;R2 -> Input ring structure MOV 10(R2),R3 ;R3 -> top of buffer SUB @R2,R3 ;R3 = Buffer size CMP LINLEN,R3 ;Room for the command to be forced? BLE 60$ ;Yep... ERROR. F,<Insufficient room to force command> BR 100$

60$: MOV LINLEN,R0 ;R0 = Count of characters to force MOV #LINBUF,R1 ;R1 -> String to force 70$: MOV 2(R2),R4 ;R4 -> Where to place character INC R4 ;Bump to next position CMP R4,10(R2) ;Time to wrap? BLO 80$ ;Nope... MOV @R2,R4 ;Yes, reset PUT pointer 80$: MOVB (R1)+,@R4 ;Stuff the character MOV R4,2(R2) ;Replace updated PUT pointer INC 4(R2) ;Bump the character count SOB R0,70$ ;Keep going MOV JOBINF+JB.IMP,R1 ;R1 -> Impure area INC I.TTLC(R1) ;Bump the line count

82$: TST I.TTLC(R1) ;Has the line been retrieved? BNE 82$ ;Not yet, wait for it

90$: TST (PC)+ ;Good return (carry = 0) 100$: SEC ;Error return (carry = 1) RETURN

.DSABL LSB .if eq 1

.SBTTL TCBPTR - Returns TCB address

;+ ; ; TCBPTR ; Returns the address of the TCB associated with a terminal ; in a multiterminal configuration. ; ; CALL: ; R1 = Number of terminal TCB desired ; (^RCTY for system console TCB) ; ; Return: ; c-bit = 0 ; R1 -> TCB ; c-bit = 1, invalid argument ; R1 unchanged ; ;-

TCBPTR: MOV R0,-(SP) ;Save R0 for awhile .MTSTA #AREA,#MTINFO ;Get info on this multiterminal system CMP R1,#<^RCTY> ;Now, is request for TCB of CTY? BNE 10$ ;Nope... MOV MTINFO+2,R1 ;R1 = Offset from to TCB BR 40$

10$: CMP R1,MTINFO+4 ;If not CTY, is terminal number valid? BGT 50$ ;Nope... MOV R1,-(SP) ;Save terminal number passed MOV MTINFO,R1 ;R1 = Offset from to first TCB 20$: DEC (SP) ;Any more TCB's to account for? BLT 30$ ;Nope, we're there... ADD MTINFO+6,R1 ;Yes, add size of a TCB BR 20$

30$: TST (SP)+ ;Discard counter 40$: ADD @#SYSPTR,R1 ;Add address of TST (PC)+ ;Good return, c-bit clear 50$: SEC ;Error return, c-bit set MOV (SP)+,R0 ;*C* Restore saved R0 RETURN

.endc ;eq 1

.SBTTL ERRPRO - Centralized error processor

;+ ; ; ERRPRO ; Prints error messages in the form ; ; ?Facility-Severity-Text ; ; CALL: ; R0 -> Message definition ; First byte is mask ; Second byte is severity character ; Remaining bytes comprise message ; (end in <NULL> or <200> byte) ; ;-

ERRPRO: BISB (R0)+,@# ;Set the User Error Byte MOVB (R0)+,SEVER ;Set message severity MOV R0,-(SP) ;Save pointer to text .PRINT #FACILI ;'?Facility-Severity- .PRINT (SP)+ ; text' RETURN

.SBTTL Text messages

.PSECT .TEXT. .NLIST BEX

M.FORC: .NLCSI TYPE=I,PART=NAME .ASCII />/<200> M.ID: .NLCSI TYPE=Z,PART=ALL

.LIST BEX .EVEN

.SBTTL Impure data area

.PSECT .DATA.

FACILI: .NLCSI TYPE=I,PART=PREFIX SEVER: .ASCII /x-/<200> .EVEN

AREA: .BLKW 3 ;General purpose EMT area

ARGBLK: .WORD 3 .WORD LINBUF .WORD M.FORC .WORD STRING

STRING: .ASCIZ /PLAIN/ JOBNAM: .BLKB 8. ;Six characters plus <NUL>

LINLEN: .BLKW ;Number of characters LINBUF: .BLKB 134. ;User response buffer

JOBINF: .BLKW 12.

JB.IMP = 10

.END FORCE