6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 14, 2024 3:39 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Wed Nov 06, 2019 11:32 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
Hello friends!

I've been away for a bit, and the 6502 itch is setting in. For me, the 6502 has always been fun to work with. But the modern temptations of wider/faster/newer processors, with the benefit of simpler math code, larger linear memories, etc are always a consideration...

I know there are a few people here who know the '816 chip. Would you share your experience? I am interested in the overall subjective feel of working with the processor - especially as compared to the 6502; but I would love to hear the gory technical details of your likes and dislikes or anything else you wish to share.

Thanks in advance.

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


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 07, 2019 1:13 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
I enjoyed using it with more than 64k of RAM on both my SBC-3 and SBC-4. I found it easy to migrate to.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 07, 2019 2:42 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
Its added instructions make it a lot easier and more efficient to do various things, and the 16-bit capabilities eliminate the need to keep taking 16-bit quantities apart to handle them 8 bits at a time. The '816 gives a ton of benefits, even if you never venture outside the first 64KB of address space. If you do need more memory space, the '816 does banking far more gracefully than the '02 with banking hardware ever could. The '816 is far better suited to things like relocatable code, multitasking, and multithreading. Is it fun to program? You bet; and it's a natural progression from the '02, meaning it's easy to pick up.

_________________
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: Thu Nov 07, 2019 6:49 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8484
Location: Midwestern USA
enso wrote:
I know there are a few people here who know the '816 chip. Would you share your experience?

Well, during my escapades with POC V1.0 and POC V1.1, I figure I wrote about 40,000 lines of code for those two machines. Having had decades of eight bit 6502 experience when I started out with my POC project, it took a while for me to understand that a different mindset is required if one is to get the most out of the '816. It's not so much learning how to use the new instructions and capabilities as it is learning to not let one's eight bit knowledge get in the way.

As Garth noted, the '816 is a substantial step up in capability when run in native mode, even without more than 64K of RAM. It's sometimes amazing how much faster things run when the 16-bit functions are exploited (arithmetic is noticeably sped up) and arcane techniques such as pointing direct page at the stack are used. Convenience is enhanced with stack relative addressing and the ability to push addresses and other quantities to the stack without clobbering any registers. Useful instructions such as BRL (16 bit version of the 65C02's BRA instruction), PER and the aforementioned stack relative addressing make it easier to create relocatable code. Also, the block-copy instructions (MVN and MVP) are invaluable for buffer and general memory management, usually working much more quickly than "traditional" methods of copying RAM from one place to another.

It's not all unicorns and rainbows, of course. The use of status register bits to change register sizes between eight and 16 bits can be cumbersome at times (it would have been so much better if the unused WDM opcode had been used as a preamble to 16-bit instructions). Although the '816 can address 16 megs of RAM, there is some hinkiness with it. For example, programs cannot span banks, which means the maximum contiguous program size will be 64K. Direct (zero) page and the stack are both confined to bank $00. MPU hardware vectors are likewise confined to bank $00, as are some indirect absolute addressing instructions. Furthermore, interrupts always force the '816 back to bank $00. Data accesses, however, can span multiple banks and are readily accessed by using 16-bit index registers and the indirect long addressing mode.

From a hardware standpoint, the '816 requires a little more work to use than the 65C02. The basic bus interface for both is similar, but with one important difference. During Ø2 low, the '816 multiplexes bits 16-23 (the bank bits) of the effective address on the data bus. When the clock flips high, the data bus reverts to being a data bus. Hence both reads and writes have to be qualified by Ø2 so a device doesn't try to drive the data bus when the '816 is driving it with the bank bits (an alternative is to interpose a bus transceiver between the MPU and the rest of the circuit).

Due to the dual use of the data bus, extra hardware is needed to capture the bank bits to access RAM beyond $00FFFF. These items become timing-critical at high Ø2 clock rates. A common solution is to use programmable logic to both achieve the required performance and to handle the decoding logic. None of this is terribly difficult to do, however. If all you want to do is build a basic 65C816 contraption, you can skip the high RAM and just use a 64K memory map, as I did with POC V1.

Having worked with the '816 for nearly 10 years in my POC units, I'd have to say the pluses far outweigh the minuses. In a new design, I would use the '816, not the 'C02.

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


Last edited by BigDumbDinosaur on Sun Apr 12, 2020 2:17 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 07, 2019 7:19 am 
Offline

Joined: Fri Apr 15, 2016 1:03 am
Posts: 139
I recommend the 65816 (or 65c265) over the 6502 for new hardware designs. It's nowhere near as fancy as an ARM, but a nice extension of the 6502.

---- hardware ----
The 65816 is alot like the 6502.
The big difference is that the 65816 always drives the databus with A23..A16 during clock phase 1, where the 6502 won't drive the databus for read cycles & drives the databus with data for write cycles.
Make sure that your memory & peripheral devices don't ever drive the CPU databus during phase 1.
If you don't care about >64K addressing the value of A23..A16 can be ignored, else latch them for your address decoding.
The 65816 has a few additional outputs & inputs that are useful for external memory mapping hardware or ignoring dead cycles.
If you're not doing that the outputs can be ignored & the inputs tied off.

---- software ----
The 65816 is designed to be everything a 6502 is, and much more!
The 65816 comes out of reset ready to execute ordinary 6502 code (except for undocumented opcodes & the RMB & SMB opcodes found on certain 65c02 variants).
All 256 opcodes are defined. All of the 6502 ones + many new instructions & addressing modes.
The new D register is used to relocate the direct page (formerly zero page) to anywhere in the 0 bank.
The new data bank (DBR or B) & program bank (PBR or K) registers prefix 16bit absolute addresses to be any bank in 16M.
The new emulation mode bit enables constraints used for executing 6502 code. Clearing it does:
* The stack pointer changes to full 16bit & points anywhere in the 0 bank.
* The new M & X size mode bits in the status register set the operation size to 8 or 16 bits.
* Interrupts & RTI save & restore a full 24bit address & use native mode vectors.

The 65816 has 5 address spaces at any instant:
* Absolute long: the full 24bit address.
* Absolute (program): 16bits, prefixed with the program bank register for program code accesses.
* Absolute (data): 16bits, added the data bank register for data accesses.
* Direct: (formerly zero page) address added to the D register, in the zero bank.
* Stack: address added to the S register, in the zero bank.
These can overlap in various ways depending on the values in D & PBR & DBR.
To be like a 6502:
D=0 so the direct page starts at $000000.
PBR=0 so program accesses start at $000000.
DBR=0 so absolute data accesses start at $000000.


---- comments ----

The 65816 data sheet & programming manual have much more detail.

There are new software features for many annoying situations on the 6502:
* Most of the 6502 sequences are still usable - the 65816 adds extensions.
* More data moves: PHX, TXY, PEA, XBA, etc.
* Faster memory block copy & initialize: MVN MVP
* In native mode, most instructions can process 8 or 16bit: M & X status bits
* New address modes to use 24bit addresses: "al" "al,x" "[d],y"
* New address modes to access the stack: "d,s" "(d,s),y"
* Zero page not big enough for everything? Switch between multiple direct pages.
* Direct page can be mapped over the stack, to be a stack frame for local variables.
* BRA, BRL & PER for position independent code.
* Indexed jump: "jmp (abs,x)" "jsr (abs,x)"
* Jmp & jsr across program banks in a single instruction: "jmp al" "jsr al" "rtl"
* With 16bit index registers, base-displacement adressing is simple: ldy ptr1; lda 2,y
* There is more I'm forgetting.

In many cases the programmer can incrementally use the new software features of the 65816.
For example: start in emulation mode, then notice there is a PEA opcode that pushes a 16bit immediate value.

The 65816 has basic memory management built-in to the core to access 16MBytes. This can be easily extended with external hardware to do more elaborate memory mapping - I think memory protection & virtual memory & user/supervisor mode are possible.

If the address spaces overlap is changing, it's important to keep track of what address space you want. Direct $04 & Absolute (program) $0004 & Absolute (data) $0004 & Absolute long $000004 & Stack $04 can be 5 different 24bit addresses.

Many code sequences will be correctly executed only if the M & X size mode bits are what the programmer expects - the sizes of instruction immediate data can change.


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 07, 2019 8:03 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
Related is the forum topic, "Not much love for the poor 65816?" where the common misunderstandings are cleared up.

_________________
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: Thu Nov 07, 2019 11:43 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10977
Location: England
Perhaps also see


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 07, 2019 7:22 pm 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
Thank you, your feedback is exactly what I've been looking for.

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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

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