Difficulty level: Freshman
Prerequisites: Academy BASIC: 110 - The Missing President
Outcome: Learn about how to save and load programs you have written.
Suggested time to complete this module: 40 minutes

Up until now, you've written short programs, perhaps up to 10 lines each. These programs were stored in the computer's memory, and were gone as soon as you exited the emulator (equivalent to shutting down the Commodore 64). However, soon you will start programming games in BASIC that have more then just a few lines in them. In fact, later, in the more advanced modules, you will be writing programs with hundreds and even thousands of code! (Don't worry, there's still a lot of time before we get there). You do not want to lose the programs you have written and have to write them all over again each and every time you restart the emulator.

There are 2 main types of storage: Volatile, and Non-Volatile. Volatile memory loses its contents when the computer is shut down or otherwise loses its power (such as in the event of a power failure). When you wrote your BASIC programs in previous modules, they got stored in Volatile memory. On the other hand, Non Volatile (aka Permanent) storage persists through interruptions in power. An example of Non Volatile storage is your Hard Drive.

Before we get to how to save your programs into this Non Volatile storage, let's have a look at what type of Non Volatile Storage the Commodore 64 has. The most common method of non volatile storage for the C64 is the 5 1/4" Floppy Disk. Another common method of non volatile storage is the Cassette (aka Magnetic Tape). A third type of permanent storage is the Cartridge. You would typically save your programs on a cassette or on a floppy, as cartridges required special equipment in order to write to them.

Pictured below you can see the three forms of permanent storage for the Commodore 64: Floppy Disk, Cassette, and Cartridge. Also pictured is a Commodore 1541 Disk Drive (Used to save to and load from Floppy Disks) and a Commodore 1531 Datassette Cassette Drive (Used to save to and load from tape).

Commodore 64 Floppy Disk 5 1/4Commodore 64 CassetteCommodore 64 Cartridge

Commodore 64 1541 Disk DriveCommodore 1531 Datassette Cassette Drive

OK so let's get to work. We are using an emulator so we will simulate saving to a floppy disk. First, let's insert a blank disk into the emulator's virtual floppy drive. We do this by attaching a disk image. You can find an image of a blank disk on the Commodore 64 website Lemon64 . Go to Help -> Emulators and Tools, and you should see the link to download the blank image in the end of the first paragraph. Download and extract to a directory of your choice.

Now let's attach the image to VICE. In the VICE menu, go to File->Attach Disk Image-> Drive 8. You can also just press Alt-8 as a shortcut to achieve the same result. There are other device ports, but the Disk Drive was typically attached to device #8. Choose the file you've extracted. On the bottom it should say something like Attached blank_disk.d64 to device#8.

To check whether the blank floppy disk image was attached successfully, issue the following command:

LOAD "$",8

This will Load the directory of the floppy into memory. Now type LIST to view the contents. There should be two lines, one with the Disk label (which is blank) and the other with the remaining space left on the Disk. See the screenshot below:

Loading blank disk directory

Let's analyze the LOAD command. As the command implies, you LOAD a something into memory. The $ sign is used to load the directory. The ,8 at the end refers to the device number. Since you now have the directory loaded into the volatile memory, you can now LIST it just as you listed your program contents.

Let's clear the content of the memory. Type in the following command:


The NEW command clears the volatile memory. For example, it can be used to erase your program from memory instead of having to reset the console. Be careful when issuing this command as you will lose any data that you have not saved.

Now write a short program using what you have learned up to this point. When you are done, SAVE it to disk:


The SAVE command lets you store your work in the permanent storage (in our case, a simulated floppy disk). Inside the quotes is your program name. I called mine MYPROGRAM, but you can name yours whatever you like.

Now, exit the console and relaunch it. Attach the disk image again (Alt-8) and look at the directory (LOAD "$",8 and then LIST). You should see the name of your program there! Now load your program into memory with the following command:


Your program is now in memory and you should be able to LIST it or RUN it as usual!

Loading your programs into memory

An alternate way to save and load your program is to save a Snapshot which saves the state of the computer at the time of the snapshot. To save a snapshot, go to Snapshot->Save snapshot image, and to load it go to Snapshot->Load snapshot image.

A snapshot is different then saving to disk, as a snapshot will save the entire state of the machine to the image. So when you load the snapshot you will see everything that was on the screen when you saved it, and the program you had in memory at the time of taking the snapshot will have been loaded.

Congratulations! You now know how to save and load programs. In the next module, you will be working on programming your first game in BASIC!

You can save more than 1 program to your floppy disk. Write two or three more programs, and save them to disk with different names. After saving each program, and before writing the next one, use the NEW command to clear the memory.

When you are done writing all your programs, reset the console, and then LOAD, LIST and RUN each of your programs.

Page copy protected against web site content infringement by Copyscape