| 1 |
incdir "tests" |
| 2 |
include "dsp_base.inc" |
| 3 |
|
| 4 |
test_main: |
| 5 |
; Test registers used by LRS and SRS |
| 6 |
LRI $CR, #0x0000 |
| 7 |
CALL clear_regs |
| 8 |
CALL store_mem_sr |
| 9 |
|
| 10 |
; Write with SR, read with LR |
| 11 |
LRI $AR0, #0xA00A |
| 12 |
CALL create_pattern |
| 13 |
CALL store_mem_sr |
| 14 |
CALL send_back |
| 15 |
CALL clear_regs |
| 16 |
CALL read_mem_lr |
| 17 |
CALL send_back |
| 18 |
|
| 19 |
; Write with SR, read with LRS |
| 20 |
LRI $AR0, #0xB00B |
| 21 |
CALL create_pattern |
| 22 |
CALL store_mem_sr |
| 23 |
CALL send_back |
| 24 |
CALL clear_regs |
| 25 |
CALL read_mem_lrs |
| 26 |
CALL send_back |
| 27 |
|
| 28 |
; Write with SRS, read with LR |
| 29 |
LRI $AR0, #0xC00C |
| 30 |
CALL create_pattern |
| 31 |
CALL store_mem_srs |
| 32 |
CALL send_back |
| 33 |
CALL clear_regs |
| 34 |
CALL read_mem_lr |
| 35 |
CALL send_back |
| 36 |
|
| 37 |
; Write with SR, read with LRS |
| 38 |
LRI $AR0, #0xD00D |
| 39 |
CALL create_pattern |
| 40 |
CALL store_mem_srs |
| 41 |
CALL send_back |
| 42 |
CALL clear_regs |
| 43 |
CALL read_mem_lrs |
| 44 |
CALL send_back |
| 45 |
|
| 46 |
; We're done, DO NOT DELETE THIS LINE |
| 47 |
JMP end_of_test |
| 48 |
|
| 49 |
create_pattern: |
| 50 |
LRI $IX0, #0x0110 |
| 51 |
MRR $AX0.L, $AR0 |
| 52 |
ADDARN $AR0, $IX0 |
| 53 |
MRR $AX1.L, $AR0 |
| 54 |
ADDARN $AR0, $IX0 |
| 55 |
MRR $AX0.H, $AR0 |
| 56 |
ADDARN $AR0, $IX0 |
| 57 |
MRR $AX1.H, $AR0 |
| 58 |
ADDARN $AR0, $IX0 |
| 59 |
MRR $AC0.L, $AR0 |
| 60 |
ADDARN $AR0, $IX0 |
| 61 |
MRR $AC1.L, $AR0 |
| 62 |
ADDARN $AR0, $IX0 |
| 63 |
MRR $AC0.M, $AR0 |
| 64 |
ADDARN $AR0, $IX0 |
| 65 |
MRR $AC1.M, $AR0 |
| 66 |
ADDARN $AR0, $IX0 |
| 67 |
; AC0.H and AC1.H have odd results since they're 8-bit sign-extended, but that's fine. |
| 68 |
MRR $AC0.H, $AR0 |
| 69 |
ADDARN $AR0, $IX0 |
| 70 |
MRR $AC1.H, $AR0 |
| 71 |
RET |
| 72 |
|
| 73 |
clear_regs: |
| 74 |
LRI $AX0.L, #0x0000 |
| 75 |
LRI $AX1.L, #0x0000 |
| 76 |
LRI $AX0.H, #0x0000 |
| 77 |
LRI $AX1.H, #0x0000 |
| 78 |
LRI $AC0.L, #0x0000 |
| 79 |
LRI $AC1.L, #0x0000 |
| 80 |
LRI $AC0.M, #0x0000 |
| 81 |
LRI $AC1.M, #0x0000 |
| 82 |
LRI $AC0.H, #0x0000 |
| 83 |
LRI $AC1.H, #0x0000 |
| 84 |
RET |
| 85 |
|
| 86 |
read_mem_lr: |
| 87 |
LR $AX0.L, @0x0000 |
| 88 |
LR $AX1.L, @0x0001 |
| 89 |
LR $AX0.H, @0x0002 |
| 90 |
LR $AX1.H, @0x0003 |
| 91 |
LR $AC0.L, @0x0004 |
| 92 |
LR $AC1.L, @0x0005 |
| 93 |
LR $AC0.M, @0x0006 |
| 94 |
LR $AC1.M, @0x0007 |
| 95 |
RET |
| 96 |
|
| 97 |
read_mem_lrs: |
| 98 |
LRS $AX0.L, @0x00 |
| 99 |
LRS $AX1.L, @0x01 |
| 100 |
LRS $AX0.H, @0x02 |
| 101 |
LRS $AX1.H, @0x03 |
| 102 |
LRS $AC0.L, @0x04 |
| 103 |
LRS $AC1.L, @0x05 |
| 104 |
LRS $AC0.M, @0x06 |
| 105 |
LRS $AC1.M, @0x07 |
| 106 |
RET |
| 107 |
|
| 108 |
store_mem_sr: |
| 109 |
SR @0x0000, $AX0.L |
| 110 |
SR @0x0001, $AX1.L |
| 111 |
SR @0x0002, $AX0.H |
| 112 |
SR @0x0003, $AX1.H |
| 113 |
SR @0x0004, $AC0.L |
| 114 |
SR @0x0005, $AC1.L |
| 115 |
SR @0x0006, $AC0.M |
| 116 |
SR @0x0007, $AC1.M |
| 117 |
RET |
| 118 |
|
| 119 |
store_mem_srs: |
| 120 |
; For future compatibility these have been changed to cw. |
| 121 |
; The way the instructions were originally encoded is commented, |
| 122 |
; but this does not match their behavior. |
| 123 |
cw 0x2800 ; SRS @0x00, $AX0.L - actually SRSH @0x00, $AC0.H |
| 124 |
cw 0x2901 ; SRS @0x01, $AX1.L - actually SRSH @0x01, $AC1.H |
| 125 |
cw 0x2A02 ; SRS @0x02, $AX0.H - actually unknown, no store performed |
| 126 |
cw 0x2B03 ; SRS @0x03, $AX1.H - actually unknown, no store performed |
| 127 |
cw 0x2C04 ; SRS @0x04, $AC0.L |
| 128 |
cw 0x2D05 ; SRS @0x05, $AC1.L |
| 129 |
cw 0x2E06 ; SRS @0x06, $AC0.M |
| 130 |
cw 0x2F07 ; SRS @0x07, $AC1.M |
| 131 |
RET |