all repos — mgba @ c7a147598167b237530dedd924443f3144501cbe

mGBA Game Boy Advance Emulator

ARM Decoder: Only print PC-relative register contents in loads (fixes #1908)
Vicki Pfau vi@endrift.com
Mon, 12 Oct 2020 18:08:13 -0700
commit

c7a147598167b237530dedd924443f3144501cbe

parent

67d3eed8fbdfadfce9c3f5c0ac1c6b4ad323b9e4

1 files changed, 8 insertions(+), 1 deletions(-)

jump to
M src/arm/decoder.csrc/arm/decoder.c

@@ -164,17 +164,20 @@ return 0;

} int total = 0; bool elideClose = false; + char comment[64]; int written; + comment[0] = '\0'; if (memory.format & ARM_MEMORY_REGISTER_BASE) { if (memory.baseReg == ARM_PC && memory.format & ARM_MEMORY_IMMEDIATE_OFFSET) { uint32_t addrBase = memory.format & ARM_MEMORY_OFFSET_SUBTRACT ? -memory.offset.immediate : memory.offset.immediate; - if (!cpu) { + if (!cpu || memory.format & ARM_MEMORY_STORE) { strlcpy(buffer, "[", blen); ADVANCE(1); written = _decodePCRelative(addrBase, symbols, pc & 0xFFFFFFFC, false, buffer, blen); ADVANCE(written); } else { uint32_t value; + _decodePCRelative(addrBase, symbols, pc & 0xFFFFFFFC, false, comment, sizeof(comment)); addrBase += pc & 0xFFFFFFFC; // Thumb does not have PC-relative LDRH/LDRB switch (memory.width & 7) { case 1:

@@ -246,6 +249,10 @@ }

if ((memory.format & (ARM_MEMORY_PRE_INCREMENT | ARM_MEMORY_WRITEBACK)) == (ARM_MEMORY_PRE_INCREMENT | ARM_MEMORY_WRITEBACK)) { strlcpy(buffer, "!", blen); ADVANCE(1); + } + if (comment[0]) { + written = snprintf(buffer, blen, " @ %s", comment); + ADVANCE(written); } return total; }