diff options
author | Oxore <oxore@protonmail.com> | 2023-05-11 00:15:44 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-05-11 00:15:44 +0300 |
commit | 9ed1399c3500a09c2fae21fc578603f2a9eaf447 (patch) | |
tree | 55b3d3e4541f67cdc57b1e396f2e99be244f56ec /main.cpp | |
parent | 5981e3d7eefba54db40d5cc11728307b2aa3d88d (diff) |
Migrate all the rest instructions
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
@@ -134,6 +134,19 @@ static const char *ReferenceTypeToString(ReferenceType type) return "UNKN"; } +static bool ShouldPrintAsRaw(const DisasmNode& node) +{ + if (node.arg1.type == ArgType::kImmediate) { + if (node.opcode == OpCode::kADD || node.opcode == OpCode::kSUB || + node.opcode == OpCode::kAND || node.opcode == OpCode::kOR || + node.opcode == OpCode::kEOR || node.opcode == OpCode::kCMP) + { + return true; + } + } + return false; +} + static void RenderDisassembly( FILE *output, const DisasmMap &disasm_map, const DataBuffer &code, const Settings &s) { @@ -159,13 +172,23 @@ static void RenderDisassembly( fprintf(output, ".L%08x:\n", node->offset); } } - const char *const delimiter = node->arguments[0] != '\0' ? " " : ""; - if (node->opcode != OpCode::kNone) { - // New API - node->FPrint(output, s); + assert(node->opcode != OpCode::kNone); + if (ShouldPrintAsRaw(*node)) { + auto raw = DisasmNode{TracedNodeType::kInstruction, node->offset}; + raw.opcode = OpCode::kRaw; + raw.opcode = OpCode::kRaw; + raw.arg1 = Arg::Raw(GetU16BE(code.buffer + raw.offset)); + raw.FPrint(output, s); + uint32_t i = kInstructionSizeStepBytes; + for (; i < node->size; i += kInstructionSizeStepBytes) { + char arg_str[kArgsBufferSize]{}; + const auto arg = Arg::Raw(GetU16BE(code.buffer + raw.offset + i)); + arg.SNPrint(arg_str, kArgsBufferSize, s); + fprintf(output, ", %s", arg_str); + } + fprintf(output, "\n"); } else { - // Old API - fprintf(output, " %s%s%s", node->mnemonic, delimiter, node->arguments); + node->FPrint(output, s); } if (node->has_branch_addr && s.xrefs_to) { char branch_addr[12]{}; |