From 1173dd3d63a292b0e02ab1a878f1cbdf530dfad2 Mon Sep 17 00:00:00 2001 From: Marco Thomas Date: Tue, 20 May 2025 11:02:46 +0900 Subject: [PATCH] chore: output parity for hex Output all immediate bytes and words as hex. --- src/instructions.rs | 100 ++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/instructions.rs b/src/instructions.rs index 6bedb60..85719c1 100644 --- a/src/instructions.rs +++ b/src/instructions.rs @@ -371,10 +371,10 @@ impl fmt::Display for Mnemonic { Self::OVERRIDE(reg) => write!(f, "{reg}:"), - Self::DAA => write!(f, "DAA"), - Self::DAS => write!(f, "DAS"), - Self::AAA => write!(f, "AAA"), - Self::AAS => write!(f, "AAS"), + Self::DAA => write!(f, "daa"), + Self::DAS => write!(f, "das"), + Self::AAA => write!(f, "aaa"), + Self::AAS => write!(f, "aas"), Self::SUB_FromReg(target, reg) => write!(f, "sub {target}, {reg}"), Self::SUB_ToReg(target, reg) => write!(f, "sub {reg}, {target}"), @@ -403,26 +403,26 @@ impl fmt::Display for Mnemonic { Self::DEC_Reg(reg) => write!(f, "dec {reg}"), Self::DEC_Mod(target) => write!(f, "dec {target}"), - Self::JO(ibyte) => write!(f, "jo {ibyte}"), - Self::JNO(ibyte) => write!(f, "jno {ibyte}"), - Self::JB(ibyte) => write!(f, "jb {ibyte}"), - Self::JNB(ibyte) => write!(f, "jnb {ibyte}"), - Self::JZ(ibyte) => write!(f, "jz {ibyte}"), - Self::JNZ(ibyte) => write!(f, "jnz {ibyte}"), - Self::JBE(ibyte) => write!(f, "jbe {ibyte}"), - Self::JA(ibyte) => write!(f, "ja {ibyte}"), - Self::JS(ibyte) => write!(f, "js {ibyte}"), - Self::JNS(ibyte) => write!(f, "jns {ibyte}"), - Self::JPE(ibyte) => write!(f, "jpe {ibyte}"), - Self::JPO(ibyte) => write!(f, "jpo {ibyte}"), - Self::JL(ibyte) => write!(f, "jl {ibyte}"), - Self::JGE(ibyte) => write!(f, "jge {ibyte}"), - Self::JLE(ibyte) => write!(f, "jle {ibyte}"), - Self::JG(ibyte) => write!(f, "jg {ibyte}"), - Self::LOOPNZ(ibyte) => write!(f, "loopnz {ibyte}"), - Self::LOOPZ(ibyte) => write!(f, "loopz {ibyte}"), - Self::LOOP(ibyte) => write!(f, "loop {ibyte}"), - Self::JCXZ(ibyte) => write!(f, "jcxz {ibyte}"), + Self::JO(ibyte) => write!(f, "jo {ibyte:#04x}"), + Self::JNO(ibyte) => write!(f, "jno {ibyte:#04x}"), + Self::JB(ibyte) => write!(f, "jb {ibyte:#04x}"), + Self::JNB(ibyte) => write!(f, "jnb {ibyte:#04x}"), + Self::JZ(ibyte) => write!(f, "jz {ibyte:#04x}"), + Self::JNZ(ibyte) => write!(f, "jnz {ibyte:#04x}"), + Self::JBE(ibyte) => write!(f, "jbe {ibyte:#04x}"), + Self::JA(ibyte) => write!(f, "ja {ibyte:#04x}"), + Self::JS(ibyte) => write!(f, "js {ibyte:#04x}"), + Self::JNS(ibyte) => write!(f, "jns {ibyte:#04x}"), + Self::JPE(ibyte) => write!(f, "jpe {ibyte:#04x}"), + Self::JPO(ibyte) => write!(f, "jpo {ibyte:#04x}"), + Self::JL(ibyte) => write!(f, "jl {ibyte:#04x}"), + Self::JGE(ibyte) => write!(f, "jge {ibyte:#04x}"), + Self::JLE(ibyte) => write!(f, "jle {ibyte:#04x}"), + Self::JG(ibyte) => write!(f, "jg {ibyte:#04x}"), + Self::LOOPNZ(ibyte) => write!(f, "loopnz {ibyte:#04x}"), + Self::LOOPZ(ibyte) => write!(f, "loopz {ibyte:#04x}"), + Self::LOOP(ibyte) => write!(f, "loop {ibyte:#04x}"), + Self::JCXZ(ibyte) => write!(f, "jcxz {ibyte:#04x}"), Self::TEST(target, reg) => write!(f, "test {target}, {reg}"), Self::TEST_Ib(target, byte) => write!(f, "test byte {target}, {byte:#04x}"), @@ -464,35 +464,35 @@ impl fmt::Display for Mnemonic { Self::LEA(mem, reg) => write!(f, "lea {}, {}", reg, mem), - Self::CBW => write!(f, "CBW"), - Self::CWD => write!(f, "CWD"), + Self::CBW => write!(f, "cbw"), + Self::CWD => write!(f, "cwd"), Self::CALL_p(ptr) => write!(f, "call {ptr}"), Self::CALL_v(word) => write!(f, "call {word:#04x}"), Self::CALL_Mod(target) => write!(f, "call {target}"), Self::JMP_p(ptr) => write!(f, "jmp {ptr}"), - Self::JMP_b(byte) => write!(f, "jmp {byte:#04}"), - Self::JMP_v(word) => write!(f, "jmp {word:#04}"), + Self::JMP_b(byte) => write!(f, "jmp {byte:#04x}"), + Self::JMP_v(word) => write!(f, "jmp {word:#04x}"), Self::JMP_Mod(target) => write!(f, "jmp {target}"), - Self::WAIT => write!(f, "WAIT"), + Self::WAIT => write!(f, "wait"), - Self::PUSHF => write!(f, "PUSHF"), - Self::POPF => write!(f, "POPF"), - Self::SAHF => write!(f, "SAHF"), - Self::LAHF => write!(f, "LAHF"), + Self::PUSHF => write!(f, "pushf"), + Self::POPF => write!(f, "popf"), + Self::SAHF => write!(f, "sahf"), + Self::LAHF => write!(f, "lahf"), - Self::MOVSB => write!(f, "MOVSB"), - Self::MOVSW => write!(f, "MOVSW"), - Self::CMPSB => write!(f, "CMPSB"), - Self::CMPSW => write!(f, "CMPSW"), - Self::STOSB => write!(f, "STOSB"), - Self::STOSW => write!(f, "STOSW"), - Self::LODSB => write!(f, "LODSB"), - Self::LODSW => write!(f, "LODSW"), - Self::SCASB => write!(f, "SCASB"), - Self::SCASW => write!(f, "SCASW"), + Self::MOVSB => write!(f, "movsb"), + Self::MOVSW => write!(f, "movsw"), + Self::CMPSB => write!(f, "cmpsb"), + Self::CMPSW => write!(f, "cmpsw"), + Self::STOSB => write!(f, "stosb"), + Self::STOSW => write!(f, "stosw"), + Self::LODSB => write!(f, "lodsb"), + Self::LODSW => write!(f, "lodsw"), + Self::SCASB => write!(f, "scasb"), + Self::SCASW => write!(f, "scasw"), Self::RET_Iw(word) => write!(f, "ret {word:#04x}"), Self::RET => write!(f, "ret"), @@ -529,14 +529,14 @@ impl fmt::Display for Mnemonic { Self::SAR_fromReg(target, reg) => write!(f, "sar {target}, {reg}"), Self::IN_AL(byte) => write!(f, "in {}, {byte:#04x}", Register::AL), - Self::IN_AX(byte) => write!(f, "in {}, {byte:#04x}", Register::AX), - Self::IN_ALDX => write!(f, "in {}, {}", Register::AL, Register::DX), - Self::IN_AXDX => write!(f, "in {}, {}", Register::AX, Register::DX), + Self::IN_AX(byte) => write!(f, "in :#04x{}, {byte:#04x}", Register::AX), + Self::IN_ALDX => write!(f, "in {}, :#04x{}", Register::AL, Register::DX), + Self::IN_AXDX => write!(f, "in {}, :#04x{}", Register::AX, Register::DX), - Self::OUT_AL(byte) => write!(f, "out {}, {byte:#04x}", Register::AL), - Self::OUT_AX(byte) => write!(f, "out {}, {byte:#04x}", Register::AX), - Self::OUT_ALDX => write!(f, "out {}, {}", Register::AL, Register::DX), - Self::OUT_AXDX => write!(f, "out {}, {}", Register::AX, Register::DX), + Self::OUT_AL(byte) => write!(f, "out :#04x{}, {byte:#04x}", Register::AL), + Self::OUT_AX(byte) => write!(f, "out :#04x{}, {byte:#04x}", Register::AX), + Self::OUT_ALDX => write!(f, "out {}, :#04x{}", Register::AL, Register::DX), + Self::OUT_AXDX => write!(f, "out {}, :#04x{}", Register::AX, Register::DX), Self::INT(byte) => write!(f, "int {byte:#04x}"), Self::INTO => write!(f, "into"),