Skip to content

Consider an invalid instruction the end of a function trace#11

Merged
KallDrexx merged 1 commit intoApfelTeeSaft:mainfrom
KallDrexx:no_exception_on_invalid_instructions
Oct 12, 2025
Merged

Consider an invalid instruction the end of a function trace#11
KallDrexx merged 1 commit intoApfelTeeSaft:mainfrom
KallDrexx:no_exception_on_invalid_instructions

Conversation

@KallDrexx
Copy link
Collaborator

When tracing a function, previously we were throwing an exception if we encountered an invalid / unknown op code. This is needed because we don't know how many bytes the instruction contains and thus can't accurately predict where the next instruction would be.

However, some roms (like super mario bros) use an always taken branch instruction to save bytes instead of a jump. In this case the next byte after the branch is an invalid op code that will never actually be hit.

So this change makes it so that invalid operations act as an end of function markers, but throw a warning in the console. That allows unconditional/always branches to work, and for games that actually use these unofficial op codes they are able to get hints in the debug window.

When tracing a function, previously we were throwing an exception
if we encountered an invalid / unknown op code. This is needed because
we don't know how many bytes the instruction contains and thus can't
accurately predict where the next instruction would be.

However, some roms (like super mario bros) use an always taken
branch instruction to save bytes instead of a jump. In this case
the next byte after the branch is an invalid op code that will never
actually be hit.

So this change makes it so that invalid operations act as an end
of function markers, but throw a warning in the console. That
allows unconditional/always branches to work, and for games that
actually use these unofficial op codes they are able to get hints
in the debug window.
@KallDrexx KallDrexx merged commit c71aa4d into ApfelTeeSaft:main Oct 12, 2025
10 checks passed
@KallDrexx KallDrexx deleted the no_exception_on_invalid_instructions branch October 12, 2025 18:31
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.

1 participant