+
+This file contains an overview of the Apple ][ runtime system
+as it comes with the cc65 C compiler. It describes the memory layout,
+Apple ][ specific header files, available drivers, and any
+pitfalls specific to that platform.
+
+Please note that Apple ][ specific functions are just mentioned
+here, they are described in detail in the separate . Even functions marked as "platform dependent" may
+be available on more than one platform. Please see the function reference for
+more information.
+
+
+
+Binary format
+
+The standard binary file format generated by the linker for the
+Apple ][ target is a binary program with a 4 byte DOS 3.3 header
+containing the load address and load length. The default load address is
+$803.
+
+) includes the option for those programs
+omits the DOS 3.3 header. The right AppleCommander option to put system files
+without a header on a ProDOS 8 disk image is Memory layout
+
+In the standard setup, cc65 generated programs use the memory from
+$803 to $95FF, so 35.5 KB of RAM are available.
+
+Special locations:
+
+
+
+
+
+While running .
+
+
+
+Linker configurations
+
+The ld65 linker comes with a builtin config file for the Apple ][,
+which is used via builtin config file
+
+Default configuration optimized for a binary program running on ProDOS 8 with
+BASIC.SYSTEM. A plain vanilla ProDOS 8 doesn't actually use the Language Card
+bank 2 memory from $D400 to $DFFF.
+
+
+
+
+ From $803 to $95FF (35.5 KB)
+
+
+ From $D400 to $DFFF (3 KB)
+
+
+ Variable (default: $803)
+
+
+ DOS 3.3 header (address and length)
+
+
+
+
+
+
+Configuration optimized for a binary program running on DOS 3.3. A plain
+vanilla DOS 3.3 doesn't make use of the Language Card at all.
+
+
+
+
+ From $803 to $95FF (35.5 KB)
+
+
+ From $D000 to $FFFF (12 KB)
+
+
+ Variable (default: $803)
+
+
+ DOS 3.3 header (address and length)
+
+
+
+
+
+
+Configuration for a system program running on ProDOS 8.
+
+
+
+
+ From $2000 to $BEFF (39.75 KB)
+
+
+ From $D400 to $DFFF (3 KB)
+
+
+ Fixed ($2000)
+
+
+ None
+
+
+
+
+
+
+Configuration optimized for a binary program running on ProDOS 8 without
+BASIC.SYSTEM. Intended to be used with
+
+
+ From $800 to $BEFF (45.75 KB)
+
+
+ From $D400 to $DFFF (3 KB)
+
+
+ Variable (default: $800)
+
+
+ DOS 3.3 header (address and length)
+
+
+
+
+
+
+Configuration optimized for a binary program running on ProDOS 8 without
+BASIC.SYSTEM. Intended to be used with
+
+
+ From $800 to $BEFF (45.75 KB)
+
+
+ From $D000 to $DFFF (4 KB)
+
+
+ Variable (default: $800)
+
+
+ DOS 3.3 header (address and length)
+
+
+
+
+
+ProDOS 8 system programs
+
+ProDOS 8 system programs are always loaded to the start address $2000.
+For cc65 programs this means that the 6 KB from $800 to $2000 are
+by default unused. There are however several options to make use of that memory
+range.
+
+
+LOADER.SYSTEM
+
+The easiest (and for really large programs in fact the only) way to have a cc65
+program use the memory from $800 to $2000 is to link it as binary
+(as opposed to system) program using the linker configuration
+ with start address
+$800 and load it with Heap
+
+If the cc65 program can be successfully linked as system program using the linker
+configuration but
+uses the heap either explicitly or implicitly (i.e. by loading a driver) then
+the memory from $800 to $2000 can be added to the heap by calling
+ProDOS 8 I/O buffers
+
+ProDOS 8 requires for every open file a page-aligned 1 KB I/O buffer. By default
+these buffers are allocated by the cc65 runtime system on the heap using
+
+cl65 -t apple2 -C apple2-system.cfg myprog.c apple2-iobuf-0800.o
+
+
+
+
+Platform specific header files
+
+Programs containing Apple ][ specific code may use the
+Apple ][ specific functions
+
+The functions listed below are special for the Apple ][. See
+the for declaration and
+usage.
+
+
+_auxtype
+_dos_type
+_filetype
+get_ostype
+rebootafterexit
+ser_apple2_slot
+tgi_apple2_mix
+
+
+
+Hardware access
+
+There's currently no support for direct hardware access. This does not mean
+you cannot do it, it just means that there's no help.
+
+
+
+Loadable drivers
+
+The names in the parentheses denote the symbols to be used for static linking of the drivers.
+
+
+Graphics drivers
+
+
+
+
+ This driver features a resolution of 40×48 with 16 colors.
+
+ The function
+ This driver features a resolution of 280×192 with 8 colors and two
+ hires pages. Note that programs using this driver will have to be linked
+ with
+
+
+Extended memory drivers
+
+
+
+
+ Gives access to 47.5 KB RAM (190 pages of 256 bytes each) on an Extended
+ 80-Column Text Card.
+
+ Note that this driver doesn't check for the actual existence of the memory
+ and that it doesn't check for ProDOS 8 RAM disk content!
+
+
+
+
+Joystick drivers
+
+
+
+
+ Supports up to two standard analog joysticks connected to the game port of
+ the Apple ][.
+
+
+
+
+Mouse drivers
+
+
+
+
+ Driver for the AppleMouse II Card. Searches all Apple II slots
+ for an AppleMouse II Card compatible firmware. The default bounding
+ box is [0..279,0..191].
+
+ Programs using this driver will have to be linked with
+
+
+RS232 device drivers
+
+
+
+
+ Driver for the Apple II Super Serial Card. Supports up to 19200 baud,
+ hardware flow control (RTS/CTS) and interrupt driven receives. Note
+ that because of the peculiarities of the 6551 chip transmits are not
+ interrupt driven, and the transceiver blocks if the receiver asserts
+ flow control because of a full buffer.
+
+ The driver defaults to slot 2. Call
+
+
+
+Limitations
+
+
+DOS 3.3
+
+Although the standard binaries generated by the linker for the Apple ][
+generally run both on DOS 3.3 (with Applesoft BASIC) and on ProDOS 8 (with
+BASIC.SYSTEM) there are some limitations for DOS 3.3:
+
+
+
+ Disk File I/O
+ There's no disk file I/O support. Any attempt to use it yields an error with
+
+
+
+Direct console I/O
+
+
+
+ ,
+ and
+ have no effect.
+
+ has no effect.
+
+
+
+
+
+Other hints
+
+
+Passing arguments to the program
+
+Command line arguments can be passed to
+]CALL2051:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
+
+
+
+Arguments are separated by spaces.
+Arguments may be quoted.
+Leading and trailing spaces around an argument are ignored. Spaces within
+ a quoted argument are allowed.
+The first argument passed to A maximum number of 10 arguments (including the program name) are
+ supported.
+
+
+
+Interrupts
+
+The runtime for the Apple ][ uses routines marked as
+.
+
+
+DIO
+
+
+
+ has the single
+ parameter
+ device = slot + (drive - 1) * 8
+
+
+ so that for example slot 6 drive 2 is mapped to returns
+ the correct sector count for all ProDOS 8 disks. However for any non-ProDOS 8
+ disk it simply always returns 280 (which is only correct for a 140 KB disk).
+ This condition is indicated by the
+
+
+
+Bugs/Feedback
+
+If you have problems using the library, 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 ().
+
+
+
+License
+
+This software is provided 'as-is', without any expressed or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+
+ The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ Altered source versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+ This notice may not be removed or altered from any source
+ distribution.
+
+
+
diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml
new file mode 100644
index 000000000..667ae9ec7
--- /dev/null
+++ b/doc/apple2enh.sgml
@@ -0,0 +1,550 @@
+
+
+
+
+Enhanced Apple //e specific information for cc65
+Oliver Schmidt,
+2009-10-07
+
+
+An overview over the enhanced Apple //e runtime system as it is
+implemented for the cc65 C compiler.
+
+
+
+
+
+
+
+Overview
+
+This file contains an overview of the enhanced Apple //e runtime system
+as it comes with the cc65 C compiler. It describes the memory layout,
+enhanced Apple //e specific header files, available drivers, and any
+pitfalls specific to that platform.
+
+Please note that enhanced Apple //e specific functions are just mentioned
+here, they are described in detail in the separate . Even functions marked as "platform dependent" may
+be available on more than one platform. Please see the function reference for
+more information.
+
+
+
+Binary format
+
+The standard binary file format generated by the linker for the
+enhanced Apple //e target is a binary program with a 4 byte DOS 3.3 header
+containing the load address and load length. The default load address is
+$803.
+
+) includes the option for those programs
+omits the DOS 3.3 header. The right AppleCommander option to put system files
+without a header on a ProDOS 8 disk image is Memory layout
+
+In the standard setup, cc65 generated programs use the memory from
+$803 to $95FF, so 35.5 KB of RAM are available.
+
+Special locations:
+
+
+
+
+
+While running .
+
+
+
+Linker configurations
+
+The ld65 linker comes with a builtin config file for the enhanced Apple //e,
+which is used via builtin config file
+
+Default configuration optimized for a binary program running on ProDOS 8 with
+BASIC.SYSTEM. A plain vanilla ProDOS 8 doesn't actually use the Language Card
+bank 2 memory from $D400 to $DFFF.
+
+
+
+
+ From $803 to $95FF (35.5 KB)
+
+
+ From $D400 to $DFFF (3 KB)
+
+
+ Variable (default: $803)
+
+
+ DOS 3.3 header (address and length)
+
+
+
+
+
+
+Configuration optimized for a binary program running on DOS 3.3. A plain
+vanilla DOS 3.3 doesn't make use of the Language Card at all.
+
+
+
+
+ From $803 to $95FF (35.5 KB)
+
+
+ From $D000 to $FFFF (12 KB)
+
+
+ Variable (default: $803)
+
+
+ DOS 3.3 header (address and length)
+
+
+
+
+
+
+Configuration for a system program running on ProDOS 8.
+
+
+
+
+ From $2000 to $BEFF (39.75 KB)
+
+
+ From $D400 to $DFFF (3 KB)
+
+
+ Fixed ($2000)
+
+
+ None
+
+
+
+
+
+
+Configuration optimized for a binary program running on ProDOS 8 without
+BASIC.SYSTEM. Intended to be used with
+
+
+ From $800 to $BEFF (45.75 KB)
+
+
+ From $D400 to $DFFF (3 KB)
+
+
+ Variable (default: $800)
+
+
+ DOS 3.3 header (address and length)
+
+
+
+
+
+
+Configuration optimized for a binary program running on ProDOS 8 without
+BASIC.SYSTEM. Intended to be used with
+
+
+ From $800 to $BEFF (45.75 KB)
+
+
+ From $D000 to $DFFF (4 KB)
+
+
+ Variable (default: $800)
+
+
+ DOS 3.3 header (address and length)
+
+
+
+
+
+ProDOS 8 system programs
+
+ProDOS 8 system programs are always loaded to the start address $2000.
+For cc65 programs this means that the 6 KB from $800 to $2000 are
+by default unused. There are however several options to make use of that memory
+range.
+
+
+LOADER.SYSTEM
+
+The easiest (and for really large programs in fact the only) way to have a cc65
+program use the memory from $800 to $2000 is to link it as binary
+(as opposed to system) program using the linker configuration
+ with start address
+$800 and load it with Heap
+
+If the cc65 program can be successfully linked as system program using the linker
+configuration but
+uses the heap either explicitly or implicitly (i.e. by loading a driver) then
+the memory from $800 to $2000 can be added to the heap by calling
+ProDOS 8 I/O buffers
+
+ProDOS 8 requires for every open file a page-aligned 1 KB I/O buffer. By default
+these buffers are allocated by the cc65 runtime system on the heap using
+
+cl65 -t apple2enh -C apple2enh-system.cfg myprog.c apple2enh-iobuf-0800.o
+
+
+
+
+Platform specific header files
+
+Programs containing enhanced Apple //e specific code may use the
+Enhanced Apple //e specific functions
+
+The functions listed below are special for the enhanced Apple //e. See
+the for declaration and
+usage.
+
+
+_auxtype
+_dos_type
+_filetype
+get_ostype
+rebootafterexit
+ser_apple2_slot
+textframe
+textframexy
+tgi_apple2_mix
+videomode
+
+
+
+Hardware access
+
+There's currently no support for direct hardware access. This does not mean
+you cannot do it, it just means that there's no help.
+
+
+
+Loadable drivers
+
+The names in the parentheses denote the symbols to be used for static linking of the drivers.
+
+
+Graphics drivers
+
+
+
+
+ This driver features a resolution of 40×48 with 16 colors.
+
+ The function
+ This driver features a resolution of 280×192 with 8 colors and two
+ hires pages. Note that programs using this driver will have to be linked
+ with
+
+
+Extended memory drivers
+
+
+
+
+ Gives access to 47.5 KB RAM (190 pages of 256 bytes each) on an Extended
+ 80-Column Text Card.
+
+ Note that this driver doesn't check for the actual existence of the memory
+ and that it doesn't check for ProDOS 8 RAM disk content!
+
+
+
+
+Joystick drivers
+
+
+
+
+ Supports up to two standard analog joysticks connected to the game port of
+ the enhanced Apple //e.
+
+
+
+
+Mouse drivers
+
+
+
+
+ Driver for the AppleMouse II Card. Searches all Apple II slots
+ for an AppleMouse II Card compatible firmware. The default bounding
+ box is [0..279,0..191].
+
+ Note that the enhanced Apple //e default mouse callbacks support
+ text mode only.
+
+
+
+
+RS232 device drivers
+
+
+
+
+ Driver for the Apple II Super Serial Card. Supports up to 19200 baud,
+ hardware flow control (RTS/CTS) and interrupt driven receives. Note
+ that because of the peculiarities of the 6551 chip transmits are not
+ interrupt driven, and the transceiver blocks if the receiver asserts
+ flow control because of a full buffer.
+
+ The driver defaults to slot 2. Call
+
+
+
+Limitations
+
+
+DOS 3.3
+
+Although the standard binaries generated by the linker for the enhanced Apple //e
+generally run both on DOS 3.3 (with Applesoft BASIC) and on ProDOS 8 (with
+BASIC.SYSTEM) there are some limitations for DOS 3.3:
+
+
+
+ Disk File I/O
+ There's no disk file I/O support. Any attempt to use it yields an error with
+
+
+
+Direct console I/O
+
+
+
+ ,
+ and
+ have no effect.
+
+ has no effect.
+
+
+
+
+
+Other hints
+
+
+Passing arguments to the program
+
+Command line arguments can be passed to
+]CALL2051:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
+
+
+
+Arguments are separated by spaces.
+Arguments may be quoted.
+Leading and trailing spaces around an argument are ignored. Spaces within
+ a quoted argument are allowed.
+The first argument passed to A maximum number of 10 arguments (including the program name) are
+ supported.
+
+
+
+Function keys
+
+These are defined to be OpenApple + number key.
+
+
+Interrupts
+
+The runtime for the enhanced Apple //e uses routines marked as
+.
+
+
+DIO
+
+
+
+ has the single
+ parameter
+ device = slot + (drive - 1) * 8
+
+
+ so that for example slot 6 drive 2 is mapped to returns
+ the correct sector count for all ProDOS 8 disks. However for any non-ProDOS 8
+ disk it simply always returns 280 (which is only correct for a 140 KB disk).
+ This condition is indicated by the
+
+
+
+Bugs/Feedback
+
+If you have problems using the library, 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 ().
+
+
+
+License
+
+This software is provided 'as-is', without any expressed or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+
+ The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ Altered source versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+ This notice may not be removed or altered from any source
+ distribution.
+
+
+
diff --git a/doc/ar65.sgml b/doc/ar65.sgml
new file mode 100644
index 000000000..d4e19a5c5
--- /dev/null
+++ b/doc/ar65.sgml
@@ -0,0 +1,156 @@
+
+
+
+
+ar65 Users Guide
+Ullrich von Bassewitz,
+19.07.2000
+
+
+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.
+
+
+
+
+
+
+
+Overview
+
+
+ar65 is a replacement for the libr65 archiver that was part of the cc65 C
+compiler suite developed by John R. Dunning. libr65 had some problems and
+the copyright does not permit some things which I wanted to be possible,
+so I decided to write a completely new assembler/linker/archiver suite
+for the cc65 compiler. ar65 is part of this suite.
+
+Usage
+
+
+The archiver is called as follows:
+
+
+ Usage: ar65 lib file|module ...
+ Operation is one of:
+ a Add modules
+ d Delete modules
+ l List library contents
+ x Extract modules
+ V Print the archiver version
+
+
+You may add modules to a library using the `a' command. If the library
+does not exist, it is created (and a warning message is printed which you
+may ignore if creation of the library was your intention). You may
+specify any number of modules on the command line following the library.
+
+If a module with the same name exists in the library, it is replaced by
+the new one. The archiver prints a warning, if the module in the library
+has a newer timestamp than the one to add.
+
+Here's an example:
+
+
+ ar65 a mysubs.lib sub1.o sub2.o
+
+
+This will add two modules to the library `mysubs.lib' creating the
+library if necessary. If the library contains modules named sub1.o or
+sub2.o, they are replaced by the new ones.
+
+Modules names in the library are stored without the path, so, using
+
+
+ ar65 a mysubs.lib ofiles/sub1.o ofiles/sub2.o
+
+
+will add two modules named `sub1.o' and `sub2.o' to the library.
+
+Deleting modules from a library is done with the `d' command. You may not
+give a path when naming the modules.
+
+Example:
+
+
+ ar65 d mysubs.lib sub1.o
+
+
+This will delete the module named `sub1.o' from the library, printing an
+error if the library does not contain that module.
+
+
+The `l' command prints a list of all modules in the library. Any module
+names on the command line are ignored.
+
+Example:
+
+
+ ar65 l mysubs.lib
+
+
+
+Using the `x' command, you may extract modules from the library. The
+modules named on the command line are extracted from the library and put
+into the current directory.
+
+Note: Because of the indexing done by the archiver, the modules may have
+a changed binary layout, that is, a binary compare with the old module
+(before importing it into the library) may yield differences. The
+extracted modules are accepted by the linker and archiver, however, so
+this is not a problem.
+
+Example for extracting a module from the library:
+
+
+ ar65 x mysubs.lib sub1.o
+
+
+
+The `V' command prints the version number of the assembler. If you send
+any suggestions or bugfixes, please include your version number.
+
+In addition to these operations, the archiver will check for, and warn
+about duplicate external symbols in the library, every time when an
+operation does update the library. This is only a warning, the linker
+will ignore one of the duplicate symbols (which one is unspecified).
+
+
+Bugs/Feedback
+
+If you have problems using the archiver, 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 ().
+
+
+
+Copyright
+
+ar65 (and all cc65 binutils) are (C) Copyright 1998-2000 Ullrich von
+Bassewitz. For usage of the binaries and/or sources the following conditions
+do apply:
+
+This software is provided 'as-is', without any expressed or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+
+ The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ Altered source versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+ This notice may not be removed or altered from any source
+ distribution.
+
+
+
+
+
+
diff --git a/doc/atari.sgml b/doc/atari.sgml
new file mode 100644
index 000000000..9fe75ec2a
--- /dev/null
+++ b/doc/atari.sgml
@@ -0,0 +1,590 @@
+
+
+
+
+Atari specific information for cc65
+Shawn Jefferson, and
+Christian Groessler,
+03-Jan-2006
+
+
+An overview over the Atari runtime system as it is implemented for the cc65 C
+compiler.
+
+
+
+
+
+
+
+Overview
+
+This file contains an overview of the Atari runtime system as it comes
+with the cc65 C compiler. It describes the memory layout, Atari specific
+header files, available drivers, and any pitfalls specific to that
+platform.
+
+Please note that Atari specific functions are just mentioned here, they are
+described in detail in the separate . Even functions marked as "platform dependent" may be available on
+more than one platform. Please see the function reference for more
+information.
+
+
+Binary format
+
+The standard binary output format generated by the linker for the
+Atari target is a machine language program with a standard executable
+header (FF FF <2 byte start address> <2 bytes end address>
+[program bytes]). These values are calculated in the crt0.s
+file from the __STARTUP_LOAD__ and __ZPSAVE_LOAD__ values, so keep
+this in mind if you create a custom linker config file and start
+moving segments around (see section
+).
+You can override this behaviour by creating your own crt0.s file and
+linking it into your program. A run vector is added to the end of the
+file ($02E0 <run vector>) and is calculated using
+__STARTUP_LOAD__ in crt0.s.
+
+
+Memory layout
+
+The default linker script assumes that the BASIC ROM is disabled (or
+the BASIC cartridge unplugged). This gives a usable memory range from
+$2E00 - $BC1F. The library startup code examines the
+current memory configuration, which depends on the size of the
+installed memory and cartridges present, by inspecting the value in
+the MEMTOP ($2E5) variable. Then the initial stack pointer,
+which indicates the upper bound of memory used, is adjusted. The
+default load address of $2E00 was chosen to accommodate having
+a DOS loaded and a driver that resides in low memory such as the 850
+R: handler. You can override this behaviour by creating a custom
+linker config file or by using the "--start-addr" cl65 command line
+argument or the "--start-addr" or "-S" ld65 command line arguments.
+
+Special locations:
+
+
+ ).
+
+
+
+
+
+Platform specific header files
+
+Programs containing Atari specific code may use the Atari specific functions
+
+The functions and global variable listed below are special for the Atari.
+See the for declaration and usage.
+
+
+get_ostype
+get_tv
+_dos_type
+_gtia_mkcolor
+_getcolor
+_getdefdev
+_graphics
+_rest_vecs
+_save_vecs
+_scroll
+_setcolor
+_setcolor_low
+
+
+
+Hardware access
+
+The following pseudo variables declared in the
+
+
+ The
+ The
+ The
+ The
+
+
+
+Loadable drivers
+
+The names in the parentheses denote the symbols to be used for static linking of the drivers.
+
+
+Graphics drivers
+
+Many graphics modes require more memory than the text screen which is
+in effect when the program starts up. Therefore the programmer has to
+tell the program beforehand the memory requirements of the graphics
+modes the program intends to use.
+This can be done by using the __RESERVED_MEMORY__ linker config
+variable. The number specified there describes the number of bytes to
+subtract from the top of available memory as seen from the runtime
+library. This memory is then used by the screen buffer.
+
+The numbers for the different graphics modes presented below should
+only be seen as a rule of thumb. Since the screen buffer memory needs
+to start at specific boundaries, the numbers depend on the current top
+of available memory.
+The following numbers were determined by a BASIC program.
+
+
reserved memory required for different graphics modes
+
+
+The values of "1" are needed because the graphics command crashes if
+it doesn't have at least one byte available. This seems to be a bug of
+the Atari ROM code.
+
+Extended memory drivers
+
+
+
+
+
+
+
+
+Joystick drivers
+
+
+
+
+ Supports up to four standard joysticks connected to the joystick ports of
+ the Atari.
+
+
+ Supports up to eight standard joysticks connected to a MultiJoy adapter.
+
+
+
+
+Mouse drivers
+
+Currently no drivers available (in fact, the API for loadable mouse drivers
+does not exist). There is a static driver you can use.
+
+
+RS232 device drivers
+
+Currently there are no RS232 loadable drivers available for the Atari
+platform. There is a static driver you can use.
+
+
+Limitations
+
+
+DIO implementation
diff --git a/doc/atmos.sgml b/doc/atmos.sgml
new file mode 100644
index 000000000..8e24c92a1
--- /dev/null
+++ b/doc/atmos.sgml
@@ -0,0 +1,260 @@
+
+
+
+
+Oric Atmos specific information for cc65
+Ullrich von Bassewitz
+Stefan A. Haubenthal
+
+2013-01-08
+
+
+An overview over the Atmos runtime system as it is implemented for the cc65 C
+compiler.
+
+
+
+
+
+
+
+Overview
+
+This file contains an overview of the Atmos runtime system as it comes with the
+cc65 C compiler. It describes the memory layout, Atmos specific header files,
+available drivers, and any pitfalls specific to that platform.
+
+Please note that Atmos specific functions are just mentioned here, they are
+described in detail in the separate . Even functions marked as "platform dependent" may be available on
+more than one platform. Please see the function reference for more
+information.
+
+
+Binary format
+
+The standard binary output format generated by the linker for the Atmos target
+is a machine language program with a 17 byte tape header including a cc65 tag.
+The standard load and autostart address is $500.
+
+
+Memory layout
+
+In the standard setup, cc65 generated programs use the memory from
+$500 to $9800, so nearly 37K of memory (including the stack) is
+available. ROM calls are possible without further precautions.
+
+Special locations:
+
+
+
+
+
+
+Platform specific header files
+
+Programs containing Atmos specific code may use the Atmos specific functions
+
+The functions listed below are special for the Atmos. See the for declaration and usage.
+
+
+atmos_load
+atmos_save
+
+
+
+Hardware access
+
+The following pseudo variables declared in the
+
+
+ Access to the VIA (versatile interface adapter) chip is available via the
+
+
+
+
+Loadable drivers
+
+Note: Since the Atmos doesn't have working disk I/O
+(see ), the
+available drivers cannot be loaded at runtime (so the term "loadable drivers"
+is somewhat misleading). Instead, the drivers have to be statically linked. While
+this may seem overhead, it has two advantages:
+
+
+The interface is identical to the one used for other platforms
+ and to the one for the Atmos once it has disk I/O.
+Once disk I/O is available, existing code can be changed to load drivers
+ at runtime with almost no effort.
+
+
+The names in the parentheses denote the symbols to be used for static linking of the drivers.
+
+
+Graphics drivers
+
+
+
+
+ This driver was written by Greg King and Stefan Haubenthal.
+ It features a resolution of 228×200 with a palette of two colors that
+ can be chosen from the Atmos's eight colors. The driver supports a third
+ palette-"color" that actually "flips" the pixel (it becomes the other color)
+ that is on the screen under the graphics cursor.
+
+
+ This driver was written by Stefan Haubenthal and Greg King.
+ It features a resolution of 240×200 with black and white colors.
+ It is the default graphics driver for the Atmos.
+
+
+
+
+Extended memory drivers
+
+No extended memory drivers are currently available for the Atmos.
+
+
+Joystick drivers
+
+
+
+
+ Supports two standard joysticks connected to the P.A.S.E. interface of the Atmos.
+
+
+
+
+Mouse drivers
+
+No mouse drivers are currently available for the Atmos.
+
+
+RS232 device drivers
+
+
+
+
+ Driver for the Telestrat integrated serial controller and the Atmos with a
+ serial add-on.
+ Note that because of the peculiarities of the 6551 chip together with the
+ use of the NMI, transmits are not interrupt driven, and the transceiver
+ blocks if the receiver asserts flow control because of a full buffer.
+
+
+
+
+
+Limitations
+
+Disk I/O
+
+The existing library for the Atmos doesn't implement C file
+I/O. There is one hack for the
+fclose
+fopen
+fread
+fprintf
+fputc
+fscanf
+fwrite
+...
+
+
+
+
+Other hints
+
+Function keys
+
+These are defined to be FUNCT + number key.
+
+Passing arguments to the program
+
+Command line arguments can be passed to
+ CALL#500:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
+
+
+
+Arguments are separated by spaces.
+Arguments may be quoted.
+Leading and trailing spaces around an argument are ignored. Spaces within
+ a quoted argument are allowed.
+The first argument passed to A maximum number of 10 arguments (including the program name) are
+ supported.
+
+
+
+Interrupts
+
+The runtime for the Atmos uses routines marked as .
+
+
+
+Bugs/Feedback
+
+If you have problems using the library, 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 ().
+
+
+
+License
+
+This software is provided 'as-is', without any expressed or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+
+ The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ Altered source versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+ This notice may not be removed or altered from any source
+ distribution.
+
+
+
+
+
+
diff --git a/doc/c128.sgml b/doc/c128.sgml
new file mode 100644
index 000000000..37cdd25f8
--- /dev/null
+++ b/doc/c128.sgml
@@ -0,0 +1,356 @@
+
+
+
+
+Commodore 128 specific information for cc65
+Ullrich von Bassewitz,
+2003-12-14
+
+
+An overview over the C128 runtime system as it is implemented for the cc65 C
+compiler.
+
+
+
+
+
+
+
+Overview
+
+This file contains an overview of the C128 runtime system as it comes with the
+cc65 C compiler. It describes the memory layout, C128 specific header files,
+available drivers, and any pitfalls specific to that platform.
+
+Please note that C128 specific functions are just mentioned here, they are
+described in detail in the separate . Even functions marked as "platform dependent" may be available on
+more than one platform. Please see the function reference for more
+information.
+
+
+Binary format
+
+The standard binary output format generated by the linker for the C128 target
+is a machine language program with a one line BASIC stub, which calls the
+machine language part via SYS. This means that a program can be loaded as
+BASIC program and started with RUN. It is of course possible to change this
+behaviour by using a modified startup file and linker config.
+
+
+Memory layout
+
+cc65 generated programs with the default setup run with the I/O area and the
+kernal ROM enabled. Note that this is a non standard memory layout, and that
+there is no "memory configuration index" for this layout. This means that
+special care has to be taken when changing the configuration, or calling any
+code that does this. The memory configuration register at $FF00 should
+be saved and restored instead of relying on the memory configuration index
+stored in the zero page.
+
+The setup gives a usable memory range of $1C00 - $BFFF. Having
+just the kernal ROM mapped in means, that kernal entry points may be called
+directly, but using the BASIC ROM is not possible without additional code.
+
+Special locations:
+
+
+
+
+
+
+Platform specific header files
+
+Programs containing C128 specific code may use the C128 specific functions
+
+The functions listed below are special for the C128. See the for declaration and usage.
+
+
+videomode
+c64mode
+fast
+slow
+
+
+
+CBM specific functions
+
+Some functions are available for all (or at least most) of the Commodore
+machines. See the for
+declaration and usage.
+
+
+cbm_close
+cbm_closedir
+cbm_k_setlfs
+cbm_k_setnam
+cbm_k_load
+cbm_k_save
+cbm_k_open
+cbm_k_close
+cbm_k_readst
+cbm_k_chkin
+cbm_k_ckout
+cbm_k_basin
+cbm_k_bsout
+cbm_k_clrch
+cbm_load
+cbm_open
+cbm_opendir
+cbm_read
+cbm_readdir
+cbm_save
+cbm_write
+get_tv
+
+
+
+Hardware access
+
+The following pseudo variables declared in the
+
+
+ The
+ The
+ The
+ Access to the two CIA (complex interface adapter) chips is available via
+ the
+ A character array that mirrors the color RAM of the C128 at $D800.
+
+
+
+
+
+Loadable drivers
+
+The names in the parentheses denote the symbols to be used for static linking of the drivers.
+
+
+Graphics drivers
+
+Note: The graphics drivers for the VDC are incompatible with the extended
+memory drivers using the VDC memory!
+
+
+
+ This driver was written by Maciej Witkowiak. It uses the 80 column display
+ and features a resolution of 640*200 with two colors and an adjustable
+ palette (that means that the two colors can be chosen out of the 16 VDC
+ colors).
+
+
+ This driver was written by Maciej Witkowiak. This driver uses the 80 column
+ display and features a resolution of 640*480 with two colors and an
+ adjustable palette (that means that the two colors can be chosen out of the
+ 16 VDC colors). The driver requires 64KB VDC RAM.
+
+
+Note: The colors are translated from definitions in headers to correct VDC values
+so please use definitions or VIC color numbers only. Colors Extended memory drivers
+
+
+
+
+ A driver for the GeoRam cartridge. The driver will always assume 2048 pages
+ of 256 bytes each. There are no checks, so if your program knows better,
+ just go ahead.
+
+
+ An extended memory driver for the RAM in page 1. The common memory area is
+ excluded, so this driver supports 251 pages of 256 bytes each.
+
+
+
+ An extended memory driver for the RAM in pages 1-3. The common memory area
+ is excluded, so this driver supports up to 731 pages of 256 bytes each. The
+ driver can be used as a full replacement for
+ A driver for the RamCart 64/128 written and contributed by Maciej Witkowiak.
+ Will test the hardware for the available RAM.
+
+
+ A driver for the CBM REUs. The driver will determine from the connected REU
+ if it supports 128KB of RAM or more. In the latter case, 256KB are assumed,
+ but since there are no range checks, the application can use more memory if
+ it has better knowledge about the hardware than the driver.
+
+
+ A driver for the VDC memory of the C128 written and contributed by Maciej
+ Witkowiak. Autodetects the amount of memory available (16 or 64K) and offers
+ 64 or 256 pages of 256 bytes each. Note: This driver is incompatible with
+ any of the graphics drivers using the VDC!
+
+
+
+
+Joystick drivers
+
+
+
+
+ Driver for the Protovision 4-player adapter originally written by Groepaz
+ for the C64 and converted for the C128 by me. See for prices and
+ building instructions. Up to four joysticks are supported.
+
+
+ Supports up to two joysticks connected to the standard joysticks port of
+ the C128.
+
+
+
+
+
+Mouse drivers
+
+
+
+
+ Supports a standard mouse connected to port #0 of the C128.
+
+
+ Supports a mouse emulated by a standard joystick e.g. 1350 mouse in port
+ #1 of the C128.
+
+
+ Supports a potentiometer device e.g. Koala Pad connected to port #1 of
+ the C128.
+
+
+
+
+RS232 device drivers
+
+
+
+
+ Driver for the SwiftLink cartridge. Supports up to 38400 baud, hardware flow
+ control (RTS/CTS) and interrupt driven receives. Note that because of the
+ peculiarities of the 6551 chip together with the use of the NMI, transmits
+ are not interrupt driven, and the transceiver blocks if the receiver asserts
+ flow control because of a full buffer.
+
+ The driver uses the RS232 variables and buffers of the kernal (buffers at
+ $C00 and $D00).
+
+
+
+
+
+Limitations
+
+
+
+Other hints
+
+Passing arguments to the program
+
+Command line arguments can be passed to
+ RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
+
+
+
+Arguments are separated by spaces.
+Arguments may be quoted.
+Leading and trailing spaces around an argument are ignored. Spaces within
+ a quoted argument are allowed.
+The first argument passed to A maximum number of 10 arguments (including the program name) are
+ supported.
+
+
+
+Program return code
+
+The program return code (low byte) is passed back to BASIC by use of the
+Interrupts
+
+The runtime for the C128 uses routines marked as .
+
+
+
+Bugs/Feedback
+
+If you have problems using the library, 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 ().
+
+
+
+License
+
+This software is provided 'as-is', without any expressed or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+
+ The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ Altered source versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+ This notice may not be removed or altered from any source
+ distribution.
+
+
+
diff --git a/doc/c16.sgml b/doc/c16.sgml
new file mode 100644
index 000000000..110082a19
--- /dev/null
+++ b/doc/c16.sgml
@@ -0,0 +1,274 @@
+
+
+
+
+Commodore 16/116 specific information for cc65
+Ullrich von Bassewitz,
+2003-12-15
+
+
+An overview over the C16 runtime system as it is implemented for the cc65 C
+compiler.
+
+
+
+
+
+
+
+Overview
+
+This file contains an overview of the C16 runtime system as it comes with the
+cc65 C compiler. It describes the memory layout, C16/116 specific header
+files, available drivers, and any pitfalls specific to that platform.
+
+Please note that C16 specific functions are just mentioned here, they are
+described in detail in the separate . Even functions marked as "platform dependent" may be available on
+more than one platform. Please see the function reference for more
+information.
+
+Since the C16/C116 and the Commodore Plus/4 are almost identical (the former
+don't have the 6551 ACIA and only 16KB of memory), the is also worth a look. The
+difference between both cc65 targets is that the Plus/4 runtime uses banking
+to support full 64K RAM, while the C16 does not use banking and supports up to
+32K RAM. Because banking is not needed, most C16 programs will be somewhat
+smaller than the same program compiled for the Plus/4. However, programs C16
+will always run on the Plus/4, while the reverse is not necessarily true.
+
+
+Binary format
+
+The standard binary output format generated by the linker for the C16/116
+target is a machine language program with a one line BASIC stub which, calls
+the machine language part via SYS. This means that a program can be loaded as
+BASIC program and started with RUN. It is of course possible to change this
+behaviour by using a modified startup file and linker config.
+
+
+Memory layout
+
+cc65 generated programs with the default setup run with the kernal and basic
+banked in. This gives a usable memory range of $1000 - $4000
+(or $8000 if the machine is equipped with 32K RAM or more). Having the
+kernal and basic ROMs banked in means, that ROM entry points may be called
+directly from user code.
+
+Special locations:
+
+
+
+
+
+
+Platform specific header files
+
+Programs containing C16 specific code may use the C16/C116 specific functions
+
+There are currently no special C16/C116 functions.
+
+
+CBM specific functions
+
+Some functions are available for all (or at least most) of the Commodore
+machines. See the for
+declaration and usage.
+
+
+cbm_close
+cbm_closedir
+cbm_k_setlfs
+cbm_k_setnam
+cbm_k_load
+cbm_k_save
+cbm_k_open
+cbm_k_close
+cbm_k_readst
+cbm_k_chkin
+cbm_k_ckout
+cbm_k_basin
+cbm_k_bsout
+cbm_k_clrch
+cbm_load
+cbm_open
+cbm_opendir
+cbm_read
+cbm_readdir
+cbm_save
+cbm_write
+get_tv
+
+
+
+Hardware access
+
+The following pseudo variables declared in the
+
+
+ The
+ A character array that mirrors the color RAM of the C16 at $0800.
+
+
+
+
+
+Loadable drivers
+
+The names in the parentheses denote the symbols to be used for static linking of the drivers.
+
+
+Graphics drivers
+
+No graphics drivers are currently available for the C16/C116.
+
+
+Extended memory drivers
+
+
+
+
+ A driver for the hidden RAM below the BASIC and KERNAL ROMs. Supports 125
+ pages with 256 bytes each if the machine is equipped with 64K of memory
+ (a Plus/4 or a memory extended C16/116).
+
+
+
+
+
+Joystick drivers
+
+
+
+
+ Supports up to two joysticks connected to the standard joysticks port of
+ the Commodore 16/116.
+
+
+
+
+
+Mouse drivers
+
+Currently no drivers available (in fact, the API for loadable mouse drivers
+does not exist).
+
+
+RS232 device drivers
+
+The Commodore 16 does not have a builtin ACIA and no RS232 extensions are
+known. For this reason, there are no RS232 drivers available. Please note that
+the standard Plus/4 driver will not run together with the C16
+library, because the latter does not support interrupts needed by the driver.
+
+
+Limitations
+
+
+
+Other hints
+
+Passing arguments to the program
+
+Command line arguments can be passed to
+ RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
+
+
+
+Arguments are separated by spaces.
+Arguments may be quoted.
+Leading and trailing spaces around an argument are ignored. Spaces within
+ a quoted argument are allowed.
+The first argument passed to A maximum number of 10 arguments (including the program name) are
+ supported.
+
+
+
+Program return code
+
+The program return code (low byte) is passed back to BASIC by use of the
+Interrupts
+
+The runtime for the C16 uses routines marked as .
+
+
+
+Bugs/Feedback
+
+If you have problems using the library, 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 ().
+
+
+
+License
+
+This software is provided 'as-is', without any expressed or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+
+ The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ Altered source versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+ This notice may not be removed or altered from any source
+ distribution.
+
+
+
+
+
+
+
diff --git a/doc/c64.sgml b/doc/c64.sgml
new file mode 100644
index 000000000..2e6a37e77
--- /dev/null
+++ b/doc/c64.sgml
@@ -0,0 +1,405 @@
+
+
+
+
+Commodore 64 specific information for cc65
+Ullrich von Bassewitz,
+2003-09-23
+
+
+An overview over the C64 runtime system as it is implemented for the cc65 C
+compiler.
+
+
+
+
+
+
+
+Overview
+
+This file contains an overview of the C64 runtime system as it comes with the
+cc65 C compiler. It describes the memory layout, C64 specific header files,
+available drivers, and any pitfalls specific to that platform.
+
+Please note that C64 specific functions are just mentioned here, they are
+described in detail in the separate . Even functions marked as "platform dependent" may be available on
+more than one platform. Please see the function reference for more
+information.
+
+
+Binary format
+
+The standard binary output format generated by the linker for the C64 target
+is a machine language program with a one line BASIC stub, which calls the
+machine language part via SYS. This means that a program can be loaded as
+BASIC program and started with RUN. It is of course possible to change this
+behaviour by using a modified startup file and linker config.
+
+
+Memory layout
+
+cc65 generated programs with the default setup run with the I/O area and the
+kernal ROM enabled (memory under the kernal may be used for graphics or as
+extended memory - see the sections about graphics and extended memory
+drivers). The BASIC ROM is disabled, which gives a usable memory range of
+$0800 - $CFFF. This means that kernal entry points may be called
+directly, but using the BASIC ROM is not possible without additional code.
+
+Special locations:
+
+
+
+
+
+Linker configurations
+
+The ld65 linker comes with a builtin config file for the Commodore 64,
+which is used via builtin config file
+
+The builtin configuration is tailored to C programs. It supplies the load
+address and a small BASIC stub that starts the compiled program using a SYS
+command.
+
+
+
+
+This configuration is made for assembler programmers who don't need a special
+setup. The default start address is $801. It can be changed with the
+linker command line option
+cl65 -o file.prg -t c64 -C c64-asm.cfg source.s
+
+
+To generate code that loads to $C000:
+
+
+cl65 -o file.prg --start-addr $C000 -t c64 -C c64-asm.cfg source.s
+
+
+It is also possible to add a small BASIC header to the program, that uses SYS
+to jump to the program entry point (which is the start of the code segment).
+The advantage is that the program can be started using RUN.
+
+To generate a program with a BASIC SYS header, use
+
+
+cl65 -o file.prg -u __EXEHDR__ -t c64 -C c64-asm.cfg source.s
+
+
+Please note that in this case a changed start address doesn't make sense,
+since the program must be loaded to the BASIC start address.
+
+
+Platform specific header files
+
+Programs containing C64 specific code may use the C64 specific functions
+
+The functions listed below are special for the C64. See the for declaration and usage.
+
+
+get_ostype
+
+
+
+CBM specific functions
+
+Some functions are available for all (or at least most) of the Commodore
+machines. See the for
+declaration and usage.
+
+
+cbm_close
+cbm_closedir
+cbm_k_setlfs
+cbm_k_setnam
+cbm_k_load
+cbm_k_save
+cbm_k_open
+cbm_k_close
+cbm_k_readst
+cbm_k_chkin
+cbm_k_ckout
+cbm_k_basin
+cbm_k_bsout
+cbm_k_clrch
+cbm_load
+cbm_open
+cbm_opendir
+cbm_read
+cbm_readdir
+cbm_save
+cbm_write
+get_tv
+
+
+
+Hardware access
+
+The following pseudo variables declared in the
+
+
+ The
+ The
+ Access to the two CIA (complex interface adapter) chips is available via
+ the
+ A character array that mirrors the color RAM of the C64 at $D800.
+
+
+
+
+
+Loadable drivers
+
+The names in the parentheses denote the symbols to be used for static linking of the drivers.
+
+
+Graphics drivers
+
+Note: All available graphics drivers for the TGI interface will use
+the space below the I/O area and kernal ROM, so you can have hires graphics in
+the standard setup without any memory loss or need for a changed
+configuration.
+
+
+
+ This driver features a resolution of 320*200 with two colors and an
+ adjustable palette (that means that the two colors can be chosen out of a
+ palette of the 16 C64 colors).
+
+
+
+Extended memory drivers
+
+
+
+
+ A driver for the C64 256K memory expansion. This driver offers 768 pages of
+ 256 bytes each. Written and contributed by Marco van den Heuvel.
+
+
+ A driver for the Double Quick Brown Box cartridge. This driver offers
+ 64 pages of 256 bytes each. Written and contributed by Marco van den Heuvel.
+
+
+ A driver for the Berkeley Softworks GeoRam cartridge. The driver will
+ determine the available RAM from the connected cartridge. It supports 64KB
+ up to 2048KB of RAM.
+
+
+ A driver for the ISEPIC cartridge. This driver offers just 8 pages of 256
+ bytes each. Written and contributed by Marco van den Heuvel.
+
+
+ A driver for the hidden RAM below the I/O area and kernal ROM. Supports 48
+ 256 byte pages. Please note that this driver is incompatible with any of the
+ graphics drivers!
+
+
+ A driver for the RamCart 64/128 written and contributed by Maciej Witkowiak.
+ Will test the hardware for the available RAM.
+
+
+ A driver for the CBM REUs. The driver will determine from the connected REU
+ if it supports 128KB of RAM or more. In the latter case, 256KB are assumed,
+ but since there are no range checks, the application can use more memory if
+ it has better knowledge about the hardware than the driver.
+
+
+ A driver for the VDC memory of the C128. Written and contributed by Maciej
+ Witkowiak. Can be used if the program is running in C64 mode of the C128.
+ Autodetects the amount of memory available (16 or 64K) and offers 64 or 256
+ pages of 256 bytes each.
+
+
+ A driver for the C64 D2TV (the second or PAL version). This driver offers
+ indeed 7680 pages of 256 bytes each.
+
+
+
+
+Joystick drivers
+
+
+
+
+ Driver for the Digital Excess & Hitmen adapter contributed by Groepaz. See
+ on
+ instructions how to build one. Up to four joysticks are supported.
+
+
+ Driver for the Protovision 4-player adapter contributed by Groepaz. See
+ for prices and
+ building instructions. Up to four joysticks are supported.
+
+
+ Supports up to two standard joysticks connected to the joysticks port of
+ the C64.
+
+
+ Supports one joystick emulated by the numberpad of the C128 in C64 mode,
+ the firebutton is labeled &dquot;5&dquot; and ENTER.
+
+
+
+
+Mouse drivers
+
+
+
+
+ Supports a standard mouse connected to port #0 of the C64.
+
+
+ Supports a mouse emulated by a standard joystick e.g. 1350 mouse in port
+ #1 of the C64.
+
+
+ Supports a potentiometer device e.g. Koala Pad connected to port #1 of
+ the C64.
+
+
+
+
+RS232 device drivers
+
+
+
+
+ Driver for the SwiftLink cartridge. Supports up to 38400 baud, hardware flow
+ control (RTS/CTS) and interrupt driven receives. Note that because of the
+ peculiarities of the 6551 chip together with the use of the NMI, transmits
+ are not interrupt driven, and the transceiver blocks if the receiver asserts
+ flow control because of a full buffer.
+
+
+
+
+
+Limitations
+
+
+
+Other hints
+
+Escape code
+
+For an Esc press CTRL and [ key.
+
+Passing arguments to the program
+
+Command line arguments can be passed to
+ RUN:REM ARG1 " ARG2 IS QUOTED" ARG3 "" ARG5
+
+
+
+Arguments are separated by spaces.
+Arguments may be quoted.
+Leading and trailing spaces around an argument are ignored. Spaces within
+ a quoted argument are allowed.
+The first argument passed to A maximum number of 10 arguments (including the program name) are
+ supported.
+
+
+
+Program return code
+
+The program return code (low byte) is passed back to BASIC by use of the
+Interrupts
+
+The runtime for the C64 uses routines marked as .
+
+
+
+Bugs/Feedback
+
+If you have problems using the library, 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 ().
+
+
+
+License
+
+This software is provided 'as-is', without any expressed or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+
+ The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ Altered source versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+ This notice may not be removed or altered from any source
+ distribution.
+
+
+
diff --git a/doc/ca65.sgml b/doc/ca65.sgml
new file mode 100644
index 000000000..00d72db56
--- /dev/null
+++ b/doc/ca65.sgml
@@ -0,0 +1,4786 @@
+
+
+
+ca65 Users Guide
+Ullrich von Bassewitz,
+2000-07-19, 2000-11-29, 2001-10-02, 2005-09-08
+
+
+ca65 is a powerful 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.
+
+
+
+
+
+
+
+Overview
+
+ca65 is a replacement for the ra65 assembler that was part of the cc65 C
+compiler, originally developed by John R. Dunning. I had some problems with
+ra65 and the copyright does not permit some things which I wanted to be
+possible, so I decided to write a completely new assembler/linker/archiver
+suite for the cc65 compiler. ca65 is part of this suite.
+
+Some parts of the assembler (code generation and some routines for symbol
+table handling) are taken from an older crossassembler named a816 written
+by me a long time ago.
+
+
+Design criteria
+
+Here's a list of the design criteria, that I considered important for the
+development:
+
+
+
+ The assembler must support macros. Macros are not essential, but they
+ make some things easier, especially when you use the assembler in the
+ backend of a compiler.
+ The assembler must support the newer 65C02 and 65816 CPUs. I have been
+ thinking about a 65816 backend for the C compiler, and even my old
+ a816 assembler had support for these CPUs, so this wasn't really a
+ problem.
+ The assembler must produce relocatable code. This is necessary for the
+ compiler support, and it is more convenient.
+ Conditional assembly must be supported. This is a must for bigger
+ projects written in assembler (like Elite128).
+ The assembler must support segments, and it must support more than
+ three segments (this is the count, most other assemblers support).
+ Having more than one code segments helps developing code for systems
+ with a divided ROM area (like the C64).
+ The linker must be able to resolve arbitrary expressions. It should
+ be able to get things like
+
+ .import S1, S2
+ .export Special
+ Special = 2*S1 + S2/7
+
+ right.
+ True lexical nesting for symbols. This is very convenient for larger
+ assembly projects.
+ "Cheap" local symbols without lexical nesting for those quick, late
+ night hacks.
+ I liked the idea of "options" as Anre Fachats .o65 format has it, so I
+ introduced the concept into the object file format use by the new cc65
+ binutils.
+ The assembler will be a one pass assembler. There was no real need for
+ this decision, but I've written several multipass assemblers, and it
+ started to get boring. A one pass assembler needs much more elaborated
+ data structures, and because of that it's much more fun:-)
+ Non-GPLed code that may be used in any project without restrictions or
+ fear of "GPL infecting" other code.
+
+
+
+
+Usage
+
+
+Command line option overview
+
+The assembler accepts the following options:
+
+
+---------------------------------------------------------------------------
+Usage: ca65 [options] file
+Short options:
+ -D name[=value] Define a symbol
+ -I dir Set an include directory search path
+ -U Mark unresolved symbols as import
+ -V Print the assembler version
+ -W n Set warning level n
+ -d Debug mode
+ -g Add debug info to object file
+ -h Help (this text)
+ -i Ignore case of symbols
+ -l name Create a listing file if assembly was ok
+ -mm model Set the memory model
+ -o name Name the output file
+ -s Enable smart mode
+ -t sys Set the target system
+ -v Increase verbosity
+
+Long options:
+ --auto-import Mark unresolved symbols as import
+ --bin-include-dir dir Set a search path for binary includes
+ --cpu type Set cpu type
+ --create-dep name Create a make dependency file
+ --create-full-dep name Create a full make dependency file
+ --debug Debug mode
+ --debug-info Add debug info to object file
+ --feature name Set an emulation feature
+ --forget-inc-paths Forget include search paths
+ --help Help (this text)
+ --ignore-case Ignore case of symbols
+ --include-dir dir Set an include directory search path
+ --large-alignment Don't warn about large alignments
+ --listing name Create a listing file if assembly was ok
+ --list-bytes n Maximum number of bytes per listing line
+ --macpack-dir dir Set a macro package directory
+ --memory-model model Set the memory model
+ --pagelength n Set the page length for the listing
+ --relax-checks Relax some checks (see docs)
+ --smart Enable smart mode
+ --target sys Set the target system
+ --verbose Increase verbosity
+ --version Print the assembler version
+---------------------------------------------------------------------------
+
+
+
+Command line options in detail
+
+Here is a description of all the command line options:
+
+
+
+
+ --bin-include-dir dir
+
+ Name a directory which is searched for binary include files. The option
+ may be used more than once to specify more than one directory to search. The
+ current directory is always searched first before considering any
+ additional directories. See also the section about .
+
+
+
+ --cpu type
+
+ Set the default for the CPU type. The option takes a parameter, which
+ may be one of
+
+ 6502, 65SC02, 65C02, 65816, sunplus, sweet16, HuC6280
+
+ The sunplus cpu is not available in the freeware version, because the
+ instruction set is "proprietary and confidential".
+
+
+
+ --create-dep name
+
+ Tells the assembler to generate a file containing the dependency list for
+ the assembled module in makefile syntax. The output is written to a file
+ with the given name. The output does not include files passed via debug
+ information to the assembler.
+
+
+
+ --create-full-dep name
+
+ Tells the assembler to generate a file containing the dependency list for
+ the assembled module in makefile syntax. The output is written to a file
+ with the given name. The output does include files passed via debug
+ information to the assembler.
+
+
+ -d, --debug
+
+ Enables debug mode, something that should not be needed for mere
+ mortals:-)
+
+
+
+ --feature name
+
+ Enable an emulation feature. This is identical as using
+ command for a list of emulation features.
+
+
+
+ --forget-inc-paths
+
+ Forget the builtin include paths. This is most useful when building
+ customized assembler modules, in which case the standard header files should
+ be ignored.
+
+
+
+ -g, --debug-info
+
+ When this option (or the equivalent control command
+ -h, --help
+
+ Print the short option summary shown above.
+
+
+
+ -i, --ignore-case
+
+ This option makes the assembler case insensitive on identifiers and labels.
+ This option will override the default, but may itself be overridden by the
+ control command.
+
+
+
+ -l name, --listing name
+
+ Generate an assembler listing with the given name. A listing file will
+ never be generated in case of assembly errors.
+
+
+
+ --large-alignment
+
+ Disable warnings about a large combined alignment. See the discussion of the
+ directive for futher information.
+
+
+
+ --list-bytes n
+
+ Set the maximum number of bytes printed in the listing for one line of
+ input. See the directive
+ for more information. The value zero can be used to encode an unlimited
+ number of printed bytes.
+
+
+
+ --macpack-dir dir
+
+ This options allows to specify a directory containing macro files that are
+ used instead of the builtin images when a directive is encountered. If --macpack-dir
+ was specified, a .mac extension is added to the package name and
+ the resulting file is loaded from the given directory. This is most useful
+ when debugging the builtin macro packages.
+
+
+
+ -mm model, --memory-model model
+
+ Define the default memory model. Possible model specifiers are near, far and
+ huge.
+
+
+
+ -o name
+
+ The default output name is the name of the input file with the extension
+ replaced by ".o". If you don't like that, you may give another name with
+ the -o option. The output file will be placed in the same directory as
+ the source file, or, if -o is given, the full path in this name is used.
+
+
+
+ --pagelength n
+
+ sets the length of a listing page in lines. See the directive for more information.
+
+
+
+ --relax-checks
+
+ Relax some checks done by the assembler. This will allow code that is an
+ error in most cases and flagged as such by the assembler, but can be valid
+ in special situations.
+
+ Examples are:
+
+Short branches between two different segments.
+Byte sized address loads where the address is not a zeropage address.
+
+
+
+
+ -s, --smart-mode
+
+ In smart mode (enabled by -s or the
+ pseudo instruction) the assembler will track usage of the
+ -t sys, --target sys
+
+ Set the target system. This will enable translation of character strings and
+ character constants into the character set of the target platform. 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
+ compiler, see there for a list.
+
+ Depending on the target, the default CPU type is also set. This can be
+ overriden by using the / option.
+
+
+
+ -v, --verbose
+
+ Increase the assembler verbosity. Usually only needed for debugging
+ purposes. You may use this option more than one time for even more
+ verbose output.
+
+
+
+ -D
+
+ This option allows you to define symbols on the command line. Without a
+ value, the symbol is defined with the value zero. When giving a value,
+ you may use the '$' prefix for hexadecimal symbols. Please note
+ that for some operating systems, '$' has a special meaning, so
+ you may have to quote the expression.
+
+
+
+ -I dir, --include-dir dir
+
+ Name a directory which is searched for include files. The option may be
+ used more than once to specify more than one directory to search. The
+ current directory is always searched first before considering any
+ additional directories. See also the section about .
+
+
+
+ -U, --auto-import
+
+ Mark symbols that are not defined in the sources as imported symbols. This
+ should be used with care since it delays error messages about typos and such
+ until the linker is run. The compiler uses the equivalent of this switch
+ () to enable auto imported
+ symbols for the runtime library. However, the compiler is supposed to
+ generate code that runs through the assembler without problems, something
+ which is not always true for assembler programmers.
+
+
+
+ -V, --version
+
+ Print the version number of the assembler. If you send any suggestions
+ or bugfixes, please include the version number.
+
+
+
+ -Wn
+
+ Set the warning level for the assembler. Using -W2 the assembler will
+ even warn about such things like unused imported symbols. The default
+ warning level is 1, and it would probably be silly to set it to
+ something lower.
+
+
+
+
+
+
+Search paths
+
+Normal include files are searched in the following places:
+
+
+The current directory.
+A compiled-in directory, which is often /usr/lib/cc65/asminc
+ on Linux systems.
+The value of the environment variable A subdirectory named Any directory added with the / option
+on the command line.
+
+
+Binary include files are searched in the following places:
+
+
+The current directory.
+Any directory added with the / option on the command line.
+
+
+
+
+Input format
+
+Assembler syntax
+
+The assembler accepts the standard 6502/65816 assembler syntax. One line may
+contain a label (which is identified by a colon), and, in addition to the
+label, an assembler mnemonic, a macro, or a control command (see section for supported control
+commands). Alternatively, the line may contain a symbol definition using
+the '=' token. Everything after a semicolon is handled as a comment (that is,
+it is ignored).
+
+Here are some examples for valid input lines:
+
+
+ Label: ; A label and a comment
+ lda #$20 ; A 6502 instruction plus comment
+ L1: ldx #$20 ; Same with label
+ L2: .byte "Hello world" ; Label plus control command
+ mymac $20 ; Macro expansion
+ MySym = 3*L1 ; Symbol definition
+ MaSym = Label ; Another symbol
+
+
+The assembler accepts
+
+
+all valid 6502 mnemonics when in 6502 mode (the default or after the
+ command was given).
+all valid 6502 mnemonics plus a set of illegal instructions when in
+ .
+all valid 65SC02 mnemonics when in 65SC02 mode (after the
+ command was given).
+all valid 65C02 mnemonics when in 65C02 mode (after the
+ command was given).
+all valid 65618 mnemonics when in 65816 mode (after the
+ command was given).
+all valid SunPlus mnemonics when in SunPlus mode (after the
+ command was given).
+
+
+
+65816 mode
+
+In 65816 mode several aliases are accepted in addition to the official
+mnemonics:
+
+
+ BGE is an alias for BCS
+ BLT is an alias for BCC
+ CPA is an alias for CMP
+ DEA is an alias for DEC A
+ INA is an alias for INC A
+ SWA is an alias for XBA
+ TAD is an alias for TCD
+ TAS is an alias for TCS
+ TDA is an alias for TDC
+ TSA is an alias for TSC
+
+
+
+
+6502X mode
+
+6502X mode is an extension to the normal 6502 mode. In this mode, several
+mnemonics for illegal instructions of the NMOS 6502 CPUs are accepted. Since
+these instructions are illegal, there are no official mnemonics for them. The
+unofficial ones are taken from . Please note that only the
+ones marked as "stable" are supported. The following table uses information
+from the mentioned web page, for more information, see there.
+
+
+ALR: A:=(A and #{imm})/2;
+ANC: A:=A and #{imm}; Generates opcode $0B.
+ARR: A:=(A and #{imm})/2;
+AXS: X:=A and X-#{imm};
+DCP: {adr}:={adr}-1; A-{adr};
+ISC: {adr}:={adr}+1; A:=A-{adr};
+LAS: A,X,S:={adr} and S;
+LAX: A,X:={adr};
+RLA: {adr}:={adr}rol; A:=A and {adr};
+RRA: {adr}:={adr}ror; A:=A adc {adr};
+SAX: {adr}:=A and X;
+SLO: {adr}:={adr}*2; A:=A or {adr};
+SRE: {adr}:={adr}/2; A:=A xor {adr};
+
+
+
+
+sweet16 mode
+
+SWEET 16 is an interpreter for a pseudo 16 bit CPU written by Steve Wozniak
+for the Apple ][ machines. It is available in the Apple ][ ROM. ca65 can
+generate code for this pseudo CPU when switched into sweet16 mode. The
+following is special in sweet16 mode:
+
+
+
+The '@' character denotes indirect addressing and is no longer available
+for cheap local labels. If you need cheap local labels, you will have to
+switch to another lead character using the / command.
+
+Registers are specified using
+
+Please note that the assembler does neither supply the interpreter needed for
+SWEET 16 code, nor the zero page locations needed for the SWEET 16 registers,
+nor does it call the interpreter. All this must be done by your program. Apple
+][ programmers do probably know how to use sweet16 mode.
+
+For more information about SWEET 16, see
+.
+
+
+Number format
+
+For literal values, the assembler accepts the widely used number formats: A
+preceding '$' or a trailing 'h' denotes a hex value, a preceding '%'
+denotes a binary value, and a bare number is interpreted as a decimal. There
+are currently no octal values and no floats.
+
+
+Conditional assembly
+
+Please note that when using the conditional directives (
+
+
+Expressions
+
+
+Expression evaluation
+
+All expressions are evaluated with (at least) 32 bit precision. An
+expression may contain constant values and any combination of internal and
+external symbols. Expressions that cannot be evaluated at assembly time
+are stored inside the object file for evaluation by the linker.
+Expressions referencing imported symbols must always be evaluated by the
+linker.
+
+
+Size of an expression result
+
+Sometimes, the assembler must know about the size of the value that is the
+result of an expression. This is usually the case, if a decision has to be
+made, to generate a zero page or an absolute memory references. In this
+case, the assembler has to make some assumptions about the result of an
+expression:
+
+
+ If the result of an expression is constant, the actual value is
+ checked to see if it's a byte sized expression or not.
+ If the expression is explicitly casted to a byte sized expression by
+ one of the '>', '<' or '^' operators, it is a byte expression.
+ If this is not the case, and the expression contains a symbol,
+ explicitly declared as zero page symbol (by one of the .importzp or
+ .exportzp instructions), then the whole expression is assumed to be
+ byte sized.
+ If the expression contains symbols that are not defined, and these
+ symbols are local symbols, the enclosing scopes are searched for a
+ symbol with the same name. If one exists and this symbol is defined,
+ its attributes are used to determine the result size.
+ In all other cases the expression is assumed to be word sized.
+
+
+Note: If the assembler is not able to evaluate the expression at assembly
+time, the linker will evaluate it and check for range errors as soon as
+the result is known.
+
+
+Boolean expressions
+
+In the context of a boolean expression, any non zero value is evaluated as
+true, any other value to false. The result of a boolean expression is 1 if
+it's true, and zero if it's false. There are boolean operators with extreme
+low precedence with version 2.x (where x > 0). The Constant expressions
+
+Sometimes an expression must evaluate to a constant without looking at any
+further input. One such example is the / command
+that decides if parts of the code are assembled or not. An expression used in
+the Available operators
+
+To force a specific order of evaluation, parentheses may be used, as usual.
+
+
+
+Symbols and labels
+
+A symbol or label is an identifier that starts with a letter and is followed
+by letters and digits. Depending on some features enabled (see
+,
+ and
+)
+other characters may be present. Use of identifiers consisting of a single
+character will not work in all cases, because some of these identifiers are
+reserved keywords (for example "A" is not a valid identifier for a label,
+because it is the keyword for the accumulator).
+
+The assembler allows you to use symbols instead of naked values to make
+the source more readable. There are a lot of different ways to define and
+use symbols and labels, giving a lot of flexibility.
+
+Numeric constants
+
+Numeric constants are defined using the equal sign or the label assignment
+operator. After doing
+
+
+ two = 2
+
+
+may use the symbol "two" in every place where a number is expected, and it is
+evaluated to the value 2 in this context. The label assignment operator is
+almost identical, but causes the symbol to be marked as a label, so it may be
+handled differently in a debugger:
+
+
+ io := $d000
+
+
+The right side can of course be an expression:
+
+
+ four = two * two
+
+
+
+
+Numeric variables
+
+Within macros and other control structures (, ...) it is sometimes useful to have some sort of
+variable. This can be achieved by the .SET operator. It creates a
+symbol that may get assigned a different value later:
+
+
+ four .set 4
+ lda #four ; Loads 4 into A
+ four .set 3
+ lda #four ; Loads 3 into A
+
+
+Since the value of the symbol can change later, it must be possible to
+evaluate it when used (no delayed evaluation as with normal symbols). So the
+expression used as the value must be constant.
+
+Following is an example for a macro that generates a different label each time
+it is used. It uses the function
+and a numeric variable named lcount.
+
+
+ .lcount .set 0 ; Initialize the counter
+
+ .macro genlab
+ .ident (.sprintf ("L%04X", lcount)):
+ lcount .set lcount + 1
+ .endmacro
+
+
+
+Standard labels
+
+A label is defined by writing the name of the label at the start of the line
+(before any instruction mnemonic, macro or pseudo directive), followed by a
+colon. This will declare a symbol with the given name and the value of the
+current program counter.
+
+
+Local labels and symbols
+
+Using the directive, it is possible to
+create regions of code where the names of labels and symbols are local to this
+region. They are not known outside of this region and cannot be accessed from
+there. Such regions may be nested like PROCEDUREs in Pascal.
+
+See the description of the
+directive for more information.
+
+
+Cheap local labels
+
+Cheap local labels are defined like standard labels, but the name of the
+label must begin with a special symbol (usually '@', but this can be
+changed by the
+directive).
+
+Cheap local labels are visible only between two non cheap labels. As soon as a
+standard symbol is encountered (this may also be a local symbol if inside a
+region defined with the directive), the
+cheap local symbol goes out of scope.
+
+You may use cheap local labels as an easy way to reuse common label
+names like "Loop". Here is an example:
+
+
+ Clear: lda #$00 ; Global label
+ ldy #$20
+ @Loop: sta Mem,y ; Local label
+ dey
+ bne @Loop ; Ok
+ rts
+ Sub: ... ; New global label
+ bne @Loop ; ERROR: Unknown identifier!
+
+
+Unnamed labels
+
+If you really want to write messy code, there are also unnamed labels. These
+labels do not have a name (you guessed that already, didn't you?). A colon is
+used to mark the absence of the name.
+
+Unnamed labels may be accessed by using the colon plus several minus or plus
+characters as a label designator. Using the '-' characters will create a back
+reference (use the n'th label backwards), using '+' will create a forward
+reference (use the n'th label in forward direction). An example will help to
+understand this:
+
+
+ : lda (ptr1),y ; #1
+ cmp (ptr2),y
+ bne :+ ; -> #2
+ tax
+ beq :+++ ; -> #4
+ iny
+ bne :- ; -> #1
+ inc ptr1+1
+ inc ptr2+1
+ bne :- ; -> #1
+
+ : bcs :+ ; #2 -> #3
+ ldx #$FF
+ rts
+
+ : ldx #$01 ; #3
+ : rts ; #4
+
+
+As you can see from the example, unnamed labels will make even short
+sections of code hard to understand, because you have to count labels
+to find branch targets (this is the reason why I for my part do
+prefer the "cheap" local labels). Nevertheless, unnamed labels are
+convenient in some situations, so it's your decision.
+
+ organize named symbols, not
+unnamed ones, so scopes don't have an effect on unnamed labels.
+
+
+
+Using macros to define labels and constants
+
+While there are drawbacks with this approach, it may be handy in a few rare
+situations. Using , it is possible
+to define symbols or constants that may be used elsewhere. One of the
+advantages is that you can use it to define string constants (this is not
+possible with the other symbol types).
+
+Please note:
+ .DEFINE two 2
+ .DEFINE version "SOS V2.3"
+
+ four = two * two ; Ok
+ .byte version ; Ok
+
+ .PROC ; Start local scope
+ two = 3 ; Will give "2 = 3" - invalid!
+ .ENDPROC
+
+
+
+Symbols and .DEBUGINFO
+
+If is enabled (or is given on the command line), global, local and
+cheap local labels are written to the object file and will be available in the
+symbol file via the linker. Unnamed labels are not written to the object file,
+because they don't have a name which would allow to access them.
+
+
+
+Scopes
+
+ca65 implements several sorts of scopes for symbols.
+
+Global scope
+
+All (non cheap local) symbols that are declared outside of any nested scopes
+are in global scope.
+
+
+Cheap locals
+
+A special scope is the scope for cheap local symbols. It lasts from one non
+local symbol to the next one, without any provisions made by the programmer.
+All other scopes differ in usage but use the same concept internally.
+
+
+Generic nested scopes
+
+A nested scoped for generic use is started with / and closed with /.
+The scope can have a name, in which case it is accessible from the outside by
+using . If the scope does not
+have a name, all symbols created within the scope are local to the scope, and
+aren't accessible from the outside.
+
+A nested scope can access symbols from the local or from enclosing scopes by
+name without using explicit scope names. In some cases there may be
+ambiguities, for example if there is a reference to a local symbol that is not
+yet defined, but a symbol with the same name exists in outer scopes:
+
+
+ .scope outer
+ foo = 2
+ .scope inner
+ lda #foo
+ foo = 3
+ .endscope
+ .endscope
+
+
+In the example above, the
+ .scope outer
+ foo = $1234
+ .scope inner
+ lda foo,x
+ foo = $12
+ .endscope
+ .endscope
+
+
+Here,
+ .scope outer
+ foo = $12
+ .scope inner
+ lda foo,x
+ foo = $1234
+ .endscope
+ .endscope
+
+
+In this case, when the assembler sees the symbol
+ .scope outer
+ foo = $12
+ .scope inner
+ lda a:foo,x
+ foo = $1234
+ .endscope
+ .endscope
+
+
+This will cause the Nested procedures
+
+A nested procedure is created by use of /. It
+differs from a / in that it must have a
+name, and a it will introduce a symbol with this name in the enclosing scope.
+So
+
+
+ .proc foo
+ ...
+ .endproc
+
+
+is actually the same as
+
+
+ foo:
+ .scope foo
+ ...
+ .endscope
+
+
+This is the reason why a procedure must have a name. If you want a scope
+without a name, use /.
+
+).
+
+
+Structs, unions and enums
+
+Structs, unions and enums are explained in a , I do only cover them here, because if they are declared with a
+name, they open a nested scope, similar to /. However, when no name is specified, the behaviour is
+different: In this case, no new scope will be opened, symbols declared within
+a struct, union, or enum declaration will then be added to the enclosing scope
+instead.
+
+
+Explicit scope specification
+
+Accessing symbols from other scopes is possible by using an explicit scope
+specification, provided that the scope where the symbol lives in has a name.
+The namespace token (
+ .scope foo
+ bar: .word 0
+ .endscope
+
+ ...
+ lda foo::bar ; Access foo in scope bar
+
+
+The only way to deny access to a scope from the outside is to declare a scope
+without a name (using the / command).
+
+A special syntax is used to specify the global scope: If a symbol or scope is
+preceded by the namespace token, the global scope is searched:
+
+
+ bar = 3
+
+ .scope foo
+ bar = 2
+ lda #::bar ; Access the global bar (which is 3)
+ .endscope
+
+
+
+Scope search order
+
+The assembler searches for a scope in a similar way as for a symbol. First, it
+looks in the current scope, and then it walks up the enclosing scopes until
+the scope is found.
+
+However, one important thing to note when using explicit scope syntax is, that
+a symbol may be accessed before it is defined, but a scope may
+ .scope foo
+ bar = 3
+ .endscope
+
+ .scope outer
+ lda #foo::bar ; Will load 3, not 2!
+ .scope foo
+ bar = 2
+ .endscope
+ .endscope
+
+
+the reference to the scope
+ .scope foo
+ .scope outer
+ .scope inner
+ bar = 1
+ .endscope
+ .endscope
+ .scope another
+ .scope nested
+ lda #outer::inner::bar ; 1
+ .endscope
+ .endscope
+ .endscope
+
+ .scope outer
+ .scope inner
+ bar = 2
+ .endscope
+ .endscope
+
+
+When
+ .scope foo
+ .scope outer
+ .scope inner
+ bar = 1
+ .endscope
+ .endscope
+ .scope another
+ .scope nested
+ lda #::outer::inner::bar ; 2
+ .endscope
+ .endscope
+ .endscope
+
+ .scope outer
+ .scope inner
+ bar = 2
+ .endscope
+ .endscope
+
+
+
+Address sizes and memory models
+
+Address sizes
+
+ca65 assigns each segment and each symbol an address size. This is true, even
+if the symbol is not used as an address. You may also think of a value range
+of the symbol instead of an address size.
+
+Possible address sizes are:
+
+
+Zeropage or direct (8 bits)
+Absolute (16 bits)
+Far (24 bits)
+Long (32 bits)
+
+
+Since the assembler uses default address sizes for the segments and symbols,
+it is usually not necessary to override the default behaviour. In cases, where
+it is necessary, the following keywords may be used to specify address sizes:
+
+
+DIRECT, ZEROPAGE or ZP for zeropage addressing (8 bits).
+ABSOLUTE, ABS or NEAR for absolute addressing (16 bits).
+FAR for far addressing (24 bits).
+LONG or DWORD for long addressing (32 bits).
+
+
+
+Address sizes of segments
+
+The assembler assigns an address size to each segment. Since the
+representation of a label within this segment is "segment start + offset",
+labels will inherit the address size of the segment they are declared in.
+
+The address size of a segment may be changed, by using an optional address
+size modifier. See the / for
+an explanation on how this is done.
+
+
+Address sizes of symbols
+
+
+
+
+Memory models
+
+The default address size of a segment depends on the memory model used. Since
+labels inherit the address size from the segment they are declared in,
+changing the memory model is an easy way to change the address size of many
+symbols at once.
+
+
+
+
+Pseudo variables
+
+Pseudo variables are readable in all cases, and in some special cases also
+writable.
+
+*
+
+ Reading this pseudo variable will return the program counter at the start
+ of the current input line.
+
+ Assignment to this variable is possible when / is used. Note: You should not use
+ assignments to / instead.
+
+
+.CPU
+
+ Reading this pseudo variable will give a constant integer value that
+ tells which CPU is currently enabled. It can also tell which instruction
+ set the CPU is able to translate. The value read from the pseudo variable
+ should be further examined by using one of the constants defined by the
+ "cpu" macro package (see /).
+
+ It may be used to replace the .IFPxx pseudo instructions or to construct
+ even more complex expressions.
+
+ Example:
+
+
+ .macpack cpu
+ .if (.cpu .bitand CPU_ISET_65816)
+ phx
+ phy
+ .else
+ txa
+ pha
+ tya
+ pha
+ .endif
+
+
+
+.PARAMCOUNT
+
+ This builtin pseudo variable is only available in macros. It is replaced by
+ the actual number of parameters that were given in the macro invocation.
+
+ Example:
+
+
+ .macro foo arg1, arg2, arg3
+ .if .paramcount <> 3
+ .error "Too few parameters for macro foo"
+ .endif
+ ...
+ .endmacro
+
+
+ See section .
+
+
+.TIME
+
+ Reading this pseudo variable will give a constant integer value that
+ represents the current time in POSIX standard (as seconds since the
+ Epoch).
+
+ It may be used to encode the time of translation somewhere in the created
+ code.
+
+ Example:
+
+
+ .dword .time ; Place time here
+
+
+
+.VERSION
+
+ Reading this pseudo variable will give the assembler version according to
+ the following formula:
+
+ VER_MAJOR*$100 + VER_MINOR*$10 + VER_PATCH
+
+ It may be used to encode the assembler version or check the assembler for
+ special features not available with older versions.
+
+ Example:
+
+ Version 2.11.1 of the assembler will return $2B1 as numerical constant when
+ reading the pseudo variable Pseudo functions
+
+Pseudo functions expect their arguments in parenthesis, and they have a result,
+either a string or an expression.
+
+
+.BANK
+
+ The or similar functions to address just part of it.
+
+ Please note that
+ .segment "BANK1"
+ .proc banked_func_1
+ ...
+ .endproc
+
+ .segment "BANK2"
+ .proc banked_func_2
+ ...
+ .endproc
+
+ .proc bank_table
+ .addr banked_func_1
+ .byte <.BANK (banked_func_1)
+
+ .addr banked_func_2
+ .byte <.BANK (banked_func_2)
+ .endproc
+
+
+
+
+.BANKBYTE
+
+ The function returns the bank byte (that is, bits 16-23) of its argument.
+ It works identical to the '^' operator.
+
+ See: ,
+
+
+
+.BLANK
+
+ Builtin function. The function evaluates its argument in braces and yields
+ "false" if the argument is non blank (there is an argument), and "true" if
+ there is no argument. The token list that makes up the function argument
+ may optionally be enclosed in curly braces. This allows the inclusion of
+ tokens that would otherwise terminate the list (the closing right
+ parenthesis). The curly braces are not considered part of the list, a list
+ just consisting of curly braces is considered to be empty.
+
+ As an example, the
+ .if .blank({arg})
+
+
+
+
+.CONCAT
+
+ Builtin string function. The function allows to concatenate a list of string
+ constants separated by commas. The result is a string constant that is the
+ concatenation of all arguments. This function is most useful in macros and
+ when used together with the
+ .include .concat ("myheader", ".", "inc")
+
+
+ This is the same as the command
+
+
+ .include "myheader.inc"
+
+
+
+.CONST
+
+ Builtin function. The function evaluates its argument in braces and
+ yields "true" if the argument is a constant expression (that is, an
+ expression that yields a constant value at assembly time) and "false"
+ otherwise. As an example, the .IFCONST statement may be replaced by
+
+
+ .if .const(a + 3)
+
+
+
+.HIBYTE
+
+ The function returns the high byte (that is, bits 8-15) of its argument.
+ It works identical to the '>' operator.
+
+ See: ,
+
+
+
+.HIWORD
+
+ The function returns the high word (that is, bits 16-31) of its argument.
+
+ See:
+
+
+.IDENT
+
+ The function expects a string as its argument, and converts this argument
+ into an identifier. If the string starts with the current /, it will be converted into a cheap local
+ identifier, otherwise it will be converted into a normal identifier.
+
+ Example:
+
+
+ .macro makelabel arg1, arg2
+ .ident (.concat (arg1, arg2)):
+ .endmacro
+
+ makelabel "foo", "bar"
+
+ .word foobar ; Valid label
+
+
+
+.LEFT
+
+ Builtin function. Extracts the left part of a given token list.
+
+ Syntax:
+
+
+ .LEFT (<int expr>, <token list>)
+
+
+ The first integer expression gives the number of tokens to extract from
+ the token list. The second argument is the token list itself. The token
+ list may optionally be enclosed into curly braces. This allows the
+ inclusion of tokens that would otherwise terminate the list (the closing
+ right paren in the given case).
+
+ Example:
+
+ To check in a macro if the given argument has a '#' as first token
+ (immediate addressing mode), use something like this:
+
+
+ .macro ldax arg
+ ...
+ .if (.match (.left (1, {arg}), #))
+
+ ; ldax called with immediate operand
+ ...
+
+ .endif
+ ...
+ .endmacro
+
+
+ See also the and builtin functions.
+
+
+.LOBYTE
+
+ The function returns the low byte (that is, bits 0-7) of its argument.
+ It works identical to the '<' operator.
+
+ See: ,
+
+
+
+.LOWORD
+
+ The function returns the low word (that is, bits 0-15) of its argument.
+
+ See:
+
+
+.MATCH
+
+ Builtin function. Matches two token lists against each other. This is
+ most useful within macros, since macros are not stored as strings, but
+ as lists of tokens.
+
+ The syntax is
+
+
+ .MATCH(<token list #1>, <token list #2>)
+
+
+ Both token list may contain arbitrary tokens with the exception of the
+ terminator token (comma resp. right parenthesis) and
+
+
+ end-of-line
+ end-of-file
+
+
+ The token lists may optionally be enclosed into curly braces. This allows
+ the inclusion of tokens that would otherwise terminate the list (the closing
+ right paren in the given case). Often a macro parameter is used for any of
+ the token lists.
+
+ Please note that the function does only compare tokens, not token
+ attributes. So any number is equal to any other number, regardless of the
+ actual value. The same is true for strings. If you need to compare tokens
+
function.
+
+ Example:
+
+ Assume the macro function
+ to check for this and print and error for invalid calls.
+
+
+ .macro asr arg
+
+ .if (.not .blank(arg)) .and (.not .match ({arg}, a))
+ .error "Syntax error"
+ .endif
+
+ cmp #$80 ; Bit 7 into carry
+ lsr a ; Shift carry into bit 7
+
+ .endmacro
+
+
+ The macro will only accept no arguments, or one argument that must be the
+ reserved keyword "A".
+
+ See:
+
+
+.MAX
+
+ Builtin function. The result is the larger of two values.
+
+ The syntax is
+
+
+ .MAX (<value #1>, <value #2>)
+
+
+ Example:
+
+
+ ; Reserve space for the larger of two data blocks
+ savearea: .max (.sizeof (foo), .sizeof (bar))
+
+
+ See:
+
+
+.MID
+
+ Builtin function. Takes a starting index, a count and a token list as
+ arguments. Will return part of the token list.
+
+ Syntax:
+
+
+ .MID (<int expr>, <int expr>, <token list>)
+
+
+ The first integer expression gives the starting token in the list (the first
+ token has index 0). The second integer expression gives the number of tokens
+ to extract from the token list. The third argument is the token list itself.
+ The token list may optionally be enclosed into curly braces. This allows the
+ inclusion of tokens that would otherwise terminate the list (the closing
+ right paren in the given case).
+
+ Example:
+
+ To check in a macro if the given argument has a '
+ .macro ldax arg
+ ...
+ .if (.match (.mid (0, 1, {arg}), #))
+
+ ; ldax called with immediate operand
+ ...
+
+ .endif
+ ...
+ .endmacro
+
+
+ See also the and builtin functions.
+
+
+.MIN
+
+ Builtin function. The result is the smaller of two values.
+
+ The syntax is
+
+
+ .MIN (<value #1>, <value #2>)
+
+
+ Example:
+
+
+ ; Reserve space for some data, but 256 bytes minimum
+ savearea: .min (.sizeof (foo), 256)
+
+
+ See:
+
+
+.REF, .REFERENCED
+
+ Builtin function. The function expects an identifier as argument in braces.
+ The argument is evaluated, and the function yields "true" if the identifier
+ is a symbol that has already been referenced somewhere in the source file up
+ to the current position. Otherwise the function yields false. As an example,
+ the statement may be replaced by
+
+
+ .if .referenced(a)
+
+
+ See:
+
+
+.RIGHT
+
+ Builtin function. Extracts the right part of a given token list.
+
+ Syntax:
+
+
+ .RIGHT (<int expr>, <token list>)
+
+
+ The first integer expression gives the number of tokens to extract from the
+ token list. The second argument is the token list itself. The token list
+ may optionally be enclosed into curly braces. This allows the inclusion of
+ tokens that would otherwise terminate the list (the closing right paren in
+ the given case).
+
+ See also the and builtin functions.
+
+
+.SIZEOF
+
+
+ .struct Point ; Struct size = 4
+ xcoord .word
+ ycoord .word
+ .endstruct
+
+ P: .tag Point ; Declare a point
+ @P: .tag Point ; Declare another point
+
+ .code
+ .proc Code
+ nop
+ .proc Inner
+ nop
+ .endproc
+ nop
+ .endproc
+
+ .proc Data
+ .data ; Segment switch!!!
+ .res 4
+ .endproc
+
+
+
+
+ will have the value 4, because this is the size of struct
+ will have the value 2, because this is the size of the member
+ will have the value 4, this is the size of the data declared on the same
+ source line as the label
+ will have the value 4, see above. The example demonstrates that
+ will have the value 3, since this is amount of data emitted into the code
+ segment, the segment that was active when
+ will have the value 1 as expected.
+
+
+ will have the value 0. Data is emitted within the scope
+
+
+.STRAT
+
+ Builtin function. The function accepts a string and an index as
+ arguments and returns the value of the character at the given position
+ as an integer value. The index is zero based.
+
+ Example:
+
+
+ .macro M Arg
+ ; Check if the argument string starts with '#'
+ .if (.strat (Arg, 0) = '#')
+ ...
+ .endif
+ .endmacro
+
+
+
+.SPRINTF
+
+ Builtin function. It expects a format string as first argument. The number
+ and type of the following arguments depend on the format string. The format
+ string is similar to the one of the C
+ num = 3
+
+ ; Generate an identifier:
+ .ident (.sprintf ("%s%03d", "label", num)):
+
+
+
+.STRING
+
+ Builtin function. The function accepts an argument in braces and converts
+ this argument into a string constant. The argument may be an identifier, or
+ a constant numeric value.
+
+ Since you can use a string in the first place, the use of the function may
+ not be obvious. However, it is useful in macros, or more complex setups.
+
+ Example:
+
+
+ ; Emulate other assemblers:
+ .macro section name
+ .segment .string(name)
+ .endmacro
+
+
+
+.STRLEN
+
+ Builtin function. The function accepts a string argument in braces and
+ evaluates to the length of the string.
+
+ Example:
+
+ The following macro encodes a string as a pascal style string with
+ a leading length byte.
+
+
+ .macro PString Arg
+ .byte .strlen(Arg), Arg
+ .endmacro
+
+
+
+.TCOUNT
+
+ Builtin function. The function accepts a token list in braces. The function
+ result is the number of tokens given as argument. The token list may
+ optionally be enclosed into curly braces which are not considered part of
+ the list and not counted. Enclosement in curly braces allows the inclusion
+ of tokens that would otherwise terminate the list (the closing right paren
+ in the given case).
+
+ Example:
+
+ The
+ .macro ldax arg
+ .if (.match (.mid (0, 1, {arg}), #))
+ ; ldax called with immediate operand
+ lda #<(.right (.tcount ({arg})-1, {arg}))
+ ldx #>(.right (.tcount ({arg})-1, {arg}))
+ .else
+ ...
+ .endif
+ .endmacro
+
+
+
+.XMATCH
+
+ Builtin function. Matches two token lists against each other. This is
+ most useful within macros, since macros are not stored as strings, but
+ as lists of tokens.
+
+ The syntax is
+
+
+ .XMATCH(<token list #1>, <token list #2>)
+
+
+ Both token list may contain arbitrary tokens with the exception of the
+ terminator token (comma resp. right parenthesis) and
+
+
+ end-of-line
+ end-of-file
+
+
+ The token lists may optionally be enclosed into curly braces. This allows
+ the inclusion of tokens that would otherwise terminate the list (the closing
+ right paren in the given case). Often a macro parameter is used for any of
+ the token lists.
+
+ The function compares tokens
function.
+
+ See:
+
+
+
+Control commands
+
+Here's a list of all control commands and a description, what they do:
+
+
+.A16
+
+ Valid only in 65816 mode. Switch the accumulator to 16 bit.
+
+ Note: This command will not emit any code, it will tell the assembler to
+ create 16 bit operands for immediate accumulator addressing mode.
+
+ See also:
+
+
+.A8
+
+ Valid only in 65816 mode. Switch the accumulator to 8 bit.
+
+ Note: This command will not emit any code, it will tell the assembler to
+ create 8 bit operands for immediate accu addressing mode.
+
+ See also:
+
+
+.ADDR
+
+ Define word sized data. In 6502 mode, this is an alias for . The command
+ must be followed by a sequence of (not necessarily constant) expressions.
+
+ Example:
+
+
+ .addr $0D00, $AF13, _Clear
+
+
+ See: ,
+
+
+.ALIGN
+
+ Align data to a given boundary. The command expects a constant integer
+ argument in the range 1 ... 65536, plus an optional second argument
+ in byte range. If there is a second argument, it is used as fill value,
+ otherwise the value defined in the linker configuration file is used
+ (the default for this value is zero).
+
+
+ .align 256
+
+
+ Some unexpected behaviour might occur if there are multiple
+ .align 15
+ .byte 15
+ .align 18
+ .byte 18
+
+
+ For the assembler to be able to align correctly, the segment must be aligned
+ to the least common multiple of 15 and 18 which is 90. The assembler will
+ calculate this automatically and will mark the segment with this value.
+
+ Unfortunately, the combined alignment may get rather large without the user
+ knowing about it, wasting space in the final executable. If we add another
+ alignment to the example above
+
+
+ .align 15
+ .byte 15
+ .align 18
+ .byte 18
+ .align 251
+ .byte 0
+
+
+ the assembler will force a segment alignment to the least common multiple of
+ 15, 18 and 251 - which is 22590. To protect the user against errors, the
+ assembler will issue a warning when the combined alignment exceeds 256. The
+ command line option will disable this warning.
+
+ Please note that with alignments that are a power of two (which were the
+ only alignments possible in older versions of the assembler), the problem is
+ less severe, because the least common multiple of powers to the same base is
+ always the larger one.
+
+
+
+.ASCIIZ
+
+ Define a string with a trailing zero.
+
+ Example:
+
+
+ Msg: .asciiz "Hello world"
+
+
+ This will put the string "Hello world" followed by a binary zero into
+ the current segment. There may be more strings separated by commas, but
+ the binary zero is only appended once (after the last one).
+
+
+.ASSERT
+
+ Add an assertion. The command is followed by an expression, an action
+ specifier, and an optional message that is output in case the assertion
+ fails. If no message was given, the string "Assertion failed" is used. The
+ action specifier may be one of
+ .assert * = $8000, error, "Code not at $8000"
+
+
+ The example assertion will check that the current location is at $8000,
+ when the output file is written, and abort with an error if this is not
+ the case. More complex expressions are possible. The action specifier
+ .AUTOIMPORT
+
+ Is followed by a plus or a minus character. When switched on (using a
+ +), undefined symbols are automatically marked as import instead of
+ giving errors. When switched off (which is the default so this does not
+ make much sense), this does not happen and an error message is
+ displayed. The state of the autoimport flag is evaluated when the
+ complete source was translated, before outputting actual code, so it is
+
+ .autoimport + ; Switch on auto import
+
+
+.BANKBYTES