.title matchc ; ; this routine implements the following fortran interface ; ; i = matchc(lin, sub) ; ; where lin and sub are EOS-terminated strings ; ; if sub is found in lin, the column where it starts is returned as ; i; if not found, 0 is returned ; ap=%5 lin=2 sub=4 .psect $r.roi,con,ro,rel,lcl,i .enabl lsb matchc:: clr r0 ; initialize position in lin mov lin(ap),r1 ; address of lin(1) in r1 10$: inc r0 ; update position in lin mov r1,r2 ; place address of this position in r2 tstb (r1)+ ; see if at EOS(0) beq 20$ ; YES, lin is exhausted, return 0 mov sub(ap),r3 ; address of sub(1) in r3 call $match ; see if match bcc 30$ ; c clear => YES br 10$ ; try next position 20$: clr r0 ; no match, return 0 30$: return .page ; ; ; $match - see if match of strings ; ; called from macro routines via call $match ; ; inputs: ; r2 address of line to match ; r3 address of EOS(0)-terminated substring ; ; outputs: ; r2,r3 modified ; c set no match ; c clear match ; $match: tstb (r3) ; see if at EOS beq ccbit ; if so, clear c-bit cmpb (r2)+,(r3)+ ; compare characters beq $match ; if ==, then try next character sec ; set c bit indicating no match return ccbit: clc ; clear c bit indicating match return .end