diff options
Diffstat (limited to 'src/disasm.cpp')
-rw-r--r-- | src/disasm.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/disasm.cpp b/src/disasm.cpp index 572030d..a7dc07b 100644 --- a/src/disasm.cpp +++ b/src/disasm.cpp @@ -5,8 +5,9 @@ #include "m68k.h" #include <cassert> -#include <cstring> #include <cerrno> +#include <cinttypes> +#include <cstring> void DisasmNode::AddReferencedBy(const uint32_t address_from, const ReferenceType ref_type) { @@ -150,6 +151,31 @@ bool DisasmMap::ApplySymbolsFromElf(const ELF::Image &elf) return true; } +void DisasmMap::ConsumeTraceTable(TraceTable &&tt) +{ + this->_tt = static_cast<TraceTable &&>(tt); + const size_t nodes_count = _tt.NodesCount(); + for (size_t n = 0; n < nodes_count; n++) { + const auto &node = _tt.Node(n); + if (node.kind == TraceNodeKind::kPc) { + if (node.address % 2) { + fprintf(stderr, + "Error: Uneven PC values are not supported " + "(got PC=0x%08" PRIu32 "), exiting\n", + node.address); + exit(1); + } else if (static_cast<unsigned long>(node.address) > kRomSizeBytes) { + fprintf(stderr, + "Error: PC values > 4MiB are not supported " + "(got PC=0x%08" PRIu32 "), exiting\n", + node.address); + exit(1); + } + insertNode(node.address, NodeType::kTracedInstruction); + } + } +} + static constexpr bool IsNextLikelyAnInstruction(const Op &op) { return (op.opcode != OpCode::kNone && |