Subject: bin/6809: opcode for i386 'pand' MMX instruction is wrong
To: None <gnats-bugs@gnats.netbsd.org>
From: None <Havard.Eidnes@runit.sintef.no>
List: netbsd-bugs
Date: 01/14/1999 21:03:49
>Number:         6809
>Category:       bin
>Synopsis:       opcode for 'pand' MMX instruction is wrong
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 14 12:20:01 1999
>Last-Modified:
>Originator:     Havard Eidnes
>Organization:
	RUNIT AS
>Release:        NetBSD-current Jan 5, 1999
>Environment:

System: NetBSD vader.runit.sintef.no 1.3I NetBSD 1.3I (VADER) #0: Sat Jan 9 18:53:46 MET 1999 he@hugin.runit.sintef.no:/usr/src/sys/arch/i386/compile/VADER i386

>Description:

	The GNU assembler version 2.8.1 has the wrong opcode for the
	MMX instruction 'pand'.  It is 0x0fda but should be 0x0fdb, as
	Bill Sommerfeld told me on port-i386.  Trying to run code with
	the 'pand' instruction leads to an illegal instruction signal.

	Similarly, disassembly of the 'pand' instruction is also
	wrong.

>How-To-Repeat:

	Try to run this program:

#include <sys/types.h>
#include <stdio.h>

int
main(argc, argv)
    int argc;
    char **argv;
{
    quad_t qa = 5, qb = 6, qc;
   
    __asm("
	movq %1, %%mm6
	movq %2, %%mm7
	pand %%mm6, %%mm7
	movq %%mm7, %0
	" : "=m" (qc) : "m" (qa), "m" (qb));
    
    printf("%qd\n", qc);
    return(0);
}

	and use 'gdb' to see that it bombs out on what appears to be
	the 'pand' instruction.

>Fix:

	This fixes both the "wrong opcode" and the disassembly of the
	'pand' instruction.

--- gnu/dist/include/opcode/i386.h.dist	Thu Sep 25 13:14:33 1997
+++ gnu/dist/include/opcode/i386.h	Thu Jan 14 16:42:21 1999
@@ -829,5 +829,5 @@
 {"paddusb",   2, 0x0fdc, _, Modrm, { RegMMX|WordMem, RegMMX, 0 } },
 {"paddusw",   2, 0x0fdd, _, Modrm, { RegMMX|WordMem, RegMMX, 0 } },
-{"pand",      2, 0x0fda, _, Modrm, { RegMMX|WordMem, RegMMX, 0 } },
+{"pand",      2, 0x0fdb, _, Modrm, { RegMMX|WordMem, RegMMX, 0 } },
 {"pandn",     2, 0x0fdf, _, Modrm, { RegMMX|WordMem, RegMMX, 0 } },
 {"pcmpeqb",   2, 0x0f74, _, Modrm, { RegMMX|WordMem, RegMMX, 0 } },
--- gnu/dist/opcodes/i386-dis.c.dist	Thu Sep 25 13:15:31 1997
+++ gnu/dist/opcodes/i386-dis.c	Thu Jan 14 19:18:51 1999
@@ -735,6 +735,6 @@
   { "psubusb", MX, EM },
   { "psubusw", MX, EM },
-  { "pand", MX, EM },
   { "(bad)" },
+  { "pand", MX, EM },
   { "paddusb", MX, EM },
   { "paddusw", MX, EM },
@@ -810,5 +810,5 @@
   /* b0 */ 1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1, /* bf */
   /* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
-  /* d0 */ 0,1,1,1,0,1,0,0,1,1,1,0,1,1,0,1, /* df */
+  /* d0 */ 0,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1, /* df */
   /* e0 */ 0,1,1,0,0,1,0,0,1,1,0,1,1,1,0,1, /* ef */
   /* f0 */ 0,1,1,1,0,1,0,0,1,1,1,0,1,1,1,0  /* ff */
>Audit-Trail:
>Unformatted: