.TITLE FIXUP .IDENT /14JAN82/ .enabl lc ; More than a teletype ; ; 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. ; ; ADDENDUM: ; ; This version of FIXUP is for use with CCL V7.0B. Extensive ; revision of .PSECT .$$$$. (former FORTRAN common) and a new ; method for defining parameters have been implemented. FIXUP ; has been extended to include two new key characters in its ; repertoire, "\" and "?". An option for parameter substitution ; has been added to the standard CCL file action line, "\string". ; If this argument is included in a parameter substitution field ; and the parameter is null, the character string following the "\" ; will be inserted instead. For example, by defining a command: ; ; $4412DUMP ; ?1File ; ?2To ; *RUN $DMP/PRM="%2.DMP\TI:%%1=%" ; ; and giving it the MCR line: ; ; DUMP MYFILE.BIN ; ; CCL would not issue a prompt for the 2nd parameter since only 1 needed ; (minimum), and FIXUP would substitute TI: for the null 2nd parameter. ; The new command to spawn to MCR would end up being: ; ; RUN $DMP/PRM="TI:=MYFILE.BIN" ; ; An additional CCL file action line has also been included: ; ; %?<\string2>% ; where: ; = Parameter specifier (0-9,A-C) ; ? = Key character to evaluate status ; (null or not) of parameter pn. ; = Character string to be inserted ; into command line if the parameter ; is not null. ; <\string2> = Character string to be inserted ; into command line if the parameter ; is null. ; For example, given: ; ; $3300UIC ; *SET /UIC%1?=[%%1%%2,]% ; ; The first parameter substitution field (%1?=[%) tests if parameter ; 1 was entered. If it was, insert "=["; if not, insert nothing. ; The next paramater substitution field (%1%) either inserts parameter 1 ; or not, and the final field (%2,]%) inserts parameter 2 preceeded by ; "," and ended with ] (unless ] in parameter 2) provided a 2nd parameter ; was entered. Thus, the following 3 MCR lines would be interpretted as: ; ; UIC = SET /UIC ; UIC 100,2 = SET /UIC=[100,2] ; UIC 100 2 = SET /UIC=[100,2] ; ; ; Paul Sorenson -- 3/81 ; Dept. of Physiol. ; Mich. State Univ. ; E. Lansing, MI 48824 ; ; J. DOWNWARD 22-MAR-81 Fix problems introduced by above ; JGD04 enhancements. 1) Ensure that task ; started by CCL prompts on exit unless ; %$ form is used., 2) add %R to replace ; the old %B (ring bell on exit) since ; %B seems to have a better use now. ; ; 23-MAR-81 Added %D (debug). If encountered the ; JGD05 line will automatically be considered ; too long (even if it isn't) and will ; be printed out so one can see what ; the line sent to MCR will look like. ; ; JGD06 Added %Q, (quit). Exit CCL without ; sending command to MCR if the default ; substitution filed is null and a ; required input parameter is not present ; JGD07 Added %P, (print) print the action ; line to TI: rather than sending it ; to MCR. Like %D but not additional ; message is produced. %P should be ; at end of CCL command string. ; ; JGD08 Add a space as a prefix character. ; This is done for RSX11M V4.0. The ; new INS /CMD="XXX cmdlin" requires ; a space between XXX and 'cmdlin' but ; some RSX utilities will not accept ; a space following the XXX if 'cmdlin' ; is a null (ie EDI). Thus the one can ; now have a CCL template line: ; *INS/CMD="XXX%A %" ; ; JGD09 Modify so that CCL can be a CLI ; Oct 23,1981 just like DEC's DCL. ; ; P. Sorenson 18-Jun-82 Moved setting up terminal string ; PRS04 "TTnn"/"VTnn" to main line CCL code ; for new connect to task processing. ; %T will use this ASCIZ string. ; ; Jan 83 ; PRS05 Redefine psect's ; ; PRS06 Add new parameter's %1a%-%9z% if ; support CCL V9.0 parameter parsing. ; ; Mar 83 ; PRS07 Fix quirks in fixing up MCR lines ; using %A% -- suppress multiple spaces; ; Allow support for both V9 parsing and ; V8 parsing to co-exist ; ; Setup miscellaneous definitions ; SPA = 40 ; Blank CR = 15 ; LF = 12 ; ESC = 33 ; PCNT = 45 BSLASH = 134 QNMRK = 77 COMMA = 54 EQUAL = 75 DOLLAR = 44 TERM = 124 GROUP = 107 MEMBER = 115 UIC = 125 ; .PSECT $IDATA,RW,D,CON,LCL,REL ;PRS05 DEFUIC: .BLKB 9. ; Space to hold ASCII default uic DEFCH: .BYTE 0 ; This is the character at the start ; of a default extender field. .PSECT $CODE1,RO,I,LCL,CON,REL ;PRS05 ; ; Entry here occurs for each occurance of the parameter flag ; character "%" in the template line and is pointed to by R2. ; The new command is being generated into CMD, with R0 pointing to ; next available slot in CMD and R1 set to # available bytes left in CMD ; (only allowed 79 for an MCR line). R3 is maintained as # bytes left to ; process in template line, while R4 and R5 are used as pointers to ; the parameters being accessed. ; FIXUP:: ; External entry point CLRB DEFCH ; For now, signal no default extender field INC R2 ; Skip template pntr over the "%" that caused DEC R3 ; call, readjust # bytes left to look at also BGT 5$ ; Branch if still stuff in template JMP EXIT ; Else, return to caller 5$: MOVB (R2),R4 ; Get parameter designator; character after % SUB #60,R4 ; Convert ASCII 0-9 to binary # BLT NOPARM ; Branch if < 0, no parameter # BEQ 9$ ; Branch if = 0, fill in %0% ;PRS07 CMP R4,#10. ; Check if < 9 ;PRS07 BGE 8$ ; Branch if not, could be A-C ;PRS07 DEC R4 ; Convert 1-9 to 0-8 ;PRS07 ASL R4 ; Start computing offset from "PNTR1" ;PRS07 BR 10$ ; and continue on ;PRS07 8$: ;PRS07 SUB #24,R4 ; Convert A-C to -3 to -1 ;PRS07 BGE NOPARM ; Branch if not A-C ;PRS07 CMP R4,#-3. ; Check lower limit ;PRS07 BLT NOPARM ; Branch if not A-C ;PRS07 9$: ;PRS07 DEC R4 ; Make A-C,0 => -4 to -1, ready to... ;PRS07 10$: ;PRS07 ASL R4 ; Compute offset to correct parameter ;PRS07 ASL R4 ; definition block relative to ;PRS07 ADD #PNTR1,R4 ; %1%'s defn. block ;PRS07 INC R2 ; Have valid parameter designator, readjust DEC R3 ; template pointer, byte count and branch BLE ERROR ; if nothing left in template (must be at ; least a trailing % for valid template) CMP R4,#PNTR1 ; Doing %1%-%9% ? ;PRS07 BLO 16$ ; Branch if no, all set ;PRS07 TSTB PRSFLG ; Using V9 parsing rules ? ;PRS07 BEQ 16$ ; Branch if no, all set ;PRS07 ; ;PRS07 ; *** Under new V9 parsing rules, check for subparameter designators ;PRS07 ; ;PRS07 MOVB (R2),R5 ; Grab 2nd character ;PRS06 SUB #140,R5 ; See if "a" - "z" ;PRS06 BLE 16$ ; Branch if < "a", use whole thing ;PRS06 CMP R5,#172 ; Exceed "z" ? ;PRS06 BGE 16$ ; Branch if > "z", use whole thing ;PRS06 INC R2 ; Step template pointer ;PRS06 DEC R3 ; and adjust count left ;PRS06 BLE ERROR ; Branch on problems ;PRS06 CMP R5,4(R4) ; Is subexpression defined ? ;PRS06 BLE 12$ ; Branch if yes ;PRS06 CLR R5 ; Else, show no parameter ;PRS06 BR 17$ ; Pick up proc. @ subst. field check ;PRS06 12$: DEC R5 ; Adjust 1-26 to 0-25 ;PRS06 ASL R5 ; multiply by 4 ;PRS06 ASL R5 ;PRS06 MOV 6(R4),R4 ; Pick up start of 2 word blocks ;PRS06 ADD R5,R4 ; Offset into list ;PRS06 ; 16$: ;PRS06 MOV (R4)+,R5 ; Move parameter length into R5 MOV (R4),R4 ; Recover parameter's start address 17$: ;PRS06 CMPB (R2),#QNMRK ; Doing test parameter field? BNE 19$ ; Branch if no INC R2 ; Step over the '?', DEC R3 ; and adjust # bytes left to scan BLE ERROR ; Branch if nothing left in template -- error CALL SUBST ; Call SUBST to substitute correct field ; dependent on whether param is null or not BR 35$ ; Branch 19$: ;PRS06 TST R5 ; Check parameter length BGT 20$ ; Branch if not null CALL SUBST ; Null parameter, check for substitution field BR 35$ ; Branch to move substitute field into command ; ; Now check for a prefix character %n,xxxxxx%, %n=xxxxxx% or %n xxxxxx% ; Insert the prefix characeter now because we know the parameter is non null. ; ;*** NEW for V9.0. Problems develop in standard "MCR" command lines ;PRS07 ;*** that include multiple spaces. Handling the space prefix character;PRS07 ;*** has changed such that the space prefix will NOT be inserted if ;PRS07 ;*** a space is already preceeding the parameter to be filled in. ;PRS07 ; 20$: CMPB (R2),#COMMA ; Check if next template character a "," BEQ 25$ ; Branch if yes CMPB (R2),#EQUAL ; Check if "=" BEQ 25$ ; Branch if yes ;PRS06 CMPB (R2),#SPA ; Check if next template char a space ; JGD08 BNE 30$ ; Branch if no ;PRS06 CMPB -1(R0),#SPA ; Already starting with space ? ;PRS07 BEQ 30$ ; Branch if yes, skip prefix character ;PRS06 25$: MOVB (R2)+,(R0)+ ; Insert prefix into command DEC R1 ; Readjust # available bytes in command BLT ERROR ; Branch if getting too long DEC R3 ; Readjust # bytes left in template BLE ERROR ; Branch if nothing left ; ; Here we set the default starter character for an extender field ; into DEFCH. ; 30$: CMPB (R2),#PCNT ; Check for "%", end of current template field BEQ 35$ ; Branch if found CMPB (R2),#BSLASH ; Check for "\" BEQ 35$ ; Branch if found MOVB (R2),DEFCH ; Assume its legitimate extender field 35$: ;*** NEW for V9.0. A check will be made for parameters that start with ;PRS07 ;*** a space against the last character in the command line being ;PRS07 ;*** formed...prevent multiple spaces from being inserted into ;PRS07 ;*** the command line. ;PRS07 CMPB -1(R0),#SPA ; Command end in space ? ;PRS07 BNE 37$ ; Branch if no, copy parameter ;PRS07 36$: CMPB (R4),#SPA ; Parameter start with space ? ;PRS07 BNE 37$ ; Branch if no, copy parameter ;PRS07 INC R4 ; Else, skip space ;PRS07 SOB R5,36$ ; Loop until have legit character ;PRS07 BR 40$ ; Branch to finish up, junk skipped ;PRS07 37$: ; Reference label ;PRS07 MOVB (R4),(R0)+ ; Move parameter to new command line DEC R1 ; Readjust # bytes available in new command BLT ERROR ; Branch if getting too long CMPB (R4)+,DEFCH ; Check for default extender character BNE 39$ ; Branch if not CLRB DEFCH ; Signal saw default extender character 39$: SOB R5,37$ ; Continue till move parameter over ;PRS07 ; ; Insert default extender if not encountered in body of parameter ; 40$: TSTB DEFCH ; Check DEFCH status BEQ SKPFWD ; Branch if nothing there 42$: MOVB (R2)+,(R0)+ ; Substitute new stuff in DEC R1 ; Adjust # available bytes in command BLT ERROR ; Branch if getting too long 46$: DEC R3 ; Adjust # bytes left to scan in template BLE ERROR ; Branch if nothing left CMPB (R2),#PCNT ; Pointing to "%" ? 47$: BEQ ENDFLD ; Branch if yes, all done: and link to ENDFLD ; for preceeding code CMPB (R2),#BSLASH ; Pointing at substitution character ("\") ? BNE 42$ ; Branch if no, keep moving stuff over BR SKPFWD ; If yes, skip forward to "%" delimiter ERROR: BR ERREX ; ERROR links to ERREX, error exit ; ; Out of range for 1-9, A-C is it %% meaning insert "%" ; NOPARM: MOVB (R2)+,R4 ; Copy character that got us here DEC R3 ; Adjust # bytes left in template CMP R4,#PCNT ; Was it "%" BNE 20$ ; Branch if no MOVB R4,(R0)+ ; Move % into command line DEC R1 ; Adjust # bytes available in command BLT ERREX ; Branch if too long BR EXIT ; All done, including pointer positioning ; ; handle %$- don't wait for spawned task to exit ; 20$: CMP R4,#DOLLAR ; Check for $ BNE 25$ ; Branch if not ;JGD04 ;**** Remove setting into command line ;PRS06 INCB NOSTOP ; Set NOSTOP non-zero BR EXIT ; Done 25$: CMP R4,#'R ; Is it %R, ring bell on exit ;JGD04 BNE 27$ ; If NE, no ;JGD04 INCB RING ; Set flag to ring bell on exit ;JGD04 BR EXIT ; Done ;JGD04 27$: CMP R4,#'Q ; Is it %Q, quit if req parm missing ;JGD06 BNE 28$ ; If NE, NO ;JGD06 INCB QTFLAG ; Show flag is found ;JGD06 BR EXIT ; Done ;JGD06 28$: CMP R4,#'D ; Is it %D (for debug) ;JGD05 BNE 29$ ; If NE, no ;JGD05 INCB DBGFLG ; Tell CCL this is a DEBUG display ;JGD05 BR EXIT ; Yes, pretend command too long ;JGD05 29$: CMP R4,#'P ; Is it %P (for print line) ;JGD07 BNE 30$ ; If NE, no ;JGD07 INCB PRINT ; Show its a PRINT line ;JGD07 BR EXIT ; Done ;JGD07 ; ; handle %T; note that this does what CCL documentation says should ; happen, e.g. that %T encountered from TT6 should return T6 in ; new command line. The original version of FIXUP looked like it ; would return the full TT6. ; 30$: CMP R4,#TERM ; Check for "T" BNE 40$ ; Branch if not MOV #TSTRNG,R4 ; Fetch start address of terminal id ;PRS04 MOVB (R4)+,(R0)+ ; Move 1st character over (T or V) DEC R1 ; Adjust room left ;PRS04 BLT ERREX ; Branch if it won't fit ;PRS04 INC R4 ; Skip 2nd; see note above 35$: MOVB (R4)+,R5 ; Fetch character ;PRS04 BEQ EXIT ; Exit when transfered string ;PRS04 MOVB R5,(R0)+ ; Copy character ;PRS04 DEC R1 ; Adjust room left ;PRS04 BGE 35$ ; Loop til done or run out of room ;PRS04 BR ERREX ; Branch on insufficient space ;PRS04 ; ; Only valid things left are %G, %M, and %U, anticipate this ; and convert default UIC to ASCII ; 40$: MOV R2,-(SP) ; Save registers used by .PPASC MOV R3,-(SP) MOV R4,-(SP) MOV #DEFUIC,R2 ; Set up start address MOV DUIC,R3 ; Fetch UIC to convert MOV #1,R4 ; Specify no leading 0 suppresion, include [,] CALL .PPASC ; Convert it to ASCII MOV (SP)+,R4 ; Recover registers MOV (SP)+,R3 MOV (SP)+,R2 ; ; Now find out what was required ; 50$: CMP R4,#GROUP ; Was it %G BNE 55$ ; Branch if no MOV #DEFUIC+1,R4 ; Set up start address of group # BR 65$ ; and branch 55$: CMP R4,#MEMBER ; Was it %M BNE 60$ ; Branch if no MOV #DEFUIC+5,R4 ; Fetch start address of member # BR 65$ ; and branch 60$: CMP R4,#UIC ; Was it %U BNE SKPFWD ; Branch if no, don't know what it was MOV #DEFUIC,R4 ; Fetch start address MOV #9.,R5 ; Define # bytes to move BR 66$ ; and branch 65$: MOV #3,R5 ; Define # bytes to move 66$: SUB R5,R1 ; Adjust # available bytes in command BLT ERREX ; Branch if won't fit 68$: MOVB (R4)+,(R0)+ ; Move it to command SOB R5,68$ ; Until done BR EXIT ; Done ; ; Skip forward in template field until hit trailing % ; SKPFWD: 1$: CMPB (R2),#PCNT ; Hit delimiter yet BEQ ENDFLD ; Branch if yes INC R2 ; Adjust template pointer, # bytes left SOB R3,1$ ; in template, and branch if still more to go ; ; Ran out of template or command space ; ERREX: SEC ; Set carry bit and exit BR EXIT ; ; End of template field, skip over trailing % ; ENDFLD: INC R2 DEC R3 ; Caller should determine if anything left ; in template line EXIT: RETURN .PAGE .SBTTL Local subroutine section ; ; SUBST -- substitution routine: Call with R2 pointing to character ; following character in template causing the call, either "?" ; or # (0-9,A-C), and the length of the parameter referenced in R5. ; R0, R1 are used. If the parameter is null (R5=0), substitute ; the address of the character immediately following a "\" and the # of ; characters from there to "%" field delimiter in R4 and R5 respectively. ; If the parameter is not null, substitute the address of the character ; immediately following the ? or parameter number (currently not allowed; ; FIXUP won't call SUBST of non-null parameter without a '?') and the # ; characters from there to either "\" or "%" delimiters into R4 and R5 ; respectively. ; ; It is the caller's responsibility to actually move the string. ; ; On return: ; R0 = unaltered ; R1 = unaltered ; R2 = points to trailing % in template ; R3 = # bytes left in template to scan ; R4 = pointer to string to substitute ; R5 = # bytes in substitute string ; SUBST: MOV R0,-(SP) ; MOV R1,-(SP) ; Save registers going to need MOV R2,-(SP) ; CLR R0 ; CLR R1 ; Signal haven't seen either "%" or "\" 5$: CMPB (R2),#PCNT ; Check if at end of field BEQ 10$ ; Branch if yes CMPB (R2),#BSLASH ; Check if at backslash BNE 7$ ; Branch if no, look again MOV R2,R0 ; Set R0 to address of "\" 7$: INC R2 ; Step over character, DEC R3 ; and adjust # bytes left in template BLE 35$ ; Branch if ran out = error BR 5$ ; Else, keep going till hit "%" 10$: MOV R2,R1 ; Set R1 to point to end of field MOV (SP)+,R4 ; Pop start address of current template field TST R5 ; Was parameter referenced in caller null? BLE 20$ ; Branch if yes MOV R0,R5 ; Copy position of "\" BNE 15$ ; Branch if defined MOV R1,R5 ; Otherwise, use end of field 15$: SUB R4,R5 ; Subtract string start address to compute BR 30$ ; string length, and get out 20$: MOV R0,R4 ; Set string start address to address of "\" BNE 25$ ; Branch if defined CLR R5 ; If not defined, nothing to substitute BR 30$ ; Branch to get out 25$: INC R4 ; Step pointer to character following "\" MOV R1,R5 ; Set R5 to point to end of field SUB R4,R5 ; Subtract start address ; and get out TST R5 ; Test length of substitute string ;JGD06 BGT 30$ ; OK ;JGD06 INCB QUIT ; Show a required field had a null ;JGD06 30$: MOV (SP)+,R1 ; Normal exit, restore registers MOV (SP)+,R0 ; from stack TST R5 ; Check length of substitute string BGT 40$ ; Branch if something to substitute MOV #ENDFLD,(SP) ; Otherwise, reset return point BR 40$ ; before leaving 35$: MOV (SP)+,R2 ; Error exit, restore registers MOV (SP)+,R1 MOV (SP)+,R0 MOV #ERREX,(SP) ; Alter return point before leaving 40$: RETURN .END