mirror of
https://github.com/cc65/cc65.git
synced 2025-08-08 22:25:28 +00:00
Converted cc65.txt to SGML (incomplete). Several corrections in the other
docs. git-svn-id: svn://svn.cc65.org/cc65/trunk@319 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
SGML = ar65.sgml \
|
SGML = ar65.sgml \
|
||||||
ca65.sgml \
|
ca65.sgml \
|
||||||
|
cc65.sgml \
|
||||||
cl65.sgml
|
cl65.sgml
|
||||||
|
|
||||||
TXT = $(SGML:.sgml=.txt)
|
TXT = $(SGML:.sgml=.txt)
|
||||||
|
@@ -3,11 +3,13 @@
|
|||||||
<article>
|
<article>
|
||||||
|
|
||||||
<title>ar65 Users Guide
|
<title>ar65 Users Guide
|
||||||
<author>Ullrich von Bassewitz, <tt/uz@musoftware.de/
|
<author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
|
||||||
<date>
|
<date>19.07.2000
|
||||||
<abstract>ar65 is an archiver for object files generated by ca65. It allows
|
|
||||||
to create archives, add or remove modules from archives, and to extract modules
|
<abstract>
|
||||||
from existing archives.
|
ar65 is an archiver for object files generated by ca65. It allows to create
|
||||||
|
archives, add or remove modules from archives, and to extract modules from
|
||||||
|
existing archives.
|
||||||
</abstract>
|
</abstract>
|
||||||
|
|
||||||
<!-- Table of contents -->
|
<!-- Table of contents -->
|
||||||
@@ -36,7 +38,7 @@ The archiver is called as follows:
|
|||||||
d Delete modules
|
d Delete modules
|
||||||
l List library contents
|
l List library contents
|
||||||
x Extract modules
|
x Extract modules
|
||||||
X Print the archiver version
|
V Print the archiver version
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
You may add modules to a library using the `a' command. If the library
|
You may add modules to a library using the `a' command. If the library
|
||||||
@@ -125,9 +127,9 @@ free to contact me by email (<htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org
|
|||||||
|
|
||||||
<sect>Copyright<p>
|
<sect>Copyright<p>
|
||||||
|
|
||||||
ar65 (and all cc65 binutils) are (C) Copyright 1998 Ullrich von Bassewitz.
|
ar65 (and all cc65 binutils) are (C) Copyright 1998-2000 Ullrich von
|
||||||
For usage of the binaries and/or sources the following conditions do
|
Bassewitz. For usage of the binaries and/or sources the following conditions
|
||||||
apply:
|
do apply:
|
||||||
|
|
||||||
This software is provided 'as-is', without any expressed or implied
|
This software is provided 'as-is', without any expressed or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
@@ -2,9 +2,13 @@
|
|||||||
|
|
||||||
<article>
|
<article>
|
||||||
<title>ca65 Users Guide
|
<title>ca65 Users Guide
|
||||||
<author>Ullrich von Bassewitz, <tt/uz@musoftware.de/
|
<author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
|
||||||
<date>19.07.2000
|
<date>19.07.2000
|
||||||
<abstract>ca65 is a macro assembler for the 6502, 65C02 and 65816 CPUs.
|
|
||||||
|
<abstract>
|
||||||
|
ca65 is a macro assembler for the 6502, 65C02 and 65816 CPUs. It is used as a
|
||||||
|
companion assembler for the cc65 crosscompiler, but it may also be used as a
|
||||||
|
standalone product.
|
||||||
</abstract>
|
</abstract>
|
||||||
|
|
||||||
<!-- Table of contents -->
|
<!-- Table of contents -->
|
||||||
@@ -15,16 +19,16 @@
|
|||||||
<sect>Overview<p>
|
<sect>Overview<p>
|
||||||
|
|
||||||
ca65 is a replacement for the ra65 assembler that was part of the cc65 C
|
ca65 is a replacement for the ra65 assembler that was part of the cc65 C
|
||||||
compiler developed by John R. Dunning. I had some problems with ra65 and
|
compiler, originally developed by John R. Dunning. I had some problems with
|
||||||
the copyright does not permit some things which I wanted to be possible,
|
ra65 and the copyright does not permit some things which I wanted to be
|
||||||
so I decided to write a completely new assembler/linker/archiver suite for
|
possible, so I decided to write a completely new assembler/linker/archiver
|
||||||
the cc65 compiler. ca65 is part of this suite.
|
suite for the cc65 compiler. ca65 is part of this suite.
|
||||||
|
|
||||||
Some parts of the assembler (code generation and some routines for symbol
|
Some parts of the assembler (code generation and some routines for symbol
|
||||||
table handling) are taken from an older crossassembler named a816 written
|
table handling) are taken from an older crossassembler named a816 written
|
||||||
by me a long time ago.
|
by me a long time ago.
|
||||||
|
|
||||||
Here's a list of the design criteria, that were important for the
|
Here's a list of the design criteria, that I considered important for the
|
||||||
development:
|
development:
|
||||||
|
|
||||||
<itemize>
|
<itemize>
|
||||||
@@ -44,14 +48,12 @@ development:
|
|||||||
three segments (this is the count, most other assemblers support).
|
three segments (this is the count, most other assemblers support).
|
||||||
Having more than one code segments helps developing code for systems
|
Having more than one code segments helps developing code for systems
|
||||||
with a divided ROM area (like the C64).
|
with a divided ROM area (like the C64).
|
||||||
<item> The linker must be able to resolve arbitrary expressions. Years ago I
|
<item> The linker must be able to resolve arbitrary expressions. It should
|
||||||
spent half a day to convince Borlands Turbo Assembler to let me use
|
be able to get things like
|
||||||
the size of a structure I had created. So I decided that this is a
|
|
||||||
must. The linker should be able to get things like
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
.import S1, S2
|
.import S1, S2
|
||||||
.export Special
|
.export Special
|
||||||
Special = 2*S1 + S2/7
|
Special = 2*S1 + S2/7
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
right.
|
right.
|
||||||
<item> True lexical nesting for symbols. This is very convenient for larger
|
<item> True lexical nesting for symbols. This is very convenient for larger
|
||||||
@@ -66,8 +68,9 @@ development:
|
|||||||
started to get boring. A one pass assembler needs much more elaborated
|
started to get boring. A one pass assembler needs much more elaborated
|
||||||
data structures, and because of that it's much more fun:-)
|
data structures, and because of that it's much more fun:-)
|
||||||
<item> Non-GPLed code that may be used in any project without restrictions or
|
<item> Non-GPLed code that may be used in any project without restrictions or
|
||||||
fear of "GPL infecting" other code.
|
fear of "GPL infecting" other code.
|
||||||
</itemize>
|
</itemize>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
|
||||||
<sect>Usage<p>
|
<sect>Usage<p>
|
||||||
@@ -83,7 +86,7 @@ Short options:
|
|||||||
-i Ignore case of symbols
|
-i Ignore case of symbols
|
||||||
-l Create a listing if assembly was ok
|
-l Create a listing if assembly was ok
|
||||||
-o name Name the output file
|
-o name Name the output file
|
||||||
-s Enable smart mode
|
-s Enable smart mode
|
||||||
-t sys Set the target system
|
-t sys Set the target system
|
||||||
-v Increase verbosity
|
-v Increase verbosity
|
||||||
-D name[=value] Define a symbol
|
-D name[=value] Define a symbol
|
||||||
@@ -120,7 +123,8 @@ Here is a description of all the command line options:
|
|||||||
|
|
||||||
6502, 65C02, 65816 and sunplus
|
6502, 65C02, 65816 and sunplus
|
||||||
|
|
||||||
(the latter is not available in the freeware version).
|
The latter (sunplus) is not available in the freeware version, because the
|
||||||
|
instruction set of the sunplus CPU is "confidential".
|
||||||
|
|
||||||
|
|
||||||
<tag><tt>--feature name</tt></tag>
|
<tag><tt>--feature name</tt></tag>
|
||||||
@@ -130,7 +134,7 @@ Here is a description of all the command line options:
|
|||||||
each feature must be specified by using an extra <tt/--feature/ option,
|
each feature must be specified by using an extra <tt/--feature/ option,
|
||||||
comma separated lists are not allowed.
|
comma separated lists are not allowed.
|
||||||
|
|
||||||
See the discussion of the <tt/.FEATURE/ command for a list of emulation
|
See the discussion of the <tt/.FEATURE/ command for a list of emulation
|
||||||
features.
|
features.
|
||||||
|
|
||||||
|
|
||||||
@@ -196,7 +200,7 @@ Here is a description of all the command line options:
|
|||||||
Set the target system. This will enable translation of character strings
|
Set the target system. This will enable translation of character strings
|
||||||
and character constants into the character set of the target platform.
|
and character constants into the character set of the target platform.
|
||||||
The default for the target system is "none", which means that no translation
|
The default for the target system is "none", which means that no translation
|
||||||
will take place. The assembler supports the same target systems as the
|
will take place. The assembler supports the same target systems as the
|
||||||
compiler, see there for a list.
|
compiler, see there for a list.
|
||||||
|
|
||||||
|
|
||||||
@@ -249,7 +253,7 @@ Here is a description of all the command line options:
|
|||||||
something lower.
|
something lower.
|
||||||
|
|
||||||
</descrip>
|
</descrip>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
|
||||||
<sect>Input format<p>
|
<sect>Input format<p>
|
||||||
@@ -304,14 +308,14 @@ the assembler to determine and would have required one more special
|
|||||||
separated by a dot:
|
separated by a dot:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
jsl 3.$1234 ; Call subroutine at $1234 in bank 3
|
jsl 3.$1234 ; Call subroutine at $1234 in bank 3
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
For literal values, the assembler accepts the widely used number formats:
|
For literal values, the assembler accepts the widely used number formats:
|
||||||
A preceeding '$' denotes a hex value, a preceeding '%' denotes a
|
A preceeding '$' denotes a hex value, a preceeding '%' denotes a
|
||||||
binary value, and a bare number is interpeted as a decimal. There are
|
binary value, and a bare number is interpeted as a decimal. There are
|
||||||
currently no octal values and no floats.
|
currently no octal values and no floats.
|
||||||
|
<p>
|
||||||
|
|
||||||
|
|
||||||
<sect>Expressions
|
<sect>Expressions
|
||||||
@@ -382,7 +386,7 @@ Available operators sorted by precedence:
|
|||||||
.TCOUNT Builtin function 1
|
.TCOUNT Builtin function 1
|
||||||
.XMATCH Builtin function 1
|
.XMATCH Builtin function 1
|
||||||
.PARAMCOUNT Builtin pseudo variable (r/o) 1
|
.PARAMCOUNT Builtin pseudo variable (r/o) 1
|
||||||
.REFERENCED Builtin function 1
|
.REFERENCED Builtin function 1
|
||||||
:: Global namespace override 1
|
:: Global namespace override 1
|
||||||
+ Unary plus 1
|
+ Unary plus 1
|
||||||
- Unary minus 1
|
- Unary minus 1
|
||||||
@@ -431,11 +435,14 @@ To force a specific order of evaluation, braces may be used as usual.
|
|||||||
|
|
||||||
Some of the pseudo variables mentioned above need some more explanation:
|
Some of the pseudo variables mentioned above need some more explanation:
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
* This symbol is replaced by the value of the program
|
* This symbol is replaced by the value of the program
|
||||||
counter at start of the current instruction. Note, that
|
counter at start of the current instruction. Note, that
|
||||||
'*' yields a rvalue, that means, you cannot assign to it.
|
'*' yields a rvalue, that means, you cannot assign to it.
|
||||||
Use <tt/.ORG/ to set the program counter in sections with
|
Use <tt/.ORG/ to set the program counter in sections with
|
||||||
absolute code.
|
absolute code.
|
||||||
|
</verb></tscreen>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
682
doc/cc65.sgml
Normal file
682
doc/cc65.sgml
Normal file
@@ -0,0 +1,682 @@
|
|||||||
|
<!doctype linuxdoc system>
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<title>cc65 Users Guide
|
||||||
|
<author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
|
||||||
|
<date>03.09.2000
|
||||||
|
|
||||||
|
<abstract>
|
||||||
|
cc65 is a C compiler for 6502 targets. It supports several old 6502 based home
|
||||||
|
computers like the Commodore and Atari machines, but it is easily retargetable.
|
||||||
|
</abstract>
|
||||||
|
|
||||||
|
<!-- Table of contents -->
|
||||||
|
<toc>
|
||||||
|
|
||||||
|
<!-- Begin the document -->
|
||||||
|
|
||||||
|
|
||||||
|
<sect>Overview<p>
|
||||||
|
|
||||||
|
cc65 was originally a C compiler for the Atari 8-bit machines written by
|
||||||
|
John R. Dunning. In prior releases I've described the compiler by listing
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<sect>Usage<p>
|
||||||
|
|
||||||
|
The compiler translates C files into files containing assembler code that
|
||||||
|
may be translated by the ca65 macroassembler (for more information about
|
||||||
|
the assembler, have a look at ca65.txt).
|
||||||
|
|
||||||
|
The compiler may be called as follows:
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Usage: cc65 [options] file
|
||||||
|
Short options:
|
||||||
|
-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
|
||||||
|
-t sys Set the target system
|
||||||
|
-v Increase verbosity
|
||||||
|
-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
|
||||||
|
|
||||||
|
Long options:
|
||||||
|
--ansi Strict ANSI mode
|
||||||
|
--cpu type Set cpu type
|
||||||
|
--debug Debug mode
|
||||||
|
--debug-info Add debug info to object file
|
||||||
|
--help Help (this text)
|
||||||
|
--include-dir dir Set an include directory search path
|
||||||
|
--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
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
|
Here is a description of all the command line options:
|
||||||
|
|
||||||
|
<descrip>
|
||||||
|
|
||||||
|
<tag><tt>-A, --ansi</tt></tag>
|
||||||
|
|
||||||
|
This option disables any compiler exensions. Have a look at section 5
|
||||||
|
for a discussion of compiler extensions. In addition, the macro
|
||||||
|
<verb>
|
||||||
|
__STRICT_ANSI__
|
||||||
|
</verb>
|
||||||
|
is defined, when using one of these options.
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>--cpu CPU</tt></tag>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-d, --debug</tt></tag>
|
||||||
|
|
||||||
|
Enables debug mode, something that should not be needed for mere
|
||||||
|
mortals:-)
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-D sym[=definition]</tt></tag>
|
||||||
|
|
||||||
|
Define a macro on the command line. If no definition is given, the macro
|
||||||
|
is defined to the value "1".
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-g, --debug-info</tt></tag>
|
||||||
|
|
||||||
|
This will cause the compiler to insert a .DEBUGINFO command into the
|
||||||
|
generated assembler code. This will cause the assembler to include all
|
||||||
|
symbols in a special section in the object file.
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-h, --help</tt></tag>
|
||||||
|
|
||||||
|
Print the short option summary shown above.
|
||||||
|
|
||||||
|
|
||||||
|
<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 "#pragma signedchars" for better control of this option
|
||||||
|
(see section 7).
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-t target, --target target</tt></tag>
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
none
|
||||||
|
c64
|
||||||
|
c128
|
||||||
|
ace (no library support)
|
||||||
|
plus4
|
||||||
|
cbm610
|
||||||
|
pet (all CBM PET systems except the 2001)
|
||||||
|
nes (Nintendo Entertainment System)
|
||||||
|
apple2
|
||||||
|
geos
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-v, --verbose</tt></tag>
|
||||||
|
|
||||||
|
Using this option, the compiler will be somewhat more verbose if errors
|
||||||
|
or warnings are encountered.
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-Cl, --static-locals</tt></tag>
|
||||||
|
|
||||||
|
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
|
||||||
|
-Cl and declaring local variables as static yourself is, that
|
||||||
|
initializer code is executed each time, the function is entered. So when
|
||||||
|
using
|
||||||
|
|
||||||
|
void f (void)
|
||||||
|
{
|
||||||
|
unsigned a = 1;
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
the variable a will always have the value 1 when entering the function
|
||||||
|
and using -Cl, while in
|
||||||
|
|
||||||
|
void f (void)
|
||||||
|
{
|
||||||
|
static unsigned a = 1;
|
||||||
|
....
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
You may also use #pragma staticlocals to change this setting in your
|
||||||
|
sources (see section 7).
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-I dir, --include-dir dir</tt></tag>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-o name</tt></tag>
|
||||||
|
|
||||||
|
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".
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-O, -Oi, -Or, -Os</tt></tag>
|
||||||
|
|
||||||
|
Enable an optimizer run over the produced code.
|
||||||
|
|
||||||
|
Using -Oi, 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.
|
||||||
|
|
||||||
|
-Or will make the compiler honor the "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 -Or may make your program even slower and larger. Use with care!
|
||||||
|
|
||||||
|
Using -Os will force the compiler to inline some known functions from
|
||||||
|
the C library like strlen. Note: This has two consequences:
|
||||||
|
|
||||||
|
* 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 -Os will actually break things.
|
||||||
|
|
||||||
|
* The inlined string and memory functions will not handle strings or
|
||||||
|
memory areas larger than 255 bytes. Similar, the inlined is..()
|
||||||
|
functions will not work with values outside char range.
|
||||||
|
|
||||||
|
It is possible to concatenate the modifiers for -O. For example, to
|
||||||
|
enable register variables and inlining of known functions, you may use
|
||||||
|
-Ors.
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-T</tt></tag>
|
||||||
|
|
||||||
|
This include the source code as comments in the generated code. This is
|
||||||
|
normally not needed.
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>-V, --version</tt></tag>
|
||||||
|
|
||||||
|
Print the version number of the compiler. When submitting a bug report,
|
||||||
|
please include the operating system you're using, and the compiler
|
||||||
|
version.
|
||||||
|
|
||||||
|
|
||||||
|
<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.
|
||||||
|
|
||||||
|
</descrip><p>
|
||||||
|
|
||||||
|
|
||||||
|
<sect>Input and output<p>
|
||||||
|
|
||||||
|
The compiler will accept one C file per invocation and create a file with
|
||||||
|
the same base name, but with the extension replaced by ".s". The output
|
||||||
|
file contains assembler code suitable for the use with the ca65 macro
|
||||||
|
assembler.
|
||||||
|
|
||||||
|
In addition to the paths named in the -I option on the command line, the
|
||||||
|
directory named in the environment variable CC65_INC is added to the
|
||||||
|
search path for include files on startup.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<sect>Differences to the ISO standard<p>
|
||||||
|
|
||||||
|
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 single line comments that start with //. This
|
||||||
|
feature is disabled in strict ANSI mode.
|
||||||
|
|
||||||
|
<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 is disabled in strict ANSI mode.
|
||||||
|
|
||||||
|
<item> The compiler has some additional keywords:<p>
|
||||||
|
|
||||||
|
<tt/asm/, <tt/__asm__/, <tt/fastcall/, <tt/__fastcall__/, <tt/__AX__/,
|
||||||
|
<tt/__EAX__/, <tt/__func__/, <tt/__attribute__/
|
||||||
|
<p>
|
||||||
|
|
||||||
|
The keywords without the underlines are disabled in strict ANSI mode.
|
||||||
|
|
||||||
|
<item> The datatypes "float" and "double" are not available.
|
||||||
|
|
||||||
|
<item> The compiler does not support bit fields.
|
||||||
|
|
||||||
|
<item> Initialization of local variables is only possible for scalar data
|
||||||
|
types (that is, not for arrays and structs).
|
||||||
|
|
||||||
|
<item> Because of the "wrong" order of the parameters on the stack, there is
|
||||||
|
an additional macro needed to access parameters in a variable
|
||||||
|
parameter list in a C function.
|
||||||
|
|
||||||
|
<item> Functions may not return structs. However, struct assignment *is*
|
||||||
|
possible.
|
||||||
|
|
||||||
|
<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.
|
||||||
|
|
||||||
|
</itemize>
|
||||||
|
|
||||||
|
There may be some more minor differences, I'm currently not aware off. The
|
||||||
|
biggest problem is the missing float data type. With this limitation in
|
||||||
|
mind, you should be able to write fairly portable code.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<sect>Extensions<p>
|
||||||
|
|
||||||
|
This cc65 version has some extensions to the ISO C standard.
|
||||||
|
|
||||||
|
<itemize>
|
||||||
|
|
||||||
|
<item> The compiler allows // comments (like in C++ and in the proposed C9x
|
||||||
|
standard). This feature is disabled by <tt/-A/.
|
||||||
|
|
||||||
|
<item> The compiler allows to insert assembler statements into the output
|
||||||
|
file. The syntax is
|
||||||
|
<p>
|
||||||
|
|
||||||
|
<tt/asm (<string literal>) ;/
|
||||||
|
<p>
|
||||||
|
|
||||||
|
or
|
||||||
|
<p>
|
||||||
|
|
||||||
|
<tt/__asm__ (<string literal>) ;/
|
||||||
|
<p>
|
||||||
|
|
||||||
|
The first form is in the user namespace and is disabled if the <tt/-A/
|
||||||
|
switch is given.
|
||||||
|
|
||||||
|
The given string is inserted literally into the output file, and a
|
||||||
|
newline is appended. The statements in this string are not checked by
|
||||||
|
the compiler, so be careful!
|
||||||
|
|
||||||
|
The asm statement may be used inside a function and on global file
|
||||||
|
level.
|
||||||
|
|
||||||
|
<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
|
||||||
|
<p>
|
||||||
|
<return type> fastcall <function name> (<parameter list>)
|
||||||
|
<p>
|
||||||
|
|
||||||
|
or
|
||||||
|
<p>
|
||||||
|
<return type> __fastcall__ <function name> (<parameter list>)
|
||||||
|
<p>
|
||||||
|
An example would be
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
void __fastcall__ f (unsigned char c)
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
|
The first form of the fastcall keyword is in the user namespace and is
|
||||||
|
therefore disabled in strict ANSI mode.
|
||||||
|
|
||||||
|
For functions declared as <tt/fastcall/, the rightmost parameter is not
|
||||||
|
pushed on the stack but left in the primary register when the function
|
||||||
|
is called. This will reduce the cost when calling assembler functions
|
||||||
|
significantly, especially when the function itself is rather small.
|
||||||
|
|
||||||
|
<item> There are two pseudo variables named <tt/__AX__/ and <tt/__EAX__/.
|
||||||
|
Both refer to the primary register that is used by the compiler to
|
||||||
|
evaluate expressions or return function results. <tt/__AX__/ is of
|
||||||
|
type <tt/unsigned int/ and <tt/__EAX__/ of type <tt/long unsigned int/
|
||||||
|
respectively. The pseudo variables may be used as lvalue and rvalue as
|
||||||
|
every other variable. They are most useful together with short
|
||||||
|
sequences of assembler code. For example, the macro
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
#define hi(x) (__AX__=(x),asm("\ttxa\n\tldx\t#$00",__AX__)
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
|
will give the high byte of any unsigned value.
|
||||||
|
|
||||||
|
<item> Inside a function, the identifier <tt/__func__/ gives the name of the
|
||||||
|
current function as a string. Outside of functions, <tt/__func__/ is
|
||||||
|
undefined.
|
||||||
|
Example:
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
#define PRINT_DEBUG(s) printf ("%s: %s\n", __func__, s);
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
|
The macro will print the name of the current function plus a given
|
||||||
|
string.
|
||||||
|
</itemize>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
|
||||||
|
<sect>Predefined macros<p>
|
||||||
|
|
||||||
|
The compiler defines several macros at startup:
|
||||||
|
|
||||||
|
<descrip>
|
||||||
|
|
||||||
|
<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.
|
||||||
|
|
||||||
|
<tag><tt>__CBM__</tt></tag>
|
||||||
|
|
||||||
|
This macro is defined if the target system is one of the CBM targets.
|
||||||
|
|
||||||
|
<tag><tt>__C64__</tt></tag>
|
||||||
|
|
||||||
|
This macro is defined if the target is the c64 (-t c64).
|
||||||
|
|
||||||
|
<tag><tt>__C128__</tt></tag>
|
||||||
|
|
||||||
|
This macro is defined if the target is the c128 (-t c128).
|
||||||
|
|
||||||
|
<tag><tt>__PLUS4__</tt></tag>
|
||||||
|
|
||||||
|
This macro is defined if the target is the plus/4 (-t plus4).
|
||||||
|
|
||||||
|
<tag><tt>__CBM610__</tt></tag>
|
||||||
|
|
||||||
|
This macro is defined if the target is one of the CBM 600/700 family of
|
||||||
|
computers (called B series in the US).
|
||||||
|
|
||||||
|
<tag><tt>__PET__</tt></tag>
|
||||||
|
|
||||||
|
This macro is defined if the target is the PET family of computers (-t pet).
|
||||||
|
|
||||||
|
<tag><tt>__ATARI__</tt></tag>
|
||||||
|
|
||||||
|
This macro is defined if the target is one of the Atari computers
|
||||||
|
(400/800/130XL/800XL). Note that there is no runtime and C library support
|
||||||
|
for atari systems.
|
||||||
|
|
||||||
|
<tag><tt>__APPLE2__</tt></tag>
|
||||||
|
|
||||||
|
This macro is defined if the target is the Apple ][ (-t apple2).
|
||||||
|
|
||||||
|
<tag><tt>__GEOS__</tt></tag>
|
||||||
|
|
||||||
|
This macro is defined if you are compiling for the GEOS system (-t geos).
|
||||||
|
|
||||||
|
<tag><tt>__FILE__</tt></tag>
|
||||||
|
|
||||||
|
This macro expands to a string containing the name of the C source file.
|
||||||
|
|
||||||
|
<tag><tt>__LINE__</tt></tag>
|
||||||
|
|
||||||
|
This macro expands to the current line number.
|
||||||
|
|
||||||
|
<tag><tt>__STRICT_ANSI__</tt></tag>
|
||||||
|
|
||||||
|
This macro is defined to 1 if the -A compiler option was given, and
|
||||||
|
undefined otherwise.
|
||||||
|
|
||||||
|
<tag><tt>__OPT__</tt></tag>
|
||||||
|
|
||||||
|
Is defined if the compiler was called with the -O command line option.
|
||||||
|
|
||||||
|
<tag><tt>__OPT_i__</tt></tag>
|
||||||
|
|
||||||
|
Is defined if the compiler was called with the -Oi command line option.
|
||||||
|
|
||||||
|
<tag><tt>__OPT_r__</tt></tag>
|
||||||
|
|
||||||
|
Is defined if the compiler was called with the -Or command line option.
|
||||||
|
|
||||||
|
<tag><tt>__OPT_s__</tt></tag>
|
||||||
|
|
||||||
|
Is defined if the compiler was called with the -Os command line option.
|
||||||
|
|
||||||
|
</descrip>
|
||||||
|
|
||||||
|
|
||||||
|
<sect>#pragmas<p>
|
||||||
|
|
||||||
|
The compiler understands some pragmas that may be used to change code
|
||||||
|
generation and other stuff.
|
||||||
|
|
||||||
|
<descrip>
|
||||||
|
|
||||||
|
<tag><tt>#pragma bssseg (<name>)</tt></tag>
|
||||||
|
|
||||||
|
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
|
||||||
|
in double quotes.
|
||||||
|
|
||||||
|
Note: The default linker configuration file does only map the standard
|
||||||
|
segments. If you use other segments, you have to create a new linker
|
||||||
|
configuration file.
|
||||||
|
|
||||||
|
Beware: The startup code will zero only the default BSS segment. If you
|
||||||
|
use another BSS segment, you have to do that yourself, otherwise
|
||||||
|
uninitialized variables do not have the value zero.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
#pragma bssseg ("MyBSS")
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>#pragma codeseg (<name>)</tt></tag>
|
||||||
|
|
||||||
|
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
|
||||||
|
double quotes.
|
||||||
|
|
||||||
|
Note: The default linker configuration file does only map the standard
|
||||||
|
segments. If you use other segments, you have to create a new linker
|
||||||
|
configuration file.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
#pragma bssseg ("MyCODE")
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>#pragma dataseg (<name>)</tt></tag>
|
||||||
|
|
||||||
|
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
|
||||||
|
double quotes.
|
||||||
|
|
||||||
|
Note: The default linker configuration file does only map the standard
|
||||||
|
segments. If you use other segments, you have to create a new linker
|
||||||
|
configuration file.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
#pragma bssseg ("MyDATA")
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>#pragma rodataseg (<name>)</tt></tag>
|
||||||
|
|
||||||
|
This pragma changes the name used for the RODATA segment (the RODATA
|
||||||
|
segment is used to store readonly data). The argument is a string
|
||||||
|
enclosed in double quotes.
|
||||||
|
|
||||||
|
Note: The default linker configuration file does only map the standard
|
||||||
|
segments. If you use other segments, you have to create a new linker
|
||||||
|
configuration file.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
#pragma bssseg ("MyRODATA")
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>#pragma regvaraddr (<const int>)</tt></tag>
|
||||||
|
|
||||||
|
The compiler does not allow to take the address of register variables.
|
||||||
|
The regvaraddr pragma changes this. Taking the address of a register
|
||||||
|
variable is allowed after using this pragma, if the argument is not
|
||||||
|
zero. Using an argument of zero changes back to the default behaviour.
|
||||||
|
|
||||||
|
Beware: The C standard does not allow taking the address of a variable
|
||||||
|
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
|
||||||
|
register variables. So be careful with this #pragma.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
#pragma regvaraddr(1) /* Allow taking the address
|
||||||
|
* of register variables
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>#pragma signedchars (<const int>)</tt></tag>
|
||||||
|
|
||||||
|
Changed the signedness of the default character type. If the argument
|
||||||
|
is not zero, default characters are signed, otherwise characters are
|
||||||
|
unsigned. The compiler default is to make characters unsigned since this
|
||||||
|
creates a lot better code.
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>#pragma staticlocals (<const int>)</tt></tag>
|
||||||
|
|
||||||
|
Use variables in the bss segment instead of variables on the stack. This
|
||||||
|
pragma changes the default set by the compiler option -Cl. If the argument
|
||||||
|
is not zero, local variables are allocated in the BSS segment, leading to
|
||||||
|
shorter and in most cases faster, but non-reentrant code.
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>#pragma zpsym (<name>)</tt></tag>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
extern int foo;
|
||||||
|
#pragma zpsym ("foo"); /* foo is in the zeropage */
|
||||||
|
|
||||||
|
</descrip>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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">).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<sect>Copyright<p>
|
||||||
|
|
||||||
|
This is the original compiler copyright:
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
-*- Mode: Text -*-
|
||||||
|
|
||||||
|
This is the copyright notice for RA65, LINK65, LIBR65, and other
|
||||||
|
Atari 8-bit programs. Said programs are Copyright 1989, by John R.
|
||||||
|
Dunning. All rights reserved, with the following exceptions:
|
||||||
|
|
||||||
|
Anyone may copy or redistribute these programs, provided that:
|
||||||
|
|
||||||
|
1: You don't charge anything for the copy. It is permissable to
|
||||||
|
charge a nominal fee for media, etc.
|
||||||
|
|
||||||
|
2: All source code and documentation for the programs is made
|
||||||
|
available as part of the distribution.
|
||||||
|
|
||||||
|
3: This copyright notice is preserved verbatim, and included in
|
||||||
|
the distribution.
|
||||||
|
|
||||||
|
You are allowed to modify these programs, and redistribute the
|
||||||
|
modified versions, provided that the modifications are clearly noted.
|
||||||
|
|
||||||
|
There is NO WARRANTY with this software, it comes as is, and is
|
||||||
|
distributed in the hope that it may be useful.
|
||||||
|
|
||||||
|
This copyright notice applies to any program which contains
|
||||||
|
this text, or the refers to this file.
|
||||||
|
|
||||||
|
This copyright notice is based on the one published by the Free
|
||||||
|
Software Foundation, sometimes known as the GNU project. The idea
|
||||||
|
is the same as theirs, ie the software is free, and is intended to
|
||||||
|
stay that way. Everybody has the right to copy, modify, and re-
|
||||||
|
distribute this software. Nobody has the right to prevent anyone
|
||||||
|
else from copying, modifying or redistributing it.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
|
In acknowledgment of this copyright, I will place my own changes to the
|
||||||
|
compiler under the same copyright. Please note however, that the library
|
||||||
|
and all binutils are covered by another copyright, and that I'm planning
|
||||||
|
to do a complete rewrite of the compiler, after which the compiler
|
||||||
|
copyright will also change.
|
||||||
|
|
||||||
|
For the list of changes requested by this copyright see newvers.txt.
|
||||||
|
|
||||||
|
|
||||||
|
</article>
|
||||||
|
|
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
<article>
|
<article>
|
||||||
<title>cl65 Users Guide
|
<title>cl65 Users Guide
|
||||||
<author>Ullrich von Bassewitz, <tt/uz@musoftware.de/
|
<author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
|
||||||
<date>01.08.2000
|
<date>01.08.2000
|
||||||
<abstract>cl65 is the compile & link utility for cc65.
|
|
||||||
|
<abstract>
|
||||||
|
cl65 is the compile & link utility for cc65, the 6502 C compiler.
|
||||||
</abstract>
|
</abstract>
|
||||||
|
|
||||||
<!-- Table of contents -->
|
<!-- Table of contents -->
|
||||||
|
Reference in New Issue
Block a user