.TITLE FIXUP .IDENT /Y01.5A/ .enabl lc ; More than a teletype ; ; 18-JUN-80 J. DOWNWARD ADD SUPPORT FOR %B ; RING BELL ON EXIT ; ; 17-NOV-81 J. CLEMENT Extend support for %$n% ; Complete cleanup, add error messages, add support for ; %-nmxxxxx%,%+nmxxxxxx% ; ; This module fixes up the parameters in the final output line ; from the parameter specifications given in return to ; questions or on the initial command line. ; ; Define buffer lengths and maximum # of parameters allowed. ; SPA = 40 ; Blank CR = 15 ; LF = 12 ; ESC = 33 ; ; ; External variables needed. ; ; MCR is the input line to parse ; CMD is the output line ; PVECT is the vector containing the address of params (1-9) ; PSIZ is the vector containing the param. sizes ; TERMIN current terminal ; DUIC UIC code ; RING non zer of ring bell when done ; ; R3 is the input index ; R0 is the output index ; ; ; This routine now supports the following commands. ; ; %PPNxxxxxxxxx% ; PP = Parameter number (1-9) or ; - Parameter number for parameters before "=" or "<" ; + Parameter number for params after "=" or "<" ; N = "," "=" or may be omitted ; xxxx = String to include if first x doesn't match ; If N is omitted the first x can't be "=" or "<". ; The final % may only be omitted at the end of a line. ; ; %ANxxxxxxx% ; Same as above except pass whole command line ; ; ; %U include UIC ; ; %G include group number ; ; %M include member number ; ; %T include terminal number ; ; %$n% Determine event flag ; n= event flag (1-9) or it may be omitted ; When this param is specified the routine doesn't ; wait for spawn. Later wait is via "-$n" CCL line. ; If n is omitted no synchronization is possible. ; ; %B Activate BELL after spawn .PSECT $VARS,rw,d,con,lcl EXTEND: .blkw 1 ; Non zero if no extension to be added .PSECT $CODE1,rw,i,con,lcl ; ; At this point all the parameters in the array should ; have the value they will finally take. ; Entry here occurs for each occurance ofthe parameter flag ; characeter "%" in the skeleton line which at this phase of ; proessing lies in the MCR buffer since that information has been ; dealt with. ; ; ; R1= The character we are currently testing ; FIXUP:: CALL INCR3 ; Get next char ; ; CHECK for %$ ; CMPB R1,#'$ ; Is it the "escape" char BNE NOTESC ; No - branch CLR EVFLG ; Zero event flag for no wait. CALL INCR3 ; Get next char MOV R1,R2 SUB #'0,R2 ; Is it smaller than 0? BLE DONE ; Yes, done CMP R2,#9. ; Greater than 9 BGT DONE ; Yes, done INC R2 ; Event flag +1 MOV R2,EVFLG ; It specifies an event flag BR DONE ; ;JGD4 ; Process "%B%" - ring bell on exit from ccl if found ;JGD4 ; ;JGD4 NOTESC: ;JGD4 CMPB R1,#'B ; WAS IT %B%? ;JGD4 BNE NOTBEL ; IF NO, CHECK FOR %% ;JGD4 INC RING ; SHOW WE MUST RING ;JGD4 BR DONE ; SKIP TO NEXT % AND CONTINUE ;JGD4 FIXUP1:: CALL INCR3 ; Get char. NOTBEL: ; ; Process "%%" - ie the character "%" is to be inserted ; CMPB R1,#'% ; Was it %% meaning % BNE NOTPCT ; No - branch MOVB #'%,(R0) CALL INCR0 ; Next output location BR DONER ; ; Process "%G%" - ie GROUP of [GROUP,MEMBER] ; NOTPCT: CMPB R1,#'G ; Group number requested? BNE NOTGRP ; No - branch MOVB DUIC+1,R1 ; Get the group number BR GM ; Join common code ; ; Process "%M%" - ie MEMBER of [GROUP,MEMBER] ; NOTGRP: CMPB R1,#'M ; Is it the member number? BNE NOTMEM ; No - branch MOVB DUIC,R1 ; Get the member number ; ; Insert either the group or member number into output string ; GM: MOV #1,R2 ; Do not suppress leading zeroes MOV R3,-(SP) CALL $CBTMG MOV (SP)+,R3 BR DONE ; ; Process "%U%" - ie UIC ; NOTMEM: CMPB R1,#'U ; Is it UIC? BNE NOTUIC ; No - branch MOV R3,-(SP) ; Put UIC string in output line MOV DUIC,R3 MOV R0,R2 CLR R4 CALL .PPASC MOV (SP)+,R3 MOV R2,R0 ; Next output byte BR DONE ; ; Process "%T%" - The terminal identifier (ie T0 to T77) ; NOTUIC: CMPB R1,#'T ; Is it a terminal ID request? BNE NOTTRM ; No - branch MOVB TERMIN+1,(R0) ; Output 2nd device byte (should be "T") CALL INCR0 MOVB UNIT,R2 MOV R2,R4 ASR R4 ; Get high order unit # ASR R4 ASR R4 BIC #^C<7>,R4 ; Range 0-7 BIC #^C<7>,R2 TST R4 ; Only output high order digit if significant BEQ 1$ ; Not - branch ADD #'0,R4 ; Convert to printing digit 0 - 7 MOVB R4,(R0) ; Add to output line CALL INCR0 1$: ADD #'0,R2 ; Convert lower to printing digit MOVB R2,(R0) ; Add to output line CALL INCR0 BR DONE ; ; Here skip until R3 points to '%' in skeleton ; SKPFWD: CMPB R1,#'% BEQ DONER ; FINISH UP ; JGD4 CALL INCR3 ; Get next char BR SKPFWD ; Tally ho! DONE: MOVB (R3),R1 ; Skip over %c CMPB R1,#'% ; Is it terminated with % BNE DONER ; No CALL INCR3 ; Yes, skip terminating % DONER: CLC ; No error RETURN ; Finally return ; ; Try checking for number %n or %-n or %+n ; NOTTRM: CLR EXTEND ; Initially no extend DEC R3 ; So will point to correct value CALL PARGET ; Get R4,R5, or give syntax error MOV (R4),R4 ; Address of param. BEQ SKPFWD MOV (R5),R5 ; Size of param (if 0 none) BLE SKPFWD ; None BEQ SKPFWD ; Null parameter skip to "%" TSTB (R4) ; Final validity test BEQ SKPFWD ; Null params skipped ; ; Now check for a prefix character %n,xxxxxxx% or %n=xxxxxx% ; or %-n,xxxxx% or %+n,xxxxxx% ; if either we insert the prefix characeter now because we know ; the parameter is non null. ; At this point R4 points to the parameter array ; CALL INCR3 ; Now R1 is char after the number CMPB R1,#', ; Is it a comma? BEQ 1$ ; Branch if it is CMPB R1,#'= ; Not a comma, is it an equal sign? BNE 3$ ; Branch if it is not ; ; Here there is a prefix character insert it ; 1$: MOVB R1,(R0) ; Insert the seperator CALL INCR0 ; ; Here we set the default starter character for an extender field ; CALL INCR3 ; Get next char (Default char in R1) ; ; Get the next character from the parameter ; 3$: CLR EXTEND ; If EXTEND>0 no extender desired NXTCHR: ; ; If null, parameter is ended - go check for extenders ; MOVB (R4)+,R2 ; 1 byte of param BEQ 2$ MOVB R2,(R0) ; Put params CALL INCR0 ; ; Copy the parameter character ; if it matches the default starter then default is not wanted ; so set default extender seen ; CMPB R1,R2 ; Default starter? BNE 1$ ; No - branch INC EXTEND ; Yes - set flag 1$: SOB R5,NXTCHR ; Process next character ; ; Parameter is done, is extender field required ; ; ; There is no extender field to give anyway %n(,or=ornull)% ; 2$: TST EXTEND ; Extender? BNE SKPFWD ; Yes - skip to the next "%" ; ; Add default extender until we reach "%" ; 3$: CMPB R1,#'% ; Is char terminator? BEQ DONER ; Yes, Done with all this MOVB R1,(R0) ; Save extender CALL INCR0 CALL INCR3 ; Get next char BR 3$ ; No - continue adding characters ; ; ; Subroutines to increment R3,R0 correctly ; INCR0: INC R0 ; Points to next output char. CMP R0,STRLEN ; Too big? BLOS 1$ ; No, normal return TST (SP)+ ; Yes, return to original caller SEC ; Error indicator 1$: RETURN ; Return 1 way or the other INCR3: MOVB (R3)+,R1 ; Next byte BNE 1$ ; Normal return TST (SP)+ ; Yes, return to original caller DEC R3 ; Points to zero byte CLC ; OK exit 1$: RETURN ; Return 1 way or the other .END