Subject: port-m68k/708: swab(3) is broken on m68k
To: None <gnats-admin@NetBSD.ORG>
From: None <jtkohl@MIT.EDU>
List: netbsd-bugs
Date: 01/06/1995 19:35:04
>Number:         708
>Category:       port-m68k
>Synopsis:       swab(3) is broken on m68k
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan  6 19:35:01 1995
>Originator:     John Kohl
>Organization:
"Kernel Hackers `R` Us"
>Release:        <NetBSD-current source date>
>Environment:
        
System: NetBSD duality.gnu.ai.mit.edu 1.0A NetBSD 1.0A (DUALITY) #10: Thu Jan 5 23:26:52 EST 1995 mycroft@duality.gnu.ai.mit.edu:/build/src/sys/arch/hp300/compile/DUALITY hp300

>Description:
swab(3) swaps twice the requested number of bytes on m68k.
>How-To-Repeat:
use swab(3). watch it trash bytes after the ones you wanted swapped.
>Fix:
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
 
 swloop:
>Audit-Trail:
>Unformatted: