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,708 of 4,675    |
|    Rick C. Hodgin to Terje Mathisen    |
|    Re: Optimize stricmp() algorithm (casele    |
|    24 Jun 17 15:52:34    |
   
   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) {};   
      
   Someone pointed out that this does not produce correct results,   
   because it has to continue so long as d is 0, hence you need an   
   == in there, or a !(d...) expression.   
      
   When those are re-introduced, this version performs identically   
   to the previous Ben version.   
      
   I was able to update my assembly version to remove an xor, and   
   a redundant jmp. The score improved from 105 to 102.   
      
   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