6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Nov 12, 2024 6:18 pm

All times are UTC




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Mon Feb 01, 2021 11:45 pm 
Offline

Joined: Tue Jan 19, 2021 11:37 pm
Posts: 5
Hello. I started a project making a 6502 from scratch before I discovered 6502.org. I am looking at making an asynchronous implementation targeted for passively-powered RFID, and I'm in the preliminary logic stage.

I've noticed that there are undocumented opcodes, which are actually just incomplete logic trees. I have two questions:
1) Are any of these undocumented OP codes used in practice?
2) I currently have all undefined sequences become NOP instructions. What is the proper way to handle these if you cannot replicate the original functionality.

Asynchronous logic uses dual-rail encoded signals and completion trees to clock the system, and the undefined instructions cause a problem in the completion logic.

Any suggestions would be appreciated.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 02, 2021 12:30 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
Welcome. Go to my links page at http://wilsonminesco.com/links.html and do a <Ctrl>F search for How 6502 illegal op codes really work. It will take you to a section of links to pages about so-called "illegal" op codes. Some of the links in following sections are relevant too. Jeff Laughton (Dr Jefyll on this forum) has some ultra-fast I/O circuits using illegal op codes on the 65c02 in the "circuit potpourri" page of the 6502 primer, at http://wilsonminesco.com/6502primer/potpourri.html#Jeff . GEOS for the C64 used illegal op codes on the NMOS 6502. (I know the C64 used the 6510; but that is a 6502 with a port tacked on. It's the same processor.)

_________________
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: Tue Feb 02, 2021 12:56 am 
Offline

Joined: Tue Jan 19, 2021 11:37 pm
Posts: 5
Thank you! That's an excellent resource. I'll dig in and see.
I don't use a PLA structure due to the completion trees, so i might not end up being illegal op code compatible, but I'll see what I can do.

Cheers.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 02, 2021 1:39 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
Unless you specifically want to run code that took advantage of the illegal op codes, if you were thinking of going to the extent of implementing them without the PLA, you might as well implement the CMOS 65c02 op codes. I have a summary of the many improvements of the CMOS over the NMOS, at http://wilsonminesco.com/NMOS-CMOSdif/ . It has more instructions and addressing modes (which are more useful than the illegal op codes), plus a lot of other benefits.

_________________
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: Tue Feb 02, 2021 2:11 am 
Offline

Joined: Tue Jan 19, 2021 11:37 pm
Posts: 5
I'll take a look at that. I was looking for a non-IP encumbered core with a low transistor count. 6502 also had a huge software and knowledge base, which made it interesting. I will look at the 65c02 as well.
I can use a PLA as long as I handle all of the corner cases. I expect the final device will run between 1Hz and 1GHz, but I'm still trying to feel my way through the application space and the silicon space. I appreciate the links. I poorly approached this by reading an old book instead of asking google. :/
Again, I appreciate the guidance.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 02, 2021 2:17 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
bpdegnan wrote:
6502 also had a huge software and knowledge base, which made it interesting. I will look at the 65c02 as well.

The NMOS 6502 has not been made in decades. The CMOS, whose development started in 1981 and I learned of it in '82 and was introduced in 1983, is being made today, with no end in sight. Lots of home computers were made with it, too. WDC plans to make their 65's indefinitely.

_________________
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: Tue Feb 02, 2021 6:37 am 
Offline
User avatar

Joined: Fri Nov 09, 2012 5:54 pm
Posts: 1431
Not all of the invalid NMOS 6502 opcodes are stable.
Some of the invalid opcodes could give you different results on different chips.

Old software isn't supposed to make much use of them.
When writing new software, best practice is to avoid using them.

Please take a look at the C74 project,
that's a 20MHz TTL CPU which is mostly timing compatible and cycle compatible to NMOS 6502 and 65C02,
although the internal architecture is different from these chips.

Recommended reading:
6502 undocumented opcodes
6502 unstable undocumented opcodes
6502 dead cycles
C74 block diagram

In the C74 project, we started to call the invalid opcodes UFOs: instructions UnFOrseen by the designers.

For an asynchronous 6502 VHDL implementation, please take a look at the PSALM project from 2001,
but be warned that all of the text seems to be in German language.

Hope, this helps.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 02, 2021 9:33 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10977
Location: England
Welcome, bpdegnan!

In my view you should feel free: the easiest route is to ignore the undocumented opcodes, allow your machine to do whatever it happens to do. That's what the original NMOS 6502 designers did. If you like NOPs, go ahead, but it might take more logic. If you like the 'C02, go with that, it's certainly more logic, but perhaps not too much.

Some software did use undocumented opcodes: some games, many demos, some software protection routines. If that software falls inside your area of interest, so be it. As ttlworks says, the undocumented behaviour is not all precisely specifiable. For me, a great reason to ignore it. For some, a challenge.

When deciding what to implement, you might also make a choice about BCD arithmetic: ignoring it will reduce the logic, but you need to know that your software won't use it. Being faithful to the NMOS 6502 behaviour for sensible BCD inputs is the next level, and then beyond that you can try to be faithful to undocumented behaviour or to choose 'C02 behaviour.

Good luck with the project!


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 02, 2021 10:27 am 
Offline
User avatar

Joined: Fri Nov 09, 2012 5:54 pm
Posts: 1431
Right, BigEd: BCD arithmetic is going to be another can of worms.

65C02 sets the flags correctly for decimal mode ADC and SBC, but NMOS 6502 does not (it sets the flags according to the result before the decimal correction).

There is a little difference between NMOS6502 and 65C02 in the decimal mode SBC results when subtracting non_decimal numbers.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 02, 2021 6:14 pm 
Offline
User avatar

Joined: Mon May 12, 2014 6:18 pm
Posts: 365
Do you plan on running existing code or writing all new code for your project? If it's the latter, you could consider reassigning the unused op codes to custom functionality instead of making them NOPs. That way you can take advantage of existing assemblers and compilers and still have a route to make your processor more efficient and easier to program. Something like the 65CE02, for example, might be a good starting point.
Quote:
I'll take a look at that. I was looking for a non-IP encumbered core with a low transistor count
6502 is a good choice I think. Have you looked at the 8051 also? No clue about the IP but it seems to get pressed into service for all kinds of things where a bare minimum 8 bit architecture is needed.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 02, 2021 6:17 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10977
Location: England
There's an index thread of previous threads about extensions - it's often thought about:


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 03, 2021 12:28 am 
Offline

Joined: Tue Jan 19, 2021 11:37 pm
Posts: 5
Druzyek wrote:
Do you plan on running existing code or writing all new code for your project?


I will be writing new code. To that end, I might also drop the zero-page addressing as everything will be on die.
Mainly, it's a low-transistor count, proven architecture. I've decided against the 8051 just because of complexity.
As I said above, I'm targeting an asynchronous implementation for battery-free devices, which is why I needed minimal transistor count. It cost me 2x the transistors, plus a completion tree circuits to go asynchronous. The 6502 architecture does quite a bit for what it is, and I really didn't find something that I could definitely describe as better. There's also C compilers but the assembler is just so easy.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 03, 2021 5:27 am 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
If the goal is minimal transistor count, then you could consider drastic measures such as eliminating one of the index registers. (Somewhere on this forum there's mention of something along those lines -- a sub-6502 intended for cost-sensitive applications -- toys, IIRC.)

Hmm, but the memory requirements for your code will increase to some degree... although perhaps not by much in simple applications.

-- Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 03, 2021 6:32 am 
Offline
User avatar

Joined: Fri Nov 09, 2012 5:54 pm
Posts: 1431
One index register, like in the 6800 ?
This would make moving blocks of data in memory pretty inefficient.


IMHO a lot of the complexity in the 6502 PLA comes from the fact that data is 8 Bit and address is 16 Bit.

If data and address both would be 16 Bit, I think this would simplify the PLA a lot,
but then the CPU won't be 6502 compatible anymore.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 03, 2021 7:40 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
Dr Jefyll wrote:
If the goal is minimal transistor count, then you could consider drastic measures such as eliminating one of the index registers. (Somewhere on this forum there's mention of something along those lines -- a sub-6502 intended for cost-sensitive applications -- toys, IIRC.)

Was it this one? http://www.bigmessowires.com/cpu-in-a-cpld/

_________________
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  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

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