1TEXT strchr(SB), $0 2 MOVBU c+4(FP), R1 3 CMP $0, R1 4 BEQ _null 5 6_strchr: /* not looking for a null, byte at a time */ 7 MOVBU.P 1(R0), R2 8 CMP R1, R2 9 BEQ _sub1 10 11 CMP $0, R2 12 BNE _strchr 13 14_return0: /* character not found in string, return 0 */ 15 MOVW $0, R0 16 RET 17 18_null: /* looking for null, align */ 19 AND.S $3, R0, R2 20 BEQ _aligned 21 22 MOVBU.P 1(R0), R4 23 CMP $0, R4 24 BEQ _sub1 25 B _null 26 27_aligned: 28 MOVW $0xFF, R3 /* mask */ 29 30_loop: 31 MOVW.P 4(R0), R4 /* 4 at a time */ 32 TST R4, R3 /* AND.S R2, R3, Rx */ 33 TST.NE R4>>8, R3 34 TST.NE R4>>16, R3 35 TST.NE R4>>24, R3 36 BNE _loop 37 38 TST R4, R3 /* its somewhere, find it and correct */ 39 BEQ _sub4 40 TST R4>>8, R3 41 BEQ _sub3 42 TST R4>>16, R3 43 BEQ _sub2 44 45_sub1: /* compensate for pointer increment */ 46 SUB $1, R0 47 RET 48_sub2: 49 SUB $2, R0 50 RET 51_sub3: 52 SUB $3, R0 53 RET 54_sub4: 55 SUB $4, R0 56 RET 57