6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Sep 19, 2024 11:18 pm

All times are UTC




Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Thu Sep 05, 2013 7:40 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
I'm all in with dropping the bit-fiddling instructions. Dropping column 2 seems sound too, if there's some advantage to be had from the tradeoff.

One point often missed: a slight decrease in instruction set efficiency or interrupt latency (as measured by cycle count) may well be more than offset by a higher clock rate. We're so used to cycle-counting at 1MHz that we sometimes miss the impact of going up to 50MHz (or even just 14MHz)

Cheers
Ed


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 1:44 pm 
Offline

Joined: Wed Jan 22, 2003 6:54 am
Posts: 56
Location: Estados Unidos
Thanks, all, for the discussion and links.

I guess I will just bite the proverbial bullet and implement all of WDC's 65c02 opcodes. That way I don't have to "worry" about it. I was just hoping to free up some single-byte opcode space and...those Branch if Bit Set/Reset instructions just don't have the same flavor of the rest of the instruction set; they seem an obvious tack-on by WDC or Rockwell or whomever.

Anyhoo, this project is just for my edumacation [sic] and not towards the end of being fit for any particular purpose.

_________________
Thanks for playing.
-- Lord Steve


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 2:13 pm 
Offline

Joined: Wed Oct 06, 2010 9:05 am
Posts: 95
Location: Palma, Spain
I would just implement the basic 65C02 extra opcodes (i.e. STZ, PHX, PHY, PLX, PLY, INC A, DEC A, TSB, TRB, the addtional BIT addressing modes, BRA, JMP (ind,X), and the non-indexed indirect addressing mode. The additional ones available on the Rockwell variants and the WDC W65C02S (i.e. RMB, SMB, BBR and BBS) take up a lot of opcode space, and I don't think were so widely used.


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 8:52 pm 
Offline
User avatar

Joined: Mon Apr 23, 2012 12:28 am
Posts: 760
Location: Huntsville, AL
I agree with RichTW and others that the instructions for the original 65C02 are the best. I only added four Rockwell instructions and two WDC instructions (WAI and STP) after getting all of the original instructions working first, and then only to be compatible with the current 65C02 processor from WDC.

The Rockwell instructions are not particularly difficult to implement, but I did shoe horn them into my implementation. WAI and STP are also not particularly difficult to add. Neither WAI nor STP are easily tested with a functional test program such as Klaus', but some simple test logic in your FPGA should suffice.

Note that eliminating column 2 instructions, as BigEd refers to them as, you will also eliminate the LDX #imm instruction. I think that all of the original 65C02 instructions are useful and should be implemented. I can't provide any data on the utilization ratios of any instruction. I've looked and have found no published studies on the average usage rates for the various 6502/65C02 instructions.

Garth pointed me to the datasheet for the 65SC02. In the datasheet there's a table that tabulates the differences between the NMOS 6502 and the 65SC02. I reconstructed the table in the spreadsheet to which I provide you a link earlier. I've printed it out and attached it below. It's one of the few places that explains how many bytes and processor cycles are used by the unimplemented opcodes of the 65C02.

From your comment regarding finding enough single byte opcode space, I imagine that you are looking to extend your core with specific instructions. The table shown below indicates that the opcodes 03...F3, 07...F7, 0B...FB, and 0F...FF are all treated as single byte, single cycle NOPs. Eliminating the 32 opcodes used by the four Rockwell instructions will give you 32 single byte opcodes.

Although, I've not taken the time to implement the necessary changes yet, I think that the '816 stack relative mode implemented using 03...F3 is also a good extension to include. I will likely tack those instructions on to the instruction set of my 65C02 core in the near future, and pull the Rockwell instructions out.
Attachment:
File comment: Comparison of NMOS 6502, 65SC02, and M65C02. Partially reproduced from the 65SC02 datasheet.
M65C02-Functional-Comparison.JPG
M65C02-Functional-Comparison.JPG [ 156.58 KiB | Viewed 1090 times ]

_________________
Michael A.


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 9:18 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
(oops - I'd not want to lose LDX #imm, of course. Perhaps it could be relocated)


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 05, 2013 11:57 pm 
Offline

Joined: Wed Jan 22, 2003 6:54 am
Posts: 56
Location: Estados Unidos
All,
I will consider omitting BBS, BBR, RMB, SMB, but they appear easy to implement and my plan allows for more opcode space via prefix bytes anyway.

MichaelM,
Thanks for the attachment. Do you have a Verilog core of your own?

_________________
Thanks for playing.
-- Lord Steve


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 06, 2013 2:24 am 
Offline
User avatar

Joined: Mon Apr 23, 2012 12:28 am
Posts: 760
Location: Huntsville, AL
Yes, but don't let that dissuade you from your effort to create your own core.

There are several of us on the forum with Verilog cores for the 6502. The designers have all had different approaches, so each core stands on its own. The core from Arlet has been extended by BigEd and ElEctric_EyE (EEye) into a 16-bit core: 65Org16. The 16-bit 65Org16 core is being actively used by EEyE in his video projects which you can read about in the Programmable Logic topic area. Arlet's core is also being used by enso on his CHOCHI development board. Rob Finch also has a core, and it appears that he's extending that work and creating a 32-bit version of the 6502. fpga_is_funny also has a 6502 and and a 65C02 core.

There are several others on the forum that have 6502 cores using that other language whose name I just can't seem to remember. :) fachat comes to mind with his 65k project.

_________________
Michael A.


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 06, 2013 2:48 am 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
MichaelM wrote:
...fpga_is_funny also has a 6502 and and a 65C02 core...

I've got the feeling 'fpga_is_funny' == Jens Gutschmidt? Creator of a cycle accurate 6502 core on Opencores.org.

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


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 06, 2013 10:31 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8509
Location: Southern California
SMB, RMB, BBS, and BBR are mainly for I/O. If we make our own I/O ICs (which I suspect is much easier than making a microprocessor), the bit instructions can be integrated into the address of store instructions, since we typically have a lot more address space alloted for I/O than it needs, which we do to simplify address decoding. Obviously the I/O IC will need more address input bits. Example possibilities:
Code:
    STA  PA              ; Port A output bits take on the value the processor puts on the data bus.
    STA  PA + %00000001  ; Port A disregards the data bus and sets bit 0 in the output registers.
    STA  PA + %00000100  ;  "   "     "       "   "    "   "   "    "  2 "   "    "        "
    STA  PA + %00000101  ;  "   "     "       "   "    "   "   "   both bits 0 and 2 in the output registers.
        <etc.>

    LDA  PA              ; Port A's value is put on the bus and read normally.
    LDA  PA + $100       ; PA<0> is put on bit 7 of the data bus for subsequent BPL/BMI.
    LDA  PA + $101       ; PA<1> "   "  "   "  " "   "   "    "   "      "       "   "
    LDA  PA + $102       ; PA<2> "   "  "   "  " "   "   "    "   "      "       "   "
        <etc.>

It wouldn't have to be done exactly this way, and more could be done with it too, but it gives the idea. The LDA's above could be replaced with BIT or LDX or LDY if we don't want to alter A, because what we're really after is to branch on the flags without having to first load A for a BIT instruction or AND-out the bits we're not testing. The bit-test-and-branch part is not quite as slick as the BBS and BBR instructions, but accomplishes most of the purpose without taking the space in the instruction table or adding the complexity to the processor itself. Indexing could be used to choose a bit we want to alter or test, so the same op code can be used for different ones, unlike SMB, RMB, BBS, and BBR.

_________________
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: Sat Sep 07, 2013 10:16 pm 
Offline

Joined: Mon Apr 16, 2012 8:45 pm
Posts: 60
Have you considered the choices made in the 65EL02 design? Having an added R-stack in address $0200 and the instructions to use it makes it apparently particularly suited for FORTH.


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 07, 2013 11:16 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8509
Location: Southern California
Alienthe wrote:
Have you considered the choices made in the 65EL02 design? Having an added R-stack in address $0200 and the instructions to use it makes it apparently particularly suited for FORTH.

What is the 65EL02? I've never heard of it. ZP works great for Forth's data stack on the '02 though because of the extra addressing modes, and the hardware stack (page 1) works great for Forth's return stack. It's almost like it was planned that way.

_________________
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 Sep 08, 2013 11:53 am 
Offline

Joined: Mon Apr 16, 2012 8:45 pm
Posts: 60
The "EL" in 65EL02 refers to Eloraam whi made the processor as a virtual computer in Minecraft. Her blog has a lot of information: http://www.eloraam.com/

More technical information on the system: http://integratedredstone.wikispaces.co ... er+Control

65EL02 overview: http://integratedredstone.wikispaces.com/65EL02
The instruction set, highlighting her extensions in yellow: http://www.eloraam.com/nonwp/redcpu.php


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

All times are UTC


Who is online

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