6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 2:21 am

All times are UTC




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: 65816 Test Suite
PostPosted: Tue Jul 09, 2024 4:37 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
Hi all,

I needed a test suite for the Kowalski 65816 Simulator and found one on an NES Dev Forum. As it was originally written for an NES platform, I had to reconfigure the IO to work with the Kowalski Terminal IO. It has over 1600 tests that cover almost every instruction and every addressing mode, including many fringe cases and some undocumented anomalies.

I wanted to run this on my SBC-4 just to ensure all test pass on a real 65816. However, My IO map is currently in the way.

I'm placing the modified test suite here if anyone wants to give it a go on their system. It needs RAM from $008000 to $07FFFF. It also needs RAM at $000000 - $000300. IO can be a simple ASCII output and waiting input. See the "how to.txt" in the zip file.

The source was modified to assemble with the Kowalski Simulator.

thanks!
Daryl

EDIT: I forgot to mention, the "tests-full.txt" is a description of each test, input data and expected results. This was very helpful in debugging my simulator.

Daryl


Attachments:
File comment: Removed uart link & fixed 16 bit immediate issues
65816 Test Suite.zip [86.16 KiB]
Downloaded 20 times

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


Last edited by 8BIT on Sat Jul 27, 2024 10:34 pm, edited 2 times in total.
Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Tue Jul 09, 2024 11:22 am 
Offline

Joined: Wed Oct 16, 2013 9:34 am
Posts: 9
Hi, I'm experimenting with a 65816 vhdl core at the moment and this looks like just the thing to test it out. Do you have a link to the original as I didn't turn the up during my searches.

Thanks to BigEd for the pointer to this thread

D

Edit: I've found the original git by searching properly! https://github.com/gilyon/snes-tests and it's MIT licenced so that fits with my project nicely!


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Tue Jul 09, 2024 11:37 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
I also put a link to the NES Dev forum in the "how to.txt" file.

Daryl

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


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Tue Jul 09, 2024 12:05 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Nice find Daryl!


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Tue Jul 09, 2024 3:36 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
I hope others here will find it useful. It helped me for sure.

See my edit to the top post. That txt file was really helpful.

Daryl

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


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Tue Jul 09, 2024 3:37 pm 
Offline

Joined: Wed Oct 16, 2013 9:34 am
Posts: 9
Yes, thanks Daryl.

I've got a way to go before my core is quite ready to tackle these tests (it passes Dormann NMOS and CMOS tests currently) but I'm looking forward to having a good test of edge cases. I'd particularly forgotten about the PLB wrap "feature"!

D


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Tue Jul 09, 2024 4:03 pm 
Offline
User avatar

Joined: Tue Feb 28, 2023 11:39 pm
Posts: 257
Location: Texas
I have to ask, did you add tests for the BCD mode? The Ricoh 65xx variants stripped out decimal mode, so those should allow the flag to be set, but ignore it when it is.


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Tue Jul 09, 2024 4:16 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
I did not write these tests... I only modified the existing tests. BCD is tested, but those tests were placed at the end and would be easy to exclude in the source.

Specifically, Test 05ac is the first BCD test. You would just add "JML success" right before label "test05ac:" in "tests-full.inc" and BCD would not be tested.

Daryl

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


Last edited by 8BIT on Wed Jul 10, 2024 9:17 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Tue Jul 09, 2024 5:54 pm 
Offline

Joined: Sun Jun 29, 2014 5:42 am
Posts: 352
dominicbeesley wrote:
I'd particularly forgotten about the PLB wrap "feature"!

Indeed, that reminds me the 65816 emulation in the 6502Decoder still had a couple of TODO's regarding the stack wrapping of new instructions (like PHB/PLB) in emulation mode. Let me know when you hit these bugs and I'll try to fix them.

Dave


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Wed Jul 10, 2024 7:14 am 
Offline

Joined: Wed Oct 16, 2013 9:34 am
Posts: 9
Thanks Hoglet,

Are the known differences listed anywhere?

I got a lot further than I expected yesterday evening and I'm on to the stack relative addressing modes now - I'm not clear when or how these should wrap in Emulation mode. Should the behaviour in 6502decoder be right for these cases. If you're not sure I'll break out the Blitter/real hardware.... its just bit of a pita moving the lx2 between the fpga rig and the BBC Micro...

I'm hoping I'll have a build of these tests before the weekend and can do a full run with Hoglets decoder hooked up. That should test both functionality _and_ cycle accuracy of all the edge cases. I'll run the test suite on real hardware too hopefully fully verify decode6502?

One thing that might slow me down a little is memory. I'm using a Gowin fpga which has roughly 128k of block RAM so and I'm limited to using just block RAM when hooked up to the logic analyser for want of pins. So I'm going to have to look at how I can limit the test suite to need fewer banks (or smaller memory fragments in each bank) or if that isn't possible I'll need to swap to a different fpga board. I think I'll need to have a closer look at the .py file.

How full is the 32k ROM? I'll be able to omit the fonts and init code as my test bed is just s dead simple memory+uart system

D


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Wed Jul 10, 2024 5:49 pm 
Offline

Joined: Sun Jun 29, 2014 5:42 am
Posts: 352
dominicbeesley wrote:
Thanks Hoglet,
Are the known differences listed anywhere?

So far, every 65816 question I've had has been answered by Bruce Clark's document:
http://www.6502.org/tutorials/65c816opcodes.html

Stack relative addressing is covered in section 5.10.

The appendix covers the foibles of emulation mode.

If this excellent document doesn't answer your question, I suspect you'll need to resort to checking real hardware.

Dave


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Wed Jul 10, 2024 6:42 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
There was also this in the Test Suite Readme:
Code:
What undocumented behavior is testsed?
In emulation mode with S=$1FF, the PLB instruction should read from $200 instead of $100. This is despite the fact that the CPU manual doesn't list it with the instructions that can access outside the stack page.
In emulation mode when the low byte of D is nonzero, the (direct,X) addressing mode behaves strangely:
The low byte of the indirect address is read from direct_addr+X+D without page wrapping (as expected). The high byte is read from direct_addr+X+D+1, but the +1 is done with wrapping within the page. For example: Emulation=1, D=$11A, X=$EE, and the instruction is lda ($F7,X). Here $F7 + $11A + $EE = $2FF. The low byte of the address is read from $2FF and the high byte from $200. This behavior only applies to this addressing mode, and not to other indirect modes.
The behavior of decimal mode isn't fully documented. See appendix A of this document for a full specification.   http://www.6502.org/tutorials/decimal_mode.html#A


Also, many of the new addressing modes have unexpected behavior in emulation mode. I found the "tests-full.txt" and reading the assembly code for the specific test that failed helped me understand the expected operation better.

Daryl

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


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Wed Jul 10, 2024 9:47 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8504
Location: Midwestern USA
8BIT wrote:
Also, many of the new addressing modes have unexpected behavior in emulation mode.

...which is why I strongly recommend not operating the 816 in emulation mode unless absolutely necessary.  There are too many ambiguities in emulation-mode behavior.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Thu Jul 11, 2024 7:03 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Well, that's a preference BDD, but it's absolutely against my preference and recommendation. Indeed, we have a thread about this sub-topic. Perhaps that's a better place to discuss it.

(Just writing this as a counter-point - your recommendations and strong recommendations are, of course, only yours. I wouldn't want your opinions to be taken as consensus.)


Top
 Profile  
Reply with quote  
 Post subject: Re: 65816 Test Suite
PostPosted: Thu Jul 11, 2024 8:57 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
I think people can figure that out, Ed.  They don't need your interpretation on everything.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 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: