Most efficent strlen subroutine in assembly? - ASM x86 ASM 370

This is a discussion on Most efficent strlen subroutine in assembly? - ASM x86 ASM 370 ; "Rod Pemberton" <spamtrap@crayne.org> wrote in message news:e1gria$dkk3$1@news3.infoave.net... > > "Alex Buell" <spamtrap@crayne.org> wrote in message > news:20060410174955.7d7c5a9a.alex.buell@munted.org.uk... >> I've rolled my own strlen routine in NASM on Linux, but was wondering if >> it could be made even better? Here's ...

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 12 of 12

Most efficent strlen subroutine in assembly?

  1. Default Re: Most efficent strlen subroutine in assembly?

    "Rod Pemberton" <spamtrap@crayne.org> wrote in message news:e1gria$dkk3$1@news3.infoave.net...
    >
    > "Alex Buell" <spamtrap@crayne.org> wrote in message
    > news:20060410174955.7d7c5a9a.alex.buell@munted.org.uk...
    >> I've rolled my own strlen routine in NASM on Linux, but was wondering if
    >> it could be made even better? Here's my code:
    >>

    >
    > I can give some links:


    Here is another link to very fast strlen() code for x86:

    http://cvs.opensolaris.org/source/xr...6/gen/strlen.s


    -- Norbert



  2. Default Re: Most efficent strlen subroutine in assembly?

    In article
    <20060410174955.7d7c5a9a.alex.buell@munted.org.uk>,
    spamtrap@crayne.org says...
    > I've rolled my own strlen routine in NASM on Linux, but was wondering if
    > it could be made even better? Here's my code:


    A few obvious possibilities:

    strlen proc
    mov ebx, 0ffffffffh
    loop_top:
    inc ebx
    cmp [eax+ebx], 0
    jnz loop_top
    mov eax, ebx
    strlen endp

    and:

    strlen proc
    mov ebx, eax
    sub eax, 1
    loop_top:
    add eax, 1
    cmp [eax], 0
    jnz loop_top
    sub eax, ebx
    strlen endp

    Better or not is probably as much a matter of taste as
    anything else. For another possibility, this:

    strlen proc
    mov ebx, eax
    jmp start_loop
    loop_top:
    add eax, 1
    start_loop:
    cmp [eax], 0
    jnz loop_top
    sub eax, ebx
    strlen endp

    might (at least theoretically) be a tiny bit faster on
    some processors, but the difference will be trivial at
    best. I certainly don't like it as well.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.


+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. strlen
    By Application Development in forum C
    Replies: 53
    Last Post: 09-11-2007, 05:12 PM
  2. Replies: 1
    Last Post: 08-20-2007, 03:35 PM
  3. Information for efficent computation of median
    By Application Development in forum Theory
    Replies: 11
    Last Post: 10-17-2006, 12:30 AM
  4. Efficent Paper Use
    By Application Development in forum Adobe Photoshop
    Replies: 10
    Last Post: 06-09-2005, 11:16 AM
  5. Replies: 5
    Last Post: 03-07-2005, 08:34 PM