]> granicus.if.org Git - yasm/commitdiff
x86/gas: Fix no-suffix push and pop.
authorPeter Johnson <peter@tortall.net>
Sun, 3 Jul 2011 00:11:10 +0000 (17:11 -0700)
committerPeter Johnson <peter@tortall.net>
Sun, 3 Jul 2011 00:11:10 +0000 (17:11 -0700)
Previously plain "push" and "pop" would always generate a 16-bit pop
(for effective address versions).

Reported by: Alexei Svitkine

[#212 state:resolved]

modules/arch/x86/gen_x86_insn.py
modules/arch/x86/tests/gas32/Makefile.inc
modules/arch/x86/tests/gas32/gas-pop.asm [new file with mode: 0644]
modules/arch/x86/tests/gas32/gas-pop.hex [new file with mode: 0644]

index b0c26465d029f0d0838e5eed8ccbadfeb9bdd6de..b48f806ed41286cf297aa12b4e318b747037ae0e 100755 (executable)
@@ -1132,6 +1132,10 @@ add_insn("movsxd", "movsxd", parser="nasm")
 #
 # Push instructions
 #
+add_group("push",
+    def_opersize_64=64,
+    opcode=[0x50],
+    operands=[Operand(type="Reg", size="BITS", dest="Op0Add")])
 add_group("push",
     suffix="w",
     opersize=16,
@@ -1146,9 +1150,16 @@ add_group("push",
     operands=[Operand(type="Reg", size=32, dest="Op0Add")])
 add_group("push",
     suffix="q",
+    only64=True,
     def_opersize_64=64,
     opcode=[0x50],
     operands=[Operand(type="Reg", size=64, dest="Op0Add")])
+
+add_group("push",
+    def_opersize_64=64,
+    opcode=[0xFF],
+    spare=6,
+    operands=[Operand(type="RM", size="BITS", dest="EA")])
 add_group("push",
     suffix="w",
     opersize=16,
@@ -1165,10 +1176,12 @@ add_group("push",
     operands=[Operand(type="RM", size=32, dest="EA")])
 add_group("push",
     suffix="q",
+    only64=True,
     def_opersize_64=64,
     opcode=[0xFF],
     spare=6,
     operands=[Operand(type="RM", size=64, dest="EA")])
+
 add_group("push",
     cpu=["186"],
     parsers=["nasm"],
@@ -1339,6 +1352,10 @@ add_insn("pushaw", "onebyte", modifiers=[0x60, 16], cpu=["186"], not64=True)
 #
 # Pop instructions
 #
+add_group("pop",
+    def_opersize_64=64,
+    opcode=[0x58],
+    operands=[Operand(type="Reg", size="BITS", dest="Op0Add")])
 add_group("pop",
     suffix="w",
     opersize=16,
@@ -1353,9 +1370,15 @@ add_group("pop",
     operands=[Operand(type="Reg", size=32, dest="Op0Add")])
 add_group("pop",
     suffix="q",
+    only64=True,
     def_opersize_64=64,
     opcode=[0x58],
     operands=[Operand(type="Reg", size=64, dest="Op0Add")])
+
+add_group("pop",
+    def_opersize_64=64,
+    opcode=[0x8F],
+    operands=[Operand(type="RM", size="BITS", dest="EA")])
 add_group("pop",
     suffix="w",
     opersize=16,
@@ -1370,9 +1393,11 @@ add_group("pop",
     operands=[Operand(type="RM", size=32, dest="EA")])
 add_group("pop",
     suffix="q",
+    only64=True,
     def_opersize_64=64,
     opcode=[0x8F],
     operands=[Operand(type="RM", size=64, dest="EA")])
+
 # POP CS is debateably valid on the 8086, if obsolete and undocumented.
 # We don't include it because it's VERY unlikely it will ever be used
 # anywhere.  If someone really wants it they can db 0x0F it.
index 282cf75f74b7e827fb45f2ff75f86b7a656341c2..5fc0afbf51f073052aa57a60ddbc067d67bb2715 100644 (file)
@@ -19,6 +19,8 @@ EXTRA_DIST += modules/arch/x86/tests/gas32/gas-movdq32.asm
 EXTRA_DIST += modules/arch/x86/tests/gas32/gas-movdq32.hex
 EXTRA_DIST += modules/arch/x86/tests/gas32/gas-movsd.asm
 EXTRA_DIST += modules/arch/x86/tests/gas32/gas-movsd.hex
+EXTRA_DIST += modules/arch/x86/tests/gas32/gas-pop.asm
+EXTRA_DIST += modules/arch/x86/tests/gas32/gas-pop.hex
 EXTRA_DIST += modules/arch/x86/tests/gas32/gas32-jmpcall.asm
 EXTRA_DIST += modules/arch/x86/tests/gas32/gas32-jmpcall.hex
 
diff --git a/modules/arch/x86/tests/gas32/gas-pop.asm b/modules/arch/x86/tests/gas32/gas-pop.asm
new file mode 100644 (file)
index 0000000..7c47ebe
--- /dev/null
@@ -0,0 +1,50 @@
+.code64
+push %cx               # out: 66 51
+pop %cx                        # out: 66 59
+push %rcx              # out: 51
+pop %rcx               # out: 59
+pushw %cx              # out: 66 51
+popw %cx               # out: 66 59
+pushq %rcx             # out: 51
+popq %rcx              # out: 59
+
+push -24(%rcx)         # out: ff 71 e8
+pop -24(%rcx)          # out: 8f 41 e8
+pushw -24(%rcx)                # out: 66 ff 71 e8
+popw -24(%rcx)         # out: 66 8f 41 e8
+pushq -24(%rcx)                # out: ff 71 e8
+popq -24(%rcx)         # out: 8f 41 e8
+
+.code32
+push %cx               # out: 66 51
+pop %cx                        # out: 66 59
+push %ecx              # out: 51
+pop %ecx               # out: 59
+pushw %cx              # out: 66 51
+popw %cx               # out: 66 59
+pushl %ecx             # out: 51
+popl %ecx              # out: 59
+
+push -24(%ecx)         # out: ff 71 e8
+pop -24(%ecx)          # out: 8f 41 e8
+pushw -24(%ecx)                # out: 66 ff 71 e8
+popw -24(%ecx)         # out: 66 8f 41 e8
+pushl -24(%ecx)                # out: ff 71 e8
+popl -24(%ecx)         # out: 8f 41 e8
+
+.code16
+push %cx               # out: 51
+pop %cx                        # out: 59
+push %ecx              # out: 66 51
+pop %ecx               # out: 66 59
+pushw %cx              # out: 51
+popw %cx               # out: 59
+pushl %ecx             # out: 66 51
+popl %ecx              # out: 66 59
+
+push -24(%bp)          # out: ff 76 e8
+pop -24(%bp)           # out: 8f 46 e8
+pushw -24(%bp)         # out: ff 76 e8
+popw -24(%bp)          # out: 8f 46 e8
+pushl -24(%bp)         # out: 66 ff 76 e8
+popl -24(%bp)          # out: 66 8f 46 e8
diff --git a/modules/arch/x86/tests/gas32/gas-pop.hex b/modules/arch/x86/tests/gas32/gas-pop.hex
new file mode 100644 (file)
index 0000000..3074437
--- /dev/null
@@ -0,0 +1,456 @@
+7f 
+45 
+4c 
+46 
+01 
+01 
+01 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+01 
+00 
+03 
+00 
+01 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+01 
+00 
+00 
+00 
+00 
+00 
+00 
+34 
+00 
+00 
+00 
+00 
+00 
+28 
+00 
+05 
+00 
+01 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+66 
+51 
+66 
+59 
+51 
+59 
+66 
+51 
+66 
+59 
+51 
+59 
+ff 
+71 
+e8 
+8f 
+41 
+e8 
+66 
+ff 
+71 
+e8 
+66 
+8f 
+41 
+e8 
+ff 
+71 
+e8 
+8f 
+41 
+e8 
+66 
+51 
+66 
+59 
+51 
+59 
+66 
+51 
+66 
+59 
+51 
+59 
+ff 
+71 
+e8 
+8f 
+41 
+e8 
+66 
+ff 
+71 
+e8 
+66 
+8f 
+41 
+e8 
+ff 
+71 
+e8 
+8f 
+41 
+e8 
+51 
+59 
+66 
+51 
+66 
+59 
+51 
+59 
+66 
+51 
+66 
+59 
+ff 
+76 
+e8 
+8f 
+46 
+e8 
+ff 
+76 
+e8 
+8f 
+46 
+e8 
+66 
+ff 
+76 
+e8 
+66 
+8f 
+46 
+e8 
+00 
+2e 
+74 
+65 
+78 
+74 
+00 
+2e 
+73 
+74 
+72 
+74 
+61 
+62 
+00 
+2e 
+73 
+79 
+6d 
+74 
+61 
+62 
+00 
+2e 
+73 
+68 
+73 
+74 
+72 
+74 
+61 
+62 
+00 
+00 
+00 
+00 
+00 
+2d 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+01 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+04 
+00 
+f1 
+ff 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+03 
+00 
+04 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+17 
+00 
+00 
+00 
+03 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+a0 
+00 
+00 
+00 
+21 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+07 
+00 
+00 
+00 
+03 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+c4 
+00 
+00 
+00 
+03 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+0f 
+00 
+00 
+00 
+02 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+c8 
+00 
+00 
+00 
+30 
+00 
+00 
+00 
+02 
+00 
+00 
+00 
+03 
+00 
+00 
+00 
+04 
+00 
+00 
+00 
+10 
+00 
+00 
+00 
+01 
+00 
+00 
+00 
+01 
+00 
+00 
+00 
+06 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+40 
+00 
+00 
+00 
+60 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+10 
+00 
+00 
+00 
+00 
+00 
+00 
+00