aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2007-01-13 16:48:00 +0000
committerH.J. Lu <hjl.tools@gmail.com>2007-01-13 16:48:00 +0000
commit99018f420ad6949183a05e15a39c2538e7be57cb (patch)
treebc8650b5029da8c287063b497d5a92b7af1f7226 /gas
parent97bac0d9c5e105dc9eb202fc11d87a43dc0b3c32 (diff)
downloadgdb-99018f420ad6949183a05e15a39c2538e7be57cb.zip
gdb-99018f420ad6949183a05e15a39c2538e7be57cb.tar.gz
gdb-99018f420ad6949183a05e15a39c2538e7be57cb.tar.bz2
2007-01-13 H.J. Lu <hongjiu.lu@intel.com>
* config/tc-i386.c (build_modrm_byte): Check number of operands when procssing memory/register operand.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog5
-rw-r--r--gas/config/tc-i386.c30
2 files changed, 20 insertions, 15 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 09b11b0..ea5596c 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-13 H.J. Lu <hongjiu.lu@intel.com>
+
+ * config/tc-i386.c (build_modrm_byte): Check number of operands
+ when procssing memory/register operand.
+
2007-01-12 Nick Clifton <nickc@redhat.com>
PR gas/3856
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 889bfc3..2f50bcf 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -3443,9 +3443,12 @@ build_modrm_byte (void)
if (i.mem_operands)
{
unsigned int fake_zero_displacement = 0;
- unsigned int op = ((i.types[0] & AnyMem)
- ? 0
- : (i.types[1] & AnyMem) ? 1 : 2);
+ unsigned int op;
+
+ for (op = 0; op < i.operands; op++)
+ if ((i.types[op] & AnyMem))
+ break;
+ assert (op < i.operands);
default_seg = &ds;
@@ -3616,18 +3619,15 @@ build_modrm_byte (void)
registers are coded into the i.rm.reg field. */
if (i.reg_operands)
{
- unsigned int op =
- ((i.types[0]
- & (Reg | RegMMX | RegXMM
- | SReg2 | SReg3
- | Control | Debug | Test))
- ? 0
- : ((i.types[1]
- & (Reg | RegMMX | RegXMM
- | SReg2 | SReg3
- | Control | Debug | Test))
- ? 1
- : 2));
+ unsigned int op;
+
+ for (op = 0; op < i.operands; op++)
+ if ((i.types[op] & (Reg | RegMMX | RegXMM
+ | SReg2 | SReg3
+ | Control | Debug | Test)))
+ break;
+ assert (op < i.operands);
+
/* If there is an extension opcode to put here, the register
number must be put into the regmem field. */
if (i.tm.extension_opcode != None)