diff options
author | iximeow <me@iximeow.net> | 2024-06-16 13:03:28 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2024-06-16 13:08:33 -0700 |
commit | 7ab69f66b983eba11e9864234585265f334caac0 (patch) | |
tree | b2a7d8e11b0c68d572bf488e581dd76d01bc6743 /src/long_mode | |
parent | 6f03facaedf214b7ab84f077027df2c0e2742de5 (diff) |
use less of core::fmt, write by hand
`name()` returning a `[u8; 2]` is nice when there is a specializing and
unrolling write implementation, whereas `&str` might not consistently
unroll into a simple 2-byte copy (rather than loop). it'll look a little
more reasonable soon, hopefully..
Diffstat (limited to 'src/long_mode')
-rw-r--r-- | src/long_mode/display.rs | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/src/long_mode/display.rs b/src/long_mode/display.rs index 4725154..3ccbb0f 100644 --- a/src/long_mode/display.rs +++ b/src/long_mode/display.rs @@ -446,7 +446,10 @@ impl <T: fmt::Write, Y: YaxColors> crate::long_mode::OperandVisitor for Colorizi self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; self.f.write_str(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { - write!(self.f, "{}:", prefix)?; + let name = prefix.name(); + self.f.write_char(name[0] as char)?; + self.f.write_char(name[1] as char)?; + self.f.write_char(':')?; } write!(self.f, "[{}]", self.colors.address(u32_hex(imm))) } @@ -454,7 +457,10 @@ impl <T: fmt::Write, Y: YaxColors> crate::long_mode::OperandVisitor for Colorizi self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; self.f.write_str(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { - write!(self.f, "{}:", prefix)?; + let name = prefix.name(); + self.f.write_char(name[0] as char)?; + self.f.write_char(name[1] as char)?; + self.f.write_char(':')?; } write!(self.f, "[{}]", self.colors.address(u64_hex(imm))) } @@ -462,8 +468,10 @@ impl <T: fmt::Write, Y: YaxColors> crate::long_mode::OperandVisitor for Colorizi self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; self.f.write_str(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { - write!(self.f, "{}", prefix)?; - self.f.write_str(":")?; + let name = prefix.name(); + self.f.write_char(name[0] as char)?; + self.f.write_char(name[1] as char)?; + self.f.write_char(':')?; } self.f.write_str("[")?; self.f.write_str(regspec_label(®))?; @@ -475,7 +483,10 @@ impl <T: fmt::Write, Y: YaxColors> crate::long_mode::OperandVisitor for Colorizi self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; self.f.write_str(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { - write!(self.f, "{}:", prefix)?; + let name = prefix.name(); + self.f.write_char(name[0] as char)?; + self.f.write_char(name[1] as char)?; + self.f.write_char(':')?; } self.f.write_str("[")?; self.f.write_str(regspec_label(®))?; @@ -485,7 +496,10 @@ impl <T: fmt::Write, Y: YaxColors> crate::long_mode::OperandVisitor for Colorizi self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; self.f.write_str(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { - write!(self.f, "{}:", prefix)?; + let name = prefix.name(); + self.f.write_char(name[0] as char)?; + self.f.write_char(name[1] as char)?; + self.f.write_char(':')?; } write!(self.f, "[{} * {}]", regspec_label(®), @@ -496,7 +510,10 @@ impl <T: fmt::Write, Y: YaxColors> crate::long_mode::OperandVisitor for Colorizi self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; self.f.write_str(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { - write!(self.f, "{}:", prefix)?; + let name = prefix.name(); + self.f.write_char(name[0] as char)?; + self.f.write_char(name[1] as char)?; + self.f.write_char(':')?; } write!(self.f, "[{} * {} ", regspec_label(®), @@ -509,7 +526,10 @@ impl <T: fmt::Write, Y: YaxColors> crate::long_mode::OperandVisitor for Colorizi self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; self.f.write_str(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { - write!(self.f, "{}:", prefix)?; + let name = prefix.name(); + self.f.write_char(name[0] as char)?; + self.f.write_char(name[1] as char)?; + self.f.write_char(':')?; } write!(self.f, "[{} + {} * {}]", regspec_label(&base), @@ -521,7 +541,10 @@ impl <T: fmt::Write, Y: YaxColors> crate::long_mode::OperandVisitor for Colorizi self.f.write_str(MEM_SIZE_STRINGS[self.instr.mem_size as usize])?; self.f.write_str(" ")?; if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) { - write!(self.f, "{}:", prefix)?; + let name = prefix.name(); + self.f.write_char(name[0] as char)?; + self.f.write_char(name[1] as char)?; + self.f.write_char(':')?; } write!(self.f, "[{} + {} * {} ", regspec_label(&base), |