diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /libkern/strchr-arm.s | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'libkern/strchr-arm.s')
| -rw-r--r-- | libkern/strchr-arm.s | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/libkern/strchr-arm.s b/libkern/strchr-arm.s new file mode 100644 index 00000000..9c04273c --- /dev/null +++ b/libkern/strchr-arm.s @@ -0,0 +1,52 @@ +TEXT strchr(SB), $-4 + MOVBU c+4(FP), R1 + CMP $0, R1 + BEQ _null + +_strchr: /* not looking for a null, byte at a time */ + MOVBU.P 1(R0), R2 + CMP R1, R2 + BEQ _sub1 + + CMP $0, R2 + BNE _strchr + +_return0: /* character not found in string, return 0 */ + MOVW $0, R0 + RET + +_null: /* looking for null, align */ + AND.S $3, R0, R2 + BEQ _aligned + + MOVBU.P 1(R0), R4 + CMP $0, R4 + BEQ _sub1 + B _null + +_aligned: + MOVW $0xFF, R3 /* mask */ + +_loop: + MOVW.P 4(R0), R4 /* 4 at a time */ + TST R4, R3 /* AND.S R2, R3, Rx */ + BEQ _sub4 + TST R4>>8, R3 + BEQ _sub3 + TST R4>>16, R3 + BEQ _sub2 + TST R4>>24, R3 + BNE _loop + +_sub1: /* compensate for pointer increment */ + SUB $1, R0 + RET +_sub2: + SUB $2, R0 + RET +_sub3: + SUB $3, R0 + RET +_sub4: + SUB $4, R0 + RET |
