Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 May 2009 10:06:42 +0530
From:      venki kaps <venkiece2005@gmail.com>
To:        Mark Tinguely <tinguely@casselton.net>
Cc:        channa.kad@gmail.com, freebsd-arm@freebsd.org
Subject:   Re: strncmp issue
Message-ID:  <6d53329e0905062136x58b4ca4eh9ebd9f45c34e565@mail.gmail.com>
In-Reply-To: <200905051637.n45GbE7Q057469@casselton.net>
References:  <20090505.081701.569396874.imp@bsdimp.com> <200905051637.n45GbE7Q057469@casselton.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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@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.
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6d53329e0905062136x58b4ca4eh9ebd9f45c34e565>