DSPLLE: Carry and overflow fixes #10045
Merged
+810
−521
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.
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 replacesless_test.dsfrom #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
LEAinstead ofADDwhere 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 ofcrdoesn'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
xAandxBconditions were broken with the recompiler. This doesn't really matter since nothing official uses them, but it's fixed now.Lastly, the
NEGinstruction 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.