/ swab.s (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes

#include <emx/asm386.h>

        .globl __swab

/ void _swab (const void *src, void *dst, size_t n)
/ {
/   char *s, *d;
/ 
/   if (n & 1) return;
/   while (n > 0)
/     {
/       d[0] = s[1];
/       d[1] = s[0];
/       d += 2; s += 2; n -= 2;
/     }
/ }

/ assumes ds=es!

        .text

        ALIGN

__swab:
        PROFILE_NOFRAME
        pushl   %esi
        pushl   %edi
        movl    3*4(%esp), %esi         /* src */
        movl    4*4(%esp), %edi         /* dst */
        movl    5*4(%esp), %ecx         /* n */
        shrl    $1, %ecx
        jc      Lreturn
        jz      Lreturn
        ALIGN
1:      lodsw
        xchgb   %al, %ah
        stosw
        loop    1b
Lreturn:popl    %edi
        popl    %esi
        EPILOGUE(_swab)
