Commodore 64 Memory

The Commodore 64 memory has an amazing system. It contains 64,000 bytes of memory, a built in music synthesizer, programmable character set, multi-color sprites, high resolution output, , includes multiple ports for disk drive, monitor, printer, and much more. Programmers can write in Basic, Assembly language, and additional varying languages.

Commodore 64 memory is divided into multiple areas. When you first turn on the system, the Basic Interpreter is loaded into memory, along with the KERNAL (input/output of data), and the screen editor. Although the system does pride itself on being a 64k machine, Basic is reserved to only 38,911 bytes of memory. With specific bank switching though, you can expand this up to access close to the full 64k.

When you are writing a program, whether in Basic, Assembly language, or an alternative, the system is storing tokenized data in an area of memory known as RAM (Random Access Memory). If you turn off your system this information will be lost, which is why it is necessary to save your program on a floppy disk.

Graphics Memory

Graphics are handled by the 6567 Video Interface Chip (also known as just the “VIC” chip). It supports a 40 column mode and 25 line line display of text, high resolution of 320 x 200, and Sprites, which are objects that can be moved around the screen without affecting characters underneath.

The screen can occupy over 1,000 possible locations starting at the upper left hand corner going all the way down to the far right corner. Each space occupies and 8 x 8 (64 bits) area that contains PET ASCII data. The screen can also be filled with 1,000 individual bytes of color ram from the upper left to the bottom right. Any of 16 colors can be filled in these areas.

Expanding Bank Memory

Memory can be expanded up to 64K (as mentioned earlier) when banks are switched. This is necessary because by default the VIC-II chip can only reference 16K of memory at a time. By default the Commodore 64 loads memory into Bank 0. This area contains the character generator in ROM. Unfortunately this creates memory limitations when trying to design character set data and sprites, which them often conflicting with one another. So this area can be reserved for smaller Basic programs, but a programmer will need to upgrade their bank memory when trying to write larger software titles, which is utilized by the 6526 chip (Complex Interface Adapter) or CIA #2.

The next area is Bank 1. This area does not give the VIC-II access to the character generator ROM, and limits the area for a BASIC program to as little as 14K. The ROM can still be switched in and the characters copied into RAM. The best thing about this area is the ability to avoid conflicts with other applications that utilize higher memory.

Bank 3 contains 8K of RAM. The primary purpose of utilizing this bank is when a demand for have more room for sprites and character data that can reside under the BASIC ROM. VIC-II reads only from RAM here, and the Basic ROM is reserved for graphics. Although data can be written here, BASIC cannot access it into memory. It is mainly used for machine language programs that need more graphics memory.

Another such area of memory is referred to as Bank 3. It houses 4K of RAM that is not in use by the system. It is divided into 4K reserved for I/O regisers, and the operating system Kernal ROM uses 8K. This is an excellent area to use for graphics and expanding more memory for BASIC. Despite the character ROM being unavailable, it can still be copied into RAM.

The chart below breaks this down while providing further information about how the Commodore 64 can manage memory.

Bank 0:

  • 4096-8191 – character generator ROM is unavailable – Must be copied to RAM
  • 679-767 – Unused
  • 820-1023 – cassette buffer – available for graphics memory
  • bitmap memory – requires 8K for the screen display

Bank 1:

  • character generator ROM is unavailable – Must be copied to RAM
  • BASIC program space – has as little as 14K
  • 16K block – contains free RAM
  • good for bitmap graphics

Bank 2:

  • consists of 8K RAM
  • can write an extra 8K for sprites and character data under BASIC ROM
  • cannot be read by BASIC
  • cannot read a high-resolution screen here – not enough memory is reserved
  • only 4K of RAM remains for use as screen memory
  • good place for graphics memory

Bank 3:

  • character generator ROM is unavailable – Must be copied to RAM
  • 4K of RAM – unused by the system
  • 4K of I/O registers
  • 8K Operating System Kernal ROM
  • good place for graphics memory
  • BASIC is not limited
  • contains enough free RAM for 4 text screens
  • ROM area could be used to store two character sets and 64 sprite shapes
    No RAM exits for a high resolution screen
  • Avoid using 52224-53247 for graphics if using DOS support
  • Hi-res could be acccessed by using the area under Kernal ROM – need to turn off interrupts and switch out the ROM to use the RAM