-
Notifications
You must be signed in to change notification settings - Fork 60
Memory Banks
greg-king5 edited this page Oct 12, 2019
·
2 revisions
The Commander X16 can use up to 2048K of RAM, but the 6502 processor can access only 64K. How does it get around the 64K limit? The X16 RAM comes in two sections: low RAM (not quite 40K) is used by BASIC, and is always visible. High RAM (up to 2048K or 2 Mibibytes) is accessed one 8K bank at a time through a 'window' at $A000-$BFFF (40960 to 49151).
There is also 128K of ROM which is accessed through a 16K window at $C000-$FFFF (49152 to 65535).
The active RAM bank is controlled by memory location $9F61 (40801). The default value is 0, which selects RAM bank 0. If you POKE 40801,1
, you will switch to bank 1. Here is a program that switches between banks 0, 1, and 2:
10 POKE 40801,0
20 POKE 40960,30
30 POKE 40801,1
40 POKE 40960,31
50 POKE 40801,2
60 POKE 40960,32
70 POKE 40801,0
80 PRINT"40960 BANK 0 IS "; PEEK(40960); " (EXPECTED 30)."
90 POKE 40801,1
100 PRINT"40960 BANK 1 IS "; PEEK(40960); " (EXPECTED 31)."
110 POKE 40801,2
120 PRINT"40960 BANK 2 IS "; PEEK(40960); " (EXPECTED 32)."