.TITLE FNDCMD - SCAN FOR COMMAND .SBTTL FNDCMD - TITLE PAGE .IDENT /V01.00/ .ENABL LC ; ; Scan for matching command in CCS tables. ; ; Version: V01.00 ; ; Author: R.W. Stamerjohn ; ; Modification history: ; ; V01.00 RWS 14-Oct-1984 Initial version .SBTTL FNDCMD - 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 FNDCMD ;Entry point ; ; Global references: ; ; CCS subroutines. ; .GLOBL GETLIN ;Get next input line. ; ; System subroutines ; .GLOBL .TPARS ;Parse command line ; ; CCS data areas. ; .GLOBL KEYL ;Length of command keyword .GLOBL KEYB ;Address of command keyword .GLOBL PMIN ;Minumum number of parameters .GLOBL PMAX ;Maxumum number of parameters ; ; .TPARS variables. ; .GLOBL .PSTCN ;Length of parsed string .GLOBL .PSTPT ;Address of parsed string .GLOBL .PCHAR ;Parsed character .ENABL CRF .SBTTL FNDCMD - PARSING TABLE ISTAT$ FNDTBL,FNDKEY STATE$ ST.00 ;Search for leading $ TRAN$ <'$> STATE$ ST.01 ;Check for minimum keyword length TRAN$ $DIGIT,,PRLMIN STATE$ ST.02 ;Check for maximum keyword length TRAN$ $DIGIT,,PRLMAX STATE$ ST.03 ;Store minumum parameters TRAN$ $DIGIT,,PRPMIN STATE$ ST.04 ;Store maximum parameters TRAN$ $DIGIT,,PRPMAX STATE$ ST.05 ;Check for keyword match TRAN$ $STRNG,$EXIT,PRKEYW STATE$ .SBTTL FNDCMD * SCAN FOR COMMAND ; ;+ ; This routine searches the current file for a record which matches the ; keyword. A keyword record starts with a dollar ($) in column 1. Such ; records have the following format: ; ; $keyword ; ; One digit minimum keyword length ; One digit maximum keyword length ; One digit minumum required parameters ; One digit maxumum parameters ; ; Call by: JSR PC,FNDCMD ; ; File open on input lun and KEYB/KEYL set to keyword ; address and size. ; ; Exit with: CC = Keyword match made, PMIN/PMAX set. ; CS = Keyword not found in file. ;- FNDCMD:: ;Ref. label CALL GETLIN ;Get next input line BCS 9999$ ; If CS - no line found ; ; We now have R3 = start of input line and R4 = size of line. Setup ; and parse to see if this line matches our command. ; CLR R1 ;Ignore blanks, exact match MOV #FNDKEY,R2 ;Set key table address MOV #FNDTBL,R5 ;Set state table address CALL .TPARS ;Parse the command line BCS FNDCMD ; If CS - try another line 9999$: 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 ; .PCHAR Last parsed character from $DIGIT ;- ; ; *** PRLMIN *** Process minumum keyword length ; PRLMIN: MOV .PCHAR,R0 ;Get minumum length digit SUB #<'0>,R0 ;Convert to binary CMP KEYL,R0 ;Is the keyword at least this long? BLT REJECT ; If LT - no, error RETURN ;Return to parser ; ; *** PRLMAX *** Process maximum keyword length ; PRLMAX: MOV .PCHAR,R0 ;Get minumum length digit SUB #<'0>,R0 ;Convert to binary BEQ 1000$ ; If EQ - ignore check CMP KEYL,R0 ;Is the keyword longer than this? BGT REJECT ; If LT - no, error 1000$: RETURN ;Return to parser ; ; *** PRPMIN *** Process minumum number of parameters ; PRPMIN: MOV .PCHAR,R0 ;Get minumum length digit SUB #<'0>,R0 ;Convert to binary MOV R0,PMIN ;Store minumum parameters RETURN ;Return to parser ; ; *** PRPMAX *** Process maximum number of parameters ; PRPMAX: MOV .PCHAR,R0 ;Get minumum length digit SUB #<'0>,R0 ;Convert to binary MOV R0,PMAX ;Store minumum parameters RETURN ;Return to parser ; ; *** PRKEYW *** Process keyword. ; PRKEYW: MOV KEYL,R0 ;Get length of master key CMP R0,.PSTCN ;Is command longer than parsed verb? BLE 1000$ ; If LE - no, skip MOV .PSTCN,R0 ;Use this length for compare 1000$: MOV KEYB,R1 ;Get address of command MOV .PSTPT,R2 ;Get address of keyword 1100$: CMPB (R1)+,(R2)+ ;Are the two equal? BNE REJECT ; If NE - no, reject SOB R0,1100$ ;Loop till done RETURN ;Return success to parser REJECT: ADD #2,(SP) ;Take skip (error) return RETURN ;Return to parser .END