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

DSPAssembler: Rework errors and warnings, and related cleanup #10694

Merged
merged 6 commits into from May 28, 2022

Conversation

Pokechu22
Copy link
Contributor

Among other changes to the error/warning messages, this trims trailing newline characters in the line. Before (on windows) the \r would corrupt the output and make them very hard to understand (as the error message would be drawn over the code line, but part of the code line would peek out from behind it).

Other than that, it's mostly removal of magic numbers (or reduction in how magical they are, as I'm not touching some of the code involving partype_t currently but using the DSP_REG_X constants helps with it.)

For example, before, if you were to add MOVR $acc1, $ac0.m (invalid because the second operand of MOVR must be either hte low or high part of $ax0 or $ax1, but I didn't realize this, and because of another typo) into dsp_base_noirq.inc, you would get this output:

	MOVR $acc1, $ac0.m
   (param 2)12 : 	MOVR $acc1, $ac0.m
 ERROR: Invalid register Line: 12 : -

except the actual output is

 ERROR: Invalid register Line: 12 : -ac0.m

because line-feed characters \r are being used without a corresponding \n. Stripping the \r would give this (which I think is also the result on non-windows OSes):

	MOVR $acc1, $ac0.m   (param 2)12 : 	MOVR $acc1, $ac0.m ERROR: Invalid register Line: 12 : -

which is still pretty messy.

Now you get this:

At line 12 of included file tests/dsp_base_noirq.inc, main opcode parameter 2:
	MOVR $acc1, $ac0.m
ERROR: Invalid register

which is reasonably understandable.

There are definitely other possible improvements here, but I think this is a good start.

Without this, execution continues beyond the end of the function, into the great unknown (probably eventually falling into either code left from a previous test, or the start of the DSP ROM). end_of_test is just an infinite loop to stop executing until the DSP is reset.
This should result in no behavior differences.
The assembler upper-cases the mnemonic internally, so it never would match the lower-case x.
CW is used as a fallback to write a full instruction as hex, but we already declare it in DSPTables.h for the assembler.
Among other things, this trims trailing newline characters. Before (on windows) the \r would corrupt the output and make them very hard to understand (as the error message would be drawn over the code line, but part of the code line would peek out from behind it).
@Pokechu22 Pokechu22 force-pushed the dsp-assembler-error-messages-etc branch from a402b28 to bd3173e Compare May 24, 2022 03:27
@Tilka Tilka merged commit 3dbc180 into dolphin-emu:master May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants