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

  1. / swab.s (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes
  2.  
  3.         .globl _swab
  4.  
  5. / void swab (const void *src, void *dst, size_t n)
  6. / {
  7. /   char *s, *d;
  8. /   if (n & 1) return;
  9. /   while (n > 0)
  10. /     {
  11. /       d[0] = s[1];
  12. /       d[1] = s[0];
  13. /       d += 2; s += 2; n -= 2;
  14. /     }
  15. / }
  16.  
  17. / assumes ds=es!
  18.  
  19.         .text
  20.  
  21.         .align  2, 0x90
  22.  
  23. _swab:
  24.         pushl   %esi
  25.         pushl   %edi
  26.         movl    3*4(%esp), %esi         / src
  27.         movl    4*4(%esp), %edi         / dst
  28.         movl    5*4(%esp), %ecx         / n
  29.         shrl    $1, %ecx
  30.         jc      9f
  31.         .align  2, 0x90
  32. 1:      lodsw
  33.         xchgb   %al, %ah
  34.         stosw
  35.         loop    1b
  36. 9:      popl    %edi
  37.         popl    %esi
  38.         ret
  39.