1993-10-07 03:17:24 +03:00
|
|
|
/*
|
1995-04-29 02:53:59 +04:00
|
|
|
* Written by J.T. Conklin <jtc@netbsd.org>.
|
|
|
|
* Public domain.
|
1993-10-07 03:17:24 +03:00
|
|
|
*/
|
|
|
|
|
1994-03-12 04:39:55 +03:00
|
|
|
#include <machine/asm.h>
|
|
|
|
|
1993-10-21 04:39:55 +03:00
|
|
|
#if defined(LIBC_SCCS)
|
1999-08-23 12:45:09 +04:00
|
|
|
RCSID("$NetBSD: swab.S,v 1.10 1999/08/23 08:45:11 kleink Exp $")
|
1993-10-07 03:17:24 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On the i486, this code is negligibly faster than the code generated
|
1993-10-21 04:48:14 +03:00
|
|
|
* by gcc at about half the size. If my i386 databook is correct, it
|
1993-10-07 03:17:24 +03:00
|
|
|
* should be considerably faster than the gcc code on a i386.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ENTRY(swab)
|
|
|
|
pushl %esi
|
|
|
|
pushl %edi
|
|
|
|
movl 12(%esp),%esi
|
|
|
|
movl 16(%esp),%edi
|
|
|
|
movl 20(%esp),%ecx
|
|
|
|
|
|
|
|
cld # set direction forward
|
|
|
|
|
1993-11-25 04:18:24 +03:00
|
|
|
shrl $1,%ecx
|
1993-10-07 03:17:24 +03:00
|
|
|
testl $7,%ecx # copy first group of 1 to 7 words
|
1993-11-25 04:18:24 +03:00
|
|
|
jz L2 # while swaping alternate bytes.
|
1999-08-23 12:45:09 +04:00
|
|
|
_ALIGN_TEXT,0x90
|
1993-10-07 03:17:24 +03:00
|
|
|
L1: lodsw
|
1994-02-14 20:43:19 +03:00
|
|
|
rorw $8,%ax
|
1993-10-07 03:17:24 +03:00
|
|
|
stosw
|
|
|
|
decl %ecx
|
|
|
|
testl $7,%ecx
|
1993-11-25 04:18:24 +03:00
|
|
|
jnz L1
|
1993-10-21 04:48:14 +03:00
|
|
|
|
1993-10-07 03:17:24 +03:00
|
|
|
L2: shrl $3,%ecx # copy remainder 8 words at a time
|
|
|
|
jz L4 # while swapping alternate bytes.
|
1999-08-23 12:45:09 +04:00
|
|
|
_ALIGN_TEXT,0x90
|
1993-10-07 03:17:24 +03:00
|
|
|
L3: lodsw
|
1994-02-14 20:43:19 +03:00
|
|
|
rorw $8,%ax
|
1993-10-07 03:17:24 +03:00
|
|
|
stosw
|
|
|
|
lodsw
|
1994-02-14 20:43:19 +03:00
|
|
|
rorw $8,%ax
|
1993-10-07 03:17:24 +03:00
|
|
|
stosw
|
|
|
|
lodsw
|
1994-02-14 20:43:19 +03:00
|
|
|
rorw $8,%ax
|
1993-10-07 03:17:24 +03:00
|
|
|
stosw
|
|
|
|
lodsw
|
1994-02-14 20:43:19 +03:00
|
|
|
rorw $8,%ax
|
1993-10-07 03:17:24 +03:00
|
|
|
stosw
|
|
|
|
lodsw
|
1994-02-14 20:43:19 +03:00
|
|
|
rorw $8,%ax
|
1993-10-07 03:17:24 +03:00
|
|
|
stosw
|
|
|
|
lodsw
|
1994-02-14 20:43:19 +03:00
|
|
|
rorw $8,%ax
|
1993-10-07 03:17:24 +03:00
|
|
|
stosw
|
|
|
|
lodsw
|
1994-02-14 20:43:19 +03:00
|
|
|
rorw $8,%ax
|
1993-10-07 03:17:24 +03:00
|
|
|
stosw
|
|
|
|
lodsw
|
1994-02-14 20:43:19 +03:00
|
|
|
rorw $8,%ax
|
1993-10-07 03:17:24 +03:00
|
|
|
stosw
|
|
|
|
decl %ecx
|
|
|
|
jnz L3
|
|
|
|
|
1994-02-14 20:43:19 +03:00
|
|
|
L4: popl %edi
|
1993-10-07 03:17:24 +03:00
|
|
|
popl %esi
|
|
|
|
ret
|