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

Subversion Repositories light52

[/] [light52/] [trunk/] [test/] [cpu_test/] [src/] [tb51_cpu.a51] - Blame information for rev 24

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 ja_rd
;-------------------------------------------------------------------------------
2
; tb51_cpu.a51 -- MCS51 instruction set test bench.
3
;-------------------------------------------------------------------------------
4
; This program is meant to verify the basic operation of an MCS51 CPU
5
; instruction set implementation.
6
; It is far too weak to rely on it exclusively but it can help detect gross
7
; implementation errors (overclocked CPUs, timing errors in FPGA cores, that
8
; kind of thing).
9
;
10
; The program is not yet ready to run on actual hardware (UART interface).
11
;
12
; For a full verification of the instruction set, an instruction set exerciser
13
; such as 'zexall' for the Z80 would be more suitable. This one is too weak.
14
;
15
; The program is meant to run in actual hardware or on a simulated environment.
16
; In the latter case you can use the co-simulation features of the light52
17
; project to pinpoint bugs.
18
;
19
; FIXME add assembly option to run tests in a (possibly infinite) loop.
20
;-------------------------------------------------------------------------------
21
; Major limitations:
22
;   1.- PSW is not checked for undue changes.
23
;   2.- <#imm> instructions are tested with one imm value only.
24
;   3.-  jumps tested with small values (not near corner values).
25
;   4.-  tested on 1 byte only, on 2 bits only.
26
;
27
; Note there are too many limitations to list. Use this test bench as a first
28
; approximation only. If your CPU fails this test, it must be dead!
29
;-------------------------------------------------------------------------------
30
 
31
        ; Include the definitions for the light52 derivative
32
        $nomod51
33
        $include (light52.mcu)
34
 
35
        ;-- Parameters common to all tests -------------------------------------
36
 
37
dir0    set     060h                ; Address used in direct addressing tests
38
dir1    set     061h                ; Address used in direct addressing tests
39
fail    set     06eh                ; (IDATA) set to 1 upon test failure
40
saved_psw set   070h                ; (IDATA) temp store for PSW value
41
stack0  set     09fh                ; (IDATA) stack addr used for push/pop tests
42
 
43
 
44
        ;-- Macros common to all tests -----------------------------------------
45
 
46
        ; putc: send character to console (UART)
47
        ; If you change this macro, make sure it DOES NOT MODIFY PSW!
48
putc    macro   character
49
        local   putc_loop
50
putc_loop:
51
        ;jnb     SCON.1,putc_loop
52
        ;clr     SCON.1
53
        mov     SBUF,character
54
        endm
55
 
56
        ; put_crlf: send CR+LF to console
57
put_crlf macro
58
        putc    #13
59
        putc    #10
60
        endm
61
 
62
        ;eot char, label: 'end of test' to be used at the end of all tests.
63
        ; If you run into this macro it will print character 'char' and
64
        ; continue.
65
        ; If you jump to label 'label', it will instead print char '?' and
66
        ; will set variable 'fail' to 1, then it will continue.
67
eot     macro   char,label
68
        local   skip
69
        putc    #char
70
        sjmp    skip
71
label:  putc    #'?'
72
        mov     fail,#001h
73
skip:
74
        endm
75
 
76
        ;-- Reset & interrupt vectors ------------------------------------------
77
 
78
        org     00h
79
        ljmp    start               ; We'll assume LJMP works this far...
80
        org     03h
81
        org     0bh
82
        org     13h
83
        org     1bh
84
        org     23h
85
 
86
 
87
        ;-- Main test program --------------------------------------------------
88
        org     30h
89
start:
90
        ; Initialize serial port
91
        ;(leave it with the default configuration: 19200-8-N-1)
92
        ;mov     TMOD,#20h           ; C/T = 0, Mode = 2
93
        ;mov     TH1,#0fdh           ; 9600 bauds @11.xxx MHz
94
        ;mov     TCON,#40h           ; Enable T1
95
        ;mov     SCON,#52h           ; 8/N/1, TI enabled
96
 
97
        ; Clear failure flag
98
        mov     fail,#000h
99
 
100
        ;-- Test series A ------------------------------------------------------
101
        ; Test the basic opcodes needed in later tests:
102
        ; a.- Serial port initialization is OK
103
        ; a.- Bootstrap instructions work as used
104
        ; b.-  (small positive rel only)
105
        ; c.- ACC can be loaded with direct mode addressing (as an SFR)
106
        ; c.- 
107
        ; d.-  (small positive rel only)
108
        ; e.- 
109
        ; Note that one instance of LJMP has been tested too.
110
 
111
        putc    #'A'                ; start of test series
112
 
113
        ; If we arrive here at all, and you see the chars in the
114
        ; terminal, the A.a test has passed
115
        putc    #'a'
116
 
117
        sjmp    ta_b0               ;  with very small positive rel
118
        putc    #'?'
119
        mov     fail,#001h
120
ta_b0:  putc    #'b'
121
 
122
 
123
ta_c0:  sjmp    ta_c1
124
ta_c3:  putc    #'c'
125
        sjmp    ta_c4
126
ta_c1:  mov     0e0h,#5ah           ; load A as SFR
127
        cjne    a,#5ah,ta_c3        ; test cjne with == args...
128
        cjne    a,#7ah,ta_c2        ; ...with != args, rel>0...
129
        putc    #'?'
130
        mov     fail,#001h
131
ta_c2:  cjne    a,#7ah,ta_c3        ; ...and with != args, rel<0
132
        putc    #'?'
133
        mov     fail,#001h
134
ta_c4:
135
 
136
        mov     dir0,#02h
137
        djnz    dir0,ta_d1
138
        putc    #'?'
139
        mov     fail,#001h
140
ta_d1:  djnz    dir0,ta_d2
141
 
142
        eot     'd',ta_d2
143
 
144
        mov     dir0,#0a5h          ; test mov a,dir
145
        mov     a,dir0
146
        cjne    a,#0a5h,ta_e1
147
 
148
        eot     'e',ta_e1
149
 
150
        put_crlf                    ; end of test series
151
 
152
        ;-- Test series B ------------------------------------------------------
153
        ; Test CJNE plus a few aux opcodes
154
        ; a.- 
155
        ; a.- 
156
        ; b.- , 
157
        ; c.- 
158
        ; d.- , , 
159
        ; e.- 
160
        ; f.- 
161
        ; g.- 
162 15 ja_rd
        ; h.-  with SFR direct address
163 3 ja_rd
 
164
        putc    #'B'                ; start of test series
165
 
166
tb_ma   macro   reg,val
167
        mov     reg,val
168
        mov     a,reg
169
        cjne    a,val,tb_a1
170
        endm
171
 
172
        tb_ma   r0,#081h
173
        tb_ma   r1,#043h
174
        tb_ma   r2,#027h
175
        tb_ma   r3,#0c2h
176
        tb_ma   r4,#0f1h
177
        tb_ma   r5,#004h
178
        tb_ma   r6,#092h
179
        tb_ma   r7,#01fh
180
 
181
        eot     'a',tb_a1
182
 
183
        mov     PSW,#80h            ; , 
184
        jc      tb_b0
185
        putc    #'?'
186
        mov     fail,#001h
187
tb_b0:  jnc     tb_b1
188
        mov     PSW,#00h
189
        jc      tb_b1
190
        jnc     tb_b2
191
tb_b1:  putc    #'?'
192
        mov     fail,#001h
193
tb_b2:  putc    #'b'
194
 
195
tb_mc   macro   reg,val
196
        local   tb_mc0
197
        local   tb_mc1
198
        mov     reg,val+1
199
        cjne    reg,val,tb_mc0
200
        putc    #'?'
201
        mov     fail,#001h
202
tb_mc1: mov     reg,val
203
tb_mc0: cjne    reg,val,tb_mc1
204
        endm
205
 
206
        tb_mc   r0,#091h            ; first test the jumps for all Rn regs
207
        tb_mc   r1,#0a2h
208
        tb_mc   r2,#0b3h
209
        tb_mc   r3,#0c4h
210
        tb_mc   r4,#0d5h
211
        tb_mc   r5,#0e6h
212
        tb_mc   r6,#0f7h
213
        tb_mc   r7,#008h
214
 
215
tb_c0:  mov     PSW,#00h            ; now test the C flag with a single Rn reg
216
        mov     r0,#034h
217
        cjne    r0,#035h,tb_c1
218
tb_c1:  jnc     tb_c2
219
        cjne    r0,#034h,tb_c3
220
tb_c3:  jc      tb_c2
221
        cjne    r0,#033h,tb_c4
222
tb_c4:  jc      tb_c2
223
 
224
        eot     'c',tb_c2
225
 
226
        mov     PSW,#80h            ; test C set, reset and complement
227
        clr     c
228
        jc      tb_d0
229
        setb    c
230
        jnc     tb_d0
231
        cpl     c
232
        jc      tb_d0
233
 
234
        eot     'd',tb_d0
235
 
236
tb_me   macro   reg
237
        mov     reg,#dir0
238
        mov     dir0,#12h
239
        mov     a,dir0
240
        cjne    a,#012h,tb_e0
241
        mov     @reg,#0f5h
242
        mov     a,dir0
243
        cjne    a,#0f5h,tb_e0
244
        endm
245
 
246
        tb_me   r0                  ; test  with both regs
247
        tb_me   r1
248
 
249
        eot     'e',tb_e0
250
 
251
tb_mf   macro   reg,val
252
        local   tb_mf0
253
        local   tb_mf1
254
        mov     reg,#30h
255
        mov     @reg,val+1
256
        cjne    @reg,val,tb_mf0
257
        putc    #'?'
258
        mov     fail,#001h
259
tb_mf1: mov     @reg,val
260
tb_mf0: cjne    @reg,val,tb_mf1
261
        endm
262
 
263
        tb_mf   r0,#12h
264
        tb_mf   r1,#34h
265
 
266
tb_f0:  mov     r0,#30h             ; now test the C flag with a single Rn reg
267
        clr     c
268
        mov     @r0,#034h
269
        cjne    @r0,#035h,tb_f1
270
tb_f1:  jnc     tb_f2
271
        cjne    @r0,#034h,tb_f3
272
tb_f3:  jc      tb_f2
273
        cjne    @r0,#033h,tb_f4
274
tb_f4:  jc      tb_f2
275
 
276
        eot     'f',tb_f2
277
 
278 15 ja_rd
        mov     dir0,#0c0h          ; CJNE A,dir,rel targetting an IRAM location
279 3 ja_rd
        mov     031h,#0c1h
280
        mov     032h,#0c2h
281
        clr     c
282
        mov     a,#0c1h
283
        cjne    a,031h,tb_g0
284
        jc      tb_g0
285
        cjne    a,032h,tb_g1
286
        putc    #'?'
287
        mov     fail,#001h
288
tb_g1:  jnc     tb_g0
289
        cjne    a,dir0,tb_g2
290
        putc    #'$'
291
        mov     fail,#001h
292
tb_g2:  jc      tb_g0
293
 
294
        eot     'g',tb_g0
295
 
296 15 ja_rd
        mov     dir0,#0c0h          ; CJNE A,dir,rel targetting an SFR location
297
        mov     B,#0c1h
298
        mov     032h,#0c2h
299
        clr     c
300
        mov     a,#0c1h
301
        mov     r0,#42h
302
        cjne    a,B,tb_h0
303
        jc      tb_h0
304
        cjne    a,032h,tb_h1
305
        putc    #'?'
306
        mov     fail,#001h
307
tb_h1:  jnc     tb_h0
308
        cjne    a,dir0,tb_h2
309
        putc    #'$'
310
        mov     fail,#001h
311
tb_h2:  jc      tb_h0
312
 
313
        eot     'h',tb_h0
314
 
315 3 ja_rd
        put_crlf                    ; end of test series
316
 
317
 
318
        ;-- Test series C ------------------------------------------------------
319
        ; Bit operations and the rest of the conditional rel jumps
320
        ; The following tests will use a bit address within the IRAM
321
        ; a.- , 
322
        ; b.- 
323
        ; c.- , 
324
        ; d.- , 
325
        ; e.- , 
326
        ; e.- , 
327
        ; f.- , 
328
        ; g.- 
329
        ; h.- 
330
        ; The following tests are the same as above except a bit address within
331
        ; SFR B is used.
332
        ; i.- , 
333
        ; j.- , 
334
        ; k.- , 
335
        ; k.- , 
336
        ; l.- , 
337
        ; m.- 
338
        ; n.- 
339
 
340
        putc    #'C'                ; start of test series
341
 
342
        mov     02fh,#80h           ; We'll be testing bits 2F.7 and 2F.6
343
        sjmp    tc_a0
344
tc_a1:  jnb     07fh,tc_a3          ; JNB jumps not on bit set
345
        jnb     07eh,tc_a2          ; JNB jumps on bit clear
346
        putc    #'?'
347
        mov     fail,#001h
348
        sjmp    tc_a3
349
tc_a0:  jb      07fh,tc_a1          ; JB jumps on bit set
350
        putc    #'!'
351
        mov     fail,#001h
352
tc_a2:  jb      07eh,tc_a3          ; JB jumps not on bit clear
353
 
354
        eot     'a',tc_a3
355
 
356
        mov     0e0h,#079h          ; init acc (as sfr) with some data
357
        cjne    a,#079h,tc_b1
358
        mov     a,#05ah             ; now load a with imm data...
359
        cjne    a,#05ah,tc_b1       ; ...and make sure a got the data
360
 
361
        eot     'b',tc_b1
362
 
363
        mov     a,#80h
364
        sjmp    tc_c0
365
tc_c1:  jz      tc_c3               ; JZ jumps not on acc!=0
366
        mov     a,#00h
367
        jz      tc_c2               ; JZ jumps on acc==0
368
        putc    #'?'
369
        mov     fail,#001h
370
        sjmp    tc_c3
371
tc_c0:  jnz     tc_c1               ; JNZ jumps on acc!=0
372
        putc    #'!'
373
        mov     fail,#001h
374
tc_c2:  jnz     tc_c3               ; JNZ jumps not on acc==0
375
 
376
        eot     'c',tc_c3
377
 
378
 
379
        mov     02fh,#80h           ; We'll be testing bit 2F.7
380
        jb      07fh,tc_d1
381
        sjmp    tc_d0
382
tc_d1:  clr     07fh
383
        jb      07fh,tc_d0
384
        cpl     07fh
385
        jnb     07fh,tc_d0
386
 
387
        eot     'd',tc_d0
388
 
389
        mov     02eh,#08h           ; We'll be testing bits 2E.3 and 2E.2
390
        clr     c
391
        anl     c,073h              ; Test ANL in all 4 input combinations
392
        jc      tc_e0
393
        setb    c
394
        anl     c,073h
395
        jnc     tc_e0
396
        anl     c,/072h
397
        jnc     tc_e0
398
                                    ; CY == 1
399
        orl     c,073h              ; ORL-ing with 1 should give 1
400
        jnc     tc_e0
401
        orl     c,072h
402
        jnc     tc_e0
403
        clr     c                   ; CY == 0
404
        orl     c,073h              ; Now ORL c, 'bit' should give 'bit'
405
        jnc     tc_e0
406
        orl     c,/072h
407
        jnc     tc_e0
408
 
409
        eot     'e',tc_e0
410
 
411
        mov     02eh,#08h           ; We'll be testing bits 2E.3 and 2E.2
412
        clr     c
413
        mov     c,073h
414
        jnc     tc_f0
415
        mov     c,072h
416
        jc      tc_f0
417
        clr     c
418
        mov     071h,c
419
        jb      071h,tc_f0
420
        setb    c
421
        mov     071h,c
422
        jnb     071h,tc_f0
423
 
424
        eot     'f',tc_f0
425
 
426
        mov     02eh,#00h           ; We'll be testing bits 2E.3 and 2E.2
427
        setb    073h
428
        mov     c,073h
429
        jnc     tc_g0
430
        setb    072h
431
        mov     c,072h
432
        jnc     tc_g0
433
 
434
        eot     'g',tc_g0
435
 
436
        ; (better read the following code in execution order)
437
        mov     02eh,#08h           ; We'll be testing bits 2E.3 and 2E.2
438
        sjmp    tc_h1               ; jump forward so we can test jump backwards
439
tc_h2:  mov     c,073h              ; make sure the target bit is clear
440
        jc      tc_h0
441
        jbc     072h,tc_h0          ; JBC jumps not when target bit clear
442
        sjmp    tc_h3
443
tc_h1:  jbc     073h,tc_h2          ; JBC jumps when target bit set
444
        sjmp    tc_h0
445
tc_h3:
446
 
447
        eot     'h',tc_h0
448
 
449
        mov     02fh,#00h
450
        mov     B,#80h              ; We'll be testing bits B.7 and B.6
451
        sjmp    tc_i0
452
tc_i1:  jnb     B.7,tc_i3           ; JNB jumps not on bit set
453
        jnb     B.6,tc_i2           ; JNB jumps on bit clear
454
        putc    #'?'
455
        mov     fail,#001h
456
        sjmp    tc_i3
457
tc_i0:  jb      B.7,tc_i1           ; JB jumps on bit set
458
        putc    #'!'
459
        mov     fail,#001h
460
tc_i2:  jb      B.6,tc_i3           ; JB jumps not on bit clear
461
 
462
        eot     'i',tc_i3
463
 
464
        mov     B,#80h              ; We'll be testing bit B.7
465
        jb      B.7,tc_j1
466
        sjmp    tc_j0
467
tc_j1:  clr     B.7
468
        jb      B.7,tc_j0
469
        cpl     B.7
470
        jnb     B.7,tc_j0
471
 
472
        eot     'j',tc_j0
473
 
474
        mov     B,#08h              ; We'll be testing bits B.3 and B.2
475
        clr     c
476
        anl     c,B.3               ; Test ANL in all 4 input combinations
477
        jc      tc_k0
478
        setb    c
479
        anl     c,B.3
480
        jnc     tc_k0
481
        anl     c,/B.2
482
        jnc     tc_k0
483
                                    ; CY == 1
484
        orl     c,B.3               ; ORL-ing with 1 should give 1
485
        jnc     tc_k0
486
        orl     c,B.2
487
        jnc     tc_k0
488
        clr     c                   ; CY == 0
489
        orl     c,B.3               ; Now ORL c, 'bit' should give 'bit'
490
        jnc     tc_k0
491
        orl     c,/B.2
492
        jnc     tc_k0
493
 
494
        eot     'k',tc_k0
495
 
496
        mov     B,#08h              ; We'll be testing bits B.3, B.2 and B.1
497
        clr     c
498
        mov     c,B.3
499
        jnc     tc_L0
500
        mov     c,B.2
501
        jc      tc_L0
502
        clr     c
503
        mov     B.1,c
504
        jb      B.1,tc_L0
505
        setb    c
506
        mov     B.1,c
507
        jnb     B.1,tc_L0
508
 
509
        eot     'l',tc_L0
510
 
511
        mov     02eh,#00h           ; We'll be testing bits B.3 and B.2
512
        setb    B.3
513
        mov     c,B.3
514
        jnc     tc_m0
515
        setb    B.2
516
        mov     c,B.2
517
        jnc     tc_m0
518
 
519
        eot     'm',tc_m0
520
 
521
        ; (better read the following code in execution order)
522
        mov     B,#08h              ; We'll be testing bits B.3 and B.2
523
        sjmp    tc_n1               ; jump forward so we can test jump backwards
524
tc_n2:  mov     c,B.3               ; make sure the target bit is clear
525
        jc      tc_n0
526
        jbc     B.2,tc_n0           ; JBC jumps not when target bit clear
527
        sjmp    tc_n3
528
tc_n1:  jbc     B.3,tc_n2           ; JBC jumps when target bit set
529
        sjmp    tc_n0
530
tc_n3:
531
 
532
        eot     'n',tc_n0
533
 
534 24 ja_rd
        ; (better read the following code in execution order)
535
        mov     ACC,#08h              ; We'll be testing bits ACC.3 and ACC.2
536
        sjmp    tc_o1               ; jump forward so we can test jump backwards
537
tc_o2:  mov     c,ACC.3               ; make sure the target bit is clear
538
        jc      tc_o0
539
        jbc     ACC.2,tc_o0           ; JBC jumps not when target bit clear
540
        sjmp    tc_o3
541
tc_o1:  jbc     ACC.3,tc_o2           ; JBC jumps when target bit set
542
        sjmp    tc_o0
543
tc_o3:
544 3 ja_rd
 
545 24 ja_rd
        eot     'o',tc_o0
546 3 ja_rd
 
547 24 ja_rd
        mov     02eh,#00h           ; We'll be testing bits ACC.3 and ACC.2
548
        setb    ACC.3
549
        mov     c,ACC.3
550
        jnc     tc_p0
551
        setb    ACC.2
552
        mov     c,ACC.2
553
        jnc     tc_p0
554
 
555
        eot     'p',tc_p0
556
 
557
        mov     ACC,#80h           ; We'll be testing bit ACC.7
558
        jb      ACC.7,tc_q1
559
        sjmp    tc_q0
560
tc_q1:  clr     ACC.7
561
        jb      ACC.7,tc_q0
562
        cpl     ACC.7
563
        jnb     ACC.7,tc_q0
564
 
565
        eot     'q',tc_q0
566
 
567
 
568 3 ja_rd
        put_crlf                    ; end of test series
569
 
570
        ;-- Test series D ------------------------------------------------------
571
        ;
572
        ; a.- 
573
        ; b.- 
574
        ; c.- 
575
        ; d.- , 
576
        ;
577
        ; This test executes a few NOPs too but does NOT check for unintended
578
        ; side effects; we intersperse the nops between the other tests to at
579
        ; least have a chance to catch buggy behavior but that's all.
580
 
581
 
582
        putc    #'D'                ; start of test series
583
 
584
        mov     a,#085h             ; test XRL A,#imm before using it in
585
        xrl     a,#044h             ; subsequent tests
586
        jz      td_a0
587
        xrl     a,#0c1h
588
        jnz     td_a0
589
 
590
        eot     'a',td_a0
591
 
592
        mov     a,#085h             ; Test RLC effects on ACC, ignore CY for now
593
        nop
594
        clr     c
595
        rlc     a                   ; a = (a << 1) | 0
596
        mov     dir0,a
597
        xrl     a,#00ah             ; We can't use CJNE because it modifies CY
598
        jnz     td_b0               ; check shifted acc
599
        mov     a,dir0
600
        rlc     a                   ; rotate again...
601
        xrl     a,#015h             ; ...and check shifted acc with CY at bit 0
602
        jnz     td_b0
603
 
604
        mov     a,#085h             ; Now check RLC effects on CY
605
        nop
606
        clr     c
607
        rlc     a
608
        jnc     td_b0
609
        rlc     a
610
        jc      td_b0               ; CY==1 moved into ACC.0
611
 
612
        eot     'b',td_b0
613
 
614
        mov     a,#085h             ; Test RRC effects on ACC, ignore CY for now
615
        clr     c
616
        rrc     a                   ; will set CY
617
        mov     dir0,a
618
        nop
619
        xrl     a,#042h             ; We can't use CJNE because it modifies CY
620
        jnz     td_c0               ; check shifted acc
621
        mov     a,dir0
622
        rrc     a                   ; rotate again...
623
        xrl     a,#0a1h             ; ...and check shifted acc with CY at bit 7
624
        jnz     td_c0
625
 
626
        mov     a,#085h             ; Now check RRC effects on CY
627
        clr     c
628
        rrc     a
629
        jnc     td_c0
630
        rrc     a
631
        jc      td_c0               ; CY==1 moved into ACC.0
632
 
633
        eot     'c',td_c0
634
 
635
        mov     a,#085h             ; Test RL effects on ACC, ignore CY for now
636
        clr     c
637
        rl      a                   ; a = (a << 1) | 0
638
        mov     dir0,a
639
        xrl     a,#00bh             ; We can't use CJNE because it modifies CY
640
        jnz     td_d0               ; check shifted acc
641
        mov     a,dir0
642
        setb    c
643
        rl      a                   ; rotate again...
644
        xrl     a,#016h             ; ...and check shifted acc with CY at bit 0
645
        jnz     td_d0
646
 
647
        mov     a,#085h             ; Test RR effects on ACC, ignore CY for now
648
        clr     c
649
        rr      a                   ; will set CY
650
        mov     dir0,a
651
        xrl     a,#0c2h             ; We can't use CJNE because it modifies CY
652
        jnz     td_d0               ; check shifted acc
653
        mov     a,dir0
654
        rr      a                   ; rotate again...
655
        xrl     a,#061h             ; ...and check shifted acc with CY at bit 7
656
        jnz     td_d0
657
 
658
        mov     a,#0ffh             ; Now make sure RL and RR don't touch CY
659
        clr     c
660
        rl      a
661
        jc      td_d0
662
        rr      a
663
        rr      a
664
        jc      td_d0
665
 
666
        eot     'd',td_d0
667
 
668
        put_crlf                    ; end of test series
669
 
670
        ;-- Test series E ------------------------------------------------------
671
        ; Increment
672
        ; a.- 
673
        ; b.- 
674
        ; c.- 
675
        ; d.- 
676
        ; e.- 
677
        ; f.- 
678
        ; g.- 
679
        ; h.- 
680
        ; i.- 
681
 
682
        putc    #'E'                ; start of test series
683
 
684
te_ma   macro   target, error_loc
685
        mov     target,#080h
686
        inc     target
687
        cjne    target,#081h,error_loc
688
        mov     target,#0ffh
689
        clr     c
690
        inc     target
691
        jc      error_loc
692
        cjne    target,#000h,error_loc
693
        endm
694
 
695
        te_ma   a,te_a0             ; Test 
696
 
697
        eot     'a',te_a0
698
 
699
        mov     r0,#066h
700
 
701
        te_ma   r0,te_b0
702
        te_ma   r1,te_b0
703
        te_ma   r2,te_b0
704
        te_ma   r3,te_b0
705
        te_ma   r4,te_b0
706
        te_ma   r5,te_b0
707
        te_ma   r6,te_b0
708
        te_ma   r7,te_b0
709
 
710
        eot     'b',te_b0
711
 
712
        mov     r0,#dir0
713
        mov     r1,#031h
714
 
715
        te_ma   @r0,te_c0
716
        te_ma   @r1,te_c0
717
 
718
        eot     'c',te_c0
719
 
720
        mov     dir0,#034h          ; Test  before using it in
721
        mov     a,dir0              ; subsequent tests
722
        cjne    a,#034h,te_d0
723
 
724
        eot     'd',te_d0
725
 
726 15 ja_rd
        mov     039h,#080h          ; Test  with IRAM address...
727 3 ja_rd
        inc     039h
728
        mov     a,039h
729
        cjne    a,#081h,te_e0
730
        mov     039h,#0ffh
731
        clr     c
732
        inc     039h
733
        jc      te_e0
734
        mov     a,039h
735
        cjne    a,#000h,te_e0
736
 
737 15 ja_rd
        mov     B,#080h             ; ...and  with SFR address
738
        inc     B
739
        mov     a,B
740
        cjne    a,#081h,te_e0
741
        mov     B,#0ffh
742
        clr     c
743
        inc     B
744
        jc      te_e0
745
        mov     a,B
746
        cjne    a,#000h,te_e0
747
 
748
 
749 3 ja_rd
        eot     'e',te_e0
750
 
751
te_mf   macro   target, error_loc
752
        mov     target,#001h
753
        dec     target
754
        cjne    target,#000h,error_loc
755
        clr     c
756
        dec     target
757
        jc      error_loc
758
        cjne    target,#0ffh,error_loc
759
        endm
760
 
761
        te_mf   a,te_f0             ; Test 
762
 
763
        eot     'f',te_f0
764
 
765
        mov     r0,#066h
766
 
767
        te_mf   r0,te_g0
768
        te_mf   r1,te_g0
769
        te_mf   r2,te_g0
770
        te_mf   r3,te_g0
771
        te_mf   r4,te_g0
772
        te_mf   r5,te_g0
773
        te_mf   r6,te_g0
774
        te_mf   r7,te_g0
775
 
776
        eot     'g',te_g0
777
 
778
        mov     r0,#dir0
779
        mov     r1,#031h
780
 
781
        te_mf   @r0,te_h0
782
        te_mf   @r1,te_h0
783
 
784
        eot     'h',te_h0
785
 
786 15 ja_rd
        mov     039h,#001h          ; Test  with IRAM address...
787 3 ja_rd
        dec     039h
788
        mov     a,039h
789
        cjne    a,#00h,te_i0
790
        mov     039h,#000h
791
        clr     c
792
        dec     039h
793
        jc      te_i0
794
        mov     a,039h
795
        cjne    a,#0ffh,te_i0
796
 
797 15 ja_rd
        mov     B,#001h             ; ...and  with SFR address
798
        dec     B
799
        mov     a,B
800
        cjne    a,#00h,te_i0
801
        mov     B,#000h
802
        clr     c
803
        dec     B
804
        jc      te_i0
805
        mov     a,B
806
        cjne    a,#0ffh,te_i0
807
 
808 3 ja_rd
        eot     'i',te_i0
809
 
810
        put_crlf                    ; end of test series
811
 
812
 
813
        ;-- Test series F ------------------------------------------------------
814
        ;
815
        ; a.- 
816
        ; b.- 
817
        ; c.- 
818
        ; d.- 
819
        ; e.- 
820
        ; f.- 
821
        ; g.- 
822
        ; h.- 
823
 
824
 
825
        putc    #'F'                ; start of test series
826
 
827
tf_ma   macro   rn, n, error_loc
828
        mov     rn,#(091h+n)
829
        mov     039h,rn
830
        mov     a,039h
831
        cjne    a,#(091h+n),error_loc
832
        endm
833
 
834
        tf_ma   r0,0,tf_a0
835
        tf_ma   r1,1,tf_a0
836
        tf_ma   r2,2,tf_a0
837
        tf_ma   r3,3,tf_a0
838
        tf_ma   r4,4,tf_a0
839
        tf_ma   r5,5,tf_a0
840
        tf_ma   r6,6,tf_a0
841
        tf_ma   r7,7,tf_a0
842
 
843
        eot     'a',tf_a0
844
 
845
        tf_ma   @r0,0,tf_b0
846
        tf_ma   @r1,1,tf_b0
847
 
848
        eot     'b',tf_b0
849
 
850 15 ja_rd
        mov     031h,#091h          ; IRAM to IRAM...
851 3 ja_rd
        mov     039h,031h
852
        mov     a,039h
853
        cjne    a,#091h,tf_c0
854
 
855 15 ja_rd
        mov     031h,#091h          ; ...IRAM to SFR...
856
        mov     B,031h
857
        mov     a,B
858
        cjne    a,#091h,tf_c0
859
 
860
        mov     B,#091h          ; ...and SFR to IRAM
861
        mov     031h,B
862
        mov     a,031h
863
        cjne    a,#091h,tf_c0
864
 
865
 
866 3 ja_rd
        eot     'c',tf_c0
867
 
868
tf_md   macro   rn, n, error_loc
869
        mov     039h,#(091h+n)
870
        mov     rn,039h
871
        cjne    rn,#(091h+n),error_loc
872
        endm
873
 
874
        tf_md   r0,0,tf_d0
875
        tf_md   r1,1,tf_d0
876
        tf_md   r2,2,tf_d0
877
        tf_md   r3,3,tf_d0
878
        tf_md   r4,4,tf_d0
879
        tf_md   r5,5,tf_d0
880
        tf_md   r6,6,tf_d0
881
        tf_md   r7,7,tf_d0
882
 
883
        eot     'd',tf_d0
884
 
885
        mov     r0,#dir0
886
        mov     r1,#031h
887
        tf_md   @r0,0,tf_e0
888
        tf_md   @r1,1,tf_e0
889
 
890
        eot     'e',tf_e0
891
 
892
tf_mf   macro   rn, n, error_loc
893
        mov     a,#(091h+n)
894
        mov     rn,a
895
        cjne    rn,#(091h+n),error_loc
896
        endm
897
 
898
        tf_mf   r0,0,tf_f0
899
        tf_mf   r1,1,tf_f0
900
        tf_mf   r2,2,tf_f0
901
        tf_mf   r3,3,tf_f0
902
        tf_mf   r4,4,tf_f0
903
        tf_mf   r5,5,tf_f0
904
        tf_mf   r6,6,tf_f0
905
        tf_mf   r7,7,tf_f0
906
 
907
        eot     'f',tf_f0
908
 
909
        mov     r0,#dir0
910
        mov     r1,#031h
911
        tf_mf   @r0,0,tf_g0
912
        tf_mf   @r1,1,tf_g0
913
 
914
        eot     'g',tf_g0
915
 
916
        mov     dir0,#079h
917
        mov     r0,#000h
918
        mov     a,#34h
919
        mov     dir0,a
920
        mov     r0,dir0
921
        cjne    r0,#034h,tf_h0
922
 
923
        eot     'h',tf_h0
924
 
925
        mov     a,#000h
926
 
927
        mov     r1,#031h
928
        mov     031h,#056h
929
        mov     r0,#dir0
930
        mov     dir0,#034h
931
        mov     a,@r0
932
        cjne    a,#034h,tf_i0
933
        mov     a,@r1
934
        cjne    a,#056h,tf_i0
935
 
936
        eot     'i',tf_i0
937
 
938
        put_crlf                    ; end of test series
939
 
940
 
941
        ;-- Test series G ------------------------------------------------------
942
        ; Note the XCG tests are specially lame even within this context.
943
        ; a.- , , 
944
        ; b.- 
945
        ; c.- 
946
        ; d.- 
947
        ; e.- 
948
 
949
        putc    #'G'                ; start of test series
950
 
951
        mov     a,#055h
952
        clr     a
953
        jnz     tg_a0
954
 
955
        mov     a,#055h
956
        cpl     a
957
        cjne    a,#0aah,tg_a0
958
 
959
        mov     a,#097h
960
        swap    a
961
        cjne    a,#079h,tg_a0
962
 
963
        eot     'a',tg_a0
964
 
965
        mov     DPH,#012h
966
        mov     DPL,#0fdh
967
        inc     dptr
968
        mov     a,DPH
969
        cjne    a,#012h,tg_b0
970
        mov     a,DPL
971
        cjne    a,#0feh,tg_b0
972
        inc     dptr
973
        mov     a,DPH
974
        cjne    a,#012h,tg_b0
975
        mov     a,DPL
976
        cjne    a,#0ffh,tg_b0
977
        inc     dptr
978
        mov     a,DPH
979
        cjne    a,#013h,tg_b0
980
        mov     a,DPL
981
        cjne    a,#000h,tg_b0
982
 
983
        eot     'b',tg_b0
984
 
985
        ; c.- 
986 15 ja_rd
        mov     a,#34h              ; IRAM address...
987 3 ja_rd
        mov     13h,#57h
988
        xch     a,13h
989
        cjne    a,#57h,tg_c0
990
        mov     a,13h
991
        cjne    a,#34h,tg_c0
992
 
993 15 ja_rd
        mov     a,#34h              ; ...and SFR address
994
        mov     B,#57h
995
        xch     a,B
996
        cjne    a,#57h,tg_c0
997
        mov     a,B
998
        cjne    a,#34h,tg_c0
999
 
1000 3 ja_rd
        eot     'c',tg_c0
1001
 
1002
        ; d.- 
1003
        mov     a,#91h
1004
        mov     29h,#78h
1005
        mov     r0,#29h
1006
        xch     a,@r0
1007
        cjne    a,#78h,tg_d0
1008
        mov     a,29h
1009
        cjne    a,#91h,tg_d0
1010
 
1011
        mov     a,#92h
1012
        mov     2ah,#78h
1013
        mov     r1,#2ah
1014
        xch     a,@r1
1015
        cjne    a,#78h,tg_d0
1016
        mov     a,2ah
1017
        cjne    a,#92h,tg_d0
1018
 
1019
        eot     'd',tg_d0
1020
 
1021
        ; e.- 
1022
 
1023
tg_ma   macro   rn, n, error_loc
1024
        mov     a,#(0c1h+n)
1025
        mov     rn,#(042h+n)
1026
        xch     a,rn
1027
        cjne    rn,#(0c1h+n),error_loc
1028
        cjne    a,#(042h+n),error_loc
1029
        endm
1030
 
1031
        tg_ma   r0, 19, tg_e0
1032
        tg_ma   r1, 18, tg_e0
1033
        tg_ma   r2, 17, tg_e0
1034
        tg_ma   r3, 16, tg_e0
1035
        tg_ma   r4, 15, tg_e0
1036
        tg_ma   r5, 14, tg_e0
1037
        tg_ma   r6, 13, tg_e0
1038
        tg_ma   r7, 12, tg_e0
1039
 
1040
        eot     'e',tg_e0
1041
 
1042
 
1043
        put_crlf                    ; end of test series
1044
 
1045
 
1046
        ;-- ALU opcode block test ----------------------------------------------
1047
        ; This set of macros is used to test families of opcodes, such as ORL,
1048
        ; ANL, ADD, etc. with all their addressing modes.
1049
        ;
1050
        ; a.- , ,  (n=0,1)
1051
        ; b.-  (n=2,3)
1052
        ; c.-  (n=4,5)
1053
        ; d.-  (n=6,7)
1054
        ; e.- 
1055
        ; f.- 
1056
        ; g.- 
1057
 
1058
        ;store psw away for later comparison
1059
save_psw macro
1060
        mov     saved_psw,PSW
1061
        endm
1062
 
1063
        ; compare flags CY, AC and OV with expected values in 
1064
tst_psw macro   flags,error_loc
1065
        mov     a,saved_psw
1066
        anl     a,#0c4h
1067
        xrl     a,#flags
1068
        anl     a,#0feh
1069
        jnz     error_loc
1070
        endm
1071
 
1072
        ; Set the CY flag to the value of the lsb of argument 
1073
set_cy  macro   flags
1074
        local   cy_val
1075
cy_val  set     (flags and 1)
1076
        if      cy_val eq 1
1077
        setb    c
1078
        else
1079
        clr     c
1080
        endif
1081
        endm
1082
 
1083
        ; Test instruction  A, src
1084
        ;
1085
        ; flags = ( & 0xfe) | 
1086
        ; (P flag result is not tested)
1087
top_ma  macro   op,src,error_loc,flags
1088
        mov     src,#arg0
1089
        mov     a,#arg1
1090
        ifnb    
1091
        set_cy  flags
1092
        endif
1093
        op      a,src
1094
        ifnb    
1095
        save_psw
1096
        endif
1097
        cjne    a,#res,error_loc
1098
        ifnb    
1099
        tst_psw ,error_loc
1100
        endif
1101
        endm
1102
 
1103
        ; Test instruction  dst, #arg0
1104
        ; ( same as top_ma)
1105
top_mb  macro   op,dst,error_loc,flags
1106
        mov     dst,#arg1
1107
        ifnb    
1108
        set_cy  flags
1109
        endif
1110
        op      dst,#arg0
1111
        ifnb    
1112
        save_psw
1113
        endif
1114
        mov     ACC,dst
1115
        cjne    a,#res,error_loc
1116
        ifnb    
1117
        tst_psw ,error_loc
1118
        endif
1119
        endm
1120
 
1121
        ; Test instruction  dir, A
1122
        ; ( same as top_ma)
1123
top_mc  macro   op,error_loc,flags
1124
        mov     dir0,#arg0
1125
        mov     a,#arg1
1126
        ifnb    
1127
        set_cy  flags
1128
        endif
1129
        op      dir0,a
1130
        ifnb    
1131
        save_psw
1132
        endif
1133
        mov     a,dir0
1134
        cjne    a,#res,error_loc
1135
        ifnb    
1136
        tst_psw ,error_loc
1137
        endif
1138
        endm
1139
 
1140
        ; Test ALU instruction with all addressing modes.
1141
        ; FIXME  A, #imm not tested!
1142
        ; op : Opcode to be tested
1143
        ; a0, a1 : Values used as 1st and 2nd args in all addressing modes
1144
        ; r : Expected result
1145
        ; am :
1146
        ; flags : &0xfe | 
1147
        ; (if the parameter is unused, the macro skips the flag check)
1148
tst_alu macro   op,a0,a1,r,am,flags
1149
        local   tall_0d
1150
        local   tall_0a
1151
        local   tall_0b
1152
        local   tall_0c
1153
        local   tall_1
1154
        local   tall_2
1155
        local   tall_3
1156
        ; Put the argument and result data into variables for easier access
1157
        arg0    set a0
1158
        arg1    set a1
1159
        res     set r
1160
 
1161
        ; Test  A, dir
1162
        top_ma  op,dir0,tall_0a,
1163
        ; Test  A, @R0
1164
        mov     r0,#dir0
1165
        top_ma  op,@r0,tall_0a,
1166
        ; Test  A, @R1
1167
        mov     r1,#031h
1168
        top_ma  op,@r1,tall_0a,
1169
 
1170
        ; Now test  A, Rn for n in 0..7
1171
        top_ma  op,r0,tall_0a,
1172
        top_ma  op,r1,tall_0a,
1173
 
1174
        eot     'a',tall_0a
1175
 
1176
        top_ma  op,r2,tall_0b,
1177
        top_ma  op,r3,tall_0b,
1178
 
1179
        eot     'b',tall_0b
1180
 
1181
        top_ma  op,r4,tall_0c,
1182
        top_ma  op,r5,tall_0c,
1183
 
1184
        eot     'c',tall_0c
1185
 
1186
        top_ma  op,r6,tall_0d,
1187
        top_ma  op,r7,tall_0d,
1188
 
1189
        eot     'd',tall_0d
1190
        ; Ok,  A, {dir | @Ri | Rn} done.
1191
 
1192
        ; Optionally test immediate addressing modes.
1193
 
1194
        if      (am and 1) ne 0
1195
        ; Test  A, #arg1...
1196
        top_mb  op,a,tall_1,
1197
        eot     'e',tall_1
1198
        endif
1199
 
1200
        if      (am and 2) ne 0
1201
        ; ...and  dir, #arg1
1202
        top_mb  op,dir0,tall_2,
1203 15 ja_rd
        top_mb  op,B,tall_2,
1204 3 ja_rd
        eot     'f',tall_2
1205
        endif
1206
 
1207
        ; Optionally test  dir, A
1208
        if      (am and 4) ne 0
1209
        top_mc  op,tall_3,
1210
        eot     'g',tall_3
1211
        endif
1212
 
1213
        endm
1214
 
1215
 
1216
        ;-- Test series H ------------------------------------------------------
1217
        ; ANL
1218
        ; (See comments for 'ALU opcode block test')
1219
 
1220
        putc    #'H'                ; start of test series
1221
 
1222
        tst_alu anl,03ch,099h,018h,07h,
1223
 
1224
        put_crlf                    ; end of test series
1225
 
1226
 
1227
        ;-- Test series I ------------------------------------------------------
1228
        ; ORL
1229
        ; (See comments for 'ALU opcode block test')
1230
 
1231
        putc    #'I'                ; start of test series
1232
 
1233
        tst_alu orl,051h,092h,0d3h,07h,
1234
 
1235
        put_crlf                    ; end of test series
1236
 
1237
        ;-- Test series J ------------------------------------------------------
1238
        ; XRL
1239
        ; (See comments for 'ALU opcode block test')
1240
 
1241
 
1242
        putc    #'J'                ; start of test series
1243
 
1244
        tst_alu xrl,051h,033h,062h,07h,
1245
 
1246
        put_crlf                    ; end of test series
1247
 
1248
        ;-- Test series K ------------------------------------------------------
1249
        ; DJNZ
1250
        ; a.- ,  tested only with small negative rels
1251
 
1252
        putc    #'K'                ; start of test series
1253
 
1254
        ;tk_ma: test DJNZ with parametrizable addressing mode
1255
tk_ma   macro   dst,error_loc
1256
        local   tk_ma0
1257
nloops  set     3
1258
        mov     dst,#nloops         ; We'll perform a fixed no. of iterations
1259
        mov     a,#(nloops+1)       ; A will or our control counter
1260
tk_ma0: dec     a
1261
        jz      error_loc           ; Break loop after nloops iterations
1262
        djnz    dst,tk_ma0          ; Test DJNZ instruction
1263
        cjne    a,#001,error_loc    ; Verify number of iterations is ok
1264
        endm
1265
 
1266 13 ja_rd
        tk_ma   dir0,tk_a0          ;  with IRAM operand
1267
        tk_ma   B,tk_a0             ;  with SFR operand
1268 3 ja_rd
 
1269
        eot     'a',tk_a0
1270
 
1271
        tk_ma   r0,tk_b0            ; 
1272
        tk_ma   r1,tk_b0
1273
        tk_ma   r2,tk_b0
1274
        tk_ma   r3,tk_b0
1275
        tk_ma   r4,tk_b0
1276
        tk_ma   r5,tk_b0
1277
        tk_ma   r6,tk_b0
1278
        tk_ma   r7,tk_b0
1279
 
1280
        eot     'b',tk_b0
1281
 
1282
        put_crlf                    ; end of test series
1283
 
1284
 
1285
        ;-- Test series L ------------------------------------------------------
1286
        ; ADD
1287
        ; (See comments for 'ALU opcode block test')
1288
 
1289
 
1290
        putc    #'L'                ; start of test series
1291
 
1292
        putc    #'0'
1293
        tst_alu add,051h,033h,084h,01h,004h     ; /CY /AC  OV
1294
        putc    #'1'
1295
        tst_alu add,081h,093h,014h,01h,084h     ;  CY /AC  OV
1296
        putc    #'2'
1297
        tst_alu add,088h,098h,020h,01h,0c4h     ;  CY  AC  OV
1298
        putc    #'3'
1299
        tst_alu add,043h,0fbh,03eh,01h,080h     ;  CY /AC /OV
1300
 
1301
        put_crlf                    ; end of test series
1302
 
1303
 
1304
        ;-- Test series M ------------------------------------------------------
1305
        ; ADDC
1306
        ; (See comments for 'ALU opcode block test')
1307
        ; Note the test runs 4 times for different values of operands
1308
 
1309
        putc    #'M'                ; start of test series
1310
 
1311
        putc    #'0'
1312
        tst_alu addc,051h,033h,084h,01h,004h     ; /CY /AC  OV
1313
        putc    #'1'
1314
        tst_alu addc,081h,093h,014h,01h,084h     ;  CY /AC  OV
1315
        putc    #'2'
1316
        tst_alu addc,088h,098h,020h,01h,0c4h     ;  CY  AC  OV
1317
        putc    #'3'
1318
        tst_alu addc,088h,098h,021h,01h,0c5h     ;  CY  AC  OV (CY input)
1319
        putc    #'4'
1320
        tst_alu addc,043h,0fbh,03fh,01h,081h     ;  CY /AC /OV (CY input)
1321
 
1322
 
1323
        put_crlf                    ; end of test series
1324
 
1325
 
1326
        ;-- Test series N ------------------------------------------------------
1327
        ; SUBB
1328
        ; (See comments for 'ALU opcode block test')
1329
        ; Note the test runs 4 times for different values of operands
1330
 
1331
        putc    #'N'                ; start of test series
1332
 
1333
        putc    #'0'
1334
        tst_alu subb,070h,073h,003h,01h,000h     ; /CY /AC /OV
1335
        putc    #'1'
1336
        tst_alu subb,070h,073h,002h,01h,001h     ; /CY /AC /OV (CY input)
1337
        putc    #'2'
1338
        tst_alu subb,0c3h,0c5h,002h,01h,000h     ; /CY  AC /OV
1339
        putc    #'3'
1340
        tst_alu subb,0c3h,0c5h,001h,01h,001h     ; /CY  AC  OV (CY input)
1341
 
1342
        ; FIXME subb tests are specially weak
1343
 
1344
        put_crlf                    ; end of test series
1345
 
1346
 
1347
        ;-- Test series O ------------------------------------------------------
1348
        ; PUSH and POP
1349
        ; a.- 
1350
        ; b.- 
1351
        ; c.- 
1352
        ; d.- 
1353
 
1354
        putc    #'O'                ; start of test series
1355
 
1356
        ; 
1357
        mov     SP,#stack0          ; prepare SP...
1358
        mov     dir0,#012h          ; ...and data to be pushed
1359
        mov     r0,#(stack0+1)      ; r0->stack so we can verify data is pushed
1360
        mov     @r0,#000h           ; clear target stack location
1361
        push    dir0                ; 
1362
        mov     a,@r0               ; verify data has been pushed
1363
        cjne    a,#012h,to_a0
1364
        mov     a,SP                ; verify SP has been incremented
1365
        cjne    a,#(stack0+1),to_a0
1366
 
1367
        eot     'a',to_a0
1368
 
1369
        ;  We'll use the data that was pushed previously
1370
        mov     dir1,#000h          ; clear POP target
1371
        clr     a
1372
        pop     dir1                ; 
1373
        mov     r1,#dir1            ; verify data has been popped
1374
        mov     a,@r1
1375
        cjne    a,#012h,to_b0
1376
        mov     a,SP                ; verify SP has been decremented
1377
        cjne    a,#stack0,to_b0
1378
 
1379
        eot     'b',to_b0
1380
 
1381
        ; 
1382
        mov     SP,#stack0          ; prepare SP...
1383
        mov     B,#042h             ; ...and data to be pushed
1384
        mov     r0,#(stack0+1)      ; r0->stack so we can verify data is pushed
1385
        mov     @r0,#000h           ; clear target stack location
1386
        push    B                   ; 
1387
        mov     a,@r0               ; verify data has been pushed
1388
        cjne    a,#042h,to_c0
1389
        mov     a,SP                ; verify SP has been incremented
1390
        cjne    a,#(stack0+1),to_c0
1391
 
1392
        eot     'c',to_c0
1393
 
1394
        ;  We'll use the data that was pushed previously
1395
        mov     B,#000h             ; clear POP target
1396
        clr     a
1397
        pop     B                   ; 
1398
        mov     a,B                 ; verify data has been popped
1399
        cjne    a,#042h,to_d0
1400
        mov     a,SP                ; verify SP has been decremented
1401
        cjne    a,#stack0,to_d0
1402
 
1403
        eot     'd',to_d0
1404
 
1405
        put_crlf                    ; end of test series
1406
 
1407
        ;-- Test series P ------------------------------------------------------
1408
        ; Access to XRAM -- note that current tests are bare-bone minimal!
1409
        ; a.- 
1410
        ; b.- , 
1411
        ; c.- 
1412
        ; d.- 
1413
 
1414
        putc    #'P'                ; start of test series
1415
 
1416
        ; a.- 
1417
        mov     DPH,#065h           ; initialize DPTR with known value...
1418
        mov     DPL,#043h
1419
 
1420
        mov     DPTR,#0123h         ; ...then load it through MOV...
1421
        mov     a,DPH               ; ...and verify the load
1422
        cjne    a,#01h,tp_a0
1423
        mov     a,DPL
1424
        cjne    a,#23h,tp_a0
1425
 
1426
        eot     'a',tp_a0
1427
 
1428
 
1429
        ; b.- , 
1430
        ; We have no independent means to verify XRAM writes or reads, other
1431
        ; than the very instructions we're testing. So we should store a data
1432
        ; pattern on XRAM that is difficult to get back 'by chance'.
1433
        ; Ideally we would try all areas of XRAM, back-to-back operations, etc.
1434
        ; For the time being a simple word store will suffice.
1435
        mov     DPTR,#0013h         ; Store 55h, aah at XRAM[0013h]...
1436
        mov     A,#55h
1437
        movx    @DPTR,a
1438
        inc     DPTR
1439
        cpl     a
1440
        movx    @DPTR,a
1441
 
1442
        mov     DPTR,#0013h         ; ...then verify the store
1443
        movx    a,@DPTR
1444
        cjne    a,#55h,tp_b0
1445
        inc     DPTR
1446
        movx    a,@DPTR
1447
        cjne    a,#0aah,tp_b0
1448
 
1449
        eot     'b',tp_b0
1450
 
1451
        ; c.- 
1452
        mov     a,#79h              ; Let [0013h] = 79h and [0014h] = 97h
1453
        mov     dptr,#0013h
1454
        mov     r0,#13h             ;
1455
        mov     r1,#14h             ; Write using @Ri...
1456
        movx    @r0,a
1457
        dec     a
1458
        movx    a,@DPTR             ; ...verify using DPTR
1459
        cjne    a,#79h,tp_c0
1460
        inc     DPTR
1461
        mov     a,#97h
1462
        movx    @r1,a
1463
        movx    a,@DPTR
1464
        cjne    a,#097h,tp_c0
1465
 
1466
        eot     'c',tp_c0
1467
 
1468
        ; d.- 
1469
        mov     a,#79h              ; Let [0013h] = 79h and [0014h] = 97h
1470
        mov     dptr,#0013h
1471
        mov     r0,#13h
1472
        mov     r1,#14h
1473
        movx    @DPTR,a             ; Write using DPTR...
1474
        dec a
1475
        movx    a,@r0               ; ... verify using @Ri
1476
        cjne    a,#79h,tp_d0
1477
        mov     a,#97h
1478
        inc     DPTR
1479
        movx    @DPTR,a
1480
        dec a
1481
        movx    a,@r1
1482
        cjne    a,#097h,tp_d0
1483
 
1484
        eot     'd',tp_d0
1485
 
1486
        put_crlf                    ; end of test series
1487
 
1488
        ;-- Test series Q ------------------------------------------------------
1489
        ; MOVC instructions
1490
        ; a.- 
1491
        ; b.- 
1492
 
1493
        putc    #'Q'                ; start of test series
1494
 
1495
        ; a.- 
1496
        mov     a,#03h              ; we'll read the 4th byte in the table...
1497
        add     a,#02h              ; ...and must account for intervening sjmp
1498
        movc    a,@a+PC
1499
        sjmp    tq0
1500
 
1501
tq1:    db      07h, 13h, 19h, 21h
1502
tq0:    cjne    a,#21h,tq_a0
1503
 
1504
        eot     'a',tq_a0
1505
 
1506
        ; b.- 
1507
        mov   DPTR,#tq1
1508
 
1509
        mov   a,#00h
1510
        movc  a,@a+DPTR
1511
        cjne  a,#07h,tq_b0
1512
 
1513
        mov   a,#01h
1514
        movc  a,@a+DPTR
1515
        cjne  a,#13h,tq_b0
1516
 
1517
        mov   a,#02h
1518
        movc  a,@a+DPTR
1519
        cjne  a,#19h,tq_b0
1520
 
1521
        mov   a,#03h
1522
        movc  a,@a+DPTR
1523
        cjne  a,#21h,tq_b0
1524
 
1525
        eot     'b',tq_b0
1526
 
1527
        put_crlf                    ; end of test series
1528
 
1529
 
1530
        ;-- Test series R ------------------------------------------------------
1531
        ; ACALL, LCALL, JMP @A+DPTR, LJMP, AJMP instructions
1532
        ; a.-      <-- uses LJMP too
1533
        ; b.-     <-- uses LJMP too
1534
        ; c.- 
1535
        ; d.- 
1536
        ; e.- 
1537
        ;
1538
        ; Biggest limitations:
1539
        ; .- Jumps to same page (== H addr byte) tested only at one page.
1540
        ;
1541
        ; Note RET is NOT tested here! we don't return from these calls, just
1542
        ; use them as jumps.
1543
        ;
1544
 
1545
        putc    #'R'                ; start of test series
1546
 
1547
        mov     SP,#4fh             ; Initialize SP...
1548
        mov     50h,#00h            ; ...and clear stack area
1549
        mov     51h,#00h
1550
        mov     52h,#00h
1551
        mov     53h,#00h
1552
 
1553
        ; a.- 
1554
        ; We should test all code pages eventually...
1555
        acall   tr_sub0             ; Do the call...
1556
tr_rv0: sjmp    tr_a0
1557
tr_sub0:
1558
        mov     A,SP
1559
        cjne    A,#51h,tr_a0       ; ...verify the SP value...
1560
        mov     A,50h
1561
        cjne    A,#LOW(tr_rv0),tr_a0 ; ...and verify the pushed ret address
1562
        mov     A,51h
1563
        cjne    A,#HIGH(tr_rv0),tr_a0
1564
 
1565
        eot     'a',tr_a0
1566
 
1567
        ; b.- 
1568
        lcall   tr_sub1             ; Do the call...
1569
tr_rv1: sjmp    tr_b0
1570
tr_rv2: nop
1571
        eot     'b',tr_b0
1572
 
1573
 
1574
        ; c.- 
1575
        ; Note that tr_sub2 is at 8000h so that we test the A+DPTR carry
1576
        ; propagation. Any address xx00h would do.
1577
        mov     DPTR,#(tr_sub2-33h) ; Prepare DPTR and A so that their sum
1578
        mov     a,#33h              ; gives the target address.
1579
        jmp     @a+DPTR
1580
        jmp     tr_c0
1581
        nop
1582
        nop
1583
tr_rv3: mov     a,#00h
1584
        mov     a,#00h
1585
        mov     a,#00h
1586
        mov     a,#00h
1587
 
1588
        eot     'c',tr_c0
1589
 
1590
        ; d.- 
1591
        ljmp    tr_sub3
1592
        jmp     tr_d0
1593
        nop
1594
        nop
1595
tr_rv4: nop
1596
        nop
1597
        eot     'd',tr_d0
1598
 
1599
        ; e.- 
1600
        ; We should test all code pages eventually...
1601
        mov     a,#00h
1602
        ajmp    tr_ajmp0            ; Do the jump...
1603
        sjmp    tr_rv5
1604
tr_ajmp0:
1605
        mov     a,#042h
1606
tr_rv5:
1607
        cjne    A,#42h,tr_e0       ; ...and make sure we've actually been there
1608
        nop
1609
 
1610
        eot     'e',tr_e0
1611
 
1612
        put_crlf                    ; end of test series
1613
 
1614
 
1615
        ;-- Test series S ------------------------------------------------------
1616
        ; RET, RETI instructions
1617
        ; a.- 
1618
        ; b.- 
1619
        ;
1620
        ; RETs to different code pages (!= H addr byte) not tested!
1621
        ; Interrupt flag stuff not tested, only RET functionality
1622
 
1623
        putc    #'S'                ; start of test series
1624
 
1625
 
1626
        ; a.- 
1627
        mov     SP,#4fh             ; Initialize SP...
1628
        mov     4fh,#HIGH(s_sub0)   ; ...and load stack area with return
1629
        mov     4eh,#LOW(s_sub0)    ; addresses to be tested
1630
        mov     4dh,#HIGH(s_sub1)
1631
        mov     4ch,#LOW(s_sub1)
1632
 
1633
        ret                         ; Do the ret...
1634
        sjmp    ts_a0
1635
        mov     A,#00h
1636
s_sub0: mov     A,SP
1637
        cjne    A,#4dh,ts_a0       ; ... and verify the SP value
1638
 
1639
        ret                         ; Do another ret...
1640
        sjmp    ts_a0
1641
        mov     A,#00h
1642
s_sub1: mov     A,SP
1643
        cjne    A,#4bh,ts_a0       ; ... and verify the SP value
1644
 
1645
        eot     'a',ts_a0
1646
 
1647
 
1648
        ; a.- 
1649
        mov     SP,#4fh             ; Initialize SP...
1650
        mov     4fh,#HIGH(s_sub2)   ; ...and load stack area with return
1651
        mov     4eh,#LOW(s_sub2)    ; addresses to be tested
1652
        mov     4dh,#HIGH(s_sub3)
1653
        mov     4ch,#LOW(s_sub3)
1654
 
1655
        ret                         ; Do the ret...
1656
        sjmp    ts_a0
1657
        mov     A,#00h
1658
s_sub2: mov     A,SP
1659
        cjne    A,#4dh,ts_b0       ; ... and verify the SP value
1660
 
1661
        ret                         ; Do another ret...
1662
        sjmp    ts_a0
1663
        mov     A,#00h
1664
s_sub3: mov     A,SP
1665
        cjne    A,#4bh,ts_b0       ; ... and verify the SP value
1666
 
1667
        eot     'b',ts_b0
1668
 
1669
        ; Lots of things can go badly and we wouldn't know with this test...
1670
        put_crlf                    ; end of test series
1671
 
1672
        ;-- Test series T ------------------------------------------------------
1673
        ; MUL, DIV instructions
1674
        ; a.- 
1675
        ; b.- 
1676
        ;
1677
 
1678
        putc    #'T'                ; start of test series
1679
 
1680
        ; a.- 
1681
        mov     B,#07h              ; First of all, make sure B can be read back
1682
        mov     A,#13h
1683
        mov     A,B
1684
        cjne    A,#07h,tt_a0
1685
 
1686
        ; Now do a few representative DIVs using a table. The table has the
1687
        ; following format:
1688
        ; denominator, numerator, overflow, quotient, remainder
1689
        ; Where 'overflow' is 00h or 04h.
1690
 
1691
        ; DPTR will point to the start of the table, r0 will be the current data
1692
        ; byte offset and r1 the number of test cases remaiining.
1693
        mov     DPTR,#tt_a_tab
1694
        mov     r0,#00h
1695
        mov     r1,#((tt_a_tab_end-tt_a_tab)/5)
1696
 
1697
tt_a_loop:
1698
        mov     a,r0
1699
        inc     r0
1700
        movc    a,@a+DPTR
1701
        mov     B,a
1702
        mov     a,r0
1703
        inc     r0
1704
        movc    a,@a+DPTR
1705
        div     ab
1706
        mov     dir0,a
1707
 
1708
        mov     a,r0                ; Get expected OV flag
1709
        inc     r0
1710
        movc    a,@a+DPTR
1711
        jnz     tt_a_divzero        ; If OV expected, skip verification of
1712
        mov     a,PSW               ; quotient and remainder
1713
        anl     a,#04h
1714
        jnz     tt_a0
1715
 
1716
        mov     a,r0                ; Verify quotient...
1717
        inc     r0
1718
        movc    a,@a+DPTR
1719
        cjne    a,dir0,tt_a0
1720
        mov     a,r0                ; ...and verify remainder
1721
        inc     r0
1722
        movc    a,@a+DPTR
1723
        cjne    a,B,tt_a0
1724
        jmp     tt_a_next
1725
 
1726
tt_a_divzero:
1727
        inc     r0
1728
        inc     r0
1729
tt_a_next:
1730
        dec     r1                  ; go for next test vector, if any
1731
        mov     a,r1
1732
        jnz     tt_a_loop
1733
 
1734
        eot     'a',tt_a0
1735
        sjmp    tt_a_tab_end
1736
 
1737
tt_a_tab:
1738
        db      7,19,0,2,5
1739
        db      7,17,0,2,3
1740
        db      7,13,0,1,6
1741
        db      13,17,0,1,4
1742
        db      17,13,0,0,13
1743
        db      0,13,4,0,13
1744
        db      80h,87h,0,1,7
1745
        db      1,255,0,255,0
1746
        db      2,255,0,127,1
1747
tt_a_tab_end:
1748
 
1749
        ; b.- 
1750
 
1751
        ; Do with MUL the same we just did with DIV. The test data table has
1752
        ; the following format:
1753
        ; denominator, numerator, product high byte, product low byte.
1754
 
1755
        ; DPTR will point to the start of the table, r0 will be the current data
1756
        ; byte offset and r1 the number of test cases remaiining.
1757
        mov     DPTR,#tt_b_tab
1758
        mov     r0,#00h
1759
        mov     r1,#((tt_b_tab_end-tt_b_tab)/4)
1760
 
1761
tt_b_loop:
1762
        mov     a,r0                ; Load B with test data...
1763
        inc     r0
1764
        movc    a,@a+DPTR
1765
        mov     B,a
1766
        mov     a,r0                ; ...then load A with test data...
1767
        inc     r0
1768
        movc    a,@a+DPTR
1769
        mul     ab                  ; and do the MUL
1770
        mov     dir0,a              ; Save A for later checks
1771
 
1772
        mov     a,r0                ; Verify product high byte
1773
        ;inc     r0
1774
        movc    a,@a+DPTR
1775
        jz      tt_b_noovf
1776
 
1777
        mov     a,PSW               ; overflow expected
1778
        anl     a,#04h
1779
        jz      tt_b0
1780
        sjmp    tt_b_0
1781
 
1782
tt_b_noovf:
1783
        mov     a,PSW               ; no overflow expected
1784
        anl     a,#04h
1785
        jnz     tt_b0
1786
 
1787
tt_b_0:
1788
        mov     a,r0                ; Verify product high byte
1789
        inc     r0
1790
        movc    a,@a+DPTR
1791
        cjne    a,B,tt_b0
1792
        mov     a,r0                ; ...and verify low byte
1793
        inc     r0
1794
        movc    a,@a+DPTR
1795
        cjne    a,dir0,tt_b0
1796
 
1797
        dec     r1                  ; go for next test vector, if any
1798
        mov     a,r1
1799
        jnz     tt_b_loop
1800
 
1801
        eot     'b',tt_b0
1802
        sjmp    tt_b_tab_end
1803
 
1804
tt_b_tab:
1805
        db      7,19,0,133
1806
        db      7,17,0,119
1807
        db      7,13,0,91
1808
        db      13,17,0,221
1809
        db      17,13,0,221
1810
        db      0,13,0,0
1811
        db      80h,87h,43h,80h
1812
        db      1,255,0,255
1813
        db      2,255,01h,0feh
1814
tt_b_tab_end:
1815
 
1816
        put_crlf                    ; end of test series
1817
 
1818
 
1819
 
1820
        ;-- Test series U ------------------------------------------------------
1821
        ; Register banks
1822
        ; a.- Write to register, read from indirect address.
1823
        ; a.- Write to indirect address, read from register.
1824
        ;
1825
 
1826
        putc    #'U'                ; start of test series
1827
 
1828
 
1829
        mov     PSW,#00h            ; Test bank 0
1830
        mov     a,#00h + 1
1831
        call    tu_a_test
1832
 
1833
        mov     PSW,#08h            ; Test bank 1
1834
        mov     a,#08h + 1
1835
        call    tu_a_test
1836
 
1837
        mov     PSW,#10h            ; Test bank 2
1838
        mov     a,#10h + 1
1839
        call    tu_a_test
1840
 
1841
        mov     PSW,#18h            ; Test bank 3
1842
        mov     a,#18h + 1
1843
        call    tu_a_test
1844
 
1845
        sjmp    tu_a_done
1846
 
1847
tu_a_test:
1848
        mov     r0,a                ; R0 points to R1 in the selected bank.
1849
 
1850
        mov     r1,#12h             ; Write to registers R1 and R7
1851
        mov     r7,#34h
1852
 
1853
        mov     a,@r0               ; Check R1
1854
        cjne    a,#12h,tu_a0
1855
        mov     a,#56h              ; Ok, now write to R1 with reg addressing...
1856
        mov     @r0,a               ; ...and check by reading in indirect.
1857
        cjne    r1,#56h,tu_a0
1858
 
1859
        mov     a,r0                ; Set R0 to point to R7 in selected bank
1860
        add     a,#06h
1861
        mov     r0,a
1862
        mov     a,@r0               ; Check R7
1863
        cjne    a,#34h,tu_a0
1864
 
1865
        mov     a,#78h              ; Ok, now write to R7 with reg addressing...
1866
        mov     @r0,a               ; ...and check by reading in indirect.
1867
        cjne    a,#78h,tu_a0
1868
 
1869
        ret
1870
 
1871
tu_a_done:
1872
        nop
1873
        eot     'a',tu_a0
1874
 
1875
        put_crlf                    ; end of test series
1876
 
1877
 
1878
        ;-- Test series V ------------------------------------------------------
1879
        ; NOP and potentially unimplemented opcodes (DA and XCHD).
1880
        ; In order to make sure an instruction does nothing we would have to
1881
        ; check everything: IRAM, XRAM and SFRs. We will leave that to the
1882
        ; zexall-style tester. In this test we rely on the cosimulation with
1883
        ; software simulator B51.
1884
        ;
1885
        ; a.- Opcode 0A5h
1886
        ; b.- DA
1887
        ; c.- XCHD A, @Ri
1888
 
1889
        putc    #'V'                ; start of test series
1890
 
1891
 
1892
        ; a.- <0A5>
1893
        db      0a5h                ; Put opcode right there...
1894
        nop                         ; and do no check at all -- rely on B51.
1895
        ; we'll catch any unintended side effects by comparing the logs.
1896
        ; Obviously this is no good for any core other then light52...
1897
 
1898
        eot     'a',tv_a0
1899
 
1900
        ; b.- 
1901
        ifdef   BCD
1902
        ; DA implemented in CPU
1903
        mov     psw,#000h           ; Al>9, AC=0
1904
        mov     a,#01ah
1905
        da      a
1906
        mov     saved_psw,psw
1907
        cjne    a,#020h,tv_b0
1908
        mov     a,saved_psw
1909
        cjne    a,#001h,tv_b0
1910
 
1911
        mov     psw,#040h           ; Al<9, AC=1
1912
        mov     a,#012h
1913
        da      a
1914
        mov     saved_psw,psw
1915
        cjne    a,#018h,tv_b0
1916
        mov     a,saved_psw
1917
        cjne    a,#040h,tv_b0
1918
 
1919
        mov     psw,#040h           ; Al>9, AC=1 (hardly possible in BCD)
1920
        mov     a,#01ah
1921
        da      a
1922
        mov     saved_psw,psw
1923
        cjne    a,#020h,tv_b0
1924
        mov     a,saved_psw
1925
        cjne    a,#041h,tv_b0
1926
 
1927
        mov     psw,#0c0h           ; AC=CY=1
1928
        mov     a,#000h
1929
        da      a
1930
        mov     saved_psw,psw
1931
        cjne    a,#066h,tv_b0
1932
        mov     a,saved_psw
1933
        cjne    a,#0c0h,tv_b0
1934
 
1935
        mov     psw,#040h           ; DA generates carry
1936
        mov     a,#0fah
1937
        da      a
1938
        mov     saved_psw,psw
1939
        cjne    a,#060h,tv_b0
1940
        mov     a,saved_psw
1941
        cjne    a,#0c0h,tv_b0
1942
 
1943
        else
1944
        ; DA unimplemented in CPU
1945
        mov     a,#01ah             ; This would be adjusted by DA to 020h...
1946
        da      a                   ; ...make sure it isn't
1947
        cjne    a,#01ah,tv_b0
1948
        nop
1949
        endif
1950
 
1951
        eot     'b',tv_b0
1952
 
1953
        ; c.- XCHD a,@ri
1954
        ifdef   BCD
1955
        ; XCHD implemented in CPU, test opcode.
1956
        mov     r0,#031h
1957
        mov     r1,#032h
1958
        mov     a,#042h
1959
        mov     @r0,a
1960
        inc     a
1961
        mov     @r1,a
1962
        mov     a,#76h
1963
        xchd    a,@r0
1964
        cjne    a,#072h,tv_c0
1965
        mov     a,31h
1966
        cjne    a,#046h,tv_c0
1967
        mov     a,#79h
1968
        xchd    a,@r1
1969
        cjne    a,#073h,tv_c0
1970
        mov     a,32h
1971
        cjne    a,#049h,tv_c0
1972
        else
1973
        ; XCHD unimplemented, make sure the nibbles aren't exchanged.
1974
        mov     r0,#031h
1975
        mov     r1,#032h
1976
        mov     a,#042h
1977
        mov     @r0,a
1978
        mov     @r1,a
1979
        mov     a,#76h
1980
        xchd    a,@r0
1981
        cjne    a,#076h,tv_c0
1982
        mov     a,#76h
1983
        xchd    a,@r1
1984
        cjne    a,#076h,tv_c0
1985
        endif
1986
 
1987
        eot     'c',tv_c0
1988
 
1989
        put_crlf                    ; end of test series
1990
 
1991
 
1992
        ;-- Template for test series -------------------------------------------
1993
 
1994
        ;-- Test series X ------------------------------------------------------
1995
        ;
1996
        ; a.-
1997
 
1998
        ;putc    #'X'                ; start of test series
1999
        ;put_crlf                    ; end of test series
2000
 
2001
        ;-----------------------------------------------------------------------
2002
 
2003
        ; Test cases finished. Now print completion message dependent on the
2004
        ; value of the fail flag.
2005
 
2006
        mov     a,fail
2007
        jnz     test_failed
2008
 
2009
        put_crlf
2010
        putc    #'P'
2011
        putc    #'A'
2012
        putc    #'S'
2013
        putc    #'S'
2014
        put_crlf
2015
        sjmp    quit
2016
 
2017
test_failed:
2018
        put_crlf
2019
        putc    #'F'
2020
        putc    #'A'
2021
        putc    #'I'
2022
        putc    #'L'
2023
        put_crlf
2024
        sjmp    quit
2025
 
2026
        ;-- End of test program, enter single-instruction endless loop
2027
quit:   ajmp    $
2028
 
2029
 
2030
        ; We'll place a few test routines in the 2nd half of the code space so
2031
        ; we can test long jumps and calls onto different code pages.
2032
        org     8000h
2033
 
2034
        ; tr_sub2: part of the JMP @A+DPTR test.
2035
        ; HAS TO BE in 8000h so we can test the A+DPTR carry propagation!
2036
tr_sub2:
2037
        jmp     tr_rv3
2038
        jmp     tr_c0
2039
        ; Make sure the assumption we'll make in the test is actually valid
2040
        if      LOW(tr_sub2) ne 0
2041
        $error("Label 'tr_sub2' must be at an address multiple of 256 to properly test JMP @A+DPTR")
2042
        endif
2043
 
2044
        ; tr_sub3: part of the LJMP test.
2045
tr_sub3:
2046
        jmp     tr_rv4
2047
        jmp     tr_d0
2048
 
2049
        ; tr_sub1: part of the LCALL test.
2050
tr_sub1:
2051
        mov     A,SP
2052
        cjne    A,#53h,tr_sub1_fail ; ...verify the SP value...
2053
        mov     A,52h               ; ...and verify the pushed ret address
2054
        cjne    A,#LOW(tr_rv1),tr_sub1_fail
2055
        mov     A,53h
2056
        cjne    A,#HIGH(tr_rv1),tr_sub1_fail
2057
        ljmp    tr_rv2
2058
tr_sub1_fail:
2059
        ljmp    tr_b0
2060
 
2061
 
2062
        end

powered by: WebSVN 2.1.0

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