strncmp issue
venki kaps
venkiece2005 at gmail.com
Thu May 7 04:44:15 UTC 2009
Hi Tinguely,
Thanks for the fix.
i am also agreeing with you.
A small doubt:
ENTRY(strncmp)
/* if (len == 0) return 0 */
cmp r2, #0
moveq r0, #0
RETc(eq)
/* ip == last src address to compare */
add ip, r0, r2
1:
ldrb r2, [r0], #1
ldrb r3, [r1], #1
cmp ip, r0
beq 2f <---- if (strlen(str1) > len) break;
cmp r2, #0
beq 2f <----- if (*str1++ == 0) break;
cmpcs r2, r3 <----- if (*str1 == *str2) return s1-s2;
beq 1b
2:
sub r0, r2, r3
RET
END(strncmp)
Expecting beq 2f after cmp r2, #0 to break the loop.
Is it good to use?
OR
Is cmp r2, #1 enough?
Regards,
Venkappa
On Tue, May 5, 2009 at 10:07 PM, Mark Tinguely <tinguely at casselton.net>wrote:
>
> > Is the hand rolled assembler still better than what gcc can produce?
> >
> > Warner
>
> Assuming my additional conditional branch, we can save at least an add and
> a branch in the comparison loop with the hard rolled assembler over the
> "cc -O2 head/lib/libc/string/strncmp.c" code.
>
> If the conditional branch can be deleted, then even better.
>
> --Mark.
>
More information about the freebsd-arm
mailing list