FIGURE 1. A BASIC for loop.
FIGURE 2. A directory listing.
Refer to Figure 1. The emulated drive 8 (as I have the
system configued) is the folder c:\c64\drive8. If you look
in this folder via Windows, you’ll see a handful of files
there. To see the same list from within WinVICE, type the
Click “File” and then click “Monitor” from the top menu.
You can enter a short machine-code subroutine that will
print the alphabet by iterating over the PETSCII alphabet
characters, calling the CHROUT character-output routine
at $FFD2 on each iteration.
Enter these lines at the monitor prompt:
Please note that the double-quotation mark character
is entered by typing SHIFT- 2 on the emulator keyboard.
The directory listings from Commodore eight-bit
machines load into memory like BASIC programs by using
the special filename “$.” You can then type LIST to see
the formatted listing as in Figure 2. Please note that this
folder can be changed by clicking on the “Settings” menu.
Refer to Figure 3. Next, close the monitor window.
Then, click the “Peripheral Settings” submenu item to
change the location.
From the C64 BASIC “READY” prompt, enter the line:
Going Old School
VICE has its own machine-language monitor that you
can invoke externally from the running C64 environment.
The above line will invoke the subroutine we just
wrote at location 49152 ($C000 hex). Refer to Figure 4.
C Programming —
The CC65 Cross-Complier
CC65 began as a port of the Small C Compiler for the
Atari eight-bit family. Many extensions were added in
addition to support for other systems.
Writing C in CC65 can be a little different than writing
C for other systems. It’s more optimal to deal with
unsigned eight-bit data when possible. While I try to do
this in my code using the “unsigned char” data type for
counters, I often just use the int data type, which is a bit
FIGURE 3. Raw assembly
code in the VICE monitor.
The goal of the programs presented here isn’t to show
CC65 optimization skills.
Let’s use the traditional “Hello, world!” program as
54 October 2015