Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSPLLE: Carry and overflow fixes #10045

Merged
merged 11 commits into from Aug 23, 2021
Merged

Conversation

Pokechu22
Copy link
Contributor

This PR fixes a bunch of status register related issues with DSPLLE, the vast majority of which are related to the carry and overflow registers. It also adds cond_test.ds, which replaces less_test.ds from #10031. With this PR, both the recompiler and the interpreter gives results that exactly match hardware (see cond_test.zip for hardware results as dumped using DSPSpy).

The way the DSP recompiler handled determining overflows and carries was both confusing and incorrect. I've rewritten the code for all relevant instructions in a way that should be more readable (and should perform the same or better (with the main optimisation being use of LEA instead of ADD where possible)). However, I also had to disable the "updates SR" check as it made assumptions that were violated by my test case (namely, that the value of cr doesn't matter when calling a function). It would be possible to fix it, but would require a much more complicated implementation that I don't want to write right now.

Additionally, the xA and xB conditions were broken with the recompiler. This doesn't really matter since nothing official uses them, but it's fixed now.

Lastly, the NEG instruction can actually generate both caries and overflows for specific inputs, which is covered by my test. This was the only thing that the interpreter handled incorrectly.

@Pokechu22 Pokechu22 force-pushed the dsp-lle-sr64 branch 2 times, most recently from a45dbfd to 2d1118d Compare August 22, 2021 03:11
This new test covers all conditions, and also tests overflow, carry, logical zero, and the behavior of NEG
It doesn't work right in all situations, including in the cond_test hardware test.  It could definitely be fixed, but it would be a hassle to do so.
Thus, the 40-bit accumulator is treated as properly sign-extended when read as a 64-bit number.  This affects e.g. overflow detection.
Thus, the 40-bit accumulator is treated as properly sign-extended when read as a 64-bit number.  This affects e.g. overflow detection.
Although it's not clear what the xA and xB conditions are intended to do, the pattern indicates that xB is the regular version and xA is the inverted version, so for consistency, IsConditionB should be the main function.
@Tilka Tilka merged commit bc10412 into dolphin-emu:master Aug 23, 2021
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants