From b48d9185f7e01778269a05db7f955e850fbb6ba0 Mon Sep 17 00:00:00 2001 From: Sean Date: Sun, 23 Feb 2020 17:19:47 -0700 Subject: [PATCH] added hex back in --- src/main.cc | 2 +- src/scanner.cc | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main.cc b/src/main.cc index 09d88e9..c57cbd1 100644 --- a/src/main.cc +++ b/src/main.cc @@ -7,7 +7,7 @@ #include "api.h" #include "iigs.h" -const char *argp_program_version = "regs 0.2"; +const char *argp_program_version = "regs 1.1"; const char *argp_program_bug_address = "sean@seancode.com"; static char doc[] = "Disassemble Apple IIgs software"; static char args_doc[] = "FILE"; diff --git a/src/scanner.cc b/src/scanner.cc index 247835d..9953bf0 100644 --- a/src/scanner.cc +++ b/src/scanner.cc @@ -188,7 +188,19 @@ bool Scanner::disassemble(std::ostream &f, uint32_t from, uint32_t to, if (!sym.empty()) { f << sym << std::endl; } - f << hex(address, 6) << ": " << printInst(map[address]) << std::endl; + f << hex(address, 6) << ": "; + auto ptr = getAddress(address); + if (map[address]->length > 4) { + f << ".. .. .. .. "; + } else { + for (int i = 0; i < map[address]->length; i++) { + f << hex(ptr->r8(), 2) << " "; + } + for (int i = map[address]->length; i < 4; i++) { + f << " "; + } + } + f << printInst(map[address]) << std::endl; address += map[address]->length; } if (address < b->address + b->length) { @@ -218,7 +230,7 @@ void Scanner::dumpHex(std::ostream &f, uint32_t from, uint32_t to) { f << " "; ascii += " "; } - for (; j < 16 && !ptr->eof(); j++) { + for (; j < 16 && !ptr->eof() && i + j - skip < len; j++) { if (j == 8) { f << " "; ascii += " ";