6502_65C02_functional_tests/bin_files/6502_functional_test.lst
Klaus2m5 a06e3b95d6 added binaries
Added pre-configured binaries with listing. Loadable from $0000 for full
64k
2013-12-18 11:19:08 +01:00

13999 lines
693 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

AS65 Assembler for R6502 [1.42]. Copyright 1994-2007, Frank A. Kingswood Page 1
---------------------------------------------------- 6502_functional_test.a65 ----------------------------------------------------
5803 lines read, no errors in pass 1.
;
; 6 5 0 2 F U N C T I O N A L T E S T
;
; Copyright (C) 2012-2013 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
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
; This program is designed to test all opcodes of a 6502 emulator using all
; addressing modes with focus on propper setting of the processor status
; register bits.
;
; version 16-aug-2013
; edited to provide a pre-configured bin file loadable at $0000 for full 64k
; contact info at http://2m5.de or email K@2m5.de
;
; assembled with AS65 from http://www.kingswood-consulting.co.uk/assemblers/
; command line switches: -l -m -s2 -w -h0
; | | | | no page headers in listing
; | | | wide listing (133 char/col)
; | | write intel hex file instead of binary
; | expand macros in listing
; generate pass2 listing
;
; No IO - should be run from a monitor with access to registers.
; To run load intel hex image with a load command, than alter PC to 400 hex
; (code_segment) and enter a go command.
; Loop on program counter determines error or successful completion of test.
; Check listing for relevant traps (jump/branch *).
; Please note that in early tests some instructions will have to be used before
; they are actually tested!
;
; RESET, NMI or IRQ should not occur and will be trapped if vectors are enabled.
; Tests documented behavior of the original NMOS 6502 only! No unofficial
; opcodes. Additional opcodes of newer versions of the CPU (65C02, 65816) will
; not be tested. Decimal ops will only be tested with valid BCD operands and
; N V Z flags will be ignored.
;
; Debugging hints:
; Most of the code is written sequentially. if you hit a trap, check the
; immediately preceeding code for the instruction to be tested. Results are
; tested first, flags are checked second by pushing them onto the stack and
; pulling them to the accumulator after the result was checked. The "real"
; flags are no longer valid for the tested instruction at this time!
; If the tested instruction was indexed, the relevant index (X or Y) must
; also be checked. Opposed to the flags, X and Y registers are still valid.
;
; versions:
; 28-jul-2012 1st version distributed for testing
; 29-jul-2012 fixed references to location 0, now #0
; added license - GPLv3
; 30-jul-2012 added configuration options
; 01-aug-2012 added trap macro to allow user to change error handling
; 01-dec-2012 fixed trap in branch field must be a branch
; 02-mar-2013 fixed PLA flags not tested
; 19-jul-2013 allowed ROM vectors to be loaded when load_data_direct = 0
; added test sequence check to detect if tests jump their fence
; 23-jul-2013 added RAM integrity check option
; 16-aug-2013 added error report to standard output option
; C O N F I G U R A T I O N
;ROM_vectors writable (0=no, 1=yes)
;if ROM vectors can not be used interrupts will not be trapped
;as a consequence BRK can not be tested but will be emulated to test RTI
0001 = ROM_vectors = 1
;load_data_direct (0=move from code segment, 1=load directly)
;loading directly is preferred but may not be supported by your platform
;0 produces only consecutive object code, 1 is not suitable for a binary image
0001 = load_data_direct = 1
;I_flag behavior (0=force enabled, 1=force disabled, 2=prohibit change, 3=allow
;change) 2 requires extra code and is not recommended. SEI & CLI can only be
;tested if you allow changing the interrupt status (I_flag = 3)
0003 = I_flag = 3
;configure memory - try to stay away from memory used by the system
;zero_page memory start address, $50 (80) consecutive Bytes required
; add 2 if I_flag = 2
000a = zero_page = $a
;data_segment memory start address, $5B (91) consecutive Bytes required
0200 = data_segment = $200
if (data_segment & $ff) != 0
ERROR ERROR ERROR low byte of data_segment MUST be $00 !!
endif
;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
0400 = code_segment = $400
;report errors through I/O channel (0=use standard self trap loops, 1=include
;report.i65 as I/O channel, add 3.5 kB)
0000 = report = 0
;RAM integrity test option. Checks for undesired RAM writes.
;set lowest non RAM or RAM mirror address page (-1=disable, 0=64k, $40=16k)
;leave disabled if a monitor, OS or background interrupt is allowed to alter RAM
ffff = ram_top = -1
noopt ;do not take shortcuts
;macros for error & success traps to allow user modification
;example:
;trap macro
; jsr my_error_handler
; endm
;trap_eq macro
; bne skip\?
; trap ;failed equal (zero)
;skip\?
; endm
;
; my_error_handler should pop the calling address from the stack and report it.
; putting larger portions of code (more than 3 bytes) inside the trap macro
; may lead to branch range problems for some tests.
if report = 0
trap macro
jmp * ;failed anyway
endm
trap_eq macro
beq * ;failed equal (zero)
endm
trap_ne macro
bne * ;failed not equal (non zero)
endm
trap_cs macro
bcs * ;failed carry set
endm
trap_cc macro
bcc * ;failed carry clear
endm
trap_mi macro
bmi * ;failed minus (bit 7 set)
endm
trap_pl macro
bpl * ;failed plus (bit 7 clear)
endm
trap_vs macro
bvs * ;failed overflow set
endm
trap_vc macro
bvc * ;failed overflow clear
endm
; please observe that during the test the stack gets invalidated
; therefore a RTS inside the success macro is not possible
success macro
jmp * ;test passed, no errors
endm
endif
if report = 1
trap macro
jsr report_error
endm
trap_eq macro
bne skip\?
trap ;failed equal (zero)
skip\?
endm
trap_ne macro
beq skip\?
trap ;failed not equal (non zero)
skip\?
endm
trap_cs macro
bcc skip\?
trap ;failed carry set
skip\?
endm
trap_cc macro
bcs skip\?
trap ;failed carry clear
skip\?
endm
trap_mi macro
bpl skip\?
trap ;failed minus (bit 7 set)
skip\?
endm
trap_pl macro
bmi skip\?
trap ;failed plus (bit 7 clear)
skip\?
endm
trap_vs macro
bvc skip\?
trap ;failed overflow set
skip\?
endm
trap_vc macro
bvs skip\?
trap ;failed overflow clear
skip\?
endm
; please observe that during the test the stack gets invalidated
; therefore a RTS inside the success macro is not possible
success macro
jsr report_success
endm
endif
0001 = carry equ %00000001 ;flag bits in status
0002 = zero equ %00000010
0004 = intdis equ %00000100
0008 = decmode equ %00001000
0010 = break equ %00010000
0020 = reserv equ %00100000
0040 = overfl equ %01000000
0080 = minus equ %10000000
0001 = fc equ carry
0002 = fz equ zero
0003 = fzc equ carry+zero
0040 = fv equ overfl
0042 = fvz equ overfl+zero
0080 = fn equ minus
0081 = fnc equ minus+carry
0082 = fnz equ minus+zero
0083 = fnzc equ minus+zero+carry
00c0 = fnv equ minus+overfl
0030 = fao equ break+reserv ;bits always on after PHP, BRK
0034 = fai equ fao+intdis ;+ forced interrupt disable
00ff = m8 equ $ff ;8 bit mask
00fb = m8i equ $ff&~intdis ;8 bit mask - interrupt disable
;macros to allow masking of status bits.
;masking of interrupt enable/disable on load and compare
;masking of always on bits after PHP or BRK (unused & break) on compare
if I_flag = 0
load_flag macro
lda #\1&m8i ;force enable interrupts (mask I)
endm
cmp_flag macro
cmp #(\1|fao)&m8i ;I_flag is always enabled + always on bits
endm
eor_flag macro
eor #(\1&m8i|fao) ;mask I, invert expected flags + always on bits
endm
endif
if I_flag = 1
load_flag macro
lda #\1|intdis ;force disable interrupts
endm
cmp_flag macro
cmp #(\1|fai)&m8 ;I_flag is always disabled + always on bits
endm
eor_flag macro
eor #(\1|fai) ;invert expected flags + always on bits + I
endm
endif
if I_flag = 2
load_flag macro
lda #\1
ora flag_I_on ;restore I-flag
and flag_I_off
endm
cmp_flag macro
eor flag_I_on ;I_flag is never changed
cmp #(\1|fao)&m8i ;expected flags + always on bits, mask I
endm
eor_flag macro
eor flag_I_on ;I_flag is never changed
eor #(\1&m8i|fao) ;mask I, invert expected flags + always on bits
endm
endif
if I_flag = 3
load_flag macro
lda #\1 ;allow test to change I-flag (no mask)
endm
cmp_flag macro
cmp #(\1|fao)&m8 ;expected flags + always on bits
endm
eor_flag macro
eor #\1|fao ;invert expected flags + always on bits
endm
endif
;macros to set (register|memory|zeropage) & status
set_stat macro ;setting flags in the processor status register
load_flag \1
pha ;use stack to load status
plp
endm
set_a macro ;precharging accu & status
load_flag \2
pha ;use stack to load status
lda #\1 ;precharge accu
plp
endm
set_x macro ;precharging index & status
load_flag \2
pha ;use stack to load status
ldx #\1 ;precharge index x
plp
endm
set_y macro ;precharging index & status
load_flag \2
pha ;use stack to load status
ldy #\1 ;precharge index y
plp
endm
set_ax macro ;precharging indexed accu & immediate status
load_flag \2
pha ;use stack to load status
lda \1,x ;precharge accu
plp
endm
set_ay macro ;precharging indexed accu & immediate status
load_flag \2
pha ;use stack to load status
lda \1,y ;precharge accu
plp
endm
set_z macro ;precharging indexed zp & immediate status
load_flag \2
pha ;use stack to load status
lda \1,x ;load to zeropage
sta zpt
plp
endm
set_zx macro ;precharging zp,x & immediate status
load_flag \2
pha ;use stack to load status
lda \1,x ;load to indexed zeropage
sta zpt,x
plp
endm
set_abs macro ;precharging indexed memory & immediate status
load_flag \2
pha ;use stack to load status
lda \1,x ;load to memory
sta abst
plp
endm
set_absx macro ;precharging abs,x & immediate status
load_flag \2
pha ;use stack to load status
lda \1,x ;load to indexed memory
sta abst,x
plp
endm
;macros to test (register|memory|zeropage) & status & (mask)
tst_stat macro ;testing flags in the processor status register
php ;save status
pla ;use stack to retrieve status
pha
cmp_flag \1
trap_ne
plp ;restore status
endm
tst_a macro ;testing result in accu & flags
php ;save flags
cmp #\1 ;test result
trap_ne
pla ;load status
pha
cmp_flag \2
trap_ne
plp ;restore status
endm
tst_x macro ;testing result in x index & flags
php ;save flags
cpx #\1 ;test result
trap_ne
pla ;load status
pha
cmp_flag \2
trap_ne
plp ;restore status
endm
tst_y macro ;testing result in y index & flags
php ;save flags
cpy #\1 ;test result
trap_ne
pla ;load status
pha
cmp_flag \2
trap_ne
plp ;restore status
endm
tst_ax macro ;indexed testing result in accu & flags
php ;save flags
cmp \1,x ;test result
trap_ne
pla ;load status
eor_flag \3
cmp \2,x ;test flags
trap_ne ;
endm
tst_ay macro ;indexed testing result in accu & flags
php ;save flags
cmp \1,y ;test result
trap_ne ;
pla ;load status
eor_flag \3
cmp \2,y ;test flags
trap_ne
endm
tst_z macro ;indexed testing result in zp & flags
php ;save flags
lda zpt
cmp \1,x ;test result
trap_ne
pla ;load status
eor_flag \3
cmp \2,x ;test flags
trap_ne
endm
tst_zx macro ;testing result in zp,x & flags
php ;save flags
lda zpt,x
cmp \1,x ;test result
trap_ne
pla ;load status
eor_flag \3
cmp \2,x ;test flags
trap_ne
endm
tst_abs macro ;indexed testing result in memory & flags
php ;save flags
lda abst
cmp \1,x ;test result
trap_ne
pla ;load status
eor_flag \3
cmp \2,x ;test flags
trap_ne
endm
tst_absx macro ;testing result in abs,x & flags
php ;save flags
lda abst,x
cmp \1,x ;test result
trap_ne
pla ;load status
eor_flag \3
cmp \2,x ;test flags
trap_ne
endm
; RAM integrity test
; verifies that none of the previous tests has altered RAM outside of the
; designated write areas.
; uses zpt word as indirect pointer, zpt+2 word as checksum
if ram_top > -1
check_ram macro
cld
lda #0
sta zpt ;set low byte of indirect pointer
sta zpt+3 ;checksum high byte
sta range_adr ;reset self modifying code
sta tandi1
sta tandi2
sta teori1
sta teori2
sta torai1
sta torai2
sta chkdadi
sta chkdsbi
sta chkadi
sta chksbi
clc
ldx #zp_bss-zero_page ;zeropage - write test area
ccs3\? adc zero_page,x
bcc ccs2\?
inc zpt+3 ;carry to high byte
clc
ccs2\? inx
bne ccs3\?
ldx #hi(data_segment) ;set high byte of indirect pointer
stx zpt+1
ldy #lo(data_bss) ;data after write test area
ccs5\? adc (zpt),y
bcc ccs4\?
inc zpt+3 ;carry to high byte
clc
ccs4\? iny
bne ccs5\?
inx ;advance RAM high address
stx zpt+1
cpx #ram_top
bne ccs5\?
sta zpt+2 ;checksum low is
cmp ram_chksm ;checksum low expected
trap_ne ;checksum mismatch
lda zpt+3 ;checksum high is
cmp ram_chksm+1 ;checksum high expected
trap_ne ;checksum mismatch
endm
else
check_ram macro
;RAM check disabled - RAM size not set
endm
endif
next_test macro ;make sure, tests don't jump the fence
lda test_case ;previous test
cmp #test_num
trap_ne ;test is out of sequence
test_num = test_num + 1
lda #test_num ;*** next tests' number
sta test_case
;check_ram ;uncomment to find altered RAM after each test
endm
if load_data_direct = 1
data
else
bss ;uninitialized segment, copy of data at end of code!
endif
; org zero_page
0000 = org 0 ;edited to provide binaries loading from 0
0000 : 00000000000000.. ds zero_page
;break test interrupt save
000a : 00 irq_a ds 1 ;a register
000b : 00 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
flag_I_off ds 1 ;and mask to load flags
endif
000c : zpt ;5 bytes store/modify test area
;add/subtract operand generation and result/flag prediction
000c : 00 adfc ds 1 ;carry flag before op
000d : 00 ad1 ds 1 ;operand 1 - accumulator
000e : 00 ad2 ds 1 ;operand 2 - memory / immediate
000f : 00 adrl ds 1 ;expected result bits 0-7
0010 : 00 adrh ds 1 ;expected result bit 8 (carry)
0011 : 00 adrf ds 1 ;expected flags NV0000ZC (only binary mode)
0012 : 00 sb2 ds 1 ;operand 2 complemented for subtract
0013 : zp_bss
0013 : c3824100 zp1 db $c3,$82,$41,0 ;test patterns for LDx BIT ROL ROR ASL LSR
0017 : 7f zp7f db $7f ;test pattern for compare
;logical zeropage operands
0018 : 001f7180 zpOR db 0,$1f,$71,$80 ;test pattern for OR
001c : 0fff7f80 zpAN db $0f,$ff,$7f,$80 ;test pattern for AND
0020 : ff0f8f8f zpEO db $ff,$0f,$8f,$8f ;test pattern for EOR
;indirect addressing pointers
0024 : 0802 ind1 dw abs1 ;indirect pointer to pattern in absolute memory
0026 : 0902 dw abs1+1
0028 : 0a02 dw abs1+2
002a : 0b02 dw abs1+3
002c : 0c02 dw abs7f
002e : 1001 inw1 dw abs1-$f8 ;indirect pointer for wrap-test pattern
0030 : 0302 indt dw abst ;indirect pointer to store area in absolute memory
0032 : 0402 dw abst+1
0034 : 0502 dw abst+2
0036 : 0602 dw abst+3
0038 : 0b01 inwt dw abst-$f8 ;indirect pointer for wrap-test store
003a : 3f02 indAN dw absAN ;indirect pointer to AND pattern in absolute memory
003c : 4002 dw absAN+1
003e : 4102 dw absAN+2
0040 : 4202 dw absAN+3
0042 : 4302 indEO dw absEO ;indirect pointer to EOR pattern in absolute memory
0044 : 4402 dw absEO+1
0046 : 4502 dw absEO+2
0048 : 4602 dw absEO+3
004a : 3b02 indOR dw absOR ;indirect pointer to OR pattern in absolute memory
004c : 3c02 dw absOR+1
004e : 3d02 dw absOR+2
0050 : 3e02 dw absOR+3
;add/subtract indirect pointers
0052 : 0302 adi2 dw ada2 ;indirect pointer to operand 2 in absolute memory
0054 : 0402 sbi2 dw sba2 ;indirect pointer to complemented operand 2 (SBC)
0056 : 0401 adiy2 dw ada2-$ff ;with offset for indirect indexed
0058 : 0501 sbiy2 dw sba2-$ff
005a : zp_bss_end
0200 = org data_segment
0200 : 00 test_case ds 1 ;current test number
0201 : 0000 ram_chksm ds 2 ;checksum for RAM integrity test
;add/subtract operand copy - abs tests write area
0203 : abst ;5 bytes store/modify test area
0203 : 00 ada2 ds 1 ;operand 2
0204 : 00 sba2 ds 1 ;operand 2 complemented for subtract
0205 : 000000 ds 3 ;fill remaining bytes
0208 : data_bss
0208 : c3824100 abs1 db $c3,$82,$41,0 ;test patterns for LDx BIT ROL ROR ASL LSR
020c : 7f abs7f db $7f ;test pattern for compare
;loads
020d : 80800002 fLDx db fn,fn,0,fz ;expected flags for load
;shifts
0211 : rASL ;expected result ASL & ROL -carry
0211 : 86048200 rROL db $86,$04,$82,0 ; "
0215 : 87058301 rROLc db $87,$05,$83,1 ;expected result ROL +carry
0219 : rLSR ;expected result LSR & ROR -carry
0219 : 61412000 rROR db $61,$41,$20,0 ; "
021d : e1c1a080 rRORc db $e1,$c1,$a0,$80 ;expected result ROR +carry
0221 : fASL ;expected flags for shifts
0221 : 81018002 fROL db fnc,fc,fn,fz ;no carry in
0225 : 81018000 fROLc db fnc,fc,fn,0 ;carry in
0229 : fLSR
0229 : 01000102 fROR db fc,0,fc,fz ;no carry in
022d : 81808180 fRORc db fnc,fn,fnc,fn ;carry in
;increments (decrements)
0231 : 7f80ff0001 rINC db $7f,$80,$ff,0,1 ;expected result for INC/DEC
0236 : 0080800200 fINC db 0,fn,fn,fz,0 ;expected flags for INC/DEC
;logical memory operand
023b : 001f7180 absOR db 0,$1f,$71,$80 ;test pattern for OR
023f : 0fff7f80 absAN db $0f,$ff,$7f,$80 ;test pattern for AND
0243 : ff0f8f8f absEO db $ff,$0f,$8f,$8f ;test pattern for EOR
;logical accu operand
0247 : 00f11f00 absORa db 0,$f1,$1f,0 ;test pattern for OR
024b : f0ffffff absANa db $f0,$ff,$ff,$ff ;test pattern for AND
024f : fff0f00f absEOa db $ff,$f0,$f0,$0f ;test pattern for EOR
;logical results
0253 : 00ff7f80 absrlo db 0,$ff,$7f,$80
0257 : 02800080 absflo db fz,fn,0,fn
025b : data_bss_end
code
0400 = org code_segment
0400 : d8 start cld
0401 : a2ff ldx #$ff
0403 : 9a txs
0404 : a900 lda #0 ;*** test 0 = initialize
0406 : 8d0002 sta test_case
0000 = test_num = 0
;stop interrupts before initializing BSS
if I_flag = 1
sei
endif
;initialize I/O for report channel
if report = 1
jsr report_init
endif
;initialize BSS segment
if load_data_direct != 1
ldx #zp_end-zp_init-1
ld_zp lda zp_init,x
sta zp_bss,x
dex
bpl ld_zp
ldx #data_end-data_init-1
ld_data lda data_init,x
sta data_bss,x
dex
bpl ld_data
if ROM_vectors = 1
ldx #5
ld_vect lda vec_init,x
sta vec_bss,x
dex
bpl ld_vect
endif
endif
;retain status of interrupt flag
if I_flag = 2
php
pla
and #4 ;isolate flag
sta flag_I_on ;or mask
eor #lo(~4) ;reverse
sta flag_I_off ;and mask
endif
;generate checksum for RAM integrity test
if ram_top > -1
lda #0
sta zpt ;set low byte of indirect pointer
sta ram_chksm+1 ;checksum high byte
sta range_adr ;reset self modifying code
sta tandi1
sta tandi2
sta teori1
sta teori2
sta torai1
sta torai2
sta chkdadi
sta chkdsbi
sta chkadi
sta chksbi
clc
ldx #zp_bss-zero_page ;zeropage - write test area
gcs3 adc zero_page,x
bcc gcs2
inc ram_chksm+1 ;carry to high byte
clc
gcs2 inx
bne gcs3
ldx #hi(data_segment) ;set high byte of indirect pointer
stx zpt+1
ldy #lo(data_bss) ;data after write test area
gcs5 adc (zpt),y
bcc gcs4
inc ram_chksm+1 ;carry to high byte
clc
gcs4 iny
bne gcs5
inx ;advance RAM high address
stx zpt+1
cpx #ram_top
bne gcs5
sta ram_chksm ;checksum complete
endif
next_test
0409 : ad0002 > lda test_case ;previous test
040c : c900 > cmp #test_num
> trap_ne ;test is out of sequence
040e : d0fe > bne * ;failed not equal (non zero)
>
0001 = >test_num = test_num + 1
0410 : a901 > lda #test_num ;*** next tests' number
0412 : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
;testing relative addressing with BEQ
0415 : a0fe ldy #$fe ;testing maximum range, not -1/-2 (invalid/self adr)
0417 : range_loop
0417 : 88 dey ;next relative address
0418 : 98 tya
0419 : aa tax ;precharge count to end of loop
041a : 1003 bpl range_fw ;calculate relative address
041c : 18 clc ;avoid branch self or to relative address of branch
041d : 6902 adc #2
041f : range_fw
041f : 497f eor #$7f ;complement except sign
0421 : 8da804 sta range_adr ;load into test target
0424 : a900 lda #0 ;should set zero flag in status register
0426 : 4ca704 jmp range_op
;relative address target field with branch under test in the middle
0429 : ca dex ;-128 - max backward
042a : ca dex
042b : ca dex
042c : ca dex
042d : ca dex
042e : ca dex
042f : ca dex
0430 : ca dex
0431 : ca dex ;-120
0432 : ca dex
0433 : ca dex
0434 : ca dex
0435 : ca dex
0436 : ca dex
0437 : ca dex
0438 : ca dex
0439 : ca dex
043a : ca dex
043b : ca dex ;-110
043c : ca dex
043d : ca dex
043e : ca dex
043f : ca dex
0440 : ca dex
0441 : ca dex
0442 : ca dex
0443 : ca dex
0444 : ca dex
0445 : ca dex ;-100
0446 : ca dex
0447 : ca dex
0448 : ca dex
0449 : ca dex
044a : ca dex
044b : ca dex
044c : ca dex
044d : ca dex
044e : ca dex
044f : ca dex ;-90
0450 : ca dex
0451 : ca dex
0452 : ca dex
0453 : ca dex
0454 : ca dex
0455 : ca dex
0456 : ca dex
0457 : ca dex
0458 : ca dex
0459 : ca dex ;-80
045a : ca dex
045b : ca dex
045c : ca dex
045d : ca dex
045e : ca dex
045f : ca dex
0460 : ca dex
0461 : ca dex
0462 : ca dex
0463 : ca dex ;-70
0464 : ca dex
0465 : ca dex
0466 : ca dex
0467 : ca dex
0468 : ca dex
0469 : ca dex
046a : ca dex
046b : ca dex
046c : ca dex
046d : ca dex ;-60
046e : ca dex
046f : ca dex
0470 : ca dex
0471 : ca dex
0472 : ca dex
0473 : ca dex
0474 : ca dex
0475 : ca dex
0476 : ca dex
0477 : ca dex ;-50
0478 : ca dex
0479 : ca dex
047a : ca dex
047b : ca dex
047c : ca dex
047d : ca dex
047e : ca dex
047f : ca dex
0480 : ca dex
0481 : ca dex ;-40
0482 : ca dex
0483 : ca dex
0484 : ca dex
0485 : ca dex
0486 : ca dex
0487 : ca dex
0488 : ca dex
0489 : ca dex
048a : ca dex
048b : ca dex ;-30
048c : ca dex
048d : ca dex
048e : ca dex
048f : ca dex
0490 : ca dex
0491 : ca dex
0492 : ca dex
0493 : ca dex
0494 : ca dex
0495 : ca dex ;-20
0496 : ca dex
0497 : ca dex
0498 : ca dex
0499 : ca dex
049a : ca dex
049b : ca dex
049c : ca dex
049d : ca dex
049e : ca dex
049f : ca dex ;-10
04a0 : ca dex
04a1 : ca dex
04a2 : ca dex
04a3 : ca dex
04a4 : ca dex
04a5 : ca dex
04a6 : ca dex ;-3
04a7 : range_op ;test target with zero flag=0, z=1 if previous dex
04a8 = range_adr = *+1 ;modifiable relative address
04a7 : f03e beq *+64 ;if called without modification
04a9 : ca dex ;+0
04aa : ca dex
04ab : ca dex
04ac : ca dex
04ad : ca dex
04ae : ca dex
04af : ca dex
04b0 : ca dex
04b1 : ca dex
04b2 : ca dex
04b3 : ca dex ;+10
04b4 : ca dex
04b5 : ca dex
04b6 : ca dex
04b7 : ca dex
04b8 : ca dex
04b9 : ca dex
04ba : ca dex
04bb : ca dex
04bc : ca dex
04bd : ca dex ;+20
04be : ca dex
04bf : ca dex
04c0 : ca dex
04c1 : ca dex
04c2 : ca dex
04c3 : ca dex
04c4 : ca dex
04c5 : ca dex
04c6 : ca dex
04c7 : ca dex ;+30
04c8 : ca dex
04c9 : ca dex
04ca : ca dex
04cb : ca dex
04cc : ca dex
04cd : ca dex
04ce : ca dex
04cf : ca dex
04d0 : ca dex
04d1 : ca dex ;+40
04d2 : ca dex
04d3 : ca dex
04d4 : ca dex
04d5 : ca dex
04d6 : ca dex
04d7 : ca dex
04d8 : ca dex
04d9 : ca dex
04da : ca dex
04db : ca dex ;+50
04dc : ca dex
04dd : ca dex
04de : ca dex
04df : ca dex
04e0 : ca dex
04e1 : ca dex
04e2 : ca dex
04e3 : ca dex
04e4 : ca dex
04e5 : ca dex ;+60
04e6 : ca dex
04e7 : ca dex
04e8 : ca dex
04e9 : ca dex
04ea : ca dex
04eb : ca dex
04ec : ca dex
04ed : ca dex
04ee : ca dex
04ef : ca dex ;+70
04f0 : ca dex
04f1 : ca dex
04f2 : ca dex
04f3 : ca dex
04f4 : ca dex
04f5 : ca dex
04f6 : ca dex
04f7 : ca dex
04f8 : ca dex
04f9 : ca dex ;+80
04fa : ca dex
04fb : ca dex
04fc : ca dex
04fd : ca dex
04fe : ca dex
04ff : ca dex
0500 : ca dex
0501 : ca dex
0502 : ca dex
0503 : ca dex ;+90
0504 : ca dex
0505 : ca dex
0506 : ca dex
0507 : ca dex
0508 : ca dex
0509 : ca dex
050a : ca dex
050b : ca dex
050c : ca dex
050d : ca dex ;+100
050e : ca dex
050f : ca dex
0510 : ca dex
0511 : ca dex
0512 : ca dex
0513 : ca dex
0514 : ca dex
0515 : ca dex
0516 : ca dex
0517 : ca dex ;+110
0518 : ca dex
0519 : ca dex
051a : ca dex
051b : ca dex
051c : ca dex
051d : ca dex
051e : ca dex
051f : ca dex
0520 : ca dex
0521 : ca dex ;+120
0522 : ca dex
0523 : ca dex
0524 : ca dex
0525 : ca dex
0526 : ca dex
0527 : ca dex
0528 : f003 beq range_ok ;+127 - max forward
trap ; bad range
052a : 4c2a05 > jmp * ;failed anyway
052d : range_ok
052d : c000 cpy #0
052f : f003 beq range_end
0531 : 4c1704 jmp range_loop
0534 : range_end ;range test successful
next_test
0534 : ad0002 > lda test_case ;previous test
0537 : c901 > cmp #test_num
> trap_ne ;test is out of sequence
0539 : d0fe > bne * ;failed not equal (non zero)
>
0002 = >test_num = test_num + 1
053b : a902 > lda #test_num ;*** next tests' number
053d : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
;partial test BNE & CMP, CPX, CPY immediate
0540 : c001 cpy #1 ;testing BNE true
0542 : d003 bne test_bne
trap
0544 : 4c4405 > jmp * ;failed anyway
0547 : test_bne
0547 : a900 lda #0
0549 : c900 cmp #0 ;test compare immediate
trap_ne
054b : d0fe > bne * ;failed not equal (non zero)
trap_cc
054d : 90fe > bcc * ;failed carry clear
trap_mi
054f : 30fe > bmi * ;failed minus (bit 7 set)
0551 : c901 cmp #1
trap_eq
0553 : f0fe > beq * ;failed equal (zero)
trap_cs
0555 : b0fe > bcs * ;failed carry set
trap_pl
0557 : 10fe > bpl * ;failed plus (bit 7 clear)
0559 : aa tax
055a : e000 cpx #0 ;test compare x immediate
trap_ne
055c : d0fe > bne * ;failed not equal (non zero)
trap_cc
055e : 90fe > bcc * ;failed carry clear
trap_mi
0560 : 30fe > bmi * ;failed minus (bit 7 set)
0562 : e001 cpx #1
trap_eq
0564 : f0fe > beq * ;failed equal (zero)
trap_cs
0566 : b0fe > bcs * ;failed carry set
trap_pl
0568 : 10fe > bpl * ;failed plus (bit 7 clear)
056a : a8 tay
056b : c000 cpy #0 ;test compare y immediate
trap_ne
056d : d0fe > bne * ;failed not equal (non zero)
trap_cc
056f : 90fe > bcc * ;failed carry clear
trap_mi
0571 : 30fe > bmi * ;failed minus (bit 7 set)
0573 : c001 cpy #1
trap_eq
0575 : f0fe > beq * ;failed equal (zero)
trap_cs
0577 : b0fe > bcs * ;failed carry set
trap_pl
0579 : 10fe > bpl * ;failed plus (bit 7 clear)
next_test
057b : ad0002 > lda test_case ;previous test
057e : c902 > cmp #test_num
> trap_ne ;test is out of sequence
0580 : d0fe > bne * ;failed not equal (non zero)
>
0003 = >test_num = test_num + 1
0582 : a903 > lda #test_num ;*** next tests' number
0584 : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
;testing stack operations PHA PHP PLA PLP
0587 : a2ff ldx #$ff ;initialize stack
0589 : 9a txs
058a : a955 lda #$55
058c : 48 pha
058d : a9aa lda #$aa
058f : 48 pha
0590 : cdfe01 cmp $1fe ;on stack ?
trap_ne
0593 : d0fe > bne * ;failed not equal (non zero)
0595 : ba tsx
0596 : 8a txa ;overwrite accu
0597 : c9fd cmp #$fd ;sp decremented?
trap_ne
0599 : d0fe > bne * ;failed not equal (non zero)
059b : 68 pla
059c : c9aa cmp #$aa ;successful retreived from stack?
trap_ne
059e : d0fe > bne * ;failed not equal (non zero)
05a0 : 68 pla
05a1 : c955 cmp #$55
trap_ne
05a3 : d0fe > bne * ;failed not equal (non zero)
05a5 : cdff01 cmp $1ff ;remains on stack?
trap_ne
05a8 : d0fe > bne * ;failed not equal (non zero)
05aa : ba tsx
05ab : e0ff cpx #$ff ;sp incremented?
trap_ne
05ad : d0fe > bne * ;failed not equal (non zero)
next_test
05af : ad0002 > lda test_case ;previous test
05b2 : c903 > cmp #test_num
> trap_ne ;test is out of sequence
05b4 : d0fe > bne * ;failed not equal (non zero)
>
0004 = >test_num = test_num + 1
05b6 : a904 > lda #test_num ;*** next tests' number
05b8 : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
;testing branch decisions BPL BMI BVC BVS BCC BCS BNE BEQ
set_stat $ff ;all on
> load_flag $ff
05bb : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
05bd : 48 > pha ;use stack to load status
05be : 28 > plp
05bf : 101a bpl nbr1 ;branches should not be taken
05c1 : 501b bvc nbr2
05c3 : 901c bcc nbr3
05c5 : d01d bne nbr4
05c7 : 3003 bmi br1 ;branches should be taken
trap
05c9 : 4cc905 > jmp * ;failed anyway
05cc : 7003 br1 bvs br2
trap
05ce : 4cce05 > jmp * ;failed anyway
05d1 : b003 br2 bcs br3
trap
05d3 : 4cd305 > jmp * ;failed anyway
05d6 : f00f br3 beq br4
trap
05d8 : 4cd805 > jmp * ;failed anyway
05db : nbr1
trap ;previous bpl taken
05db : 4cdb05 > jmp * ;failed anyway
05de : nbr2
trap ;previous bvc taken
05de : 4cde05 > jmp * ;failed anyway
05e1 : nbr3
trap ;previous bcc taken
05e1 : 4ce105 > jmp * ;failed anyway
05e4 : nbr4
trap ;previous bne taken
05e4 : 4ce405 > jmp * ;failed anyway
05e7 : 08 br4 php
05e8 : ba tsx
05e9 : e0fe cpx #$fe ;sp after php?
trap_ne
05eb : d0fe > bne * ;failed not equal (non zero)
05ed : 68 pla
cmp_flag $ff ;returned all flags on?
05ee : c9ff > cmp #($ff |fao)&m8 ;expected flags + always on bits
trap_ne
05f0 : d0fe > bne * ;failed not equal (non zero)
05f2 : ba tsx
05f3 : e0ff cpx #$ff ;sp after php?
trap_ne
05f5 : d0fe > bne * ;failed not equal (non zero)
set_stat 0 ;all off
> load_flag 0
05f7 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
05f9 : 48 > pha ;use stack to load status
05fa : 28 > plp
05fb : 301a bmi nbr11 ;branches should not be taken
05fd : 701b bvs nbr12
05ff : b01c bcs nbr13
0601 : f01d beq nbr14
0603 : 1003 bpl br11 ;branches should be taken
trap
0605 : 4c0506 > jmp * ;failed anyway
0608 : 5003 br11 bvc br12
trap
060a : 4c0a06 > jmp * ;failed anyway
060d : 9003 br12 bcc br13
trap
060f : 4c0f06 > jmp * ;failed anyway
0612 : d00f br13 bne br14
trap
0614 : 4c1406 > jmp * ;failed anyway
0617 : nbr11
trap ;previous bmi taken
0617 : 4c1706 > jmp * ;failed anyway
061a : nbr12
trap ;previous bvs taken
061a : 4c1a06 > jmp * ;failed anyway
061d : nbr13
trap ;previous bcs taken
061d : 4c1d06 > jmp * ;failed anyway
0620 : nbr14
trap ;previous beq taken
0620 : 4c2006 > jmp * ;failed anyway
0623 : 08 br14 php
0624 : 68 pla
cmp_flag 0 ;flags off except break (pushed by sw) + reserved?
0625 : c930 > cmp #(0 |fao)&m8 ;expected flags + always on bits
trap_ne
0627 : d0fe > bne * ;failed not equal (non zero)
;crosscheck flags
set_stat zero
> load_flag zero
0629 : a902 > lda #zero ;allow test to change I-flag (no mask)
>
062b : 48 > pha ;use stack to load status
062c : 28 > plp
062d : d002 bne brzs1
062f : f003 beq brzs2
0631 : brzs1
trap ;branch zero/non zero
0631 : 4c3106 > jmp * ;failed anyway
0634 : b002 brzs2 bcs brzs3
0636 : 9003 bcc brzs4
0638 : brzs3
trap ;branch carry/no carry
0638 : 4c3806 > jmp * ;failed anyway
063b : 3002 brzs4 bmi brzs5
063d : 1003 bpl brzs6
063f : brzs5
trap ;branch minus/plus
063f : 4c3f06 > jmp * ;failed anyway
0642 : 7002 brzs6 bvs brzs7
0644 : 5003 bvc brzs8
0646 : brzs7
trap ;branch overflow/no overflow
0646 : 4c4606 > jmp * ;failed anyway
0649 : brzs8
set_stat carry
> load_flag carry
0649 : a901 > lda #carry ;allow test to change I-flag (no mask)
>
064b : 48 > pha ;use stack to load status
064c : 28 > plp
064d : f002 beq brcs1
064f : d003 bne brcs2
0651 : brcs1
trap ;branch zero/non zero
0651 : 4c5106 > jmp * ;failed anyway
0654 : 9002 brcs2 bcc brcs3
0656 : b003 bcs brcs4
0658 : brcs3
trap ;branch carry/no carry
0658 : 4c5806 > jmp * ;failed anyway
065b : 3002 brcs4 bmi brcs5
065d : 1003 bpl brcs6
065f : brcs5
trap ;branch minus/plus
065f : 4c5f06 > jmp * ;failed anyway
0662 : 7002 brcs6 bvs brcs7
0664 : 5003 bvc brcs8
0666 : brcs7
trap ;branch overflow/no overflow
0666 : 4c6606 > jmp * ;failed anyway
0669 : brcs8
set_stat minus
> load_flag minus
0669 : a980 > lda #minus ;allow test to change I-flag (no mask)
>
066b : 48 > pha ;use stack to load status
066c : 28 > plp
066d : f002 beq brmi1
066f : d003 bne brmi2
0671 : brmi1
trap ;branch zero/non zero
0671 : 4c7106 > jmp * ;failed anyway
0674 : b002 brmi2 bcs brmi3
0676 : 9003 bcc brmi4
0678 : brmi3
trap ;branch carry/no carry
0678 : 4c7806 > jmp * ;failed anyway
067b : 1002 brmi4 bpl brmi5
067d : 3003 bmi brmi6
067f : brmi5
trap ;branch minus/plus
067f : 4c7f06 > jmp * ;failed anyway
0682 : 7002 brmi6 bvs brmi7
0684 : 5003 bvc brmi8
0686 : brmi7
trap ;branch overflow/no overflow
0686 : 4c8606 > jmp * ;failed anyway
0689 : brmi8
set_stat overfl
> load_flag overfl
0689 : a940 > lda #overfl ;allow test to change I-flag (no mask)
>
068b : 48 > pha ;use stack to load status
068c : 28 > plp
068d : f002 beq brvs1
068f : d003 bne brvs2
0691 : brvs1
trap ;branch zero/non zero
0691 : 4c9106 > jmp * ;failed anyway
0694 : b002 brvs2 bcs brvs3
0696 : 9003 bcc brvs4
0698 : brvs3
trap ;branch carry/no carry
0698 : 4c9806 > jmp * ;failed anyway
069b : 3002 brvs4 bmi brvs5
069d : 1003 bpl brvs6
069f : brvs5
trap ;branch minus/plus
069f : 4c9f06 > jmp * ;failed anyway
06a2 : 5002 brvs6 bvc brvs7
06a4 : 7003 bvs brvs8
06a6 : brvs7
trap ;branch overflow/no overflow
06a6 : 4ca606 > jmp * ;failed anyway
06a9 : brvs8
set_stat $ff-zero
> load_flag $ff-zero
06a9 : a9fd > lda #$ff-zero ;allow test to change I-flag (no mask)
>
06ab : 48 > pha ;use stack to load status
06ac : 28 > plp
06ad : f002 beq brzc1
06af : d003 bne brzc2
06b1 : brzc1
trap ;branch zero/non zero
06b1 : 4cb106 > jmp * ;failed anyway
06b4 : 9002 brzc2 bcc brzc3
06b6 : b003 bcs brzc4
06b8 : brzc3
trap ;branch carry/no carry
06b8 : 4cb806 > jmp * ;failed anyway
06bb : 1002 brzc4 bpl brzc5
06bd : 3003 bmi brzc6
06bf : brzc5
trap ;branch minus/plus
06bf : 4cbf06 > jmp * ;failed anyway
06c2 : 5002 brzc6 bvc brzc7
06c4 : 7003 bvs brzc8
06c6 : brzc7
trap ;branch overflow/no overflow
06c6 : 4cc606 > jmp * ;failed anyway
06c9 : brzc8
set_stat $ff-carry
> load_flag $ff-carry
06c9 : a9fe > lda #$ff-carry ;allow test to change I-flag (no mask)
>
06cb : 48 > pha ;use stack to load status
06cc : 28 > plp
06cd : d002 bne brcc1
06cf : f003 beq brcc2
06d1 : brcc1
trap ;branch zero/non zero
06d1 : 4cd106 > jmp * ;failed anyway
06d4 : b002 brcc2 bcs brcc3
06d6 : 9003 bcc brcc4
06d8 : brcc3
trap ;branch carry/no carry
06d8 : 4cd806 > jmp * ;failed anyway
06db : 1002 brcc4 bpl brcc5
06dd : 3003 bmi brcc6
06df : brcc5
trap ;branch minus/plus
06df : 4cdf06 > jmp * ;failed anyway
06e2 : 5002 brcc6 bvc brcc7
06e4 : 7003 bvs brcc8
06e6 : brcc7
trap ;branch overflow/no overflow
06e6 : 4ce606 > jmp * ;failed anyway
06e9 : brcc8
set_stat $ff-minus
> load_flag $ff-minus
06e9 : a97f > lda #$ff-minus ;allow test to change I-flag (no mask)
>
06eb : 48 > pha ;use stack to load status
06ec : 28 > plp
06ed : d002 bne brpl1
06ef : f003 beq brpl2
06f1 : brpl1
trap ;branch zero/non zero
06f1 : 4cf106 > jmp * ;failed anyway
06f4 : 9002 brpl2 bcc brpl3
06f6 : b003 bcs brpl4
06f8 : brpl3
trap ;branch carry/no carry
06f8 : 4cf806 > jmp * ;failed anyway
06fb : 3002 brpl4 bmi brpl5
06fd : 1003 bpl brpl6
06ff : brpl5
trap ;branch minus/plus
06ff : 4cff06 > jmp * ;failed anyway
0702 : 5002 brpl6 bvc brpl7
0704 : 7003 bvs brpl8
0706 : brpl7
trap ;branch overflow/no overflow
0706 : 4c0607 > jmp * ;failed anyway
0709 : brpl8
set_stat $ff-overfl
> load_flag $ff-overfl
0709 : a9bf > lda #$ff-overfl ;allow test to change I-flag (no mask)
>
070b : 48 > pha ;use stack to load status
070c : 28 > plp
070d : d002 bne brvc1
070f : f003 beq brvc2
0711 : brvc1
trap ;branch zero/non zero
0711 : 4c1107 > jmp * ;failed anyway
0714 : 9002 brvc2 bcc brvc3
0716 : b003 bcs brvc4
0718 : brvc3
trap ;branch carry/no carry
0718 : 4c1807 > jmp * ;failed anyway
071b : 1002 brvc4 bpl brvc5
071d : 3003 bmi brvc6
071f : brvc5
trap ;branch minus/plus
071f : 4c1f07 > jmp * ;failed anyway
0722 : 7002 brvc6 bvs brvc7
0724 : 5003 bvc brvc8
0726 : brvc7
trap ;branch overflow/no overflow
0726 : 4c2607 > jmp * ;failed anyway
0729 : brvc8
next_test
0729 : ad0002 > lda test_case ;previous test
072c : c904 > cmp #test_num
> trap_ne ;test is out of sequence
072e : d0fe > bne * ;failed not equal (non zero)
>
0005 = >test_num = test_num + 1
0730 : a905 > lda #test_num ;*** next tests' number
0732 : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
; test PHA does not alter flags or accumulator but PLA does
0735 : a255 ldx #$55 ;x & y protected
0737 : a0aa ldy #$aa
set_a 1,$ff ;push
> load_flag $ff
0739 : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
073b : 48 > pha ;use stack to load status
073c : a901 > lda #1 ;precharge accu
073e : 28 > plp
073f : 48 pha
tst_a 1,$ff
0740 : 08 > php ;save flags
0741 : c901 > cmp #1 ;test result
> trap_ne
0743 : d0fe > bne * ;failed not equal (non zero)
>
0745 : 68 > pla ;load status
0746 : 48 > pha
> cmp_flag $ff
0747 : c9ff > cmp #($ff|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0749 : d0fe > bne * ;failed not equal (non zero)
>
074b : 28 > plp ;restore status
set_a 0,0
> load_flag 0
074c : a900 > lda #0 ;allow test to change I-flag (no mask)
>
074e : 48 > pha ;use stack to load status
074f : a900 > lda #0 ;precharge accu
0751 : 28 > plp
0752 : 48 pha
tst_a 0,0
0753 : 08 > php ;save flags
0754 : c900 > cmp #0 ;test result
> trap_ne
0756 : d0fe > bne * ;failed not equal (non zero)
>
0758 : 68 > pla ;load status
0759 : 48 > pha
> cmp_flag 0
075a : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
075c : d0fe > bne * ;failed not equal (non zero)
>
075e : 28 > plp ;restore status
set_a $ff,$ff
> load_flag $ff
075f : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
0761 : 48 > pha ;use stack to load status
0762 : a9ff > lda #$ff ;precharge accu
0764 : 28 > plp
0765 : 48 pha
tst_a $ff,$ff
0766 : 08 > php ;save flags
0767 : c9ff > cmp #$ff ;test result
> trap_ne
0769 : d0fe > bne * ;failed not equal (non zero)
>
076b : 68 > pla ;load status
076c : 48 > pha
> cmp_flag $ff
076d : c9ff > cmp #($ff|fao)&m8 ;expected flags + always on bits
>
> trap_ne
076f : d0fe > bne * ;failed not equal (non zero)
>
0771 : 28 > plp ;restore status
set_a 1,0
> load_flag 0
0772 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
0774 : 48 > pha ;use stack to load status
0775 : a901 > lda #1 ;precharge accu
0777 : 28 > plp
0778 : 48 pha
tst_a 1,0
0779 : 08 > php ;save flags
077a : c901 > cmp #1 ;test result
> trap_ne
077c : d0fe > bne * ;failed not equal (non zero)
>
077e : 68 > pla ;load status
077f : 48 > pha
> cmp_flag 0
0780 : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0782 : d0fe > bne * ;failed not equal (non zero)
>
0784 : 28 > plp ;restore status
set_a 0,$ff
> load_flag $ff
0785 : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
0787 : 48 > pha ;use stack to load status
0788 : a900 > lda #0 ;precharge accu
078a : 28 > plp
078b : 48 pha
tst_a 0,$ff
078c : 08 > php ;save flags
078d : c900 > cmp #0 ;test result
> trap_ne
078f : d0fe > bne * ;failed not equal (non zero)
>
0791 : 68 > pla ;load status
0792 : 48 > pha
> cmp_flag $ff
0793 : c9ff > cmp #($ff|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0795 : d0fe > bne * ;failed not equal (non zero)
>
0797 : 28 > plp ;restore status
set_a $ff,0
> load_flag 0
0798 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
079a : 48 > pha ;use stack to load status
079b : a9ff > lda #$ff ;precharge accu
079d : 28 > plp
079e : 48 pha
tst_a $ff,0
079f : 08 > php ;save flags
07a0 : c9ff > cmp #$ff ;test result
> trap_ne
07a2 : d0fe > bne * ;failed not equal (non zero)
>
07a4 : 68 > pla ;load status
07a5 : 48 > pha
> cmp_flag 0
07a6 : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
07a8 : d0fe > bne * ;failed not equal (non zero)
>
07aa : 28 > plp ;restore status
set_a 0,$ff ;pull
> load_flag $ff
07ab : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
07ad : 48 > pha ;use stack to load status
07ae : a900 > lda #0 ;precharge accu
07b0 : 28 > plp
07b1 : 68 pla
tst_a $ff,$ff-zero
07b2 : 08 > php ;save flags
07b3 : c9ff > cmp #$ff ;test result
> trap_ne
07b5 : d0fe > bne * ;failed not equal (non zero)
>
07b7 : 68 > pla ;load status
07b8 : 48 > pha
> cmp_flag $ff-zero
07b9 : c9fd > cmp #($ff-zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
07bb : d0fe > bne * ;failed not equal (non zero)
>
07bd : 28 > plp ;restore status
set_a $ff,0
> load_flag 0
07be : a900 > lda #0 ;allow test to change I-flag (no mask)
>
07c0 : 48 > pha ;use stack to load status
07c1 : a9ff > lda #$ff ;precharge accu
07c3 : 28 > plp
07c4 : 68 pla
tst_a 0,zero
07c5 : 08 > php ;save flags
07c6 : c900 > cmp #0 ;test result
> trap_ne
07c8 : d0fe > bne * ;failed not equal (non zero)
>
07ca : 68 > pla ;load status
07cb : 48 > pha
> cmp_flag zero
07cc : c932 > cmp #(zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
07ce : d0fe > bne * ;failed not equal (non zero)
>
07d0 : 28 > plp ;restore status
set_a $fe,$ff
> load_flag $ff
07d1 : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
07d3 : 48 > pha ;use stack to load status
07d4 : a9fe > lda #$fe ;precharge accu
07d6 : 28 > plp
07d7 : 68 pla
tst_a 1,$ff-zero-minus
07d8 : 08 > php ;save flags
07d9 : c901 > cmp #1 ;test result
> trap_ne
07db : d0fe > bne * ;failed not equal (non zero)
>
07dd : 68 > pla ;load status
07de : 48 > pha
> cmp_flag $ff-zero-minus
07df : c97d > cmp #($ff-zero-minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
07e1 : d0fe > bne * ;failed not equal (non zero)
>
07e3 : 28 > plp ;restore status
set_a 0,0
> load_flag 0
07e4 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
07e6 : 48 > pha ;use stack to load status
07e7 : a900 > lda #0 ;precharge accu
07e9 : 28 > plp
07ea : 68 pla
tst_a $ff,minus
07eb : 08 > php ;save flags
07ec : c9ff > cmp #$ff ;test result
> trap_ne
07ee : d0fe > bne * ;failed not equal (non zero)
>
07f0 : 68 > pla ;load status
07f1 : 48 > pha
> cmp_flag minus
07f2 : c9b0 > cmp #(minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
07f4 : d0fe > bne * ;failed not equal (non zero)
>
07f6 : 28 > plp ;restore status
set_a $ff,$ff
> load_flag $ff
07f7 : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
07f9 : 48 > pha ;use stack to load status
07fa : a9ff > lda #$ff ;precharge accu
07fc : 28 > plp
07fd : 68 pla
tst_a 0,$ff-minus
07fe : 08 > php ;save flags
07ff : c900 > cmp #0 ;test result
> trap_ne
0801 : d0fe > bne * ;failed not equal (non zero)
>
0803 : 68 > pla ;load status
0804 : 48 > pha
> cmp_flag $ff-minus
0805 : c97f > cmp #($ff-minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0807 : d0fe > bne * ;failed not equal (non zero)
>
0809 : 28 > plp ;restore status
set_a $fe,0
> load_flag 0
080a : a900 > lda #0 ;allow test to change I-flag (no mask)
>
080c : 48 > pha ;use stack to load status
080d : a9fe > lda #$fe ;precharge accu
080f : 28 > plp
0810 : 68 pla
tst_a 1,0
0811 : 08 > php ;save flags
0812 : c901 > cmp #1 ;test result
> trap_ne
0814 : d0fe > bne * ;failed not equal (non zero)
>
0816 : 68 > pla ;load status
0817 : 48 > pha
> cmp_flag 0
0818 : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
081a : d0fe > bne * ;failed not equal (non zero)
>
081c : 28 > plp ;restore status
081d : e055 cpx #$55 ;x & y unchanged?
trap_ne
081f : d0fe > bne * ;failed not equal (non zero)
0821 : c0aa cpy #$aa
trap_ne
0823 : d0fe > bne * ;failed not equal (non zero)
next_test
0825 : ad0002 > lda test_case ;previous test
0828 : c905 > cmp #test_num
> trap_ne ;test is out of sequence
082a : d0fe > bne * ;failed not equal (non zero)
>
0006 = >test_num = test_num + 1
082c : a906 > lda #test_num ;*** next tests' number
082e : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
; partial pretest EOR #
set_a $3c,0
> load_flag 0
0831 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
0833 : 48 > pha ;use stack to load status
0834 : a93c > lda #$3c ;precharge accu
0836 : 28 > plp
0837 : 49c3 eor #$c3
tst_a $ff,fn
0839 : 08 > php ;save flags
083a : c9ff > cmp #$ff ;test result
> trap_ne
083c : d0fe > bne * ;failed not equal (non zero)
>
083e : 68 > pla ;load status
083f : 48 > pha
> cmp_flag fn
0840 : c9b0 > cmp #(fn|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0842 : d0fe > bne * ;failed not equal (non zero)
>
0844 : 28 > plp ;restore status
set_a $c3,0
> load_flag 0
0845 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
0847 : 48 > pha ;use stack to load status
0848 : a9c3 > lda #$c3 ;precharge accu
084a : 28 > plp
084b : 49c3 eor #$c3
tst_a 0,fz
084d : 08 > php ;save flags
084e : c900 > cmp #0 ;test result
> trap_ne
0850 : d0fe > bne * ;failed not equal (non zero)
>
0852 : 68 > pla ;load status
0853 : 48 > pha
> cmp_flag fz
0854 : c932 > cmp #(fz|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0856 : d0fe > bne * ;failed not equal (non zero)
>
0858 : 28 > plp ;restore status
next_test
0859 : ad0002 > lda test_case ;previous test
085c : c906 > cmp #test_num
> trap_ne ;test is out of sequence
085e : d0fe > bne * ;failed not equal (non zero)
>
0007 = >test_num = test_num + 1
0860 : a907 > lda #test_num ;*** next tests' number
0862 : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
; PC modifying instructions except branches (NOP, JMP, JSR, RTS, BRK, RTI)
; testing NOP
0865 : a224 ldx #$24
0867 : a042 ldy #$42
set_a $18,0
> load_flag 0
0869 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
086b : 48 > pha ;use stack to load status
086c : a918 > lda #$18 ;precharge accu
086e : 28 > plp
086f : ea nop
tst_a $18,0
0870 : 08 > php ;save flags
0871 : c918 > cmp #$18 ;test result
> trap_ne
0873 : d0fe > bne * ;failed not equal (non zero)
>
0875 : 68 > pla ;load status
0876 : 48 > pha
> cmp_flag 0
0877 : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0879 : d0fe > bne * ;failed not equal (non zero)
>
087b : 28 > plp ;restore status
087c : e024 cpx #$24
trap_ne
087e : d0fe > bne * ;failed not equal (non zero)
0880 : c042 cpy #$42
trap_ne
0882 : d0fe > bne * ;failed not equal (non zero)
0884 : a2db ldx #$db
0886 : a0bd ldy #$bd
set_a $e7,$ff
> load_flag $ff
0888 : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
088a : 48 > pha ;use stack to load status
088b : a9e7 > lda #$e7 ;precharge accu
088d : 28 > plp
088e : ea nop
tst_a $e7,$ff
088f : 08 > php ;save flags
0890 : c9e7 > cmp #$e7 ;test result
> trap_ne
0892 : d0fe > bne * ;failed not equal (non zero)
>
0894 : 68 > pla ;load status
0895 : 48 > pha
> cmp_flag $ff
0896 : c9ff > cmp #($ff|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0898 : d0fe > bne * ;failed not equal (non zero)
>
089a : 28 > plp ;restore status
089b : e0db cpx #$db
trap_ne
089d : d0fe > bne * ;failed not equal (non zero)
089f : c0bd cpy #$bd
trap_ne
08a1 : d0fe > bne * ;failed not equal (non zero)
next_test
08a3 : ad0002 > lda test_case ;previous test
08a6 : c907 > cmp #test_num
> trap_ne ;test is out of sequence
08a8 : d0fe > bne * ;failed not equal (non zero)
>
0008 = >test_num = test_num + 1
08aa : a908 > lda #test_num ;*** next tests' number
08ac : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
; jump absolute
set_stat $0
> load_flag $0
08af : a900 > lda #$0 ;allow test to change I-flag (no mask)
>
08b1 : 48 > pha ;use stack to load status
08b2 : 28 > plp
08b3 : a946 lda #'F'
08b5 : a241 ldx #'A'
08b7 : a052 ldy #'R' ;N=0, V=0, Z=0, C=0
08b9 : 4c1b36 jmp test_far
08bc : ea nop
08bd : ea nop
trap_ne ;runover protection
08be : d0fe > bne * ;failed not equal (non zero)
08c0 : e8 inx
08c1 : e8 inx
08c2 : far_ret
trap_eq ;returned flags OK?
08c2 : f0fe > beq * ;failed equal (zero)
trap_pl
08c4 : 10fe > bpl * ;failed plus (bit 7 clear)
trap_cc
08c6 : 90fe > bcc * ;failed carry clear
trap_vc
08c8 : 50fe > bvc * ;failed overflow clear
08ca : c9ec cmp #('F'^$aa) ;returned registers OK?
trap_ne
08cc : d0fe > bne * ;failed not equal (non zero)
08ce : e042 cpx #('A'+1)
trap_ne
08d0 : d0fe > bne * ;failed not equal (non zero)
08d2 : c04f cpy #('R'-3)
trap_ne
08d4 : d0fe > bne * ;failed not equal (non zero)
08d6 : ca dex
08d7 : c8 iny
08d8 : c8 iny
08d9 : c8 iny
08da : 49aa eor #$aa ;N=0, V=1, Z=0, C=1
08dc : 4ce508 jmp test_near
08df : ea nop
08e0 : ea nop
trap_ne ;runover protection
08e1 : d0fe > bne * ;failed not equal (non zero)
08e3 : e8 inx
08e4 : e8 inx
08e5 : test_near
trap_eq ;passed flags OK?
08e5 : f0fe > beq * ;failed equal (zero)
trap_mi
08e7 : 30fe > bmi * ;failed minus (bit 7 set)
trap_cc
08e9 : 90fe > bcc * ;failed carry clear
trap_vc
08eb : 50fe > bvc * ;failed overflow clear
08ed : c946 cmp #'F' ;passed registers OK?
trap_ne
08ef : d0fe > bne * ;failed not equal (non zero)
08f1 : e041 cpx #'A'
trap_ne
08f3 : d0fe > bne * ;failed not equal (non zero)
08f5 : c052 cpy #'R'
trap_ne
08f7 : d0fe > bne * ;failed not equal (non zero)
next_test
08f9 : ad0002 > lda test_case ;previous test
08fc : c908 > cmp #test_num
> trap_ne ;test is out of sequence
08fe : d0fe > bne * ;failed not equal (non zero)
>
0009 = >test_num = test_num + 1
0900 : a909 > lda #test_num ;*** next tests' number
0902 : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
; jump indirect
set_stat 0
> load_flag 0
0905 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
0907 : 48 > pha ;use stack to load status
0908 : 28 > plp
0909 : a949 lda #'I'
090b : a24e ldx #'N'
090d : a044 ldy #'D' ;N=0, V=0, Z=0, C=0
090f : 6c4a36 jmp (ptr_tst_ind)
0912 : ea nop
trap_ne ;runover protection
0913 : d0fe > bne * ;failed not equal (non zero)
0915 : 88 dey
0916 : 88 dey
0917 : ind_ret
0917 : 08 php ;either SP or Y count will fail, if we do not hit
0918 : 88 dey
0919 : 88 dey
091a : 88 dey
091b : 28 plp
trap_eq ;returned flags OK?
091c : f0fe > beq * ;failed equal (zero)
trap_pl
091e : 10fe > bpl * ;failed plus (bit 7 clear)
trap_cc
0920 : 90fe > bcc * ;failed carry clear
trap_vc
0922 : 50fe > bvc * ;failed overflow clear
0924 : c9e3 cmp #('I'^$aa) ;returned registers OK?
trap_ne
0926 : d0fe > bne * ;failed not equal (non zero)
0928 : e04f cpx #('N'+1)
trap_ne
092a : d0fe > bne * ;failed not equal (non zero)
092c : c03e cpy #('D'-6)
trap_ne
092e : d0fe > bne * ;failed not equal (non zero)
0930 : ba tsx ;SP check
0931 : e0ff cpx #$ff
trap_ne
0933 : d0fe > bne * ;failed not equal (non zero)
next_test
0935 : ad0002 > lda test_case ;previous test
0938 : c909 > cmp #test_num
> trap_ne ;test is out of sequence
093a : d0fe > bne * ;failed not equal (non zero)
>
000a = >test_num = test_num + 1
093c : a90a > lda #test_num ;*** next tests' number
093e : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
; jump subroutine & return from subroutine
set_stat 0
> load_flag 0
0941 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
0943 : 48 > pha ;use stack to load status
0944 : 28 > plp
0945 : a94a lda #'J'
0947 : a253 ldx #'S'
0949 : a052 ldy #'R' ;N=0, V=0, Z=0, C=0
094b : 208636 jsr test_jsr
094d = jsr_ret = *-1 ;last address of jsr = return address
094e : 08 php ;either SP or Y count will fail, if we do not hit
094f : 88 dey
0950 : 88 dey
0951 : 88 dey
0952 : 28 plp
trap_eq ;returned flags OK?
0953 : f0fe > beq * ;failed equal (zero)
trap_pl
0955 : 10fe > bpl * ;failed plus (bit 7 clear)
trap_cc
0957 : 90fe > bcc * ;failed carry clear
trap_vc
0959 : 50fe > bvc * ;failed overflow clear
095b : c9e0 cmp #('J'^$aa) ;returned registers OK?
trap_ne
095d : d0fe > bne * ;failed not equal (non zero)
095f : e054 cpx #('S'+1)
trap_ne
0961 : d0fe > bne * ;failed not equal (non zero)
0963 : c04c cpy #('R'-6)
trap_ne
0965 : d0fe > bne * ;failed not equal (non zero)
0967 : ba tsx ;sp?
0968 : e0ff cpx #$ff
trap_ne
096a : d0fe > bne * ;failed not equal (non zero)
next_test
096c : ad0002 > lda test_case ;previous test
096f : c90a > cmp #test_num
> trap_ne ;test is out of sequence
0971 : d0fe > bne * ;failed not equal (non zero)
>
000b = >test_num = test_num + 1
0973 : a90b > lda #test_num ;*** next tests' number
0975 : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
; break & return from interrupt
if ROM_vectors = 1
set_stat 0
> load_flag 0
0978 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
097a : 48 > pha ;use stack to load status
097b : 28 > plp
097c : a942 lda #'B'
097e : a252 ldx #'R'
0980 : a04b ldy #'K' ;N=0, V=0, Z=0, C=0
0982 : 00 brk
else
lda #hi brk_ret ;emulated break
pha
lda #lo brk_ret
pha
lda #fao ;set break & unused on stack
pha
set_stat intdis
lda #'B'
ldx #'R'
ldy #'K' ;N=0, V=0, Z=0, C=0
jmp irq_trap
endif
0983 : 88 dey ;should not be executed
0984 : brk_ret ;address of break return
0984 : 08 php ;either SP or Y count will fail, if we do not hit
0985 : 88 dey
0986 : 88 dey
0987 : 88 dey
0988 : c9e8 cmp #('B'^$aa) ;returned registers OK?
trap_ne
098a : d0fe > bne * ;failed not equal (non zero)
098c : e053 cpx #('R'+1)
trap_ne
098e : d0fe > bne * ;failed not equal (non zero)
0990 : c045 cpy #('K'-6)
trap_ne
0992 : d0fe > bne * ;failed not equal (non zero)
0994 : 68 pla ;returned flags OK (unchanged)?
cmp_flag 0
0995 : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
trap_ne
0997 : d0fe > bne * ;failed not equal (non zero)
0999 : ba tsx ;sp?
099a : e0ff cpx #$ff
trap_ne
099c : d0fe > bne * ;failed not equal (non zero)
next_test
099e : ad0002 > lda test_case ;previous test
09a1 : c90b > cmp #test_num
> trap_ne ;test is out of sequence
09a3 : d0fe > bne * ;failed not equal (non zero)
>
000c = >test_num = test_num + 1
09a5 : a90c > lda #test_num ;*** next tests' number
09a7 : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
; test set and clear flags CLC CLI CLD CLV SEC SEI SED
set_stat $ff
> load_flag $ff
09aa : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
09ac : 48 > pha ;use stack to load status
09ad : 28 > plp
09ae : 18 clc
tst_stat $ff-carry
09af : 08 > php ;save status
09b0 : 68 > pla ;use stack to retrieve status
09b1 : 48 > pha
> cmp_flag $ff-carry
09b2 : c9fe > cmp #($ff-carry|fao)&m8 ;expected flags + always on bits
>
> trap_ne
09b4 : d0fe > bne * ;failed not equal (non zero)
>
09b6 : 28 > plp ;restore status
09b7 : 38 sec
tst_stat $ff
09b8 : 08 > php ;save status
09b9 : 68 > pla ;use stack to retrieve status
09ba : 48 > pha
> cmp_flag $ff
09bb : c9ff > cmp #($ff|fao)&m8 ;expected flags + always on bits
>
> trap_ne
09bd : d0fe > bne * ;failed not equal (non zero)
>
09bf : 28 > plp ;restore status
if I_flag = 3
09c0 : 58 cli
tst_stat $ff-intdis
09c1 : 08 > php ;save status
09c2 : 68 > pla ;use stack to retrieve status
09c3 : 48 > pha
> cmp_flag $ff-intdis
09c4 : c9fb > cmp #($ff-intdis|fao)&m8 ;expected flags + always on bits
>
> trap_ne
09c6 : d0fe > bne * ;failed not equal (non zero)
>
09c8 : 28 > plp ;restore status
09c9 : 78 sei
tst_stat $ff
09ca : 08 > php ;save status
09cb : 68 > pla ;use stack to retrieve status
09cc : 48 > pha
> cmp_flag $ff
09cd : c9ff > cmp #($ff|fao)&m8 ;expected flags + always on bits
>
> trap_ne
09cf : d0fe > bne * ;failed not equal (non zero)
>
09d1 : 28 > plp ;restore status
endif
09d2 : d8 cld
tst_stat $ff-decmode
09d3 : 08 > php ;save status
09d4 : 68 > pla ;use stack to retrieve status
09d5 : 48 > pha
> cmp_flag $ff-decmode
09d6 : c9f7 > cmp #($ff-decmode|fao)&m8 ;expected flags + always on bits
>
> trap_ne
09d8 : d0fe > bne * ;failed not equal (non zero)
>
09da : 28 > plp ;restore status
09db : f8 sed
tst_stat $ff
09dc : 08 > php ;save status
09dd : 68 > pla ;use stack to retrieve status
09de : 48 > pha
> cmp_flag $ff
09df : c9ff > cmp #($ff|fao)&m8 ;expected flags + always on bits
>
> trap_ne
09e1 : d0fe > bne * ;failed not equal (non zero)
>
09e3 : 28 > plp ;restore status
09e4 : b8 clv
tst_stat $ff-overfl
09e5 : 08 > php ;save status
09e6 : 68 > pla ;use stack to retrieve status
09e7 : 48 > pha
> cmp_flag $ff-overfl
09e8 : c9bf > cmp #($ff-overfl|fao)&m8 ;expected flags + always on bits
>
> trap_ne
09ea : d0fe > bne * ;failed not equal (non zero)
>
09ec : 28 > plp ;restore status
set_stat 0
> load_flag 0
09ed : a900 > lda #0 ;allow test to change I-flag (no mask)
>
09ef : 48 > pha ;use stack to load status
09f0 : 28 > plp
tst_stat 0
09f1 : 08 > php ;save status
09f2 : 68 > pla ;use stack to retrieve status
09f3 : 48 > pha
> cmp_flag 0
09f4 : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
09f6 : d0fe > bne * ;failed not equal (non zero)
>
09f8 : 28 > plp ;restore status
09f9 : 38 sec
tst_stat carry
09fa : 08 > php ;save status
09fb : 68 > pla ;use stack to retrieve status
09fc : 48 > pha
> cmp_flag carry
09fd : c931 > cmp #(carry|fao)&m8 ;expected flags + always on bits
>
> trap_ne
09ff : d0fe > bne * ;failed not equal (non zero)
>
0a01 : 28 > plp ;restore status
0a02 : 18 clc
tst_stat 0
0a03 : 08 > php ;save status
0a04 : 68 > pla ;use stack to retrieve status
0a05 : 48 > pha
> cmp_flag 0
0a06 : c930 > cmp #(0 |fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a08 : d0fe > bne * ;failed not equal (non zero)
>
0a0a : 28 > plp ;restore status
if I_flag = 3
0a0b : 78 sei
tst_stat intdis
0a0c : 08 > php ;save status
0a0d : 68 > pla ;use stack to retrieve status
0a0e : 48 > pha
> cmp_flag intdis
0a0f : c934 > cmp #(intdis|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a11 : d0fe > bne * ;failed not equal (non zero)
>
0a13 : 28 > plp ;restore status
0a14 : 58 cli
tst_stat 0
0a15 : 08 > php ;save status
0a16 : 68 > pla ;use stack to retrieve status
0a17 : 48 > pha
> cmp_flag 0
0a18 : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a1a : d0fe > bne * ;failed not equal (non zero)
>
0a1c : 28 > plp ;restore status
endif
0a1d : f8 sed
tst_stat decmode
0a1e : 08 > php ;save status
0a1f : 68 > pla ;use stack to retrieve status
0a20 : 48 > pha
> cmp_flag decmode
0a21 : c938 > cmp #(decmode|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a23 : d0fe > bne * ;failed not equal (non zero)
>
0a25 : 28 > plp ;restore status
0a26 : d8 cld
tst_stat 0
0a27 : 08 > php ;save status
0a28 : 68 > pla ;use stack to retrieve status
0a29 : 48 > pha
> cmp_flag 0
0a2a : c930 > cmp #(0 |fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a2c : d0fe > bne * ;failed not equal (non zero)
>
0a2e : 28 > plp ;restore status
set_stat overfl
> load_flag overfl
0a2f : a940 > lda #overfl ;allow test to change I-flag (no mask)
>
0a31 : 48 > pha ;use stack to load status
0a32 : 28 > plp
tst_stat overfl
0a33 : 08 > php ;save status
0a34 : 68 > pla ;use stack to retrieve status
0a35 : 48 > pha
> cmp_flag overfl
0a36 : c970 > cmp #(overfl|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a38 : d0fe > bne * ;failed not equal (non zero)
>
0a3a : 28 > plp ;restore status
0a3b : b8 clv
tst_stat 0
0a3c : 08 > php ;save status
0a3d : 68 > pla ;use stack to retrieve status
0a3e : 48 > pha
> cmp_flag 0
0a3f : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a41 : d0fe > bne * ;failed not equal (non zero)
>
0a43 : 28 > plp ;restore status
next_test
0a44 : ad0002 > lda test_case ;previous test
0a47 : c90c > cmp #test_num
> trap_ne ;test is out of sequence
0a49 : d0fe > bne * ;failed not equal (non zero)
>
000d = >test_num = test_num + 1
0a4b : a90d > lda #test_num ;*** next tests' number
0a4d : 8d0002 > sta test_case
> ;check_ram ;uncomment to find altered RAM after each test
; testing index register increment/decrement and transfer
; INX INY DEX DEY TAX TXA TAY TYA
0a50 : a2fe ldx #$fe
set_stat $ff
> load_flag $ff
0a52 : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
0a54 : 48 > pha ;use stack to load status
0a55 : 28 > plp
0a56 : e8 inx ;ff
tst_x $ff,$ff-zero
0a57 : 08 > php ;save flags
0a58 : e0ff > cpx #$ff ;test result
> trap_ne
0a5a : d0fe > bne * ;failed not equal (non zero)
>
0a5c : 68 > pla ;load status
0a5d : 48 > pha
> cmp_flag $ff-zero
0a5e : c9fd > cmp #($ff-zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a60 : d0fe > bne * ;failed not equal (non zero)
>
0a62 : 28 > plp ;restore status
0a63 : e8 inx ;00
tst_x 0,$ff-minus
0a64 : 08 > php ;save flags
0a65 : e000 > cpx #0 ;test result
> trap_ne
0a67 : d0fe > bne * ;failed not equal (non zero)
>
0a69 : 68 > pla ;load status
0a6a : 48 > pha
> cmp_flag $ff-minus
0a6b : c97f > cmp #($ff-minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a6d : d0fe > bne * ;failed not equal (non zero)
>
0a6f : 28 > plp ;restore status
0a70 : e8 inx ;01
tst_x 1,$ff-minus-zero
0a71 : 08 > php ;save flags
0a72 : e001 > cpx #1 ;test result
> trap_ne
0a74 : d0fe > bne * ;failed not equal (non zero)
>
0a76 : 68 > pla ;load status
0a77 : 48 > pha
> cmp_flag $ff-minus-zero
0a78 : c97d > cmp #($ff-minus-zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a7a : d0fe > bne * ;failed not equal (non zero)
>
0a7c : 28 > plp ;restore status
0a7d : ca dex ;00
tst_x 0,$ff-minus
0a7e : 08 > php ;save flags
0a7f : e000 > cpx #0 ;test result
> trap_ne
0a81 : d0fe > bne * ;failed not equal (non zero)
>
0a83 : 68 > pla ;load status
0a84 : 48 > pha
> cmp_flag $ff-minus
0a85 : c97f > cmp #($ff-minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a87 : d0fe > bne * ;failed not equal (non zero)
>
0a89 : 28 > plp ;restore status
0a8a : ca dex ;ff
tst_x $ff,$ff-zero
0a8b : 08 > php ;save flags
0a8c : e0ff > cpx #$ff ;test result
> trap_ne
0a8e : d0fe > bne * ;failed not equal (non zero)
>
0a90 : 68 > pla ;load status
0a91 : 48 > pha
> cmp_flag $ff-zero
0a92 : c9fd > cmp #($ff-zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0a94 : d0fe > bne * ;failed not equal (non zero)
>
0a96 : 28 > plp ;restore status
0a97 : ca dex ;fe
set_stat 0
> load_flag 0
0a98 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
0a9a : 48 > pha ;use stack to load status
0a9b : 28 > plp
0a9c : e8 inx ;ff
tst_x $ff,minus
0a9d : 08 > php ;save flags
0a9e : e0ff > cpx #$ff ;test result
> trap_ne
0aa0 : d0fe > bne * ;failed not equal (non zero)
>
0aa2 : 68 > pla ;load status
0aa3 : 48 > pha
> cmp_flag minus
0aa4 : c9b0 > cmp #(minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0aa6 : d0fe > bne * ;failed not equal (non zero)
>
0aa8 : 28 > plp ;restore status
0aa9 : e8 inx ;00
tst_x 0,zero
0aaa : 08 > php ;save flags
0aab : e000 > cpx #0 ;test result
> trap_ne
0aad : d0fe > bne * ;failed not equal (non zero)
>
0aaf : 68 > pla ;load status
0ab0 : 48 > pha
> cmp_flag zero
0ab1 : c932 > cmp #(zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0ab3 : d0fe > bne * ;failed not equal (non zero)
>
0ab5 : 28 > plp ;restore status
0ab6 : e8 inx ;01
tst_x 1,0
0ab7 : 08 > php ;save flags
0ab8 : e001 > cpx #1 ;test result
> trap_ne
0aba : d0fe > bne * ;failed not equal (non zero)
>
0abc : 68 > pla ;load status
0abd : 48 > pha
> cmp_flag 0
0abe : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0ac0 : d0fe > bne * ;failed not equal (non zero)
>
0ac2 : 28 > plp ;restore status
0ac3 : ca dex ;00
tst_x 0,zero
0ac4 : 08 > php ;save flags
0ac5 : e000 > cpx #0 ;test result
> trap_ne
0ac7 : d0fe > bne * ;failed not equal (non zero)
>
0ac9 : 68 > pla ;load status
0aca : 48 > pha
> cmp_flag zero
0acb : c932 > cmp #(zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0acd : d0fe > bne * ;failed not equal (non zero)
>
0acf : 28 > plp ;restore status
0ad0 : ca dex ;ff
tst_x $ff,minus
0ad1 : 08 > php ;save flags
0ad2 : e0ff > cpx #$ff ;test result
> trap_ne
0ad4 : d0fe > bne * ;failed not equal (non zero)
>
0ad6 : 68 > pla ;load status
0ad7 : 48 > pha
> cmp_flag minus
0ad8 : c9b0 > cmp #(minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0ada : d0fe > bne * ;failed not equal (non zero)
>
0adc : 28 > plp ;restore status
0add : a0fe ldy #$fe
set_stat $ff
> load_flag $ff
0adf : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
0ae1 : 48 > pha ;use stack to load status
0ae2 : 28 > plp
0ae3 : c8 iny ;ff
tst_y $ff,$ff-zero
0ae4 : 08 > php ;save flags
0ae5 : c0ff > cpy #$ff ;test result
> trap_ne
0ae7 : d0fe > bne * ;failed not equal (non zero)
>
0ae9 : 68 > pla ;load status
0aea : 48 > pha
> cmp_flag $ff-zero
0aeb : c9fd > cmp #($ff-zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0aed : d0fe > bne * ;failed not equal (non zero)
>
0aef : 28 > plp ;restore status
0af0 : c8 iny ;00
tst_y 0,$ff-minus
0af1 : 08 > php ;save flags
0af2 : c000 > cpy #0 ;test result
> trap_ne
0af4 : d0fe > bne * ;failed not equal (non zero)
>
0af6 : 68 > pla ;load status
0af7 : 48 > pha
> cmp_flag $ff-minus
0af8 : c97f > cmp #($ff-minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0afa : d0fe > bne * ;failed not equal (non zero)
>
0afc : 28 > plp ;restore status
0afd : c8 iny ;01
tst_y 1,$ff-minus-zero
0afe : 08 > php ;save flags
0aff : c001 > cpy #1 ;test result
> trap_ne
0b01 : d0fe > bne * ;failed not equal (non zero)
>
0b03 : 68 > pla ;load status
0b04 : 48 > pha
> cmp_flag $ff-minus-zero
0b05 : c97d > cmp #($ff-minus-zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0b07 : d0fe > bne * ;failed not equal (non zero)
>
0b09 : 28 > plp ;restore status
0b0a : 88 dey ;00
tst_y 0,$ff-minus
0b0b : 08 > php ;save flags
0b0c : c000 > cpy #0 ;test result
> trap_ne
0b0e : d0fe > bne * ;failed not equal (non zero)
>
0b10 : 68 > pla ;load status
0b11 : 48 > pha
> cmp_flag $ff-minus
0b12 : c97f > cmp #($ff-minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0b14 : d0fe > bne * ;failed not equal (non zero)
>
0b16 : 28 > plp ;restore status
0b17 : 88 dey ;ff
tst_y $ff,$ff-zero
0b18 : 08 > php ;save flags
0b19 : c0ff > cpy #$ff ;test result
> trap_ne
0b1b : d0fe > bne * ;failed not equal (non zero)
>
0b1d : 68 > pla ;load status
0b1e : 48 > pha
> cmp_flag $ff-zero
0b1f : c9fd > cmp #($ff-zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0b21 : d0fe > bne * ;failed not equal (non zero)
>
0b23 : 28 > plp ;restore status
0b24 : 88 dey ;fe
set_stat 0
> load_flag 0
0b25 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
0b27 : 48 > pha ;use stack to load status
0b28 : 28 > plp
0b29 : c8 iny ;ff
tst_y $ff,0+minus
0b2a : 08 > php ;save flags
0b2b : c0ff > cpy #$ff ;test result
> trap_ne
0b2d : d0fe > bne * ;failed not equal (non zero)
>
0b2f : 68 > pla ;load status
0b30 : 48 > pha
> cmp_flag 0+minus
0b31 : c9b0 > cmp #(0+minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0b33 : d0fe > bne * ;failed not equal (non zero)
>
0b35 : 28 > plp ;restore status
0b36 : c8 iny ;00
tst_y 0,zero
0b37 : 08 > php ;save flags
0b38 : c000 > cpy #0 ;test result
> trap_ne
0b3a : d0fe > bne * ;failed not equal (non zero)
>
0b3c : 68 > pla ;load status
0b3d : 48 > pha
> cmp_flag zero
0b3e : c932 > cmp #(zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0b40 : d0fe > bne * ;failed not equal (non zero)
>
0b42 : 28 > plp ;restore status
0b43 : c8 iny ;01
tst_y 1,0
0b44 : 08 > php ;save flags
0b45 : c001 > cpy #1 ;test result
> trap_ne
0b47 : d0fe > bne * ;failed not equal (non zero)
>
0b49 : 68 > pla ;load status
0b4a : 48 > pha
> cmp_flag 0
0b4b : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0b4d : d0fe > bne * ;failed not equal (non zero)
>
0b4f : 28 > plp ;restore status
0b50 : 88 dey ;00
tst_y 0,zero
0b51 : 08 > php ;save flags
0b52 : c000 > cpy #0 ;test result
> trap_ne
0b54 : d0fe > bne * ;failed not equal (non zero)
>
0b56 : 68 > pla ;load status
0b57 : 48 > pha
> cmp_flag zero
0b58 : c932 > cmp #(zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0b5a : d0fe > bne * ;failed not equal (non zero)
>
0b5c : 28 > plp ;restore status
0b5d : 88 dey ;ff
tst_y $ff,minus
0b5e : 08 > php ;save flags
0b5f : c0ff > cpy #$ff ;test result
> trap_ne
0b61 : d0fe > bne * ;failed not equal (non zero)
>
0b63 : 68 > pla ;load status
0b64 : 48 > pha
> cmp_flag minus
0b65 : c9b0 > cmp #(minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0b67 : d0fe > bne * ;failed not equal (non zero)
>
0b69 : 28 > plp ;restore status
0b6a : a2ff ldx #$ff
set_stat $ff
> load_flag $ff
0b6c : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
0b6e : 48 > pha ;use stack to load status
0b6f : 28 > plp
0b70 : 8a txa
tst_a $ff,$ff-zero
0b71 : 08 > php ;save flags
0b72 : c9ff > cmp #$ff ;test result
> trap_ne
0b74 : d0fe > bne * ;failed not equal (non zero)
>
0b76 : 68 > pla ;load status
0b77 : 48 > pha
> cmp_flag $ff-zero
0b78 : c9fd > cmp #($ff-zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0b7a : d0fe > bne * ;failed not equal (non zero)
>
0b7c : 28 > plp ;restore status
0b7d : 08 php
0b7e : e8 inx ;00
0b7f : 28 plp
0b80 : 8a txa
tst_a 0,$ff-minus
0b81 : 08 > php ;save flags
0b82 : c900 > cmp #0 ;test result
> trap_ne
0b84 : d0fe > bne * ;failed not equal (non zero)
>
0b86 : 68 > pla ;load status
0b87 : 48 > pha
> cmp_flag $ff-minus
0b88 : c97f > cmp #($ff-minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0b8a : d0fe > bne * ;failed not equal (non zero)
>
0b8c : 28 > plp ;restore status
0b8d : 08 php
0b8e : e8 inx ;01
0b8f : 28 plp
0b90 : 8a txa
tst_a 1,$ff-minus-zero
0b91 : 08 > php ;save flags
0b92 : c901 > cmp #1 ;test result
> trap_ne
0b94 : d0fe > bne * ;failed not equal (non zero)
>
0b96 : 68 > pla ;load status
0b97 : 48 > pha
> cmp_flag $ff-minus-zero
0b98 : c97d > cmp #($ff-minus-zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0b9a : d0fe > bne * ;failed not equal (non zero)
>
0b9c : 28 > plp ;restore status
set_stat 0
> load_flag 0
0b9d : a900 > lda #0 ;allow test to change I-flag (no mask)
>
0b9f : 48 > pha ;use stack to load status
0ba0 : 28 > plp
0ba1 : 8a txa
tst_a 1,0
0ba2 : 08 > php ;save flags
0ba3 : c901 > cmp #1 ;test result
> trap_ne
0ba5 : d0fe > bne * ;failed not equal (non zero)
>
0ba7 : 68 > pla ;load status
0ba8 : 48 > pha
> cmp_flag 0
0ba9 : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0bab : d0fe > bne * ;failed not equal (non zero)
>
0bad : 28 > plp ;restore status
0bae : 08 php
0baf : ca dex ;00
0bb0 : 28 plp
0bb1 : 8a txa
tst_a 0,zero
0bb2 : 08 > php ;save flags
0bb3 : c900 > cmp #0 ;test result
> trap_ne
0bb5 : d0fe > bne * ;failed not equal (non zero)
>
0bb7 : 68 > pla ;load status
0bb8 : 48 > pha
> cmp_flag zero
0bb9 : c932 > cmp #(zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0bbb : d0fe > bne * ;failed not equal (non zero)
>
0bbd : 28 > plp ;restore status
0bbe : 08 php
0bbf : ca dex ;ff
0bc0 : 28 plp
0bc1 : 8a txa
tst_a $ff,minus
0bc2 : 08 > php ;save flags
0bc3 : c9ff > cmp #$ff ;test result
> trap_ne
0bc5 : d0fe > bne * ;failed not equal (non zero)
>
0bc7 : 68 > pla ;load status
0bc8 : 48 > pha
> cmp_flag minus
0bc9 : c9b0 > cmp #(minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0bcb : d0fe > bne * ;failed not equal (non zero)
>
0bcd : 28 > plp ;restore status
0bce : a0ff ldy #$ff
set_stat $ff
> load_flag $ff
0bd0 : a9ff > lda #$ff ;allow test to change I-flag (no mask)
>
0bd2 : 48 > pha ;use stack to load status
0bd3 : 28 > plp
0bd4 : 98 tya
tst_a $ff,$ff-zero
0bd5 : 08 > php ;save flags
0bd6 : c9ff > cmp #$ff ;test result
> trap_ne
0bd8 : d0fe > bne * ;failed not equal (non zero)
>
0bda : 68 > pla ;load status
0bdb : 48 > pha
> cmp_flag $ff-zero
0bdc : c9fd > cmp #($ff-zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0bde : d0fe > bne * ;failed not equal (non zero)
>
0be0 : 28 > plp ;restore status
0be1 : 08 php
0be2 : c8 iny ;00
0be3 : 28 plp
0be4 : 98 tya
tst_a 0,$ff-minus
0be5 : 08 > php ;save flags
0be6 : c900 > cmp #0 ;test result
> trap_ne
0be8 : d0fe > bne * ;failed not equal (non zero)
>
0bea : 68 > pla ;load status
0beb : 48 > pha
> cmp_flag $ff-minus
0bec : c97f > cmp #($ff-minus|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0bee : d0fe > bne * ;failed not equal (non zero)
>
0bf0 : 28 > plp ;restore status
0bf1 : 08 php
0bf2 : c8 iny ;01
0bf3 : 28 plp
0bf4 : 98 tya
tst_a 1,$ff-minus-zero
0bf5 : 08 > php ;save flags
0bf6 : c901 > cmp #1 ;test result
> trap_ne
0bf8 : d0fe > bne * ;failed not equal (non zero)
>
0bfa : 68 > pla ;load status
0bfb : 48 > pha
> cmp_flag $ff-minus-zero
0bfc : c97d > cmp #($ff-minus-zero|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0bfe : d0fe > bne * ;failed not equal (non zero)
>
0c00 : 28 > plp ;restore status
set_stat 0
> load_flag 0
0c01 : a900 > lda #0 ;allow test to change I-flag (no mask)
>
0c03 : 48 > pha ;use stack to load status
0c04 : 28 > plp
0c05 : 98 tya
tst_a 1,0
0c06 : 08 > php ;save flags
0c07 : c901 > cmp #1 ;test result
> trap_ne
0c09 : d0fe > bne * ;failed not equal (non zero)
>
0c0b : 68 > pla ;load status
0c0c : 48 > pha
> cmp_flag 0
0c0d : c930 > cmp #(0|fao)&m8 ;expected flags + always on bits
>
> trap_ne
0c0f : d0fe > bne * ;failed not equal (non zero)
>
0c11 : 28 > plp ;restore status
0c12 : 08 php
0c13 : 88 dey ;00
0c14 : 28 plp
0c15 : 98 tya
tst_a 0,zero
0c16 : 08 > php ;save flags
0c17 : c900 > cmp #0 ;test result
> trap_ne
0c19 : d0fe > bne * ;failed not equal (non zero)
>
0c1b : 68 > pla ;load status
0c1c : 48 > pha
> cmp_flag zero
0c1d : c932 > cmp #(zero|fao)&m8 ;expected flags + always on bits
>