123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #include <features.h>
- #include <endian.h>
- #include <bits/arm_asm.h>
- #include <bits/arm_bx.h>
- .text
- .global strlen
- .type strlen,%function
- .align 4
- #if defined(THUMB1_ONLY)
- .thumb_func
- strlen:
- mov r2, #0
- 1:
- ldrb r1, [r0, r2]
- add r2, r2, #1
- cmp r1, #0
- bne 1b
- sub r0, r2, #1
- bx lr
- #else
- strlen:
- bic r1, r0, $3
- ldr r2, [r1], $4
- ands r3, r0, $3
- rsb r0, r3, $0
- beq Laligned
-
- #if __BYTE_ORDER == __BIG_ENDIAN
- orr r2, r2, $0xff000000
- subs r3, r3, $1
- IT(t, gt)
- orrgt r2, r2, $0x00ff0000
- subs r3, r3, $1
- IT(t, gt)
- orrgt r2, r2, $0x0000ff00
- #else
- orr r2, r2, $0x000000ff
- subs r3, r3, $1
- IT(t, gt)
- orrgt r2, r2, $0x0000ff00
- subs r3, r3, $1
- IT(t, gt)
- orrgt r2, r2, $0x00ff0000
- #endif
- Laligned:
- tst r2, $0x000000ff
- IT(tttt, ne)
- tstne r2, $0x0000ff00
- tstne r2, $0x00ff0000
- tstne r2, $0xff000000
- addne r0, r0, $4
- IT(t, ne)
- ldrne r2, [r1], $4
- bne Laligned
- Llastword:
- #if __BYTE_ORDER == __BIG_ENDIAN
- tst r2, $0xff000000
- IT(tttt, ne)
- addne r0, r0, $1
- tstne r2, $0x00ff0000
- addne r0, r0, $1
- tstne r2, $0x0000ff00
- IT(t, ne)
- addne r0, r0, $1
- #else
- tst r2, $0x000000ff
- IT(tttt, ne)
- addne r0, r0, $1
- tstne r2, $0x0000ff00
- addne r0, r0, $1
- tstne r2, $0x00ff0000
- IT(t, ne)
- addne r0, r0, $1
- #endif
- BX(lr)
- #endif
- .size strlen,.-strlen
- libc_hidden_def(strlen)
|