]> git.sur5r.net Git - cc65/blob - doc/cl65.sgml
Added blurb about register variables
[cc65] / doc / cl65.sgml
1 <!doctype linuxdoc system>
2
3 <article>
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
7
8 <abstract>
9 cl65 is the compile &amp; 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 and the linker (ld65).
12 </abstract>
13
14 <!-- Table of contents -->
15 <toc>
16
17 <!-- Begin the document -->
18
19 <sect>Overview<p>
20
21 cl65 is a frontend for cc65, ca65 and ld65. While you may not use the full
22 power of the tools when calling them through cl65, most features are
23 available, and the use of cl65 is much simpler.
24
25
26 <sect>Basic Usage<p>
27
28 The cl65 compile and link utility may be used to compile, assemble and
29 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
31 assembler) and other things.
32
33 <tscreen><verb>
34 ---------------------------------------------------------------------------
35 Usage: cl65 [options] file
36 Short options:
37   -c                    Compiler and assemble but don't link
38   -d                    Debug mode
39   -g                    Add debug info
40   -h                    Help (this text)
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
46   -v                    Verbose mode
47   -vm                   Verbose map file
48   -A                    Strict ANSI mode
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   -Ln name              Create a VICE label file
54   -O                    Optimize code
55   -Oi                   Optimize code, inline functions
56   -Or                   Optimize code, honour the register keyword
57   -Os                   Optimize code, inline known C funtions
58   -S                    Compile but don't assemble and link
59   -T                    Include source as comment
60   -V                    Print the version number
61   -W                    Suppress warnings
62
63 Long options:
64   --add-source          Include source as comment
65   --ansi                Strict ANSI mode
66   --asm-include-dir dir Set an assembler include directory
67   --bss-name seg        Set the name of the BSS segment
68   --check-stack         Generate stack overflow checks
69   --code-name seg       Set the name of the CODE segment
70   --codesize x          Accept larger code by factor x
71   --cpu type            Set cpu type
72   --create-dep          Create a make dependency file
73   --data-name seg       Set the name of the DATA segment
74   --debug               Debug mode
75   --debug-info          Add debug info
76   --feature name        Set an emulation feature
77   --help                Help (this text)
78   --include-dir dir     Set a compiler include directory path
79   --listing             Create an assembler listing
80   --mapfile name        Create a map file
81   --register-space b    Set space available for register variables
82   --register-vars       Enable register variables
83   --rodata-name seg     Set the name of the RODATA segment
84   --signed-chars        Default characters are signed
85   --start-addr addr     Set the default start address
86   --static-locals       Make local variables static
87   --target sys          Set the target system
88   --version             Print the version number
89   --verbose             Verbose mode
90 ---------------------------------------------------------------------------
91 </verb></tscreen>
92
93 Most of the options have the same meaning than the corresponding compiler,
94 assembler or linker option. See the documentation for these tools for an
95 explanation. If an option is available for more than one of the tools, it
96 is set for all tools, where it is available. One example for this is <tt/-v/:
97 The compiler, the assembler and the linker are all called with the <tt/-v/
98 switch.
99
100 There are a few remaining options that control the behaviour of cl65:
101
102 <descrip>
103
104   <tag><tt>-S</tt></tag>
105
106   This option forces cl65 to stop after the assembly step. This means that
107   C files are translated into assembler files, but nothing more is done.
108   Assembler files, object files and libraries given on the command line
109   are ignored.
110
111
112   <tag><tt>-c</tt></tag>
113
114   This options forces cl65 to stop after the assembly step. This means
115   that C and assembler files given on the command line are translated into
116   object files, but there is no link step, and object files and libraries
117   given on the command line are ignored.
118
119
120   <tag><tt>-o name</tt></tag>
121
122   The -o option is used for the target name in the final step. This causes
123   problems, if the linker will not be called, and there are several input
124   files on the command line. In this case, the name given with -o will be
125   used for all of them, which makes the option pretty useless. You
126   shouldn't use -o when more than one output file is created.
127
128
129   <tag><tt>-t sys, --target sys</tt></tag>
130
131   The default for this option is different from the compiler and linker in the
132   case that the option is missing: While the other tools (compiler, assembler
133   and linker) will use the "none" system settings by default, cl65 will use
134   the C64 as a target system by default. This was choosen since most people
135   seem to use cc65 to develop for the C64.
136
137 </descrip>
138
139
140
141 <sect>More usage<p>
142
143 Since cl65 was created to simplify the use of the cc65 development
144 package, it tries to be smart about several things.
145
146 <itemize>
147
148 <item>  If you don't give a target system on the command line, cl65
149         defaults to the C64.
150
151 <item>  When linking, cl65 will supply the names of the startup file and
152         library for the target system to the linker, so you don't have to do
153         that.
154
155 <item>  If the final step is the linker, and the name of the output file was
156         not explicitly given, cl65 will use the name of the first input file
157         without the extension, provided that the name of this file has an
158         extension. So you don't need to name the executable name in most
159         cases, just give the name of your "main" file as first input file.
160 </itemize>
161
162
163 <sect>Examples<p>
164
165 The morse trainer software, which consists of one C file (morse.c) and one
166 assembler file (irq.s) will need the following separate steps to compile
167 into an executable named morse:
168
169 <tscreen><verb>
170         cc65 -g -Oi -t c64 morse.c
171         ca65 -g morse.s
172         ca65 -g irq.s
173         ld65 -t c64 -o morse c64.o morse.o irq.o c64.lib
174 </verb></tscreen>
175
176 When using cl65, this is simplified to
177
178 <tscreen><verb>
179         cl65 -g -Oi morse.c irq.s
180 </verb></tscreen>
181
182 As a general rule, you may use cl65 instead of cc65 at most times,
183 especially in makefiles to build object files directly from C files. Use
184
185 <tscreen><verb>
186         .c.o:
187                 cl65 -g -Oi $<
188 </verb></tscreen>
189
190 to do this.
191
192
193
194 <sect>Bugs/Feedback<p>
195
196 If you have problems using the utility, if you find any bugs, or if you're
197 doing something interesting with it, I would be glad to hear from you. Feel
198 free to contact me by email (<htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">).
199
200
201
202 <sect>Copyright<p>
203
204 cl65 (and all cc65 binutils) are (C) Copyright 1998-2000 Ullrich von
205 Bassewitz. For usage of the binaries and/or sources the following
206 conditions do apply:
207
208 This software is provided 'as-is', without any expressed or implied
209 warranty.  In no event will the authors be held liable for any damages
210 arising from the use of this software.
211
212 Permission is granted to anyone to use this software for any purpose,
213 including commercial applications, and to alter it and redistribute it
214 freely, subject to the following restrictions:
215
216 <enum>
217 <item>  The origin of this software must not be misrepresented; you must not
218         claim that you wrote the original software. If you use this software
219         in a product, an acknowledgment in the product documentation would be
220         appreciated but is not required.
221 <item>  Altered source versions must be plainly marked as such, and must not
222         be misrepresented as being the original software.
223 <item>  This notice may not be removed or altered from any source
224         distribution.
225 </enum>
226
227
228
229 </article>
230