Skip to content

Fix ARM7 recompiler crashing when using SUB R*,PC,* opcodes - #2441

Open
trap15 wants to merge 1 commit into
flyinghead:masterfrom
trap15:fix-arm7-rn15
Open

Fix ARM7 recompiler crashing when using SUB R*,PC,* opcodes#2441
trap15 wants to merge 1 commit into
flyinghead:masterfrom
trap15:fix-arm7-rn15

Conversation

@trap15

@trap15 trap15 commented Aug 21, 2026

Copy link
Copy Markdown

Generalized handling of operands in the emitDataProcOp function, which had inconsistent handling of operands, leading to some instructions working with this operand set, and others not, as any use of PC as Rn is generally converted to an immediate operand instead.

A better solution is to generalize the emitter and operand handling to transparently handle immediates vs. register operands, but that is a much more intrusive change that I'm not confident to make in an unfamiliar codebase.

I was a little surprised to find such a low-hanging error here, I guess the ARM7 core doesn't get much workout from the existing library?

Generalized handling of operands in the emitDataProcOp function,
which had inconsistent handling of operands, leading to some
instructions working with this operand set, and others not, as any use
of PC as Rn is generally converted to an immediate operand instead.

A better solution is to generalize the emitter and operand handling
to transparently handle immediates vs. register operands, but that is a
much more intrusive change that I'm not confident to make in an
unfamiliar codebase.
@vkedwardli

Copy link
Copy Markdown
Collaborator

What game can reproduce this crash?

@trap15

trap15 commented Aug 21, 2026

Copy link
Copy Markdown
Author

I found this issue while writing my own code for a personal project, I can create a minimized test case with KallistiOS if needed. The easiest way to run into this issue is with the ADR pseudo-instruction referring to a symbol behind that instruction.

@trap15

trap15 commented Aug 21, 2026

Copy link
Copy Markdown
Author

After more development on my own project, I've found issues with the carry-out handling for shift-by-register operands as well. I think there are probably even more bugs here if things like this don't get caught by any existing programs, so it might be good to find an ARM test suite (if one exists...) and port it to DC for this and fully flush it out.

@flyinghead

Copy link
Copy Markdown
Owner

this is the only ARM test suite for this cpu I know of:
https://github.com/snickerbockers/dc-arm7wrestler

@trap15

trap15 commented Aug 21, 2026

Copy link
Copy Markdown
Author

Ah, that's at the least a great starting point, thank you very much. I'll take a look at enhancing it to cover the cases I fixed here, and any other cases I can find or think of.

@flyinghead

Copy link
Copy Markdown
Owner

Could you target the dev branch instead of master? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants