[retroforth] Re: Even faster find!

  • From: "Ron Aaron" <ron@xxxxxxxxxxx>
  • To: retroforth@xxxxxxxxxxxxx
  • Date: Sun, 30 Jan 2005 21:17:08 -0800 (PST)

Now I've got it up to ludicrous speed!

I don't know how much faster the linked-list search can go.  Probably getting
rid of the cmpsb in favor of discrete instructions will have some benefit.

But I've got 'find' running at about twice the speed it was this morning,
between the ALIGN 4 (easy change) and my most recent code changes to 'find'. 
I did some common optimizations: common subexpression removal, elimination of
unnecessary push/pop, and more tricky stuff like doing two compares in one
shot.

So now it's smaller *and* faster!

Here's the code:

; trashes EDX,ECX,EDI
FORTH 'find', find              ;
        push ebx                ;
        mov ebx, flast          ;
.o:     upop ecx                ;
        push esi
        mov esi,eax             ;
        mov dh,  byte [eax]     ; get first char to do quick compare:
        mov dl, cl              ; and the length; do both compares at once!
.a:     mov ebx,[ebx]           ;
        test ebx,ebx            ;
        jz .end                 ; end of wordlist
        lea edi, [ebx+9]        ; point edi at the string
        cmp dx, [edi-1]
        jne .a
.len:   push esi                ; same length, so do the compare
        push ecx                ;
        repe cmpsb              ;
        pop ecx                 ;
        pop esi                 ;
        jne .a                  ;
        mov eax,[ebx+4]         ; exact match: return XT
        clc                     ;
.ret:   pop esi
        pop ebx                 ;
        ret
.end:   pop esi
        upsh ecx                ; no matches
        stc                     ;
        pop ebx
next


-- 
My GPG public key is at http://ronware.org/
fingerprint: 8130 734C 69A3 6542 0853  CB42 3ECF 9259 AD29 415D




Other related posts: