<article>
<title>cc65 Users Guide
<author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
-<date>03.09.2000, 02.10.2001
+<date>2000-09-03, 2001-10-02, 2005-08-01
<abstract>
cc65 is a C compiler for 6502 targets. It supports several 6502 based home
up the changes made by me. I have made many more changes in the meantime
(and rewritten major parts of the compiler), so I will no longer do that,
since the list would be too large and of no use to anyone. Instead I will
-describe the compiler in respect to the ANSI/ISO C standard. In fact, I'm
-planning a complete rewrite (that is, a complete new compiler) for the
-next release, since there are too many limitations in the current code,
-and removing these limitations would mean a rewrite of many more parts of
-the compiler.
+describe the compiler in respect to the ANSI/ISO C standard.
-There is a separate document named "library.txt" that covers the library
-available for the compiler. If you know C and are interested in doing
-actual programming, the library documentation is probably of much more use
-than this document.
+There are separate documents named <url url="library.html"> and <url
+url="funcref.html"> that cover the library that is available for the compiler.
+If you know C, and are interested in doing actual programming, the library
+documentation is probably of much more use than this document.
If you need some hints for getting the best code out of the compiler, you
-may have a look at "coding.txt" which covers some code generation issues.
+may have a look at <url url="coding.html"> which covers some code generation
+issues.
<sect>Usage<p>
-The compiler translates C files into files containing assembler code that
+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 ca65.txt).
+the assembler, have a look at <url url="ca65.html">).
<sect1>Command line option overview<p>
-Os Inline some known functions
-T Include source as comment
-V Print the compiler version number
- -W Suppress warnings
+ -W name[,name] Enable or disable warnings
-d Debug mode
-g Add debug info to object file
-h Help (this text)
<descrip>
+ <label id="option-bss-name">
<tag><tt>--bss-name seg</tt></tag>
- Set the name of the bss segment.
+ Set the name of the bss segment. See also <tt/<ref id="pragma-bss-name"
+ name="#pragma bss-name">/.
+ <label id="option-check-stack">
<tag><tt>--check-stack</tt></tag>
Tells the compiler to generate code that checks for stack overflows. See
- <tt><ref id="pragma-checkstack" name="#pragma checkstack"></tt> for an
+ <tt/<ref id="pragma-check-stack" name="#pragma check-stack">/ for an
explanation of this feature.
+ <label id="option-code-name">
<tag><tt>--code-name seg</tt></tag>
- Set the name of the code segment.
+ Set the name of the code segment. See also <tt/<ref id="pragma-code-name"
+ name="#pragma code-name">/
<label id="option-codesize">
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 <tt/-Oi/ and 200 when
- using <tt/-Oi/ (<tt/-Oi/ is the same as <tt/--codesize 200/).
+ using <tt/-Oi/ (<tt/-Oi/ is the same as <tt/-O --codesize 200/).
+ <label id="option-cpu">
<tag><tt>--cpu CPU</tt></tag>
A new, still experimental option. You may specify "6502" or "65C02" as
overwhelming.
+ <label id="option-create-dep">
<tag><tt>--create-dep</tt></tag>
Tells the compiler to generate a file containing the dependency list for
file with the extension replaced by <tt/.u/.
+ <label id="option-data-name">
+ <tag><tt>--data-name seg</tt></tag>
+
+ Set the name of the data segment. See also <tt/<ref id="pragma-data-name"
+ name="#pragma data-name">/
+
+
<tag><tt>-d, --debug</tt></tag>
Enables debug mode, something that should not be needed for mere
name of the C input file is used, with the extension replaced by ".s".
+ <label id="option-register-vars">
<tag><tt>-r, --register-vars</tt></tag>
<tt/-r/ will make the compiler honor the <tt/register/ keyword. Local
variables are of limited use without the optimizer, there is also a combined
switch: <tt/-Or/ will enable both, the optimizer and register variables.
- For more information about register variables see <ref id="regvars"
+ For more information about register variables see <ref id="register-vars"
name="register variables">.
The compiler setting can also be changed within the source file by using
- <tt><ref id="pragma-regvars" name="#pragma regvars"></tt>.
+ <tt/<ref id="pragma-register-vars" name="#pragma register-vars">/.
+ <label id="option-register-space">
<tag><tt>--register-space</tt></tag>
This option takes a numeric parameter and is used to specify, how much
If you don't know what all this means, please don't use this option.
+ <label id="option-rodata-name">
<tag><tt>--rodata-name seg</tt></tag>
Set the name of the rodata segment (the segment used for readonly data).
+ See also <tt/<ref id="pragma-rodata-name" name="#pragma rodata-name">/
-
+ <label id="option-signed-chars">
<tag><tt>-j, --signed-chars</tt></tag>
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 <tt><ref id="pragma-signedchars" name="#pragma
- signedchars"></tt> for better control of this option.
-
+ can also use <tt><ref id="pragma-signed-chars"
+ name="#pragma signed-chars"></tt> for better control of this option.
+
<label id="option--standard">
<tag><tt>--standard std</tt></tag>
<item>cc65
</itemize>
+ Please note that the compiler does not support the c99 standard and never
+ will. c99 mode is actually c89 mode with a few selected c99 extensions
+ (// comments for example).
+
+ <label id="option-standard">
<tag><tt>-t target, --target target</tt></tag>
This option is used to set the target system. The target system
<item>cbm610 (all CBM-II II computers with 80 column video)
<item>geos
<item>lunix
+ <item>lynx
<item>nes
<item>pet (all CBM PET systems except the 2001)
<item>plus4
<item>supervision
+ <item>vic20
</itemize>
<tag><tt>-v, --verbose</tt></tag>
or warnings are encountered.
+ <label id="option-writable-strings">
<tag><tt>--writable-strings</tt></tag>
Make string literals writable by placing them into the data segment instead
- of the rodata segment.
+ of the rodata segment. You can also use <tt><ref id="pragma-writable-strings"
+ name="#pragma writable-strings"></tt> to control this option on a
+ per function basis.
+ <label id="option-static-locals">
<tag><tt>-Cl, --static-locals</tt></tag>
Use static storage for local variables instead of storage on the stack.
}
</verb></tscreen>
- the variable a will always have the value 1 when entering the function
- and using <tt/-Cl/, while in
+ the variable <tt/a/ will always have the value <tt/1/ when entering the
+ function and using <tt/-Cl/, while in
<tscreen><verb>
void f (void)
}
</verb></tscreen>
- the variable a will have the value 1 only the first time, the function
- is entered, and will keep the old value from one call of the function to
- the next.
+ the variable <tt/a/ will have the value <tt/1/ only the first time that the
+ function is entered, and will keep the old value from one call of the
+ function to the next.
- You may also use <tt><ref id="pragma-staticlocals" name="#pragma
- staticlocals"></tt> to change this setting in your sources.
+ You may also use <tt><ref id="pragma-static-locals"
+ name="#pragma static-locals"></tt> to change this setting in your
+ sources.
+ <label id="option-include-dir">
<tag><tt>-I dir, --include-dir dir</tt></tag>
Set a directory where the compiler searches for include files. You may
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. <tt/-Oi/ is an alias for
- <tt/--codesize 200/.
+ <tt/-O --codesize 200/.
<tt/-Or/ will make the compiler honor the <tt/register/ 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 <tt/-Or/ may make your program even slower and larger. Use with care!
+ locations). See also the <tt/<ref id="option-register-vars"
+ name="--register-vars">/ command line option, and the <ref
+ id="register-vars" name="discussion of register variables"> below.
Using <tt/-Os/ will force the compiler to inline some known functions from
the C library like strlen. Note: This has two consequences:
<tt/-Os/ will actually break things.
<p>
<item>The inlined string and memory functions will not handle strings or
- memory areas larger than 255 bytes. Similar, the inlined <tt/is..()/
- functions will not work with values outside char range.
+ memory areas larger than 255 bytes. Similarly, the inlined <tt/is..()/
+ functions will not work with values outside the char. range (such as
+ <tt/EOF/).
<p>
</itemize>
<p>
<label id="option-W">
- <tag><tt>-W</tt></tag>
-
- 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.
+ <tag><tt>-W name[,name]</tt></tag>
+
+ This option allows to control warnings generated by the compiler. It is
+ followed by a comma separated list of warnings that should be enabled or
+ disabled. To disable a warning, its name is prefixed by a minus sign. If
+ no such prefix exists, or the name is prefixed by a plus sign, the warning
+ is enabled.
+
+ The following warning names are currently recognized:
+ <descrip>
+ <tag><tt/error/</tag>
+ Treat all warnings as errors.
+ <tag><tt/unknown-pragma/</tag>
+ Warn about known #pragmas.
+ <tag><tt/unused-label/</tag>
+ Warn about unused labels.
+ <tag><tt/unused-param/</tag>
+ Warn about unused function parameters.
+ <tag><tt/unused-var/</tag>
+ Warn about unused variables.
+ </descrip>
+
+ You may also use <tt><ref id="pragma-warn" name="#pragma warn"></tt> to
+ control this setting for smaller pieces of code from within your code.
</descrip><p>
file contains assembler code suitable for the use with the ca65 macro
assembler.
-In addition to the paths named in the <tt/-I/ option on the command line, the
-directory named in the environment variable <tt/CC65_INC/ is added to the
-search path for include files on startup.
+Include files in single quotes are searched in the following places:
+<enum>
+<item>The current directory.
+<item>The value of the environment variable <tt/CC65_INC/ if it is defined.
+<item>Any directory added with the <tt/-I/ option on the command line.
+</enum>
+
+Include files in angle brackets are searched in the following places:
+<enum>
+<item>A compiled in directory which is often <tt>/usr/lib/cc65/include</tt> on
+ Linux systems.
+<item>The value of the environment variable <tt/CC65_INC/ if it is defined.
+<item>A subdirectory named <tt/include/ of the directory defined in the
+ environment variable <tt/CC65_HOME/, if it is defined.
+<item>Any directory added with the <tt/-I/ option on the command line.
+</enum>
<sect>Differences to the ISO standard<p>
+Apart from the things listed below, the compiler does support additional
+keywords, has several functions in the standard headers with names outside the
+reserved namespace and a few syntax extensions. All these can be disabled with
+the <tt><ref id="option--standard" name="--standard"></tt> command line
+option. Its use for maximum standards compatibility is advised.
+
Here is a list of differences between the language, the compiler accepts,
and the one defined by the ISO standard:
<itemize>
-<item> The compiler allows unnamed parameters in parameter lists. The
- compiler will not issue warnings about unused parameters that don't
- have a name. This feature can be disabled with the <tt><ref
- id="option--standard" name="--standard"></tt> command line option.
- <p>
-<item> The compiler has some additional keywords:
- <p>
- <itemize>
- <item><tt/asm/
- <item><tt/__asm__/
- <item><tt/fastcall/
- <item><tt/__fastcall__/
- <item><tt/__AX__/
- <item><tt/__EAX__/
- <item><tt/__func__/
- <item><tt/__attribute__/
- </itemize>
- <p>
- The keywords without the underlines can be disabled with the
- <tt><ref id="option--standard" name="--standard"></tt> command line
- option.
- <p>
<item> The datatypes "float" and "double" are not available.
<p>
-<item> The compiler does not support bit fields.
- <p>
<item> C Functions may not return structs (or unions), and structs may not
be passed as parameters by value. However, struct assignment *is*
possible.
<p>
<item> Part of the C library is available only with fastcall calling
- conventions (see below). This means, that you may not mix pointers to
- those functions with pointers to user written functions.
+ conventions (see below). It means that you must not mix pointers to
+ those functions with pointers to user-written, not-fastcall functions.
+ <p>
+<item> The <tt/volatile/ keyword doesn't have an effect. This is not as bad
+ as it sounds, since the 6502 has so few registers that it isn't
+ possible to keep values in registers anyway.
<p>
</itemize>
-There may be some more minor differences, I'm currently not aware off. The
+There may be some more minor differences I'm currently not aware of. The
biggest problem is the missing float data type. With this limitation in
mind, you should be able to write fairly portable code.
<ref id="inline-asm" name="see there">.
<p>
-<item> There is a special calling convention named "fastcall". This calling
- convention is currently only usable for functions written in
- assembler. The syntax for a function declaration using fastcall is
+<item> There is a special calling convention named "fastcall".
+ The syntax for a function declaration using fastcall is
<tscreen><verb>
<return type> fastcall <function name> (<parameter list>)
However, taking the address of the variable results in a <tt/void*/
which may be passed to any function expecting a pointer.
- See the <htmlurl url="geos.html" name="GEOS library"> for examples on
- how to use this feature.
+ See the <url url="geos.html" name="GEOS library document"> for examples
+ on how to use this feature.
<p>
<item> cc65 implements flexible array struct members as defined in the C99 ISO
standard. As an extension, these fields may be initialized. There are
several exceptions, however (which is probably the reason why the
standard does not define this feature, because it is highly
- unorthogonal). Flexible array members cannot be initialized...
+ unorthogonal). Flexible array members cannot be initialized ...
<itemize>
- <item> ...when defining an array of structs with flexible members.
- <item> ...if such a struct is a member field of another struct which
- is not the last field.
- <item> If the struct which contains a flexible array member is
- declared as <tt/register/ and the size and compiler settings
- do allow the compiler to actually place the struct into the
+ <item>... when defining an array of structs with flexible
+ members.
+ <item>... if such a struct is a member field of another struct
+ which is not the last field.
+ <item>... if the struct which contains a flexible array member is
+ declared as <tt/register/, and the size and compiler settings
+ do allow the compiler actually to place the struct into the
register bank in the zero page.
</itemize>
- Please note that - as defined in the ISO C standard - the <tt/sizeof/
+ Please note that -- as defined in the ISO C standard -- the <tt/sizeof/
operator returns the struct size with the flexible array member having
size zero, even if it is initialized.
<p>
<tag><tt>__CC65__</tt></tag>
This macro is always defined. Its value is the version number of the
- compiler in hex. Version 2.0.1 of the compiler will have this macro defined
- as 0x0201.
+ compiler in hex. For example, version 2.10.1 of the compiler has this macro
+ defined as <tt/0x02A1/.
<tag><tt>__APPLE2__</tt></tag>
This macro is defined if the target is the Apple ][ (-t apple2).
+ <tag><tt>__APPLE2ENH__</tt></tag>
+
+ This macro is defined if the target is the enhanced Apple //e (-t apple2enh).
+
<tag><tt>__ATARI__</tt></tag>
This macro is defined if the target is one of the Atari computers
This macro is defined if you are compiling for the GEOS system (-t geos).
+ <tag><tt>__LUNIX__</tt></tag>
+
+ This macro is defined if you are compiling for the LUnix system (-t lunix).
+
+ <tag><tt>__LYNX__</tt></tag>
+
+ This macro is defined if the target is the Atari Lynx (-t lynx).
+
+ <tag><tt>__NES__</tt></tag>
+
+ This macro is defined if the target is the NES (-t nes).
+
<tag><tt>__PET__</tt></tag>
This macro is defined if the target is the PET family of computers (-t pet).
This macro is defined if the target is the plus/4 (-t plus4).
+ <tag><tt>__SUPERVISION__</tt></tag>
+
+ This macro is defined if the target is the supervision (-t supervision).
+
<tag><tt>__VIC20__</tt></tag>
This macro is defined if the target is the vic20 (-t vic20).
</descrip>
-<sect>#pragmas<label id="pragmas"><p>
+<sect>#pragmas<label id="pragmas"><p>
The compiler understands some pragmas that may be used to change code
generation and other stuff. Some of these pragmas understand a special form:
before changing it. The value may later be restored by using the <tt/pop/
parameter with the <tt/#pragma/.
-<sect1><tt>#pragma bssseg (<name>)</tt><p>
+<sect1><tt>#pragma bss-name ([push,] <name>)</tt><label id="pragma-bss-name"><p>
This pragma changes the name used for the BSS segment (the BSS segment
is used to store uninitialized data). The argument is a string enclosed
Example:
<tscreen><verb>
- #pragma bssseg ("MyBSS")
+ #pragma bss-name ("MyBSS")
</verb></tscreen>
-<sect1><tt>#pragma charmap (<index>, <code>)</tt><p>
+<sect1><tt>#pragma charmap (<index>, <code>)</tt><label id="pragma-charmap"><p>
Each literal string and each literal character in the source is translated
by use of a translation table. This translation table is preset when the
<itemize>
<item>The character index is actually the code of the character in the
C source, so character mappings do always depend on the source
- character set. This means that <tt/#pragma charmap/ is not portable
- - it depends on the build environment.
+ character set. This means that <tt/#pragma charmap/ is not
+ portable -- it depends on the build environment.
<item>While it is possible to use character literals as indices, the
result may be somewhat unexpected, since character literals are
itself translated. For this reason I would suggest to avoid
</verb></tscreen>
-<sect1><tt>#pragma checkstack ([push,]on|off)</tt><label id="pragma-checkstack"><p>
+<sect1><tt>#pragma check-stack ([push,] on|off)</tt><label id="pragma-check-stack"><p>
Tells the compiler to insert calls to a stack checking subroutine to detect
stack overflows. The stack checking code will lead to somewhat larger and
The <tt/#pragma/ understands the push and pop parameters as explained above.
-<sect1><tt>#pragma codeseg ([push,]<name>)</tt><p>
+<sect1><tt>#pragma code-name ([push,] <name>)</tt><label id="pragma-code-name"><p>
This pragma changes the name used for the CODE segment (the CODE segment
is used to store executable code). The argument is a string enclosed in
Example:
<tscreen><verb>
- #pragma codeseg ("MyCODE")
+ #pragma code-name ("MyCODE")
</verb></tscreen>
-<sect1><tt>#pragma codesize ([push,]<int>)</tt><label id="pragma-codesize"><p>
+<sect1><tt>#pragma codesize ([push,] <int>)</tt><label id="pragma-codesize"><p>
This pragma allows finer control about speed vs. size decisions in the code
generation and optimization phase. It gives the allowed size increase factor
The <tt/#pragma/ understands the push and pop parameters as explained above.
-<sect1><tt>#pragma dataseg ([push,]<name>)</tt><p>
+<sect1><tt>#pragma data-name ([push,] <name>)</tt><label id="pragma-data-name"><p>
This pragma changes the name used for the DATA segment (the DATA segment
is used to store initialized data). The argument is a string enclosed in
Example:
<tscreen><verb>
- #pragma dataseg ("MyDATA")
+ #pragma data-name ("MyDATA")
</verb></tscreen>
-<sect1><tt>#pragma optimize ([push,]on|off)</tt><label id="pragma-optimize"><p>
+<sect1><tt>#pragma optimize ([push,] on|off)</tt><label id="pragma-optimize"><p>
Switch optimization on or off. If the argument is "off", optimization is
disabled, otherwise it is enabled. Please note that this pragma only effects
The <tt/#pragma/ understands the push and pop parameters as explained above.
-<sect1><tt>#pragma rodataseg ([push,]<name>)</tt><p>
+<sect1><tt>#pragma rodata-name ([push,] <name>)</tt><label id="pragma-rodata-name"><p>
This pragma changes the name used for the RODATA segment (the RODATA
segment is used to store readonly data). The argument is a string
Example:
<tscreen><verb>
- #pragma rodataseg ("MyRODATA")
+ #pragma rodata-name ("MyRODATA")
</verb></tscreen>
-<sect1><tt>#pragma regvaraddr ([push,]on|off)</tt><p>
+<sect1><tt>#pragma regvaraddr ([push,] on|off)</tt><label id="pragma-regvaraddr"><p>
The compiler does not allow to take the address of register variables.
The regvaraddr pragma changes this. Taking the address of a register
declared as register. So your programs become non-portable if you use
this pragma. In addition, your program may not work. This is usually the
case if a subroutine is called with the address of a register variable,
- and this subroutine (or a subroutine called from there) uses itself
+ and this subroutine (or a subroutine called from there) uses
register variables. So be careful with this #pragma.
The <tt/#pragma/ understands the push and pop parameters as explained above.
</verb></tscreen>
-<sect1><tt>#pragma regvars ([push,]on|off)</tt><label id="pragma-regvars"><p>
+<sect1><tt>#pragma register-vars ([push,] on|off)</tt><label id="pragma-register-vars"><p>
Enables or disables use of register variables. If register variables are
disabled (the default), the <tt/register/ keyword is ignored. Register
- variables are explained in more detail in <ref id="regvars" name="a separate
+ variables are explained in more detail in <ref id="register-vars" name="a separate
chapter">.
The <tt/#pragma/ understands the push and pop parameters as explained above.
-<sect1><tt>#pragma signedchars ([push,]on|off)</tt><label id="pragma-signedchars"><p>
+<sect1><tt>#pragma signed-chars ([push,] on|off)</tt><label id="pragma-signed-chars"><p>
Changes the signedness of the default character type. If the argument is
- "on", default characters are signed, otherwise characters are unsigned.
- The compiler default is to make characters unsigned since this creates a
- lot better code. This default may be overridden by the <tt/--signed-chars/
- command line option.
+ "on", default characters are signed, otherwise characters are unsigned. The
+ compiler default is to make characters unsigned since this creates a lot
+ better code. This default may be overridden by the <tt/<ref
+ name="--signed-chars" id="option-signed-chars">/ command line option.
The <tt/#pragma/ understands the push and pop parameters as explained above.
-<sect1><tt>#pragma staticlocals ([push,]on|off)</tt><label id="pragma-staticlocals"<p>
+<sect1><tt>#pragma static-locals ([push,] on|off)</tt><label id="pragma-static-locals"<p>
Use variables in the bss segment instead of variables on the stack. This
- pragma changes the default set by the compiler option <tt/-Cl/. If the
- argument is "on", local variables are allocated in the BSS segment,
- leading to shorter and in most cases faster, but non-reentrant code.
+ pragma changes the default set by the compiler option <tt/<ref
+ name="--static-locals" id="option-static-locals">/. If the argument is "on",
+ local variables are allocated in the BSS segment, leading to shorter and in
+ most cases faster, but non-reentrant code.
The <tt/#pragma/ understands the push and pop parameters as explained above.
-<sect1><tt>#pragma warn ([push,]on|off)</tt><label id="pragma-warn"><p>
+<sect1><tt>#pragma warn (name, [push,] on|off)</tt><label id="pragma-warn"><p>
+
+ Switch compiler warnings on or off. "name" is the name of a warning (see the
+ <tt/<ref name="-W" id="option-W">/ compiler option for a list). The name is
+ either followed by "pop", which restores the last pushed state, or by "on" or
+ "off", optionally preceeded by "push" to push the current state before
+ changing it.
- Switch compiler warnings on or off. If the argument is "off", warnings are
- disabled, otherwise they're enabled. The default is "on", but may be changed
- with the <tt/<ref name="-W" id="option-W">/ compiler option.
+ Example:
+ <tscreen><verb>
+ /* Don't warn about the unused parameter in function func */
+ #pragma warn (unused-param, push, off)
+ static int func (int unused)
+ {
+ return 0;
+ }
+ #pragma warn (unused-param, pop)
+ </verb></tscreen>
+
+<sect1><tt>#pragma writable-strings ([push,] on|off)</tt><label id="pragma-writable-strings"><p>
+
+ Changes the storage location of string literals. For historical reasons,
+ the C standard defines that string literals are of type "char[]", but
+ writing to such a literal causes undefined behaviour. Most compilers
+ (including cc65) place string literals in the read-only data segment, which
+ may cause problems with old C code that writes to string literals.
+
+ Using this pragma (or the corresponding command line option <tt/<ref
+ name="--writable-strings" id="option-writable-strings">/) causes the
+ literals to be placed in the data segment so they can be written to without
+ worry.
+
+ Please note that the value of this flag that is in effect when a function
+ is encountered, determines where the literals are stored. Changing the
+ <tt/#pragma/ within a function doesn't have an effect for this function.
The <tt/#pragma/ understands the push and pop parameters as explained above.
<sect1><tt>#pragma zpsym (<name>)</tt><p>
- Tell the compiler that the - previously as external declared - symbol with
+ Tell the compiler that the -- previously as external declared -- symbol with
the given name is a zero page symbol (usually from an assembler file).
The compiler will create a matching import declaration for the assembler.
-<sect>Register variables<label id="regvars"><p>
+<sect>Register variables<label id="register-vars"><p>
The runtime for all supported platforms has 6 bytes of zero page space
available for register variables (this could be increased, but I think it's a
trouble. The only savings you get here are by the use of a zero page variable
instead of one on the stack or in the data segment.
-Register variables must be explicitly enabled by using <tt/-Or/ or <tt/-r/ on
-the command line. Register variables are only accepted on function top level,
-register variables declared in interior blocks are silently converted to
-<tt/auto/. With register variables disabled, all variables declared as
-<tt/register/ are actually auto variables.
+Register variables must be explicitly enabled, either by using <tt/<ref
+name="-Or" id="option-O">/ or <tt/<ref name="--register-vars"
+id="option-register-vars">/ on the command line or by use of <tt/<ref
+name="#pragma register-vars" id="pragma-register-vars">/. Register variables
+are only accepted on function top level, register variables declared in
+interior blocks are silently converted to <tt/auto/. With register variables
+disabled, all variables declared as <tt/register/ are actually auto variables.
Please take care when using register variables: While they are helpful and can
lead to a tremendous speedup when used correctly, improper usage will cause
the format specifier before passing the assembly code line to the backend.
<itemize>
- <item><tt/%b/ - Numerical 8 bit value
- <item><tt/%w/ - Numerical 16 bit value
- <item><tt/%l/ - Numerical 32 bit value
+ <item><tt/%b/ - Numerical 8-bit value
+ <item><tt/%w/ - Numerical 16-bit value
+ <item><tt/%l/ - Numerical 32-bit value
<item><tt/%v/ - Assembler name of a (global) variable or function
<item><tt/%o/ - Stack offset of a (local) variable
<item><tt/%g/ - Assembler name of a C label
<p>
+<sect>Implementation-defined behavior<p>
+
+This section describes the behavior of cc65 when the standard describes the
+behavior as implementation-defined.
+
+(to be done)
+
<sect>Bugs/Feedback<p>
If you have problems using the compiler, if you find any bugs, or if you're
doing something interesting with it, I would be glad to hear from you. Feel
-free to contact me by email (<htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">).
+free to contact me by email (<htmlurl url="mailto:uz@cc65.org"
+name="uz@cc65.org">).