From 5967089c87c59f5884b3a47dc1ed19f90c9d4d13 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Thu, 18 Aug 2022 21:11:21 +0300 Subject: [PATCH] Optional short absolute disassembly (-$xxxx.w/$FFFFxxx.w) --- disasm.cpp | 23 ++++++++++++++++++----- include/disasm.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/disasm.cpp b/disasm.cpp index eb4702a6..20933b71 100644 --- a/disasm.cpp +++ b/disasm.cpp @@ -10,13 +10,15 @@ #include "debugmem.h" #include "disasm.h" -int disasm_flags = DISASM_FLAG_LC_MNEMO | DISASM_FLAG_LC_REG | DISASM_FLAG_LC_SIZE | DISASM_FLAG_LC_HEX | DISASM_FLAG_CC | DISASM_FLAG_EA | DISASM_FLAG_VAL | DISASM_FLAG_WORDS; +int disasm_flags = DISASM_FLAG_LC_MNEMO | DISASM_FLAG_LC_REG | DISASM_FLAG_LC_SIZE | DISASM_FLAG_LC_HEX | + DISASM_FLAG_CC | DISASM_FLAG_EA | DISASM_FLAG_VAL | DISASM_FLAG_WORDS | DISASM_FLAG_ABSSHORTLONG; int disasm_min_words = 5; int disasm_max_words = 16; TCHAR disasm_hexprefix[3] = { '$', 0 }; static TCHAR disasm_areg, disasm_dreg; static TCHAR disasm_pcreg[3], disasm_fpreg[3]; +static bool absshort_long = false; void disasm_init(void) { @@ -28,6 +30,7 @@ void disasm_init(void) } disasm_areg = (disasm_flags & DISASM_FLAG_LC_REG) ? 'a' : 'A'; disasm_dreg = (disasm_flags & DISASM_FLAG_LC_REG) ? 'd' : 'D'; + absshort_long = (disasm_flags & DISASM_FLAG_ABSSHORTLONG) != 0; } @@ -560,10 +563,20 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi } break; case absw: - addr = (uae_s32)(uae_s16)get_iword_debug (pc); - _stprintf (buffer, disasm_lc_hex(_T("$%04X")), (uae_u16)addr); - pc += 2; - showea_val(buffer, opcode, addr, size); + { + addr = (uae_s32)(uae_s16)get_iword_debug (pc); + uae_s16 saddr = (uae_s16)addr; + TCHAR w = (disasm_flags & DISASM_FLAG_LC_REG) ? 'w' : 'W'; + if (absshort_long) { + _stprintf(buffer, disasm_lc_hex(_T("$%08X.%c")), addr, w); + } else if (saddr < 0) { + _stprintf(buffer, disasm_lc_hex(_T("-$%04X.%c")), -saddr, w); + } else { + _stprintf(buffer, disasm_lc_hex(_T("$%04X.%c")), saddr, w); + } + pc += 2; + showea_val(buffer, opcode, addr, size); + } break; case absl: addr = get_ilong_debug (pc); diff --git a/include/disasm.h b/include/disasm.h index 4ed91a9d..a877c2d0 100644 --- a/include/disasm.h +++ b/include/disasm.h @@ -24,3 +24,4 @@ extern TCHAR disasm_hexprefix[3]; #define DISASM_FLAG_EA 64 #define DISASM_FLAG_VAL 128 #define DISASM_FLAG_WORDS 256 +#define DISASM_FLAG_ABSSHORTLONG 512 -- 2.47.3