Micro programmed 6502-like CPU
Re: Micro programmed 6502-like CPU
After adding a hidden carry, I have now written microcode for each and every instruction, except SED and CLD, as I'm not implementing decimal mode. Also NMI is missing as of now, I'll add that later if I see the need.
I have lightly tested every instruction and ran some sample programs and it seems to work fine.
After painstakingly writing 1000+ lines of code to generate all microcode and implementing and debugging each instruction, writing in assembly is going to be an enjoyable activity I'm sure.
I'll tidy things up a bit and publish the logisim files so anyone can have play around if they wish to.
Juan
I have lightly tested every instruction and ran some sample programs and it seems to work fine.
After painstakingly writing 1000+ lines of code to generate all microcode and implementing and debugging each instruction, writing in assembly is going to be an enjoyable activity I'm sure.
I'll tidy things up a bit and publish the logisim files so anyone can have play around if they wish to.
Juan
Re: Micro programmed 6502-like CPU
Congratulations!
Re: Micro programmed 6502-like CPU
I am now looking for some sort of test program so I can ensure that all opcodes work well. I have found this
https://github.com/Klaus2m5/6502_65C02_functional_tests
but I'm not able to find the as65 assembler that this code is written for (plenty of sites point to this broken site: http://www.kingswood-consulting.co.uk/assemblers/).
I have tried with a65 assembler (without the s) with no luck, it gives me "Fatal Error -- If Stack Overflow".
Any ideas? Or any other test program that I can use? Thanks. Ideally something that doesn't use any input-output beyond memory and with optional decimal mode, as my CPU does not have that. But I suppose I can modify something to suit my needs
Juan
https://github.com/Klaus2m5/6502_65C02_functional_tests
but I'm not able to find the as65 assembler that this code is written for (plenty of sites point to this broken site: http://www.kingswood-consulting.co.uk/assemblers/).
I have tried with a65 assembler (without the s) with no luck, it gives me "Fatal Error -- If Stack Overflow".
Any ideas? Or any other test program that I can use? Thanks. Ideally something that doesn't use any input-output beyond memory and with optional decimal mode, as my CPU does not have that. But I suppose I can modify something to suit my needs
Juan
Re: Micro programmed 6502-like CPU
Yep, see this post:
viewtopic.php?p=70183#p70183
viewtopic.php?p=70183#p70183
- GARTHWILSON
- Forum Moderator
- Posts: 8774
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Micro programmed 6502-like CPU
JuanGg wrote:
but I'm not able to find the as65 assembler that this code is written for
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Micro programmed 6502-like CPU
Have you tried archive.org? I was able to locate Frank's assemblers with that.
Cheers,
Andy
Cheers,
Andy
Re: Micro programmed 6502-like CPU
GARTHWILSON wrote:
JuanGg wrote:
but I'm not able to find the as65 assembler that this code is written for
BigEd wrote:
Yep, see this post:
viewtopic.php?p=70183#p70183
viewtopic.php?p=70183#p70183
I have taken the test program from here: https://github.com/Klaus2m5/6502_65C02_functional_tests and changed the configuration at the top so it ignores decimal mode and so that code starts at c000, where I have put a 16k ROM.
I assembled it with no errors and ended up with an Intel Hex file. By virtues of Notepad ++, I have stripped all addresses and check sums, and added a space in between each two characters. This ends up with the format Logisim needs.
Said file starts with 9 BRK opcodes, and as the IRQ vector is set to 0000, it continues execution on said address, where it reads another 00 and off it goes on an endless loop that just fills the stack.
Any ideas? it doesn't seem to specify those vectors in the test file. Maybe I should learn 6502 assembly first...
Juan
Last edited by JuanGg on Sun Dec 08, 2019 2:18 pm, edited 1 time in total.
Re: Micro programmed 6502-like CPU
handyandy wrote:
Have you tried archive.org? I was able to locate Frank's assemblers with that.
Cheers,
Andy
Cheers,
Andy
Re: Micro programmed 6502-like CPU
Most likely you haven't built the binary in the way you expected to: there are several options to comment in or out in the code, depending on how the zero page is to be initialised. What you're seeing as BRK are probably the first few bytes of storage, which shouldn't be placed in your ROM.
IIRC Klaus' repo includes binary images which are suitable for running in emulators. Just take care to load them at the right address. There are also listing files for these images so you can see which addresses correspond to which test fails.
BTW, the 'srecord' set of utilities are very useful for dealing with hex format conversions.
IIRC Klaus' repo includes binary images which are suitable for running in emulators. Just take care to load them at the right address. There are also listing files for these images so you can see which addresses correspond to which test fails.
BTW, the 'srecord' set of utilities are very useful for dealing with hex format conversions.
Re: Micro programmed 6502-like CPU
I wasn't doing it right. Now i have filled the 64k address space with a unique ram, that makes it easier.
Thanks for pointing srecord out, its awesome.
I have successfully loaded the test and began execution. It got stuck after a couple instructions, and I was able to fix the fault.
Now, it is reiterating though code around addresses $400-500. I don't know if something is failing or if it just takes too long. It seems to me that it's doing the same thing time and time again. Register Y starts at $fe and goes down to $66, then to $5, to $0 ,and back again.
In addition, with a maximun clock speed of 4 kHz, the simulation may take a while (10s of hours) to run the full test I'm afraid.
Juan
Thanks for pointing srecord out, its awesome.
I have successfully loaded the test and began execution. It got stuck after a couple instructions, and I was able to fix the fault.
Now, it is reiterating though code around addresses $400-500. I don't know if something is failing or if it just takes too long. It seems to me that it's doing the same thing time and time again. Register Y starts at $fe and goes down to $66, then to $5, to $0 ,and back again.
In addition, with a maximun clock speed of 4 kHz, the simulation may take a while (10s of hours) to run the full test I'm afraid.
Juan
Re: Micro programmed 6502-like CPU
Worked that out. My jump instruction wasn't working properly. Now it's getting stuck at $a88 and I'm finding it a bit difficult to track down. Any ideas?
Juan
Code: Select all
>
0a74 : 28 > plp ;restore status
endif
0a75 : d8 cld
tst_stat $ff-decmode
0a76 : 08 > php ;save status
0a77 : 68 > pla ;use stack to retrieve status
0a78 : 48 > pha
> cmp_flag $ff-decmode
0a79 : 0908 > ora #decmode ;ignore decimal mode b
0a7b : c9ff > cmp #($ff-decmode|faod)&m8 ;expected fla
>
> trap_ne
0a7d : d0fe > bne * ;failed not equal (non zero)
>
0a7f : 28 > plp ;restore status
0a80 : f8 sed
tst_stat $ff
0a81 : 08 > php ;save status
0a82 : 68 > pla ;use stack to retrieve status
0a83 : 48 > pha
> cmp_flag $ff
0a84 : 0908 > ora #decmode ;ignore decimal mode b
0a86 : c9ff > cmp #($ff|faod)&m8 ;expected flags + alw
>
> trap_ne
0a88 : d0fe > bne * ;failed not equal (non zero)
>
0a8a : 28 > plp ;restore status
Re: Micro programmed 6502-like CPU
Looks like your CPU hasn't saved (or hasn't restored) (or doesn't implement) the decimal flag in the processor status register.
Re: Micro programmed 6502-like CPU
I have disabled decimal flag and mode altogether, but I'm not sure what implications does that have.
Last place it was stuck on, it was because it was expecting unused bits of the status register to be 1, and I had them always set to 0. So I arranged it so unused bits would always be read as one, and D flag always as 0. I have now enabled D flag to be read as its current value and it makes no difference.
Juan
Code: Select all
;disable test decimal mode ADC & SBC, 0=enable, 1=disable,
;2=disable including decimal flag in processor status
disable_decimal = 2
Juan
Last edited by JuanGg on Sat Dec 14, 2019 6:58 pm, edited 1 time in total.
Re: Micro programmed 6502-like CPU
Hmm, odd, looking more carefully, I might guess that the test is indeed ignoring D and is checking all other bits (all 7 of them) are 1. Have you certainly set all 7 other bits to 1? That's including B and 'unused'.
Re: Micro programmed 6502-like CPU
BigEd wrote:
Hmm, odd, looking more carefully, I might guess that the test is indeed ignoring D and is checking all other bits (all 7 of them) are 1. Have you certainly set all 7 other bits to 1? That's including B and 'unused'.
It's coming along, and the logging functionality of logisim helps a great deal. But at effective clock speeds of hundreds of hertz, it takes a while...
Juan