-<item> The compiler allows // comments (like in C++ and in the proposed C9x
- standard). This feature is disabled by <tt><ref id="option-A"
- name="-A"></tt>.
- <p>
-
-<item> The compiler allows to insert assembler statements into the output
- file. The syntax is
-
- <tscreen><verb>
- asm (<string literal>[, optional parameters]) ;
- </verb></tscreen>
- or
- <tscreen><verb>
- __asm__ (<string literal>[, optional parameters]) ;
- </verb></tscreen>
-
- The first form is in the user namespace and is disabled if the <tt/-A/
- switch is given.
-
- There is a whole section covering inline assembler statements,
- <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
-
- <tscreen><verb>
- <return type> fastcall <function name> (<parameter list>)
- </verb></tscreen>
- or
- <tscreen><verb>
- <return type> __fastcall__ <function name> (<parameter list>)
- </verb></tscreen>
- 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.
- <p>
-
-<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.
- <p>
-
-<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.
- <p>
-
-<item> cc65 allows the initialization of <tt/void/ variables. This may be
- used to create variable structures that are more compatible with
- interfaces written for assembler languages. Here is an example:
-
- <tscreen><verb>
- void GCmd = { (char)3, (unsigned)0x2000, (unsigned)0x3000 };
- </verb></tscreen>
-
- This will be translated as follows:
-
- <tscreen><verb>
- _GCmd:
- .byte 3
- .word $2000
- .word $3000
- </verb></tscreen>
-
- 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*/
- 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.
- <p>
+<item> The compiler allows to insert assembler statements into the output
+ file. The syntax is
+
+ <tscreen><verb>
+ asm [optional volatile] (<string literal>[, optional parameters]) ;
+ </verb></tscreen>
+ or
+ <tscreen><verb>
+ __asm__ [optional volatile] (<string literal>[, optional parameters]) ;
+ </verb></tscreen>
+
+ The first form is in the user namespace; and, is disabled if the <tt/-A/
+ switch is given.
+
+ There is a whole section covering inline assembler statements,
+ <ref id="inline-asm" name="see there">.
+ <p>
+
+<label id="extension-fastcall">
+<item> The normal calling convention -- for non-variadic functions -- is
+ named "fastcall". The syntax for a function declaration that
+ <em/explicitly/ uses fastcall is
+
+ <tscreen><verb>
+ <return type> fastcall <function name> (<parameter list>)
+ </verb></tscreen>
+ or
+ <tscreen><verb>
+ <return type> __fastcall__ <function name> (<parameter list>)
+ </verb></tscreen>
+ An example is
+ <tscreen><verb>
+ void __fastcall__ f (unsigned char c)
+ </verb></tscreen>
+ The first form of the fastcall keyword is in the user namespace and can
+ therefore be disabled with the <tt><ref id="option--standard"
+ name="--standard"></tt> command line option.
+
+ For functions that are <tt/fastcall/, the rightmost parameter is not
+ pushed on the stack but left in the primary register when the function
+ is called. That significantly reduces the cost of calling those functions.
+ <p>
+
+<item> There is another calling convention named "cdecl". Variadic functions
+ (their prototypes have an ellipsis [<tt/.../]) always use that
+ convention. The syntax for a function declaration using cdecl is
+
+ <tscreen><verb>
+ <return type> cdecl <function name> (<parameter list>)
+ </verb></tscreen>
+ or
+ <tscreen><verb>
+ <return type> __cdecl__ <function name> (<parameter list>)
+ </verb></tscreen>
+ An example is
+ <tscreen><verb>
+ int* __cdecl__ f (unsigned char c)
+ </verb></tscreen>
+
+ The first form of the cdecl keyword is in the user namespace;
+ and therefore, can be disabled with the <tt/<ref id="option--standard"
+ name="--standard">/ command-line option.
+
+ For functions that are <tt/cdecl/, the rightmost parameter is pushed
+ onto the stack before the function is called. That increases the cost
+ of calling those functions, especially when they are called from many
+ places.
+ <p>
+
+<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 ("txa"), \
+ asm ("ldx #$00"), \
+ __AX__)
+ </verb></tscreen>
+
+ will give the high byte of any unsigned value.
+ <p>
+
+<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.
+ <p>
+
+<item> cc65 allows the initialization of <tt/void/ variables. This may be
+ used to create arbitrary structures that are more compatible with
+ interfaces written for assembler languages. Here is an example:
+
+ <tscreen><verb>
+ void GCmd = { (char)3, (unsigned)0x2000, (unsigned)0x3000 };
+ </verb></tscreen>
+
+ That will be translated as follows:
+
+ <tscreen><verb>
+ _GCmd:
+ .byte 3
+ .word $2000
+ .word $3000
+ </verb></tscreen>
+
+ 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*/
+ which may be passed to any function expecting a pointer. Also, the
+ <tt/sizeof/ operator will give the length of the initializer:
+
+ <tscreen><verb>
+ GLen = sizeof GCmd;
+ </verb></tscreen>
+
+ will assign the value 5 to <tt/GLen/.
+
+ See the <url url="geos.html" name="GEOS library document"> for examples
+ on how to use that feature.
+ <p>