7bca5fab5b
git-svn-id: svn://svn.compuextreme.de/Viitor/V962/Viitor_cc65@4352 504e572c-2e33-0410-9681-be2bf7408885
333 lines
13 KiB
HTML
333 lines
13 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 Users Guide: Usage</TITLE>
|
|
<LINK HREF="cc65-3.html" REL=next>
|
|
<LINK HREF="cc65-1.html" REL=previous>
|
|
<LINK HREF="cc65.html#toc2" REL=contents>
|
|
</HEAD>
|
|
<BODY>
|
|
<A HREF="cc65-3.html">Next</A>
|
|
<A HREF="cc65-1.html">Previous</A>
|
|
<A HREF="cc65.html#toc2">Contents</A>
|
|
<HR>
|
|
<H2><A NAME="s2">2.</A> <A HREF="cc65.html#toc2">Usage</A></H2>
|
|
|
|
|
|
<P>The compiler translates C files into files containing assembly code that
|
|
may be translated by the ca65 macroassembler (for more information about
|
|
the assembler, have a look at
|
|
<A HREF="ca65.html">ca65.html</A>).</P>
|
|
|
|
|
|
<H2><A NAME="ss2.1">2.1</A> <A HREF="cc65.html#toc2.1">Command line option overview</A>
|
|
</H2>
|
|
|
|
|
|
<P>The compiler may be called as follows:</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
---------------------------------------------------------------------------
|
|
Usage: cc65 [options] file
|
|
Short options:
|
|
-Cl Make local variables static
|
|
-Dsym[=defn] Define a symbol
|
|
-I dir Set an include directory search path
|
|
-O Optimize code
|
|
-Oi Optimize code, inline more code
|
|
-Or Enable register variables
|
|
-Os Inline some known functions
|
|
-T Include source as comment
|
|
-V Print the compiler version number
|
|
-W Suppress warnings
|
|
-d Debug mode
|
|
-g Add debug info to object file
|
|
-h Help (this text)
|
|
-j Default characters are signed
|
|
-o name Name the output file
|
|
-r Enable register variables
|
|
-t sys Set the target system
|
|
-v Increase verbosity
|
|
|
|
Long options:
|
|
--add-source Include source as comment
|
|
--bss-name seg Set the name of the BSS segment
|
|
--check-stack Generate stack overflow checks
|
|
--code-name seg Set the name of the CODE segment
|
|
--codesize x Accept larger code by factor x
|
|
--cpu type Set cpu type
|
|
--create-dep Create a make dependency file
|
|
--data-name seg Set the name of the DATA segment
|
|
--debug Debug mode
|
|
--debug-info Add debug info to object file
|
|
--forget-inc-paths Forget include search paths
|
|
--help Help (this text)
|
|
--include-dir dir Set an include directory search path
|
|
--register-space b Set space available for register variables
|
|
--register-vars Enable register variables
|
|
--rodata-name seg Set the name of the RODATA segment
|
|
--signed-chars Default characters are signed
|
|
--standard std Language standard (c89, c99, cc65)
|
|
--static-locals Make local variables static
|
|
--target sys Set the target system
|
|
--verbose Increase verbosity
|
|
--version Print the compiler version number
|
|
--writable-strings Make string literals writable
|
|
---------------------------------------------------------------------------
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
|
|
|
|
<H2><A NAME="ss2.2">2.2</A> <A HREF="cc65.html#toc2.2">Command line options in detail</A>
|
|
</H2>
|
|
|
|
|
|
<P>Here is a description of all the command line options:</P>
|
|
<P>
|
|
<DL>
|
|
|
|
<DT><B><CODE>--bss-name seg</CODE></B><DD><P>Set the name of the bss segment.</P>
|
|
|
|
|
|
<DT><B><CODE>--check-stack</CODE></B><DD><P>Tells the compiler to generate code that checks for stack overflows. See
|
|
<CODE>
|
|
<A HREF="cc65-7.html#pragma-checkstack">#pragma checkstack</A></CODE> for an
|
|
explanation of this feature.</P>
|
|
|
|
|
|
<DT><B><CODE>--code-name seg</CODE></B><DD><P>Set the name of the code segment.</P>
|
|
|
|
<P>
|
|
<A NAME="option-codesize"></A> </P>
|
|
<DT><B><CODE>--codesize x</CODE></B><DD><P>This options allows finer control about speed vs. size decisions in the code
|
|
generation and optimization phases. It gives the allowed size increase
|
|
factor (in percent). The default is 100 when not using <CODE>-Oi</CODE> and 200 when
|
|
using <CODE>-Oi</CODE> (<CODE>-Oi</CODE> is the same as <CODE>--codesize 200</CODE>).</P>
|
|
|
|
|
|
<DT><B><CODE>--cpu CPU</CODE></B><DD><P>A new, still experimental option. You may specify "6502" or "65C02" as
|
|
the CPU. 6502 is the default, so this will not change anything.
|
|
Specifying 65C02 will use a few 65C02 instructions when generating code.
|
|
Don't expect too much from this option: It is still new (and may have
|
|
bugs), and the additional instructions for the 65C02 are not that
|
|
overwhelming.</P>
|
|
|
|
|
|
<DT><B><CODE>--create-dep</CODE></B><DD><P>Tells the compiler to generate a file containing the dependency list for
|
|
the compiled module in makefile syntax. The file is named as the C input
|
|
file with the extension replaced by <CODE>.u</CODE>.</P>
|
|
|
|
|
|
<DT><B><CODE>-d, --debug</CODE></B><DD><P>Enables debug mode, something that should not be needed for mere
|
|
mortals:-)</P>
|
|
|
|
|
|
<DT><B><CODE>-D sym[=definition]</CODE></B><DD><P>Define a macro on the command line. If no definition is given, the macro
|
|
is defined to the value "1".</P>
|
|
|
|
|
|
<DT><B><CODE>--forget-inc-paths</CODE></B><DD><P>Forget the builtin include paths. This is most useful when building
|
|
customized C or runtime libraries, in which case the standard header
|
|
files should be ignored.</P>
|
|
|
|
|
|
<DT><B><CODE>-g, --debug-info</CODE></B><DD><P>This will cause the compiler to insert a <CODE>.DEBUGINFO</CODE> command into the
|
|
generated assembler code. This will cause the assembler to include all
|
|
symbols in a special section in the object file.</P>
|
|
|
|
|
|
<DT><B><CODE>-h, --help</CODE></B><DD><P>Print the short option summary shown above.</P>
|
|
|
|
|
|
<DT><B><CODE>-o name</CODE></B><DD><P>Specify the name of the output file. If you don't specify a name, the
|
|
name of the C input file is used, with the extension replaced by ".s".</P>
|
|
|
|
|
|
<DT><B><CODE>-r, --register-vars</CODE></B><DD><P><CODE>-r</CODE> will make the compiler honor the <CODE>register</CODE> keyword. Local
|
|
variables may be placed in registers (which are actually zero page
|
|
locations). There is some overhead involved with register variables, since
|
|
the old contents of the registers must be saved and restored. Since register
|
|
variables are of limited use without the optimizer, there is also a combined
|
|
switch: <CODE>-Or</CODE> will enable both, the optimizer and register variables.</P>
|
|
<P>For more information about register variables see
|
|
<A HREF="cc65-8.html#regvars">register variables</A>.</P>
|
|
<P>The compiler setting can also be changed within the source file by using
|
|
<CODE>
|
|
<A HREF="cc65-7.html#pragma-regvars">#pragma regvars</A></CODE>.</P>
|
|
|
|
|
|
<DT><B><CODE>--register-space</CODE></B><DD><P>This option takes a numeric parameter and is used to specify, how much
|
|
zero page register space is available. Please note that just giving this
|
|
option will not increase or decrease by itself, it will just tell the
|
|
compiler about the available space. You will have to allocate that space
|
|
yourself using an assembler module with the necessary allocations, and a
|
|
linker configuration that matches the assembler module. The default value
|
|
for this option is 6 (bytes).</P>
|
|
<P>If you don't know what all this means, please don't use this option.</P>
|
|
|
|
|
|
<DT><B><CODE>--rodata-name seg</CODE></B><DD><P>Set the name of the rodata segment (the segment used for readonly data).</P>
|
|
|
|
|
|
<DT><B><CODE>-j, --signed-chars</CODE></B><DD><P>Using this option, you can make the default characters signed. Since the
|
|
6502 has no provisions for sign extending characters (which is needed on
|
|
almost any load operation), this will make the code larger and slower. A
|
|
better way is to declare characters explicitly as "signed" if needed. You
|
|
can also use <CODE>
|
|
<A HREF="cc65-7.html#pragma-signedchars">#pragma signedchars</A></CODE> for better control of this option.</P>
|
|
|
|
<P>
|
|
<A NAME="option--standard"></A> </P>
|
|
<DT><B><CODE>--standard std</CODE></B><DD><P>This option allows to set the language standard supported. The argument is
|
|
one of
|
|
<UL>
|
|
<LI>c89</LI>
|
|
<LI>c99</LI>
|
|
<LI>cc65</LI>
|
|
</UL>
|
|
</P>
|
|
|
|
|
|
<DT><B><CODE>-t target, --target target</CODE></B><DD><P>This option is used to set the target system. The target system
|
|
determines things like the character set that is used for strings and
|
|
character constants. The following target systems are supported:</P>
|
|
<P>
|
|
<UL>
|
|
<LI>none</LI>
|
|
<LI>apple2</LI>
|
|
<LI>apple2enh</LI>
|
|
<LI>atari</LI>
|
|
<LI>atmos</LI>
|
|
<LI>c16 (works also for the c116 with memory up to 32K)</LI>
|
|
<LI>c64</LI>
|
|
<LI>c128</LI>
|
|
<LI>cbm510 (CBM-II series with 40 column video)</LI>
|
|
<LI>cbm610 (all CBM-II II computers with 80 column video)</LI>
|
|
<LI>geos</LI>
|
|
<LI>lunix</LI>
|
|
<LI>lynx</LI>
|
|
<LI>nes</LI>
|
|
<LI>pet (all CBM PET systems except the 2001)</LI>
|
|
<LI>plus4</LI>
|
|
<LI>supervision</LI>
|
|
<LI>vic20</LI>
|
|
</UL>
|
|
</P>
|
|
|
|
<DT><B><CODE>-v, --verbose</CODE></B><DD><P>Using this option, the compiler will be somewhat more verbose if errors
|
|
or warnings are encountered.</P>
|
|
|
|
|
|
<DT><B><CODE>--writable-strings</CODE></B><DD><P>Make string literals writable by placing them into the data segment instead
|
|
of the rodata segment.</P>
|
|
|
|
|
|
<DT><B><CODE>-Cl, --static-locals</CODE></B><DD><P>Use static storage for local variables instead of storage on the stack.
|
|
Since the stack is emulated in software, this gives shorter and usually
|
|
faster code, but the code is no longer reentrant. The difference between
|
|
<CODE>-Cl</CODE> and declaring local variables as static yourself is, that
|
|
initializer code is executed each time, the function is entered. So when
|
|
using</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
void f (void)
|
|
{
|
|
unsigned a = 1;
|
|
...
|
|
}
|
|
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>the variable <CODE>a</CODE> will always have the value <CODE>1</CODE> when entering the
|
|
function and using <CODE>-Cl</CODE>, while in</P>
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
void f (void)
|
|
{
|
|
static unsigned a = 1;
|
|
....
|
|
}
|
|
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
</P>
|
|
<P>the variable <CODE>a</CODE> will have the value <CODE>1</CODE> only the first time that the
|
|
function is entered, and will keep the old value from one call of the
|
|
function to the next.</P>
|
|
<P>You may also use <CODE>
|
|
<A HREF="cc65-7.html#pragma-staticlocals">#pragma staticlocals</A></CODE> to change this setting in your
|
|
sources.</P>
|
|
|
|
|
|
<DT><B><CODE>-I dir, --include-dir dir</CODE></B><DD><P>Set a directory where the compiler searches for include files. You may
|
|
use this option multiple times to add more than one directory to the
|
|
search list.</P>
|
|
|
|
<P>
|
|
<A NAME="option-O"></A> </P>
|
|
<DT><B><CODE>-O, -Oi, -Or, -Os</CODE></B><DD><P>Enable an optimizer run over the produced code.</P>
|
|
<P>Using <CODE>-Oi</CODE>, the code generator will inline some code where otherwise a
|
|
runtime functions would have been called, even if the generated code is
|
|
larger. This will not only remove the overhead for a function call, but will
|
|
make the code visible for the optimizer. <CODE>-Oi</CODE> is an alias for
|
|
<CODE>--codesize 200</CODE>.</P>
|
|
<P><CODE>-Or</CODE> will make the compiler honor the <CODE>register</CODE> keyword. Local
|
|
variables may be placed in registers (which are actually zero page
|
|
locations). There is some overhead involved with register variables, since
|
|
the old contents of the registers must be saved and restored. In addition,
|
|
the current implementation does not make good use of register variables, so
|
|
using <CODE>-Or</CODE> may make your program even slower and larger. Use with care!</P>
|
|
<P>Using <CODE>-Os</CODE> will force the compiler to inline some known functions from
|
|
the C library like strlen. Note: This has two consequences:</P>
|
|
<P>
|
|
<UL>
|
|
<LI>You may not use names of standard C functions in your own code. If you
|
|
do that, your program is not standard compliant anyway, but using
|
|
<CODE>-Os</CODE> will actually break things.
|
|
|
|
</LI>
|
|
<LI>The inlined string and memory functions will not handle strings or
|
|
memory areas larger than 255 bytes. Similarly, the inlined <CODE>is..()</CODE>
|
|
functions will not work with values outside the char. range (such as
|
|
<CODE>EOF</CODE>).
|
|
|
|
</LI>
|
|
</UL>
|
|
</P>
|
|
<P>It is possible to concatenate the modifiers for <CODE>-O</CODE>. For example, to
|
|
enable register variables and inlining of known functions, you may use
|
|
<CODE>-Ors</CODE>.</P>
|
|
|
|
|
|
<DT><B><CODE>-T, --add-source</CODE></B><DD><P>This include the source code as comments in the generated code. This is
|
|
normally not needed.</P>
|
|
|
|
|
|
<DT><B><CODE>-V, --version</CODE></B><DD><P>Print the version number of the compiler. When submitting a bug report,
|
|
please include the operating system you're using, and the compiler
|
|
version.</P>
|
|
|
|
<P>
|
|
<A NAME="option-W"></A> </P>
|
|
<DT><B><CODE>-W</CODE></B><DD><P>This option will suppress any warnings generated by the compiler. Since
|
|
any source file may be written in a manner that it will not produce
|
|
compiler warnings, using this option is usually not a good idea.</P>
|
|
|
|
</DL>
|
|
</P>
|
|
|
|
|
|
|
|
<HR>
|
|
<A HREF="cc65-3.html">Next</A>
|
|
<A HREF="cc65-1.html">Previous</A>
|
|
<A HREF="cc65.html#toc2">Contents</A>
|
|
</BODY>
|
|
</HTML>
|