6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun May 12, 2024 10:48 am

All times are UTC




Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: 6502 Klaus Test Program
PostPosted: Sun Nov 30, 2014 5:17 am 
Offline

Joined: Sun Nov 30, 2014 5:15 am
Posts: 18
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?


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 30, 2014 4:04 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1686
Location: Sacramento, CA
Give the Kowalski Simulator a try. It supports 6502 and 65C02.

http://exifpro.com/utils.html

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 30, 2014 4:54 pm 
Offline

Joined: Sun Nov 30, 2014 5:15 am
Posts: 18
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.


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 30, 2014 5:06 pm 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
Bob,

could you please post the listing as an attachment or link?

_________________
6502 sources on GitHub: https://github.com/Klaus2m5


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 30, 2014 5:12 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
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


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 30, 2014 5:29 pm 
Offline

Joined: Sun Nov 30, 2014 5:15 am
Posts: 18
Klaus2m5 wrote:
Bob,

could you please post the listing as an attachment or link?


Thanks, I've attached the generated list file.

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 129 times
Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 30, 2014 6:08 pm 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
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.

_________________
6502 sources on GitHub: https://github.com/Klaus2m5


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 30, 2014 6:56 pm 
Offline

Joined: Sun Nov 30, 2014 5:15 am
Posts: 18
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.


Okay, that's really weird. I thought maybe there was something that needed to get changed in the asm file before I assembled. I've attached the hex file thats being generated, although I expect it to be the same as what you have.

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 114 times
Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 30, 2014 9:14 pm 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
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.
:shock: O.K., I understand the issue now!

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 01, 2014 3:11 am 
Offline

Joined: Sun Nov 30, 2014 5:15 am
Posts: 18
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.
:shock: O.K., I understand the issue now!

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.


That was it! What threw me off was that I was running Kowalski's emulator in "animate mode" which was stepping through the code fast, but not fast enough, so it made it look like I was in an infinite loop. My emulator did have a bug which was actually producing an infinite loop in that same spot.

Thanks for the help and your test program, it's very comprehensive!


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 07, 2014 9:55 pm 
Offline

Joined: Sun Nov 30, 2014 5:15 am
Posts: 18
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.


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 07, 2014 10:32 pm 
Offline
User avatar

Joined: Mon Apr 23, 2012 12:28 am
Posts: 760
Location: Huntsville, AL
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 08, 2014 9:48 am 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
Thanks Michael. In the assembler source you can search for:
Code:
; decimal add/subtract test

_________________
6502 sources on GitHub: https://github.com/Klaus2m5


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 11, 2014 4:41 pm 
Offline

Joined: Sun Nov 30, 2014 5:15 am
Posts: 18
Code:
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 subtract


I'm able to get to $32f4 as seen above. Does this mean that I passed Klaus' test? I'm writing an NES emulator for now, so I'd like to test everything but BCD.


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 11, 2014 4:50 pm 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
Yep, everything except BCD has been tested at this point.

_________________
6502 sources on GitHub: https://github.com/Klaus2m5


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: