From 51c26d82a5604e0877c8a07d4d00b6ac46e9ff65 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 15 Aug 2021 15:26:03 -0700 Subject: [PATCH] DSPSpy: Require user to specify a test_main label This makes the point where execution starts more obvious compared to a start_of_test label at the end of the include, and allows putting other functions at the start of the file. This change also modifies the existing tests to build with this change. --- Source/DSPSpy/tests/accelerator_loop_test.ds | 2 ++ Source/DSPSpy/tests/accelerator_test.ds | 1 - Source/DSPSpy/tests/andc_ls_test.ds | 4 ++-- Source/DSPSpy/tests/arith_test.ds | 2 ++ Source/DSPSpy/tests/cr_test.ds | 1 + Source/DSPSpy/tests/dr_test.ds | 1 + Source/DSPSpy/tests/dsp_base_noirq.inc | 5 +---- Source/DSPSpy/tests/dsp_test.ds | 15 ++++++++------- Source/DSPSpy/tests/ir_test.ds | 2 +- Source/DSPSpy/tests/ld_test.ds | 1 + Source/DSPSpy/tests/less_test.ds | 1 + Source/DSPSpy/tests/mul_test.ds | 3 ++- Source/DSPSpy/tests/neg_test.ds | 1 + Source/DSPSpy/tests/op_test.ds | 1 + Source/DSPSpy/tests/reg_mask_test.ds | 1 + Source/DSPSpy/tests/unk_regs_test.ds | 2 +- 16 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Source/DSPSpy/tests/accelerator_loop_test.ds b/Source/DSPSpy/tests/accelerator_loop_test.ds index 20e72919f5..6348f52efe 100644 --- a/Source/DSPSpy/tests/accelerator_loop_test.ds +++ b/Source/DSPSpy/tests/accelerator_loop_test.ds @@ -1,6 +1,8 @@ incdir "tests" include "dsp_base.inc" +test_main: + ; Test parameters lri $AC0.M, #0x0000 ; start lri $AC0.L, #0x0000 ; start diff --git a/Source/DSPSpy/tests/accelerator_test.ds b/Source/DSPSpy/tests/accelerator_test.ds index ac9cb99b83..a05866d5bb 100644 --- a/Source/DSPSpy/tests/accelerator_test.ds +++ b/Source/DSPSpy/tests/accelerator_test.ds @@ -2,7 +2,6 @@ ; See https://github.com/dolphin-emu/dolphin/pull/5997 incdir "tests" include "dsp_base.inc" -jmp test_main ; Writes the passed format, start and end addresses to the accelerator registers, ; then reads them back to registers. diff --git a/Source/DSPSpy/tests/andc_ls_test.ds b/Source/DSPSpy/tests/andc_ls_test.ds index 7a0c4fccc5..9967f7cfcf 100644 --- a/Source/DSPSpy/tests/andc_ls_test.ds +++ b/Source/DSPSpy/tests/andc_ls_test.ds @@ -5,7 +5,7 @@ include "dsp_base.inc" ; ; 3d80 andc'ls $AC1.M : $AX0.L, $AC0.M - +test_main: clr $ACC0 clr $ACC1 lri $AX0.L, #0x0000 @@ -14,7 +14,7 @@ include "dsp_base.inc" lri $AC0.M, #0x0004 lri $AC1.M, #0x1234 - andc'ls $AC1.M : $AX0.L, $AC0.M + cw 0x3d80 ; andc'ls $AC1.M : $AX0.L, $AC0.M call send_back diff --git a/Source/DSPSpy/tests/arith_test.ds b/Source/DSPSpy/tests/arith_test.ds index 704437b45b..96884c6bbc 100644 --- a/Source/DSPSpy/tests/arith_test.ds +++ b/Source/DSPSpy/tests/arith_test.ds @@ -2,6 +2,8 @@ incdir "tests" include "dsp_base.inc" +test_main: + clr $acc0 tst $acc0 diff --git a/Source/DSPSpy/tests/cr_test.ds b/Source/DSPSpy/tests/cr_test.ds index 272e4b8c2a..4ffc53d0ec 100644 --- a/Source/DSPSpy/tests/cr_test.ds +++ b/Source/DSPSpy/tests/cr_test.ds @@ -12,6 +12,7 @@ TEST_ADDR: equ 0xFFA0 ; 0x0000 TEST_MEM: equ 0x00A0 ; 0x0000 TEST_MEM_2: equ 0x01A0 ; 0x0100 +test_main: LRI $AC0.L, #0xf00f SR @TEST_REG, $AC0.L SR @TEST_MEM, $AC0.L diff --git a/Source/DSPSpy/tests/dr_test.ds b/Source/DSPSpy/tests/dr_test.ds index 1085c74cdc..96109a499b 100644 --- a/Source/DSPSpy/tests/dr_test.ds +++ b/Source/DSPSpy/tests/dr_test.ds @@ -27,6 +27,7 @@ include "dsp_base.inc" ; And thus it's tricky to implement in software too :p ; test using indexing register 1 - 0 is used in send_back +test_main: lri $AR1, #16 lri $IX1, #32 lri $WR1, #0 diff --git a/Source/DSPSpy/tests/dsp_base_noirq.inc b/Source/DSPSpy/tests/dsp_base_noirq.inc index 1d2f815e41..1558c7c5ca 100644 --- a/Source/DSPSpy/tests/dsp_base_noirq.inc +++ b/Source/DSPSpy/tests/dsp_base_noirq.inc @@ -97,7 +97,7 @@ ORG 0x10 lrri $ac1.m, @$ar0 lr $ar0, @REGS_BASE - jmp start_of_test + jmp test_main ; This is where we jump when we're done testing, see above. ; We just fall into a loop, playing dead until someone resets the DSP. @@ -281,6 +281,3 @@ dma_copy: lr $sr, @(REGS_BASE+19) ret ; from send_back - -; Obviously this must be included directly before your test code -start_of_test: diff --git a/Source/DSPSpy/tests/dsp_test.ds b/Source/DSPSpy/tests/dsp_test.ds index 3550dd205c..772573b9c3 100644 --- a/Source/DSPSpy/tests/dsp_test.ds +++ b/Source/DSPSpy/tests/dsp_test.ds @@ -6,13 +6,14 @@ include "dsp_base.inc" ; We can call send_back at any time to send data back to the PowerPC. - lri $AC0.M, #0x1000 - call send_back +test_main: + lri $AC0.M, #0x1000 + call send_back - set40 - lri $AC0.M, #0x1000 - set16 - call send_back + set40 + lri $AC0.M, #0x1000 + set16 + call send_back ; We're done, DO NOT DELETE THIS LINE - jmp end_of_test + jmp end_of_test diff --git a/Source/DSPSpy/tests/ir_test.ds b/Source/DSPSpy/tests/ir_test.ds index b9a80b3c96..e47aa729bf 100644 --- a/Source/DSPSpy/tests/ir_test.ds +++ b/Source/DSPSpy/tests/ir_test.ds @@ -30,7 +30,7 @@ include "dsp_base.inc" ; I really don't know how the above could possibly be efficiently implemented in hardware. ; And thus it's tricky to implement in software too :p - +test_main: ; test using indexing register 1 - 0 is used in send_back lri $AR1, #16 lri $IX1, #32 diff --git a/Source/DSPSpy/tests/ld_test.ds b/Source/DSPSpy/tests/ld_test.ds index 0154677d6a..045680c877 100644 --- a/Source/DSPSpy/tests/ld_test.ds +++ b/Source/DSPSpy/tests/ld_test.ds @@ -2,6 +2,7 @@ incdir "tests" include "dsp_base.inc" +test_main: lri $AR0, #0x001c lri $AR1, #0x001d lri $AR2, #0x001e diff --git a/Source/DSPSpy/tests/less_test.ds b/Source/DSPSpy/tests/less_test.ds index 1b75eaecdd..20be209b73 100644 --- a/Source/DSPSpy/tests/less_test.ds +++ b/Source/DSPSpy/tests/less_test.ds @@ -1,6 +1,7 @@ incdir "tests" include "dsp_base.inc" +test_main: CLR $acc0 CLR $acc1 LRI $ac0.h, #0x0050 diff --git a/Source/DSPSpy/tests/mul_test.ds b/Source/DSPSpy/tests/mul_test.ds index 3ec2e83f64..8f5ca9810f 100644 --- a/Source/DSPSpy/tests/mul_test.ds +++ b/Source/DSPSpy/tests/mul_test.ds @@ -2,8 +2,9 @@ incdir "tests" include "dsp_base.inc" -; Results is in capitails like this: UNSIGNED +; Results are in capitals like this: UNSIGNED +test_main: CLR15 ; Test MULXMVZ - SET15 diff --git a/Source/DSPSpy/tests/neg_test.ds b/Source/DSPSpy/tests/neg_test.ds index 22c4ba8481..57c1610511 100644 --- a/Source/DSPSpy/tests/neg_test.ds +++ b/Source/DSPSpy/tests/neg_test.ds @@ -2,6 +2,7 @@ incdir "tests" include "dsp_base.inc" +test_main: clr $ACC0 neg $ACC0 diff --git a/Source/DSPSpy/tests/op_test.ds b/Source/DSPSpy/tests/op_test.ds index 5b2ab76bc5..b77fc6525d 100644 --- a/Source/DSPSpy/tests/op_test.ds +++ b/Source/DSPSpy/tests/op_test.ds @@ -10,6 +10,7 @@ include "dsp_base.inc" // 0x02cb is the same opcode, but arithmetic. // We'll call it asrn, no arguments. +test_main: clr $ACC0 clr $ACC1 lri $AC0.H, #0 diff --git a/Source/DSPSpy/tests/reg_mask_test.ds b/Source/DSPSpy/tests/reg_mask_test.ds index 3bc0e9068b..39238d5b16 100644 --- a/Source/DSPSpy/tests/reg_mask_test.ds +++ b/Source/DSPSpy/tests/reg_mask_test.ds @@ -1,6 +1,7 @@ incdir "tests" include "dsp_base.inc" +test_main: ; Test what happens various values are written to every register LRI $ar0, #0xffff CALL set_all_regs diff --git a/Source/DSPSpy/tests/unk_regs_test.ds b/Source/DSPSpy/tests/unk_regs_test.ds index 54f4fa5a74..d4fd79c5ae 100644 --- a/Source/DSPSpy/tests/unk_regs_test.ds +++ b/Source/DSPSpy/tests/unk_regs_test.ds @@ -2,7 +2,7 @@ incdir "tests" include "dsp_base.inc" ; Reads regs from 0xFF80 to 0xFF8D and sends them back - +test_main: lr $AC0.M, @0xff80 call send_back