OpenCores
URL https://opencores.org/ocsvn/ion/ion/trunk

Subversion Repositories ion

[/] [ion/] [trunk/] [src/] [opcodes/] [opcodes.s] - Blame information for rev 27

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ja_rd
################################################################################
2 4 ja_rd
# opcode.s -- MIPS opcode tester for Ion project
3 2 ja_rd
#-------------------------------------------------------------------------------
4
# ORIGINAL AUTHOR: Steve Rhoads (rhoadss@yahoo.com) -- 1/10/01
5
#
6
# This file is an edited version of 'opcodes.asm', which is part of the Plasma
7
# project (http://opencores.org/project,plasma).
8
# COPYRIGHT: Software placed into the public domain by the original author.
9
# Software 'as is' without warranty.  Author liable for nothing.
10 4 ja_rd
#
11 2 ja_rd
#-------------------------------------------------------------------------------
12 4 ja_rd
# This assembly file tests all of the opcodes supported by the Ion core.
13 2 ja_rd
# This test assumes that address 0x20000000 is the UART write register.
14
# Successful tests will print out "A" or "AB" or "ABC" or ....
15
# Missing letters or letters out of order indicate a failure.
16 14 ja_rd
#
17 2 ja_rd
#-------------------------------------------------------------------------------
18 4 ja_rd
# NOTE: This test bench relies on the simulation logs to catch errors. That is,
19
# unlike the original Plasma code, this one does not test the test success
20
# conditions. instead, it performs the operations to be tested and relies on you
21
# to compare the logs from the logic simulation and the software simulation.
22
# Test that work this way have been commented with this tag: "@log"
23
#
24 2 ja_rd
#-------------------------------------------------------------------------------
25 4 ja_rd
# NOTE: NOPs have been inserted after load instructions.
26 2 ja_rd
#
27
################################################################################
28
 
29 4 ja_rd
    #-- Set flags below to >0 to enable/disable test assembly ------------------
30 2 ja_rd
 
31 4 ja_rd
    .set TEST_UNALIGNED_LOADS, 0        # unaligned loads
32
    .set TEST_UNALIGNED_STORES, 0       # unaligned stores
33
    .set TEST_BREAK, 1                  # BREAK instruction
34
    # WARNING: the assembler expands div instructions, see 'as' manual
35 14 ja_rd
    .set TEST_DIV, 1                    # DIV* instructions
36
    .set TEST_MUL, 1                    # MUL* instructions
37 2 ja_rd
 
38 4 ja_rd
    #---------------------------------------------------------------------------
39
 
40 2 ja_rd
    .text
41
    .align  2
42
    .globl  entry
43
    .ent    entry
44
entry:
45
    .set    noreorder
46
 
47
    la      $gp, _gp            #initialize stack pointer
48
    la      $4, __bss_start     #$4 = .sbss_start
49
    la      $5, _end            #$5 = .bss_end
50
    nop                         #no stack needed
51
    nop
52
 
53
    b       StartTest
54
    nop                         #nops required to place ISR at 0x3c
55
    nop
56
 
57
OS_AsmPatchValue:
58
    #Code to place at address 0x3c
59
    lui     $26, 0x1000
60
    ori     $26, $26, 0x3c
61
    jr      $26
62
    nop
63
 
64
    .org    0x3c
65 9 ja_rd
    # FIXME assume exception is trap or break for the time being
66 2 ja_rd
InterruptVector:                # Address=0x3c
67
    mfc0    $26,$14             # C0_EPC=14 (Exception PC)
68 9 ja_rd
    addi    $26,$26,4           # skip trap instruction
69 2 ja_rd
    jr      $26
70
    add     $4,$4,5
71
 
72
StartTest:
73
    mtc0    $0,$12              # disable interrupts
74
    lui     $20,0x2000          # serial port write address
75
    ori     $21,$0,'\n'         # <CR> character
76
    ori     $22,$0,'X'          # 'X' letter
77
    ori     $23,$0,'\r'
78
    ori     $24,$0,0x0f80       # temp memory
79
 
80
    sb      $23,0($20)
81
    sb      $21,0($20)
82
    sb      $23,0($20)
83
    sb      $21,0($20)
84
    sb      $23,0($20)
85
    sb      $21,0($20)
86
    sb      $23,0($20)
87
    sb      $21,0($20)
88
 
89
    #Patch interrupt vector to 0x1000003c
90
    la      $5, OS_AsmPatchValue
91
    sub     $6,$5,0x1000
92
    blez    $6,NoPatch
93
    nop
94
    #lw     $6, 0($5)
95
    #sw     $6, 0x3c($0)
96
    #lw     $6, 4($5)
97
    #sw     $6, 0x40($0)
98
    #lw     $6, 8($5)
99
    #sw     $6, 0x44($0)
100
    #lw     $6, 12($5)
101
    #sw     $6, 0x48($0)
102
NoPatch:
103
 
104
    ######################################
105
    #Arithmetic Instructions
106
    ######################################
107
ArthmeticTest:
108
    ori     $2,$0,'A'
109
    sb      $2,0($20)
110
    ori     $2,$0,'r'
111
    sb      $2,0($20)
112
    ori     $2,$0,'i'
113
    sb      $2,0($20)
114
    ori     $2,$0,'t'
115
    sb      $2,0($20)
116
    ori     $2,$0,'h'
117
    sb      $2,0($20)
118
    sb      $23,0($20)
119
    sb      $21,0($20)
120
 
121
    #a: ADD
122
    ori     $2,$0,'a'
123
    sb      $2,0($20)
124
    ori     $3,$0,5
125
    ori     $4,$0,60
126
    add     $2,$3,$4
127
    sb      $2,0($20)    #A
128
    sb      $23,0($20)
129
    sb      $21,0($20)
130
 
131
    #b: ADDI
132
    ori     $2,$0,'b'
133
    sb      $2,0($20)
134
    ori     $4,$0,60
135
    addi    $2,$4,5
136
    sb      $2,0($20)    #A
137
    sb      $23,0($20)
138
    sb      $21,0($20)
139
 
140
    #c: ADDIU
141
    ori     $2,$0,'c'
142
    sb      $2,0($20)
143
    ori     $4,$0,50
144
    addiu   $5,$4,15
145
    sb      $5,0($20)    #A
146
    sb      $23,0($20)
147
    sb      $21,0($20)
148
 
149
    #d: ADDU
150
    ori     $2,$0,'d'
151
    sb      $2,0($20)
152
    ori     $3,$0,5
153
    ori     $4,$0,60
154
    add     $2,$3,$4
155
    sb      $2,0($20)    #A
156
    sb      $23,0($20)
157
    sb      $21,0($20)
158
 
159 4 ja_rd
    # DIV tests, skip conditionally
160
    .ifgt TEST_DIV
161 2 ja_rd
 
162
    #e: DIV
163
    ori     $2,$0,'e'
164
    sb      $2,0($20)
165
    ori     $2,$0,65*117+41
166
    ori     $3,$0,117
167
    div     $2,$3
168
    nop
169
    mflo    $4
170
    sb      $4,0($20)    #A
171
    mfhi    $4
172
    addi    $4,$4,66-41
173
    sb      $4,0($20)    #B
174
    li      $2,-67*19
175
    ori     $3,$0,19
176
    div     $2,$3
177
    nop
178
    mflo    $4
179
    sub     $4,$0,$4
180
    sb      $4,0($20)    #C
181
    ori     $2,$0,68*23
182
    li      $3,-23
183
    div     $2,$3
184
    nop
185
    mflo    $4
186
    sub     $4,$0,$4
187
    sb      $4,0($20)    #D
188
    li      $2,-69*13
189
    li      $3,-13
190
    div     $2,$3
191
    mflo    $4
192
    sb      $4,0($20)    #E
193
    sb      $23,0($20)
194
    sb      $21,0($20)
195
 
196
    #f: DIVU
197
    ori     $2,$0,'f'
198
    sb      $2,0($20)
199
    ori     $2,$0,65*13
200
    ori     $3,$0,13
201
    divu    $2,$3
202
    nop
203
    mflo    $4
204
    sb      $4,0($20)    #A
205
    sb      $23,0($20)
206
    sb      $21,0($20)
207 4 ja_rd
    .endif
208 2 ja_rd
 
209 4 ja_rd
    # MUL tests, skip conditionally
210
    .ifgt   TEST_MUL
211 2 ja_rd
 
212
    #g: MULT
213
    ori     $2,$0,'g'
214
    sb      $2,0($20)
215
    ori     $2,$0,5
216
    ori     $3,$0,13
217
    mult    $2,$3
218
    nop
219
    mflo    $4
220
    sb      $4,0($20)    #A
221
    li      $2,-5
222
    ori     $3,$0,13
223
    mult    $2,$3
224
    mfhi    $5
225
    mflo    $4
226
    sub     $4,$0,$4
227
    addu    $4,$4,$5
228
    addi    $4,$4,2
229
    sb      $4,0($20)    #B
230
    ori     $2,$0,5
231
    li      $3,-13
232
    mult    $2,$3
233
    mfhi    $5
234
    mflo    $4
235
    sub     $4,$0,$4
236
    addu    $4,$4,$5
237
    addi    $4,$4,3
238
    sb      $4,0($20)    #C
239
    li      $2,-5
240
    li      $3,-13
241
    mult    $2,$3
242
    mfhi    $5
243
    mflo    $4
244
    addu    $4,$4,$5
245
    addi    $4,$4,3
246
    sb      $4,0($20)    #D
247
    lui     $4,0xfe98
248
    ori     $4,$4,0x62e5
249
    lui     $5,0x6
250
    ori     $5,0x8db8
251
    mult    $4,$5
252
    mfhi    $6
253
    addiu   $7,$6,2356+1+'E' #E
254
    sb      $7,0($20)
255
    sb      $23,0($20)
256
    sb      $21,0($20)
257
 
258
    #h: MULTU
259
    ori     $2,$0,'h'
260
    sb      $2,0($20)
261
    ori     $2,$0,5
262
    ori     $3,$0,13
263
    multu   $2,$3
264
    nop
265
    mflo    $4
266
    sb      $4,0($20)    #A
267
    sb      $23,0($20)
268
    sb      $21,0($20)
269 4 ja_rd
    .endif
270 2 ja_rd
 
271
    #i: SLT
272
    ori     $2,$0,'i'
273
    sb      $2,0($20)
274
    ori     $2,$0,10
275
    ori     $3,$0,12
276
    slt     $4,$2,$3
277
    addi    $5,$4,64
278
    sb      $5,0($20)    #A
279
    slt     $4,$3,$2
280
    addi    $5,$4,66
281
    sb      $5,0($20)    #B
282
    li      $2,0xfffffff0
283
    slt     $4,$2,$3
284
    addi    $5,$4,66
285
    sb      $5,0($20)    #C
286
    slt     $4,$3,$2
287
    addi    $5,$4,68
288
    sb      $5,0($20)    #D
289
    li      $3,0xffffffff
290
    slt     $4,$2,$3
291
    addi    $5,$4,68
292
    sb      $5,0($20)    #E
293
    slt     $4,$3,$2
294
    addi    $5,$4,70
295
    sb      $5,0($20)    #F
296
    sb      $23,0($20)
297
    sb      $21,0($20)
298
 
299
    #j: SLTI
300
    ori     $2,$0,'j'
301
    sb      $2,0($20)
302
    ori     $2,$0,10
303
    slti    $4,$2,12
304
    addi    $5,$4,64
305
    sb      $5,0($20)    #A
306
    slti    $4,$2,8
307
    addi    $5,$4,66
308
    sb      $5,0($20)    #B
309
    sb      $23,0($20)
310
    sb      $21,0($20)
311
 
312
    #k: SLTIU
313
    ori     $2,$0,'k'
314
    sb      $2,0($20)
315
    ori     $2,$0,10
316
    sltiu   $4,$2,12
317
    addi    $5,$4,64
318
    sb      $5,0($20)    #A
319
    sltiu   $4,$2,8
320
    addi    $5,$4,66
321
    sb      $5,0($20)    #B
322
    sb      $23,0($20)
323
    sb      $21,0($20)
324
 
325
    #l: SLTU
326
    ori     $2,$0,'l'
327
    sb      $2,0($20)
328
    ori     $2,$0,10
329
    ori     $3,$0,12
330
    slt     $4,$2,$3
331
    addi    $5,$4,64
332
    sb      $5,0($20)    #A
333
    slt     $4,$3,$2
334
    addi    $5,$4,66
335
    sb      $5,0($20)    #B
336
    sb      $23,0($20)
337
    sb      $21,0($20)
338
 
339
    #m: SUB
340
    ori     $2,$0,'m'
341
    sb      $2,0($20)
342
    ori     $3,$0,70
343
    ori     $4,$0,5
344
    sub     $2,$3,$4
345
    sb      $2,0($20)    #A
346
    sb      $23,0($20)
347
    sb      $21,0($20)
348
 
349
    #n: SUBU
350
    ori     $2,$0,'n'
351
    sb      $2,0($20)
352
    ori     $3,$0,70
353
    ori     $4,$0,5
354
    sub     $2,$3,$4
355
    sb      $2,0($20)    #A
356
    sb      $23,0($20)
357
    sb      $21,0($20)
358
 
359
    ######################################
360
    #Branch and Jump Instructions
361
    ######################################
362
BranchTest:
363
    ori     $2,$0,'B'
364
    sb      $2,0($20)
365
    ori     $2,$0,'r'
366
    sb      $2,0($20)
367
    ori     $2,$0,'a'
368
    sb      $2,0($20)
369
    ori     $2,$0,'n'
370
    sb      $2,0($20)
371
    ori     $2,$0,'c'
372
    sb      $2,0($20)
373
    ori     $2,$0,'h'
374
    sb      $2,0($20)
375
    sb      $23,0($20)
376
    sb      $21,0($20)
377
 
378
    #a: B
379
    ori     $2,$0,'a'
380
    sb      $2,0($20)
381
    ori     $10,$0,'A'
382
    ori     $11,$0,'B'
383
    b       $B1
384
    sb      $10,0($20)
385
    sb      $22,0($20)
386
$B1:
387
    sb      $11,0($20)
388
    sb      $23,0($20)
389
    sb      $21,0($20)
390
 
391
    #b: BAL
392
    ori     $2,$0,'b'
393
    sb      $2,0($20)
394
    ori     $10,$0,'A'
395
    ori     $11,$0,'B'
396
    ori     $12,$0,'C'
397
    ori     $13,$0,'D'
398
    ori     $14,$0,'E'
399
    ori     $15,$0,'X'
400
    bal     $BAL1
401
    sb      $10,0($20)
402
    sb      $13,0($20)
403
    b       $BAL2
404
    sb      $14,0($20)
405
    sb      $15,0($20)
406
$BAL1:
407
    sb      $11,0($20)
408
    jr      $31
409
    sb      $12,0($20)
410
    sb      $22,0($20)
411
$BAL2:
412
    sb      $23,0($20)
413
    sb      $21,0($20)
414
 
415
    #c: BEQ
416
    ori     $2,$0,'c'
417
    sb      $2,0($20)
418
    ori     $10,$0,'A'
419
    ori     $11,$0,'B'
420
    ori     $12,$0,'C'
421
    ori     $13,$0,'D'
422
    ori     $2,$0,100
423
    ori     $3,$0,123
424
    ori     $4,$0,123
425
    beq     $2,$3,$BEQ1
426
    sb      $10,0($20)
427
    sb      $11,0($20)
428
    beq     $3,$4,$BEQ1
429
    sb      $12,0($20)
430
    sb      $22,0($20)
431
$BEQ1:
432
    sb      $13,0($20)
433
    sb      $23,0($20)
434
    sb      $21,0($20)
435
 
436
    #d: BGEZ
437
    ori     $2,$0,'d'
438
    sb      $2,0($20)
439
    ori     $10,$0,'A'
440
    ori     $11,$0,'B'
441
    ori     $12,$0,'C'
442
    ori     $13,$0,'D'
443
    or      $15,$0,'X'
444
    ori     $2,$0,100
445
    li      $3,0xffff1234
446
    ori     $4,$0,123
447
    bgez    $3,$BGEZ1
448
    sb      $10,0($20)
449
    sb      $11,0($20)
450
    bgez    $2,$BGEZ1
451
    sb      $12,0($20)
452
    sb      $22,0($20)
453
$BGEZ1:
454
    bgez    $0,$BGEZ2
455
    nop
456
    sb      $15,0($20)
457
$BGEZ2:
458
    sb      $13,0($20)
459
    sb      $23,0($20)
460
    sb      $21,0($20)
461
 
462
    #e: BGEZAL
463
    ori     $2,$0,'e'
464
    sb      $2,0($20)
465
    ori     $10,$0,'A'
466
    ori     $11,$0,'B'
467
    ori     $12,$0,'C'
468
    ori     $13,$0,'D'
469
    ori     $14,$0,'E'
470
    ori     $15,$0,'X'
471
    li      $3,0xffff1234
472
    bgezal  $3,$BGEZAL1
473
    nop
474
    sb      $10,0($20)
475
    bgezal  $0,$BGEZAL1
476
    nop
477
    sb      $13,0($20)
478
    b       $BGEZAL2
479
    sb      $14,0($20)
480
    sb      $15,0($20)
481
$BGEZAL1:
482
    sb      $11,0($20)
483
    jr      $31
484
    sb      $12,0($20)
485
    sb      $22,0($20)
486
$BGEZAL2:
487
    sb      $23,0($20)
488
    sb      $21,0($20)
489
 
490
    #f: BGTZ
491
    ori     $2,$0,'f'
492
    sb      $2,0($20)
493
    ori     $10,$0,'A'
494
    ori     $11,$0,'B'
495
    ori     $12,$0,'C'
496
    ori     $13,$0,'D'
497
    ori     $2,$0,100
498
    li      $3,0xffff1234
499
    bgtz    $3,$BGTZ1
500
    sb      $10,0($20)
501
    sb      $11,0($20)
502
    bgtz    $2,$BGTZ1
503
    sb      $12,0($20)
504
    sb      $22,0($20)
505
$BGTZ1:
506
    sb      $13,0($20)
507
    sb      $23,0($20)
508
    sb      $21,0($20)
509
 
510
    #g: BLEZ
511
    ori     $2,$0,'g'
512
    sb      $2,0($20)
513
    ori     $10,$0,'A'
514
    ori     $11,$0,'B'
515
    ori     $12,$0,'C'
516
    ori     $13,$0,'D'
517
    ori     $2,$0,100
518
    li      $3,0xffff1234
519
    blez    $2,$BLEZ1
520
    sb      $10,0($20)
521
    sb      $11,0($20)
522
    blez    $3,$BLEZ1
523
    sb      $12,0($20)
524
    sb      $22,0($20)
525
$BLEZ1:
526
    blez    $0,$BLEZ2
527
    nop
528
    sb      $22,0($20)
529
$BLEZ2:
530
    sb      $13,0($20)
531
    sb      $23,0($20)
532
    sb      $21,0($20)
533
 
534
    #h: BLTZ
535
    ori     $2,$0,'h'
536
    sb      $2,0($20)
537
    ori     $10,$0,'A'
538
    ori     $11,$0,'B'
539
    ori     $12,$0,'C'
540
    ori     $13,$0,'D'
541
    ori     $14,$0,'E'
542
    ori     $2,$0,100
543
    li      $3,0xffff1234
544
    ori     $4,$0,0
545
    bltz    $2,$BLTZ1
546
    sb      $10,0($20)
547
    sb      $11,0($20)
548
    bltz    $3,$BLTZ1
549
    sb      $12,0($20)
550
    sb      $22,0($20)
551
$BLTZ1:
552
    bltz    $4,$BLTZ2
553
    nop
554
    sb      $13,0($20)
555
$BLTZ2:
556
    sb      $14,0($20)
557
    sb      $23,0($20)
558
    sb      $21,0($20)
559
 
560
    #i: BLTZAL
561
    ori     $2,$0,'i'
562
    sb      $2,0($20)
563
    ori     $10,$0,'A'
564
    ori     $11,$0,'B'
565
    ori     $12,$0,'C'
566
    ori     $13,$0,'D'
567
    ori     $14,$0,'E'
568
    ori     $15,$0,'X'
569
    li      $3,0xffff1234
570
    bltzal  $0,$BLTZAL1
571
    nop
572
    sb      $10,0($20)
573
    bltzal  $3,$BLTZAL1
574
    nop
575
    sb      $13,0($20)
576
    b       $BLTZAL2
577
    sb      $14,0($20)
578
    sb      $15,0($20)
579
$BLTZAL1:
580
    sb      $11,0($20)
581
    jr      $31
582
    sb      $12,0($20)
583
    sb      $22,0($20)
584
$BLTZAL2:
585
    sb      $23,0($20)
586
    sb      $21,0($20)
587
 
588
    #j: BNE
589
    ori     $2,$0,'j'
590
    sb      $2,0($20)
591
    ori     $10,$0,'A'
592
    ori     $11,$0,'B'
593
    ori     $12,$0,'C'
594
    ori     $13,$0,'D'
595
    ori     $2,$0,100
596
    ori     $3,$0,123
597
    ori     $4,$0,123
598
    bne     $3,$4,$BNE1
599
    sb      $10,0($20)
600
    sb      $11,0($20)
601
    bne     $2,$3,$BNE1
602
    sb      $12,0($20)
603
    sb      $22,0($20)
604
$BNE1:
605
    sb      $13,0($20)
606
    sb      $23,0($20)
607
    sb      $21,0($20)
608
 
609
    #k: J
610
    ori     $2,$0,'k'
611
    sb      $2,0($20)
612
    ori     $10,$0,'A'
613
    ori     $11,$0,'B'
614
    ori     $15,$0,'X'
615
    j       $J1
616
    sb      $10,0($20)
617
    sb      $15,0($20)
618
$J1:
619
    sb      $11,0($20)
620
    sb      $23,0($20)
621
    sb      $21,0($20)
622
 
623
    #l: JAL
624
    ori     $2,$0,'l'
625
    sb      $2,0($20)
626
    ori     $10,$0,'A'
627
    ori     $11,$0,'B'
628
    ori     $12,$0,'C'
629
    ori     $13,$0,'D'
630
    ori     $14,$0,'E'
631
    ori     $15,$0,'X'
632
    jal     $JAL1
633
    sb      $10,0($20)
634
    sb      $13,0($20)
635
    b       $JAL2
636
    sb      $14,0($20)
637
    sb      $15,0($20)
638
$JAL1:
639
    sb      $11,0($20)
640
    jr      $31
641
    sb      $12,0($20)
642
    sb      $22,0($20)
643
$JAL2:
644
    sb      $23,0($20)
645
    sb      $21,0($20)
646
 
647
    #m: JALR
648
    ori     $2,$0,'m'
649
    sb      $2,0($20)
650
    ori     $10,$0,'A'
651
    ori     $11,$0,'B'
652
    ori     $12,$0,'C'
653
    ori     $13,$0,'D'
654
    ori     $14,$0,'E'
655
    ori     $15,$0,'X'
656
    la      $3,$JALR1
657
    jalr    $3
658
    sb      $10,0($20)
659
    sb      $13,0($20)
660
    b       $JALR2
661
    sb      $14,0($20)
662
    sb      $15,0($20)
663
$JALR1:
664
    sb      $11,0($20)
665
    jr      $31
666
    sb      $12,0($20)
667
    sb      $22,0($20)
668
$JALR2:
669
    sb      $23,0($20)
670
    sb      $21,0($20)
671
 
672
    #n: JR
673
    ori     $2,$0,'n'
674
    sb      $2,0($20)
675
    ori     $10,$0,'A'
676
    ori     $11,$0,'B'
677
    ori     $15,$0,'X'
678
    la      $3,$JR1
679
    jr      $3
680
    sb      $10,0($20)
681
    sb      $15,0($20)
682
$JR1:
683
    sb      $11,0($20)
684
    sb      $23,0($20)
685
    sb      $21,0($20)
686
 
687
    #o: NOP
688
    ori     $2,$0,'o'
689
    sb      $2,0($20)
690
    ori     $2,$0,65
691
    nop
692
    sb      $2,0($20)
693
    sb      $23,0($20)
694
    sb      $21,0($20)
695
 
696
 #   b     LoadTest
697
 
698 4 ja_rd
 
699 2 ja_rd
BreakTest:
700 4 ja_rd
    .ifgt TEST_BREAK
701 2 ja_rd
    #p: BREAK
702 4 ja_rd
    ori     $2,$0,'p'       # check if it jumps to break address and comes back
703 2 ja_rd
    sb      $2,0($20)
704
    ori     $2,$0,'z'
705
    ori     $4,$0,59
706
    break   0
707
    addi    $4,$4,1
708
    sb      $4,0($20)
709 4 ja_rd
 
710
    break   0               # check if load instruction is aborted (@log)
711
    lb      $2,16($2)
712
 
713
    break   0               # check if jump instruction is aborted (@log)
714 9 ja_rd
    j       break_jump_test1
715 4 ja_rd
    add     $4,$4,5
716
 
717 9 ja_rd
break_jump_test1:
718 4 ja_rd
    add     $4,$4,1         # make sure the jump shows in the log (@log)
719
 
720 9 ja_rd
    # TODO traps in delay slots not supported yet
721
    #j       break_jump_test2# check if break works in delay slot of jump
722
    #break   0
723
    nop
724
    j       break_continue
725
    nop
726
 
727
break_jump_test2:
728
    add     $4,$4,1
729
 
730
break_continue:
731 2 ja_rd
    sb      $23,0($20)
732 4 ja_rd
    sb      $21,0($20)
733
    .endif
734 2 ja_rd
 
735
    #q: SYSCALL
736 14 ja_rd
    ori     $2,$0,'q'       # check if it jumpts to trap vector and comes back
737 2 ja_rd
    sb      $2,0($20)
738
    ori     $4,$0,61
739
    syscall 0
740
    addi    $4,$4,-1
741
    sb      $4,0($20)
742 14 ja_rd
 
743
    syscall 0               # check if load instruction is aborted (@log)
744
    lb      $2,16($2)
745
 
746
    syscall 0               # check if jump instruction is aborted (@log)
747
    j       syscall_jump_test1
748
    add     $4,$4,5
749
 
750
syscall_jump_test1:
751
    add     $4,$4,1         # make sure the jump shows in the log (@log)
752
 
753
    # TODO traps in delay slots not supported yet
754
    #j       syscall_jump_test2 # check if syscall works in delay slot of jump
755
    #break   0
756
    nop
757
    j       syscall_continue
758
    nop
759
 
760
syscall_jump_test2:
761
    add     $4,$4,1
762
 
763
syscall_continue:
764 2 ja_rd
    sb      $23,0($20)
765
    sb      $21,0($20)
766
 
767
 
768
    ######################################
769
    #Load, Store, and Memory Control Instructions
770
    ######################################
771
LoadTest:
772
    ori     $2,$0,'L'
773
    sb      $2,0($20)
774
    ori     $2,$0,'o'
775
    sb      $2,0($20)
776
    ori     $2,$0,'a'
777
    sb      $2,0($20)
778
    ori     $2,$0,'d'
779
    sb      $2,0($20)
780
    sb      $23,0($20)
781
    sb      $21,0($20)
782
 
783
    #a: LB
784
    ori     $2,$0,'a'
785
    sb      $2,0($20)
786
    or      $2,$0,$24
787
    li      $3,0x414243fc
788
    sw      $3,16($2)              # 16($2)    = 0x414243fc
789
    lb      $4,16($2)              # $4        = 0x41
790
    sb      $4,0($20)              # UART      = 0x41
791
    lb      $4,17($2)              # $4        = 0x42
792
    nop
793
    sb      $4,0($20)              # UART      = 0x42
794
    lb      $4,18($2)              # $4        = 0x43
795
    nop
796
    sb      $4,0($20)              # UART      = 0x43
797
    lb      $2,19($2)              # $2        = 0xffff.fffc
798
    nop
799
    sra     $3,$2,8                # $3        = 0xffff.ffff
800
    addi    $3,$3,0x45             # $3        = 0x44
801
    sb      $3,0($20)              # UART      = 0x44
802
    addi    $2,$2,0x49             # $4        = 0x45, overflow
803
    sb      $2,0($20)              # UART      = 0x45
804
    sb      $23,0($20)             # UART      = CR
805
    sb      $21,0($20)             # UART      = LF
806
 
807
    #b: LBU
808
    ori     $2,$0,'b'
809
    sb      $2,0($20)
810
    or      $2,$0,$24
811
    li      $3,0x41424344
812
    sw      $3,16($2)
813
    lb      $4,16($2)
814
    sb      $4,0($20)
815
    lb      $4,17($2)
816
    sb      $4,0($20)
817
    lb      $4,18($2)
818
    sb      $4,0($20)
819
    lb      $2,19($2)
820
    sb      $2,0($20)
821
    sb      $23,0($20)
822
    sb      $21,0($20)
823
 
824
    #c: LH
825
    ori     $2,$0,'c'
826
    sb      $2,0($20)
827
    or      $2,$0,$24
828
    li      $3,0x00410042
829
    sw      $3,16($2)
830
    lh      $4,16($2)
831
    sb      $4,0($20)
832
    lh      $2,18($2)
833
    sb      $2,0($20)
834
    sb      $23,0($20)
835
    sb      $21,0($20)
836
 
837
    #d: LHU
838
    ori     $2,$0,'d'
839
    sb      $2,0($20)
840
    or      $2,$0,$24
841
    li      $3,0x00410042
842
    sw      $3,16($2)
843
    lh      $4,16($2)
844
    sb      $4,0($20)
845
    lh      $2,18($2)
846
    sb      $2,0($20)
847
    sb      $23,0($20)
848
    sb      $21,0($20)
849
 
850
    #e: LW
851
    ori     $2,$0,'e'
852
    sb      $2,0($20)
853
    or      $2,$0,$24
854
    li      $3,'A'
855
    sw      $3,16($2)
856
    ori     $3,$0,0
857
    lw      $2,16($2)
858
    sb      $2,0($20)
859
    sb      $23,0($20)
860
    sb      $21,0($20)
861
 
862
    .ifgt TEST_UNALIGNED_LOADS
863
    #f: LWL & LWR
864
    ori     $2,$0,'f'
865
    sb      $2,0($20)
866
    or      $2,$0,$24
867
    li      $3,'A'
868
    sw      $3,16($2)
869
    ori     $3,$0,0
870
    lwl     $2,16($2)
871
    lwr     $2,16($2)
872
    sb      $2,0($20)
873
    sb      $23,0($20)
874
    sb      $21,0($20)
875
    .endif
876
 
877
    #g: SB
878
    ori     $2,$0,'g'
879
    sb      $2,0($20)
880
    ori     $2,$0,'A'
881
    sb      $2,0($20)
882
    sb      $23,0($20)
883
    sb      $21,0($20)
884
 
885
    #h: SH
886
    ori     $2,$0,'h'
887
    sb      $2,0($20)
888
    or      $4,$0,$24
889
    ori     $2,$0,0x4142
890
    sh      $2,16($4)
891
    lb      $3,16($4)
892
    sb      $3,0($20)
893
    lb      $2,17($4)
894
    sb      $2,0($20)
895
    sb      $23,0($20)
896
    sb      $21,0($20)
897
 
898
    #i: SW
899
    ori     $2,$0,'i'
900
    sb      $2,0($20)
901
    or      $2,$0,$24
902
    li      $3,0x41424344
903
    sw      $3,16($2)
904
    lb      $4,16($2)
905
    sb      $4,0($20)
906
    lb      $4,17($2)
907
    sb      $4,0($20)
908
    lb      $4,18($2)
909
    sb      $4,0($20)
910
    lb      $2,19($2)
911
    sb      $2,0($20)
912
    sb      $23,0($20)
913
    sb      $21,0($20)
914
 
915
    .ifgt  TEST_UNALIGNED_STORES
916
    #j: SWL & SWR
917
    ori     $2,$0,'j'
918
    sb      $2,0($20)
919
    or      $2,$0,$24
920
    li      $3,0x41424344
921
    swl     $3,16($2)
922
    swr     $3,16($2)
923
    lb      $4,16($2)
924
    sb      $4,0($20)
925
    lb      $4,17($2)
926
    sb      $4,0($20)
927
    lb      $4,18($2)
928
    sb      $4,0($20)
929
    lb      $2,19($2)
930
    sb      $2,0($20)
931
    sb      $23,0($20)
932
    sb      $21,0($20)
933
    .endif
934
 
935
    ######################################
936
    #Logical Instructions
937
    ######################################
938
LogicalTest:
939
    ori     $2,$0,'L'
940
    sb      $2,0($20)
941
    ori     $2,$0,'o'
942
    sb      $2,0($20)
943
    ori     $2,$0,'g'
944
    sb      $2,0($20)
945
    ori     $2,$0,'i'
946
    sb      $2,0($20)
947
    ori     $2,$0,'c'
948
    sb      $2,0($20)
949
    sb      $23,0($20)
950
    sb      $21,0($20)
951
 
952
    #a: AND
953
    ori     $2,$0,'a'
954
    sb      $2,0($20)
955
    ori     $2,$0,0x0741
956
    ori     $3,$0,0x60f3
957
    and     $4,$2,$3
958
    sb      $4,0($20)
959
    sb      $23,0($20)
960
    sb      $21,0($20)
961
 
962
    #b: ANDI
963
    ori     $2,$0,'b'
964
    sb      $2,0($20)
965
    ori     $2,$0,0x0741
966
    andi    $4,$2,0x60f3
967
    sb      $4,0($20)
968
    sb      $23,0($20)
969
    sb      $21,0($20)
970
 
971
    #c: LUI
972
    ori     $2,$0,'c'
973
    sb      $2,0($20)
974
    lui     $2,0x41
975
    srl     $3,$2,16
976
    sb      $3,0($20)
977
    sb      $23,0($20)
978
    sb      $21,0($20)
979
 
980
    #d: NOR
981
    ori     $2,$0,'d'
982
    sb      $2,0($20)
983
    li      $2,0xf0fff08e
984
    li      $3,0x0f0f0f30
985
    nor     $4,$2,$3
986
    sb      $4,0($20)
987
    sb      $23,0($20)
988
    sb      $21,0($20)
989
 
990
    #e: OR
991
    ori     $2,$0,'e'
992
    sb      $2,0($20)
993
    ori     $2,$0,0x40
994
    ori     $3,$0,0x01
995
    or      $4,$2,$3
996
    sb      $4,0($20)
997
    sb      $23,0($20)
998
    sb      $21,0($20)
999
 
1000
    #f: ORI
1001
    ori     $2,$0,'f'
1002
    sb      $2,0($20)
1003
    ori     $2,$0,0x40
1004
    ori     $4,$2,0x01
1005
    sb      $4,0($20)
1006
    sb      $23,0($20)
1007
    sb      $21,0($20)
1008
 
1009
    #g: XOR
1010
    ori     $2,$0,'g'
1011
    sb      $2,0($20)
1012
    ori     $2,$0,0xf043
1013
    ori     $3,$0,0xf002
1014
    xor     $4,$2,$3
1015
    sb      $4,0($20)
1016
    sb      $23,0($20)
1017
    sb      $21,0($20)
1018
 
1019
    #h: XORI
1020
    ori     $2,$0,'h'
1021
    sb      $2,0($20)
1022
    ori     $2,$0,0xf043
1023
    xor     $4,$2,0xf002
1024
    sb      $4,0($20)
1025
    sb      $23,0($20)
1026
    sb      $21,0($20)
1027
 
1028
 
1029
    ######################################
1030
    #Move Instructions
1031
    ######################################
1032
MoveTest:
1033
    ori     $2,$0,'M'
1034
    sb      $2,0($20)
1035
    ori     $2,$0,'o'
1036
    sb      $2,0($20)
1037
    ori     $2,$0,'v'
1038
    sb      $2,0($20)
1039
    ori     $2,$0,'e'
1040
    sb      $2,0($20)
1041
    sb      $23,0($20)
1042
    sb      $21,0($20)
1043
 
1044 25 ja_rd
    # HI and LO are only implemented if the mul/div block is
1045
    .ifgt (TEST_DIV + TEST_MUL)
1046 2 ja_rd
    #a: MFHI
1047
    ori     $2,$0,'a'
1048
    sb      $2,0($20)
1049
    ori     $2,$0,65
1050
    mthi    $2
1051
    mfhi    $3
1052
    sb      $3,0($20)
1053
    sb      $23,0($20)
1054
    sb      $21,0($20)
1055
 
1056
    #b: MFLO
1057
    ori     $2,$0,'b'
1058
    sb      $2,0($20)
1059
    ori     $2,$0,65
1060
    mtlo    $2
1061
    mflo    $3
1062
    sb      $3,0($20)
1063
    sb      $23,0($20)
1064
    sb      $21,0($20)
1065
 
1066
    #c: MTHI
1067
    ori     $2,$0,'c'
1068
    sb      $2,0($20)
1069
    ori     $2,$0,65
1070
    mthi    $2
1071
    mfhi    $3
1072
    sb      $3,0($20)
1073
    sb      $23,0($20)
1074
    sb      $21,0($20)
1075
 
1076
    #d: MTLO
1077
    ori     $2,$0,'d'
1078
    sb      $2,0($20)
1079
    ori     $2,$0,65
1080
    mtlo    $2
1081
    mflo    $3
1082
    sb      $3,0($20)
1083
    sb      $23,0($20)
1084
    sb      $21,0($20)
1085 25 ja_rd
    .endif
1086 2 ja_rd
 
1087
    ######################################
1088
    #Shift Instructions
1089
    ######################################
1090
ShiftTest:
1091
    ori     $2,$0,'S'
1092
    sb      $2,0($20)
1093
    ori     $2,$0,'h'
1094
    sb      $2,0($20)
1095
    ori     $2,$0,'i'
1096
    sb      $2,0($20)
1097
    ori     $2,$0,'f'
1098
    sb      $2,0($20)
1099
    ori     $2,$0,'t'
1100
    sb      $2,0($20)
1101
    sb      $23,0($20)
1102
    sb      $21,0($20)
1103
 
1104
    #a: SLL
1105
    ori     $2,$0,'a'
1106
    sb      $2,0($20)
1107
    li      $2,0x40414243
1108
    sll     $3,$2,8
1109
    srl     $3,$3,24
1110
    sb      $3,0($20)
1111
    sb      $23,0($20)
1112
    sb      $21,0($20)
1113
 
1114
    #b: SLLV
1115
    ori     $2,$0,'b'
1116
    sb      $2,0($20)
1117
    li      $2,0x40414243
1118
    ori     $3,$0,8
1119
    sllv    $3,$2,$3
1120
    srl     $3,$3,24
1121
    sb      $3,0($20)
1122
    sb      $23,0($20)
1123
    sb      $21,0($20)
1124
 
1125
    #c: SRA
1126
    ori     $2,$0,'c'
1127
    sb      $2,0($20)
1128
    li      $2,0x40414243
1129
    sra     $3,$2,16
1130
    sb      $3,0($20)
1131
    li      $2,0x84000000
1132
    sra     $3,$2,25
1133
    sub     $3,$3,0x80
1134
    sb      $3,0($20)
1135
    sb      $23,0($20)
1136
    sb      $21,0($20)
1137
 
1138
    #d: SRAV
1139
    ori     $2,$0,'d'
1140
    sb      $2,0($20)
1141
    li      $2,0x40414243
1142
    ori     $3,$0,16
1143
    srav    $3,$2,$3
1144
    sb      $3,0($20)
1145
    ori     $3,$0,25
1146
    li      $2,0x84000000
1147
    srav    $3,$2,$3
1148
    sub     $3,$3,0x80
1149
    sb      $3,0($20)
1150
    sb      $23,0($20)
1151
    sb      $21,0($20)
1152
 
1153
    #e: SRL
1154
    ori     $2,$0,'e'
1155
    sb      $2,0($20)
1156
    li      $2,0x40414243
1157
    srl     $3,$2,16
1158
    sb      $3,0($20)
1159
    li      $2,0x84000000
1160
    srl     $3,$2,25
1161
    sb      $3,0($20)
1162
    sb      $23,0($20)
1163
    sb      $21,0($20)
1164
 
1165
    #f: SRLV
1166
    ori     $2,$0,'f'
1167
    sb      $2,0($20)
1168
    li      $2,0x40414243
1169
    ori     $3,$0,16
1170
    srlv    $4,$2,$3
1171
    sb      $4,0($20)
1172
    ori     $3,$0,25
1173
    li      $2,0x84000000
1174
    srlv    $3,$2,$3
1175
    sb      $3,0($20)
1176
    sb      $23,0($20)
1177
    sb      $21,0($20)
1178
 
1179
 
1180
    ori     $2,$0,'D'
1181
    sb      $2,0($20)
1182
    ori     $2,$0,'o'
1183
    sb      $2,0($20)
1184
    ori     $2,$0,'n'
1185
    sb      $2,0($20)
1186
    ori     $2,$0,'e'
1187
    sb      $2,0($20)
1188
    sb      $23,0($20)
1189
    sb      $21,0($20)
1190
 
1191
 
1192
$DONE:
1193
    j       $DONE
1194
    nop
1195
 
1196
    .set    reorder
1197
    .end    entry
1198
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.