sudp.s
9.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#include "suregre.h"
#define c0000 $0
#define c5555 $2
#define cAAAA $3
#define cFFFF $4
#define TESTID $1
#define c0004 $24
#define MEMLOC $25
#define CNTR1 $26
#define CNTR2 $27
#define ACCUM1 $28
#define ACCUM2 $29
#define SCRTCH $30
/* #define SELF_CHECK */
#ifdef SELF_CHECK
# define output(T,A,L)\
bne T, A, L
#else
# define output(T,A,L)\
sw T, 0 (MEMLOC);\
bne T, A, L;\
add MEMLOC, MEMLOC, c0004;
#endif
/* INITIALIZE REGISTERS */
or $1, $0, $0
or $2, $0, $0
or $3, $0, $0
or $4, $0, $0
or $5, $0, $0
or $6, $0, $0
or $7, $0, $0
or $8, $0, $0
or $9, $0, $0
or $10, $0, $0
or $11, $0, $0
or $12, $0, $0
or $13, $0, $0
or $14, $0, $0
or $15, $0, $0
or $16, $0, $0
or $17, $0, $0
or $18, $0, $0
or $19, $0, $0
or $20, $0, $0
or $21, $0, $0
or $22, $0, $0
or $23, $0, $0
or $24, $0, $0
or $25, $0, $0
or $26, $0, $0
or $27, $0, $0
or $28, $0, $0
or $29, $0, $0
or $30, $0, $0
or $31, $0, $0
or TESTID, c0000, c0000
lui c5555, 0x5555
ori c5555, c5555, 0x5555
lui cAAAA, 0xAAAA
ori cAAAA, cAAAA, 0xAAAA
lui cFFFF, 0xFFFF
ori cFFFF, cFFFF, 0xFFFF
ori c0004, c0000, 0x0004
or MEMLOC, c0000, c0000
or CNTR1, c0000, c0000
or CNTR2, c0000, c0000
or ACCUM1, c0000, c0000
or ACCUM2, c0000, c0000
or SCRTCH, c0000, c0000
/* ADDITION */
ori TESTID, c0000, 1
add SCRTCH, cFFFF, c0000 /* 0xFFFFFFFF + 0x00000000 */
output( SCRTCH, cFFFF, Fail)
addu SCRTCH, c0000, cFFFF /* 0x00000000 + 0xFFFFFFFF */
output( SCRTCH, cFFFF, Fail)
add SCRTCH, c0000, c0000 /* 0x00000000 + 0x00000000 */
output( SCRTCH, c0000, Fail)
addu SCRTCH, c5555, c5555 /* 0x55555555 + 0x55555555 */
output( SCRTCH, cAAAA, Fail)
add SCRTCH, cAAAA, c5555 /* 0xAAAAAAAA + 0x55555555 */
output( SCRTCH, cFFFF, Fail)
addi ACCUM1, cAAAA, 0x0001 /* 0x55555555 + 0xAAAAAAAB */
addu SCRTCH, c5555, ACCUM1
output( SCRTCH, c0000, Fail)
add SCRTCH, ACCUM1, c5555 /* 0xAAAAAAAB + 0x55555555 */
output( SCRTCH, c0000, Fail)
lui ACCUM1, 0x5554 /* 0x55555555 + 0xFFFFAAAA */
ori ACCUM1, ACCUM1, 0xFFFF
addi SCRTCH, c5555, 0xAAAA
bne SCRTCH, ACCUM1, Fail
lui ACCUM1, 0xAAAA /* 0xAAAAAAAA + 0x00005555 */
ori ACCUM1, ACCUM1, 0xFFFF
addiu SCRTCH, cAAAA, 0x5555
bne SCRTCH, ACCUM1, Fail
/* SUBTRACTION */
ori TESTID, c0000, 2
sub SCRTCH, cFFFF, cFFFF /* 0xFFFFFFFF - 0xFFFFFFFF */
output( SCRTCH, c0000, Fail)
subu SCRTCH, cFFFF, c0000 /* 0xFFFFFFFF - 0x00000000 */
output( SCRTCH, cFFFF, Fail)
sub SCRTCH, c0000, cFFFF /* 0x00000000 - 0xFFFFFFFF */
add SCRTCH, SCRTCH, cFFFF /* + 0xFFFFFFFF */
output( SCRTCH, c0000, Fail)
subu SCRTCH, cAAAA, c5555 /* 0xAAAAAAAA - 0x55555555 */
output( SCRTCH, c5555, Fail)
sub SCRTCH, c0000, c0000 /* 0x00000000 - 0x00000000 */
output( SCRTCH, c0000, Fail)
subu SCRTCH, c5555, cAAAA /* 0x55555555 - 0xAAAAAAAA */
add SCRTCH, SCRTCH, cFFFF
output( SCRTCH, cAAAA, Fail)
/* AND */
ori TESTID, c0000, 3
and SCRTCH, cFFFF, c0000 /* 0xFFFFFFFF & 0x00000000 */
output( SCRTCH, c0000, Fail)
and SCRTCH, cFFFF, cFFFF /* 0xFFFFFFFF & 0xFFFFFFFF */
output( SCRTCH, cFFFF, Fail)
and SCRTCH, c0000, cFFFF /* 0x00000000 & 0xFFFFFFFF */
output( SCRTCH, c0000, Fail)
and SCRTCH, cFFFF, c5555 /* 0xFFFFFFFF & 0x55555555 */
output( SCRTCH, c5555, Fail)
and SCRTCH, c0000, c0000 /* 0x00000000 & 0x00000000 */
output( SCRTCH, c0000, Fail)
and SCRTCH, c5555, cFFFF /* 0x55555555 & 0xFFFFFFFF */
output( SCRTCH, c5555, Fail)
and SCRTCH, c5555, cAAAA /* 0x55555555 & 0xAAAAAAAA */
output( SCRTCH, c0000, Fail)
and SCRTCH, cFFFF, cAAAA /* 0xFFFFFFFF & 0xAAAAAAAA */
output( SCRTCH, cAAAA, Fail)
and SCRTCH, cAAAA, c5555 /* 0xAAAAAAAA & 0x55555555 */
output( SCRTCH, c0000, Fail)
and SCRTCH, cAAAA, cFFFF /* 0xAAAAAAAA & 0xFFFFFFFF */
output( SCRTCH, cAAAA, Fail)
/* NOR */
ori TESTID, c0000, 4
nor SCRTCH, cFFFF, c0000 /* ~(0xFFFFFFFF | 0x00000000) */
output( SCRTCH, c0000, Fail)
nor SCRTCH, c0000, c0000 /* ~(0x00000000 | 0x00000000) */
output( SCRTCH, cFFFF, Fail)
nor SCRTCH, cFFFF, c0000 /* ~(0x00000000 | 0xFFFFFFFF) */
output( SCRTCH, c0000, Fail)
nor SCRTCH, c5555, c0000 /* ~(0x55555555 | 0x00000000) */
output( SCRTCH, cAAAA, Fail)
nor SCRTCH, c5555, cAAAA /* ~(0x55555555 | 0xAAAAAAAA) */
output( SCRTCH, c0000, Fail)
nor SCRTCH, c0000, cAAAA /* ~(0x00000000 | 0xAAAAAAAA) */
output( SCRTCH, c5555, Fail)
nor SCRTCH, c0000, c5555 /* ~(0x00000000 | 0x55555555) */
output( SCRTCH, cAAAA, Fail)
nor SCRTCH, cAAAA, c5555 /* ~(0xAAAAAAAA | 0x55555555) */
output( SCRTCH, c0000, Fail)
nor SCRTCH, cAAAA, c0000 /* ~(0xAAAAAAAA | 0x00000000) */
output( SCRTCH, c5555, Fail)
nor SCRTCH, cFFFF, cFFFF /* ~(0xFFFFFFFF | 0xFFFFFFFF) */
output( SCRTCH, c0000, Fail)
/* OR */
ori TESTID, c0000, 5
or SCRTCH, cFFFF, c0000 /* 0xFFFFFFFF | 0x00000000 */
output( SCRTCH, cFFFF, Fail)
or SCRTCH, c0000, c0000 /* 0x00000000 | 0x00000000 */
output( SCRTCH, c0000, Fail)
or SCRTCH, cFFFF, c0000 /* 0x00000000 | 0xFFFFFFFF */
output( SCRTCH, cFFFF, Fail)
or SCRTCH, c5555, c0000 /* 0x55555555 | 0x00000000 */
output( SCRTCH, c5555, Fail)
or SCRTCH, c5555, cAAAA /* 0x55555555 | 0xAAAAAAAA */
output( SCRTCH, cFFFF, Fail)
or SCRTCH, c0000, cAAAA /* 0x00000000 | 0xAAAAAAAA */
output( SCRTCH, cAAAA, Fail)
or SCRTCH, c0000, c5555 /* 0x00000000 | 0x55555555 */
output( SCRTCH, c5555, Fail)
or SCRTCH, cAAAA, c5555 /* 0xAAAAAAAA | 0x55555555 */
output( SCRTCH, cFFFF, Fail)
or SCRTCH, cAAAA, c0000 /* 0xAAAAAAAA | 0x00000000 */
output( SCRTCH, cAAAA, Fail)
or SCRTCH, cFFFF, cFFFF /* 0xFFFFFFFF | 0xFFFFFFFF */
output( SCRTCH, cFFFF, Fail)
/* XOR */
ori TESTID, c0000, 6
xor SCRTCH, cFFFF, c0000 /* 0xFFFFFFFF ^ 0x00000000 */
output( SCRTCH, cFFFF, Fail)
xor SCRTCH, c0000, c0000 /* 0x00000000 ^ 0x00000000 */
output( SCRTCH, c0000, Fail)
xor SCRTCH, cFFFF, c0000 /* 0x00000000 ^ 0xFFFFFFFF */
output( SCRTCH, cFFFF, Fail)
xor SCRTCH, c5555, cFFFF /* 0x55555555 ^ 0xFFFFFFFF */
output( SCRTCH, cAAAA, Fail)
xor SCRTCH, c5555, cAAAA /* 0x55555555 ^ 0xAAAAAAAA */
output( SCRTCH, cFFFF, Fail)
xor SCRTCH, cFFFF, cAAAA /* 0xFFFFFFFF ^ 0xAAAAAAAA */
output( SCRTCH, c5555, Fail)
xor SCRTCH, cFFFF, c5555 /* 0xFFFFFFFF ^ 0x55555555 */
output( SCRTCH, cAAAA, Fail)
xor SCRTCH, cAAAA, c5555 /* 0xAAAAAAAA ^ 0x55555555 */
output( SCRTCH, cFFFF, Fail)
xor SCRTCH, cAAAA, cFFFF /* 0xAAAAAAAA ^ 0xFFFFFFFF */
output( SCRTCH, c5555, Fail)
xor SCRTCH, cFFFF, cFFFF /* 0xFFFFFFFF ^ 0xFFFFFFFF */
output( SCRTCH, c0000, Fail)
/* SLLV */
/* SRLV */
ori TESTID, c0000, 7
or CNTR1, c0000, c0000
ori CNTR2, c0000, 0x1F
or ACCUM1, c0000, c0000
lui ACCUM2, 0x8000
L_SLLV:
sllv SCRTCH, cFFFF, CNTR1
srl SCRTCH, SCRTCH, 31
sllv SCRTCH, SCRTCH, CNTR2
or ACCUM1, ACCUM1, SCRTCH
srav SCRTCH, ACCUM2, CNTR1
output( ACCUM1, SCRTCH, Fail)
output( SCRTCH, ACCUM1, Fail)
addi CNTR1, CNTR1, 1
bne CNTR2, c0000, L_SLLV
add CNTR2, CNTR2, cFFFF
/* GENERAL DECODING */
ori TESTID, c0000, 8
sll ACCUM1, cFFFF, 0x000F /* SLL */
srl ACCUM2, cFFFF, 0x0011 /* SRL */
xor SCRTCH, ACCUM1, ACCUM2
bne SCRTCH, cFFFF, Fail
andi ACCUM1, c5555, 0x8000 /* ANDI */
andi ACCUM2, c5555, 0x7FFF /* ANDI */
xor SCRTCH, ACCUM1, ACCUM2
srl ACCUM1, c5555, 0x0010
bne SCRTCH, ACCUM1, Fail
sll ACCUM1, cFFFF, 0x0011 /* SLL */
srl ACCUM2, cFFFF, 0x000F /* SRL */
xor SCRTCH, ACCUM1, ACCUM2
bne SCRTCH, cFFFF, Fail
ori CNTR1, c0000, 0x000F
srlv ACCUM1, cFFFF, CNTR1 /* SRLV */
sll ACCUM2, cFFFF, 0x0011
xor SCRTCH, ACCUM1, ACCUM2
bne SCRTCH, cFFFF, Fail
ori CNTR1, c0000, 0x0011
srlv ACCUM1, cFFFF, CNTR1 /* SRLV */
sll ACCUM2, cFFFF, 0x000F
xor SCRTCH, ACCUM1, ACCUM2
bne SCRTCH, cFFFF, Fail
xori SCRTCH, cAAAA, 0xFFFF /* XORI */
lui ACCUM1, 0xAAAA
ori ACCUM1, ACCUM1, 0x5555
bne SCRTCH, ACCUM1, Fail
xori SCRTCH, cAAAA, 0x0000 /* XORI */
bne SCRTCH, cAAAA, Fail
/* ------------------------- */
ori TESTID, c0000, 9
ori ACCUM1, c0000, 0x001
slt SCRTCH, cAAAA, c5555 /* SLT */
bne SCRTCH, ACCUM1, Fail
slt SCRTCH, c5555, cAAAA
bne SCRTCH, c0000, Fail
sltu SCRTCH, cAAAA, c5555 /* SLTU */
bne SCRTCH, c0000, Fail
sltu SCRTCH, c5555, cAAAA
bne SCRTCH, ACCUM1, Fail
slti SCRTCH, cAAAA, 0xFFFE /* SLTI */
bne SCRTCH, ACCUM1, Fail
slti SCRTCH, c5555, 0x7FFF
bne SCRTCH, c0000, Fail
slti SCRTCH, cFFFF, 0x7FFF
bne SCRTCH, ACCUM1, Fail
sltiu SCRTCH, cFFFF, 0xFFFE /* SLTIU*/
bne SCRTCH, c0000, Fail
sltiu SCRTCH, cAAAA, 0xFFFF
bne SCRTCH, ACCUM1, Fail
sltiu SCRTCH, c5555, 0x7FFF
bne SCRTCH, c0000, Fail
ChkJ( 10, j, ACCUM1)
ChkJAL( 11, jal, ACCUM1)
ChkJALR(12, jalr, ACCUM1, ACCUM2, SCRTCH)
ChkJR( 13, jr, ACCUM1, ACCUM2)
ChkBrWWF(14,beq,ACCUM1,ACCUM2,0x0000,0x0008,0x0000,0x0020,SCRTCH)
ChkBrWT(15,bgez,ACCUM1,0x0000,0x0010,SCRTCH )
ChkBrlWT(16,bgezal,ACCUM1,0x0000,0x0020,SCRTCH )
ChkBrWT(17,bgtz,ACCUM1,0x0000,0x0080,SCRTCH )
ChkBrWF(18,blez,ACCUM1,0x0000,0x0080,SCRTCH )
ChkBrWF(19,bltz,ACCUM1,0x0000,0x0100,SCRTCH )
ChkBrlWF(20,bltzal,ACCUM1,0x0000,0x0200,SCRTCH )
ChkBrWWF(21,bne,ACCUM1,ACCUM2,0x0000,0x0800,0x0000,0x0800,SCRTCH)
ori TESTID, c0000, 0xFEED
Fail:
output( SCRTCH, SCRTCH, Fail)
output( ACCUM1, ACCUM1, Fail)
output( ACCUM2, ACCUM2, Fail)
output( CNTR1, CNTR1, Fail)
output( CNTR2, CNTR2, Fail)
output( MEMLOC, MEMLOC, Fail)
/* DMA WRITE ISSUE SUBROUTINE */
/* or ACCUM1, c0000, c0000
or ACCUM2, c0000, c0000
addi MEMLOC, MEMLOC, 0xFFFF
DmaWrite:
mfc0 SCRTCH, $7
bne SCRTCH, $0, DmaWrite
nop
DW_full:
mfc0 SCRTCH, $5
bne SCRTCH, $0, DW_full
nop
mtc0 ACCUM1, $0
mtc0 ACCUM2, $1
mtc0 MEMLOC, $3
DmaDone:
mfc0 SCRTCH, $6
bne SCRTCH, c0000, DmaDone
nop
mtc0 SCRTCH, $7
*/
break