Skip to content

Loopback jumps should occur on the same cpu address of the jump#13

Merged
ApfelTeeSaft merged 1 commit intoApfelTeeSaft:mainfrom
KallDrexx:loopback_instruction_fix
Jan 17, 2026
Merged

Loopback jumps should occur on the same cpu address of the jump#13
ApfelTeeSaft merged 1 commit intoApfelTeeSaft:mainfrom
KallDrexx:loopback_instruction_fix

Conversation

@KallDrexx
Copy link
Collaborator

When a function is decompiled in the middle of a function, and that function has a jump point prior to the function's entry point, we need to add a fake virtual instruction that jumps back to the start of the function.

The virtual instruction needs to be the last instruction in the ordered instruction set.

We previously accomplished that by adding an instruction at the location of the function entrypiont minus one. However, this was failing in cases where a system would cause an interrupt right on the virtual address. Emulators would then save the virtual instruction's address to the stack, and jump back into that address once RTI occurs.

This fails because the virtual address can't be decompiled, because legit code doesn't exist at that address.

To fix this, I updated the SubAddressOrder property to allow for negative values. This allows the loopback instruction to be on the correct CPUAddress while still being ordered as expected.

Also ensured that virtual addresses do not get labels, as they are not actually valid jump targets.

When a function is decompiled in the middle of a function, and that function
has a jump point prior to the function's entry point, we need to add a
fake virtual instruction that jumps back to the start of the function.

The virtual instruction needs to be the last instruction in the
ordered instruction set.

We previously accomplished that by adding an instruction at the
location of the function entrypiont minus one. However, this was
failing in cases where a system would cause an interrupt right on
the virtual address. Emulators would then save the virtual
instruction's address to the stack, and jump back into that address
once RTI occurs.

This fails because the virtual address can't be decompiled, because
legit code doesn't exist at that address.

To fix this, I updated the `SubAddressOrder` property to allow for negative
values. This allows the loopback instruction to be on the correct CPUAddress
while still being ordered as expected.

Also ensured that virtual addresses do not get labels, as they are not
actually valid jump targets.
@ApfelTeeSaft ApfelTeeSaft merged commit 8242ffb into ApfelTeeSaft:main Jan 17, 2026
10 checks passed
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.

2 participants