6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 7:07 pm

All times are UTC




Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Sep 04, 2013 12:44 am 
Offline

Joined: Wed Jan 22, 2003 6:54 am
Posts: 56
Location: Estados Unidos
The 65c02 adds new mnemonics and addressing modes to the instruction set of the original NMOS 6502. The Western Design Center's datasheet for their 65c02 has a nice opcode matrix (on page 22) here: http://www.westerndesigncenter.com/wdc/documentation/w65c02s.pdf.

I am considering a Verilog FPGA project concerning a 32-bit, instruction-set-enhanced 6502, but I am not interested in all the new instructions.

I am not concerned with BBRn, BBSn, RMBn, SMBn, STZ, TSB, TRB, or the zero page addressing mode additions (see column 2 of the opcode matrix) unless they are very pervasive in 6502 software. Also how useful are WAI, STP, and BRA?

So, can anyone tell me what cross section of the 65c02 opcodes/mnemonics are considered "canon" for 6502 software? What are the "must have" opcodes?

Me love you long time.

_________________
Thanks for playing.
-- Lord Steve


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 2:15 am 
Offline
User avatar

Joined: Mon Apr 23, 2012 12:28 am
Posts: 760
Location: Huntsville, AL
Neill Parker has a very good opcode matrix that describes the differences between the various versions of the 6502. I used his matrix to define the opcodes that I would implement for my core. You can find his matrix here.

I have also created an Excel spreadsheet with the various opcodes mapped to the various instruction sets for the original 6502, the original 65C02, and the Rockwell 65C02. You can find it here. On the M65C02 tab, the opcodes in black are for the NMOS 6502, the opcodes in red are for the original WDC 65C02, and the opcodes in blue are for the Rockwell 65C02. The PDF is for the WDC 65C02, and only shows the NMOS 6502 (black) and original 65C02 opcodes (red).

You appear to be interested in only the opcodes in the black font shown in either of these two documents.

The original 65C02 by WDC is sometimes referred to as the 65SC02. Garth has placed a copy of the datasheet for this processor here.

Hope this helps.

_________________
Michael A.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 2:27 am 
Offline

Joined: Wed Jan 22, 2003 6:54 am
Posts: 56
Location: Estados Unidos
Hi, MichaelM.

I want to do the 65c02 opcodes if they are heavily used in the 6502 software "repertoire". So, that's why I was wondering if I REALLY need to do, say, TRB, TSB, WAI, STZ, et al.

I remember seeing that Neill Parker page sometime back. I like the breakdown of the bit patterns. Thanks for the links!

_________________
Thanks for playing.
-- Lord Steve


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 2:55 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8504
Location: Midwestern USA
lordsteve wrote:
The 65c02 adds new mnemonics and addressing modes to the instruction set of the original NMOS 6502. The Western Design Center's datasheet for their 65c02 has a nice opcode matrix (on page 22) here: http://www.westerndesigncenter.com/wdc/documentation/w65c02s.pdf.

I am considering a Verilog FPGA project concerning a 32-bit, instruction-set-enhanced 6502, but I am not interested in all the new instructions.

I am not concerned with BBRn, BBSn, RMBn, SMBn, STZ, TSB, TRB, or the zero page addressing mode additions (see column 2 of the opcode matrix) unless they are very pervasive in 6502 software. Also how useful are WAI, STP, and BRA?

So, can anyone tell me what cross section of the 65c02 opcodes/mnemonics are considered "canon" for 6502 software? What are the "must have" opcodes?

Me love you long time.

Why make a crippled 65C02?

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 3:56 am 
Offline

Joined: Wed Jan 22, 2003 6:54 am
Posts: 56
Location: Estados Unidos
The functionality lost by not implementing those instructions will be made up for in the 32-bit (orthogonal) extension to the instruction set. Plus, it would free those locations in the opcode map.

So, do those 65c02 instructions permeate most of 6502 software? That is what I would like to know. What is the distribution of the 65c02-only opcodes across the domain of 6502 software?

Thanks!

_________________
Thanks for playing.
-- Lord Steve


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 4:29 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
Nice to hear from you lordsteve, after about five years of silence!

lordsteve wrote:
but I am not interested in all the new instructions.

I am not concerned with BBRn, BBSn, RMBn, SMBn, STZ, TSB, TRB, or the zero page addressing mode additions (see column 2 of the opcode matrix) unless they are very pervasive in 6502 software. Also how useful are WAI, STP, and BRA?

BBR, BBS, SMB, and RMB have their greatest usefulness when I/O in in ZP as it was with some 6502-based microcontrollers. I have not really found them useful for variables in ZP. I would enjoy having them available with an absolute (non-ZP) addressing mode for improved I/O performance. Indexing or indirects would not really be necessary since I/O does not move around. OTOH, if everything is 32-bit in your new processor, abs and ZP (or DP) are the whole 4gigaword space anyway, with no difference. I do use STZ, TSB, TRB, and BRA all the time, and of course PHX, PLX, PHY, and PLY. I have not used WAI and STP myself, but I think BDD has. Besides saving power, there's a trick you can do with WAI to get much faster interrupt response if you can get everything else done that needs to be done in time to sit idle and wait for the next interrupt.

I always encourage newcomers to use the CMOS version if they are building their own computer and are not limited to vintage hardware like the C64 which used the 6510 which never had a CMOS version available.

Quote:
So, can anyone tell me what cross section of the 65c02 opcodes/mnemonics are considered "canon" for 6502 software? What are the "must have" opcodes?

One I have never used since my 6502 class in 1982 is BRK, but I know those interested in certain types of multitasking and OS calls will want it. My exposure is to assembly and to the innards of Forth since I have written a very rich Forth kernel for the 65816. You will want input from Toshi others who have done OS design, Lee who wrote EhBASIC which appears to be a really outstanding BASIC for 6502, and someone here--I can't think of who it was at the moment--has written a Pascal compiler. André Fachat has written his very impressive GekOS multitasking & multithreading OS for C64. I'm sure there are other important ones I'm missing. From the type of software work they've done, each will be able to give an idea of what is needed, which will be something the others may not have realized is important for a particular type of programming.

Quote:
I am considering a Verilog FPGA project concerning a 32-bit, instruction-set-enhanced 6502,

I am glad to see growing interest in a 32-bit version of the 6502. We do however have several efforts in different stages of interest and work, and although there's no obligation for the different people working on them to agree and work together on a single one, I would still encourage each to read all the discussion on all of them, for maximum benefit and minium re-invention. The 65Org32 detailed discussion started at viewtopic.php?f=1&t=1419 with a discussion on improving the 6502 but quickly went to a new all-32-bit version of the 65816 which of course because of 32-bit direct-page register, data bank register, and program bank register, does away with page and bank boundaries and is suitable for multitasking and relocatable code. The '816 has a lot of instructions and addressing modes which may seem to complicate things at first, but I found when I was writing the '816 Forth kernel that it really made programming much easier-- and I wasn't even working toward a multitasking OS. Another recent start is Mike's 65m32 which he began to discuss at viewtopic.php?f=1&t=1419&start=125, and another is Rob Finch's RTF65002 at viewtopic.php?f=10&t=2653 which is to be able to run legacy 6502 code. Another I am aware of but its Yahoo forum seems to have disappeared is the 65GZ032 work which they did actually have working hardware on although it was not finished the last I heard and the job was put in hybernation. BigEd can probably fill in some more URLs for us.

_________________
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: Wed Sep 04, 2013 5:04 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
The 6502/65C02 instruction set hits the 'sweet spot' of the retro period. It's not great for compiling C or Forth, but is surprisingly satisfying. ARM instruction set is much more straightforward and regular, but for me it leaves an unpleasant taste in my mouth; 68K was more pleasant...

One of the joys of 6502 is the incredible compactness of code, and its surprising speed of execution.

I am somewhat suspicious of 32-bit versions... It's tempting to add registers which then must be constantly pushed and pulled to/from the stack, and the spirit of 6502 vanishes. 16 bits is probably plenty for most applications; fixed point can be better than floating point in many cases. I'd be more interested in adding instructions to support Forth, a larger stack space, and a larger memory space while keeping closer to 6502 (accumulator and a couple of index registers). 6809 seems to be more in the right direction than a full-blown 16-register 32-bit processor with a vague resemblance to the 6502.

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 5:30 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
enso wrote:
...I am somewhat suspicious of 32-bit versions... It's tempting to add registers which then must be constantly pushed and pulled to/from the stack, and the spirit of 6502 vanishes....

Huh? Not the 65Org16.b. Extra accumulators/registers are awesome IMO, for a 6502 CPU like construct.
I would suspect also, that a 32-bit version would take a more full advantage of an Xilinx Spartan 6 FPGA without sacrificing a thing, compared to 16-bits.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 5:42 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
32 bit takes up a lot of room, though, both in your data path and program space. Impact on speed is less, although things like 32 bit ripple carry take a bit more time, as does increased routing congestion.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 5:58 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
Things in the critical path often taken for granted like setting the zero flag also require wide logic, and several layers of luts.

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 6:07 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
Yes, the zero flag is a good one.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 6:17 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Is this because the Zero flag would have to be 1-bit wider than the data path?

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 6:25 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
It's because it requires a 32-input OR to determine value of the Z flag. This requires 2 levels of logic on a Spartan-6. On a Spartan-3 it requires 3 levels of logic, because the LUTs only have 4 inputs.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 6:39 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Maybe I was thinking of the N flag, for BMI and BPL opcodes.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 04, 2013 6:45 pm 
Offline
User avatar

Joined: Tue Nov 16, 2010 8:00 am
Posts: 2353
Location: Gouda, The Netherlands
For the C flag you need the carry out from the adder, and also for the V flag, because it requires C.

But the Z flag is the biggest/slowest to calculate.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 14 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: