The existing tests in the C64 Emulator Test Suite are good, but the assembly code for them is poorly documented, and being written using Turbo Assembler on a real C64, they are 95% shared code.
I have tried to improve this situation by factoring out a lot of the common parts of the tests, and using the .include directive of Ophis, so that a complete test is <100 lines, and each of the includes and parts of the test itself are fairly well documented.
For example, the test for PLZ is:
.include "test_top.a65"
.byte 145,"PLZN"
.include "test_prepare.a65"
; perform one test
next: ; expect data byte to be in results
lda db
sta dr
; expect Z and data byte should be identical
lda db
sta zr
; expect A to be the same in the results
lda ab
sta ar
; expect x to be the same in the results
lda xb
sta xr
; expect Y to be the same in the results
lda yb
sta yr
; expect processor flags to have B flag set and E flag set
lda pb
ora #110000
and #%01111101
tax
lda dr
cmp #0
bne nozero
txa
ora #000010
tax
lda dr
nozero: asl
bcc noneg
txa
ora #%10000000
tax
noneg: stx pr
; expect SP to be one more than it started
; but in practice, the value will be the same, because we will be pulling
; a byte off that we have pushed
ldx sb
txs
stx sr
; push data byte onto stack to be pulled off by the instruction
lda db
pha
.include "test_setup.a65"
; test instruction
cmd: plz
.include "test_record.a65"
; for stack pull instructions, data value is the appropriate register
lda za
sta da
.include "test_check.a65"
; name of next test
name: .byte "PHWIL"
.include "test_common.a65"
I am sure there will be further changes before it is all done and dusted, but I can now fairly rapidly write tests for the simpler instructions.
Those interested can check out http://github.com/gardners/4510tests
If anyone with a real C65 is willing to run the tests on their machine in C64 mode, that would be a great help to verify that the behaviour I am implementing is correct. I can provide a D81 file of the current set of tests if anyone is able to help out.
No comments:
Post a Comment