home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / STR / STRCMP.S < prev    next >
Encoding:
Text File  |  1993-01-02  |  966 b   |  46 lines

  1. / strcmp.s (emx+gcc) -- Copyright (c) 1990-1993 by Eberhard Mattes
  2.  
  3.         .globl _strcmp
  4.  
  5. / int strcmp (const char *string1, const char *string2)
  6. / {
  7. /   int d;
  8. /   
  9. /   for (;;)
  10. /     {
  11. /       d = (int)(unsigned char)*string1 - (int)(unsigned char)*string2;
  12. /       if (d != 0 || *string1 == 0 || *string2 == 0)
  13. /         return (d);
  14. /       ++string1; ++string2;
  15. /     }
  16. / }
  17.  
  18. / assumes ds=es!
  19.  
  20.         .text
  21.  
  22.         .align  2, 0x90
  23.  
  24. _strcmp:
  25.         pushl   %esi
  26.         pushl   %edi
  27.         movl    3*4(%esp), %esi         / string1
  28.         movl    4*4(%esp), %edi         / string2
  29.         .align  2, 0x90
  30. 1:      lodsb
  31.         scasb
  32.         jne     2f
  33.         orb     %al, %al
  34.         jne     1b
  35.         xorl    %eax, %eax
  36.         popl    %edi
  37.         popl    %esi
  38.         ret
  39.  
  40.         .align  2, 0x90
  41. 2:      subb    -1(%edi), %al
  42.         movsbl  %al, %eax
  43.         popl    %edi
  44.         popl    %esi
  45.         ret
  46.