1 <!doctype linuxdoc system>
4 <title>cl65 Users Guide
5 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
6 <date>01.08.2000, 27.11.2000, 02.10.2001
9 cl65 is the compile & link utility for cc65, the 6502 C compiler. It was
10 designed as a smart frontend for the C compiler (cc65), the assembler (ca65),
11 the object file converter (co65), and the linker (ld65).
14 <!-- Table of contents -->
17 <!-- Begin the document -->
21 cl65 is a frontend for cc65, ca65, co65 and ld65. While you may not use the
22 full power of the tools when calling them through cl65, most features are
23 available, and the use of cl65 is much simpler.
28 The cl65 compile and link utility may be used to convert, compile, assemble
29 and link files. While the separate tools do just one step, cl65 knows how to
30 build object files from C files (by calling the compiler, then the assembler)
34 ---------------------------------------------------------------------------
35 Usage: cl65 [options] file [...]
37 -c Compile and assemble but don't link
41 -l Create an assembler listing
42 -m name Create a map file
43 -o name Name the output file
44 -r Enable register variables
45 -t sys Set the target system
49 -C name Use linker config file
50 -Cl Make local variables static
51 -D sym[=defn] Define a preprocessor symbol
52 -I dir Set a compiler include directory path
53 -L path Specify a library search path
54 -Ln name Create a VICE label file
56 -Oi Optimize code, inline functions
57 -Or Optimize code, honour the register keyword
58 -Os Optimize code, inline known C funtions
59 -S Compile but don't assemble and link
60 -T Include source as comment
61 -V Print the version number
65 --add-source Include source as comment
66 --ansi Strict ANSI mode
67 --asm-include-dir dir Set an assembler include directory
68 --bss-label name Define and export a BSS segment label
69 --bss-name seg Set the name of the BSS segment
70 --cfg-path path Specify a config file search path
71 --check-stack Generate stack overflow checks
72 --code-label name Define and export a CODE segment label
73 --code-name seg Set the name of the CODE segment
74 --codesize x Accept larger code by factor x
75 --cpu type Set cpu type
76 --create-dep Create a make dependency file
77 --data-label name Define and export a DATA segment label
78 --data-name seg Set the name of the DATA segment
80 --debug-info Add debug info
81 --feature name Set an emulation feature
82 --help Help (this text)
83 --include-dir dir Set a compiler include directory path
84 --lib file Link this library
85 --lib-path path Specify a library search path
86 --listing Create an assembler listing
87 --mapfile name Create a map file
88 --module Link as a module
89 --module-id id Specify a module id for the linker
90 --o65-model model Override the o65 model
91 --obj file Link this object file
92 --obj-path path Specify an object file search path
93 --register-space b Set space available for register variables
94 --register-vars Enable register variables
95 --rodata-name seg Set the name of the RODATA segment
96 --signed-chars Default characters are signed
97 --start-addr addr Set the default start address
98 --static-locals Make local variables static
99 --target sys Set the target system
100 --version Print the version number
101 --verbose Verbose mode
102 --zeropage-label name Define and export a ZEROPAGE segment label
103 --zeropage-name seg Set the name of the ZEROPAGE segment
104 ---------------------------------------------------------------------------
107 Most of the options have the same meaning than the corresponding compiler,
108 assembler or linker option. See the documentation for these tools for an
109 explanation. If an option is available for more than one of the tools, it
110 is set for all tools, where it is available. One example for this is <tt/-v/:
111 The compiler, the assembler and the linker are all called with the <tt/-v/
114 There are a few remaining options that control the behaviour of cl65:
118 <tag><tt>-S</tt></tag>
120 This option forces cl65 to stop after the assembly step. This means that
121 C files are translated into assembler files, but nothing more is done.
122 Assembler files, object files and libraries given on the command line
126 <tag><tt>-c</tt></tag>
128 This options forces cl65 to stop after the assembly step. This means
129 that C and assembler files given on the command line are translated into
130 object files, but there is no link step, and object files and libraries
131 given on the command line are ignored.
134 <tag><tt>-o name</tt></tag>
136 The -o option is used for the target name in the final step. This causes
137 problems, if the linker will not be called, and there are several input
138 files on the command line. In this case, the name given with -o will be
139 used for all of them, which makes the option pretty useless. You
140 shouldn't use -o when more than one output file is created.
143 <tag><tt>-t sys, --target sys</tt></tag>
145 The default for this option is different from the compiler and linker in the
146 case that the option is missing: While the other tools (compiler, assembler
147 and linker) will use the "none" system settings by default, cl65 will use
148 the C64 as a target system by default. This was choosen since most people
149 seem to use cc65 to develop for the C64.
157 Since cl65 was created to simplify the use of the cc65 development
158 package, it tries to be smart about several things.
162 <item> If you don't give a target system on the command line, cl65
165 <item> When linking, cl65 will supply the names of the startup file and
166 library for the target system to the linker, so you don't have to do
169 <item> If the final step is the linker, and the name of the output file was
170 not explicitly given, cl65 will use the name of the first input file
171 without the extension, provided that the name of this file has an
172 extension. So you don't need to name the executable name in most
173 cases, just give the name of your "main" file as first input file.
176 The type of an input file is derived from its extension:
179 <item>C files: <tt/.c/
180 <item>Assembler files: <tt/.s/, <tt/.asm/, <tt/.a65/
181 <item>Object files: <tt/.o/ <tt/.obj/
182 <item>Libraries: <tt/.a/, <tt/.lib/
183 <item>GEOS resource files: <tt/.grc/
184 <item>o65 files: <tt/.o65/, <tt/.emd/, <tt/.joy/, <tt/.tgi/
187 Please note that the program cannot handle input files with unknown file
193 The morse trainer software, which consists of one C file (morse.c) and one
194 assembler file (irq.s) will need the following separate steps to compile
195 into an executable named morse:
198 cc65 -g -Oi -t c64 morse.c
201 ld65 -t c64 -o morse c64.o morse.o irq.o c64.lib
204 When using cl65, this is simplified to
207 cl65 -g -Oi morse.c irq.s
210 As a general rule, you may use cl65 instead of cc65 at most times,
211 especially in makefiles to build object files directly from C files. Use
222 <sect>Bugs/Feedback<p>
224 If you have problems using the utility, if you find any bugs, or if you're
225 doing something interesting with it, I would be glad to hear from you. Feel
226 free to contact me by email (<htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">).
232 cl65 (and all cc65 binutils) are (C) Copyright 1998-2000 Ullrich von
233 Bassewitz. For usage of the binaries and/or sources the following
236 This software is provided 'as-is', without any expressed or implied
237 warranty. In no event will the authors be held liable for any damages
238 arising from the use of this software.
240 Permission is granted to anyone to use this software for any purpose,
241 including commercial applications, and to alter it and redistribute it
242 freely, subject to the following restrictions:
245 <item> The origin of this software must not be misrepresented; you must not
246 claim that you wrote the original software. If you use this software
247 in a product, an acknowledgment in the product documentation would be
248 appreciated but is not required.
249 <item> Altered source versions must be plainly marked as such, and must not
250 be misrepresented as being the original software.
251 <item> This notice may not be removed or altered from any source