aboutsummaryrefslogtreecommitdiff
path: root/src/real_mode/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/real_mode/mod.rs')
-rw-r--r--src/real_mode/mod.rs29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/real_mode/mod.rs b/src/real_mode/mod.rs
index fbfc687..548c42e 100644
--- a/src/real_mode/mod.rs
+++ b/src/real_mode/mod.rs
@@ -7236,6 +7236,7 @@ fn read_operands<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpe
};
instruction.regs[0] =
RegSpec::from_parts(reg, bank);
+ instruction.mem_size = 2;
instruction.operand_count = 1;
}
1 => {
@@ -7329,6 +7330,9 @@ fn read_operands<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpe
if immsz == 0 {
instruction.operands[0] = OperandSpec::ImmI8;
} else {
+ if instruction.opcode == Opcode::CALL {
+ instruction.mem_size = 2;
+ }
instruction.operands[0] = OperandSpec::ImmI32;
}
instruction.operand_count = 1;
@@ -7506,11 +7510,19 @@ fn read_operands<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpe
if instruction.operands[0] == OperandSpec::RegMMM {
// in real mode, `xed` reports that operand-size does in fact override from word to
// dword. unlikely larger modes, operand-size can't shrink the call operand down.
- if opcode == Opcode::CALLF || opcode == Opcode::JMPF {
+ if opcode == Opcode::CALL {
+ instruction.mem_size = 2;
+ } else if opcode == Opcode::CALLF || opcode == Opcode::JMPF {
return Err(DecodeError::InvalidOperand);
}
} else {
- if opcode == Opcode::CALL || opcode == Opcode::JMP || opcode == Opcode::PUSH || opcode == Opcode::POP {
+ if opcode == Opcode::CALL || opcode == Opcode::JMP {
+ if instruction.prefixes.operand_size() {
+ instruction.mem_size = 4;
+ } else {
+ instruction.mem_size = 2;
+ }
+ } else if opcode == Opcode::PUSH || opcode == Opcode::POP {
if instruction.prefixes.operand_size() {
instruction.mem_size = 4;
} else {
@@ -7658,6 +7670,14 @@ fn read_operands<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpe
instruction.operand_count = 1;
}
28 => {
+ if instruction.opcode == Opcode::Invalid {
+ return Err(DecodeError::InvalidOpcode);
+ }
+ if instruction.opcode == Opcode::RETURN {
+ instruction.mem_size = 2;
+ } else {
+ instruction.mem_size = 4;
+ }
instruction.operands[0] = OperandSpec::Nothing;
instruction.operand_count = 0;
return Ok(());
@@ -9140,6 +9160,11 @@ fn unlikely_operands<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as y
instruction.imm =
read_imm_unsigned(words, 2)?;
instruction.operands[0] = OperandSpec::ImmU16;
+ if instruction.opcode == Opcode::RETURN {
+ instruction.mem_size = 2;
+ } else {
+ instruction.mem_size = 4;
+ }
instruction.operand_count = 1;
}
OperandCode::ModRM_0x0f00 => {