Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 2,709 of 4,675    |
|    Rick C. Hodgin to Terje Mathisen    |
|    Re: Optimize stricmp() algorithm (casele    |
|    24 Jun 17 15:13:42    |
   
   From: rick.c.hodgin@nospicedham.gmail.com   
      
   On Saturday, June 24, 2017 at 5:50:14 PM UTC-4, Terje Mathisen wrote:   
   > Rick C. Hodgin wrote:   
   > > Can anybody help me optimize this code?   
   > [snip]   
   > > It's designed to be used as a custom assembly algorithm for a   
   > > stricmp() algorithm which follows this general pattern, which   
   > > is designed to be the target of a qsort() callback:   
   > >   
   > > int caseless_compare(const void *p1, const void *p2)   
   > > {   
   > > int d;   
   > > const unsigned char *s1 = p1;   
   > > const unsigned char *s2 = p2;   
   > >   
   > > while ((d = tolower(*s1) - tolower(*s2)) == 0 && *s1)   
   > > s1++, s2++;   
   > >   
   > > return d;   
   > > }   
   > >   
   >   
   > Just writing a version of this code which can handle national 8-bit   
   > character sets is more interesting, you pretty much have to use some   
   > form of lookup table, i.e.   
   >   
   > while (d = tolower[c = *s1++] - tolower[*s2++] && c) {};   
      
   This minor tweak has given the best results so far:   
      
    Rick2 = 123   
    Bart = 117   
    Ben = 116   
    RickAsm = 105   
    BartAsm = 104   
    Terje C = 96   
      
   The original algorithm yours was based off is the Ben score above.   
   Your little tweak gave it a 20-point gain.   
      
   FWIW, Terje, I am always impressed with your optimization skills.   
   That sentiment dates back to the 90s as well. I've always viewed   
   you as the best assembly developer I know, and I admire your mind   
   and skills in considering the variables in tasks like this.   
      
   Thank you,   
   Rick C. Hodgin   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca