xref: /minix3/lib/libc/arch/m68k/string/swab.S (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc/*	$NetBSD: swab.S,v 1.11 2014/03/18 18:20:37 riastradh Exp $	*/
22fe8fb19SBen Gras
32fe8fb19SBen Gras#include <machine/asm.h>
42fe8fb19SBen Gras
52fe8fb19SBen GrasENTRY(swab)
684d9c625SLionel Sambuc	movl	4(%sp),%a0		| source
784d9c625SLionel Sambuc	movl	8(%sp),%a1		| destination
884d9c625SLionel Sambuc	movl	12(%sp),%d0		| count
92fe8fb19SBen Gras	lsrl	#1,%d0			| count is in bytes; we need words
102fe8fb19SBen Gras	jeq	swdone
112fe8fb19SBen Gras
122fe8fb19SBen Grasswloop:
1384d9c625SLionel Sambuc#ifdef __mcoldfire__
1484d9c625SLionel Sambuc	movb	(%a0)+,1(%a1)
1584d9c625SLionel Sambuc	movb	(%a0)+,(%a1)
1684d9c625SLionel Sambuc	addql	#2,%a1
1784d9c625SLionel Sambuc#else
1884d9c625SLionel Sambuc	movw	(%a0)+,%d1
192fe8fb19SBen Gras	rorw	#8,%d1
2084d9c625SLionel Sambuc	movw	%d1,(%a1)+
2184d9c625SLionel Sambuc#endif
222fe8fb19SBen Gras	subql	#1,%d0
232fe8fb19SBen Gras	jne	swloop
242fe8fb19SBen Gras
252fe8fb19SBen Grasswdone:
262fe8fb19SBen Gras	rts
2784d9c625SLionel SambucEND(swab)
28