.MCALL .MODULE .MODULE INDPAR,VERSION=03,COMMENT= ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .ENABL GBL,LC .SBTTL Macro definitions .MCALL GCLDF$, DEFIN$, RT5DF$ GCLDF$ ;Define GCML block offsets and symbols DEFIN$ ;Definitions for IND files RT5DF$ ;RT specific definitions OPSECT INDPAR ;+ ;Local data ;- .NLIST BEX COMSTR: .ASCII " COMMAN " ; VARIABLE TO WRITE STRING INTO VARSTR: .ASCIZ ' COMMAN " " P0 P1 P2 P3 P4 P5 P6 P7 P8 P9' .EVEN .LIST BEX PARILN: .BLKW ;Length of input string PARIAD: .BLKW ;Address of input string PARSLN: .BLKW ;Substring length PARSAD: .BLKW ;Substring address PARCLN: .BLKW ;Control string length PARCAD: .BLKW ;Control string address .SBTTL INDPAR - Indirect parameter parsing. ;+ ;INDPAR ;This routine handles parameter passing when the nesting depth increases. ; ; Input: R0 -> GCML control block for command file ; ; Output: None ; ; Actions: Stores the command string, minus the leading "@" character, ; into the local symbol "COMMAN", then calls .PARSE with a ; prestored command line. ; ;First, locate the command string and define the variable "COMMAN". ;- .ENABL LSB INDPAR:: SAVE MOV #COMSTR,R0 ;Point to the prestored string " COMMAN " MOVB #,SYMTP ;Setup symbol type to string CALL PRSYM ;Find or define the string symbol RESTOR ;Get the address of the GCML block MOV G.CMLD(R0),R1 ;Get the length of the command line DEC R1 ;Ignore the "@" character at the beginning MOV G.CMLD+2(R0),R0 ;Get the address of the command line INC R0 ;Point beyond @ character MOV R0,R2 ;Save a copy of the string address MOV R1,R3 ;Save a copy of the string length 1$: CMPB (R2)+,# ;Is this the start of a comment? BEQ 2$ ;Branch if yes. Ignore comments DEC R3 ;Decreament character count BNE 1$ ;Loop until done with the scan 2$: SUB R3,R1 ;Adjust end of line by # of char in comment CALL ASVALS ;Now assign the value to the variable BCS OVFLO ;Error - symbol table overflow ;+ ;The command string has been stored in "COMMAN". Now complete by assigning ;individual parts to variables. ;- 3$: MOV #VARSTR,R0 ;Point to the prestored command string BR PARSE ;AND parse string .DSABL LSB .SBTTL PARSE - Indirect .PARSE handling ;+ ;PARSE ;Routine to handle the .PARSE directive. First, find the two input string ;parameters (the string to be parsed and the parsing control string). ; ; Input: R0 -> command string ; ; Output: none ; Note that on return, a JMP will be made to INDRD ;- .ENABL LSB PARSE:: CLR SPSSL+SEVAL ;Initialize CALL GSVAL ;Get the string parameters of the first string MOV R1,PARILN ;Store the length of the input string BEQ 2$ ;Branch if null string MOV #TERM,R2 ;Get the address of the buffer to write MOV R2,PARIAD ;Store string address 1$: MOVB (R5)+,(R2)+ ;Move the string into our local buffer DEC R1 ;One less character to move BHI 1$ ;Loop until done 2$: CALL GSVAL ;Get the string parameters of the second MOV R5,PARCAD ;Store the control string address MOV R1,PARCLN ;Store the control string length BNE 3$ ;String is not null TRAP ERNUL ;Error - control string is null ;+ ;Get variables and insert parts of the string according to the parsing ;algorithm. ;- 3$: CALL $GNBLK ;Get the next non-blank character BCS 11$ ;Branch if end of line was seen CMPB R2,# ;Beginning of a comment? BNE 5$ ;No, go process 4$: TSTB @R0 ;End of line? BEQ 12$ ;Branch out if yes CMPB (R0)+,# ;End of a comment? BNE 4$ ;No, loop until found BR 3$ ;Yes, go handle the following character ;+ ;Find string parameters to use for the next symbol. ;- 5$: MOVB @PARCAD,R1 ;Get deliminator character CMPB PARCLN,#<1> ;Is this the last character? BEQ 6$ ;Branch if yes INC PARCAD ;Point to next control character DEC PARCLN ;Decreament count 6$: MOV PARIAD,R2 ;Get the address of the input string MOV PARILN,R3 ;Get the length of the input string BEQ 9$ ;Branch if done 7$: DEC R3 ;Decreament length count CMPB (R2)+,R1 ;Is this the delimiter we are looking for? BEQ 8$ ;Yes, we have the substring TST R3 ;End of string? BNE 7$ ;No, continue scanning for the delimiter INC R2 ;Modify ptr as if encountered delimiter. ;+ ;End of substring found. Calculate parameters - length and starting ;address, and setup any other parameters required before storing the ;substring. ;- 8$: MOV R3,PARILN ;Store the updated string length MOV PARIAD,R3 ;Get the previous string starting address MOV R2,PARIAD ;Store the new string starting address DEC R2 ;Point to string ending character SUB R3,R2 ;Calculate length of string MOV R2,PARSLN ;Store the string length MOV R3,PARSAD ;Store the string address INC SPSSL+SEVAL ;Update BR 10$ ;Insert substring to variable ;+ ;Get variable and insert substring. ;- 9$: CLR PARSLN ;No length for the output variable 10$: SUB #<2>,R0 ;Point to space preceeding the start of symbol MOVB #,SYMTP ;Setup the symbol type code CALL PRSYM ;Get the symbol information SAVE ;Save the pointer to the command for now MOV PARSAD, R0 ;Get the pointer to the string to insert MOV PARSLN,R1 ;Get the length of the string to insert CALL ASVALS ;Assign the value RESTOR ;Restore the pointer to the command BCC 3$ ;Loop and handle the next one if fine OVFLO: TRAP ERSOV ;Symbol table overflow ;+ ;End of command seen. Move rest of string into the last variable ;- 11$: MOV PARILN,R1 ;Get the length of leftover BEQ 12$ ;Branch if no leftover ADD PARSLN,R1 ;Get the length of the last string INC R1 ;Adjust for the terminator we removed MOV PARSAD,R0 ;Get the address of the last string CALL ASVALS ;Setup the string value BCS OVFLO ;Error - Symbol table overflow 12$: JMP INDRD ;Read the next line .DSABL LSB ROUNDUP ;Check for overflow and roundup .END