.title index ; ; this routine provides the following fortran interface ; ; i = index(buf, char) ; ; where buf is an EOS terminated string and the value of the function ; is its position in the string if found, and 0 if not ; ap=%5 buf=2 char=4 index:: mov buf(ap),r1 ; buffer address in r1 movb @char(ap),r2 ; character to find in r2 clr r0 ; initialize character position 10$: inc r0 ; increment to current char position tstb (r1) ; see if at EOS(0) beq 20$ ; if == 0, return value of 0 cmpb (r1)+,r2 ; see if current byte matches beq 30$ ; if so, r0 contains position br 10$ ; try next byte 20$: clr r0 ; return 0 since char not found 30$: return .end