.TITLE FIXUP .IDENT /Y01.5A/ .enabl lc ; More than a teletype ; ; 18-JUN-80 J. DOWNWARD ADD SUPPORT FOR %B ; RING BELL ON EXIT ; ; This is derived from an original in FORTRAN (now deceased) so excuse ; the odd names for PSECTs, variables etc. ; ; 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. ; MAXPAR = 9. ; %1% to %9% PARLNG = 30. ; 30. bytes per %n% PARLN1 = PARLNG+1 ; One more than PARLNG SPA = 40 ; Blank CR = 15 ; LF = 12 ; ESC = 33 ; ; ; This common contains the original MCR command line minus the keyword. ; .psect MCRDAT,rw,d,con,ovr,gbl OMCR: .blkb 80. ; Original line NOSTOP::.WORD 0 ; Do not stop for EFN1 if set ; Is set if %$% terminates line RING:: .WORD 0 ; Ring Bell on exit if %B% found .PSECT .$$$$.,rw,d,con,ovr,gbl PARAMS: .word 0 ; Max # params to question for MCRL: .word 0 ; Length of MCR initial line KEYL: .word 0 ; Length of keyword typed MCR: .blkb 80. ; Command line typed by user KEYB: .blkb 8. ; Text of typed keyword P: ; Parameter block space .REPT MAXPAR ; For this many parameters .BLKB PARLNG ; Containing this many characters .ENDR CMD: .blkb 80. ; Output command line ( space to build it) PMIN: .WORD 0 ; Save place to keep commons aligned EXSTAT: .WORD EX$SUC ; To keep commons aligned DUIC: .WORD 0 ; Default (or Current) UIC TERMIN: .BYTE 0 ; Terminal char 1 ie V of VT .BYTE 0 ; ............ 2 ie T of VT UNIT: .BYTE 0 ; Terminal unit # (ie 1 if VT1) .BLKB 9. ; Hold rest of space claimed by GLBUF .PSECT $VARS,RW,D,CON,LCL SEEN: .BYTE 0 ; This is 0 if no explicit extender ; field is matched, -1 if it is. The extender ; field is that field which will be added by ; default to a pararmeter if the initial char ; is not matched in the parameter. ; If it is matched then the default will not ; be added. DEFCH: .BYTE 0 ; This is the character at the start ; which determines the match. .PSECT $CODE1,rw,i,con,lcl ; ; At this point all the parameters in the array should ; have the value they will finally take. ; The array P is a FORTRAN array (MAXPAR,PARLNG) bytes which contains ; as the initial bytes for each of the MAXPAR parameters the ; the character text of all parameters. ; The character text is terminated on a null. ; ; 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. ; The routine maintains R3 as the pointer to a word which is the ; the poiinter into the skeleton in the MCR buffer ; and R4 as the pointer to a word which is the pointer into the ; new command buffer which is being created. ; FIXUP:: ; External entry point CLRB SEEN ; Say not seen extender delimiter yet MOV 2(R5),R3 ; Get address of word pointer in skeleton MOV 4(R5),R4 ; and pointer to result INC (R3) ; Skip over "%" that caused call MOV (R3),R2 ; Get pointer value MOVB MCR-1(R2),R2 ; and character from there ; Should be param # 1-9 SUB #'0,R2 ; Try it as number -"0" BLE NOTNUM ; <="0" then not number CMP R2,#9. ; >"9" BGT NOTNUM ; Something besides a number MOV R2,R1 ; Check for a null parameter in which ; case entire parameter spec is skipped MUL #PARLNG,R1 ; Compute address of first character TSTB P-PARLNG(R1) ; of this parameter << P(1,R1) >> BEQ SKPFWD ; Null parameter skip to "%" ; ; Now check for a prefix character %n,xxxxxxx% or %n=xxxxxx% ; if either we insert the prefix characeter now because we know ; the parameter is non null. ; MOV #1,R5 ; Index into parameter string MOV (R3),R0 ; Get character to inspect CMPB MCR(R0),#', ; Is it a comma? BEQ 1$ ; Branch if it is CMPB MCR(R0),#'= ; Not a comma, is it an equal sign? BNE 2$ ; Branch if it is not ; ; Here there is a prefix character insert it ; 1$: INC (R3) MOV (R3),R0 MOV (R4),R1 MOVB MCR-1(R0),CMD-1(R1) INC (R4) ; ; Here we set the default starter character for an extender field ; into DEFCH. ; 2$: MOV (R3),R0 MOVB MCR(R0),DEFCH ; ; Get the next character from the parameter ; NXTCHR: MOV R2,R1 MUL #PARLNG,R1 ADD R5,R1 ; ; If null, parameter is ended - go check for extenders ; TSTB P-PARLN1(R1) BEQ 2$ MOV (R4),R0 MOVB P-PARLN1(R1),CMD-1(R0) ; ; Copy the parameter character ; if it matches the default starter then default is not wanted ; so set default extender seen ; CMPB CMD-1(R0),DEFCH ; Default starter? BNE 1$ ; No - branch MOVB #-1,SEEN ; Yes - set flag 1$: INC (R4) INC R5 BR NXTCHR ; Process next character ; ; Parameter is done, is extender field required ; 2$: INC (R3) MOV (R3),R0 ; ; There is no extender field to give anyway %n(,or=ornull)% ; CMPB MCR-1(R0),#'% ; Is it a "%"? BEQ SKPFWD ; Yes - skip to the next "%" TSTB SEEN ; Extender? BLT SKPFWD ; Yes - skip to the next "%" ; ; Add default extender until we reach "%" ; 3$: MOV (R3),R0 MOV (R4),R1 MOVB MCR-1(R0),CMD-1(R1) INC (R4) INC (R3) MOV (R3),R0 CMPB MCR-1(R0),#'% ; End of extender? BNE 3$ ; No - continue adding characters ; ; Here skip until (R3) points to '%' in skeleton ; SKPFWD: 4$: MOV (R3),R0 CMPB MCR-1(R0),#'% BNE 5$ ; Branch if End-of-string reached JMP DONE ; FINISH UP ; JGD4 5$: INC (R3) ; Go to next byte BR 4$ ; Tally ho! ; ; Out of range for 1-9 is it %$ meaning altmode/escape ; NOTNUM: MOV (R3),R0 ; Get next character CMPB MCR-1(R0),#'$ ; Is it the "escape" character? BNE NOTESC ; No - branch MOV (R4),R0 MOVB #15,CMD-1(R0) ; MOVE IN SO IT WILL PROMPT INC (R4) INC NOSTOP ; DO NOT STOP CCL UNTIL COMMAND TO EXITS BR DONE ; ;JGD4 ; Process "%B%" - ring bell on exit from ccl if found ;JGD4 ; ;JGD4 NOTESC: ;JGD4 CMPB MCR-1(R0),#'B ; WAS IT %B%? ;JGD4 BNE NOTBEL ; IF NO, CHECK FOR %% ;JGD4 INC RING ; SHOW WE MUST RING ;JGD4 ; INC (R4) ; BACK UP OVER 'B' ;JGD4 BR DONE ; SKIP TO NEXT % AND CONTINUE ;JGD4 ; ; Process "%%" - ie the character "%" is to be inserted ; NOTBEL: CMPB MCR-1(R0),#'% ; Was it %% meaning % BNE NOTPCT ; No - branch MOV (R4),R0 ; Yes - insert "%" in output buffer MOVB #'%,CMD-1(R0) INC (R4) BR DONE ; ; Process "%G%" - ie GROUP of [GROUP,MEMBER] ; NOTPCT: CMPB MCR-1(R0),#'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 MCR-1(R0),#'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 (R4),R0 ADD #CMD-1,R0 MOV #1,R2 ; Do not suppress leading zeroes CALL $CBTMG ADD #3,(R4) ; Length of group or member code BR DONE ; ; Process "%U%" - ie UIC ; NOTMEM: CMPB MCR-1(R0),#'U ; Is it UIC? BNE NOTUIC ; No - branch MOV R3,-(SP) ; Put UIC string in output line MOV DUIC,R3 MOV (R4),R2 ADD #CMD-1,R2 MOV R4,-(SP) MOV R2,-(SP) CLR R4 CALL .PPASC SUB (SP)+,R2 MOV (SP)+,R4 MOV (SP)+,R3 ADD R2,(R4) BR DONE ; ; Process "%T%" - The terminal identifier (ie TT7) ; NOTUIC: CMPB MCR-1(R0),#'T ; Is it a terminal ID request? BNE NOTTRM ; No - branch MOV (R4),R0 ; Output terminal ID ADD #CMD-1,R0 MOV R0,-(SP) MOVB TERMIN,(R0)+ MOVB TERMIN+1,(R0)+ ; Output 2nd device byte (should be "T") MOVB UNIT,R1 MOV R1,R2 ASR R2 ; Get high order unit # ASR R2 ASR R2 BIC #^C<7>,R2 ; Range 0-7 BIC #^C<7>,R1 TST R2 ; Only output high order digit if significant BEQ 1$ ; Not - branch ADD #'0,R2 ; Convert to printing digit 0 - 7 MOVB R2,(R0)+ ; Add to output line 1$: ADD #'0,R1 ; Convert lower to printing digit MOVB R1,(R0)+ ; Add to output line SUB (SP)+,R0 ; Calculate length of terminal ID string ADD R0,(R4) ; Update length of output buffer BR DONE ; ; Process %A - Insert all parameters ; NOTTRM: CMPB MCR-1(R0),#'A ; Is it the whole command line? BNE NOTALL ; No - branch MOV #OMCR,R1 ; Get address of command line arguments MOV (R4),R2 ; Get index into CMD 10$: MOVB (R1)+,CMD-1(R2) ; Transfer a bite BEQ 20$ ; Stop on the null bite INC R2 ; Next one please INC (R4) ; Do this one also CMP R2,#79. ; Are we at the end of the output buffer? BLT 10$ ; No - continue RETURN ; Return - command line too long 20$: BR DONE ; All done NOTALL: BR DONER ; Not a valid terminal character ; ; Here we skip final '%' in skeleton and return to mainline ; DONE: INC (R3) ; Skip last detected character (%) DONER: RETURN .END