aboutsummaryrefslogtreecommitdiff
path: root/src/long_mode
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2024-06-18 22:36:54 -0700
committeriximeow <me@iximeow.net>2024-06-18 22:38:49 -0700
commite904f613a29a5e3edfe20991b38356e77c857ba9 (patch)
treea379c6135a458054d5a26f5b1f8cfccc4d539766 /src/long_mode
parent89838f6bc67d0f7e8ae509a8bfa9d7e2ccc3137c (diff)
try grouping characters printed with or without segment prefixes
Diffstat (limited to 'src/long_mode')
-rw-r--r--src/long_mode/display.rs42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/long_mode/display.rs b/src/long_mode/display.rs
index 24d35be..355cbc7 100644
--- a/src/long_mode/display.rs
+++ b/src/long_mode/display.rs
@@ -1433,17 +1433,18 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
}
fn visit_disp(&mut self, reg: RegSpec, disp: i32) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
- self.f.write_fixed_size(" ")?;
if self.op_nr >= 4 {
unsafe { core::hint::unreachable_unchecked(); }
}
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
+ self.f.write_char(' ')?;
self.f.write_char(name[0] as char)?;
self.f.write_char(name[1] as char)?;
- self.f.write_char(':')?;
+ self.f.write_fixed_size(":[")?;
+ } else {
+ self.f.write_fixed_size(" [")?;
}
- self.f.write_fixed_size("[")?;
unsafe { self.f.write_lt_8(regspec_label(&reg))?; }
self.f.write_fixed_size(" ")?;
@@ -1461,33 +1462,35 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
}
fn visit_deref(&mut self, reg: RegSpec) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
- self.f.write_fixed_size(" ")?;
if self.op_nr >= 4 {
unsafe { core::hint::unreachable_unchecked(); }
}
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
+ self.f.write_char(' ')?;
self.f.write_char(name[0] as char)?;
self.f.write_char(name[1] as char)?;
- self.f.write_char(':')?;
+ self.f.write_fixed_size(":[")?;
+ } else {
+ self.f.write_fixed_size(" [")?;
}
- self.f.write_fixed_size("[")?;
unsafe { self.f.write_lt_8(regspec_label(&reg))?; }
self.f.write_fixed_size("]")
}
fn visit_reg_scale(&mut self, reg: RegSpec, scale: u8) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
- self.f.write_fixed_size(" ")?;
if self.op_nr >= 4 {
unsafe { core::hint::unreachable_unchecked(); }
}
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
+ self.f.write_char(' ')?;
self.f.write_char(name[0] as char)?;
self.f.write_char(name[1] as char)?;
- self.f.write_char(':')?;
+ self.f.write_fixed_size(":[")?;
+ } else {
+ self.f.write_fixed_size(" [")?;
}
- self.f.write_fixed_size("[")?;
unsafe { self.f.write_lt_8(regspec_label(&reg))?; }
self.f.write_fixed_size(" * ")?;
self.f.write_char((0x30 + scale) as char)?; // translate scale=1 to '1', scale=2 to '2', etc
@@ -1497,17 +1500,18 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
}
fn visit_reg_scale_disp(&mut self, reg: RegSpec, scale: u8, disp: i32) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
- self.f.write_fixed_size(" ")?;
if self.op_nr >= 4 {
unsafe { core::hint::unreachable_unchecked(); }
}
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
+ self.f.write_char(' ')?;
self.f.write_char(name[0] as char)?;
self.f.write_char(name[1] as char)?;
- self.f.write_char(':')?;
+ self.f.write_fixed_size(":[")?;
+ } else {
+ self.f.write_fixed_size(" [")?;
}
- self.f.write_fixed_size("[")?;
unsafe { self.f.write_lt_8(regspec_label(&reg))?; }
self.f.write_fixed_size(" * ")?;
self.f.write_char((0x30 + scale) as char)?; // translate scale=1 to '1', scale=2 to '2', etc
@@ -1527,17 +1531,18 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
}
fn visit_index_base_scale(&mut self, base: RegSpec, index: RegSpec, scale: u8) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
- self.f.write_fixed_size(" ")?;
if self.op_nr >= 4 {
unsafe { core::hint::unreachable_unchecked(); }
}
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
+ self.f.write_char(' ')?;
self.f.write_char(name[0] as char)?;
self.f.write_char(name[1] as char)?;
- self.f.write_char(':')?;
+ self.f.write_fixed_size(":[")?;
+ } else {
+ self.f.write_fixed_size(" [")?;
}
- self.f.write_fixed_size("[")?;
unsafe { self.f.write_lt_8(regspec_label(&base))?; }
self.f.write_fixed_size(" + ")?;
unsafe { self.f.write_lt_8(regspec_label(&index))?; }
@@ -1547,17 +1552,18 @@ impl <T: DisplaySink> crate::long_mode::OperandVisitor for ColorizingOperandVisi
}
fn visit_index_base_scale_disp(&mut self, base: RegSpec, index: RegSpec, scale: u8, disp: i32) -> Result<Self::Ok, Self::Error> {
unsafe { self.f.write_lt_8(MEM_SIZE_STRINGS.get_kinda_unchecked(self.instr.mem_size as usize))? };
- self.f.write_fixed_size(" ")?;
if self.op_nr >= 4 {
unsafe { core::hint::unreachable_unchecked(); }
}
if let Some(prefix) = self.instr.segment_override_for_op(self.op_nr) {
let name = prefix.name();
+ self.f.write_char(' ')?;
self.f.write_char(name[0] as char)?;
self.f.write_char(name[1] as char)?;
- self.f.write_char(':')?;
+ self.f.write_fixed_size(":[")?;
+ } else {
+ self.f.write_fixed_size(" [")?;
}
- self.f.write_fixed_size("[")?;
unsafe { self.f.write_lt_8(regspec_label(&base))?; }
self.f.write_fixed_size(" + ")?;
unsafe { self.f.write_lt_8(regspec_label(&index))?; }