Physical Types of Memory

Computer memory is physically located on integrated circuits. While auxiliary "mass storage" is available on floppy diskettes or cassette tape, information must be loaded into the integrated circuit chips before the processor can work with it. It is important to know and understand the types of memory in order to take advantage of the special features of the Atari.

The best known type of integrated circuit is RAM, or "Random Access Memory." Random access means that any byte in that memory can be selected and accessed at any time. This is unlike a cassette tape, where you have to read through the tape from the beginning until you come to the information you want. However, Random Access Memory is not the best way to describe this memory, as other types of memory, including ROM, can also be accessed the same way. A better description is "Read-Write Memory," for the distinguishing feature of RAM is that information can be written to and read from the chip electronically in a few microseconds. The information can be and usually is changed frequently, often many times within the space of a single second.

The principal disadvantage of RAM is that information is stored only as long as electric power is continuously available to the chip. If the electric power is interrupted for even a fraction of a second, the information will be lost. The Atari power supply is designed to smooth out some minor power fluctuations, but it is still possible and even common for information to be lost due to momentary loss of power or voltage fluctuations. The chips were designed to store a lot of information in a small area. This required very low currents and close tolerances, which made the chips very sensitive.

But if RAM can only store information as long as power is available, how do we "wake up" the Atari computers? How can we store the information that the computer needs to get going, even when the power is turned off? We cannot read a program from disk or cassette. The computer needs a program to do that. Not too long ago, the operators of small computers had to physically load a bootstrap program into the computer by setting switches for each bit. ("Let's see now, up for 1 and down for 0, so 0010 0111 is down, down, up, down, down, up, up, up. Now we throw the switch to load that byte and go to the next address...") After a program of 60 or 70 bytes was loaded, that program could be run to load a longer monitor program from paper tape. If one bit was wrong, after throwing 500 switches, the program crashed and the operator had to start over. Fortunately, the Atari uses a better way.

Our second type of chip is called a "ROM", for "Read Only Memory". ROM is not affected when the power is turned off. The data in ROM is permanently burnt into the chip. (There are certain types of ROM which can be erased for special applications.) You cannot write anything to ROM because the hardware will reject it. Since ROM is always readable, it can be used to provide an initial program for the microprocessor to run. The operating system, the computer's main program, is stored in ROM. Remember ROM is used for programs that never need to be changed and those programs that can survive a power loss.

The Basic and Star Raiders cartridges contain programs written in machine language. Since the cartridge can survive a power loss when unplugged, it must be ROM. If you open up the cartridge, you will find two ROM chips. Atari cartridges have programs stored in ROM.

The ROM operating system is located inside the board that is plugged into the top of the Atari. This is a program the Atari uses to start up after a power loss. RAM cartridges with 8K or 16K of memory provide the read-write memory of the Atari.

An 8K RAM memory board has 8,192 bytes available and a 16K RAM board has 16,384 bytes available. The Atari can handle three 16K boards or 48K of read-write memory. There is 64K of total memory in the machine. The last 16K is split up into several other uses. One use is in the Operating System,ROM.

Think of the memory as a long thin line of bytes, each numbered individually. If we have a 16K board plugged into the Atari, and we write to any location from 0 to 16,383, we'll physically write something into the chips on that board. If we have a second 16K board, that will be the bytes from 16,384 to 32,767. A third board handles the next 16,384 bytes of memory. The last 16K of memory, (the total memory is in four 16K parts) from byte number 49,152 to number 65,535, is split up into other functions that do not require read-write memory. If you read location 60,000, you'll be reading from the Operating System ROM board. You cannot write to this.

Certain tools are provided in Atari Basic that are useful in gaining a better understanding of the memory. One of the tools is a function called FRE.

FRE is a way to determine "the number of remaining free bytes in RAM." When we type in a Basic program, we start to use RAM to store it. The storage in RAM is limited, so for every line typed in, there is less free RAM left. RAM has many purposes. Part of the operating system is stored there. Any tables that have to be saved must be stored in RAM since you cannot write to a location in ROM. Basic programs that you type in are stored in the remaining free RAM. FRE tells us how much RAM is left unassigned and is usable for the storage of Basic programs.

With only one 16K board in the Atari, we have only 16K of read-write memory. There will be considerably less space for storing Basic code. If we write to a byte that is not physically located on the memory board, our data will disappear and be lost. Extra memory is very handy, and this is why people are willing to spend extra money for it.

Two other Basic statements that will be valuable to us are PEEK and POKE. Peek gets a byte directly from a memory location that you specify, and puts it into a variable you designate. The number that will be shown will be the contents of that byte, a number from 0 to 255. POKE takes the number you give and puts it directly into the memory location that you indicate. The number that you poke should not be greater than 255 (a larger number will not work).

This is the format of PEEK: Variable=PEEK (address).

For example: to set variable A to the value of the contents of memory location 40,000, use:

A=PEEK (40000)

Let's say we wanted to dump a large section of memory to the printer. Here's a short program to do it.

100 START=40000
110 SEND=50000
230 END

It's harmless to PEEK anywhere in memory. It will teach you a great deal about the machine. You can look at a Basic program in memory and find out exactly what it looks like to the computer as bytes.

POKE puts something into memory. Be cautious because if you randomly poke into memory you'll eventually rewrite a byte that the Atari needs to keep functioning. The result will be that the computer will "crash." You must then either press RESET or turn the power off and on again.

Type NEW to clear out any Basic program in memory, then type PRINT PEEK(8000). This will show you what memory location 8000 currently contains.

Type POKE 8000,100 to change the memory contents to 100. Now a PEEK at 8000 will return the number 100.

Many things can be done in the Atari with PEEKs and POKEs. Since everything the Atari does is based in memory, and PEEK and POKE are the only direct Basic memory modification statements, we'll be seeing a lot of them.

Let's review what we have covered so far. The Atari has up to 64K of memory, meaning there is around 64,000 individually numbered bytes. Each byte is composed of 8 bits. Bits can be either on or off, 1 or 0. A byte stores numbers through representing them with patterns in its internal bits. Since there are 256 possible combinations in 8 bits, a byte can store numbers from 0 to 255.

The microprocessor the Atari uses has 16 bits assigned to memory. The range of numbers 16 bits can represent is from 0 to 65,535. Because of this, the highest memory location the Atari can look at is also 65,535.

Memory is composed of RAM or ROM. The lower 40,000 or so locations of memory are RAM, depending on how much RAM memory you have installed. If you have installed just one 16K board, then the lower 16K of the 48K RAM area will be actual memory and the other 32K will be unusable. The upper 16K of memory is assigned to various purposes. Some of it is ROM, some is for other purposes.

Basic has several statements that allow us to directly work with memory. PEEK allows us to directly examine any byte. POKE allows us to directly modify a byte. FRE tells us how much free RAM we have available for storage purposes.

This should give you a pretty good overview of memory. We'll be dealing with memory throughout the book in more specific ways; for example, how is a string stored in memory? Let's move on now to the graphics section. In it we're going to deal mostly with memory and how to use it to generate graphics images.

Table of Contents
Previous Section: Bits & Bytes
Next Section: Atari Music Composer