Debian Codegraph @

Source/DSPSpy/tests/40bit_ins_test.ds

raw
1 ; This test covers the behavior of 40-bit mode with various instructions.
2 incdir "tests"
3 include "dsp_base.inc"
4
5 positive_value: EQU #0x1234
6 negative_value: EQU #0x9876
7
8 negative_imem_value_addr:
9 CW negative_value
10
11 ; DSPSpy doesn't pre-populating DMEM currently, so instead use these addresses to store values.
12 positive_dmem_value_addr: EQU #0x100
13 negative_dmem_value_addr: EQU #0x101
14 readback_dmem_addr: EQU #0x102
15
16 test_main:
17 LRI $ar0, #positive_dmem_value_addr
18 LRI $ar1, #negative_dmem_value_addr
19 LRI $ar2, #negative_imem_value_addr
20 LRI $ar3, #readback_dmem_addr
21 LRI $ix0, #0
22 LRI $ix1, #0
23 LRI $ix2, #0
24 LRI $ix3, #0
25
26 LRI $ax0.h, #positive_value
27 LRI $ax1.h, #negative_value
28
29 SR @positive_dmem_value_addr, $ax0.h
30 SR @negative_dmem_value_addr, $ax1.h
31
32 LRI $cr, #(positive_dmem_value_addr / 256)
33
34 SET40
35 ; Instructions that perform sign-extension
36 ; $acc0 should alternate between being positive and negative here
37 ; (though none of these instructions update $sr)
38
39 ; [1] ILRR (also ILRRD/ILRRI/ILRRN, not covered)
40 ILRR $ac0.m, @$ar2 ; -
41 CALL send_back
42 ; [2] LR
43 LR $ac0.m, @positive_dmem_value_addr ; +
44 CALL send_back
45 ; [3] LRI
46 LRI $ac0.m, #negative_value ; -
47 CALL send_back
48 ; [4] LRIS
49 LRIS $ac0.m, #42 ; +
50 CALL send_back
51 ; [5] LRR (also LRRD/LRRI/LRRN)
52 LRR $ac0.m, @$ar1 ; -
53 CALL send_back
54 ; [6] LRS
55 LRS $ac0.m, @(positive_dmem_value_addr & 0xff) ; +
56 CALL send_back
57 ; [7] MRR
58 MRR $ac0.m, $ax1.h ; -
59 CALL send_back
60 ; [8] 'LN (and 'L, but 'LN lets us set $ix0 to not increment $ar0)
61 NX'LN : $ac0.m, @$ar0 ; +
62 CALL send_back
63
64 ; Instructions that experience saturation
65 ; $ax1.l should alternate between 0x8000 and 0x7fff.
66 LRI $ac0.m, #0x4231
67 LRI $ac0.h, #0x12 ; positive
68 LRI $ac1.m, #0x2816
69 LRI $ac1.h, #0x99 ; negative
70 ; [9] MRR (again)
71 MRR $ax1.l, $ac1.m ; -
72 CALL send_back
73 ; [10] SR
74 SR @readback_dmem_addr, $ac0.m
75 LR $ax1.l, @readback_dmem_addr ; +
76 CALL send_back
77 ; [11] SRRN (also SRR/SRRD/SRRI)
78 SRRN @$ar3, $ac1.m
79 LR $ax1.l, @readback_dmem_addr ; -
80 CALL send_back
81 ; [12] SRS
82 SRS @(readback_dmem_addr & 0xff), $ac0.m
83 LR $ax1.l, @readback_dmem_addr ; +
84 CALL send_back
85 ; [13] 'LSNM (also 'LS/'LSM/'LSN) - the $ax0.l read is not relevant
86 NX'LSNM : $ax0.l, $ac1.m
87 LR $ax1.l, @readback_dmem_addr ; -
88 CALL send_back
89 ; [14] 'MV
90 NX'MV : $ax1.l, $ac0.m ; +
91 CALL send_back
92 ; [15] 'SLNM (also 'SL/'SLM/'SLN) - the $ax0.l read is not relevant
93 ; Note that 'SL stores to @$ar0, while 'LS stores to @$ar3
94 LRI $ar0, #readback_dmem_addr
95 NX'SLNM : $ac1.m, $ax0.l
96 LR $ax1.l, @readback_dmem_addr ; -
97 CALL send_back
98 LRI $ar0, #positive_dmem_value_addr
99 ; [16] 'SN (also 'S)
100 NX'SN : @$ar3, $ac0.m
101 LR $ax1.l, @readback_dmem_addr ; +
102 CALL send_back
103
104 ; Instructions that are not affected
105 ; [17] ADDI
106 ADDI $ac0.m, #8
107 CALL send_back
108 ; [18] ADDIS
109 ADDIS $ac0.m, #-8
110 CALL send_back
111 ; [19] ANDC
112 ANDC $ac1.m, $ac0.m
113 CALL send_back
114 ; [20] ANDI
115 ANDI $ac0.m, #0x6666
116 CALL send_back
117 ; [21] ANDR
118 ANDR $ac0.m, $ax0.h
119 CALL send_back
120 ; [22] ORC
121 ORC $ac0.m, $ac1.m
122 CALL send_back
123 ; [23] ORI
124 ORI $ac0.m, #0xfeed
125 CALL send_back
126 ; [24] ORR
127 ORR $ac1.m, $ax0.h
128 CALL send_back
129 ; [25] NOT
130 NOT $ac1.m
131 CALL send_back
132 ; [26] XORC
133 XORC $ac0.m, $ac1.m
134 CALL send_back
135 ; [27] XORI
136 XORI $ac0.m, #0x5555
137 CALL send_back
138 ; [28] XORR
139 XORR $ac1.m, $ax1.h
140 CALL send_back
141
142 ; [29] MOVR always sign extends...
143 MOVR $acc1, $ax0.h
144 CALL send_back
145 ; [30] ... even in SET16 mode
146 SET16
147 MOVR $acc1, $ax1.h
148 CALL send_back
149 SET40
150
151 ; Shift instructions - do these see saturated $ac1.m?
152 LRI $ac0.m, #positive_value
153 LRI $ac1.m, #2
154 LRI $ac1.h, #1
155 ; [31] - for diffs only
156 CALL send_back
157 ; [32]
158 LSRNR $acc0, $ac1.m
159 CALL send_back
160 ; [33] Shifts $acc0 by $ac1.m (in the other direction)
161 LSRN
162 CALL send_back
163
164 ; Does LOOP experience saturation?
165 CLR $acc0
166 LRI $ac1.m, #0x1234
167 LRI $ac1.h, #1
168 ; [34] - for diffs only
169 CALL send_back
170 ; [35] LOOP
171 LOOP $ac1.m
172 INC $acc0
173 CALL send_back
174 LRI $ac1.h, #0x99
175 ; [36] BLOOP
176 BLOOP $ac1.m, bloop_last_ins
177 INCM $ac0.m
178 bloop_last_ins:
179 NOP
180 CALL send_back
181
182 ; For the sake of clarity, the same LOOP/BLOOP calls in SET16 mode don't have saturation:
183 SET16
184 CLR $acc0
185 LRI $ac1.m, #0x1234
186 LRI $ac1.h, #1
187 ; [37] - for diffs only
188 CALL send_back
189 ; [38] LOOP
190 LOOP $ac1.m
191 INC $acc0
192 CALL send_back
193 LRI $ac1.h, #0x99
194 ; [39] BLOOP
195 BLOOP $ac1.m, bloop2_last_ins
196 INCM $ac0.m
197 bloop2_last_ins:
198 NOP
199 CALL send_back
200
201 ; We're done, DO NOT DELETE THIS LINE
202 JMP end_of_test