mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 19:29:37 +00:00
Improved the compiler documentation, a little bit.
This commit is contained in:
parent
bbb6f89731
commit
b49fd26d16
@ -3,7 +3,7 @@
|
|||||||
<article>
|
<article>
|
||||||
<title>cc65 Users Guide
|
<title>cc65 Users Guide
|
||||||
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
|
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
|
||||||
<date>2015-04-21
|
<date>2015-05-26
|
||||||
|
|
||||||
<abstract>
|
<abstract>
|
||||||
cc65 is a C compiler for 6502 targets. It supports several 6502 based home
|
cc65 is a C compiler for 6502 targets. It supports several 6502 based home
|
||||||
@ -558,10 +558,10 @@ and the one defined by the ISO standard:
|
|||||||
be passed as parameters by value. However, struct assignment *is*
|
be passed as parameters by value. However, struct assignment *is*
|
||||||
possible.
|
possible.
|
||||||
<p>
|
<p>
|
||||||
<item> Most of the C library is available only with the fastcall calling
|
<item> Most of the C library is available with only the fastcall calling
|
||||||
convention (<ref id="extension-fastcall" name="see below">). It means
|
convention (<ref id="extension-fastcall" name="see below">). It means
|
||||||
that you must not mix pointers to those functions with pointers to
|
that you must not mix pointers to those functions with pointers to
|
||||||
user-written, cdecl functions.
|
user-written, cdecl functions (the calling conventions are incompatible).
|
||||||
<p>
|
<p>
|
||||||
<item> The <tt/volatile/ keyword doesn't have an effect. This is not as bad
|
<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
|
as it sounds, since the 6502 has so few registers that it isn't
|
||||||
@ -600,30 +600,30 @@ This cc65 version has some extensions to the ISO C standard.
|
|||||||
<p>
|
<p>
|
||||||
|
|
||||||
<label id="extension-fastcall">
|
<label id="extension-fastcall">
|
||||||
<item> The normal calling convention -- for non-variadic functions -- is
|
<item> The normal calling convention -- for non-variadic functions -- is
|
||||||
named "fastcall". The syntax for a function declaration that
|
named "fastcall". The syntax for a function declaration that
|
||||||
<em/explicitly/ uses fastcall is
|
<em/explicitly/ uses fastcall is
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
<return type> fastcall <function name> (<parameter list>)
|
<return type> fastcall <function name> (<parameter list>)
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
or
|
or
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
<return type> __fastcall__ <function name> (<parameter list>)
|
<return type> __fastcall__ <function name> (<parameter list>)
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
An example would be
|
An example is
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
void __fastcall__ f (unsigned char c)
|
void __fastcall__ f (unsigned char c)
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
The first form of the fastcall keyword is in the user namespace and can
|
The first form of the fastcall keyword is in the user namespace and can
|
||||||
therefore be disabled with the <tt><ref id="option--standard"
|
therefore be disabled with the <tt><ref id="option--standard"
|
||||||
name="--standard"></tt> command line option.
|
name="--standard"></tt> command line option.
|
||||||
|
|
||||||
For functions that are <tt/fastcall/, the rightmost parameter is not
|
For functions that are <tt/fastcall/, the rightmost parameter is not
|
||||||
pushed on the stack but left in the primary register when the function
|
pushed on the stack but left in the primary register when the function
|
||||||
is called. That significantly reduces the cost of calling functions.
|
is called. That significantly reduces the cost of calling those functions.
|
||||||
<newline><newline>
|
<newline><newline>
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
<item> There is another calling convention named "cdecl". Variadic functions
|
<item> There is another calling convention named "cdecl". Variadic functions
|
||||||
(their prototypes have an ellipsis [<tt/.../]) always use that
|
(their prototypes have an ellipsis [<tt/.../]) always use that
|
||||||
@ -636,14 +636,14 @@ This cc65 version has some extensions to the ISO C standard.
|
|||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
<return type> __cdecl__ <function name> (<parameter list>)
|
<return type> __cdecl__ <function name> (<parameter list>)
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
An example would be
|
An example is
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
int * __cdecl__ f (unsigned char c)
|
int* __cdecl__ f (unsigned char c)
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
The first form of the cdecl keyword is in the user namespace;
|
The first form of the cdecl keyword is in the user namespace;
|
||||||
and therefore, can be disabled with the <tt><ref id="option--standard"
|
and therefore, can be disabled with the <tt/<ref id="option--standard"
|
||||||
name="--standard"></tt> command-line option.
|
name="--standard">/ command-line option.
|
||||||
|
|
||||||
For functions that are <tt/cdecl/, the rightmost parameter is pushed
|
For functions that are <tt/cdecl/, the rightmost parameter is pushed
|
||||||
onto the stack before the function is called. That increases the cost
|
onto the stack before the function is called. That increases the cost
|
||||||
@ -701,7 +701,7 @@ This cc65 version has some extensions to the ISO C standard.
|
|||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
Since the variable is of type <tt/void/ you may not use it as is.
|
Since the variable is of type <tt/void/ you may not use it as is.
|
||||||
However, taking the address of the variable results in a <tt/void */
|
However, taking the address of the variable results in a <tt/void*/
|
||||||
which may be passed to any function expecting a pointer.
|
which may be passed to any function expecting a pointer.
|
||||||
|
|
||||||
See the <url url="geos.html" name="GEOS library document"> for examples
|
See the <url url="geos.html" name="GEOS library document"> for examples
|
||||||
|
@ -597,7 +597,7 @@ variable which is stored in the zero page memory space in order to allow
|
|||||||
for retrieval of each character in the string via the indirect indexed
|
for retrieval of each character in the string via the indirect indexed
|
||||||
addressing mode.
|
addressing mode.
|
||||||
|
|
||||||
The assembly language routine is stored in a file named
|
The assembly language routine is stored in a file names
|
||||||
"rs232_tx.s" and is shown below:
|
"rs232_tx.s" and is shown below:
|
||||||
|
|
||||||
<tscreen><code>
|
<tscreen><code>
|
||||||
@ -681,7 +681,7 @@ all of the behind-the-scene work is transparent to the user.
|
|||||||
#define TX_FIFO_FULL (FIFO_STATUS & 0x01)
|
#define TX_FIFO_FULL (FIFO_STATUS & 0x01)
|
||||||
#define RX_FIFO_EMPTY (FIFO_STATUS & 0x02)
|
#define RX_FIFO_EMPTY (FIFO_STATUS & 0x02)
|
||||||
|
|
||||||
extern void wait (void);
|
extern void wait ();
|
||||||
extern void __fastcall__ rs232_tx (char *str);
|
extern void __fastcall__ rs232_tx (char *str);
|
||||||
|
|
||||||
int main () {
|
int main () {
|
||||||
|
Loading…
Reference in New Issue
Block a user