1/* index.s 4.1 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 .globl _index 12 13_index: 14 .word 0x0 15 movq 4(ap),r1 # r1 = cp; r2 = c 16 tstl r2 # check for special case c == '\0' 17 bneq 2f 181: 19 locc $0,$65535,(r1) # just find end of string 20 beql 1b # still looking 21 movl r1,r0 # found it 22 ret 232: 24 movab tbl[r2],r5 # table entry for c 25 incb (r5) 26 movzwl $65535,r4 # fast access 273: 28 scanc r4,(r1),tbl,$1 # look for c or '\0' 29 beql 3b # still looking 30 movl r1,r0 # return pointer to char 31 tstb (r0) # if have found '\0' 32 bneq 4f 33 clrl r0 # else return 0 344: 35 clrb (r5) # clean up table 36 ret 37 38 .data 39tbl: .byte 1 40 .space 255 41 .text 42