.TITLE LOOKUP .IDENT /Y01.3A/ .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. ; .MCALL GET$ ; ; Define buffer lengths and maximum # of parameters allowed ; MAXPAR = 9. ; %1% to %9% PARLNG = 30. ; 30. bytes per %n% PARLN1 = PARLNG+1 ; One more than PARLNG SPA = 40 ; Blank CR = 15 ; LF = 12 ; ESC = 33 ; .PSECT .$$$$.,rw,d,con,ovr,gbl ; ; The common data area for the three routines FIXUP,LOOKUP and the MAIN proram. ; PARAMS: .word 0 ; Max # params to prompt for MCRL: .word 0 ; Length of mcr line KEYL: .word 0 ; Length of keyword MCR: .blkb 80. KEYB: .blkb 8. ; Keyword text space padded P: ; Buffer for parameters .REPT MAXPAR ; For this many parameters .BLKB PARLNG ; This may bytes in length .ENDR CMD: .blkb 80. ; Output command line PMIN: .WORD 0 ; Min # of parameters allowed .PSECT $VARS,RW,D,CON,LCL LMIN: .WORD 0 ; Minimum length of keyword .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: ; ; The result of a failure to find the keyword which is presented ; in the buffer keyb..keyb+7 of length KEYL bytes is to return ; a 0 ( FORTRAN false). ; GET$ #FDB,#INBF,#80. ; Read a line from the file BCC 10$ ; Branch if read OK CLR R0 ; Return EOF on input file RETURN ; 10$: MOV #'0,R2 ; Numeric bias for our computations ; ; 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. ; MOV #INBF,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 (skipped) ; parameter count minimum ; parameter count required if no params specified ; MOVB (R0)+,R1 ; Get minimum match length for name SUB R2,R1 ; Make integer MOVB R1,LMIN ; Set MIN length TSTB (R0)+ ; Ignore MAX length 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,PARAMS ; And last of the numbers. ; ; If the input record was shorter than 13 characters, that is ; "$abcd"+keyword of 8 chars then ; pad it out with spaces until it is at least that length so ; the comparison is easier. ; MOV FDB+F.NRBD,R1 ; Size of record read CMP R1,#13. ; Min chars needed BGE 30$ ; Yes MOV #13.,R4 SUB R1,R4 ; Number of fill bytes needed ADD #INBF,R1 ; First byte to fill 20$: MOVB #SPA,(R1)+ SOB R4,20$ ; ; Here both keyword and item to test occupy 8 characters and ; they are both spce filled. ; 30$: ; 0015 ; ; Now they must at least match up to the minimum length ; given on the keyword line. ; MOV #1,R0 ; Set pointer to file keyword 40$: CMPB INBF+4(R0),KEYB-1(R0) ; Match? BNE NXTLIN ; No - try for another keyword INC R0 ; One matched, try for another CMP R0,LMIN ; Minimum achieved? BLE 40$ ; No - continue checking CMP LMIN,#8. ; Minimum exceed keyword length? BEQ MATCH ; Yes - success ; ; They must also match spaces in the keyword typed, or real ; matches to characters in the keyword spec line ; for the rest of the 8. characters. ; 50$: CMPB KEYB-1(R0),INBF+4(R0) ; Match on rest of given keyword? BEQ 60$ ; Yes - so far CMPB KEYB-1(R0),#SPA ; End of keyword? BNE NXTLIN ; No - not right keyword 60$: INC R0 ; Go to next character to check CMP R0,#8. ; All matched up? BLE 50$ ; No - look some more ; ; Here they have matched to 8. characters exactly or to ; greater than LMIN and then have had the user typed keyword ; trailing space padded. ; MATCH: MOV #-1,R0 ; Return FORTRAN .TRUE. RETURN .END