.TITLE LOOKUP .IDENT /V02.1/ .enabl lc ; Not a cheap teletype ; ; This is derived from a (deceased) FORTRAN program so please excuse the ; odd names of variables and PSECTs. ; ; This subroutine is entered with a file open on LUN 1. ; This file must be in the specified form for a CCL command set. ; ; ADDENDUM FOR V2.0A ; ; ; Major revision of LOOKUP -- 3/81, by P. Sorenson ; Extensive modification has been made to the FORTRAN common PSECT .$$$$. ; with all parameters now being variable length strings identified ; by a corresponding pointer (e.g. Parameter 0 pointed to ; by PNTR0). Additionally, order of variables has been rearranged ; for no particularly good reason; 2 new parameters have been added, "B", ; which points to the first major section of the command specifiers up to ; a major delimiter (currently only space), and 'C' which points to ; the remainder of the command specifiers (from B on, without delimiter). ; Finally, added an internal "file" to implement a more flexible and ; easily altered set of internal functions then allowed by DCL; ; use of this "file" is keyed to all program elements by setting the ; LUN to 0. ; ; MODIFIED: ; ; PRS01 5/5/81 CHANGE HANDLING OF KEYWORD FROM 8 BYTE ; LONG STRING TO VARIBLE LENGTH STRING ; POINTED TO BY 'KEYB'. SUPPORT '0' FOR MAX. ; STRING LENGTH TO DISABLE MAX. KEYWORD STRING ; LENGTH CHECK. ; ; JGD09 Oct 23,1981 Modify so CCL can be a full CLI. ; .MCALL GET$ SPA = 40 ; Blank CR = 15 ; LF = 12 ; ESC = 33 ; .PSECT .$$$$.,rw,d,ovr,gbl ; ; The common data area for the three routines FIXUP,LOOKUP and the MAIN proram. ; CMD: .blkb 80. ; Output command line CLIBF: .BLKW 3 ; Modify for Full alternate CLI support :JGD09 MCRL: .word 0 ; Length of mcr line MCR: .blkb 80. ; MCR line KEYL: .word 0 ; Length of keyword KEYB: .WORD MCR ; Keyword buffer address ;PRS01 P: ; Buffer for parameters .BLKB 256. ; Dfn parameter buffer, 256 should be enough NEXTP: .WORD P ; Points to next free spot in P PNTR0: .WORD 0,0 ; Parameter 0 pointer PNTR1: .WORD 0,0 ; Parameter 1 pointer PNTR2: .WORD 0,0 ; Parameter 2 pointer PNTR3: .WORD 0,0 ; Parameter 3 pointer PNTR4: .WORD 0,0 ; Parameter 4 pointer PNTR5: .WORD 0,0 ; Parameter 5 pointer PNTR6: .WORD 0,0 ; Parameter 6 pointer PNTR7: .WORD 0,0 ; Parameter 7 pointer PNTR8: .WORD 0,0 ; Parameter 8 pointer PNTR9: .WORD 0,0 ; Parameter 9 pointer PNTRA: .WORD 0,0 ; Parameter A pointer PNTRB: .WORD 0,0 ; Parameter B pointer PNTRC: .WORD 0,0 ; Parameter C pointer PMIN: .WORD 0 ; Min # of parameters allowed PMAX: .WORD 0 ; Max # of parameters to prompt for .PSECT $VARS,RW,D,CON,LCL LMIN: .WORD 0 ; Minimum length of keyword LMAX: .WORD 0 ; Maximum length of keyword ;PRS01 .PSECT $CODE1,RW,I,CON,LCL ; ; Entry to get next record for processing. ; Note the effect of null records and of records with junk in the first ; 5 columns is undefined, but unlikely to be nasty in the extreme. ; worst case is CCL could spin on incomplete data set of CCL spec. ; LOOKUP:: ; External entry point NXTLIN: CALL GETLIN ; Fetch line from correct file BCC START ; Branch if read OK EOF: CLR R0 ; Return EOF on input file RETURN ; ; The result of a failure to find the keyword which is presented ; in the buffer pointed to by KEYB of length KEYL bytes is to return ; a 0 ( FORTRAN false). ; ; The first character of the line is checked for a "$" symbol ; if it is not that then the line is not a keyword line and can be ; bypassed in our search. ; START: MOV FDB+F.URBD+2,R0 ; Pointer to input line CMPB (R0)+,#'$ ; Is it "$"? BNE NXTLIN ; No, get next line ; ; The 4 number fields of a "$" record are now obtained with no ; checking and an enormous degree of hopefulness. ; They are in turn: ; length minimum match ; length max ; parameter count minimum ; parameter count required if no params specified ; MOV #'0,R2 ; Set up to convert ascii to binary # MOVB (R0)+,R1 ; Get minimum match length for name SUB R2,R1 ; Make integer MOV R1,LMIN ; Set MIN length MOVB (R0)+,R1 ; Set up to handle max. length ;PRS01 SUB R2,R1 ; Convert to integer ;PRS01 BLE 5$ ; Let "0" suppress maximum keyword length check ;PRS01 MOV R1,LMAX ; Save max. length ;PRS01 BR 6$ ;PRS01 5$: MOV #80.,LMAX ; Set LMAX>>>0 to suppress max. length check ;PRS01 6$: ;PRS01 MOVB (R0)+,R1 ; Get minimum parameters to process SUB R2,R1 MOV R1,PMIN MOVB (R0)+,R1 ; Get minimum pameters that must be non-NULL SUB R2,R1 MOV R1,PMAX ; And last of the numbers. ; ; At this point, R0 points to start of master string to match with ; keyword. Set R1 to master word length; R2 to start of keyword; ; and R3 to length of keyword. ; ; First matching criteria is that have at least minimum # characters ; necessary (LMIN) in the keyword. ; MOV KEYL,R3 ; Fetch keyword length CMP LMIN,R3 ; Check keyword length against min # to match BGT NXTLIN ; Branch if not at least LMIN characters CMP LMAX,R3 ; Check keyword length against max. ;PRS01 BLT NXTLIN ; Branch if more then max. characters in keyword ;PRS01 MOV FDB+F.NRBD,R1 ; Fetch # bytes read SUB #5,R1 ; Subtract out the 4 numbers already handled ;PRS01 ; and the "$" leading character. ;PRS01 MOV KEYB,R2 ; Fetch start address of keyword ;PRS01 10$: CMPB (R0)+,(R2)+ ; Do characters match? BNE NXTLIN ; Branch if no, get new master string DEC R1 ; Set R1 to # characters left in master string BLE 20$ ; Branch if 0, all done DEC R3 ; Set R3 to # characters left in keyword BGT 10$ ; Branch if still more keyword to match up 20$: MOV #-1,R0 ; To get here must have matched, return success RETURN .END