BigEd wrote:
(From a
previous discussion, a clarification (for those not already familiar with 6509):
Quote:
the MOS 6509 has a pair of 4-bit memory-mapped registers - at $0000/$0001 - that extend the addressing range of the CPU to 20 bits, or 1MB; one is the "code" register, that is used on most memory accesses, and the other is the "data" register, used on the (the "significant" load/store operation of the) "LDA/STA (zp),Y" instructions (opcodes $B1/$91).
So, if only two opcodes are affected, the code/data distinction is not quite what one might have thought - it's not a matter of distinguishing fetches from other accesses, for example.
)
Interesting! I missed the fact that there were only two instructions affected by the data register which is a limitation. I still don't understand how you are supposed to get data into another zero-page to use those instructions thus (since they are indirect LDA/STA and you basically need to store the zp pointer there before you can use them). Anyway it probably makes for fetching data from other pages/banks more straight-forward.
As I only have a handful of 6509 (and unlikely to find more) I also want to look into a 65C02 page/bank implementation on the longer term. I like the $x3 NOP single-cycle bank switch, which can be used in a number of ways. I was thinking of using a $x3 to JMP replacement scheme (e.g. intercept the $x3 and put a $4c there, with two cycles of bank-switch delay). But compared to the 6509 that is only going to give me a way of doing direct jump to any page. But it would make for a better scheme than only using $x3 to switch banks since the PC would require a program to be at the exact same place once the flipflot switches to another SRAM bank.
Another more 6509-like way would be to use $x3 as a pre-opcode bank switch. For example:
Code:
Byte $13
LDA $c000
AND #$F
Byte $23
STA $c000
Would mean that bank/page $1 should be used for LDA and page/bank $2 for STA. E.g. for a 20-bit address:
Code:
LDA $1c000
AND #$F
STA $2c000
Without the $x3 precode it would run as usual, so full backward compability. For a permanent bank/page switch I would have used JMP (as explained above) with $x3 as precode.
Or maybe there is a better way which is less complicated..