.TITLE INDEX ; INDEX(STRING,CHAR) GIVES EITHER HIGHEST LOC IN STRING WITH ; CHARACTER OR END OF STRING. INDEX:: MOV 2(R5),R0 ;R0=CHAR STRING ADDR MOVB @4(R5),R2 ;R2 IS CHARACTER TO USE MOV #256.,R3 ;MAX 256 CHARS 1$: TSTB (R0) ;SEE IF ZERO CHARACTER BEQ 2$ ;IF SO SCRAM CMPB (R0)+,R2 ;GOT THE CHAR? BEQ 2$ ;IF WE GOT IT, SKIP OUT SOB R3,1$ ;ELSE KEEP LOOKING 2$: SUB 2(R5),R0 ;FORM OFFSET TO CHAR. AUTOINC MAKES IT 1 BASED ;RATHER THAN 0 BASED, WHICH IS WHAT WE NEED ;FOR FORTRAN SUBSCRIPT. CLR R1 ;GET INDEX (STARTING AT 1) FOR CHARACTER RTS PC ISGN:: CLR R1 CLR R0 TST @2(R5) ;SEE IF ARG IS NEGATIVE BLT 1$ BGT 2$ RTS PC ;RETURN 0 IF IT'S 0 1$: MOV #-1,R0 MOV #-1,R1 ;RETURN 32 BIT -1 RTS PC 2$: MOV #1,R0 ;RETURN 32 BIT +1 IF POSITIVE RTS PC .END