opcode: Not all single-operand instructions take a width parameter

This commit is contained in:
John 2023-10-04 04:31:43 -05:00
parent d73c5b2e5d
commit fd417afba0

View File

@ -77,9 +77,11 @@ impl Opcode {
use Register as Reg; use Register as Reg;
use {PrimaryOperand as Src, SecondaryOperand as Dst}; use {PrimaryOperand as Src, SecondaryOperand as Dst};
match self { match self {
Self::Rrc | Self::Swpb | Self::Rra | Self::Sxt | Self::Push | Self::Call | Self::Reti => { Self::Rrc | Self::Rra | Self::Push => (self, Enc::single().end()),
(self, Enc::single().end()) // these instructions do not take a width specifier (though they may still behave properly)
} Self::Swpb | Self::Sxt | Self::Call => (self, Enc::single().width(false).end()),
// `reti` does not take any operands.
Self::Reti => (self, Enc::single().operand(Src::Direct(Reg::pc)).end()),
Self::Jnz | Self::Jz | Self::Jnc | Self::Jc | Self::Jn | Self::Jge | Self::Jl | Self::Jmp => { Self::Jnz | Self::Jz | Self::Jnc | Self::Jc | Self::Jn | Self::Jge | Self::Jl | Self::Jmp => {
(self, Enc::jump().end()) (self, Enc::jump().end())
} }