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:
Klaus2m5 2017-12-07 16:49:40 +01:00
parent f54e9a77ef
commit fe99e56162
7 changed files with 12207 additions and 11383 deletions

View File

@ -21,7 +21,7 @@
; addressing modes with focus on propper setting of the processor status ; addressing modes with focus on propper setting of the processor status
; register bits. ; register bits.
; ;
; version 21-oct-2015 ; version 04-dec-2017
; contact info at http://2m5.de or email K@2m5.de ; contact info at http://2m5.de or email K@2m5.de
; ;
; assembled with AS65 from http://www.kingswood-consulting.co.uk/assemblers/ ; 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 ; 24-aug-2015 all self modifying immediate opcodes now execute in data RAM
; added small branch offset pretest ; added small branch offset pretest
; 21-oct-2015 added option to disable decimal mode ADC & SBC tests ; 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 ; 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 ; break & return from interrupt
if ROM_vectors = 1 if ROM_vectors = 1
set_stat 0 load_flag 0 ;with interrupts enabled if allowed!
pha
lda #'B' lda #'B'
ldx #'R' ldx #'R'
ldy #'K' ;N=0, V=0, Z=0, C=0 ldy #'K'
plp ;N=0, V=0, Z=0, C=0
brk brk
else else
lda #hi brk_ret ;emulated break lda #hi brk_ret0 ;emulated break
pha pha
lda #lo brk_ret lda #lo brk_ret0
pha pha
lda #fao ;set break & unused on stack load_flag fao ;set break & unused on stack
pha
load_flag intdis ;during interrupt
pha pha
set_stat intdis
lda #'B' lda #'B'
ldx #'R' 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 jmp irq_trap
endif endif
dey ;should not be executed 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 php ;either SP or Y count will fail, if we do not hit
dey dey
dey 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 trap_ne
cpx #('R'+1) cpx #'R'+1
trap_ne trap_ne
cpy #('K'-6) cpy #'K'-6
trap_ne trap_ne
pla ;returned flags OK (unchanged)? pla ;returned flags OK (unchanged)?
cmp_flag 0 cmp_flag 0
@ -1644,6 +1652,47 @@ brk_ret ;address of break return
tsx ;sp? tsx ;sp?
cpx #$ff cpx #$ff
trap_ne 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 next_test
; test set and clear flags CLC CLI CLD CLV SEC SEI SED ; 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 eor #$aa ;N=1, V=1, Z=0, C=1
jmp (ptr_ind_ret) jmp (ptr_ind_ret)
trap ;runover protection trap ;runover protection
jmp start ;catastrophic error - cannot continue
; target for the jump subroutine test ; target for the jump subroutine test
dey dey
@ -5848,12 +5898,15 @@ test_jsr
eor #$aa ;N=1, V=1, Z=0, C=1 eor #$aa ;N=1, V=1, Z=0, C=1
rts rts
trap ;runover protection trap ;runover protection
jmp start ;catastrophic error - cannot continue
;trap in case of unexpected IRQ, NMI, BRK, RESET - BRK test target ;trap in case of unexpected IRQ, NMI, BRK, RESET - BRK test target
nmi_trap nmi_trap
trap ;check stack for conditions at NMI trap ;check stack for conditions at NMI
jmp start ;catastrophic error - cannot continue
res_trap res_trap
trap ;unexpected RESET trap ;unexpected RESET
jmp start ;catastrophic error - cannot continue
dey dey
dey dey
@ -5862,41 +5915,81 @@ irq_trap ;BRK test or unextpected BRK or IRQ
dey dey
dey 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 ;check stack for BREAK and originating location
;possible jump/branch into weeds (uninitialized space) ;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 trap_ne
cpx #'R' cpx #'R'
trap_ne trap_ne
cpy #('K'-3) cpy #'K'-3
trap_ne trap_ne
sta irq_a ;save registers during break test sta irq_a ;save registers during break test
stx irq_x stx irq_x
tsx ;test break on stack tsx ;test break on stack
lda $102,x 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 trap_ne ; - no break flag on stack
pla pla
cmp #fai ;should have added interrupt disable cmp_flag intdis ;should have added interrupt disable
trap_ne trap_ne
tsx tsx
cpx #$fc ;sp -3? (return addr, flags) cpx #$fc ;sp -3? (return addr, flags)
trap_ne trap_ne
lda $1ff ;propper return on stack lda $1ff ;propper return on stack
cmp #hi(brk_ret) cmp #hi(brk_ret0)
trap_ne trap_ne
lda $1fe lda $1fe
cmp #lo(brk_ret) cmp #lo(brk_ret0)
trap_ne trap_ne
set_stat $ff load_flag $ff
pha
ldx irq_x ldx irq_x
inx ;return registers with modifications inx ;return registers with modifications
lda irq_a 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 rti
trap ;runover protection 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 if report = 1
include "report.i65" include "report.i65"
endif endif

View File

@ -20,9 +20,9 @@
; This program is designed to test all additional 65C02 opcodes, addressing ; This program is designed to test all additional 65C02 opcodes, addressing
; modes and functionality not available in the NMOS version of the 6502. ; modes and functionality not available in the NMOS version of the 6502.
; The 6502_functional_test is a prerequisite to this test. ; 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 ; contact info at http://2m5.de or email K@2m5.de
; ;
; assembled with AS65 from http://www.kingswood-consulting.co.uk/assemblers/ ; 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 ; 24-aug-2015 all self modifying immediate opcodes now execute in data RAM
; 28-aug-2015 fixed decimal adc/sbc immediate only testing carry ; 28-aug-2015 fixed decimal adc/sbc immediate only testing carry
; 09-feb-2017 fixed RMB/SMB tested when they shouldn't be tested ; 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 ; 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) ;(0=test as NOPs, 1=full test, >1=no test)
rkwl_wdc_op = 1 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 errors through I/O channel (0=use standard self trap loops, 1=include
;report.i65 as I/O channel, add 3 kB) ;report.i65 as I/O channel, add 3 kB)
report = 0 report = 0
@ -552,6 +560,9 @@ test_num = test_num + 1
bss ;uninitialized segment, copy of data at end of code! bss ;uninitialized segment, copy of data at end of code!
endif endif
org zero_page org zero_page
;break test interrupt save
irq_a ds 1 ;a register
irq_x ds 1 ;x register
if I_flag = 2 if I_flag = 2
;masking for I bit in status ;masking for I bit in status
flag_I_on ds 1 ;or mask to load flags flag_I_on ds 1 ;or mask to load flags
@ -1131,7 +1142,8 @@ nop_test macro ;\1 = opcode, \2 = # of bytes
cpx #0 cpx #0
trap_ne ;x changed trap_ne ;x changed
endm endm
if skip_nop = 0
nop_test $02,2 nop_test $02,2
nop_test $22,2 nop_test $22,2
nop_test $42,2 nop_test $42,2
@ -1215,6 +1227,7 @@ nop_test macro ;\1 = opcode, \2 = # of bytes
nop_test $db,1 nop_test $db,1
endif endif
next_test next_test
endif
; jump indirect (test page cross bug is fixed) ; jump indirect (test page cross bug is fixed)
ldx #3 ;prepare table ldx #3 ;prepare table
@ -1310,10 +1323,59 @@ jxp_ok
if ROM_vectors = 1 if ROM_vectors = 1
; test BRK clears decimal mode ; 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 brk
nop dey ;should not be executed
brk_ret 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 next_test
endif endif
@ -2534,6 +2596,7 @@ test_ji
nop nop
nop nop
trap ;runover protection trap ;runover protection
jmp start ;catastrophic error - cannot continue
; target for the jump indirect test ; target for the jump indirect test
jxi_adr dw trap_ind jxi_adr dw trap_ind
@ -2578,6 +2641,7 @@ test_jxi
nop nop
nop nop
trap ;runover protection trap ;runover protection
jmp start ;catastrophic error - cannot continue
; JMP (abs,x) with bad x ; JMP (abs,x) with bad x
nop nop
@ -2586,33 +2650,96 @@ trap_ind
nop nop
nop nop
trap ;near miss indexed indirect jump trap ;near miss indexed indirect jump
jmp start ;catastrophic error - cannot continue
;trap in case of unexpected IRQ, NMI, BRK, RESET ;trap in case of unexpected IRQ, NMI, BRK, RESET
nmi_trap nmi_trap
trap ;check stack for conditions at NMI trap ;check stack for conditions at NMI
jmp start ;catastrophic error - cannot continue
res_trap res_trap
trap ;unexpected RESET trap ;unexpected RESET
irq_trap jmp start ;catastrophic error - cannot continue
php ;save decimal flag
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 tsx ;test break on stack
lda $102,x lda $102,x
and #break cmp_flag 0 ;break test should have B=1 & unused=1 on stack
trap_eq ;check stack for conditions at IRQ trap_ne ;possible no break flag on stack
if ROM_vectors = 1 pla
pla ;test decimal mode cleared cmp_flag intdis ;should have added interrupt disable
and #decmode trap_ne
trap_ne ;decimal mode not cleared after BRK tsx
plp ;pop saved flags cpx #$fc ;sp -3? (return addr, flags)
pla ;return address low trap_ne
cmp #lo(brk_ret) lda $1ff ;propper return on stack
trap_ne ;unexpected BRK cmp #hi(brk_ret0)
pla ;return address high trap_ne
cmp #hi(brk_ret) lda $1fe
trap_ne ;unexpected BRK cmp #lo(brk_ret0)
jmp brk_ret trap_ne
else load_flag $ff
trap_ne ;check stack for conditions at BRK pha
endif 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 if report = 1
include "report.i65" include "report.i65"

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -78,6 +78,8 @@ rabs jsr rspace
;ask to continue ;ask to continue
rprt rmsg_cont rprt rmsg_cont
rerr1 jsr rget rerr1 jsr rget
cmp #'S'
beq rskip
cmp #'C' cmp #'C'
bne rerr1 bne rerr1
;restore registers ;restore registers
@ -87,7 +89,44 @@ rerr1 jsr rget
tax tax
pla pla
plp 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 ;show test has ended, ask to repeat
report_success report_success
@ -117,7 +156,8 @@ rget ;get character in A
; and #8 ; and #8
; beq rget1 ; beq rget1
;not a real ACIA - so RDRF is not checked ;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 ;the load can be replaced by a call to a kernal routine
; jsr $ffcf ;example: CHRIN for a C64 ; jsr $ffcf ;example: CHRIN for a C64
cmp #'a' ;lower case cmp #'a' ;lower case
@ -159,7 +199,8 @@ rchar ;report character in A
; beq rchar1 ; beq rchar1
; pla ; pla
;not a real ACIA - so TDRF is not checked ;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 ;the store can be replaced by a call to a kernal routine
; jsr $ffd2 ;example: CHROUT for a C64 ; jsr $ffd2 ;example: CHROUT for a C64
rts rts
@ -169,7 +210,7 @@ rmsg_start
rmsg_stack rmsg_stack
db 10,13,"regs Y X A PS PCLPCH",10,13,0 db 10,13,"regs Y X A PS PCLPCH",10,13,0
rmsg_cont 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 rmsg_success
db 10,13,"All tests completed, press R to repeat",10,13,0 db 10,13,"All tests completed, press R to repeat",10,13,0
if rep_int = 1 if rep_int = 1