6502 Klaus Test Program
-
BobLoblaw0101
- Posts: 18
- Joined: 30 Nov 2014
6502 Klaus Test Program
I'm trying to test my emulator against the Klaus Test Program and would like to throw it into another emulator just so I can walk through it and see what to expect. Whats a good/easy 6502 emulator I can use that will work out of the box with the Klaus test program I assembled?
Re: 6502 Klaus Test Program
Please visit my website -> https://sbc.rictor.org/
-
BobLoblaw0101
- Posts: 18
- Joined: 30 Nov 2014
Re: 6502 Klaus Test Program
Okay great!
I ran the 6502 Kowalski simulator program you linked in and it's getting stuck in the same loop that my emulator is stuck in. This suggests that I'm not building the test code correctly.
I downloaded Klaus' program from:
https://github.com/Klaus2m5/6502_65C02_ ... l_test.a65
Then I assembled it with AS65 from http://www.kingswood-consulting.co.uk/assemblers/ using the following options:
as65.exe -l -m -s2 -w -h0 6502_functional_test.a65
This produced an Intel HEX format file. I ran this against my emulator and Kowalski's 6502 simulator program (starting at address 0x400). We both infinitely loop in the "dex" code ("relative address target field with branch under test in the middle") which is one of the first tests.
Does anyone have an idea of what I'm doing wrong? Ideally, I'd like to get this code working in any emulator so I can start debugging my own. Thanks in advance.
I ran the 6502 Kowalski simulator program you linked in and it's getting stuck in the same loop that my emulator is stuck in. This suggests that I'm not building the test code correctly.
I downloaded Klaus' program from:
https://github.com/Klaus2m5/6502_65C02_ ... l_test.a65
Then I assembled it with AS65 from http://www.kingswood-consulting.co.uk/assemblers/ using the following options:
as65.exe -l -m -s2 -w -h0 6502_functional_test.a65
This produced an Intel HEX format file. I ran this against my emulator and Kowalski's 6502 simulator program (starting at address 0x400). We both infinitely loop in the "dex" code ("relative address target field with branch under test in the middle") which is one of the first tests.
Does anyone have an idea of what I'm doing wrong? Ideally, I'd like to get this code working in any emulator so I can start debugging my own. Thanks in advance.
Re: 6502 Klaus Test Program
Bob,
could you please post the listing as an attachment or link?
could you please post the listing as an attachment or link?
6502 sources on GitHub: https://github.com/Klaus2m5
Re: 6502 Klaus Test Program
Hi Bob
See results from a previous thread, such as viewtopic.php?p=26265#p26265
which indicates that lib6502 passes everything except decimal tests, py65 passes. Those are the two emulators I run most often.
You might also like to try Michael Steil's perfect6502:
https://github.com/mist64/perfect6502
which is a port to C of the visual6502 netlist simulator.
Oh, and easy6502 also passes, apparently, according to my note at viewtopic.php?p=24177#p24177
Cheers
Ed
See results from a previous thread, such as viewtopic.php?p=26265#p26265
which indicates that lib6502 passes everything except decimal tests, py65 passes. Those are the two emulators I run most often.
You might also like to try Michael Steil's perfect6502:
https://github.com/mist64/perfect6502
which is a port to C of the visual6502 netlist simulator.
Oh, and easy6502 also passes, apparently, according to my note at viewtopic.php?p=24177#p24177
Cheers
Ed
-
BobLoblaw0101
- Posts: 18
- Joined: 30 Nov 2014
Re: 6502 Klaus Test Program
Klaus2m5 wrote:
Bob,
could you please post the listing as an attachment or link?
could you please post the listing as an attachment or link?
Both simulators get stuck in the dex loop between 0x429 and 0x4a7. I'm guessing it's user error, something I forgot to change on the asm file before I built it.
- Attachments
-
- 6502_functional_test.txt
- (706.01 KiB) Downloaded 199 times
Re: 6502 Klaus Test Program
Strange, there is nothing wrong with the generated listing. I ran my own hex file in Kowalski and it traps the break at $982, well beyond the branch range test (DEX loop). Changing the simulator option "Finish running program" from BRK to 0xBB continues to loop on the trap at $36E5, a known compatibilty problem in Kowalski (The stacked status from a BRK has the unused bit = 0).
Maybe you could attach your hex file too please.
Maybe you could attach your hex file too please.
6502 sources on GitHub: https://github.com/Klaus2m5
-
BobLoblaw0101
- Posts: 18
- Joined: 30 Nov 2014
Re: 6502 Klaus Test Program
Klaus2m5 wrote:
Strange, there is nothing wrong with the generated listing. I ran my own hex file in Kowalski and it traps the break at $982, well beyond the branch range test (DEX loop). Changing the simulator option "Finish running program" from BRK to 0xBB continues to loop on the trap at $36E5, a known compatibilty problem in Kowalski (The stacked status from a BRK has the unused bit = 0).
Maybe you could attach your hex file too please.
Maybe you could attach your hex file too please.
To reproduce the issue:
Open Kowalski 6502 simulator. Click File->Load Code. Then select the attached hex file. Once opened click Simulator->Step Into, and continue stepping until stuck in the infinite loop.
Does it loop when you do that? Or did I miss additional steps in between? Thanks.
- Attachments
-
- 6502_functional_test.hex.txt
- (31.17 KiB) Downloaded 187 times
Re: 6502 Klaus Test Program
BobLoblaw0101 wrote:
To reproduce the issue:
Open Kowalski 6502 simulator. Click File->Load Code. Then select the attached hex file. Once opened click Simulator->Step Into, and continue stepping until stuck in the infinite loop.
Does it loop when you do that? Or did I miss additional steps in between? Thanks.
Open Kowalski 6502 simulator. Click File->Load Code. Then select the attached hex file. Once opened click Simulator->Step Into, and continue stepping until stuck in the infinite loop.
Does it loop when you do that? Or did I miss additional steps in between? Thanks.
The branch range test runs for a very long time (in excess of 70000 clocks). So running it in step mode doesn't do you any good. It repeats the loop 254 times from 254 DEX to none. You should run that test at speed and check the PC from time to time. If the PC is stuck, then checking the listing about where it is stuck (branch to self) should give you an idea of what went wrong.
Your hex file runs as expected in Kowalski up to $36E5 (simulator click run, after a few seconds click break). It would run to completion in the Kowalski simulator if you would set ROM_vectors = 0 (BRK cannot be tested without the IRQ vector) before assembly.
6502 sources on GitHub: https://github.com/Klaus2m5
-
BobLoblaw0101
- Posts: 18
- Joined: 30 Nov 2014
Re: 6502 Klaus Test Program
Klaus2m5 wrote:
BobLoblaw0101 wrote:
To reproduce the issue:
Open Kowalski 6502 simulator. Click File->Load Code. Then select the attached hex file. Once opened click Simulator->Step Into, and continue stepping until stuck in the infinite loop.
Does it loop when you do that? Or did I miss additional steps in between? Thanks.
Open Kowalski 6502 simulator. Click File->Load Code. Then select the attached hex file. Once opened click Simulator->Step Into, and continue stepping until stuck in the infinite loop.
Does it loop when you do that? Or did I miss additional steps in between? Thanks.
The branch range test runs for a very long time (in excess of 70000 clocks). So running it in step mode doesn't do you any good. It repeats the loop 254 times from 254 DEX to none. You should run that test at speed and check the PC from time to time. If the PC is stuck, then checking the listing about where it is stuck (branch to self) should give you an idea of what went wrong.
Your hex file runs as expected in Kowalski up to $36E5 (simulator click run, after a few seconds click break). It would run to completion in the Kowalski simulator if you would set ROM_vectors = 0 (BRK cannot be tested without the IRQ vector) before assembly.
Thanks for the help and your test program, it's very comprehensive!
-
BobLoblaw0101
- Posts: 18
- Joined: 30 Nov 2014
Re: 6502 Klaus Test Program
I'm trying to emulate a system that doesn't have support for BCD mode.
Looking at Klaus' "6502_functional_test.a65" file, does anyone know the point at which everything has been tested EXCEPT for BCD? I'm trying to figure out a place to put a breakpoint in my debugger so I don't creep into the BCD testing code. Thanks.
Looking at Klaus' "6502_functional_test.a65" file, does anyone know the point at which everything has been tested EXCEPT for BCD? I'm trying to figure out a place to put a breakpoint in my debugger so I don't creep into the BCD testing code. Thanks.
Re: 6502 Klaus Test Program
The BCD ADC/SBC tests are numbered $2A. Look for where Klaus writes the test number to location $0200. In my listing of Klaus' functional tests, the BCD tests start around address $397B. These tests start with a bold header and an SED instruction. If you are searching a binary, look for the following hexadecimal sequence: A92A8D0002F8.
Michael A.
Re: 6502 Klaus Test Program
Thanks Michael. In the assembler source you can search for:
Code: Select all
; decimal add/subtract test6502 sources on GitHub: https://github.com/Klaus2m5
-
BobLoblaw0101
- Posts: 18
- Joined: 30 Nov 2014
Re: 6502 Klaus Test Program
Code: Select all
12979 ; decimal add/subtract test
12980 ; *** WARNING - tests documented behavior only! ***
12981 ; only valid BCD operands are tested, N V Z flags are ignored
12982 ; iterates through all valid combinations of operands and carry input
12983 ; uses increments/decrements to predict result & carry flag
12984 32f4 : f8 sed
12985 32f5 : a20e ldx #ad2 ;for indexed test
12986 32f7 : a0ff ldy #$ff ;max range
12987 32f9 : a999 lda #$99 ;start with adding 99 to 99 with carry
12988 32fb : 850d sta ad1 ;operand 1 - accumulator
12989 32fd : 850e sta ad2 ;operand 2 - memory or immediate
12990 32ff : 8d0302 sta ada2 ;non zp
12991 3302 : 850f sta adrl ;expected result bits 0-7
12992 3304 : a901 lda #1 ;set carry in & out
12993 3306 : 850c sta adfc ;carry in - for diag
12994 3308 : 8510 sta adrh ;expected result bit 8 (carry out)
12995 330a : a900 lda #0 ;complemented operand 2 for subtractRe: 6502 Klaus Test Program
Yep, everything except BCD has been tested at this point.
6502 sources on GitHub: https://github.com/Klaus2m5