From 84e184518f2aecfa347eae4600391d01d875834b Mon Sep 17 00:00:00 2001 From: Shadow Cat Date: Sat, 13 Jun 2026 13:47:12 -0400 Subject: [PATCH] small stuff --- src/arch/x86_64/encode.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/arch/x86_64/encode.rs b/src/arch/x86_64/encode.rs index 9499c62..978ab44 100644 --- a/src/arch/x86_64/encode.rs +++ b/src/arch/x86_64/encode.rs @@ -172,7 +172,7 @@ impl Code { self.bytes.push(0xc3); } - pub fn sub(&mut self, mut dst: Reg, src: impl Into) -> ERes { + pub fn sub(&mut self, dst: Reg, src: impl Into) -> ERes { let mut src = src.into(); let mut width = src.width_signed()?; let dst_width = dst.width().min(Width::B32); @@ -188,16 +188,16 @@ impl Code { src = src.reinterpret(dst_width); width = src.width_signed()?; } + if dst.width() == Width::B8 { self.bytes.push(0x80); + } else if width == Width::B8 { + self.bytes.push(0x83); } else { - if width == Width::B8 { - self.bytes.push(0x83); - } else { - self.bytes.push(0x81); - width = dst_width; - } + self.bytes.push(0x81); + width = dst_width; } + self.bytes.push(modrm(0b11, 0b101, dst.base())); self.imm(src, width); Ok(())