Next Previous Contents

1. Overview

This is a short intro, how to use the compiler and the binutils. It contains a step-by-step example, how to build a complete application from one C and one assembler module. This file does not contain a complete reference for the tools used in the process. There are separate files describing these tools in detail.

Note: There is a much simpler way to compile this example using the cl65 compiler and link utility. However, it makes sense to understand how the separate steps work. How to do the example with the cl65 utility is described below.

1.1 The sample modules

To explain the development flow, I will use the following example modules:

hello.c:


        #include <stdio.h>
        #include <stdlib.h>

        extern const char text[];       /* In text.s */

        int main (void)
        {
            printf ("%s\n", text);
            return EXIT_SUCCESS;
        }

text.s:


        .export _text
        _text:  .asciiz "Hello world!"

1.2 Translation phases

We assume that the target file should be named "hello", and the target system is the C64.

    +---------+
    | hello.c |
    +---------+
         |
        cc65
         \/
    +---------+       +---------+
    | hello.s |       | text.s  |
    +---------+       +---------+
         |                 |
        ca65              ca65
         \/                \/
    +---------+       +---------+       +----------+       +---------+
    | hello.o |       | text.o  |       |  c64.o   |       | c64.lib |
    +---------+       +---------+       +----------+       +---------+
         |                     \         /                      |
         |                      \       /                       |
         |                       \     /                        |
         +----------------------->ld65<-------------------------+
                                   \/
                                  hello

c64.o (the startup code) and c64.lib (the c64 version of the runtime and C library) are provided in binary form in the cc65 package.


Next Previous Contents