Functional Test for the NMOS 6502 - request for verification

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
zellyn
Posts: 16
Joined: 28 Feb 2013
Location: San Francisco, California
Contact:

Re: Functional Test for the NMOS 6502 - request for verifica

Post by zellyn »

Klaus2m5: yes, the ignored reads don't have any effect without other hardware attached :-)

Unfortunately, I didn't write down the exact instruction that failed, and I fixed all of them at the same time. It was something like STA $D0,y - with y > $30: it was writing to page 1, because I was doing a 16-bit add. When my current test-run (a full run of your tests comparing all memory reads and writes to the gate-level implementation) finishes, I'll try to re-break it and find that problem again.

I didn't change anything about the file: just compiled it as-is, with the binary image starting at $a.
Klaus2m5
Posts: 442
Joined: 28 Jul 2012
Location: Wiesbaden, Germany

Re: Functional Test for the NMOS 6502 - request for verifica

Post by Klaus2m5 »

zellyn wrote:
It was something like STA $D0,y - with y > $30
There is no STA zp,y in the 6502 instruction set and assemblers convert this to STA abs,y. This is expected to cross into the next page.
6502 sources on GitHub: https://github.com/Klaus2m5
zellyn
Posts: 16
Joined: 28 Feb 2013
Location: San Francisco, California
Contact:

Re: Functional Test for the NMOS 6502 - request for verifica

Post by zellyn »

Ugh. Serves me right for making up examples without checking. I'll get back here when I have a chance to re-break my emulator.
whartung
Posts: 1004
Joined: 13 Dec 2003

Re: Functional Test for the NMOS 6502 - request for verifica

Post by whartung »

Does anyone know of an assembler that can run on the Mac OS and assemble this file, or that this file can be (reasonably) trivially adapted to? I don't have access to Windows, and I tried to run a Linux assembler on a VM, but the binary download was missing some dependency that I simply wasn't about to go trying to track down. And the assembler didn't have source code, so I couldn't rebuild it.

I tried loading the binary that's with the source code, and running that, but it's just nonsense trying to figure out where it's all locked up without an assembly listing, plus I may have to play with things (since BRK doesn't work on my system, nor do interrupts).
zellyn
Posts: 16
Joined: 28 Feb 2013
Location: San Francisco, California
Contact:

Re: Functional Test for the NMOS 6502 - request for verifica

Post by zellyn »

I've been running it in VirtualBox, with a shared folder.
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Functional Test for the NMOS 6502 - request for verifica

Post by BigEd »

whartung wrote:
I tried loading the binary that's with the source code, and running that, but ...
Which binary? Which source code? Sorry, too little context to be of any help here.
Cheers
Ed
zellyn
Posts: 16
Joined: 28 Feb 2013
Location: San Francisco, California
Contact:

Re: Functional Test for the NMOS 6502 - request for verifica

Post by zellyn »

whartung, here's what I've been doing.

I set up an Ubuntu VirtualBox image, with a shared folder. I then downloaded and installed the 6502 assembler from http://www.kingswood-consulting.co.uk/assemblers/, and used the command line specified in the functional test source. It works just fine for me (on Mac OS).

I intend to eventually write an assembler in go, which will be trivially cross-platform, but haven't gotten around to it yet.

Zellyn
whartung
Posts: 1004
Joined: 13 Dec 2003

Re: Functional Test for the NMOS 6502 - request for verifica

Post by whartung »

zellyn wrote:
I set up an Ubuntu VirtualBox image, with a shared folder. I then downloaded and installed the 6502 assembler from http://www.kingswood-consulting.co.uk/assemblers/, and used the command line specified in the functional test source. It works just fine for me (on Mac OS).
Yea, the linux I was using didn't, so maybe I'll try it with Ubuntu. I have a bunch more diskspace so firing up another VM shouldn't be a problem.
Quote:
I intend to eventually write an assembler in go, which will be trivially cross-platform, but haven't gotten around to it yet.
Yea, I have an assembler, I'm just not motivated to fix it to build this project. It's mostly missing macros, but other things as well. I just want to fix the simulator of any problems, then go back and tackle the assembler.
whartung
Posts: 1004
Joined: 13 Dec 2003

Re: Functional Test for the NMOS 6502 - request for verifica

Post by whartung »

BigEd wrote:
whartung wrote:
I tried loading the binary that's with the source code, and running that, but ...
Which binary? Which source code? Sorry, too little context to be of any help here.
From the Tools page, there's a link to cl_6502, a simulator in Common Lisp up on github, which seems to be the source hosting point for this test suite. There's also a binary of it hosted there as well.
zellyn
Posts: 16
Joined: 28 Feb 2013
Location: San Francisco, California
Contact:

Re: Functional Test for the NMOS 6502 - request for verifica

Post by zellyn »

The cl-6502 github repo does have an up-to-date version, thanks to BigEd's pull request. The authoritative source is the "Downloads" section of http://2m5.de

I have a version here too: https://github.com/zellyn/go6502/tree/master/tests

Beware that the lowest referenced memory address is $000A, so depending on what format you assemble to, it may need to be loaded there. Some assembler formats are sparse: they include only the relevant ranges, and omit the gaps between them. You can see that in my tests, I assembled it without gaps, but still need to load starting at location $000A: https://github.com/zellyn/go6502/blob/m ... est.go#L61

Hope that helps.

Zellyn
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Functional Test for the NMOS 6502 - request for verifica

Post by BigEd »

Thanks for clarifying what you did, whartung! Same as zellyn, I found I had to use the specific assembler the test suite is written for, but that was straightforward for me because I already run Linux - as it happens, Ubuntu. Both Ubuntu and Debian are usually pretty good for resolving dependencies:
apt-file find filename
sudo apt-get install packagename
(And if you don't have apt-file, then "sudo apt-get install apt-file" will get it.)
Cheers
Ed
whartung
Posts: 1004
Joined: 13 Dec 2003

Re: Functional Test for the NMOS 6502 - request for verifica

Post by whartung »

BigEd wrote:
Thanks for clarifying what you did, whartung! Same as zellyn, I found I had to use the specific assembler the test suite is written for, but that was straightforward for me because I already run Linux - as it happens, Ubuntu. Both Ubuntu and Debian are usually pretty good for resolving dependencies:
apt-file find filename
sudo apt-get install packagename
(And if you don't have apt-file, then "sudo apt-get install apt-file" will get it.)
I got ubuntu up and running in VirtualBox last night, but I wasn't able to get the host enhancements or whatever they're called installed to get shared folders working, so I'll try to get that working some more tonight.

If y'all are having success with it, I'm sure it should drop right in once I get it up and running. If all else fails, I could probably spool up a WEBDAV share on the linux box and mount that on the Mac -- that would probably work fine for my needs as well.
zellyn
Posts: 16
Joined: 28 Feb 2013
Location: San Francisco, California
Contact:

Re: Functional Test for the NMOS 6502 - request for verifica

Post by zellyn »

@whartung: If you simply want an unmodified compilation of the binary, you can grab it from my repo and load it at $000A. However, I strongly recommend having a listing handy with annotated memory addresses...
redline6561
Posts: 2
Joined: 22 May 2013

Re: Functional Test for the NMOS 6502 - request for verifica

Post by redline6561 »

I guess it's about time I made my first post. I'm the author of cl-6502[0].
@Klaus: Your test suite is fantastic. Thank you so much for making it. It made my life much easier as someone new to hardware emulation.

I've successfully run the tests (with decimal mode disabled) on lib6502[1] after a small patch to the PHP opcode[2]. It completed in about 0.1 seconds...roughly 100x faster than cl-6502. -_-
py65 also completed the tests as reported before by @BigEd. I took the liberty of timing it with a small script[3]. py65 completes the test in about 126 seconds... roughly 10x slower than cl-6502. :P
Obviously, these benchmarks are both sloppy and just for fun. FWIW, I have some optimizing left to do.

Cheers,
B

[0]: http://github.com/redline6561/cl-6502
[1]: http://piumarta.com/software/lib6502/ Command used was 'time ./run6502 -l a test.bin -R 1000 -X 3c37'
[2]: Told ya it was small.
-#define php(ticks, adrmode) phR(ticks, adrmode, P)
+#define php(ticks, adrmode) phR(ticks, adrmode, P | flagX | flagB)
[3]: bench.sh
#!/usr/bin/python
import py65.monitor
m = py65.monitor.Monitor()
m.do_load('test.bin a')
m.do_goto('1000')
exit()
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Functional Test for the NMOS 6502 - request for verifica

Post by BigEd »

Great speedup! And welcome to the forum!
Post Reply