aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/long_mode/display.rs22
-rw-r--r--test/long_mode/display.rs8
2 files changed, 24 insertions, 6 deletions
diff --git a/src/long_mode/display.rs b/src/long_mode/display.rs
index 8750cc6..3631800 100644
--- a/src/long_mode/display.rs
+++ b/src/long_mode/display.rs
@@ -2709,10 +2709,28 @@ fn contextualize_c<T: fmt::Write, Color: fmt::Display, Y: YaxColors<Color>>(inst
write!(out, "{} = movntq({})", instr.operand(0), instr.operand(1))?;
}
Opcode::INC => {
- write!(out, "{}++", instr.operand(0))?;
+ if instr.operand(0).is_memory() {
+ match instr.mem_size {
+ 1 => { write!(out, "byte {}++", instr.operand(0))?; },
+ 2 => { write!(out, "word {}++", instr.operand(0))?; },
+ 4 => { write!(out, "dword {}++", instr.operand(0))?; },
+ _ => { write!(out, "qword {}++", instr.operand(0))?; }, // sizes that are not 1, 2, or 4, *better* be 8.
+ }
+ } else {
+ write!(out, "{}++", instr.operand(0))?;
+ }
}
Opcode::DEC => {
- write!(out, "{}--", instr.operand(0))?;
+ if instr.operand(0).is_memory() {
+ match instr.mem_size {
+ 1 => { write!(out, "byte {}--", instr.operand(0))?; },
+ 2 => { write!(out, "word {}--", instr.operand(0))?; },
+ 4 => { write!(out, "dword {}--", instr.operand(0))?; },
+ _ => { write!(out, "qword {}--", instr.operand(0))?; }, // sizes that are not 1, 2, or 4, *better* be 8.
+ }
+ } else {
+ write!(out, "{}--", instr.operand(0))?;
+ }
}
Opcode::JG => {
write!(out, "if greater(rflags) then jmp {}", instr.operand(0))?;
diff --git a/test/long_mode/display.rs b/test/long_mode/display.rs
index 2d1a540..4ef3f74 100644
--- a/test/long_mode/display.rs
+++ b/test/long_mode/display.rs
@@ -178,8 +178,8 @@ fn test_instructions_c() {
test_display(&[0x66, 0x0f, 0x38, 0xf6, 0x01], "eax += [rcx] + rflags.cf");
test_display(&[0xf3, 0x4f, 0x0f, 0x38, 0xf6, 0x01], "r8 += [r9] + rflags.of");
- test_display(&[0xfe, 0x00], "[rax]++"); // TODO: byte
- test_display(&[0xfe, 0x08], "[rax]--"); // TODO: byte
- test_display(&[0xff, 0x00], "[rax]++"); // TODO: dword
- test_display(&[0x48, 0xff, 0x00], "[rax]++"); // TODO: qword
+ test_display(&[0xfe, 0x00], "byte [rax]++");
+ test_display(&[0x66, 0xff, 0x08], "word [rax]--");
+ test_display(&[0xff, 0x00], "dword [rax]++");
+ test_display(&[0x48, 0xff, 0x00], "qword [rax]++");
}