cc65-2.html
来自「cc65 的编译器文档」· HTML 代码 · 共 303 行
HTML
303 行
<!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 assembler code thatmay be translated by the ca65 macroassembler (for more information aboutthe assembler, have a look at ca65.txt).</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] fileShort options: -A Strict ANSI mode -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 verbosityLong options: --add-source Include source as comment --ansi Strict ANSI mode --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 --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 --static-locals Make local variables static --target sys Set the target system --verbose Increase verbosity --version Print the compiler version number---------------------------------------------------------------------------</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><P><A NAME="option-A"></A> </P><DT><B><CODE>-A, --ansi</CODE></B><DD><P>This option disables any compiler exensions. Have a look at section 5for a discussion of compiler extensions. In addition, the macro<CODE>__STRICT_ANSI__</CODE> is defined, when using one of these options.</P><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 anexplanation of this feature.</P><DT><B><CODE>--code-name seg</CODE></B><DD><P>Set the name of the code segment.</P><DT><B><CODE>--codesize x</CODE></B><DD><P>This options allows finer control about speed vs. size decisions in thecode generation phase. It gives the allowed size increase factor (inpercent). 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" asthe 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 havebugs), and the additional instructions for the 65C02 are not thatoverwhelming.</P><DT><B><CODE>--create-dep</CODE></B><DD><P>Tells the compiler to generate a file containing the dependency list forthe compiled module in makefile syntax. The file is named as the C inputfile 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 meremortals:-)</P><DT><B><CODE>-D sym[=definition]</CODE></B><DD><P>Define a macro on the command line. If no definition is given, the macrois defined to the value "1".</P><DT><B><CODE>-g, --debug-info</CODE></B><DD><P>This will cause the compiler to insert a <CODE>.DEBUGINFO</CODE> command into thegenerated assembler code. This will cause the assembler to include allsymbols 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, thename 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. Localvariables may be placed in registers (which are actually zero pagelocations). There is some overhead involved with register variables, sincethe old contents of the registers must be saved and restored. Since registervariables are of limited use without the optimizer, there is also a combinedswitch: <CODE>-Or</CODE> will enable both, the optmizer and register variables.</P><P>For more information about register variables see <A HREF="cc65-8.html#regvars">register variables</A>.</P><DT><B><CODE>--register-space</CODE></B><DD><P>This option takes a numeric parameter and is used to specify, how muchzero page register space is available. Please note that just giving thisoption will not increase or decrease by itself, it will just tell thecompiler about the available space. You will have to allocate that spaceyourself using an assembler module with the necessary allocations, and alinker configuration that matches the assembler module. The default valuefor 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 the6502 has no provisions for sign extending characters (which is needed onalmost any load operation), this will make the code larger and slower. Abetter way is to declare characters explicitly as "signed" if needed. Youcan also use <CODE><A HREF="cc65-7.html#pragma-signedchars">#pragma signedchars</A></CODE> for better control of this option.</P><DT><B><CODE>-t target, --target target</CODE></B><DD><P>This option is used to set the target system. The target systemdetermines things like the character set that is used for strings andcharacter constants. The following target systems are supported:</P><P><UL><LI>none</LI><LI>apple2</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>plus4</LI><LI>cbm510 (CBM-II series with 40 column video)</LI><LI>cbm610 (all CBM-II II computers with 80 column video)</LI><LI>pet (all CBM PET systems except the 2001)</LI><LI>geos</LI></UL></P><DT><B><CODE>-v, --verbose</CODE></B><DD><P>Using this option, the compiler will be somewhat more verbose if errorsor warnings are encountered.</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 usuallyfaster code, but the code is no longer reentrant. The difference between<CODE>-Cl</CODE> and declaring local variables as static yourself is, thatinitializer code is executed each time, the function is entered. So whenusing</P><P><BLOCKQUOTE><CODE><PRE> void f (void) { unsigned a = 1; ... } </PRE></CODE></BLOCKQUOTE></P><P>the variable a will always have the value 1 when entering the functionand 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 a will have the value 1 only the first time, the functionis entered, and will keep the old value from one call of the function tothe 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 mayuse this option multiple times to add more than one directory to thesearch list.</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 aruntime functions would have been called, even if the generated code islarger. This will not only remove the overhead for a function call, but willmake 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. Localvariables may be placed in registers (which are actually zero pagelocations). There is some overhead involved with register variables, sincethe old contents of the registers must be saved and restored. In addition,the current implementation does not make good use of register variables, sousing <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 fromthe 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 youdo 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 ormemory areas larger than 255 bytes. Similar, the inlined <CODE>is..()</CODE>functions will not work with values outside char range.</LI></UL></P><P>It is possible to concatenate the modifiers for <CODE>-O</CODE>. For example, toenable 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 isnormally 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 compilerversion.</P><DT><B><CODE>-W</CODE></B><DD><P>This option will suppress any warnings generated by the compiler. Sinceany source file may be written in a manner that it will not producecompiler 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>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?