3 Description of the C library for the cc65 C compiler
5 (C) Copyright 1998-1999 Ullrich von Bassewitz
15 2. ISO C compatible library
17 3. CPU specific stuff - 6502.h
19 4. System specific stuff
21 5. Direct console I/O - conio.h
23 6. Using the joystick - joystick.h
34 This file contains a description of the library routines available for the
35 cc65 C compiler. It is not complete in some areas, so if you miss
36 something, have a look into the header files. All functions, that are not
37 defined by the ISO C standard have a short comment in the headers,
42 2. ISO C compatible library
43 ---------------------------
45 The C library contains a large subset of the ISO C library. Functions are
46 usually missing in areas, where there is no support on typical 6502
47 systems. Wide character sets are an example for this.
49 I will not go into detail about the ISO functions. If a function is not
50 mentioned here explicitly, expect it to be available and to behave as
51 defined in the C standard.
54 Functions that are NOT available:
56 * ftell/fseek/fgetpos/fsetpos
60 * The scanf family of functions
62 * time/asctime/ctime/difftime/asctime/gmtime/localtime/mktime/strftime
66 * All functions that handle floating point numbers in some manner.
68 * The div and ldiv functions (because cc65 is not able to return
71 * All functions handling wide character strings.
73 * Signals and all related functions (having SIGSEGV would be cool:-)
75 * rename/remove/rewind
77 * setbuf/setvbuf/ungetc
81 Functions that are limited in any way:
83 * fopen/fread/fwrite/fclose/fputs/fgets/fscanf....
85 These functions are built on open/read/write/close. Neither of these
86 low level functions is currently available for the supported systems,
87 and so, fopen and friends do not work. However, the functions exist
88 and are tested to some degree under the ACE operating systems (which
89 is no longer supported).
92 * The va_... family of macros
94 The macros do not work completely as defined by the standard. Since cc65
95 has the wrong calling order, the (non-standard) va_fix macro must be used
96 to access fixed parameters in functions with a variable parameter size.
97 See newvers.txt for a discussion of the problem.
100 * strcspn/strpbrk/strspn
102 These functions have a length limitation of 256 for the second string
103 argument. Since this string gives a character set, and there are only 256
104 distinct characters, this shouldn't be a problem.
107 * Since there is no such thing as an environment on all supported
108 systems, the getenv function will always return a NULL pointer.
111 * There is no other locale than the "C" locale. The native locale is
112 identical to the "C" locale.
115 In addition to these limitations, some more functions are limited if inlined
116 versions are requested by using -Os:
118 * The strlen function only works for strings with a maximum length of
121 * The isxxx character classification functions from <ctype.h> will give
122 unpredictable results if the argument is not in character range
123 (0..255). This limitation may be removed by #undef'ing the function
124 name (when using -Os, the functions are actually macros that expand to
125 inline assembler code, but the real functions are still available if
126 the macro definition is removed).
130 3. CPU specific stuff - 6502.h
131 ------------------------------
133 The header file 6502.h contains some functions that make only sense with
134 the 6502 CPU. Examples are macros to insert more or less useful
135 instructions into your C code, or a function to call arbitrary machine
136 language subroutines, passing registers in and out.
140 4. System specific stuff
141 ------------------------
143 For each supported system there's a header file that contains calls or
144 defines specific for this system. So, when programming for the C64,
145 include c64.h, for the C128, include c128.h and so on. To make the task
146 for the Commodore systems easier, there is also a header file named cbm.h
147 that will define stuff common for all CBM systems, and include the header
148 file for the specific target system.
150 The header files contain
152 * Defines for special keys (like function keys)
154 * Defines for special characters (like the graphics characters)
156 * Variables with a fixed address in memory that may be used to access
157 special hardware. For the C64 and C128 there is a variable struct
158 named "sid". Writing to the fields of this struct will write to the
159 SID device instead. Using these variables will make your program more
160 readable and more portable. Don't fear ineffective code when using
161 these variables, the compiler will translate reads and writes to these
162 structs into direct memory accesses.
164 * Other routines that make only sense for a specific system. One example
165 are routines to write memory locations in the system bank for the CBM
166 600/700 family (called B128/B256 in the US).
170 5. Direct console I/O - conio.h
171 -------------------------------
173 The conio header file contains a large set of functions that do screen and
174 keyboard I/O. The functions will write directly to the screen or poll the
175 keyboard directly with no more help from the operating system than needed.
176 This has some disadvantages, but on the other side it's fast and
177 reasonably portable. conio implementations exist for the following
183 cbm610 (that is, the complete 600/700 series)
184 pet (all PETs except the 2001)
188 The conio.h header file does also include the system specific header files
189 which define constants for special characters and keys.
193 6. Using the joystick - joystick.h
194 ----------------------------------
196 For systems that have a joystick, joystick.h will define a subroutine to
197 read the current value, including constants to evaluate the result of this
198 function. To help in writing portable code, the header file will define
199 the symbol __JOYSTICK__ on systems that have a joystick.
206 If you have problems using the library, if you find any bugs, or if you've
207 written some extensions or otherwise interesting programs, I would be glad
208 to hear from you. Feel free to contact me by email (uz@musoftware.de).
215 This C runtime library implementation for the cc65 compiler is (C)
216 Copyright 1998-1999 Ullrich von Bassewitz. For usage of the binaries
217 and/or sources the following conditions do apply:
219 This software is provided 'as-is', without any expressed or implied
220 warranty. In no event will the authors be held liable for any damages
221 arising from the use of this software.
223 Permission is granted to anyone to use this software for any purpose,
224 including commercial applications, and to alter it and redistribute it
225 freely, subject to the following restrictions:
227 1. The origin of this software must not be misrepresented; you must not
228 claim that you wrote the original software. If you use this software
229 in a product, an acknowledgment in the product documentation would be
230 appreciated but is not required.
231 2. Altered source versions must be plainly marked as such, and must not
232 be misrepresented as being the original software.
233 3. This notice may not be removed or altered from any source