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

All times are UTC




Post new topic Reply to topic  [ 84 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6
Author Message
PostPosted: Sun Apr 18, 2021 3:15 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
tokafondo wrote:
Dr Jefyll wrote:
I and many others agree. It'd be better if the chip simply had 8 extra pins for the Bank Address.


Well, the '265 does have them. I'm not sure what's the real difference software wise between a real '816 and a '265, though.


Software is identical. The '265 has more hardware vectors for more interrupt sources from the various on-board peripherals but for a minimal system you mostly might not be too concerned. (You might also need to poke a few more hardware registers at boot time to make sure you enable off-board ROM & RAM too).

Quote:
Having a 16 bit data path would be highly valued for sure.


You may then need extra instructions to specify byte or word read/writes from memory - or a mode switch which is has...

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 02, 2022 12:55 pm 
Offline

Joined: Sat Feb 19, 2022 2:18 am
Posts: 47
BigDumbDinosaur wrote:
This topic seems to be going in circles (along with some occasional OT commentary), as the same tired, old tropes are being repeated about the 65C816. For instance, everyone and his pet monkey seems to be obsessed with banks and what a bad thing they are. If you understand the following, you and the MPU's banks will get along just fine.

  1. Hardware vectors. The 65C816's hardware vectors are seen only in bank $00. This characteristic is a byproduct of the need to maintain (mostly) backward compatibility with the 65C02.

  2. Program code. If the program counter (PC) wraps, the program bank (PB) will not increment. Therefore, program execution is confined to the bank defined by PB. This simply means that relative branches, 16-bit jumps and 16-bit subroutine calls cannot cross bank boundaries.

    In practice, this limitation is very rarely an issue—65C816 code, like its 65C02 counterpart, can be quite compact if written by a skilled programmer. If necessary, really large programs can be built in segments, loaded into several contiguous banks and long jumps (JML) and/or long subroutine calls (JSL, with RTL to return) used to handle cross-bank execution.

  3. Absolute indirect jumps. An absolute indirect jump, e.g., JMP ($1234), "bounces" off a vector located in bank $00. This characteristic also applies to an absolute indirect long jump, e.g., JMP [$1234].

    On the other hand, an absolute indexed indirect jump, e.g., JMP ($1234,X), bounces off a vector located in the same bank in which the indexed indirect jump instruction is located. This characteristic also applies to an indexed indirect subroutine call, e.g., JSR ($1234,X) (a very useful instruction—it's like ON - GOSUB in BASIC).

  4. Stack. All stack accesses are directed to bank $00. This includes both stack-relative addressing modes. As the 65C816's stack pointer (SP) is a 16-bit register, the stack may be located anywhere in bank $00.

  5. Direct page. All direct page (aka page zero or zero page) accesses are directed to bank $00, including the indirect direct page addressing modes. As the 816's direct page pointer (DP) is a 16-bit register, direct page may be located anywhere in bank $00. In fact, DP may be pointed to a reserved area on the stack, a very useful feature!

  6. Data fetch/store. Unless one of the long addressing modes is used, data will be fetched and/or stored in the bank defined in the data bank register (DB). This characteristic allows most 65C02 code to run unchanged on the 65C816 if DB is set to whatever is in PB with a PHK - PLB instruction sequence.

  7. Block-copy instructions. Both MVN and MVP take a source and destination bank as operands and can copy intra- or inter-bank at high speed (seven clock cycles per byte copied). DB is changed by these instructions to point to the destination bank. It is customary to surround a block-copy instruction with PHB and PLB to preserve DB.

  8. Long addressing. The long absolute addressing modes, e.g., LDA $AB1234 or LDA $AB1234,X, implicitly specify the target bank and hence may be used to access data outside of the bank defined in DB. The indexed form of long absolute will span bank boundaries if the sum of the address plus .X causes a carry into bits 16-23.

    The long indirect addressing modes, [<dp>] and/or [<dp>],Y, where <dp> is a location on direct page of a 24-bit address (in three contiguous bytes), are completely bank-agnostic and when used with 16-bit index registers, facilitate fetch/store access to the 816's entire 16MB address space with succinct code that is easy to write. What this means is that from a data fetch/store perspective, memory accesses are completely linear.

Further to long indirect addressing, I have learned that in writing efficient 65C816 code, direct page pointers (also, long indirect jump vectors) are better handled as 32-bit quantities, even though the MPU is limited to 24-bit addresses. Programs so written tend to be more compact and also tend to run faster because the accumulator can be set to 16 bits and left that way as pointer arithmetic is carried out. Otherwise, it is necessary to repeatedly execute REP and SEP instructions to switch the accumulator size to handle the LSW or MSB of the 24-bit address being processed, at a cost of two bytes and three Ø2 cycles per REP or SEP.

Having written tens of thousands lines of 65C816 code, I will emphasize that manipulation of the bank registers is very uncommon. In the case of PB, the program bank register, there is no direct, programatic means by which it can be changed. In practice, DB (data bank register) hardly ever gets touched as well, a good thing, since doing so tends to be awkward. During initialization, my main-line programs will do a PHK followed by a PLB to set the default data bank to the program bank. Hence fetching static data that was assembled as part of the program can be conveniently accomplished with 16-bit addressing. In contrast, data that is being processed is handled with long indirect addressing, which means it can come from anywhere in memory and go to anywhere in memory.

In summary, while existing 65C02 algorithms can be made to run on the 65C816 (in either mode), that is a gross under-utilization of the MPU's capabilities. The key to developing for the '816 is to understand that it is a completely different critter in native mode than its eight-bit cousin (the 65C02) and thus programming it demands a totally different approach if the full power of the '816 is to be used. Once you come to that realization you will be amazed by what you can accomplish.

Good stuff! I appreciate you sharing all this, BDD. This is helpful as I move into 65816 programming. I have so much to learn. :)


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 02, 2022 7:57 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
I had forgotten about this topic. rehsd, after the last post previous to yours, I posted an article about the common '816 misunderstandings that make people shy away from it, at http://wilsonminesco.com/816myths/ .

_________________
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 Mar 02, 2022 8:13 pm 
Offline

Joined: Sat Feb 19, 2022 2:18 am
Posts: 47
GARTHWILSON wrote:
I had forgotten about this topic. rehsd, after the last post previous to yours, I posted an article about the common '816 misunderstandings that make people shy away from it, at http://wilsonminesco.com/816myths/.

Your article brought me to this thread! :)


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 03, 2022 11:16 pm 
Offline

Joined: Wed Aug 21, 2019 6:10 pm
Posts: 217
Dr Jefyll wrote:
tokafondo wrote:
if the '816 would have had a physical implementation and hardware improvements that would had made a difference.
I and many others agree. It'd be better if the chip simply had 8 extra pins for the Bank Address. Then the "recipe" -- the '573 and '245 -- would be unnecessary.


At the time of introduction, the increment in the packaging cost would have been a noticeable difference.

And since the biggest commercial success of the 65816, the licensing of the core for the SNES is not likely to have been topped if a 48 pin version had been available, it's hard to argue that it was a commercial mistake.

Surely it would be more convenient TODAY to have that design, but the total demand for that hypothetical 48 pin version wouldn't pay for the redesign, so that the convenience doesn't pay it's own way in a commercial sense.

Perhaps more commercially viable would be a 6502 socket compatible daughter board with surface mount 65816, 512KB SRAM and support circuit.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 04, 2022 6:01 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8504
Location: Midwestern USA
BruceRMcF wrote:
Dr Jefyll wrote:
tokafondo wrote:
if the '816 would have had a physical implementation and hardware improvements that would had made a difference.
I and many others agree. It'd be better if the chip simply had 8 extra pins for the Bank Address. Then the "recipe" -- the '573 and '245 -- would be unnecessary.

At the time of introduction, the increment in the packaging cost would have been a noticeable difference.

And since the biggest commercial success of the 65816, the licensing of the core for the SNES is not likely to have been topped if a 48 pin version had been available, it's hard to argue that it was a commercial mistake.

However, the 65C816 was available in PLCC-44 in the 1980s, so WDC clearly didn't think it would be a commercial mistake to upgrade the packaging from PDIP-40.

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


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 04, 2022 8:32 am 
Offline

Joined: Wed Aug 21, 2019 6:10 pm
Posts: 217
BigDumbDinosaur wrote:
BruceRMcF wrote:
Dr Jefyll wrote:
tokafondo wrote:
if the '816 would have had a physical implementation and hardware improvements that would had made a difference.
I and many others agree. It'd be better if the chip simply had 8 extra pins for the Bank Address. Then the "recipe" -- the '573 and '245 -- would be unnecessary.

At the time of introduction, the increment in the packaging cost would have been a noticeable difference.

And since the biggest commercial success of the 65816, the licensing of the core for the SNES is not likely to have been topped if a 48 pin version had been available, it's hard to argue that it was a commercial mistake.

However, the 65C816 was available in PLCC-44 in the 1980s, so WDC clearly didn't think it would be a commercial mistake to upgrade the packaging from PDIP-40.


Quite ... the commercial consideration of a surface mount package that did not require any change to the circuit design would have been a stronger benefit for a smaller cost.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 04, 2022 9:00 pm 
Offline

Joined: Thu Mar 10, 2016 4:33 am
Posts: 181
It would be interesting if there was a 65C816 with an external 16-bit data bus. I know this would require a lot of internal changes as well, but then we would have a true 16-bit 6502 processor and quite a large speed improvement. This would require 10 extra pins (8 data and UDS, LDS for byte transfers, maybe something could be combined with VDA and VPA to save a pin).

If the bank address was still multiplexed on the data bus then we could also have a full 32-bit address range with no extra pins.

This wouldn't be that interesting for microcontroller applications, it would more have been a competitor to the 68000, it could maybe have won out on speed, but the 68000 had architectural advantages that set it up for the many years of successor products. Plus the 6502's efficient bus cycle would soon run into problems with memory speeds at that time.


Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 04, 2022 9:47 pm 
Offline

Joined: Wed Aug 21, 2019 6:10 pm
Posts: 217
Given the PLCC part, a board that has a 48 pin DIP form factor, just by integrating the standard circuit, seems like it would be straightforward.


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

All times are UTC


Who is online

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