Subject: swab(3) is broken on m68k
To: None <gnats-bugs@NetBSD.ORG, port-m68k@NetBSD.ORG>
From: None <jtkohl@MIT.EDU>
List: port-m68k
Date: 01/06/1995 22:28:43
>Submitter-Id:  net
>Originator:    John Kohl
"Kernel Hackers `R` Us"
>Confidential:  no
>Synopsis:      swab(3) is broken on m68k
>Severity:      serious
>Priority:      high
>Category:      port-m68k
>Class:         sw-bug
>Release:       <NetBSD-current source date>
System: NetBSD 1.0A NetBSD 1.0A (DUALITY) #10: Thu Jan 5 23:26:52 EST 1995 hp300

swab(3) swaps twice the requested number of bytes on m68k.
use swab(3). watch it trash bytes after the ones you wanted swapped.
I think this will do it:

--- swab.S~	Fri Jan  6 22:15:36 1995
+++ usr/src/lib/libc/arch/m68k/string/swab.S	Fri Jan  6 22:19:46 1995
@@ -4,6 +4,7 @@
 	movl	sp@(4),a0	/* source */
 	movl	sp@(8),a1	/* destination */
 	movl	sp@(12),d0	/* count */
+	asrl	#1,d0		/* count is bytes, we do words */
 	jeq	swdone