From 151e1b4bcc5a64355f55b870d1f5eb74d27223e6 Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 7 Apr 2018 19:17:25 -0400 Subject: [PATCH] arm: Calculate R15-relative offsets in disassembly --- src/devices/cpu/arm/armdasm.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/devices/cpu/arm/armdasm.cpp b/src/devices/cpu/arm/armdasm.cpp index 81bd4c8dc6e..047fb2b3f70 100644 --- a/src/devices/cpu/arm/armdasm.cpp +++ b/src/devices/cpu/arm/armdasm.cpp @@ -245,27 +245,32 @@ offs_t arm_disassembler::disassemble(std::ostream &stream, offs_t pc, const data } } + int memreg = (opcode >> 16) & 0xf; WritePadding(stream, start_position); - util::stream_format( stream, "R%d, [R%d", - (opcode>>12)&0xf, (opcode>>16)&0xf ); + util::stream_format(stream, "R%d, [R%d", (opcode >> 12) & 0xf, memreg); if( opcode&0x02000000 ) { /* register form */ - WriteRegisterOperand1( stream, opcode ); - util::stream_format( stream, "]" ); + WriteRegisterOperand1(stream, opcode); + util::stream_format(stream, "]"); } else { /* immediate form */ - util::stream_format( stream, "]" ); + util::stream_format(stream, "]"); + uint16_t displacement = opcode & 0xfff; if( opcode&0x00800000 ) { - util::stream_format( stream, ", #$%x", opcode&0xfff ); + util::stream_format(stream, ", #$%x", displacement); + if (memreg == 15) + util::stream_format(stream, " ; [$%x]", pc + 8 + displacement); } else { - util::stream_format( stream, ", -#$%x", opcode&0xfff ); + util::stream_format(stream, ", -#$%x", displacement); + if (memreg == 15) + util::stream_format(stream, " ; [$%x]", pc + 8 - displacement); } } }