1/* index.s 4.2 84/11/01 */ 2 3/* 4 * Find the first occurence of c in the string cp. 5 * Return pointer to match or null pointer. 6 * 7 * char * 8 * index(cp, c) 9 * char *cp, c; 10 */ 11#include "DEFS.h" 12 13ENTRY(index, 0) 14 movq 4(ap),r1 # r1 = cp; r2 = c 15 tstl r2 # check for special case c == '\0' 16 bneq 2f 171: 18 locc $0,$65535,(r1) # just find end of string 19 beql 1b # still looking 20 movl r1,r0 # found it 21 ret 222: 23 movab tbl[r2],r5 # table entry for c 24 incb (r5) 25 movzwl $65535,r4 # fast access 263: 27 scanc r4,(r1),tbl,$1 # look for c or '\0' 28 beql 3b # still looking 29 movl r1,r0 # return pointer to char 30 tstb (r0) # if have found '\0' 31 bneq 4f 32 clrl r0 # else return 0 334: 34 clrb (r5) # clean up table 35 ret 36 37 .data 38tbl: .byte 1 39 .space 255 40 .text 41