.TITLE FNDPRM - SCAN FOR PARAMETERS .SBTTL FNDPRM - TITLE PAGE .IDENT /V01.00/ .ENABL LC ; ; Scan command line into component parameters ; ; Version: V01.00 ; ; Author: R.W. Stamerjohn ; ; Modification history: ; ; V01.00 RWS 14-Oct-1984 Initial version .SBTTL FNDPRM - DECLARATIONS .DSABL GBL .DSABL CRF ; ; Macro library calls: ; ; Define TPARS macros. ; .MCALL ISTAT$ ;Define initial state .MCALL STATE$ ;Define state transition .MCALL TRAN$ ;Define transition ; ; Global declarations: ; .GLOBL FNDPRM ;Entry point ; ; Global references: ; ; System subroutines ; .GLOBL .TPARS ;Parse command line ; ; CCS data areas. ; .GLOBL KEYB ;Pointer to start of command key .GLOBL KEYL ;Length of command key .GLOBL PNTR0 ;Leading command switches .GLOBL PNTR1 ;Start of %1-9 parameters .GLOBL PNTRA ;Command line minus command key .GLOBL PNTRB ;Command line up to space .GLOBL PNTRC ;Command line after space .GLOBL PINDX ;Index to defined parameters ; ; .TPARS variables. ; .GLOBL .PSTCN ;Length of parsed string .GLOBL .PSTPT ;Address of parsed string .ENABL CRF .SBTTL FNDPRM - PARSING TABLE ISTAT$ PRMTBL,PRMKEY STATE$ ST.00 ;Parse keyword TRAN$ $STRNG,,PRKEYW STATE$ ST.01 ;Set %A parameter, skip any blank TRAN$ !SLASH,ST.02,PRPRM0 TRAN$ $BLANK,ST.02,PRPRMA TRAN$ $LAMDA, ,PRPRMA STATE$ ST.02 TRAN$ $EOS ,$EXIT TRAN$ !UICSP,ST.02 TRAN$ $BLANK,ST.02,PRMAJR TRAN$ <'=> ,ST.02,PRMINR TRAN$ <',> ,ST.02,PRMINR TRAN$ $ANY ,ST.02 STATE$ SLASH ;Parse slash - all up to space/EOL TRAN$ <'/> STATE$ SL.01 TRAN$ $BLANK,$EXIT TRAN$ $EOS ,$EXIT TRAN$ $ANY ,SL.01 STATE$ UICSP ;Parse out any [...] fields TRAN$ <'[> STATE$ UI.01 TRAN$ $EOS ,$EXIT TRAN$ <']> ,$EXIT TRAN$ $ANY ,UI.01 STATE$ .SBTTL FNDPRM * SCAN FOR COMMAND ; ;+ ; This routine scans the input command line into its component parts. ; The following pointer pairs (length, address) are setup: ; ; KEYL/B Length/address of command keyword ; PNTRA Length/address of command minus keyword ; PNTRB Length/address of command from keyword to space ; PNTRC Length/address of command from space to EOL ; PNTR0 Length/address of any leading switches ; PNTRn Length/address of parameters (space,equal,comma) ; ; Call by: JSR PC,FNDPRM ; ; R4 = Start of command buffer. ; R3 = Length of command buffer. ; ; Exit with: CC = Command line parsed. ; CS = No keyword found in command. ;- FNDPRM:: ;Ref. label ; ; Zero the parameter pointers from PNTR0 through PNTRC. ; MOV #PNTR0,R0 ;Get start of parameters 1000$: CLR (R0)+ ;Clear a parameter length CLR (R0)+ ;Clear a parameter size CMP #PNTRC+4,R0 ;Are we done BNE 1000$ ; If NE - no, loop ; ; We now have R4 = start of input line and R3 = size of line. Setup ; and parse to see if this line matches our command. ; MOV #1,R1 ;Blanks have meaning. MOV #PRMKEY,R2 ;Set key table address MOV #PRMTBL,R5 ;Set state table address CALL .TPARS ;Parse the command line RETURN ;Return to caller .SBTTL PR???? * ACTION ROUTINES ;+ ; These are the action routines for the keyword search. They assume the ; following .TPARS variables are setup. ; ; .PSTCN Count of characters matched ; .PSTPT Address of characters matched ;- ; ; *** PRKEYW *** Parse out keyword ; PRKEYW: MOV .PSTCN,KEYL ;Set length of keyword MOV .PSTPT,KEYB ;Set address of keyword RETURN ;Return to parser ; ; *** PRPRM0 *** Set length of leading switches and %A. Preset %B, %1. ; PRPRM0: MOV .PSTCN,PNTR0+0 ;Set length of switches MOV .PSTPT,PNTR0+2 ;Set address of switches MOV .PSTCN,PNTRA+0 ;Set length of command ADD R3,PNTRA+0 ; ... MOV .PSTPT,PNTRA+2 ;Set start of command BR PRPRMB ; and preset %B, %1 ; ; *** PRPRMA *** Set remaining command line as %A. Preset %B, %1. ; PRPRMA: MOV R3,PNTRA+0 ;Set length of remaining command MOV R4,PNTRA+2 ;Set address of remaining command PRPRMB: MOV R3,PNTRB+0 ;Set length of remaining command MOV R4,PNTRB+2 ;Set address of remaining command MOV #PNTR1,R0 ;Get address of %1 MOV R3,(R0)+ ;Set length of remaining command MOV R4,(R0)+ ;Set address of remaining command MOV R0,PINDX ;Index to %2. RETURN ;Return to parser ; ; *** PRMAJR *** Set major separtor. Adjust %B length and set %C. ; PRMAJR: TST PNTRC+0 ;Have we already set %C? BNE PRMINR ; If NE - yes, skip MOV R3,PNTRC+0 ;Set length of remaining command MOV R4,PNTRC+2 ;Set address of remaining command SUB R3,PNTRB+0 ;Adjust %B length DEC PNTRB+0 ; including separtor ;Fall into PRMINR ; ; *** PRMINR *** Set minor separtor. Adjust previous and set next. ; PRMINR: MOV PINDX,R0 ;Get index into commands CMP #PNTRA,R0 ;Have we gone far enought BEQ 1000$ ; If EQ - yes, no more SUB R3,-4(R0) ;Adjust last parameter size DEC -4(R0) ; including separtor MOV R3,(R0)+ ;Store length of remainder MOV R4,(R0)+ ;Store address of remainder MOV R0,PINDX ;Store index back again 1000$: RETURN ;Return to parser .END