1
0
Fork 0
forked from len0rd/rockbox

Coldfire strlen, slight optimization pointed out by amiconn, eliminate some unconditionla branches by rearranging the code handling the head bytes

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25968 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2010-05-12 12:32:34 +00:00
parent a5d8d21596
commit aa1e471f9a

View file

@ -31,21 +31,14 @@ strlen:
move.l %a0, %a1 /* %a1 = start address */ move.l %a0, %a1 /* %a1 = start address */
move.l %a0, %d0 move.l %a0, %d0
andi.l #3, %d0 /* %d0 = %a0 & 3 */ andi.l #3, %d0 /* %d0 = %a0 & 3 */
jmp.l (2,%pc,%d0.l*2) beq.b 1f /* already aligned */
bra.b .bytes0 jmp.l (-2,%pc,%d0.l*4)
bra.b .bytes3
bra.b .bytes2
bra.b .bytes1
.bytes3:
tst.b (%a0)+ tst.b (%a0)+
beq.b .done beq.b .done
.bytes2:
tst.b (%a0)+ tst.b (%a0)+
beq.b .done beq.b .done
.bytes1:
tst.b (%a0)+ tst.b (%a0)+
beq.b .done beq.b .done
.bytes0:
1: 1:
move.l (%a0)+, %d0 /* load %d0 increment %a0 */ move.l (%a0)+, %d0 /* load %d0 increment %a0 */