.TITLE INDEX ; MODIFIED INDEX FUNCTION FOR ANALYTICALC ;COPYRIGHT(C) 1984 G. EVERHART ; INDEX:: .WORD ^M ; FIRST SEARCH FOR NULL CHARACTER IN INPUT STRING, THEN LOOK FOR ;MATCH UP TO THAT POINT. CLRL R7 MOVL #256.,R5 MOVL 4(AP),R6 ;R6 IS STRING ADDRESS LOCC R7,R5,(R6) ;LOCATE 0 (IN MAX 256 CHARS) BNEQ 1$ ;IF NE WE FOUND A 0 SOMEWHERE 3$: MOVL R5,R0 ;ELSE RETURN 256. AS RESULT. RET 1$: MOVZBL @8(AP),R7 ;R7 GETS CHAR ; SUPPOSE WE SAID MAX 6 CHARS AND HAD ; A B C <0> D E (<0> = NULL) ; 1 2 3 4 5 6 ; 1ST LOCC GIVES 3 CHARS LEFT ; 6-3=3 BUT WE WANT TO ENSURE THAT IF STRING IS NOT FOUND WE ; RETURN 4. SUBL3 R0,R5,R5 ;R5 GETS 256 - NO. BYTES THAT WERE LEFT ;THUS R5 IS STRING LENGTH NULL TERMINATED. INCL R5 ;BUMP UP BY 1 AGAIN ; IF WE SEARCH FOR B ABOVE, LOCC GIVES R0=3, R5 HAS 4 LOCC R7,R5,(R6) ;SO RE HUNT FOR STRING BEQL 3$ ;IF NOT THERE, RETURN LENGTH SUBL3 R0,R5,R0 ;IF IT IS THERE,SUBTRACT LENGTH LEFT TO ;GET STRING LOCATION. INCL R0 ;THEN ADD 1 TO ACCOUNT FOR FORTRAN SUBSCRIPTS RET .END