Home | History | Annotate | Line # | Download | only in string
swab.S revision 1.3.50.1
      1       1.1    fvdl /*
      2       1.2    salo  * Written by J.T. Conklin <jtc (at) NetBSD.org>.
      3       1.1    fvdl  * Public domain.
      4       1.1    fvdl  */
      5       1.1    fvdl 
      6       1.1    fvdl #include <machine/asm.h>
      7       1.1    fvdl 
      8       1.1    fvdl #if defined(LIBC_SCCS)
      9  1.3.50.1     tls 	RCSID("$NetBSD: swab.S,v 1.3.50.1 2014/08/20 00:02:12 tls Exp $")
     10       1.1    fvdl #endif
     11       1.1    fvdl 
     12       1.1    fvdl #define LOAD_SWAP_STORE_WORD \
     13       1.1    fvdl 	lodsw	; \
     14       1.1    fvdl 	xchgb	%al,%ah ; \
     15       1.1    fvdl 	stosw
     16       1.1    fvdl 
     17       1.1    fvdl ENTRY(swab)
     18       1.1    fvdl 	xchgq	%rdi,%rsi
     19       1.1    fvdl 	cld				# set direction forward
     20       1.1    fvdl 
     21       1.1    fvdl 	shrq	$1,%rdx
     22       1.1    fvdl 	testq	$7,%rdx			# copy first group of 1 to 7 words
     23       1.3  rpaulo 	jz	L2			# while swapping alternate bytes.
     24       1.1    fvdl L1:	lodsw
     25       1.1    fvdl 	rorw	$8,%ax
     26       1.1    fvdl 	stosw
     27       1.1    fvdl 	decq	%rdx
     28       1.1    fvdl 	testq	$7,%rdx
     29       1.1    fvdl 	jnz	L1
     30       1.1    fvdl 
     31       1.1    fvdl L2:	shrq	$3,%rdx			# copy remainder 8 words at a time
     32       1.1    fvdl 	jz	L4			# while swapping alternate bytes.
     33       1.1    fvdl L3:
     34       1.1    fvdl 	LOAD_SWAP_STORE_WORD
     35       1.1    fvdl 	LOAD_SWAP_STORE_WORD
     36       1.1    fvdl 	LOAD_SWAP_STORE_WORD
     37       1.1    fvdl 	LOAD_SWAP_STORE_WORD
     38       1.1    fvdl 	LOAD_SWAP_STORE_WORD
     39       1.1    fvdl 	LOAD_SWAP_STORE_WORD
     40       1.1    fvdl 	LOAD_SWAP_STORE_WORD
     41       1.1    fvdl 	LOAD_SWAP_STORE_WORD
     42       1.1    fvdl 
     43       1.1    fvdl 	decq	%rdx
     44       1.1    fvdl 	jnz	L3
     45       1.1    fvdl L4:
     46       1.1    fvdl 	ret
     47  1.3.50.1     tls END(swab)
     48