mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 17:30:50 +00:00
Changes by Greg King
git-svn-id: svn://svn.cc65.org/cc65/trunk@3543 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
00555c26fa
commit
dcf2bf4976
442
doc/intro.sgml
442
doc/intro.sgml
@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
<article>
|
<article>
|
||||||
|
|
||||||
<title>cc65 compiler intro
|
<title>cc65 Compiler Intro
|
||||||
<author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org"> and CbmNut <htmlurl url="mailto:cbmnut@hushmail.com" name="cbmnut@hushmail.com">
|
<author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">,
|
||||||
<date>07.13.2002
|
<and>CbmNut, <htmlurl url="mailto:cbmnut@hushmail.com" name="cbmnut@hushmail.com">,
|
||||||
|
<and><url name="Greg King" url="mailto:gngking@erols.com">
|
||||||
|
<date>2005-7-22
|
||||||
|
|
||||||
<abstract>
|
<abstract>
|
||||||
How to use the cc65 C compiler - an introduction.
|
How to use the cc65 C language system -- an introduction.
|
||||||
</abstract>
|
</abstract>
|
||||||
|
|
||||||
<!-- Table of contents -->
|
<!-- Table of contents -->
|
||||||
@ -17,32 +19,32 @@ How to use the cc65 C compiler - an introduction.
|
|||||||
|
|
||||||
<sect>Overview<p>
|
<sect>Overview<p>
|
||||||
|
|
||||||
This is a short intro of how to use the compiler and the binutils. It contains a
|
This is a short intro of how to use the compiler and the bin-utils. It contains
|
||||||
step-by-step example of how to build a complete application from one C and one
|
a step-by-step example of how to build a complete application from one C and
|
||||||
assembler module. This file does <em/not/ contain a complete reference for the
|
one assembly modules. This file does <em/not/ contain a complete reference for
|
||||||
tools used in the process. There are separate files describing these tools in
|
the tools used in the process. There are separate files describing those tools,
|
||||||
detail.
|
in detail (see <url url="index.html">).
|
||||||
|
|
||||||
You are assumed to have downloaded and extracted the executables and the
|
You are assumed to have downloaded and extracted the executables and the
|
||||||
target specific files. For example, for Windows users targeting C64, you need
|
target-specific files. For example: for Windows users targeting C64, you need
|
||||||
cc65-win32-2.8.0.zip and cc65-c64-2.8.0.zip (or whatever the current cc65
|
<bf/cc65-win32-2.10.1.zip/ and <bf/cc65-c64-2.10.1.zip/ (or, whatever the
|
||||||
version is) extracted to the same directory. If you received the files as a
|
current cc65 version is) extracted to the same directory. If you received the
|
||||||
bzip2 archive (extension *.bz2), you will need to get the <htmlurl
|
files as a bzip2 archive (extension <bf/.bz2/), you will need to get <url
|
||||||
url="http://sources.redhat.com/bzip2/#bzip2-latest" name="bzip2 package"> to
|
url="http://sources.redhat.com/bzip2/#bzip2-latest" name="the bzip2 package">
|
||||||
decompress it.
|
to decompress it.
|
||||||
|
|
||||||
<bf>Note</bf>: There is a much simpler way to compile this example using the
|
<bf/Note/: There is a much simpler way to compile this example, by using the
|
||||||
cl65 compiler and link utility. However, it makes sense to understand how the
|
<bf/cl65/ compile-and-link utility. However, it makes sense to understand how
|
||||||
separate steps work. How to do the example with the cl65 utility is described
|
the separate steps work. How to do the example with the <bf/cl65/ utility is
|
||||||
<ref id="using-cl65" name="later">.
|
described <ref id="using-cl65" name="later">.
|
||||||
|
|
||||||
|
|
||||||
<sect1>Before we start<p>
|
<sect1>Before we start<p>
|
||||||
|
|
||||||
You will find a copy of the sample modules used in the next section in the
|
You will find a copy of the sample modules, used in the next section, in the
|
||||||
samples/tutorial directory. Please check that the compiler and linker can
|
"<tt>cc65/samples/tutorial</tt>" directory. Please make sure that the compiler
|
||||||
find the include library files by setting the environment variables
|
and linker can find the include and library files, by setting the environment
|
||||||
<tt/CC65_INC/ and <tt/CC65_LIB/ respectively.
|
variables <tt/CC65_INC/ and <tt/CC65_LIB/, respectively.
|
||||||
|
|
||||||
|
|
||||||
<sect1>The sample modules<p>
|
<sect1>The sample modules<p>
|
||||||
@ -50,24 +52,23 @@ find the include library files by setting the environment variables
|
|||||||
To explain the development flow, I will use the following example modules:
|
To explain the development flow, I will use the following example modules:
|
||||||
|
|
||||||
hello.c:
|
hello.c:
|
||||||
|
|
||||||
<tscreen><code>
|
<tscreen><code>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
extern const char text[]; /* In text.s */
|
extern const char text[]; /* In text.s */
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
printf ("%s\n", text);
|
printf ("%s\n", text);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
</code></tscreen>
|
</code></tscreen>
|
||||||
|
|
||||||
text.s:
|
text.s:
|
||||||
<tscreen><code>
|
<tscreen><code>
|
||||||
.export _text
|
.export _text
|
||||||
_text: .asciiz "Hello world!"
|
_text: .asciiz "Hello world!"
|
||||||
</code></tscreen>
|
</code></tscreen>
|
||||||
|
|
||||||
|
|
||||||
@ -80,34 +81,34 @@ is the C64.
|
|||||||
+---------+
|
+---------+
|
||||||
| hello.c |
|
| hello.c |
|
||||||
+---------+
|
+---------+
|
||||||
|
|
|
|
||||||
cc65
|
cc65
|
||||||
\/
|
\/
|
||||||
+---------+ +---------+
|
+---------+ +---------+
|
||||||
| hello.s | | text.s |
|
| hello.s | | text.s |
|
||||||
+---------+ +---------+
|
+---------+ +---------+
|
||||||
| |
|
| |
|
||||||
ca65 ca65
|
ca65 ca65
|
||||||
\/ \/
|
\/ \/
|
||||||
+---------+ +---------+ +----------+ +---------+
|
+---------+ +---------+ +----------+ +---------+
|
||||||
| hello.o | | text.o | | c64.o | | c64.lib |
|
| hello.o | | text.o | | c64.o | | c64.lib |
|
||||||
+---------+ +---------+ +----------+ +---------+
|
+---------+ +---------+ +----------+ +---------+
|
||||||
| \ / |
|
| \ / |
|
||||||
| \ / |
|
| \ / |
|
||||||
| \ / |
|
| \ / |
|
||||||
+----------------------->ld65<-------------------------+
|
+----------------------->ld65<-------------------------+
|
||||||
\/
|
\/
|
||||||
hello
|
hello
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
<tt/c64.o/ (the startup code) and <tt/c64.lib/ (the c64 version of the runtime
|
<tt/c64.o/ (the startup code) and <tt/c64.lib/ (the C64 version of the runtime
|
||||||
and C library) are provided in binary form in the cc65 package.
|
and C library) are provided in binary form in the cc65 package.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sect>The compiler<p>
|
<sect>The compiler<p>
|
||||||
|
|
||||||
The compiler translates one C source into one assembler source for each
|
The compiler translates one C source into one assembly source, for each
|
||||||
invocation. It does <em/not/ create object files directly, and it is <em/not/
|
invocation. It does <em/not/ create object files directly, and it is <em/not/
|
||||||
able to translate more than one file per run.
|
able to translate more than one file per run.
|
||||||
|
|
||||||
@ -115,7 +116,7 @@ In the example above, we would use the following command line, to translate
|
|||||||
<tt/hello.c/ into <tt/hello.s/:
|
<tt/hello.c/ into <tt/hello.s/:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
cc65 -O -I ../include -t c64 hello.c
|
cc65 -O -I ../../include -t c64 hello.c
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
The <tt/-O/ switch tells the compiler to do an additional optimizer run, which
|
The <tt/-O/ switch tells the compiler to do an additional optimizer run, which
|
||||||
@ -124,155 +125,167 @@ about the size, but want to have slightly faster code, use <tt/-Oi/ to inline
|
|||||||
some runtime functions.
|
some runtime functions.
|
||||||
|
|
||||||
The <tt/-I/ switch gives a search path for the include files. You may also set
|
The <tt/-I/ switch gives a search path for the include files. You may also set
|
||||||
the environment variable CC65_INC to the search path.
|
the environment variable <tt/CC65_INC/ to the search path.
|
||||||
|
|
||||||
The <tt/-t/ switch is followed by the target system.
|
The <tt/-t/ switch is followed by the target system name.
|
||||||
|
|
||||||
If the compiler does not complain about errors in our hello world, we will
|
If the compiler does not complain about errors in our "hello world" program, we
|
||||||
have a file named "<tt/hello.s/" in our directory that contains the assembler
|
will have a file named "<tt/hello.s/", in our directory, that contains the
|
||||||
source for the hello module.
|
assembly source for the <bf/hello/ module.
|
||||||
|
|
||||||
For more information about the compiler see <htmlurl url="cc65.html"
|
For more information about the compiler, see <url url="cc65.html">.
|
||||||
name="cc65.html">.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sect>The assembler<p>
|
<sect>The assembler<p>
|
||||||
|
|
||||||
The assembler translates one assembler source into an object file for each
|
The assembler translates one assembly source into an object file, for each
|
||||||
invocation. The assembler is <tt/not/ able to translate more than one source
|
invocation. The assembler is <em/not/ able to translate more than one source
|
||||||
file per run.
|
file per run.
|
||||||
|
|
||||||
Let's translate the hello.s and text.s files from our example:
|
Let's translate the "hello.s" and "text.s" files from our example:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
ca65 hello.s
|
ca65 hello.s
|
||||||
ca65 -t c64 text.s
|
ca65 -t c64 text.s
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
The <tt/-t/ switch is needed when translating the <tt/text.s/ file, so the
|
The <tt/-t/ switch is needed when translating the <tt/text.s/ file, so the
|
||||||
text is converted from the input character set (usually ISO-8859-1) into the
|
text is converted from the input character-set (usually ISO-8859-1) into the
|
||||||
target character set (PETSCII) by the assembler. The compiler generated file
|
target character-set (PETSCII, in this example) by the assembler. The
|
||||||
<tt/hello.s/ does not contain any character constants, so specification of a
|
compiler-generated file <tt/hello.s/ does not contain any character constants,
|
||||||
target is not necessary (it wouldn't do any harm, however).
|
so specification of a target is not necessary (it wouldn't do any harm,
|
||||||
|
however).
|
||||||
|
|
||||||
If the assembler does not complain, we should now have two object files (named
|
If the assembler does not complain, we should now have two object files (named
|
||||||
<tt/hello.o/ and <tt/text.o/) in the current directory.
|
<tt/hello.o/ and <tt/text.o/) in the current directory.
|
||||||
|
|
||||||
For more information about the assembler see <htmlurl url="ca65.html"
|
For more information about the assembler, see <url url="ca65.html">.
|
||||||
name="ca65.html">.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sect>The linker<p>
|
<sect>The linker<p>
|
||||||
|
|
||||||
The linker combines several object and library file into one output file. ld65
|
The linker combines several object and library files into one output file.
|
||||||
is very configurable, but fortunately has a builtin configuration for the C64,
|
<bf/ld65/ is very configurable, but fortunately has a built-in configuration
|
||||||
so we don't need to mess with configuration files here.
|
for the C64, so we don't need to mess with configuration files, here.
|
||||||
|
|
||||||
The compiler uses small functions to do things that cannot be done inline
|
The compiler uses small functions to do things that cannot be done inline
|
||||||
without big impact on code size. These runtime functions, together with the C
|
without a big impact on code size. Those runtime functions, together with the
|
||||||
library are in an object file archive named after the system, in this case
|
C library, are in an object-file archive named after the system, in this case,
|
||||||
"<tt/c64.lib/". We have to specify this file on the command line so that the
|
"<tt/c64.lib/". We have to specify that file on the command line, so that the
|
||||||
linker can resolve these functions.
|
linker can resolve those functions.
|
||||||
|
|
||||||
A second file (this time an object file) needed, is the startup code that
|
A second file (this time, an object file) needed is the startup code that
|
||||||
prepares the grounds for the C program to run. The startup file must be
|
prepares the grounds for the C program to run. The startup file must be
|
||||||
executed first, so it must be the first file on the linker command line.
|
executed first, so it must be the first file on the linker command line.
|
||||||
|
|
||||||
Let's link our files to get the final executable:
|
Let's link our files to get the final executable:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
ld65 -t c64 -o hello c64.o hello.o text.o c64.lib
|
ld65 -t c64 -o hello c64.o hello.o text.o c64.lib
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
The argument after <tt/-o/ specifies the name of the output file, the argument
|
The argument after <tt/-o/ specifies the name of the output file, the argument
|
||||||
after <tt/-t/ gives the target system. As discussed, the startup file must be
|
after <tt/-t/ gives the target system. As discussed, the startup file must be
|
||||||
the first file on the command line (you may have to add a path here, if
|
the first input file on the command line (you may have to add a path here, if
|
||||||
<tt/c64.o/ is not in your current directory). Since the library resolves
|
<tt/c64.o/ is not in your current directory). Since the library resolves
|
||||||
imports in <tt/hello.o/ and <tt/text.o/, it must be specified <em/after/ these
|
imports in <tt/hello.o/ and <tt/text.o/, it must be specified <em/after/ those
|
||||||
files.
|
files.
|
||||||
|
|
||||||
After a successful linker run, we have a file named "<tt/hello/", ready for
|
After a successful linker run, we have a file named "<tt/hello/", ready for
|
||||||
our C64!
|
our C64!
|
||||||
|
|
||||||
For more information about the linker see <htmlurl url="ld65.html"
|
For more information about the linker, see <url url="ld65.html">.
|
||||||
name="ld65.html">.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sect>The easy way (using the cl65 utility)<label id="using-cl65"><p>
|
<sect>The easy way (using the cl65 utility)<label id="using-cl65"><p>
|
||||||
|
|
||||||
The cl65 utility is able to do all of the steps described above in just one
|
The <bf/cl65/ utility is able to do all of the steps described above, in just
|
||||||
call, and it has defaults for some options that are very well suited for our
|
one command line, and it has defaults for some options that are very
|
||||||
example.
|
well-suited for our example.
|
||||||
|
|
||||||
To compile both files into one executable enter
|
To compile both files into one executable, enter:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
cl65 -O -I ../include hello.c text.s
|
cl65 -O -I ../../include -L ../../lib hello.c text.s
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
(The <tt/-I/ switch is not needed if you are working under Linux with the
|
(The <tt/-I/ option is not needed if you are working under a Unix-like system
|
||||||
include files in the default path, or the <tt/CC65_INC/ environment variable
|
with the include files in their default path, or if the <tt/CC65_INC/
|
||||||
is set correctly).
|
environment variable is set correctly. The <tt/-L/ option is not needed if the
|
||||||
|
libraries are in their default path, or if the <tt/CC65_LIB/ environment
|
||||||
|
variable is set correctly. [Those two environment variables should be set to
|
||||||
|
absolute paths.])
|
||||||
|
|
||||||
The cl65 utility knows, how to translate C files into object files (it will
|
The <bf/cl65/ utility knows how to translate C files into object files (it will
|
||||||
call the compiler and then the assembler). It does also know how to create
|
call the compiler, and then, the assembler). It does know also how to create
|
||||||
object files from assembler files (it will call the assembler for that). It
|
object files from assembly files (it will call only the assembler, for that).
|
||||||
knows how to build an executable (it will pass all object files to the
|
It knows how to build an executable (it will pass all object files to the
|
||||||
linker). And, finally, it has the C64 as a default target and will supply the
|
linker). And finally, it has the C64 as a default target, and will supply the
|
||||||
correct startup file and runtime library names to the linker, so you don't
|
correct startup file and runtime library names to the linker, so you don't
|
||||||
have to care about that.
|
have to care about that.
|
||||||
|
|
||||||
The one-liner above should give you a C64 executable named "<tt/hello/" in the
|
The one-liner above should give you a C64 executable named "<tt/hello/" in the
|
||||||
current directory.
|
current directory.
|
||||||
|
|
||||||
For more information about the compile & link utility see <htmlurl
|
For more information about the compile & link utility, see <url
|
||||||
url="cl65.html" name="cl65.html">.
|
url="cl65.html">.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sect>Running The Executable<p>
|
<sect>Running The Executable<p>
|
||||||
|
|
||||||
<bf>Note: this section is incomplete!</bf>
|
<em/Note: this section is incomplete!/
|
||||||
|
|
||||||
Depending on the target, the compiler chooses several methods of making a
|
Depending on the target, cc65 chooses several methods of making a
|
||||||
program available for execution. Here we list sample emulators and
|
program available for execution. Here, we list sample emulators and
|
||||||
instructions for running the program. Unless noted, similar instructions
|
instructions for running the program. Unless noted, similar instructions
|
||||||
would also apply to a real machine. One word of advice: we suggest you clear
|
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,
|
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.
|
as each target varies in it's start and exit conditions.
|
||||||
|
|
||||||
<sect1>Apple<p>
|
|
||||||
|
|
||||||
<bf>AppleWin 1.10.4</bf> (available at
|
<sect1>Apple
|
||||||
<url url="http://www.jantzer-schmidt.de/applewin/">): Emulates Apple II+/IIe
|
|
||||||
computer, with sound, video, joysticks, serial port, and disk images. Roms and
|
<sect2>AppleWin 1.10.4<p>
|
||||||
dos disk included. Includes monitor. Only for Windows. The package comes with
|
Available at <url url="http://www.jantzer-schmidt.de/applewin/">:
|
||||||
roms and dos3.3 disk (called master.dsk), however you will need a2tools
|
|
||||||
(available at <url url="http://hotel04.ausys.se/pausch/apple2/#a2tools">).
|
Emulates Apple II+/IIe computers, with sound, video, joysticks, serial port,
|
||||||
|
and disk images. Includes monitor. Only for Windows. The package comes with
|
||||||
|
ROM and DOS 3.3 disk (called "master.dsk") images; however, you will need
|
||||||
|
<bf/a2tools/ (available at <url
|
||||||
|
url="http://hotel04.ausys.se/pausch/apple2/#a2tools">).
|
||||||
|
|
||||||
Compile the tutorial with
|
Compile the tutorial with
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
cl65 -O -t apple2 hello.c text.s
|
cl65 -O -t apple2 hello.c text.s
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
for the Apple II, or:
|
||||||
|
<tscreen><verb>
|
||||||
|
cl65 -O -t apple2enh hello.c text.s
|
||||||
|
</verb></tscreen>
|
||||||
|
for the Apple IIe.
|
||||||
|
|
||||||
Then insert the file into an Apple disk image for use with an emulator. Copy
|
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
|
the <tt/master.dsk/ which comes with <bf/Applewin/, and rename it to
|
||||||
a2tools:
|
<tt/cc65.dsk/, then use <bf/a2tools/:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
a2tools in -r b cc65.dsk TEST hello
|
a2tools in -r b cc65.dsk TEST hello
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
Note that a convention in the Apple world is that hello is the file which is
|
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
|
run automatically 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
|
the MSDOS/Windows world. We've avoided that in the example, however. Also,
|
||||||
parameter must be in caps, and is the name of the program as it will appear on
|
the <tt/TEST/ parameter must be in caps., and is the name of the program as it
|
||||||
the Apple disk.
|
will appear on the Apple disk.
|
||||||
|
|
||||||
Start the emulator, click on the Disk 1 icon, and point to cc65.dsk, then
|
Start the emulator, click on the <bf/Disk 1/ icon, and point to <bf/cc65.dsk/;
|
||||||
click the big Apple logo to boot the system. Then type this on the Apple:
|
then, click the big Apple logo, to boot the system. Then, type this on the
|
||||||
|
Apple:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
BRUN TEST
|
BRUN TEST
|
||||||
@ -282,14 +295,17 @@ You will see the "Hello, World!" appear on the same line. Thanks to Oliver
|
|||||||
Schmidt, <htmlurl url="mailto:oliver@jantzer-schmidt.de"
|
Schmidt, <htmlurl url="mailto:oliver@jantzer-schmidt.de"
|
||||||
name="oliver@jantzer-schmidt.de"> for his help in completing this section.
|
name="oliver@jantzer-schmidt.de"> for his help in completing this section.
|
||||||
|
|
||||||
<sect1>Atari<p>
|
|
||||||
|
|
||||||
<bf>Atari800Win Plus 3.0</bf> (available at
|
<sect1>Atari
|
||||||
<url url="http://www.a800win.atari-area.prv.pl">): Emulates Atari
|
|
||||||
400/800/65XE/130XE/800XL/1200XL/5200, with stereo sound, disk images, scanline
|
<sect2>Atari800Win Plus 3.0<p>
|
||||||
exact NTSC/PAL video, joysticks, mouse, cartridges and ram expansions.
|
Available at <url url="http://www.a800win.atari-area.prv.pl">:
|
||||||
Includes monitor. Unfortunately only for Windows. You will need the emulator,
|
|
||||||
atarixl.rom or atariosb.rom/ataribas.rom and dos25.xfd files (not supplied).
|
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
|
Compile the tutorial with
|
||||||
|
|
||||||
@ -297,43 +313,74 @@ Compile the tutorial with
|
|||||||
cl65 -O -t atari hello.c text.s
|
cl65 -O -t atari hello.c text.s
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
Start the emulator, choose File>Autoboot image or File>Load executable, and
|
Start the emulator, choose <bf/File>Autoboot image/ or <bf/File>Load
|
||||||
point to the hello executable. It is customary to rename executables of this
|
executable/, and point to the "<bf/hello/" executable. It is customary to
|
||||||
type to hello.xex. The file has a 7 byte header meant to be loaded directly
|
rename executables of that type to "<bf/hello.xex/". The file has a 7-byte
|
||||||
from Atari DOS 2/2.5 or compatibles.
|
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.
|
On a real Atari, you would need a disk drive, and Atari DOS 2.5 or compatible.
|
||||||
Turn on the computer, type
|
Turn on the computer, type
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
DOS
|
DOS
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
at the basic prompt, then choose N. CREATE MEM.SAV then choose L. BINARY LOAD
|
at the BASIC prompt, then choose <bf/N. CREATE MEM.SAV/,
|
||||||
and enter HELLO.
|
then choose <bf/L. BINARY LOAD/, and enter <tt/HELLO/.
|
||||||
|
|
||||||
The emulation also supports this method. Look at Atari>Settings and check
|
The emulation, also, supports that method. Look at <bf/Atari>Settings/, and
|
||||||
Enable H: Patch for Hard Disk Devices, then Atari>Hard disks and set the path
|
check <bf/Enable H: Patch for Hard Disk Devices/, then <bf/Atari>Hard
|
||||||
of H1: to your executables directory, then use H0:HELLO.XEX in the above
|
disks/, and set the path of <bf/H1:/ to your executables directory, then use
|
||||||
procedure (after pressing L) to access your hardrive directly.
|
"<bf/H0:HELLO.XEX/" in the above procedure (after pressing <tt/L/), to access
|
||||||
|
your harddrive directly.
|
||||||
|
|
||||||
<bf>Note:</bf> There is no delay after the program exits, as you are returned
|
<bf/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
|
to the DOS menu. Your C program should wait for a keypress if you want to see
|
||||||
any output.
|
any output.
|
||||||
|
|
||||||
<sect1>Commodore<p>
|
|
||||||
|
|
||||||
<bf>Vice 1.15</bf> (available at
|
<sect1>Commodore
|
||||||
<url url="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
|
<sect2>VICE 1.16<p>
|
||||||
image, and choose your executable. The file has a 14 byte header which
|
Available at <url
|
||||||
corresponds to a PRG format BASIC program, consisting of a single line;
|
url="http://www.zimmers.net/anonftp/pub/cbm/crossplatform/emulators/VICE/">,
|
||||||
|
<newline>and at <url
|
||||||
|
url="http://www.ibiblio.org/pub/micro/commodore/crossplatform/emulators/VICE/">:
|
||||||
|
|
||||||
|
Emulates Commodore 64/128/VIC-20/PET/CBM II/Plus 4 computers. Supports
|
||||||
|
printers, serial port and adapters, stereo sound, disk drives and images, RAM
|
||||||
|
expansions, cartridges, ethernet connection, cycle-exact NTSC/PAL video, mice,
|
||||||
|
and joysticks. Includes monitor. Runs on MSDOS/PCDOS, Win9x/ME/NT/2000/XP, OS2,
|
||||||
|
BeOS x86, Acorn RISC OS, and most Unixes.
|
||||||
|
|
||||||
|
Compile the tutorial with
|
||||||
|
<tscreen><verb>
|
||||||
|
cl65 -O -t <sys> hello.c text.s
|
||||||
|
</verb></tscreen>
|
||||||
|
Substitute the name of a Commodore computer for that <tt/<sys>/:
|
||||||
|
<itemize>
|
||||||
|
<item><tt/c128/
|
||||||
|
<item><tt/c16/
|
||||||
|
<item><tt/c64/
|
||||||
|
<item><tt/cbm510/
|
||||||
|
<item><tt/cbm610/
|
||||||
|
<item><tt/pet/
|
||||||
|
<item><tt/plus4/
|
||||||
|
<item><tt/vic20/
|
||||||
|
</itemize>
|
||||||
|
|
||||||
|
Start the desired version of the emulator (CBM510 and CBM610 programs run on
|
||||||
|
the CBM II [<tt/xcbm2/] emulator).
|
||||||
|
|
||||||
|
In the Windows versions of VICE, choose <bf>File>Autoboot disk/tape
|
||||||
|
image...</bf>, choose your executable, and click <bf/OK/.
|
||||||
|
|
||||||
|
In the Unix versions, hold down the mouse's first button. Move the pointer to
|
||||||
|
<bf>Smart-attach disk/tape...</bf>, and release the button. Choose your
|
||||||
|
executable, and click <bf/Autostart/.
|
||||||
|
|
||||||
|
The file has a 14-byte header which corresponds to a PRG-format BASIC program,
|
||||||
|
consisting of a single line, similar to this:
|
||||||
|
|
||||||
<tscreen><code>
|
<tscreen><code>
|
||||||
1000 sys2061
|
1000 sys2061
|
||||||
@ -342,30 +389,113 @@ corresponds to a PRG format BASIC program, consisting of a single line;
|
|||||||
On a real Commodore with attached disk drive, you would type:
|
On a real Commodore with attached disk drive, you would type:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
LOAD "HELLO",8
|
LOAD "0:HELLO",8
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
for Vic 20/C64, or
|
for VIC-20/C64, or:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
DLOAD "0:HELLO"
|
DLOAD "HELLO"
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
on PET/CBM II/C128, then type
|
on PET/CBM II/C128/C16/Plus 4; then, type
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
RUN
|
RUN
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
|
On a Commodore 128, you can combine those two commands:
|
||||||
|
<tscreen><verb>
|
||||||
|
RUN "HELLO"
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
The output will appear on a separate line, and you will be returned to a BASIC
|
The output will appear on a separate line, and you will be returned to a BASIC
|
||||||
prompt.
|
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.
|
<sect1>GEOS<p>
|
||||||
|
Available at <it/Click Here Software's/ <url
|
||||||
|
url="http://cmdrkey.com/cbm/geos/geos1.html" name="GEOS download page">:
|
||||||
|
|
||||||
|
<it><bf/G/raphics <bf/E/nvironment <bf/O/perating <bf/S/ystem.</it>
|
||||||
|
It provides a WIMP GUI (Windows, Icons, and Mouse-Pointer Graphical User
|
||||||
|
Interface) for Commodore's computer models <bf/64/ and <bf/128/. It can be
|
||||||
|
controlled by many different types of input devices:
|
||||||
|
<itemize>
|
||||||
|
<item>keyboard
|
||||||
|
<item>joysticks
|
||||||
|
<item>mice
|
||||||
|
<item>trackballs
|
||||||
|
<item>graphics drawing tablets
|
||||||
|
<item>light-pens
|
||||||
|
</itemize>
|
||||||
|
|
||||||
|
The tutorial files are different for GEOS. You will find them "next door," in
|
||||||
|
"<tt>cc65/samples/geos</tt>"; they are called "<tt/hello1.c/" and
|
||||||
|
"<tt/apphello1.grc/".
|
||||||
|
|
||||||
|
Compile the tutorial with
|
||||||
|
<tscreen><verb>
|
||||||
|
cl65 -O -t geos hello1.c apphello1.grc
|
||||||
|
</verb></tscreen>
|
||||||
|
Copy the resulting file "<tt/hello1/" onto a (GEOS-format) disk.
|
||||||
|
|
||||||
|
Boot the GEOS master disk/image.
|
||||||
|
|
||||||
|
<quote>
|
||||||
|
When you want to run GEOS in an emulator, you must adjust that emulator so that
|
||||||
|
it does a "true drive" emulation. Each emulator has its own way of turning that
|
||||||
|
feature on.
|
||||||
|
</quote>
|
||||||
|
|
||||||
|
<quote>
|
||||||
|
VICE even has different ways that depend on which operating system is running
|
||||||
|
the emulator.
|
||||||
|
<itemize>
|
||||||
|
<item>In Windows, you must click on <bf/Options/ (in an always visible menu).
|
||||||
|
Then, you must click on <bf/True drive emulation/.
|
||||||
|
<item>In Unix, you must <em/hold down/ the second button on your mouse. Move
|
||||||
|
the pointer down to <bf/Drive settings/. Then, move the pointer over to
|
||||||
|
<bf/Enable true drive emulation/. (If there is a check-mark in front of
|
||||||
|
those words, that feature already is turned on -- then, move the pointer
|
||||||
|
off of that menu.) Release the mouse button.
|
||||||
|
</itemize>
|
||||||
|
</quote>
|
||||||
|
|
||||||
|
Find the <bf/CONVERT/ program on the boot disk [tap the 6-key; then, you
|
||||||
|
should see it's icon in the fourth position on the <bf/deskTop/'s directory
|
||||||
|
notePad]. Move GEOS's pointer over to <bf/CONVERT/'s icon; double-click
|
||||||
|
it to run that program. Click on the <bf/Disk/ icon; put the disk with
|
||||||
|
"<tt/hello1/" into the drive; and, click the <bf/OK/ icon. Use the little
|
||||||
|
icons under the list of file-names to move through that list until you find
|
||||||
|
"<tt/hello1/". Click on it; and then, click on the <bf/Convrt/ icon.
|
||||||
|
<bf/CONVERT/ will ask you to confirm that you choose the correct file; click
|
||||||
|
<bf/YES/ if you did (or, click <bf/NO/ if you made a mistake). After the
|
||||||
|
program has converted "<tt/hello1/" from a CBM file into a GEOS file, it will
|
||||||
|
announce what it did -- click on <bf/OK/. <bf/CONVERT/ will show the file list
|
||||||
|
again. This time, click on <bf/Quit/.
|
||||||
|
|
||||||
|
(You might need to put the boot disk back into the drive, in order to reload
|
||||||
|
<bf/deskTop/. Then, you must swap back to the disk with the tutorial program
|
||||||
|
on it, and click on its disk icon [on the right side of the screen].)
|
||||||
|
|
||||||
|
Now, you must find <bf/hello1/. Click on the lower left-hand corner of the
|
||||||
|
directory notePad. Look at the eight file-positions on each page until you see
|
||||||
|
<bf/hello1/. Double-click on its icon.
|
||||||
|
|
||||||
|
The output is shown in a GEOS dialog box; click <bf/OK/ when you have finished
|
||||||
|
reading it.
|
||||||
|
|
||||||
|
|
||||||
|
<sect1>Contributions wanted<p>
|
||||||
|
|
||||||
|
We need your help! Recommended emulators and instructions for other targets
|
||||||
|
are missing. We suggest that you choose emulators 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 or Windows would help to reach a wider
|
||||||
|
audience.
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user