Skip to content

Commit fa33577

Browse files
committed
Add new test to *cpu* tests: undocumented nop irqs
1 parent ed2c3aa commit fa33577

File tree

7 files changed

+377
-114
lines changed

7 files changed

+377
-114
lines changed

audio/tests.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
sta _g_results + 4 ; #2 Expected: $00 (counter should be zero)
124124

125125
lda AUD0OUT
126-
sta _g_results + 5 ; #3 Expected: $00
126+
sta _g_results + 5 ; #3 Expected: $7F
127127

128128
rts
129129
.endproc

audio2/tests.s

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@
102102
beq @fail
103103

104104
lda ch3_iter
105-
sta _g_results + 0 ; #1: how many CH3 DONEs we counted (expect 10)
105+
sta _g_results + 0 ; #1: how many CH3 DONEs we counted (expect 10) Expected: $0A
106106
lda TIM1CTLB
107-
sta _g_results + 1 ; #2: Timer1 CTLB
107+
sta _g_results + 1 ; #2: Timer1 CTLB Expected: $08
108108
lda AUD3CTLB
109-
sta _g_results + 2 ; #3: CH3 CTLB
109+
sta _g_results + 2 ; #3: CH3 CTLB Expected: $34
110110
rts
111111

112112
@fail:
@@ -209,14 +209,14 @@
209209
beq @fail
210210

211211
lda t7_iter
212-
sta _g_results + 3 ; #1: number of TIM7 DONEs we counted (expect 10)
212+
sta _g_results + 3 ; #1: number of TIM7 DONEs we counted (expect 10) Expected: $0A
213213
lda TIM7CTLB
214214
and #$0F ; mask out unused bits (they are LFSR btw)
215-
sta _g_results + 4 ; #2: TIM7 CTLB
215+
sta _g_results + 4 ; #2: TIM7 CTLB Expected: $04
216216
lda AUD0CTLB
217-
sta _g_results + 5 ; #3: CH0 CTLB
217+
sta _g_results + 5 ; #3: CH0 CTLB Expected: $78
218218
lda AUD0OUT
219-
sta _g_results + 6 ; #4: CH0 OUT
219+
sta _g_results + 6 ; #4: CH0 OUT Expected: $70
220220
rts
221221

222222
@fail:
@@ -328,13 +328,13 @@
328328
beq @fail
329329

330330
lda ch0_iter
331-
sta _g_results + 7 ; #1: CH0 DONEs counted (expect 10)
331+
sta _g_results + 7 ; #1: CH0 DONEs counted (expect 10) Expected: $0A
332332
lda AUD3CTLB
333-
sta _g_results + 8 ; #2: CH3 CTLB
333+
sta _g_results + 8 ; #2: CH3 CTLB Expected: $A8
334334
lda AUD0CTLB
335-
sta _g_results + 9 ; #3: CH0 CTLB
335+
sta _g_results + 9 ; #3: CH0 CTLB Expected: $30 or $34
336336
lda AUD3OUT
337-
sta _g_results + 10 ; #4: CH3 OUT
337+
sta _g_results + 10 ; #4: CH3 OUT Expected: $10
338338
rts
339339

340340
@fail:
@@ -406,7 +406,7 @@
406406

407407
; capture OUT just before the prescaler change
408408
lda AUD0OUT
409-
sta _g_results + 11
409+
sta _g_results + 11 ; Expected: $00
410410

411411
; set prescaler to $5
412412
lda #(ENABLE_RELOAD | ENABLE_COUNT | $05)
@@ -427,7 +427,7 @@
427427
sta AUD0CTLA
428428

429429
lda AUD0OUT
430-
sta _g_results + 12
430+
sta _g_results + 12 ; Expected: $FD
431431
rts
432432
.endproc
433433

@@ -488,7 +488,7 @@
488488

489489
; capture OUT just before changing feedback taps
490490
lda AUD0OUT
491-
sta _g_results + 13
491+
sta _g_results + 13 ; Expected: $EE
492492

493493
; -------- change feedback taps --------
494494
lda #$55
@@ -512,7 +512,7 @@
512512
sta AUD0CTLA
513513

514514
lda AUD0OUT
515-
sta _g_results + 14
515+
sta _g_results + 14 ; Expected: $EB
516516
rts
517517
.endproc
518518

@@ -573,7 +573,7 @@
573573

574574
; capture OUT just before changing LFSR
575575
lda AUD0OUT
576-
sta _g_results + 15
576+
sta _g_results + 15 ; Expected: $D0
577577

578578
; -------- change LFSR state --------
579579
lda #$11
@@ -595,7 +595,7 @@
595595
sta AUD0CTLA
596596

597597
lda AUD0OUT
598-
sta _g_results + 16
598+
sta _g_results + 16 ; Expected: $D3
599599
rts
600600
.endproc
601601

@@ -667,7 +667,7 @@
667667

668668
@fail_7:
669669
lda #$FF
670-
sta _g_results + 17
670+
sta _g_results + 17 ; Expected: $2B (or $FF on failure)
671671
rts
672672
.endproc
673673

cpu/main.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "util.h"
66

77
#define RESULT_COUNT 18
8-
#define TEST_COUNT 7
8+
#define TEST_COUNT 8
99

1010
extern void run_tests(void);
1111
static void init(void);
@@ -18,12 +18,10 @@ extern volatile uint8_t g_results[RESULT_COUNT];
1818
static const expected_result_t k_expected_results[RESULT_COUNT] =
1919
{
2020
/* Test 1: SEI/CLI IRQ latency */
21-
EXPECT(0x01), /* CLI: INC ran before IRQ (value = 1) */
22-
EXPECT(0x01), /* IRQ was actually taken */
21+
EXPECT(0x00), /* Pass=0, 1=INC fail, 2=IRQ not taken */
2322

2423
/* Test 2: D flag cleared on interrupt */
25-
EXPECT(0x00), /* D flag should be cleared in IRQ handler */
26-
EXPECT(0x08), /* D flag should be restored after RTI */
24+
EXPECT(0x00), /* Pass=0, 1=D not cleared, 2=D not restored */
2725

2826
/* Test 3: BCD arithmetic and flags */
2927
EXPECT(0x52), /* 0x29 + 0x23 = 0x52 in BCD */
@@ -48,20 +46,25 @@ static const expected_result_t k_expected_results[RESULT_COUNT] =
4846
EXPECT(0x01), /* SMB0: bit 0 set */
4947
EXPECT(0x01), /* BBR0: branch taken */
5048
EXPECT(0x01), /* BBS0: branch taken */
49+
50+
/* Test 8: 1-byte illegal NOPs don't acknowledge IRQs */
51+
EXPECT(0x00), /* Pass=0, non-zero=PC low byte where IRQ fired */
52+
EXPECT(0x00), /* Pass=0 (IRQ inside block), 1=fail */
5153
};
5254

53-
static const uint8_t k_test_offsets[TEST_COUNT] = { 0, 2, 4, 9, 11, 12, 14 };
54-
static const uint8_t k_test_counts[TEST_COUNT] = { 2, 2, 5, 2, 1, 2, 4 };
55+
static const uint8_t k_test_offsets[TEST_COUNT] = { 0, 1, 2, 7, 9, 10, 12, 16 };
56+
static const uint8_t k_test_counts[TEST_COUNT] = { 1, 1, 5, 2, 1, 2, 4, 2 };
5557

5658
static const char* k_test_names[TEST_COUNT] =
5759
{
5860
"SEI/CLI",
5961
"D FLAG IRQ",
60-
"BCD",
62+
"BCD MATH",
6163
"BRK 2 BYTES",
6264
"JMP IND FIX",
63-
"ILLEGAL OPS",
65+
"UNDOC NOPS",
6466
"RMB/SMB/BBx",
67+
"UNDC NOP IRQ",
6568
};
6669

6770
void main(void)

0 commit comments

Comments
 (0)