aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2020-08-02 20:57:17 -0700
committeriximeow <me@iximeow.net>2020-08-09 01:38:57 -0700
commit4112c2282a207ab0738db44dfc69caf68fe50de9 (patch)
tree02d1e364cfc33eb044bc7ef1279cf0709a3cfba7
parentf87d5d33c50adc6c7112945e61b23e4c4dd3e83c (diff)
fix setcc decoding
-rw-r--r--src/long_mode/mod.rs17
-rw-r--r--test/long_mode/mod.rs5
2 files changed, 17 insertions, 5 deletions
diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs
index 61ae89f..b620092 100644
--- a/src/long_mode/mod.rs
+++ b/src/long_mode/mod.rs
@@ -3524,7 +3524,13 @@ pub enum OperandCode {
x87_de = OperandCodeBuilder::new().special_case(37).bits(),
x87_df = OperandCodeBuilder::new().special_case(38).bits(),
- Eb_R0 = OperandCodeBuilder::new().special_case(39).bits(),
+ Eb_R0 = OperandCodeBuilder::new()
+ .read_modrm()
+ .set_embedded_instructions()
+ .read_E()
+ .byte_operands()
+ .operand_case(20)
+ .bits(),
AL_Ib = OperandCodeBuilder::new().special_case(40).bits(),
AX_Ib = OperandCodeBuilder::new().special_case(41).bits(),
Ib_AL = OperandCodeBuilder::new().special_case(42).bits(),
@@ -5770,10 +5776,11 @@ fn read_operands<T: Iterator<Item=u8>>(decoder: &InstDecoder, mut bytes_iter: T,
let operand_code: OperandCode = unsafe { core::mem::transmute(operand_code.bits()) };
match operand_code {
OperandCode::Eb_R0 => {
- if (modrm & 0b00111000) != 0 {
- instruction.opcode = Opcode::Invalid;
- return Err(DecodeError::InvalidOperand); // Err("Invalid modr/m for opcode 0xc6".to_owned());
- }
+ // turns out xed cand capstone both permit nonzero rrr bits here.
+ // if (modrm & 0b00111000) != 0 {
+ // instruction.opcode = Opcode::Invalid;
+ // return Err(DecodeError::InvalidOperand);
+ //}
instruction.operands[0] = mem_oper;
instruction.operand_count = 1;
diff --git a/test/long_mode/mod.rs b/test/long_mode/mod.rs
index ca4670c..7472c06 100644
--- a/test/long_mode/mod.rs
+++ b/test/long_mode/mod.rs
@@ -1062,6 +1062,11 @@ fn test_mov() {
test_display(&[0x48, 0x63, 0x04, 0xba], "movsxd rax, [rdx + rdi * 4]");
test_display(&[0xf3, 0x0f, 0x6f, 0x07], "movdqu xmm0, [rdi]");
test_display(&[0xf3, 0x0f, 0x7f, 0x45, 0x00], "movdqu [rbp], xmm0");
+
+ test_display(&[0x0f, 0x97, 0xc0], "seta al");
+ test_display(&[0x0f, 0x97, 0xc8], "seta al");
+ test_display(&[0x0f, 0x97, 0x00], "seta [rax]");
+ test_display(&[0x0f, 0x97, 0x08], "seta [rax]");
}
#[test]