From 2146ee62c265cd13ebcc1aaef138dd9e1aec4b72 Mon Sep 17 00:00:00 2001 From: Samuel Arnold Date: Fri, 12 Jun 2026 17:30:30 -0700 Subject: Make invalid instruction constructors actually return invalid instructions As opposed to nops. --- CHANGELOG | 9 +++++++++ src/long_mode/mod.rs | 2 +- src/protected_mode/mod.rs | 2 +- src/real_mode/mod.rs | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0765b68..3850ee6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,12 @@ +## 2.2.0 + +* `Instruction::invalid()` returns instructions with opcode `Opcode::Invalid`, rather than nop. + decoding an instruction with `opcode == Invalid` was already possible through attempting + to decode invalid opcodes into a `&mut Instruction`; `invalid()` returning a no-operand + nop dates back to initial versions of the library attempting to never return instructions + that did not reflect a decoded x86 instruction. + it has long passed its time. thank you for the patch, @Grond66! + ## 2.1.1 * fix jrcxz/jecxz/jcxz having "two operands". accessing the "second" operand diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index ca2e7cb..b7daa4a 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -3283,7 +3283,7 @@ impl Instruction { pub fn invalid() -> Instruction { Instruction { prefixes: Prefixes::new(0), - opcode: Opcode::NOP, + opcode: Opcode::Invalid, mem_size: 0, regs: [RegSpec::rax(); 4], scale: 0, diff --git a/src/protected_mode/mod.rs b/src/protected_mode/mod.rs index 6a1d19b..64c1c8d 100644 --- a/src/protected_mode/mod.rs +++ b/src/protected_mode/mod.rs @@ -3213,7 +3213,7 @@ impl Instruction { pub fn invalid() -> Instruction { Instruction { prefixes: Prefixes::new(0), - opcode: Opcode::NOP, + opcode: Opcode::Invalid, mem_size: 0, regs: [RegSpec::eax(); 4], scale: 0, diff --git a/src/real_mode/mod.rs b/src/real_mode/mod.rs index f54533c..3a7cbd3 100644 --- a/src/real_mode/mod.rs +++ b/src/real_mode/mod.rs @@ -3240,7 +3240,7 @@ impl Instruction { pub fn invalid() -> Instruction { Instruction { prefixes: Prefixes::new(0), - opcode: Opcode::NOP, + opcode: Opcode::Invalid, mem_size: 0, regs: [RegSpec::ax(); 4], scale: 0, -- cgit v1.1