added switch to disable self modifying tests

allow the object code to be run from ROM
This commit is contained in:
Klaus2m5 2015-08-23 06:35:02 +02:00
parent 22498d2485
commit 053ab877a8
2 changed files with 47 additions and 15 deletions

View File

@ -1,7 +1,7 @@
;
; 6 5 0 2 F U N C T I O N A L T E S T
;
; Copyright (C) 2012-2014 Klaus Dormann
; Copyright (C) 2012-2015 Klaus Dormann
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
; addressing modes with focus on propper setting of the processor status
; register bits.
;
; version 14-dec-2014
; version 23-aug-2015
; contact info at http://2m5.de or email K@2m5.de
;
; assembled with AS65 from http://www.kingswood-consulting.co.uk/assemblers/
@ -69,6 +69,7 @@
; 16-aug-2013 added error report to standard output option
; 13-dec-2014 added binary/decimal opcode table switch test
; 14-dec-2014 improved relative address test
; 23-aug-2015 added option to disable self modifying tests
; C O N F I G U R A T I O N
@ -101,9 +102,13 @@ data_segment = $200
;code_segment memory start address, 13kB of consecutive space required
; add 2.5 kB if I_flag = 2
;parts of the code are self modifying and must reside in RAM
code_segment = $400
;self modifying code may be disabled to allow running in ROM
;0=parts of the code are self modifying and must reside in RAM
;1=tests disabled: branch range, immediate AND, ORA, EOR, ADC & SBC
disable_selfmod = 0
;report errors through I/O channel (0=use standard self trap loops, 1=include
;report.i65 as I/O channel, add 3.5 kB)
report = 0
@ -483,6 +488,7 @@ check_ram macro
lda #0
sta zpt ;set low byte of indirect pointer
sta zpt+3 ;checksum high byte
if disable_selfmod = 0
sta range_adr ;reset self modifying code
sta tandi1
sta tandi2
@ -494,6 +500,7 @@ check_ram macro
sta chkdsbi
sta chkadi
sta chksbi
endif
clc
ldx #zp_bss-zero_page ;zeropage - write test area
ccs3\? adc zero_page,x
@ -697,6 +704,7 @@ ld_vect lda vec_init,x
lda #0
sta zpt ;set low byte of indirect pointer
sta ram_chksm+1 ;checksum high byte
if disable_selfmod = 0
sta range_adr ;reset self modifying code
sta tandi1
sta tandi2
@ -708,6 +716,7 @@ ld_vect lda vec_init,x
sta chkdsbi
sta chkadi
sta chksbi
endif
clc
ldx #zp_bss-zero_page ;zeropage - write test area
gcs3 adc zero_page,x
@ -733,6 +742,7 @@ gcs4 iny
endif
next_test
if disable_selfmod = 0
;testing relative addressing with BEQ
ldy #$fe ;testing maximum range, not -1/-2 (invalid/self adr)
range_loop
@ -1042,6 +1052,7 @@ range_ok
beq range_end
jmp range_loop
range_end ;range test successful
endif
next_test
;partial test BNE & CMP, CPX, CPY immediate
@ -4598,6 +4609,7 @@ tdec17
; testing logical instructions - AND EOR ORA all addressing modes
; AND
if disable_selfmod = 0
ldx #3 ;immediate - self modifying code
tand lda zpAN,x
sta tandi1
@ -4616,7 +4628,8 @@ tandi2 equ *+1 ;target for immediate operand
tst_ax absrlo,absflo,$ff-fnz
dex
bpl tand1
endif
ldx #3 ;zp
tand2 lda zpAN,x
sta zpt
@ -4734,6 +4747,7 @@ tand15
next_test
; EOR
if disable_selfmod = 0
ldx #3 ;immediate - self modifying code
teor lda zpEO,x
sta teori1
@ -4752,7 +4766,8 @@ teori2 equ *+1 ;target for immediate operand
tst_ax absrlo,absflo,$ff-fnz
dex
bpl teor1
endif
ldx #3 ;zp
teor2 lda zpEO,x
sta zpt
@ -4870,6 +4885,7 @@ teor15
next_test
; OR
if disable_selfmod = 0
ldx #3 ;immediate - self modifying code
tora lda zpOR,x
sta torai1
@ -4888,7 +4904,8 @@ torai2 equ *+1 ;target for immediate operand
tst_ax absrlo,absflo,$ff-fnz
dex
bpl tora1
endif
ldx #3 ;zp
tora2 lda zpOR,x
sta zpt
@ -5272,6 +5289,7 @@ chkdad
cmp adrh
trap_ne ;bad carry
plp
if disable_selfmod = 0
; decimal ADC / SBC #
php ;save carry for subtract
lda ad2
@ -5301,6 +5319,7 @@ chkdsbi = * + 1 ;operand of the immediate SBC
cmp adrh
trap_ne ;bad carry
plp
endif
; decimal ADC / SBC zp,x
php ;save carry for subtract
lda ad1
@ -5481,6 +5500,7 @@ ckad1 pla
cmp adrf
trap_ne ;bad flags
plp
if disable_selfmod = 0
; binary ADC / SBC #
php ;save carry for subtract
lda ad2
@ -5510,6 +5530,7 @@ chksbi = * + 1 ;operand of the immediate SBC
cmp adrf
trap_ne ;bad flags
plp
endif
; binary ADC / SBC zp,x
php ;save carry for subtract
lda ad1

View File

@ -1,7 +1,7 @@
;
; 6 5 C 0 2 E X T E N D E D O P C O D E S T E S T
;
; Copyright (C) 2013 Klaus Dormann
; Copyright (C) 2013-2015 Klaus Dormann
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
@ -22,7 +22,7 @@
; The 6502_functional_test is a prerequisite to this test.
; NMI, IRQ, BRK, STP & WAI are covered in the 6502_interrupt_test.
;
; version 16-aug-2013
; version 23-aug-2015
; contact info at http://2m5.de or email K@2m5.de
;
; assembled with AS65 from http://www.kingswood-consulting.co.uk/assemblers/
@ -61,6 +61,7 @@
; 23-jul-2013 fixed BRA out of range due to larger trap macros
; added RAM integrity check
; 16-aug-2013 added error report to standard output option
; 23-aug-2015 added option to disable self modifying tests
; C O N F I G U R A T I O N
@ -93,9 +94,13 @@ data_segment = $200
;code_segment memory start address, 10kB of consecutive space required
; add 1 kB if I_flag = 2
;parts of the code are self modifying and must reside in RAM
code_segment = $400
;self modifying code may be disabled to allow running in ROM
;0=parts of the code are self modifying and must reside in RAM
;1=tests disabled: immediate ADC & SBC decimal
disable_selfmod = 0
;added WDC only opcodes WAI & STP (0=test as NOPs, >0=no test)
wdc_op = 1
@ -368,8 +373,8 @@ set_absx macro ;precharging abs,x & immediate status
;macros to test (register|memory|zeropage) & status & (mask)
tst_stat macro ;testing flags in the processor status register
php ;save status
php ;use stack to retrieve status
pla
pla ;use stack to retrieve status
pha
cmp_flag \1
trap_ne
plp ;restore status
@ -377,10 +382,10 @@ tst_stat macro ;testing flags in the processor status register
tst_a macro ;testing result in accu & flags
php ;save flags
php
cmp #\1 ;test result
trap_ne
pla ;load status
pha
cmp_flag \2
trap_ne
plp ;restore status
@ -389,10 +394,10 @@ tst_a macro ;testing result in accu & flags
tst_as macro ;testing result in accu & flags, save accu
pha
php ;save flags
php
cmp #\1 ;test result
trap_ne
pla ;load status
pha
cmp_flag \2
trap_ne
plp ;restore status
@ -401,10 +406,10 @@ tst_as macro ;testing result in accu & flags, save accu
tst_x macro ;testing result in x index & flags
php ;save flags
php
cpx #\1 ;test result
trap_ne
pla ;load status
pha
cmp_flag \2
trap_ne
plp ;restore status
@ -412,10 +417,10 @@ tst_x macro ;testing result in x index & flags
tst_y macro ;testing result in y index & flags
php ;save flags
php
cpy #\1 ;test result
trap_ne
pla ;load status
pha
cmp_flag \2
trap_ne
plp ;restore status
@ -499,8 +504,10 @@ check_ram macro
ccs1\? sta jxi_tab,x ;JMP indirect page cross area
dex
bpl ccs1\?
if disable_selfmod = 0
sta chkdadi ;self modifying code
sta chkdsbi
endif
clc
ldx #zp_bss-zero_page ;zeropage - write test area
ccs3\? adc zero_page,x
@ -710,8 +717,10 @@ ld_vect lda vec_init,x
gcs1 sta jxi_tab,x ;JMP indirect page cross area
dex
bpl gcs1
if disable_selfmod = 0
sta chkdadi ;self modifying code
sta chkdsbi
endif
clc
ldx #zp_bss-zero_page ;zeropage - write test area
gcs3 adc zero_page,x
@ -2279,6 +2288,7 @@ chkdad
cmp adrf
trap_ne ;bad flags
plp
if disable_selfmod = 0
; decimal ADC / SBC #
php ;save carry for subtract
lda ad2
@ -2308,6 +2318,7 @@ chkdsbi = * + 1 ;operand of the immediate SBC
cmp adrf
trap_ne ;bad flags
plp
endif
; decimal ADC / SBC zp,x
php ;save carry for subtract
lda ad1