3-operand MULT/MULTU & delay slot exception handling#71
Closed
aslanhudajev wants to merge 0 commit intoran-j:mainfrom
Closed
3-operand MULT/MULTU & delay slot exception handling#71aslanhudajev wants to merge 0 commit intoran-j:mainfrom
aslanhudajev wants to merge 0 commit intoran-j:mainfrom
Conversation
ran-j
requested changes
Feb 21, 2026
Owner
ran-j
left a comment
There was a problem hiding this comment.
Hey nice work, the Vu0 implementations seens good to me but please create a new PR with only thouse changes, we have a lot of "noise" from your recompilation like gitignore changed and some cursor thing.
.cursor/data/funDefsZDataError.md
Outdated
| @@ -0,0 +1,6525 @@ | |||
|
|
|||
Owner
There was a problem hiding this comment.
ok you have some files like this one that is specific for you project and can't be merge like this one.
Contributor
Author
There was a problem hiding this comment.
Yes, I will fix that.
I'll make a new PR.
| @@ -1,6 +0,0 @@ | |||
| #include "register_functions.h" | |||
ps2xRuntime/CMakeLists.txt
Outdated
| ) | ||
| FetchContent_MakeAvailable(raylib) | ||
|
|
||
| set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "" FORCE) |
Owner
There was a problem hiding this comment.
we can't have this deep on the runtime this scene specific for your project.
.gitignore
Outdated
| ps2xRuntime/src/runner/register_functions.cpp | ||
| ps2xRuntime/output No newline at end of file | ||
| ps2xRuntime/output | ||
| ps2xRuntime/src/runner |
Owner
|
Also the build are fail |
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.
This commit:
6821c69eb5674807569416cbac236510491f41a4fixes a lot of runtime errors.The MULT/MULTU fix is the most impactful I would say. Not super sure about the delay slot fix, it did however fix many issues in the game I am trying to get to run.
Fix R5900 3-operand MULT/MULTU:
Standard MIPS MULT rs, rt only writes HI/LO. The R5900 extends this with a 3-operand form MULT rd, rs, rt that also writes the low 32 bits of the result into rd. The code generator was omitting the rd write, leaving the destination register stale. Any game code that reads rd after a multiply (instead of using MFLO) would get garbage, causing infinite loops and incorrect computations. This was found in Gauntlet: Dark Legacy's InitAtreeSeqs where the loop counter was computed via 3-operand MULT and never advanced.
Fix delay slot exception handling:
When a MIPS exception occurs on a delay slot instruction, the CPU sets the BD (Branch Delay) bit in the Cause register and EPC points to the branch instruction, not the delay slot. The runtime's exception handler needs to know it was in a delay slot to correctly re-execute the branch after returning from the exception. The code generator now emits ctx->in_delay_slot = 1 / = 0 around delay slot instruction code, allowing raiseCop0Exception to set EPC and BD correctly and preserve the branch target.