6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 9:04 pm

All times are UTC




Post new topic Reply to topic  [ 176 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 12  Next
Author Message
PostPosted: Fri Dec 06, 2019 5:27 pm 
Offline
User avatar

Joined: Mon Nov 04, 2019 4:53 pm
Posts: 103
Location: Spain
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


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 06, 2019 5:51 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Congratulations!


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 07, 2019 10:49 pm 
Offline
User avatar

Joined: Mon Nov 04, 2019 4:53 pm
Posts: 103
Location: Spain
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


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 07, 2019 10:54 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Yep, see this post:
viewtopic.php?p=70183#p70183


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 07, 2019 11:01 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
JuanGg wrote:
but I'm not able to find the as65 assembler that this code is written for

Is it this one?  http://www.obelisk.me.uk/dev65/as65.html

_________________
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  
PostPosted: Sun Dec 08, 2019 2:12 pm 
Offline

Joined: Mon Sep 14, 2015 8:50 pm
Posts: 112
Location: Virginia USA
Have you tried archive.org? I was able to locate Frank's assemblers with that.

Cheers,
Andy


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 08, 2019 2:16 pm 
Offline
User avatar

Joined: Mon Nov 04, 2019 4:53 pm
Posts: 103
Location: Spain
GARTHWILSON wrote:
JuanGg wrote:
but I'm not able to find the as65 assembler that this code is written for

Is it this one? http://www.obelisk.me.uk/dev65/as65.html


I wasn't able to run that one, it appears that it is only compatible with 16-bit systems.

BigEd wrote:
Yep, see this post:
viewtopic.php?p=70183#p70183


Thanks, I finally got it from here http://web.archive.org/web/201903011236 ... ssemblers/

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.

Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 08, 2019 2:17 pm 
Offline
User avatar

Joined: Mon Nov 04, 2019 4:53 pm
Posts: 103
Location: Spain
handyandy wrote:
Have you tried archive.org? I was able to locate Frank's assemblers with that.

Cheers,
Andy

Yes, found it there finally. Thanks


Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 08, 2019 2:39 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 13, 2019 7:56 pm 
Offline
User avatar

Joined: Mon Nov 04, 2019 4:53 pm
Posts: 103
Location: Spain
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


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 14, 2019 5:07 pm 
Offline
User avatar

Joined: Mon Nov 04, 2019 4:53 pm
Posts: 103
Location: Spain
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?
Code:

                       >
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
                       


Juan


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 14, 2019 5:09 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Looks like your CPU hasn't saved (or hasn't restored) (or doesn't implement) the decimal flag in the processor status register.


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 14, 2019 6:46 pm 
Offline
User avatar

Joined: Mon Nov 04, 2019 4:53 pm
Posts: 103
Location: Spain
I have disabled decimal flag and mode altogether, but I'm not sure what implications does that have.
Code:
;disable test decimal mode ADC & SBC, 0=enable, 1=disable,
;2=disable including decimal flag in processor status
disable_decimal = 2

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


Last edited by JuanGg on Sat Dec 14, 2019 6:58 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 14, 2019 6:51 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
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'.


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 17, 2019 4:27 pm 
Offline
User avatar

Joined: Mon Nov 04, 2019 4:53 pm
Posts: 103
Location: Spain
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'.


I have indeed, but this is not why it was failing in the end. After chasing red herrings for a while, it helps looking at it a few days later. The problem was due to a flip-flop that buffers the carry flag into the ALU, and me having forgotten to enable hidden carry on the preceding clock cycle... It was not jumping to the correct location and that caused issues. Also found out that my clv instruction cleared I instead of V.
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 176 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 12  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 19 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: