aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2021-08-21 14:33:13 -0700
committeriximeow <me@iximeow.net>2021-08-21 14:33:13 -0700
commitdff9a7e4a14984705db8fb18550af5a4fa9ce3d5 (patch)
tree01fcd2794040ad1b29ac2638726a090a312f05f4 /src
parentd7208834963c46a6da74a3837d9e82bad33dfd7f (diff)
fix negative relative branches (again!!! +- is bad!!!)
Diffstat (limited to 'src')
-rw-r--r--src/long_mode/display.rs18
-rw-r--r--src/protected_mode/display.rs18
-rw-r--r--src/real_mode/display.rs18
3 files changed, 45 insertions, 9 deletions
diff --git a/src/long_mode/display.rs b/src/long_mode/display.rs
index 59efe38..7bbd83f 100644
--- a/src/long_mode/display.rs
+++ b/src/long_mode/display.rs
@@ -3331,7 +3331,11 @@ fn contextualize_intel<T: fmt::Write, Y: YaxColors>(instr: &Instruction, colors:
out.write_str(instr.opcode.name())?;
if instr.opcode == Opcode::XBEGIN {
- return write!(out, " $+{}", colors.number(signed_i32_hex(instr.imm as i32)));
+ if (instr.imm as i32) >= 0 {
+ return write!(out, " $+{}", colors.number(signed_i32_hex(instr.imm as i32)));
+ } else {
+ return write!(out, " ${}", colors.number(signed_i32_hex(instr.imm as i32)));
+ }
}
if instr.operand_count > 0 {
@@ -3356,10 +3360,18 @@ fn contextualize_intel<T: fmt::Write, Y: YaxColors>(instr: &Instruction, colors:
if RELATIVE_BRANCHES.contains(&instr.opcode) {
return match x {
Operand::ImmediateI8(rel) => {
- write!(out, "$+{}", colors.number(signed_i32_hex(rel as i32)))
+ if rel >= 0 {
+ write!(out, "$+{}", colors.number(signed_i32_hex(rel as i32)))
+ } else {
+ write!(out, "${}", colors.number(signed_i32_hex(rel as i32)))
+ }
}
Operand::ImmediateI32(rel) => {
- write!(out, "$+{}", colors.number(signed_i32_hex(rel)))
+ if rel >= 0 {
+ write!(out, "$+{}", colors.number(signed_i32_hex(rel)))
+ } else {
+ write!(out, "${}", colors.number(signed_i32_hex(rel)))
+ }
}
_ => { unreachable!() }
};
diff --git a/src/protected_mode/display.rs b/src/protected_mode/display.rs
index 72bfcb4..33c0cda 100644
--- a/src/protected_mode/display.rs
+++ b/src/protected_mode/display.rs
@@ -3344,7 +3344,11 @@ fn contextualize_intel<T: fmt::Write, Y: YaxColors>(instr: &Instruction, colors:
out.write_str(instr.opcode.name())?;
if instr.opcode == Opcode::XBEGIN {
- return write!(out, " $+{}", colors.number(signed_i32_hex(instr.imm as i32)));
+ if (instr.imm as i32) >= 0 {
+ return write!(out, " $+{}", colors.number(signed_i32_hex(instr.imm as i32)));
+ } else {
+ return write!(out, " ${}", colors.number(signed_i32_hex(instr.imm as i32)));
+ }
}
if instr.operand_count > 0 {
@@ -3369,10 +3373,18 @@ fn contextualize_intel<T: fmt::Write, Y: YaxColors>(instr: &Instruction, colors:
if RELATIVE_BRANCHES.contains(&instr.opcode) {
return match x {
Operand::ImmediateI8(rel) => {
- write!(out, "$+{}", colors.number(signed_i32_hex(rel as i32)))
+ if rel >= 0 {
+ write!(out, "$+{}", colors.number(signed_i32_hex(rel as i32)))
+ } else {
+ write!(out, "${}", colors.number(signed_i32_hex(rel as i32)))
+ }
}
Operand::ImmediateI32(rel) => {
- write!(out, "$+{}", colors.number(signed_i32_hex(rel)))
+ if rel >= 0 {
+ write!(out, "$+{}", colors.number(signed_i32_hex(rel)))
+ } else {
+ write!(out, "${}", colors.number(signed_i32_hex(rel)))
+ }
}
_ => { unreachable!() }
};
diff --git a/src/real_mode/display.rs b/src/real_mode/display.rs
index f514974..3a9fddc 100644
--- a/src/real_mode/display.rs
+++ b/src/real_mode/display.rs
@@ -3344,7 +3344,11 @@ fn contextualize_intel<T: fmt::Write, Y: YaxColors>(instr: &Instruction, colors:
out.write_str(instr.opcode.name())?;
if instr.opcode == Opcode::XBEGIN {
- return write!(out, " $+{}", colors.number(signed_i32_hex(instr.imm as i32)));
+ if (instr.imm as i32) >= 0 {
+ return write!(out, " $+{}", colors.number(signed_i32_hex(instr.imm as i32)));
+ } else {
+ return write!(out, " ${}", colors.number(signed_i32_hex(instr.imm as i32)));
+ }
}
if instr.operand_count > 0 {
@@ -3369,10 +3373,18 @@ fn contextualize_intel<T: fmt::Write, Y: YaxColors>(instr: &Instruction, colors:
if RELATIVE_BRANCHES.contains(&instr.opcode) {
return match x {
Operand::ImmediateI8(rel) => {
- write!(out, "$+{}", colors.number(signed_i32_hex(rel as i32)))
+ if rel >= 0 {
+ write!(out, "$+{}", colors.number(signed_i32_hex(rel as i32)))
+ } else {
+ write!(out, "${}", colors.number(signed_i32_hex(rel as i32)))
+ }
}
Operand::ImmediateI32(rel) => {
- write!(out, "$+{}", colors.number(signed_i32_hex(rel)))
+ if rel >= 0 {
+ write!(out, "$+{}", colors.number(signed_i32_hex(rel)))
+ } else {
+ write!(out, "${}", colors.number(signed_i32_hex(rel)))
+ }
}
_ => { unreachable!() }
};