This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: PR gas/1874: mwait/monitor don't work in 64bit


On Thu, Nov 17, 2005 at 06:05:57PM +0100, Jan Beulich wrote:
> >>> "H. J. Lu" <hjl@lucon.org> 17.11.05 17:44:06 >>>
> >On Thu, Nov 17, 2005 at 10:30:05AM +0100, Jan Beulich wrote:
> >> 
> >> Regarding the patch, I don't think hard-coding the address size
> >> override for 16-bit operation of monitor is appropriate - under
> .code16
> >> this is not going to produce the desired effect (and likewise is
> the
> >> opposite 32-bit operation in 16-bit mode then missing the override).
> The
> >> base problem here is that monitor's address operand, when
> explicitly
> >
> >The opcode is the same for both 32bit and 64bit modes. The address
> > size ovverride only changes the size of EAX/RAX. I don't see how
> >".code16" can be used with it. As for ".code32", it works fine:
> 
> Why shouldn't BIOS code be using this? This would likely require
> .code16.
> 

monitor/mwait work in 16bit mode. The address size override prefix can
be used to change the AX size. This patch support memory as the first
operand of monitor. 

-----
gas/

2005-11-17  H.J. Lu  <hongjiu.lu@intel.com>

	* config/tc-i386.c (md_assemble): Don't check the first operand of
	"monitor/mwait" if it isn't a register.
	(process_suffix): Handle monitor for 16bit mode.
	(i386_index_check): Handle monitor.

gas/testsuite/

2005-11-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR gas/1874
	* gas/i386/i386.exp: Add x86-64-prescott for 64bit.

	* gas/i386/prescott.s: Test new monitor syntax. Test address
	size override for monitor.
	* gas/i386/prescott.d: Updated.

	* gas/i386/suffix.d: Updated.

	* gas/i386/x86-64-prescott.d: New file.
	* gas/i386/x86-64-prescott.s: Likewise.

include/opcode/

2005-11-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR gas/1874
	* i386.h (i386_optab): Support memory as the first operand of
	monitor. Add 64bit support for monitor and mwait.

opcodes/

2005-11-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR gas/1874
	* configure.in (AC_GNU_SOURCE): Added.
	(AC_CHECK_DECLS): Add stpcpy.
	* configure: Regenerated.
	* config.in: Likewise.

	* i386-dis.c (PNI_Fixup): Change the the first operand of
	monitor to memory. Add 64bit and address size override support
	for monitor and mwait.

	* sysdep.h (stpcpy): Declare if HAVE_DECL_STPCPY isn't defined.

--- binutils/gas/config/tc-i386.c.pni	2005-11-11 10:48:52.000000000 -0800
+++ binutils/gas/config/tc-i386.c	2005-11-17 11:56:03.000000000 -0800
@@ -1538,7 +1538,7 @@ md_assemble (line)
 	  unsigned int x;
 
 	  for (x = 0; x < i.operands; x++)
-	    if (i.op[x].regs->reg_num != x)
+	    if (i.op[x].regs && i.op[x].regs->reg_num != x)
 	      as_bad (_("can't use register '%%%s' as operand %d in '%s'."),
 			i.op[x].regs->reg_name, x + 1, i.tm.name);
 	  i.operands = 0;
@@ -2545,12 +2545,25 @@ process_suffix (void)
       /* Now select between word & dword operations via the operand
 	 size prefix, except for instructions that will ignore this
 	 prefix anyway.  */
-      if (i.suffix != QWORD_MNEM_SUFFIX
-	  && i.suffix != LONG_DOUBLE_MNEM_SUFFIX
-	  && !(i.tm.opcode_modifier & (IgnoreSize | FloatMF))
-	  && ((i.suffix == LONG_MNEM_SUFFIX) == (flag_code == CODE_16BIT)
-	      || (flag_code == CODE_64BIT
-		  && (i.tm.opcode_modifier & JumpByte))))
+      if ((i.tm.cpu_flags & CpuPNI)
+	  && i.tm.base_opcode == 0x0f01
+	  && i.tm.extension_opcode == 0xc8)
+	{
+	  /* monitor in SSE3 is a very special case. In 16bit mode,
+	     the default is AX. The address size override prefix is
+	     used to indicate EAX.  */
+	  if (flag_code == CODE_16BIT
+	      && (i.base_reg->reg_type & Reg32)
+	      && i.prefix [ADDR_PREFIX] == 0
+	      && !add_prefix (ADDR_PREFIX_OPCODE))
+	    return 0;
+	}
+      else if (i.suffix != QWORD_MNEM_SUFFIX
+	       && i.suffix != LONG_DOUBLE_MNEM_SUFFIX
+	       && !(i.tm.opcode_modifier & (IgnoreSize | FloatMF))
+	       && ((i.suffix == LONG_MNEM_SUFFIX) == (flag_code == CODE_16BIT)
+		   || (flag_code == CODE_64BIT
+		       && (i.tm.opcode_modifier & JumpByte))))
 	{
 	  unsigned int prefix = DATA_PREFIX_OPCODE;
 
@@ -4322,6 +4335,28 @@ i386_index_check (operand_string)
 	  || (i.types[0] & Disp))
 	ok = 0;
     }
+  else if ((current_templates->start->cpu_flags & CpuPNI)
+	   && current_templates->end[-1].operand_types[0] == AnyMem
+	   && current_templates->start->base_opcode == 0x0f01
+	   && current_templates->start->extension_opcode == 0xc8)
+    {
+      /* Memory operand of "monitor" is special in that it only allows
+	 rAX as their memory address. */
+      unsigned RegXX;
+
+      if (flag_code == CODE_64BIT)
+	RegXX = i.prefix[ADDR_PREFIX] == 0 ? Reg64 : Reg32;
+      else
+	RegXX = (flag_code == CODE_16BIT) ^ (i.prefix[ADDR_PREFIX] != 0)
+		? Reg16
+		: Reg32;
+      if (!i.base_reg
+	  || !(i.base_reg->reg_type & Acc)
+	  || !(i.base_reg->reg_type & RegXX)
+	  || i.index_reg
+	  || (i.types[0] & Disp))
+	ok = 0;
+    }
   else if (flag_code == CODE_64BIT)
      {
        unsigned RegXX = (i.prefix[ADDR_PREFIX] == 0 ? Reg64 : Reg32);
--- binutils/gas/testsuite/gas/i386/i386.exp.pni	2005-11-11 10:48:53.000000000 -0800
+++ binutils/gas/testsuite/gas/i386/i386.exp	2005-11-15 15:37:50.000000000 -0800
@@ -131,6 +131,7 @@ if [expr ([istarget "i*86-*-*"] || [ista
     run_dump_test "svme64"
     run_dump_test "x86-64-vmx"
     run_dump_test "immed64"
+    run_dump_test "x86-64-prescott"
 
     # For ELF targets verify that @unwind works.
     if { ([istarget "*-*-elf*"] || [istarget "*-*-linux*"]
--- binutils/gas/testsuite/gas/i386/prescott.d.pni	2004-06-23 08:06:57.000000000 -0700
+++ binutils/gas/testsuite/gas/i386/prescott.d	2005-11-17 11:33:18.000000000 -0800
@@ -22,8 +22,8 @@ Disassembly of section .text:
   3b:	f2 0f 7d d2 [ 	]*hsubps %xmm2,%xmm2
   3f:	f2 0f 7d 1c 24 [ 	]*hsubps \(%esp\),%xmm3
   44:	f2 0f f0 2e [ 	]*lddqu  \(%esi\),%xmm5
-  48:	0f 01 c8 [ 	]*monitor %eax,%ecx,%edx
-  4b:	0f 01 c8 [ 	]*monitor %eax,%ecx,%edx
+  48:	0f 01 c8 [ 	]*monitor \(%eax\),%ecx,%edx
+  4b:	0f 01 c8 [ 	]*monitor \(%eax\),%ecx,%edx
   4e:	f2 0f 12 f7 [ 	]*movddup %xmm7,%xmm6
   52:	f2 0f 12 38 [ 	]*movddup \(%eax\),%xmm7
   56:	f3 0f 16 01 [ 	]*movshdup \(%ecx\),%xmm0
@@ -32,5 +32,7 @@ Disassembly of section .text:
   62:	f3 0f 12 dc [ 	]*movsldup %xmm4,%xmm3
   66:	0f 01 c9 [ 	]*mwait  %eax,%ecx
   69:	0f 01 c9 [ 	]*mwait  %eax,%ecx
-  6c:	00 00 [ 	]*add    %al,\(%eax\)
+  6c:	0f 01 c8 [ 	]*monitor \(%eax\),%ecx,%edx
+  6f:	67 0f 01 c8 [ 	]*monitor \(%ax\),%ecx,%edx
+  73:	67 0f 01 c8 [ 	]*monitor \(%ax\),%ecx,%edx
 	...
--- binutils/gas/testsuite/gas/i386/prescott.s.pni	2004-06-23 08:06:58.000000000 -0700
+++ binutils/gas/testsuite/gas/i386/prescott.s	2005-11-17 11:31:57.000000000 -0800
@@ -29,4 +29,8 @@ foo:
 	mwait
 	mwait		%eax,%ecx
 
+	monitor		(%eax),%ecx,%edx
+	monitor		(%ax),%ecx,%edx
+	addr16 monitor
+
 	.p2align	4,0
--- binutils/gas/testsuite/gas/i386/suffix.d.pni	2005-07-18 21:11:19.000000000 -0700
+++ binutils/gas/testsuite/gas/i386/suffix.d	2005-11-17 11:34:25.000000000 -0800
@@ -6,7 +6,7 @@
 Disassembly of section .text:
 
 0+000 <foo>:
-   0:	0f 01 c8 [ 	]*monitor %eax,%ecx,%edx
+   0:	0f 01 c8 [ 	]*monitor \(%eax\),%ecx,%edx
    3:	0f 01 c9 [ 	]*mwait  %eax,%ecx
    6:	0f 01 c1 [ 	]*vmcall 
    9:	0f 01 c2 [ 	]*vmlaunch 
--- binutils/gas/testsuite/gas/i386/x86-64-prescott.d.pni	2005-11-15 15:33:49.000000000 -0800
+++ binutils/gas/testsuite/gas/i386/x86-64-prescott.d	2005-11-17 11:36:57.000000000 -0800
@@ -0,0 +1,37 @@
+#objdump: -dw
+#name: x86-64 prescott
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+000 <foo>:
+   0:	66 0f d0 01 [ 	]*addsubpd \(%rcx\),%xmm0
+   4:	66 0f d0 ca [ 	]*addsubpd %xmm2,%xmm1
+   8:	f2 0f d0 13 [ 	]*addsubps \(%rbx\),%xmm2
+   c:	f2 0f d0 dc [ 	]*addsubps %xmm4,%xmm3
+  10:	df 88 90 90 90 90 [ 	]*fisttp 0xffffffff90909090\(%rax\)
+  16:	db 88 90 90 90 90 [ 	]*fisttpl 0xffffffff90909090\(%rax\)
+  1c:	dd 88 90 90 90 90 [ 	]*fisttpll 0xffffffff90909090\(%rax\)
+  22:	66 0f 7c 65 00 [ 	]*haddpd 0x0\(%rbp\),%xmm4
+  27:	66 0f 7c ee [ 	]*haddpd %xmm6,%xmm5
+  2b:	f2 0f 7c 37 [ 	]*haddps \(%rdi\),%xmm6
+  2f:	f2 0f 7c f8 [ 	]*haddps %xmm0,%xmm7
+  33:	66 0f 7d c1 [ 	]*hsubpd %xmm1,%xmm0
+  37:	66 0f 7d 0a [ 	]*hsubpd \(%rdx\),%xmm1
+  3b:	f2 0f 7d d2 [ 	]*hsubps %xmm2,%xmm2
+  3f:	f2 0f 7d 1c 24 [ 	]*hsubps \(%rsp\),%xmm3
+  44:	f2 0f f0 2e [ 	]*lddqu  \(%rsi\),%xmm5
+  48:	0f 01 c8 [ 	]*monitor \(%rax\),%rcx,%rdx
+  4b:	0f 01 c8 [ 	]*monitor \(%rax\),%rcx,%rdx
+  4e:	f2 0f 12 f7 [ 	]*movddup %xmm7,%xmm6
+  52:	f2 0f 12 38 [ 	]*movddup \(%rax\),%xmm7
+  56:	f3 0f 16 01 [ 	]*movshdup \(%rcx\),%xmm0
+  5a:	f3 0f 16 ca [ 	]*movshdup %xmm2,%xmm1
+  5e:	f3 0f 12 13 [ 	]*movsldup \(%rbx\),%xmm2
+  62:	f3 0f 12 dc [ 	]*movsldup %xmm4,%xmm3
+  66:	0f 01 c9 [ 	]*mwait  %rax,%rcx
+  69:	0f 01 c9 [ 	]*mwait  %rax,%rcx
+  6c:	67 0f 01 c8 [ 	]*monitor \(%eax\),%rcx,%rdx
+  70:	67 0f 01 c8 [ 	]*monitor \(%eax\),%rcx,%rdx
+	...
--- binutils/gas/testsuite/gas/i386/x86-64-prescott.s.pni	2005-11-15 15:33:47.000000000 -0800
+++ binutils/gas/testsuite/gas/i386/x86-64-prescott.s	2005-11-17 11:35:47.000000000 -0800
@@ -0,0 +1,35 @@
+#Prescott New Instructions
+
+	.text
+foo:
+	addsubpd	(%rcx),%xmm0
+	addsubpd	%xmm2,%xmm1
+	addsubps	(%rbx),%xmm2
+	addsubps	%xmm4,%xmm3
+	fisttp		0x90909090(%rax)
+	fisttpl		0x90909090(%rax)
+	fisttpll	0x90909090(%rax)
+	haddpd		0x0(%rbp),%xmm4
+	haddpd		%xmm6,%xmm5
+	haddps		(%rdi),%xmm6
+	haddps		%xmm0,%xmm7
+	hsubpd		%xmm1,%xmm0
+	hsubpd		(%rdx),%xmm1
+	hsubps		%xmm2,%xmm2
+	hsubps		(%rsp,1),%xmm3
+	lddqu		(%rsi),%xmm5
+	monitor
+	monitor		(%rax),%rcx,%rdx
+	movddup		%xmm7,%xmm6
+	movddup		(%rax),%xmm7
+	movshdup	(%rcx),%xmm0
+	movshdup	%xmm2,%xmm1
+	movsldup	(%rbx),%xmm2
+	movsldup	%xmm4,%xmm3
+	mwait
+	mwait		%rax,%rcx
+
+	monitor		(%eax),%rcx,%rdx
+	addr32 monitor
+
+	.p2align	4,0
--- binutils/include/opcode/i386.h.pni	2005-07-27 08:41:15.000000000 -0700
+++ binutils/include/opcode/i386.h	2005-11-17 11:44:31.000000000 -0800
@@ -1346,14 +1346,29 @@ static const template i386_optab[] =
 {"hsubps",    2, 0xf20f7d,  X, CpuPNI, NoSuf|IgnoreSize|Modrm,	{ RegXMM|LLongMem, RegXMM, 0 } },
 {"lddqu",     2, 0xf20ff0,  X, CpuPNI, NoSuf|IgnoreSize|Modrm,	{ LLongMem, RegXMM, 0 } },
 {"monitor",   0, 0x0f01, 0xc8, CpuPNI, NoSuf|ImmExt,	{ 0, 0, 0} },
-/* Need to ensure only "monitor %eax,%ecx,%edx" is accepted. */
-{"monitor",   3, 0x0f01, 0xc8, CpuPNI, NoSuf|ImmExt,	{ Reg32, Reg32, Reg32} },
+/* monitor is very special. CX and DX are always 64bits with zero upper
+   32bits in 64bit mode, and 32bits in 16bit and 32bit modes. The
+   address size override prefix can be used to overrride the AX size in
+   all modes.  */
+/* The old syntax for 32bit only. Need to ensure only
+   "monitor %eax,%ecx,%edx" is accepted. */
+{"monitor",   3, 0x0f01, 0xc8, CpuPNI|CpuNo64, NoSuf|ImmExt,	{ Reg32, Reg32, Reg32 } },
+/* The new syntax for 32bit. Need to ensure only
+   "monitor (%eax)/(%ax),%ecx,%edx" is accepted. */
+{"monitor",   3, 0x0f01, 0xc8, CpuPNI|CpuNo64, NoSuf|ImmExt,	{ AnyMem, Reg32, Reg32 } },
+/* The syntax for 64bit. Need to ensure only
+   "monitor (%rax)/(%eax),%rcx,%rdx" is accepted. */
+{"monitor",   3, 0x0f01, 0xc8, CpuPNI|Cpu64, NoSuf|ImmExt|NoRex64,	{ AnyMem, Reg64, Reg64 } },
 {"movddup",   2, 0xf20f12,  X, CpuPNI, NoSuf|IgnoreSize|Modrm,	{ RegXMM|LLongMem, RegXMM, 0 } },
 {"movshdup",  2, 0xf30f16,  X, CpuPNI, NoSuf|IgnoreSize|Modrm,	{ RegXMM|LLongMem, RegXMM, 0 } },
 {"movsldup",  2, 0xf30f12,  X, CpuPNI, NoSuf|IgnoreSize|Modrm,	{ RegXMM|LLongMem, RegXMM, 0 } },
 {"mwait",     0, 0x0f01, 0xc9, CpuPNI, NoSuf|ImmExt,	{ 0, 0, 0} },
+/* mwait is very special. AX and CX are always 64bits with zero upper
+   32bits in 64bit mode, and 32bits in 16bit and 32bit modes.  */
 /* Need to ensure only "mwait %eax,%ecx" is accepted.  */
-{"mwait",     2, 0x0f01, 0xc9, CpuPNI, NoSuf|ImmExt,	{ Reg32, Reg32, 0} },
+{"mwait",     2, 0x0f01, 0xc9, CpuPNI|CpuNo64, NoSuf|ImmExt,	{ Reg32, Reg32, 0} },
+/* Need to ensure only "mwait %rax,%rcx" is accepted.  */
+{"mwait",     2, 0x0f01, 0xc9, CpuPNI|Cpu64, NoSuf|ImmExt|NoRex64,	{ Reg64, Reg64, 0} },
 
 /* VMX instructions.  */
 {"vmcall",    0, 0x0f01, 0xc1, CpuVMX, NoSuf|ImmExt,	{ 0, 0, 0} },
--- binutils/opcodes/config.in.pni	2005-04-01 08:54:17.000000000 -0800
+++ binutils/opcodes/config.in	2005-11-17 10:17:56.000000000 -0800
@@ -28,6 +28,10 @@
    don't. */
 #undef HAVE_DECL_BASENAME
 
+/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
+   */
+#undef HAVE_DECL_STPCPY
+
 /* Define to 1 if you have the `getcwd' function. */
 #undef HAVE_GETCWD
 
@@ -150,6 +154,11 @@
 /* Version number of package */
 #undef VERSION
 
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
--- binutils/opcodes/configure.in.pni	2005-10-26 15:03:33.000000000 -0700
+++ binutils/opcodes/configure.in	2005-11-17 10:17:52.000000000 -0800
@@ -59,6 +59,7 @@ AC_EXEEXT
 # host-specific stuff:
 
 AC_PROG_CC
+AC_GNU_SOURCE
 
 ALL_LINGUAS="fr sv tr es da de id pt_BR ro nl fi vi ga"
 CY_GNU_GETTEXT
@@ -72,7 +73,7 @@ AC_PROG_INSTALL
 
 AC_CHECK_HEADERS(string.h strings.h stdlib.h)
 
-AC_CHECK_DECLS(basename)
+AC_CHECK_DECLS([basename, stpcpy])
 
 cgen_maint=no
 cgendir='$(srcdir)/../cgen'
--- binutils/opcodes/configure.pni	2005-11-11 10:48:50.000000000 -0800
+++ binutils/opcodes/configure	2005-11-17 10:17:59.000000000 -0800
@@ -5119,6 +5119,12 @@ ac_link='$CC -o conftest$ac_exeext $CFLA
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+cat >>confdefs.h <<\_ACEOF
+#define _GNU_SOURCE 1
+_ACEOF
+
+
+
 ALL_LINGUAS="fr sv tr es da de id pt_BR ro nl fi vi ga"
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
@@ -8607,6 +8613,76 @@ _ACEOF
 
 
 fi
+echo "$as_me:$LINENO: checking whether stpcpy is declared" >&5
+echo $ECHO_N "checking whether stpcpy is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_stpcpy+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+#ifndef stpcpy
+  char *p = (char *) stpcpy;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_have_decl_stpcpy=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_stpcpy=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_stpcpy" >&5
+echo "${ECHO_T}$ac_cv_have_decl_stpcpy" >&6
+if test $ac_cv_have_decl_stpcpy = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STPCPY 1
+_ACEOF
+
+
+else
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STPCPY 0
+_ACEOF
+
+
+fi
 
 
 
--- binutils/opcodes/i386-dis.c.pni	2005-11-11 10:48:50.000000000 -0800
+++ binutils/opcodes/i386-dis.c	2005-11-17 11:30:56.000000000 -0800
@@ -4412,40 +4412,55 @@ PNI_Fixup (int extrachar ATTRIBUTE_UNUSE
   if (mod == 3 && reg == 1 && rm <= 1)
     {
       /* Override "sidt".  */
-      char *p = obuf + strlen (obuf) - 4;
+      size_t olen = strlen (obuf);
+      char *p = obuf + olen - 4;
+      const char **names = mode_64bit ? names64 : names32;
 
       /* We might have a suffix when disassembling with -Msuffix.  */
       if (*p == 'i')
 	--p;
 
+      /* Remove "addr16/addr32" if we aren't in Intel mode.  */
+      if (!intel_syntax
+	  && (prefixes & PREFIX_ADDR)
+	  && olen >= (4 + 7)
+	  && *(p - 1) == ' '
+	  && strncmp (p - 7, "addr", 4) == 0
+	  && (strncmp (p - 3, "16", 2) == 0
+	      || strncmp (p - 3, "32", 2) == 0))
+	p -= 7;
+
       if (rm)
 	{
 	  /* mwait %eax,%ecx  */
 	  strcpy (p, "mwait");
 	  if (!intel_syntax)
-	    strcpy (op1out, names32[0]);
+	    strcpy (op1out, names[0]);
 	}
       else
 	{
-	  /* monitor %eax,%ecx,%edx"  */
+	  /* monitor (%eax),%ecx,%edx"  */
 	  strcpy (p, "monitor");
 	  if (!intel_syntax)
 	    {
-	      if (!mode_64bit)
-		strcpy (op1out, names32[0]);
-	      else if (!(prefixes & PREFIX_ADDR))
-		strcpy (op1out, names64[0]);
+	      const char **op1_names;
+	      *op1out = '(';
+	      if (!(prefixes & PREFIX_ADDR))
+		op1_names = names;
 	      else
 		{
-		  strcpy (op1out, names32[0]);
+		  op1_names = mode_64bit ? names32 : names16;
 		  used_prefixes |= PREFIX_ADDR;
 		}
-	      strcpy (op3out, names32[2]);
+	      p = stpcpy (op1out + 1, op1_names [0]);
+	      *p++ = ')';
+	      *p++ = '\0';
+	      strcpy (op3out, names[2]);
 	    }
 	}
       if (!intel_syntax)
 	{
-	  strcpy (op2out, names32[1]);
+	  strcpy (op2out, names[1]);
 	  two_source_ops = 1;
 	}
 
--- binutils/opcodes/sysdep.h.pni	2005-07-06 08:45:35.000000000 -0700
+++ binutils/opcodes/sysdep.h	2005-11-17 10:10:29.000000000 -0800
@@ -41,3 +41,7 @@
 #include <strings.h>
 #endif
 #endif
+
+#if !HAVE_DECL_STPCPY
+extern char *stpcpy (char *, const char *);
+#endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]