klaus2m5 / 6502_65c02_functional_tests Goto Github PK
View Code? Open in Web Editor NEWTests for all valid opcodes of the 6502 and 65C02 processor
License: GNU General Public License v3.0
Tests for all valid opcodes of the 6502 and 65C02 processor
License: GNU General Public License v3.0
It appears that the files 6502_functional_test.bin/lst
checked in under bin_files
have not been updated to reflect the latest commit from 2020
By the way - Thanks for creating this—it's awesome!
Hi Klaus,
I have just been writing a small 6502 simulator in Python3 for supporting my own FPGA developments, and found your very useful test suite. I have made a little modification in your asm code to be able to produce a complete ROM image with reset vector pointing to the start of the testing code. The reset vector is written back to point original "res_trap" vector, right after the start. This feature is useful when you start the testing code on a simple virtual microcomputer which has no other executable code apart from this testing suite -> after "powering on" this machine, the test code is started immediately by the reset mechanism.
If you find this extension usable, please feel free to lift it into your test code. Attached zip contains the complete modified asm.
Thank you for attention,
Zoltan
I have a question about this portion of your functional test
37c3 : ba tsx ;test break on stack
37c4 : bd0201 lda $102,x
cmp_flag 0 ;break test should have B=1 & unused=1 on stack
37c7 : c930 > cmp #(0 |fao)&m8 ;expected flags + always on bits
This is what I see in my emulator:
37C3: BA TSX A=42 X=FB Y=48 S=FB P=B1 PC=$37C3 P={$B1 N=1 V=0 B=1 D=0 I=0 Z=0 C=1} SP={$FB stack:[$1FF:$09 $1FE:$CF $1FD:$00 $1FC:$30 ]}
37C4: BD 02 01 LDA $0102,X A=00 X=FB Y=48 S=FB P=33 PC=$37C4 P={$33 N=0 V=0 B=1 D=0 I=0 Z=1 C=1} SP={$FB stack:[$1FF:$09 $1FE:$CF $1FD:$00 $1FC:$30 ]}
37C7: C9 30 CMP #$30 A=00 X=FB Y=48 S=FB P=B0 PC=$37C7 P={$B0 N=1 V=0 B=1 D=0 I=0 Z=0 C=0} SP={$FB stack:[$1FF:$09 $1FE:$CF $1FD:$00 $1FC:$30 ]}
37C7: D0 30 BNE $37C7 A=00 X=FB Y=48 S=FB P=B0 PC=$37C7 P={$B0 N=1 V=0 B=1 D=0 I=0 Z=0 C=0} SP={$FB stack:[$1FF:$09 $1FE:$CF $1FD:$00 $1FC:$30 ]}
As you can see, my stack contains the expected value (#$30), however, TSX
followed by LDA $102,X
points toward the next available spot of the stack, not the current value. So I get 0 and the test fails.
Am I missing something?
I'm writing a nes emulator which uses a custom NMOS 6502 that doesn't implement decimal mode ADC/SBC. It would be nice to have an option not to test this functionality.
First, thank you very much for this fantastic suite.
This is not really an issue, but I've noticed that the compiled examples belong to a previous version. The 6502 LST file states 2015 and the 65c02 LST file states 2017.
I've compiled myself the 6502 and I've obtained a different HEX/BIN and LST file.
Raul
I'm writing a Lynx emulator and I've used this test suit many months ago and my CPU emulation eventually passed it (after many corrections as the tests are excellent and I've found many bugs thanks to them). It turns out that I had one bug more - in RMW operations addressing absolutely with indexing (e.g. inc $80ff,x
) when page crossing occurred ( here x > 0 ) the read was from correct address but write to not corrected (i.e. to page $80 not $81 in above example). It wasn't cached by this test suit.
Hi, I have a problem with the 65c02 test code:Two uninitialized memory spaces are compared and this leads to a trap.
Should really the index register y be used? x is cleared jut before. But then a loop over y is programmed...
; testing load / store accumulator LDA / STA (zp)
.
.
.
trap_ne
cpx #$99
trap_ne ;x altered during test
cpy #$66 <= Here it is clear that y is #$66
trap_ne ;y altered during testorg
ldx #0
tstai2 lda abst,y <= Here $0205 + $66 = $026B is read, which is uninitialized
eor #$c3
cmp abs1,y <= Here $0210 + $66 = $0276 is read, which is uninitialized
trap_ne ;store to indirect data <= Compare fails and trap occurred
txa
sta abst,y ;clear
dey
bpl tstai2
tsx
cpx #$ff
trap_ne ;sp push/pop mismatch
next_test
As indicated in the source code, I followed the link to the AS65 assembler at the indicated link: http://www.kingswood-consulting.co.uk/assemblers/ which is unfortunately broken. As a retro-computing fan, I see a lot of these issues happening. In fact, nowadays it would be not a bad idea to simply include the compiler into the project to avoid any external dependencies. Another option would be to re-write the source-code to run on more widespread assemblers, or publish compiled hex-code listings alongside.
The 6502 test checks the BRK instruction only with the interrupt disable flag off. The additional 65C02 test makes the humble assumption that the BRK instruction works in general and does not check if the BRK is actually executed.
I will add a second pass with I flag on to the test and repeat the full BRK test for the 65C02.
A bug reported in the a6502 emulator project indicates a possible test hole, because I believe that project passes this test suite. See
BigEd/a6502#2
when carry flag is cleared and register value is 0x01, it fails to set zero flag.
(I haven't yet been able to test this myself.)
Hello!
Could you add the missing bin file for the interrupt tests and the decimal tests?
(and seeing that the other tests got an update a few weeks ago, perhaps update the two other bin files with the recent changes?)
Thanks a lot!
Hi
This is not a ticket - but I haven't got your email address, so ;-)
I am one of countless others who are having fun implementing a 6502 simulator. I have included
one bin file from your repo (6502_functional_test.bin). How do you want me to credit you?
Best
Morten
Maybe allow for self modifying code to be an option?
See http://stackoverflow.com/q/31260415 where someone wants to run from ROM
I tried to compile the .bin files myself on a Windows 10 VM, using the zipped as65.exe.
./as65.exe -l -m -w -h0 ../6502_functional_test.a65
Somehow, the resulting .bin file's codes segment starts 10bytes before 0x0400
.
I fixed this using
dd if=6502_functional_test.bin of=6502_functional_test.bin.padded bs=1 seek=10
Any idea why this happens?
Hi,
I'm adding 65C02 support to an emulator and currently stuck on the TRB tests for 65C02
It completes an op1 loop, but appears to fail when OP2/$0B = $01
As you can see, AND $0B does not set the Zero flag because A=1 and $0B = 1.
I should note that this emulator passes the 6502 Tests with no issues so I'm really confused as to what is going on here.
ZPG values at failure time:
0008-000F 00 00 01 01 00 00 01 81
Trace log:
1CC2 98 TYA A:01 X:C0 Y:01 F:21 S:1FF [..-....C]
1CC3 25 0B AND $0B A:01 X:C0 Y:01 F:21 S:1FF [..-....C]
1CC5 08 PHP A:01 X:C0 Y:01 F:21 S:1FE [..-....C]
1CC6 68 PLA A:31 X:C0 Y:01 F:21 S:1FF [..-....C]
1CC7 29 02 AND #$02 A:00 X:C0 Y:01 F:23 S:1FF [..-...ZC]
1CC9 85 0C STA $0C A:00 X:C0 Y:01 F:23 S:1FF [..-...ZC]
1CCB 98 TYA A:01 X:C0 Y:01 F:21 S:1FF [..-....C]
1CCC 49 FF EOR #$FF A:FE X:C0 Y:01 F:A1 S:1FF [N.-....C]
1CCE 05 0B ORA $0B A:FF X:C0 Y:01 F:A1 S:1FF [N.-....C]
1CD0 49 FF EOR #$FF A:00 X:C0 Y:01 F:23 S:1FF [..-...ZC]
1CD2 85 0D STA $0D A:00 X:C0 Y:01 F:23 S:1FF [..-...ZC]
1CD4 98 TYA A:01 X:C0 Y:01 F:21 S:1FF [..-....C]
1CD5 05 0B ORA $0B A:01 X:C0 Y:01 F:21 S:1FF [..-....C]
1CD7 85 0E STA $0E A:01 X:C0 Y:01 F:21 S:1FF [..-....C]
1CD9 84 0A STY $0A A:01 X:C0 Y:01 F:21 S:1FF [..-....C]
1CDB A9 FF LDA #$FF A:FF X:C0 Y:01 F:A1 S:1FF [N.-....C]
1CDD 48 PHA A:FF X:C0 Y:01 F:A1 S:1FE [N.-....C]
1CDE A5 0B LDA $0B A:01 X:C0 Y:01 F:21 S:1FE [..-....C]
1CE0 28 PLP A:01 X:C0 Y:01 F:FF S:1FF [NV-BDIZC]
1CE1 14 0A TRB $0A A:01 X:C0 Y:01 F:FF S:1FF [NV-BDIZC]
1CE3 08 PHP A:01 X:C0 Y:01 F:FF S:1FE [NV-BDIZC]
1CE4 C5 0B CMP $0B A:01 X:C0 Y:01 F:7F S:1FE [.V-BDIZC]
1CE6 D0 FE BNE $FE A:01 X:C0 Y:01 F:7F S:1FE [.V-BDIZC]
1CE8 68 PLA A:FF X:C0 Y:01 F:FD S:1FF [NV-BDI.C]
1CE9 48 PHA A:FF X:C0 Y:01 F:FD S:1FE [NV-BDI.C]
1CEA 09 02 ORA #$02 A:FF X:C0 Y:01 F:FD S:1FE [NV-BDI.C]
1CEC C9 FF CMP #$FF A:FF X:C0 Y:01 F:7F S:1FE [.V-BDIZC]
1CEE D0 FE BNE $FE A:FF X:C0 Y:01 F:7F S:1FE [.V-BDIZC]
1CF0 68 PLA A:FF X:C0 Y:01 F:FD S:1FF [NV-BDI.C]
1CF1 29 02 AND #$02 A:02 X:C0 Y:01 F:7D S:1FF [.V-BDI.C]
1CF3 C5 0C CMP $0C A:02 X:C0 Y:01 F:7D S:1FF [.V-BDI.C]
1CF5 D0 FE BNE $FE A:02 X:C0 Y:01 F:7D S:1FF [.V-BDI.C]
1CF5 D0 FE BNE $FE A:02 X:C0 Y:01 F:7D S:1FF [.V-BDI.C]
1CF5 D0 FE BNE $FE A:02 X:C0 Y:01 F:7D S:1FF [.V-BDI.C]
Hi, I really like your 6502 testing suite but I found an error in report.i65 that converts values to hexadecimal characters for IO debugging output:
Line 189: bcc rchar
This line in the "rnib" subroutine should actually be a BCS instead. Thanks :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.