From 53012e24ee9179a911cc6a3a8c4dc30cb9906c70 Mon Sep 17 00:00:00 2001 From: iximeow Date: Tue, 18 Jun 2024 14:25:48 -0700 Subject: mem size strings are all 7b or less --- src/long_mode/display.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/long_mode/display.rs b/src/long_mode/display.rs index 46227fb..d7a80cb 100644 --- a/src/long_mode/display.rs +++ b/src/long_mode/display.rs @@ -1198,7 +1198,7 @@ impl crate::long_mode::OperandVisitor for Coloriz Ok(()) } fn visit_abs_u32(&mut self, imm: u32) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { let name = prefix.name(); @@ -1209,7 +1209,7 @@ impl crate::long_mode::OperandVisitor for Coloriz write!(self.f, "[{}]", self.colors.address(u32_hex(imm))) } fn visit_abs_u64(&mut self, imm: u64) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { let name = prefix.name(); @@ -1220,7 +1220,7 @@ impl crate::long_mode::OperandVisitor for Coloriz write!(self.f, "[{}]", self.colors.address(u64_hex(imm))) } fn visit_disp(&mut self, reg: RegSpec, disp: i32) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { let name = prefix.name(); @@ -1263,7 +1263,7 @@ impl crate::long_mode::OperandVisitor for Coloriz self.f.write_fixed_size("]") } fn visit_deref(&mut self, reg: RegSpec) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { let name = prefix.name(); @@ -1276,7 +1276,7 @@ impl crate::long_mode::OperandVisitor for Coloriz self.f.write_fixed_size("]") } fn visit_reg_scale(&mut self, reg: RegSpec, scale: u8) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { let name = prefix.name(); @@ -1293,7 +1293,7 @@ impl crate::long_mode::OperandVisitor for Coloriz Ok(()) } fn visit_reg_scale_disp(&mut self, reg: RegSpec, scale: u8, disp: i32) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { let name = prefix.name(); @@ -1338,7 +1338,7 @@ impl crate::long_mode::OperandVisitor for Coloriz write!(self.f, "]") } fn visit_index_base_scale(&mut self, base: RegSpec, index: RegSpec, scale: u8) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { let name = prefix.name(); @@ -1355,7 +1355,7 @@ impl crate::long_mode::OperandVisitor for Coloriz self.f.write_fixed_size("]") } fn visit_index_base_scale_disp(&mut self, base: RegSpec, index: RegSpec, scale: u8, disp: i32) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { let name = prefix.name(); @@ -1402,7 +1402,7 @@ impl crate::long_mode::OperandVisitor for Coloriz self.f.write_fixed_size("]") } fn visit_reg_disp_masked(&mut self, spec: RegSpec, disp: i32, mask_reg: RegSpec) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; write!(self.f, "[{} ", regspec_label(&spec))?; format_number_i32(self.colors, self.f, disp, NumberStyleHint::HexSignedWithSignSplit)?; @@ -1410,7 +1410,7 @@ impl crate::long_mode::OperandVisitor for Coloriz write!(self.f, "{{{}}}", regspec_label(&mask_reg)) } fn visit_reg_deref_masked(&mut self, spec: RegSpec, mask_reg: RegSpec) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; self.f.write_fixed_size("[")?; self.f.write_str(regspec_label(&spec))?; @@ -1418,7 +1418,7 @@ impl crate::long_mode::OperandVisitor for Coloriz write!(self.f, "{{{}}}", regspec_label(&mask_reg)) } fn visit_reg_scale_masked(&mut self, spec: RegSpec, scale: u8, mask_reg: RegSpec) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; write!(self.f, "[{} * {}]", regspec_label(&spec), @@ -1427,7 +1427,7 @@ impl crate::long_mode::OperandVisitor for Coloriz write!(self.f, "{{{}}}", regspec_label(&mask_reg)) } fn visit_reg_scale_disp_masked(&mut self, spec: RegSpec, scale: u8, disp: i32, mask_reg: RegSpec) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; write!(self.f, "[{} * {} ", regspec_label(&spec), @@ -1438,7 +1438,7 @@ impl crate::long_mode::OperandVisitor for Coloriz write!(self.f, "{{{}}}", regspec_label(&mask_reg)) } fn visit_index_base_masked(&mut self, base: RegSpec, index: RegSpec, mask_reg: RegSpec) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; self.f.write_fixed_size("[")?; self.f.write_str(regspec_label(&base))?; @@ -1448,7 +1448,7 @@ impl crate::long_mode::OperandVisitor for Coloriz write!(self.f, "{{{}}}", regspec_label(&mask_reg)) } fn visit_index_base_disp_masked(&mut self, base: RegSpec, index: RegSpec, disp: i32, mask_reg: RegSpec) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; write!(self.f, "[{} + {} ", regspec_label(&base), @@ -1459,7 +1459,7 @@ impl crate::long_mode::OperandVisitor for Coloriz write!(self.f, "{{{}}}", regspec_label(&mask_reg)) } fn visit_index_base_scale_masked(&mut self, base: RegSpec, index: RegSpec, scale: u8, mask_reg: RegSpec) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; write!(self.f, "[{} + {} * {}]", regspec_label(&base), @@ -1469,7 +1469,7 @@ impl crate::long_mode::OperandVisitor for Coloriz write!(self.f, "{{{}}}", regspec_label(&mask_reg)) } fn visit_index_base_scale_disp_masked(&mut self, base: RegSpec, index: RegSpec, scale: u8, disp: i32, mask_reg: RegSpec) -> Result { - self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; + unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS[self.instr.mem_size as usize])? }; self.f.write_fixed_size(" ")?; write!(self.f, "[{} + {} * {} ", regspec_label(&base), -- cgit v1.1