; SUBROUTINE IINDEX(A,PATTRN,{I},M) ; FUNCTION IINDEX(A,PATTRN{,I}) ; ; Searches string A for the first occurrence of string PATTRN, ; returning the position of the first character of PATTRN in M ; or as the function result. If specified, I is the starting ; position for the search; if not specified the search begins at the ; first character. ; ; MODIFICATIONS RECORD ; ==================== ; V2.01 7-July-82 CJD ; Change to preferred name IINDEX to avoid confusion with F77's INDEX. .TITLE IINDEX .IDENT /V2.01/ .PSECT .GLOBL INDEX,IINDEX INDEX: IINDEX: MOV (R5)+,-(SP) MOV (R5)+,R1 MOV (R5)+,R2 MOV #1 ,R0 CMPB #3 ,(SP) BHI INDEXA MOV (R5)+,R4 CMP #177777 ,R4 BEQ INDEXA INDEXB: CMP (R4),R0 BLOS INDEXA INC R0 TSTB (R1)+ BNE INDEXB BR INDEXC INDEXA: MOV R2,R4 MOV R1,R3 INDEXE: TSTB (R2) BEQ INDEXD TSTB (R1) BEQ INDEXC CMPB (R1)+,(R2)+ BEQ INDEXE MOV R4,R2 INC R0 INC R3 MOV R3,R1 BR INDEXE INDEXC: CLR R0 INDEXD: CMPB #4,(SP)+ BHI INDEXF MOV R0,@(R5)+ INDEXF: RTS PC .END