mirror of
https://github.com/Klaus2m5/6502_65C02_functional_tests.git
synced 2025-01-17 23:31:38 +00:00
fixed BRK not tested with interrupts disabled
added option to skip the remainder of a failing test in report.i65 added otion to skip undefined opcode as NOP test for the 65C02 replaced binaries with the current version of the test
This commit is contained in:
parent
f54e9a77ef
commit
fe99e56162
@ -21,7 +21,7 @@
|
||||
; addressing modes with focus on propper setting of the processor status
|
||||
; register bits.
|
||||
;
|
||||
; version 21-oct-2015
|
||||
; version 04-dec-2017
|
||||
; contact info at http://2m5.de or email K@2m5.de
|
||||
;
|
||||
; assembled with AS65 from http://www.kingswood-consulting.co.uk/assemblers/
|
||||
@ -73,6 +73,9 @@
|
||||
; 24-aug-2015 all self modifying immediate opcodes now execute in data RAM
|
||||
; added small branch offset pretest
|
||||
; 21-oct-2015 added option to disable decimal mode ADC & SBC tests
|
||||
; 04-dec-2017 fixed BRK only tested with interrupts enabled
|
||||
; added option to skip the remainder of a failing test
|
||||
; in report.i65
|
||||
|
||||
|
||||
; C O N F I G U R A T I O N
|
||||
@ -1608,35 +1611,40 @@ jsr_ret = *-1 ;last address of jsr = return address
|
||||
|
||||
; break & return from interrupt
|
||||
if ROM_vectors = 1
|
||||
set_stat 0
|
||||
load_flag 0 ;with interrupts enabled if allowed!
|
||||
pha
|
||||
lda #'B'
|
||||
ldx #'R'
|
||||
ldy #'K' ;N=0, V=0, Z=0, C=0
|
||||
ldy #'K'
|
||||
plp ;N=0, V=0, Z=0, C=0
|
||||
brk
|
||||
else
|
||||
lda #hi brk_ret ;emulated break
|
||||
lda #hi brk_ret0 ;emulated break
|
||||
pha
|
||||
lda #lo brk_ret
|
||||
lda #lo brk_ret0
|
||||
pha
|
||||
lda #fao ;set break & unused on stack
|
||||
load_flag fao ;set break & unused on stack
|
||||
pha
|
||||
load_flag intdis ;during interrupt
|
||||
pha
|
||||
set_stat intdis
|
||||
lda #'B'
|
||||
ldx #'R'
|
||||
ldy #'K' ;N=0, V=0, Z=0, C=0
|
||||
ldy #'K'
|
||||
plp ;N=0, V=0, Z=0, C=0
|
||||
jmp irq_trap
|
||||
endif
|
||||
dey ;should not be executed
|
||||
brk_ret ;address of break return
|
||||
brk_ret0 ;address of break return
|
||||
php ;either SP or Y count will fail, if we do not hit
|
||||
dey
|
||||
dey
|
||||
dey
|
||||
cmp #('B'^$aa) ;returned registers OK?
|
||||
cmp #'B'^$aa ;returned registers OK?
|
||||
;the IRQ vector was never executed if A & X stay unmodified
|
||||
trap_ne
|
||||
cpx #('R'+1)
|
||||
cpx #'R'+1
|
||||
trap_ne
|
||||
cpy #('K'-6)
|
||||
cpy #'K'-6
|
||||
trap_ne
|
||||
pla ;returned flags OK (unchanged)?
|
||||
cmp_flag 0
|
||||
@ -1644,6 +1652,47 @@ brk_ret ;address of break return
|
||||
tsx ;sp?
|
||||
cpx #$ff
|
||||
trap_ne
|
||||
if ROM_vectors = 1
|
||||
load_flag $ff ;with interrupts disabled if allowed!
|
||||
pha
|
||||
lda #$ff-'B'
|
||||
ldx #$ff-'R'
|
||||
ldy #$ff-'K'
|
||||
plp ;N=1, V=1, Z=1, C=1
|
||||
brk
|
||||
else
|
||||
lda #hi brk_ret1 ;emulated break
|
||||
pha
|
||||
lda #lo brk_ret1
|
||||
pha
|
||||
load_flag $ff
|
||||
pha ;set break & unused on stack
|
||||
pha ;actual flags
|
||||
lda #$ff-'B'
|
||||
ldx #$ff-'R'
|
||||
ldy #$ff-'K'
|
||||
plp ;N=1, V=1, Z=1, C=1
|
||||
jmp irq_trap
|
||||
endif
|
||||
dey ;should not be executed
|
||||
brk_ret1 ;address of break return
|
||||
php ;either SP or Y count will fail, if we do not hit
|
||||
dey
|
||||
dey
|
||||
dey
|
||||
cmp #($ff-'B')^$aa ;returned registers OK?
|
||||
;the IRQ vector was never executed if A & X stay unmodified
|
||||
trap_ne
|
||||
cpx #$ff-'R'+1
|
||||
trap_ne
|
||||
cpy #$ff-'K'-6
|
||||
trap_ne
|
||||
pla ;returned flags OK (unchanged)?
|
||||
cmp_flag $ff
|
||||
trap_ne
|
||||
tsx ;sp?
|
||||
cpx #$ff
|
||||
trap_ne
|
||||
next_test
|
||||
|
||||
; test set and clear flags CLC CLI CLD CLV SEC SEI SED
|
||||
@ -5808,6 +5857,7 @@ test_ind
|
||||
eor #$aa ;N=1, V=1, Z=0, C=1
|
||||
jmp (ptr_ind_ret)
|
||||
trap ;runover protection
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
|
||||
; target for the jump subroutine test
|
||||
dey
|
||||
@ -5848,12 +5898,15 @@ test_jsr
|
||||
eor #$aa ;N=1, V=1, Z=0, C=1
|
||||
rts
|
||||
trap ;runover protection
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
|
||||
;trap in case of unexpected IRQ, NMI, BRK, RESET - BRK test target
|
||||
nmi_trap
|
||||
trap ;check stack for conditions at NMI
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
res_trap
|
||||
trap ;unexpected RESET
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
|
||||
dey
|
||||
dey
|
||||
@ -5862,41 +5915,81 @@ irq_trap ;BRK test or unextpected BRK or IRQ
|
||||
dey
|
||||
dey
|
||||
dey
|
||||
;next 4 traps could be caused by unexpected BRK or IRQ
|
||||
;next traps could be caused by unexpected BRK or IRQ
|
||||
;check stack for BREAK and originating location
|
||||
;possible jump/branch into weeds (uninitialized space)
|
||||
cmp #'B' ;registers loaded?
|
||||
cmp #$ff-'B' ;BRK pass 2 registers loaded?
|
||||
beq break2
|
||||
cmp #'B' ;BRK pass 1 registers loaded?
|
||||
trap_ne
|
||||
cpx #'R'
|
||||
trap_ne
|
||||
cpy #('K'-3)
|
||||
cpy #'K'-3
|
||||
trap_ne
|
||||
sta irq_a ;save registers during break test
|
||||
stx irq_x
|
||||
tsx ;test break on stack
|
||||
lda $102,x
|
||||
cmp_flag 0 ;break test should have B=1
|
||||
cmp_flag 0 ;break test should have B=1 & unused=1 on stack
|
||||
trap_ne ; - no break flag on stack
|
||||
pla
|
||||
cmp #fai ;should have added interrupt disable
|
||||
cmp_flag intdis ;should have added interrupt disable
|
||||
trap_ne
|
||||
tsx
|
||||
cpx #$fc ;sp -3? (return addr, flags)
|
||||
trap_ne
|
||||
lda $1ff ;propper return on stack
|
||||
cmp #hi(brk_ret)
|
||||
cmp #hi(brk_ret0)
|
||||
trap_ne
|
||||
lda $1fe
|
||||
cmp #lo(brk_ret)
|
||||
cmp #lo(brk_ret0)
|
||||
trap_ne
|
||||
set_stat $ff
|
||||
load_flag $ff
|
||||
pha
|
||||
ldx irq_x
|
||||
inx ;return registers with modifications
|
||||
lda irq_a
|
||||
eor #$aa ;N=1, V=1, Z=0, C=1 but original flags should be restored
|
||||
eor #$aa
|
||||
plp ;N=1, V=1, Z=1, C=1 but original flags should be restored
|
||||
rti
|
||||
trap ;runover protection
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
|
||||
break2 ;BRK pass 2
|
||||
cpx #$ff-'R'
|
||||
trap_ne
|
||||
cpy #$ff-'K'-3
|
||||
trap_ne
|
||||
sta irq_a ;save registers during break test
|
||||
stx irq_x
|
||||
tsx ;test break on stack
|
||||
lda $102,x
|
||||
cmp_flag $ff ;break test should have B=1
|
||||
trap_ne ; - no break flag on stack
|
||||
pla
|
||||
ora #decmode ;ignore decmode cleared if 65c02
|
||||
cmp_flag $ff ;actual passed flags
|
||||
trap_ne
|
||||
tsx
|
||||
cpx #$fc ;sp -3? (return addr, flags)
|
||||
trap_ne
|
||||
lda $1ff ;propper return on stack
|
||||
cmp #hi(brk_ret1)
|
||||
trap_ne
|
||||
lda $1fe
|
||||
cmp #lo(brk_ret1)
|
||||
trap_ne
|
||||
load_flag intdis
|
||||
pha
|
||||
ldx irq_x
|
||||
inx ;return registers with modifications
|
||||
lda irq_a
|
||||
eor #$aa
|
||||
plp ;N=0, V=0, Z=0, C=0 but original flags should be restored
|
||||
rti
|
||||
trap ;runover protection
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
|
||||
if report = 1
|
||||
include "report.i65"
|
||||
endif
|
||||
|
@ -20,9 +20,9 @@
|
||||
; This program is designed to test all additional 65C02 opcodes, addressing
|
||||
; modes and functionality not available in the NMOS version of the 6502.
|
||||
; The 6502_functional_test is a prerequisite to this test.
|
||||
; NMI, IRQ, BRK, STP & WAI are covered in the 6502_interrupt_test.
|
||||
; NMI, IRQ, STP & WAI are covered in the 6502_interrupt_test.
|
||||
;
|
||||
; version 09-feb-2017
|
||||
; version 04-dec-2017
|
||||
; contact info at http://2m5.de or email K@2m5.de
|
||||
;
|
||||
; assembled with AS65 from http://www.kingswood-consulting.co.uk/assemblers/
|
||||
@ -65,6 +65,10 @@
|
||||
; 24-aug-2015 all self modifying immediate opcodes now execute in data RAM
|
||||
; 28-aug-2015 fixed decimal adc/sbc immediate only testing carry
|
||||
; 09-feb-2017 fixed RMB/SMB tested when they shouldn't be tested
|
||||
; 04-dec-2017 fixed BRK not tested for actually going through the IRQ vector
|
||||
; added option to skip the remainder of a failing test
|
||||
; in report.i65
|
||||
; added skip override to undefined opcode as NOP test
|
||||
|
||||
|
||||
; C O N F I G U R A T I O N
|
||||
@ -106,6 +110,10 @@ wdc_op = 1
|
||||
;(0=test as NOPs, 1=full test, >1=no test)
|
||||
rkwl_wdc_op = 1
|
||||
|
||||
;skip testing all undefined opcodes override
|
||||
;0=test as NOP, >0=skip
|
||||
skip_nop = 0
|
||||
|
||||
;report errors through I/O channel (0=use standard self trap loops, 1=include
|
||||
;report.i65 as I/O channel, add 3 kB)
|
||||
report = 0
|
||||
@ -552,6 +560,9 @@ test_num = test_num + 1
|
||||
bss ;uninitialized segment, copy of data at end of code!
|
||||
endif
|
||||
org zero_page
|
||||
;break test interrupt save
|
||||
irq_a ds 1 ;a register
|
||||
irq_x ds 1 ;x register
|
||||
if I_flag = 2
|
||||
;masking for I bit in status
|
||||
flag_I_on ds 1 ;or mask to load flags
|
||||
@ -1131,7 +1142,8 @@ nop_test macro ;\1 = opcode, \2 = # of bytes
|
||||
cpx #0
|
||||
trap_ne ;x changed
|
||||
endm
|
||||
|
||||
|
||||
if skip_nop = 0
|
||||
nop_test $02,2
|
||||
nop_test $22,2
|
||||
nop_test $42,2
|
||||
@ -1215,6 +1227,7 @@ nop_test macro ;\1 = opcode, \2 = # of bytes
|
||||
nop_test $db,1
|
||||
endif
|
||||
next_test
|
||||
endif
|
||||
|
||||
; jump indirect (test page cross bug is fixed)
|
||||
ldx #3 ;prepare table
|
||||
@ -1310,10 +1323,59 @@ jxp_ok
|
||||
|
||||
if ROM_vectors = 1
|
||||
; test BRK clears decimal mode
|
||||
sed
|
||||
load_flag 0 ;with interrupts enabled if allowed!
|
||||
pha
|
||||
lda #'B'
|
||||
ldx #'R'
|
||||
ldy #'K'
|
||||
plp ;N=0, V=0, Z=0, C=0
|
||||
brk
|
||||
nop
|
||||
brk_ret
|
||||
dey ;should not be executed
|
||||
brk_ret0 ;address of break return
|
||||
php ;either SP or Y count will fail, if we do not hit
|
||||
dey
|
||||
dey
|
||||
dey
|
||||
cmp #'B'^$aa ;returned registers OK?
|
||||
;the IRQ vector was never executed if A & X stay unmodified
|
||||
trap_ne
|
||||
cpx #'R'+1
|
||||
trap_ne
|
||||
cpy #'K'-6
|
||||
trap_ne
|
||||
pla ;returned flags OK (unchanged)?
|
||||
cmp_flag 0
|
||||
trap_ne
|
||||
tsx ;sp?
|
||||
cpx #$ff
|
||||
trap_ne
|
||||
;pass 2
|
||||
load_flag $ff ;with interrupts disabled if allowed!
|
||||
pha
|
||||
lda #$ff-'B'
|
||||
ldx #$ff-'R'
|
||||
ldy #$ff-'K'
|
||||
plp ;N=1, V=1, Z=1, C=1
|
||||
brk
|
||||
dey ;should not be executed
|
||||
brk_ret1 ;address of break return
|
||||
php ;either SP or Y count will fail, if we do not hit
|
||||
dey
|
||||
dey
|
||||
dey
|
||||
cmp #($ff-'B')^$aa ;returned registers OK?
|
||||
;the IRQ vector was never executed if A & X stay unmodified
|
||||
trap_ne
|
||||
cpx #$ff-'R'+1
|
||||
trap_ne
|
||||
cpy #$ff-'K'-6
|
||||
trap_ne
|
||||
pla ;returned flags OK (unchanged)?
|
||||
cmp_flag $ff
|
||||
trap_ne
|
||||
tsx ;sp?
|
||||
cpx #$ff
|
||||
trap_ne
|
||||
next_test
|
||||
endif
|
||||
|
||||
@ -2534,6 +2596,7 @@ test_ji
|
||||
nop
|
||||
nop
|
||||
trap ;runover protection
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
|
||||
; target for the jump indirect test
|
||||
jxi_adr dw trap_ind
|
||||
@ -2578,6 +2641,7 @@ test_jxi
|
||||
nop
|
||||
nop
|
||||
trap ;runover protection
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
|
||||
; JMP (abs,x) with bad x
|
||||
nop
|
||||
@ -2586,33 +2650,96 @@ trap_ind
|
||||
nop
|
||||
nop
|
||||
trap ;near miss indexed indirect jump
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
|
||||
;trap in case of unexpected IRQ, NMI, BRK, RESET
|
||||
nmi_trap
|
||||
trap ;check stack for conditions at NMI
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
res_trap
|
||||
trap ;unexpected RESET
|
||||
irq_trap
|
||||
php ;save decimal flag
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
|
||||
dey
|
||||
dey
|
||||
irq_trap ;BRK test or unextpected BRK or IRQ
|
||||
php ;either SP or Y count will fail, if we do not hit
|
||||
dey
|
||||
dey
|
||||
dey
|
||||
;next traps could be caused by unexpected BRK or IRQ
|
||||
;check stack for BREAK and originating location
|
||||
;possible jump/branch into weeds (uninitialized space)
|
||||
cmp #$ff-'B' ;BRK pass 2 registers loaded?
|
||||
beq break2
|
||||
cmp #'B' ;BRK pass 1 registers loaded?
|
||||
trap_ne
|
||||
cpx #'R'
|
||||
trap_ne
|
||||
cpy #'K'-3
|
||||
trap_ne
|
||||
sta irq_a ;save registers during break test
|
||||
stx irq_x
|
||||
tsx ;test break on stack
|
||||
lda $102,x
|
||||
and #break
|
||||
trap_eq ;check stack for conditions at IRQ
|
||||
if ROM_vectors = 1
|
||||
pla ;test decimal mode cleared
|
||||
and #decmode
|
||||
trap_ne ;decimal mode not cleared after BRK
|
||||
plp ;pop saved flags
|
||||
pla ;return address low
|
||||
cmp #lo(brk_ret)
|
||||
trap_ne ;unexpected BRK
|
||||
pla ;return address high
|
||||
cmp #hi(brk_ret)
|
||||
trap_ne ;unexpected BRK
|
||||
jmp brk_ret
|
||||
else
|
||||
trap_ne ;check stack for conditions at BRK
|
||||
endif
|
||||
cmp_flag 0 ;break test should have B=1 & unused=1 on stack
|
||||
trap_ne ;possible no break flag on stack
|
||||
pla
|
||||
cmp_flag intdis ;should have added interrupt disable
|
||||
trap_ne
|
||||
tsx
|
||||
cpx #$fc ;sp -3? (return addr, flags)
|
||||
trap_ne
|
||||
lda $1ff ;propper return on stack
|
||||
cmp #hi(brk_ret0)
|
||||
trap_ne
|
||||
lda $1fe
|
||||
cmp #lo(brk_ret0)
|
||||
trap_ne
|
||||
load_flag $ff
|
||||
pha
|
||||
ldx irq_x
|
||||
inx ;return registers with modifications
|
||||
lda irq_a
|
||||
eor #$aa
|
||||
plp ;N=1, V=1, Z=1, C=1 but original flags should be restored
|
||||
rti
|
||||
trap ;runover protection
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
|
||||
break2 ;BRK pass 2
|
||||
cpx #$ff-'R'
|
||||
trap_ne
|
||||
cpy #$ff-'K'-3
|
||||
trap_ne
|
||||
sta irq_a ;save registers during break test
|
||||
stx irq_x
|
||||
tsx ;test break on stack
|
||||
lda $102,x
|
||||
cmp_flag $ff ;break test should have B=1
|
||||
trap_ne ;possibly no break flag on stack
|
||||
pla
|
||||
cmp_flag $ff-decmode ;actual passed flags should have decmode cleared
|
||||
trap_ne
|
||||
tsx
|
||||
cpx #$fc ;sp -3? (return addr, flags)
|
||||
trap_ne
|
||||
lda $1ff ;propper return on stack
|
||||
cmp #hi(brk_ret1)
|
||||
trap_ne
|
||||
lda $1fe
|
||||
cmp #lo(brk_ret1)
|
||||
trap_ne
|
||||
load_flag intdis
|
||||
pha
|
||||
ldx irq_x
|
||||
inx ;return registers with modifications
|
||||
lda irq_a
|
||||
eor #$aa
|
||||
plp ;N=0, V=0, Z=0, C=0 but original flags should be restored
|
||||
rti
|
||||
trap ;runover protection
|
||||
jmp start ;catastrophic error - cannot continue
|
||||
|
||||
if report = 1
|
||||
include "report.i65"
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
49
report.i65
49
report.i65
@ -78,6 +78,8 @@ rabs jsr rspace
|
||||
;ask to continue
|
||||
rprt rmsg_cont
|
||||
rerr1 jsr rget
|
||||
cmp #'S'
|
||||
beq rskip
|
||||
cmp #'C'
|
||||
bne rerr1
|
||||
;restore registers
|
||||
@ -87,7 +89,44 @@ rerr1 jsr rget
|
||||
tax
|
||||
pla
|
||||
plp
|
||||
rts
|
||||
rts
|
||||
;skip the current test
|
||||
rskip lda #$f0 ;already end of tests?
|
||||
cmp test_case
|
||||
beq rerr1 ;skip is not available
|
||||
ldx #$ff ;clear stack
|
||||
txs
|
||||
inc test_case ;next test
|
||||
lda #lo(start) ;find begin of test
|
||||
sta zpt
|
||||
lda #hi(start)
|
||||
sta zpt+1
|
||||
rskipl1 ldy #4 ;search pattern
|
||||
rskipl2 lda (zpt),y ;next byte
|
||||
cmp rmark,y
|
||||
bne rskipnx ;no match
|
||||
dey
|
||||
bmi rskipf ;found pattern
|
||||
cpy #1 ;skip immediate value
|
||||
bne rskipl2
|
||||
dey
|
||||
beq rskipl2
|
||||
|
||||
rskipnx inc zpt ;next RAM location
|
||||
bne rskipl1
|
||||
inc zpt+1
|
||||
bne rskipl1
|
||||
|
||||
rskipf ldy #1 ;pattern found - check test number
|
||||
lda (zpt),y ;test number
|
||||
cmp #$f0 ;end of last test?
|
||||
beq rskipe ;ask to rerun all
|
||||
cmp test_case ;is next test?
|
||||
bne rskipnx ;continue searching
|
||||
rskipe jmp (zpt) ;start next test or rerun at end of tests
|
||||
|
||||
rmark lda #0 ;begin of test search pattern
|
||||
sta test_case
|
||||
|
||||
;show test has ended, ask to repeat
|
||||
report_success
|
||||
@ -117,7 +156,8 @@ rget ;get character in A
|
||||
; and #8
|
||||
; beq rget1
|
||||
;not a real ACIA - so RDRF is not checked
|
||||
lda $bff0 ;read acia rx reg
|
||||
; lda $bff0 ;read acia rx reg
|
||||
lda $f004 ;Kowalski simulator default
|
||||
;the load can be replaced by a call to a kernal routine
|
||||
; jsr $ffcf ;example: CHRIN for a C64
|
||||
cmp #'a' ;lower case
|
||||
@ -159,7 +199,8 @@ rchar ;report character in A
|
||||
; beq rchar1
|
||||
; pla
|
||||
;not a real ACIA - so TDRF is not checked
|
||||
sta $bff0 ;write acia tx reg
|
||||
; sta $bff0 ;write acia tx reg
|
||||
sta $f001 ;Kowalski simulator default
|
||||
;the store can be replaced by a call to a kernal routine
|
||||
; jsr $ffd2 ;example: CHROUT for a C64
|
||||
rts
|
||||
@ -169,7 +210,7 @@ rmsg_start
|
||||
rmsg_stack
|
||||
db 10,13,"regs Y X A PS PCLPCH",10,13,0
|
||||
rmsg_cont
|
||||
db 10,13,"press C to continue",10,13,0
|
||||
db 10,13,"press C to continue or S to skip current test",10,13,0
|
||||
rmsg_success
|
||||
db 10,13,"All tests completed, press R to repeat",10,13,0
|
||||
if rep_int = 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user