]> git.sur5r.net Git - cc65/blob - doc/library.txt
This commit was generated by cvs2svn to compensate for changes in r2,
[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   * The character classification functions (is...)
101
102     These functions have unexpected results when called with arguments that
103     are not really chars (are outside the 0..255 range).
104
105
106   * The strerror function
107
108     The function will return "error #n" where n is the error number.
109
110
111   * strcspn/strpbrk/strspn
112
113     These functions have a length limitation of 256 for the second string
114     argument. Since this string gives a character set, and there are only 256
115     distinct characters, this shouldn't be a problem.
116
117
118   * Since there is no such thing as an environment on all supported
119     systems, the getenv function will always return a NULL pointer.
120
121
122   * There is no other locale than the "C" locale. The native locale is
123     identical to the "C" locale.
124
125
126
127 3. CPU specific stuff - 6502.h
128 ------------------------------
129
130 The header file 6502.h contains some functions that make only sense with
131 the 6502 CPU. Examples are macros to insert more or less useful
132 instructions into your C code, or a function to call arbitrary machine
133 language subroutines, passing registers in and out.
134
135
136
137 4. System specific stuff
138 ------------------------
139
140 For each supported system there's a header file that contains calls or
141 defines specific for this system. So, when programming for the C64,
142 include c64.h, for the C128, include c128.h and so on. To make the task
143 for the Commodore systems easier, there is also a header file named cbm.h
144 that will define stuff common for all CBM systems, and include the header
145 file for the specific target system.
146
147 The header files contain
148
149   * Defines for special keys (like function keys)
150
151   * Defines for special characters (like the graphics characters)
152
153   * Variables with a fixed address in memory that may be used to access
154     special hardware. For the C64 and C128 there is a variable struct
155     named "sid". Writing to the fields of this struct will write to the
156     SID device instead. Using these variables will make your program more
157     readable and more portable. Don't fear ineffective code when using
158     these variables, the compiler will translate reads and writes to these
159     structs into direct memory accesses.
160
161   * Other routines that make only sense for a specific system. One example
162     are routines to write memory locations in the system bank for the CBM
163     600/700 family (called B128/B256 in the US).
164
165
166
167 5. Direct console I/O - conio.h
168 -------------------------------
169
170 The conio header file contains a large set of functions that do screen and
171 keyboard I/O. The functions will write directly to the screen or poll the
172 keyboard directly with no more help from the operating system than needed.
173 This has some disadvantages, but on the other side it's fast and
174 reasonably portable. conio implementations exist for the following
175 targets:
176
177         c64
178         c128
179         plus/4
180         cbm610          (that is, the complete 600/700 series)
181         pet             (all PETs except the 2001)
182         apple 2
183
184 The conio.h header file does also include the system specific header files
185 which define constants for special characters and keys.
186
187
188
189 6. Using the joystick - joystick.h
190 ----------------------------------
191
192 For systems that have a joystick, joystick.h will define a subroutine to
193 read the current value, including constants to evaluate the result of this
194 function. To help in writing portable code, the header file will define
195 the symbol __JOYSTICK__ on systems that have a joystick.
196
197
198
199 7. Bugs/Feedback
200 ----------------
201
202 If you have problems using the library, if you find any bugs, or if you've
203 written some extensions or otherwise interesting programs, I would be glad
204 to hear from you. Feel free to contact me by email (uz@musoftware.de).
205
206
207
208 8. Copyright
209 ------------
210
211 This C runtime library implementation for the cc65 compiler is (C)
212 Copyright 1998-1999 Ullrich von Bassewitz. For usage of the binaries
213 and/or sources the following conditions do apply:
214
215 This software is provided 'as-is', without any expressed or implied
216 warranty.  In no event will the authors be held liable for any damages
217 arising from the use of this software.
218
219 Permission is granted to anyone to use this software for any purpose,
220 including commercial applications, and to alter it and redistribute it
221 freely, subject to the following restrictions:
222
223 1. The origin of this software must not be misrepresented; you must not
224    claim that you wrote the original software. If you use this software
225    in a product, an acknowledgment in the product documentation would be
226    appreciated but is not required.
227 2. Altered source versions must be plainly marked as such, and must not
228    be misrepresented as being the original software.
229 3. This notice may not be removed or altered from any source
230    distribution.
231
232
233
234
235