From 673c2c8d20a279d84709e5e080ad1446bda57c28 Mon Sep 17 00:00:00 2001 From: Samy Solhi Date: Wed, 26 Oct 2022 15:10:21 +0200 Subject: [PATCH] Added hex conversion --- src/print.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/print.rs b/src/print.rs index c2e2e47..28bcb25 100644 --- a/src/print.rs +++ b/src/print.rs @@ -166,16 +166,16 @@ pub fn print(ins: Instruction, pc: i32) -> String { //TODO pc should be u64 } }, RISCV_LUI => { - format!("lui x{}, {}", ins.rd.to_string(), ins.imm31_12.to_string()) //TODO Value is supposed to be in hex + format!("lui x{}, {:X}", ins.rd.to_string(), ins.imm31_12) }, RISCV_AUIPC => { - format!("auipc x{}, {}", ins.rd.to_string(), ins.imm31_12.to_string()) // TODO Value is supposed to be in hex + format!("auipc x{}, {:X}", ins.rd.to_string(), ins.imm31_12) }, RISCV_JAL => { if ins.rd == 0 { format!("j {}", ins.imm31_12.to_string()) } else { - format!("jal x{}, {}", ins.rd.to_string(), (pc - 4 + ins.imm21_1_signed).to_string()) // TODO Value is supposed to be in hex + format!("jal x{}, {:X}", ins.rd.to_string(), (pc - 4 + ins.imm21_1_signed)) } }, RISCV_JALR => { @@ -183,7 +183,7 @@ pub fn print(ins: Instruction, pc: i32) -> String { //TODO pc should be u64 if ins.rs1 == 1 { "ret".to_string() } else { - format!("jr {}", ins.imm31_12.to_string()) // TODO Value is supposed to be in hex + format!("jr {:X}", ins.imm31_12) } } else { format!("jalr {}, (r{})", ins.imm12_I_signed.to_string(), ins.rs1.to_string())