]> git.sur5r.net Git - cc65/blob - doc/library.txt
getfd.o: new object file
[cc65] / doc / library.txt
1
2
3            Description of the C library for the cc65 C compiler
4
5               (C) Copyright 1998-1999 Ullrich von Bassewitz
6                             (uz@musoftware.de)
7
8
9
10 Contents
11 --------
12
13   1. Overview
14
15   2. ISO C compatible library
16
17   3. CPU specific stuff - 6502.h
18
19   4. System specific stuff
20
21   5. Direct console I/O - conio.h
22
23   6. Using the joystick - joystick.h
24
25   7. Bugs/Feedback
26
27   8. Copyright
28
29
30
31 1. Overview
32 -----------
33
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,
38 explaining their use.
39
40
41
42 2. ISO C compatible library
43 ---------------------------
44
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.
48
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.
52
53
54 Functions that are NOT available:
55
56   * ftell/fseek/fgetpos/fsetpos
57
58   * tmpfile/tmpnam
59
60   * The scanf family of functions
61
62   * time/asctime/ctime/difftime/asctime/gmtime/localtime/mktime/strftime
63
64   * system
65
66   * All functions that handle floating point numbers in some manner.
67
68   * The div and ldiv functions (because cc65 is not able to return
69     structs).
70
71   * All functions handling wide character strings.
72
73   * Signals and all related functions (having SIGSEGV would be cool:-)
74
75   * rename/remove/rewind
76
77   * setbuf/setvbuf/ungetc
78
79
80
81 Functions that are limited in any way:
82
83   * fopen/fread/fwrite/fclose/fputs/fgets/fscanf....
84
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).
90
91
92   * The va_... family of macros
93
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.
98
99
100   * strcspn/strpbrk/strspn
101
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.
105
106
107   * Since there is no such thing as an environment on all supported
108     systems, the getenv function will always return a NULL pointer.
109
110
111   * There is no other locale than the "C" locale. The native locale is
112     identical to the "C" locale.
113
114
115 In addition to these limitations, some more functions are limited if inlined
116 versions are requested by using -Os:
117
118   * The strlen function only works for strings with a maximum length of
119     255 characters.
120
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).
127
128
129
130 3. CPU specific stuff - 6502.h
131 ------------------------------
132
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.
137
138
139
140 4. System specific stuff
141 ------------------------
142
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.
149
150 The header files contain
151
152   * Defines for special keys (like function keys)
153
154   * Defines for special characters (like the graphics characters)
155
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.
163
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).
167
168
169
170 5. Direct console I/O - conio.h
171 -------------------------------                                     
172
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
178 targets:
179
180         c64
181         c128
182         plus/4
183         cbm610          (that is, the complete 600/700 series)
184         pet             (all PETs except the 2001)
185         apple 2
186         atari
187
188 The conio.h header file does also include the system specific header files
189 which define constants for special characters and keys.
190
191
192
193 6. Using the joystick - joystick.h
194 ----------------------------------
195
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.
200
201
202
203 7. Bugs/Feedback
204 ----------------
205
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).
209
210
211
212 8. Copyright
213 ------------
214
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:
218
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.
222
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:
226
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
234    distribution.
235
236
237
238
239