Functional Test for the NMOS 6502 - request for verification

Programming the 6502 microprocessor and its relatives in assembly and other languages.
iLavr
Posts: 7
Joined: 24 Dec 2014

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

Post by iLavr »

BigEd wrote:
I found and fixed some problems in the easy6502 simulator, which Nick has now updated.
http://skilldrick.github.com/easy6502/#first-program
Yes, I see, that this post is 2 years old, but can BigEd or smb. else explain me
how to use 6502_functional_test in Nick's easy6502 simulator ?

Image
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 »

I just checked my notes, and what I did was use the recommended as65 assembler to make a binary file, and then transform the binary file into a load of dcb statements. I then pasted the dcb statements into an easy6502 window, perhaps with a .org directive.

Code: Select all

$ xxd -p *bin|sed 's/\(..\)/,$\1/g;s/^/dcb/;s/,/ /' | head
dcb $4c,$87,$43,$00,$ff,$ff,$ff,$ff,$ff,$ff,$c3,$82,$41,$00,$7f,$00,$00,$00,$00,$00,$00,$1f,$71,$80,$0f,$ff,$7f,$80,$ff,$0f
dcb $8f,$8f,$00,$02,$01,$02,$02,$02,$03,$02,$04,$02,$08,$01,$33,$02,$34,$02,$35,$02,$36,$02,$3b,$01,$3c,$02,$3d,$02,$3e,$02
dcb $3f,$02,$40,$02,$41,$02,$42,$02,$43,$02,$38,$02,$39,$02,$3a,$02,$3b,$02,$58,$02,$59,$02,$59,$01,$5a,$01,$00,$00,$00,$00
dcb $00,$00,$00,$00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
Klaus2m5
Posts: 442
Joined: 28 Jul 2012
Location: Wiesbaden, Germany

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

Post by Klaus2m5 »

Hi iLavr,

and welcome to the forum. I am currently running the functional test on easy6502. Here is what I did:

I assembled the test with ROM_vectors = 0 (BRK does not seem to work in easy6502), data_segment = $600 (easy6502 has a screenbuffer from $200-$5ff) and code_segment = $800. Everything else remained at its default value.
  1. I took the resulting Intel hex file and edited it in a macro editor (I used PSPad, but it should work in any other macro capable editor).
  2. convert all to lower case (there is a bug in easy6502: *=$A fails, *=$a works)
  3. pad all lines with xx until all have the same length
  4. record a macro parsing one line into separate *=$ and dcb statements, add $ or ,$ to every byte (thanks for the idea by BigEd to convert assembler output to dcb statements)

    Code: Select all

    This:
    :2006200080810180028101800001000102818081807F80FF00010080800200001F71800F0E
                                                           checksum (delete) --
             ----------------------------------------------------------------
             data (dcb $xx,$xx,$xx...[newline]) twice with 16 Bytes each
           -- function 00 = data (delete)
       ---- location (*=$xxxx[newline])
     -- byte count (delete)
    - start of hex record (delete)
    
    should be converted to this:
    *=$0620
    dcb $80,$81,$01,$80,$02,$81,$01,$80,$00,$01,$00,$01,$02,$81,$80,$81
    dcb $80,$7f,$80,$ff,$00,$01,$00,$80,$80,$02,$00,$00,$1f,$71,$80,$0f
    
  5. run the macro on every line in the Intel hex file
  6. remove all ,$xx and all lines from the last *=$0800 (setting the start address)
  7. copy all into easy6502
  8. click [Assemble], click Debugger checkbox, click [Jump to] and enter $800
  9. click [OK] and uncheck Debugger, click [Run]
  10. be very patient! (mine is running for an hour now)
  11. a few warnings about stack wrapping appear as a result of the stack overflow test
  12. when the PC is not updating any more, check the listing for error or success
6502_func_test_easy_6502.zip
modified 6502 functional test for use with easy6502.
(86.32 KiB) Downloaded 398 times
6502 sources on GitHub: https://github.com/Klaus2m5
iLavr
Posts: 7
Joined: 24 Dec 2014

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

Post by iLavr »

Thanks, BigEd! Thanks, Klaus2m5! You are very kind!

I am making my own version of 6502 JS simulator, using the old
Stian Søreng sources: 6502 assembler.
And I see, that Nick Morgan has patched the original code a lot.

Spent a half of night, looking for bugs in my code... :wink: Thanks for help!
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 »

Glad to be of some assistance - and welcome!
iLavr
Posts: 7
Joined: 24 Dec 2014

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

Post by iLavr »

Klaus2m5 wrote:
  • be very patient! (mine is running for an hour now)
  • a few warnings about stack wrapping appear as a result of the stack overflow test
  • when the PC is not updating any more, check the listing for error or success
Hi All,
Before testing my own 6502 JS simulator I've observed the Nick's easy6502 simulator
behavior while executing this special version of Functional Test for the NMOS 6502.
And here is the result:

Image

I see that:

Code: Select all

                        ; S U C C E S S ************************************************
                        ; -------------
                                success         ;if you get here everything went well
3819 : 4c1938          >        jmp *           ;test passed, no errors

                        ; -------------
                        ; S U C C E S S ************************************************
But I wonder, and I don't understand yet such a thing that in Nick's easy6502 simulator
the B flag is always set! :shock:
I think that
Quote:
The copy of the status register that is pushed on to the stack will have the B flag set if
a BRK (software interrupt) was the cause of the interrupt
, or cleared if an IRQ was the cause.
In my version the reg P is initiated with $20 value, but in Nick's it starts with reg P = $30...
Attachments
B_flag6502.gif
Klaus2m5
Posts: 442
Joined: 28 Jul 2012
Location: Wiesbaden, Germany

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

Post by Klaus2m5 »

A few weeks ago I answered almost the same question (viewtopic.php?f=8&t=3111#p35579):
Klaus2m5 wrote:
The emulators just follow the behavior of a real 6502 or any of its hardware successors. The unused bit returns a 1 when read, because it is not present in hardware and reading an open circuit simply returns a logic high state. The same is true for the break bit, as it is not an existing flag bit register but a forced low to an otherwise open circuit. The bit is forced low only when the processor flag bits are pushed onto the stack during either an IRQ or a NMI. So the break bit would be better defined to signal "pushed by software" (BRK or PHP only).
There is also a discussion in this thread about my test expecting these bits to be on after a PHP. viewtopic.php?f=2&t=2241&start=30#p20914
6502 sources on GitHub: https://github.com/Klaus2m5
iLavr
Posts: 7
Joined: 24 Dec 2014

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

Post by iLavr »

Thanks, Klaus!

I'll pay attention on such behavior of the B flag in my code.
fsakura
Posts: 7
Joined: 19 Nov 2014

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

Post by fsakura »

I know this might be asked numerous times on this forum, but still I could not get clear and simple answer for it.

My question is:
1. I have written a 6502 emulator in Java and I want to test it. How do I do it?
2. A little bit of search showed me I can use test suite by Klaus.
His test suite is ASM code which we can build into a binary. I can run this binary with my emulator.
But against what should I compare my output for each step. I'm confused.

All in all, this is what my understanding is:
1. I get a file with set of 6502 instructions
2. I also get a corresponding file which shows values for each register and flag for each instruction in step 1.

I run file in step 1 and compare my output against values in step 2 for each instruction. This will verify if all basic operations are error free.

How do I do this with Klaus's test suite? Am I missing something?
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 »

Hi - you're missing that Klaus' suite is self-checking. It always lands in a tight loop. The final tight loop signals success, whereas all the possible tight loops at lower addresses signal a failure. So you need a setup which detects and reports the final PC value after the machine gets into a tight loop. (And you need to know the addresses of the loops, so you need not just the binary file but also a listing file. Klaus supplies both.)

Or, you can modify the macros which do this, to signal the result in some other way.

Hope this helps
Ed
pebmeister
Posts: 32
Joined: 19 Feb 2013
Location: Marlborough, Ma

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

Post by pebmeister »

I don't want to hijack this thread but I have a simple question how can I get the assembler list file for the
6 5 C 0 2 E X T E N D E D O P C O D E S T E S T by Klaus Dorman

I have rewritten parts of my assembler to be almost 100% compatible with the source.
There are some minor exceptions such as HI and LO are functions (requires parameter in () ) and and labels that get redefined must be declared as vars.

I am not 100 per cent sure that it is correct. If it is correct then I am done and will write a manual for it.

Thanks for any help
Paul
Klaus2m5
Posts: 442
Joined: 28 Jul 2012
Location: Wiesbaden, Germany

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

Post by Klaus2m5 »

Sent a PM with the requested list file.
6502 sources on GitHub: https://github.com/Klaus2m5
Dennis
Posts: 6
Joined: 05 Mar 2017

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

Post by Dennis »

Thanks Klaus for your testing suite. I'm currently stuck on my 6502 emulator, and can't find out what's wrong. It runs till test 42 ($3249) and halts on ($335A), using the the functional test bin found in the NESkell https://github.com/blitzcode/neskell/tr ... onal_tests source. I've used that bin because they've included a vis6502 trace cpu listing which helped me finding another bug by comparing my cpu trace to that trace. unfortunately it doesn't run beyond test 40. Could someone provide a complete trace of this test suite (along with the binary+listing, if not default found under bin_files\ )? That would be really great (I've failed setting up vis6502 for trace logging, after some hours it just fails - looks like my potato computer isn't powerful enough ;-). Thank you!
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 »

Welcome to the forum, Dennis, and congratulations on getting as far as test 42. This is the decimal arithmetic test, and the final test, which means your core passes all the tests except decimal. For many purposes, you are done.

For testing decimal arithmetic, you might want to switch to Bruce Clark's tests and to read his document at
http://www.6502.org/tutorials/decimal_mode.html
- it's easier to follow and to run, and once you pass this test you'll also pass Klaus' tests.

(Thanks for the pointer to neskell - interesting idea to provide so much visual6502 logging data!)
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 »

Here's another idea: take perfect6502 as a starting point, and modify it to produce the traces you need. It's a C program, implementing the same transistor-level model as visual6502, and should be easier to work with for these purposes.
https://github.com/mist64/perfect6502
Post Reply