Consider an invalid instruction the end of a function trace#11
Merged
KallDrexx merged 1 commit intoApfelTeeSaft:mainfrom Oct 12, 2025
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.