9763b5530d
git-svn-id: svn://svn.compuextreme.de/Viitor/V961/Viitor_cc65@4236 504e572c-2e33-0410-9681-be2bf7408885
127 lines
3.9 KiB
HTML
127 lines
3.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.20">
|
|
<TITLE>cc65 Compiler Intro: Overview</TITLE>
|
|
<LINK HREF="intro-2.html" REL=next>
|
|
|
|
<LINK HREF="intro.html#toc1" REL=contents>
|
|
</HEAD>
|
|
<BODY>
|
|
<A HREF="intro-2.html">Next</A>
|
|
Previous
|
|
<A HREF="intro.html#toc1">Contents</A>
|
|
<HR>
|
|
<H2><A NAME="s1">1.</A> <A HREF="intro.html#toc1">Overview</A></H2>
|
|
|
|
|
|
<P>This is a short intro of how to use the compiler and the bin-utils. It contains
|
|
a step-by-step example of how to build a complete application from one C and
|
|
one assembly modules. This file does <EM>not</EM> contain a complete reference for
|
|
the tools used in the process. There are separate files describing those tools,
|
|
in detail (see
|
|
<A HREF="index.html">index.html</A>).</P>
|
|
<P>You are assumed to have downloaded and extracted the executables and the
|
|
target-specific files. For example: for Windows users targeting C64, you need
|
|
<B>cc65-win32-2.10.1.zip</B> and <B>cc65-c64-2.10.1.zip</B> (or, whatever the
|
|
current cc65 version is) extracted to the same directory. If you received the
|
|
files as a bzip2 archive (extension <B>.bz2</B>), you will need to get
|
|
<A HREF="http://sources.redhat.com/bzip2/#bzip2-latest">the bzip2 package</A>
|
|
to decompress it.</P>
|
|
<P><B>Note</B>: There is a much simpler way to compile this example, by using the
|
|
<B>cl65</B> compile-and-link utility. However, it makes sense to understand how
|
|
the separate steps work. How to do the example with the <B>cl65</B> utility is
|
|
described
|
|
<A HREF="intro-5.html#using-cl65">later</A>.</P>
|
|
|
|
|
|
<H2><A NAME="ss1.1">1.1</A> <A HREF="intro.html#toc1.1">Before we start</A>
|
|
</H2>
|
|
|
|
|
|
<P>You will find a copy of the sample modules, used in the next section, in the
|
|
"<CODE>cc65/samples/tutorial</CODE>" directory. Please make sure that the compiler
|
|
and linker can find the include and library files, by setting the environment
|
|
variables <CODE>CC65_INC</CODE> and <CODE>CC65_LIB</CODE>, respectively.</P>
|
|
|
|
|
|
<H2><A NAME="ss1.2">1.2</A> <A HREF="intro.html#toc1.2">The sample modules</A>
|
|
</H2>
|
|
|
|
|
|
<P>To explain the development flow, I will use the following example modules:</P>
|
|
<P>hello.c:
|
|
<BLOCKQUOTE><CODE>
|
|
<HR>
|
|
<PRE>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
extern const char text[]; /* In text.s */
|
|
|
|
int main (void)
|
|
{
|
|
printf ("%s\n", text);
|
|
return EXIT_SUCCESS;
|
|
}
|
|
</PRE>
|
|
<HR>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>text.s:
|
|
<BLOCKQUOTE><CODE>
|
|
<HR>
|
|
<PRE>
|
|
.export _text
|
|
_text: .asciiz "Hello world!"
|
|
</PRE>
|
|
<HR>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
|
|
|
|
<H2><A NAME="ss1.3">1.3</A> <A HREF="intro.html#toc1.3">Translation phases</A>
|
|
</H2>
|
|
|
|
|
|
<P>We assume that the target file should be named "hello", and the target system
|
|
is the C64.</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
+---------+
|
|
| hello.c |
|
|
+---------+
|
|
|
|
|
cc65
|
|
\/
|
|
+---------+ +---------+
|
|
| hello.s | | text.s |
|
|
+---------+ +---------+
|
|
| |
|
|
ca65 ca65
|
|
\/ \/
|
|
+---------+ +---------+ +----------+ +---------+
|
|
| hello.o | | text.o | | c64.o | | c64.lib |
|
|
+---------+ +---------+ +----------+ +---------+
|
|
| \ / |
|
|
| \ / |
|
|
| \ / |
|
|
+----------------------->ld65<-------------------------+
|
|
\/
|
|
hello
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P><CODE>c64.o</CODE> (the startup code) and <CODE>c64.lib</CODE> (the C64 version of the runtime
|
|
and C library) are provided in binary form in the cc65 package.</P>
|
|
|
|
|
|
|
|
<HR>
|
|
<A HREF="intro-2.html">Next</A>
|
|
Previous
|
|
<A HREF="intro.html#toc1">Contents</A>
|
|
</BODY>
|
|
</HTML>
|