<title>cc65 Users Guide
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
<url url="mailto:gregdk@users.sf.net" name="Greg King">
-<date>2017-03-21
+<date>2017-05-20
<abstract>
cc65 is a C compiler for 6502 targets. It supports several 6502 based home
<item>sim6502
<item>sim65c02
<item>supervision
+ <item>telestrat
<item>vic20
</itemize>
This macro is defined if the target is the Supervision (-t supervision).
+ <tag><tt>__TELESTRAT__</tt></tag>
+
+ This macro is defined if the target is the Telestrat (-t telestrat).
+
<tag><tt>__TIME__</tt></tag>
This macro expands to the time of translation of the preprocessing
remembered and output as a whole when translation is finished.
+<sect1><tt>#pragma message (<message>)</tt><label id="pragma-message"><p>
+
+ This pragma is used to display informational messages at compile-time.
+
+ The message intented to be displayed must be a string literal.
+
+ Example:
+ <tscreen><verb>
+ #pragma message ("in a bottle")
+ </verb></tscreen>
+
+ Results in the compiler outputting the following to stderr:
+ <tscreen><verb>
+ example.c(42): Note: in a bottle
+ </verb></tscreen>
+
+
<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
The <tt/#pragma/ understands the push and pop parameters as explained above.
-<sect1><tt>#pragma trampoline (<push&rt;, <name>, <value>)</tt><label id="pragma-trampoline"><p>
-
- This pragma sets a trampoline for functions. The name is either
- a function returning void and taking no parameters, or the address
- of an array in memory (for a RAM trampoline). The value is an
- 8-bit number that's set to tmp4.
-
- The address of the function is passed in ptr4.
-
- This is useful for example with banked memory, to automatically
- switch banks to where this function resides, and then restore
- the bank when it returns.
-
- The <tt/#pragma/ requires the push and pop parameters as explained above.
-
- Example:
- <tscreen><verb>
- void mytrampoline(void);
-
- #pragma trampoline (push, mytrampoline, 0)
- void somefunc(void);
- #pragma trampoline (pop)
- </verb></tscreen>
-
-
<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
</verb></tscreen>
+<sect1><tt>#pragma wrapped-call (push, <name>, <identifier>)</tt><label id="pragma-wrapped-call"><p>
+
+ This pragma sets a wrapper for functions, often used for trampolines.
+
+ The name is a function returning <tt/void/, and taking no parameters.
+ It must preserve the CPU's <tt/A/ and <tt/X/ registers if it wraps any
+ <tt/__fastcall__/ functions that have parameters. It must preserve
+ the <tt/Y/ register if it wraps any variadic functions (they have "<tt/.../"
+ in their prototypes).
+
+ The identifier is an 8-bit number that's set into <tt/tmp4/.
+
+ The address of a wrapped function is passed in <tt/ptr4/. The wrapper can
+ call that function by using "<tt/jsr callptr4/".
+
+ This feature is useful, for example, with banked memory, to switch banks
+ automatically to where a wrapped function resides, and then to restore the
+ previous bank when it returns.
+
+ The <tt/#pragma/ requires the push or pop argument as explained above.
+
+ Example:
+ <tscreen><verb>
+/* Note that this code can be in a header. */
+void mytrampoline(void); /* Doesn't corrupt __AX__ */
+
+#pragma wrapped-call (push, mytrampoline, 5)
+void somefunc1(void);
+void somefunc2(int, char *);
+#pragma wrapped-call (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,