VICE C64: Saving programs to disk
In yesterday’s post, creating simple BASIC programs, saving them into memory and running them was demonstrated. This post will be a small one demonstrating how to save your program from memory to a disk so it can be retrieved again after restarting the C64 or clearing the memory.
The emulated disk drives
VICE supports both C64 disc images and tape images by emulating the original devices. The use of an emulator means that we will have to use images of the storage media saved as files on the host operating system’s file system.
It is possible to create empty disk image files through VICE, ready to save data to them as if they were a real medium. To create one of these empty images, click File > Create and attach an empty disk > Unit #8… and then choose a name and location to create the image.
Make sure not to forget to include the .C64 file extension.
Once the file has been created, it will be attached to Unit #8. This is the identifier of the drive in which the disk has been loaded. It is necessary to remember the ID of the drive because to save and load from it, the number is used as a parameter.
If all went well, the C64 should still show READY and we can move on to writing the program to be saved.
Writing the program
We shall begin by creating a basic program, saving it in memory and then writing it to the disk. The program will be a simple loop, printing out a string a few times before exiting.
The program:
0 FOR I = 0 TO 10
1 PRINT "HI, I'M NATHAN"
2 NEXT I
3 END
Go ahead and test the program to make sure it works before we write it to the disk.
Saving our program
Once the program has been tested, it’s time to save it to our disk image. The process of saving is relatively simple and quite easy to remember, consisting of only one command, SAVE.
The usage of SAVE is as follows:
SAVE [Name of program], [Device ID]
To save the program currently saved in memory, type:
SAVE "MYPROGRAM", 8
The C64 will then attempt to save the code under the title MYPROGRAM to the disk attached to device number 8. If all goes well, the C64 should announce that it is saving the program and then become READY for more input. The program should now be saved for future use.
Loading and testing
Now the program is saved, testing it out should be easy and will require one new command, LOAD. If re-attaching the disk is needed, click File > Attach a disk image > Unit #8… and then choose the disk image file which contains the program.
To test properly, it is necessary to clear memory of any program which might be stored by using the NEW command and then LIST to check memory contents have been removed.
The LOAD command is to be used as follows:
LOAD [Program name], [Device ID]
Go ahead and load up the program from the disk by typing LOAD “MYPROGRAM”, 8. The C64 should announce that it is searching for the program and once found, it will begin to load it into memory. When it becomes READY, go ahead and type LIST to check the contents now stored in memory.
Once the LIST command finished, the output on screen should perfectly resemble the program you saved to the disk. Use the RUN command to execute the program and check that it loaded successfully.
The loop will be executed and the string printed. The program has been successfully saved to disk.
The quick way
There is also a quicker and easier way to load a program from disk with VICE. In the Attach Disk Image dialog, clicking once on the disk image file will display the contents of it in the box to the right. There will be a list of programs stored and clicking on once will automatically load it and run it within the C64.


