Classic Computer Magazine Archive COMPUTE! ISSUE 51 / AUGUST 1984 / PAGE 10

Hidden 64 RAM

I have been dabbling in machine language a bit, and have a question. I would like to know if it is possible to load machine language programs into the RAM that is underneath BASIC ROM. If it is, how do I go about switching out BASIC ROM to use the ML routines, and then switching BASIC back in?

Kenneth Cox

There is 16K (16,384 bytes) of hidden RAM in the 64. 8K can be found underneath BASIC ROM at 40960 to 49151, hex $A000-$BFFF, 8192 bytes, and 8K is under the Kernal at 57344 to 65535, hex $E000-$FFFF.

Switching either BASIC or Kernal ROM in or out to expose the available RAM underneath is done via memory location 1. Normally, there's a 55 in that location. Setting bit 0 here to a zero will switch out BASIC and expose the 8K block of RAM underneath. Setting bit 1 of memory location one to a 0 will switch out both BASIC and Kernal ROM, exposing a total of 16K of RAM.

Use this BASIC line to switch out BASIC ROM:

POKE 1, PEEK(1) AND 254

To switch out both BASIC and the Kernal, use:

POKE 1, PEEK(1) AND 253

When memory location 1 is set at its normal value of 55 (BASIC and Kernal ROM switched in), POKEing and PEEKing to this memory follows spe­cial rules. When you PEEK this memory, you will get the values of the BASIC or Kernal ROM, that is, PEEK (40960). However, POKEing this memory (POKE 40960, 255) will automatically POKE the RAM underneath.

This makes placing programs into the hidden RAM easy. You can POKE in your machine language routines via a BASIC poker program, or simply load the programs from tape or disk.