Classic Computer Magazine Archive COMPUTE! ISSUE 88 / SEPTEMBER 1987 / PAGE 91

Atari XL/XE Hidden RAM

Ronald R. Lambert

Don't let the hidden RAM in your computer go to waste. Instead, use it to store text, machine language programs, graphics data, or help screens. For the 800XL, 65XE, 130XE, and for the 600XL with memory expanded to 64K.

Have you ever needed just a little more RAM? Perhaps you have a custom character set that you would like to store away for a more convenient time. Or you may have a series of help screens that you'd like to use without tying up the normal RAM in the computer. Or maybe you have a whole collection of machine language programs that you would like to be able to use. If you own an Atari 130XE, you have an extra 64K of RAM that you may be using as a ramdisk. You may not realize it, but there is an additional 8K of RAM available "under" the BASIC ROMs. This extra RAM can be found in any Atari XL or XE model (excluding the 1200XL) with 64K or more of memory. You can use this technique only when you are using the BASIC ROMs inside your computer. It will not work if you have a BASIC cartridge plugged into the cartridge port.

Normally, BASIC programmers can't make use of the RAM at memory locations 40960–49151. This is because the ROM containing the BASIC interpreter itself resides at these locations. But RAM is still there—hidden, but ready to be used by an enterprising programmer.

To use this 8K block of RAM, you must switch the BASIC ROM out of the computer's memory map, and switch in the alternate block of RAM. Location 54017 controls whether ROM or RAM is seen at addresses 40960–49151. That location contains the value 253 when BASIC ROM is selected, and 255 when RAM is selected.

In BASIC, you might be inclined to try to accomplish the switch using a statement like POKE 54017,255. But there is one obvious problem in using a POKE to switch from ROM to RAM. When the BASIC ROM is switched out, the computer (which has been executing the BASIC interpreter, a machine language program) tries to execute whatever is in the RAM under BASIC. Since there is no intelligible machine language program here, the computer crashes. The only way to recover is to press SYSTEM RESET (which, among other things, turns BASIC ROM back on). This makes it impossible to usefully turn off BASIC from within BASIC.

Fortunately, turning the BASIC ROM off with machine language causes no problems, and machine language can be executed from BASIC with the USR function. Even if you don't know machine language, you can use the program presented here to copy information to and from the hidden area of RAM.

Using The Program

Type in the program and save a copy to tape or disk. Because the program requires accurate typing, be sure to use "The Automatic Proofreader" program found elsewhere in this issue.

Use this program as a model for your own programs. In lines 10–30, the program POKEs the machine language program held in the DATA statements (lines 100–180) into memory starting at location 1536. This machine language program has two entry points. X = USR (1536) copies the contents of a section of normal memory into the hidden RAM beneath the BASIC ROMs. X = USR(1543) does the opposite, copying the contents of a section of the hidden memory into normal memory.

Before you call one of these routines, you must first set up two zero-page memory locations. This is done in lines 300–310 and 330–340 of the sample program. Locations 203–204 hold the number of bytes to be transferred to or from hidden RAM. Remember that no more than 8192 bytes can be transferred. Locations 205–206 hold the address of the first byte in normal memory to be copied into hidden RAM, or the address of the first byte in normal memory into which the contents of hidden RAM is to be copied.

If you are moving information back and forth between a string and hidden memory, as in the example program, be sure that the string is large enough to hold the data. Otherwise, you may crash your computer.

Atari XL/XE Hidden RAM

For instructions on entering this program, please refer to "COMPUTE!'s Guide to Typing in Programs" elsewhere in this issue.

OC 5 REM COPYRIGHT 1987 COM.UTE! PUBLICATIONS, INC. ALL RIGHTS RESERVED.
FD 8 PRINT "{CLEAR} Copyright 1987" : PRINT "COMPUTE! Publications, Inc." : PRINT "All Rights Reserved." : PRINT : PRINT
BG 10 FOR T = 1536 TO 1604
MA 15 READ NUM : CHECK = CHECK + NUM
AB 20 POKE T, NUM
CA 30 NEXT T : IF CHECK < > 10239 THEN PRINT "ERROR IN DATA. PLEASE CHECK TYPING."
DP 100 DATA 104, 169, 205, 160, 207, 208, 5, 104
AP 110 DATA 160, 205, 169, 207, 141, 34, 6, 140
LH 120 DATA 36, 6, 169, 255, 141, 1, 211, 169
EB 130 DATA 0, 133, 207, 169, 160, 133, 208, 160
EP 140 DATA 0, 177, 205, 145, 207, 198, 203, 165
EI 150 DATA 203, 201, 255, 208, 2, 198, 204, 165
OF 160 DATA 203, 5, 204, 208, 6, 169, 253, 141
AO 170 DATA 1, 211, 96, 200, 208, 227, 230, 206
JL 180 DATA 230, 208, 76, 33, 6
IH 200 DIM A$ (50)
JF 210 A$ = "This is a sample string."
LL 300 LA = LEN (A$) : H = INT (LA/256) : L = LA - H*256 : POKE 203,L : POKE 204, H
KA 310 AD = ADR (A$) : H = INT (AD/256) : L = AD - H*256 : POKE 205,L : POKE 206, H
CN 320 A = USR (1536)
FJ 325 A$(50) = "*" : PRINT "A$ HAS BEEN STORED UNDER BASIC ROMS. A$ HAS BEEN CHANGED."
LO 330 LA = LEN(A$) : H = INT (LA/256) : L = LA - H*256 : POKE 203, L : POKE 204, H
KD 340 AD = ADR(A$) : H = INT(AD/256) : L = AD - H*256 : POKE 205, L : POKE 206, H
CO 350 A = USR (1543)
NC 360 PRINT "A$ HAS BEEN RECOVERED." : PRINT A$ (1, 24)