Closed RyanGlScott closed 2 years ago
I thought that this would suffice to handle the cases for immediates:
diff --git a/data/optable.xml b/data/optable.xml
index 7d02fba..c5facfc 100644
--- a/data/optable.xml
+++ b/data/optable.xml
@@ -6982,7 +6982,7 @@
<def>
<pfx>oso</pfx>
<opc>68</opc>
- <opr>Iz</opr>
+ <opr>sIz</opr>
<mode>def64</mode>
</def>
<def>
@@ -6994,7 +6994,7 @@
<def>
<pfx>oso</pfx>
<opc>6a</opc>
- <opr>Ib</opr>
+ <opr>sIb</opr>
<mode>def64</mode>
</def>
</instruction>
diff --git a/tests/Assemble.hs b/tests/Assemble.hs
index ace04f5..e5a2179 100644
--- a/tests/Assemble.hs
+++ b/tests/Assemble.hs
@@ -31,9 +31,9 @@ j20 = [D.JumpOffset D.JSize8 (D.FixedOffset (20 - 2))]
testCases :: [(AsmFlavor, String, Maybe D.InstructionInstance)]
testCases = [ (Att, "ret", mkI "ret" [])
, (Att, "int $0x3", mkI "int3" [])
- , (Att, "push $0x8", mkI "push" [D.ByteImm 8])
- , (Att, "pushw $0xfff", fmap setOSO $ mkI "push" [D.WordImm 0xfff])
- , (Att, "push $0x2000000", mkI "push" [D.DWordImm (D.Imm32Concrete 0x2000000)])
+ , (Att, "push $0x8", mkI "push" [D.ByteSignedImm 8])
+ , (Att, "pushw $0xfff", fmap setOSO $ mkI "push" [D.WordSignedImm 0xfff])
+ , (Att, "push $0x2000000", mkI "push" [D.DWordSignedImm 0x2000000])
-- The subtraction here is gross, but required because
-- the jump is relative to the IP, which is incremented
-- past the jump by the time it executes.
However, that causes the (Att, "pushw $0xfff", fmap setOSO $ mkI "push" [D.WordSignedImm 0xfff])
test case to fail. Some investigation reveals that this is because matchOperandType
returns False
. Ideally, we would hit this case of matchOperandType
:
However, oso
is False
here because of this line:
Ugh. I guess this means we'll need to infer the presence of oso
like we do for REX
?
Fixed in #37.
If you run
DumpInstr
on apush
instruction with an immediate argument, you'll get something like this:Notice that while the address size (and in this case, the operand size as well)
iiAddrSize
isSize64
(8 bytes), while the operand isByteImm 0
(only 1 byte). This is a bit dubious. Per the ISA manual:Since
push
sign-extends the operand in some cases, ideally we would indicate this in theInstructionInstance
itself. In the example above, for instance, we should be usingByteSignedImm
instead ofByteImm
. Fixing this may be as simple as editing the parts ofoptable.xml
that pertain topush
.