Next Previous Contents

6. Running The Executable

Note: this section is incomplete!

Depending on the target, the compiler chooses several methods of making a program available for execution. Here we list sample emulators and instructions for running the program. Unless noted, similar instructions would also apply to a real machine. One word of advice: we suggest you clear the screen at the start, and wait for a keypress at the end of your program, as each target varies in it's start and exit conditions.

6.1 Apple

AppleWin 1.10.4 (available at http://www.jantzer-schmidt.de/applewin/): Emulates Apple II+/IIe computer, with sound, video, joysticks, serial port, and disk images. Roms and dos disk included. Includes monitor. Only for Windows. The package comes with roms and dos3.3 disk (called master.dsk), however you will need a2tools (available at http://hotel04.ausys.se/pausch/apple2/#a2tools).

Compile the tutorial with

cl65 -O -t apple2 hello.c text.s

Then insert the file into an Apple disk image for use with an emulator. Copy the master.dsk which comes with Applewin and rename it to cc65.dsk, then use a2tools:

a2tools in -r b cc65.dsk TEST hello

Note that a convention in the Apple world is that hello is the file which is automatically run upon booting a DOS disk, sort of like the Autoexec.bat of the PC world. We've avoided this in the example however. Also, the TEST parameter must be in caps, and is the name of the program as it will appear on the Apple disk.

Start the emulator, click on the Disk 1 icon, and point to cc65.dsk, then click the big Apple logo to boot the system. Then type this on the Apple:

BRUN TEST

You will see the "Hello, World!" appear on the same line. Thanks to Oliver Schmidt, oliver@jantzer-schmidt.de for his help in completing this section.

6.2 Atari

Atari800Win Plus 3.0 (available at http://www.a800win.atari-area.prv.pl): Emulates Atari 400/800/65XE/130XE/800XL/1200XL/5200, with stereo sound, disk images, scanline exact NTSC/PAL video, joysticks, mouse, cartridges and ram expansions. Includes monitor. Unfortunately only for Windows. You will need the emulator, atarixl.rom or atariosb.rom/ataribas.rom and dos25.xfd files (not supplied).

Compile the tutorial with

cl65 -O -t atari hello.c text.s

Start the emulator, choose File>Autoboot image or File>Load executable, and point to the hello executable. It is customary to rename executables of this type to hello.xex. The file has a 7 byte header meant to be loaded directly from Atari DOS 2/2.5 or compatibles.

On a real Atari, you would need a disk drive and Atari Dos 2.5 or compatible. Turn on the computer, type

DOS

at the basic prompt, then choose N. CREATE MEM.SAV then choose L. BINARY LOAD and enter HELLO.

The emulation also supports this method. Look at Atari>Settings and check Enable H: Patch for Hard Disk Devices, then Atari>Hard disks and set the path of H1: to your executables directory, then use H0:HELLO.XEX in the above proceedure (after pressing L) to access your hardrive directly.

Note: There is no delay after the program exits, as you are returned to the DOS menu. Your C program should wait for a keypress if you want to see any output.

6.3 Commodore

Vice 1.9 (available at ftp://ftp.funet.fi/pub/cbm/crossplatform/emulators/VICE/): Emulates Commodore 64/128/Vic 20/PET/CBM II computers. Missing is the Plus/4 and Commodore 16. Supports printer, serial port, stereo sound, disk drives and images, ram expansions, cartridges, cycle exact NTSC/PAL video, mice, joysticks. Includes monitor. Runs on Win9x/NT/2000/XP/ME/OS2/MSDOS, Beos x86, Acorn RISC OS, and many Unixes.

Start the desired version of the emulator, choose File>Autoboot disk/tape image, and choose your executable. The file has a 14 byte header which corresponds to a PRG format BASIC program, consisting of a single line;


1000 sys2061

On a real Commodore with attached disk drive, you would type:

LOAD "HELLO",8

for Vic 20/C64, or

DLOAD "0:HELLO"

on PET/CBM II/C128, then type

RUN

The output will appear on a separate line, and you will be returned to a BASIC prompt.

We need your help! Recommended emulators and instructions for other targets are missing. We suggest an emulator with good compatibility. Also, being able to run all computers in the target series is good for target compatibility testing. A machine language monitor is almost essential for debugging, but a native debugger could be used as well.

Finally, emulators which run on Unix/Windows would help reach a wider audience.


Next Previous Contents