kc5tja wrote:
Okay? Is that it?
Yes. Thanks for asking.
kc5tja wrote:
I haven't seen any so-called caveats in any of my datasheets.
See section 8 (pp. 56-60) of:
http://www.6502.org/documents/datasheet ... b_2004.pdfand:
http://www.westerndesigncenter.com/wdc/ ... 5c816s.pdf(Actually, those are the 65802 caveats, but they also pertain to the 65816.) This leads to today's 65816 trivia question:
If e=1 and S=$00 (i.e. $0100) when (i.e. before) the sequence PHB PLB is executed, what is the (24-bit) address that PHB writes to and what is the address that PLB reads from? Bonus points if you can find where WDC's documentation tips you off about this.
kc5tja wrote:
As far as I can recall, the 65816 emulates a 65C02 exactly when in emulation mode, judging by what is in my 65816 book here.
It's very close to, but not exactly like, a 65C02. Here are a few examples. A JMP ($12FF) reads the high byte from $1300, like a 65C02, but takes 5 cycles like a 6502. This is an important difference when you need exact timing. Likewise an ASL absolute,X takes 7 cycles regardless of whether a page boundary is crossed, like a 6502. A LDA $FFFF,X when X is non-zero reads from bank 1 (assuming B, the DBR, is zero) on a 65816, though it would almost never be found in a 65C02 program. In the realm of undocmented behavior there's:
Code:
SED
SEC
LDA #$20
SBC #$0F
The result in the accumulator is $1B on a 65816, same as a 6502 (the 65C02 accumulator result is $0B). Also, only the 65C02, not the 6502 or 65816, takes an extra cycle in decimal mode. Yet on the 65816, the N and Z flags are based on the decimal result, like the 65C02, not the 6502. Of course, I can't fault any differences in undocumented behavior -- making changes there is fair game. It's merely an example of something that functions partly like the 6502, and partly like the 65C02.
kc5tja wrote:
Actually, it always acts like there is a banked 16-bit address space. Always. The 24-bit long-address instructions are included as a programmer convenience, and really are the only instructions that can linearly address all 16MB.
No, not always. Several other addressing modes can cross page boundaries. For example, when e=0, m=0, and B=$12 (DBR), an ASL $FFFF (i.e. absolute addressing) performs a 16-bit shift whose low byte is at $12FFFF and whose high byte is at $130000.
kc5tja wrote:
If you need more than 64K of code in a single program image, you're almost certainly doing something wrong.
I agree that in almost all cases program code should and will fit in 64k. Using, a large unrolled loop (for, say, fast video or something) does not seem unreasonable, yet it's something that could make the code larger than 64k.
kc5tja wrote:
However, it would not be hard for a compiler to conveniently introduce long jumps to the next bank whenever it approached the end of a code bank.
This is true if the code is intended for a fixed location (or at least when the lower 16 bits of its location are fixed). On a 65C02, if the final location isn't known at compile time, relocating a program at load time is fairly straightforward. The program can be located anywhere with enough available memory, unless, for example, exact timing is needed and page boundary crossings must be avoided. However, such programs are the exception, not the common case. On a 65816, bank boundary crossings have to be considered for every program at some point, at compile time, at load time, or what have you.
Is there really a benefit to having the program counter wrap on a bank boundary? Sure, it saves a little silicon because the 65816 does not have to increment (or, when branching backward, decrement) K (the PBR), but to me this is just creating an idiosyncrasy that you have to program around.
kc5tja wrote:
Not disadvantages, but challenges. I agree that it requires more parts if you want to exploit this feature. If you meet the challenges, there is no real difference in operation between a 6502 and a 65816. The bus tenures are exactly the same.
One of the early advantages of the 6502 and 65C02 was they didn't use the data bus for half of the clock cycle. You lose this with a 65816 due to the multiplexed data bus. The only thing that multiplexing the data bus really gives you is it allows the 65816 to have a standard (40-pin) DIP package. Imagine if the PLCC version was the standard 52-pin package and used the extra pins for the bank address rather than multiplexing it on the data bus. That would making it an extremely attractive choice even in hobbyist environments where DIPs are usually far more convenient than PLCCs. "Challenges" isn't quite a strong enough term, IMO.
All in all, I think the 65816's advantages outweigh the disadvantages (yes, I actually like the thing), but I was anticipating gushing responses to the original post, and I thought I'd play devil's advocate a bit in the interest of balance.