]> git.sur5r.net Git - cc65/blob - doc/cbm510.sgml
Change .CONDES -> .INTERRUPTOR (Stefan Haubenthal).
[cc65] / doc / cbm510.sgml
1 <!doctype linuxdoc system>
2
3 <article>
4
5 <title>Commodore 510 (aka P500) specific information for cc65
6 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
7 Stefan A. Haubenthal, <htmlurl url="mailto:polluks@sdf.lonestar.org" name="polluks@sdf.lonestar.org">
8 <date>2006-05-22
9
10 <abstract>
11 An overview over the Commodore 510 runtime system as it is implemented for the
12 cc65 C compiler.
13 </abstract>
14
15 <!-- Table of contents -->
16 <toc>
17
18 <!-- Begin the document -->
19
20 <sect>Overview<p>
21
22 This file contains an overview of the CBM 510 runtime system as it comes with
23 the cc65 C compiler. It describes the memory layout, CBM 510 specific header
24 files, available drivers, and any pitfalls specific to that platform.
25
26 Please note that CBM 510 specific functions are just mentioned here, they are
27 described in detail in the separate <htmlurl url="funcref.html" name="function
28 reference">. Even functions marked as "platform dependent" may be available on
29 more than one platform. Please see the function reference for more
30 information.
31
32 In addition to the Commodore 510 (named P128 in the U.S.), no other
33 machines are supported by this cc65 target.
34
35
36
37 <sect>Binary format<p>
38
39 The standard binary output format generated by the linker for the Commodore
40 510 target is a machine language program with a one line BASIC stub, which
41 transfers control to the machine language running in bank 0. This means that a
42 program can be loaded as BASIC program and started with RUN. It is of course
43 possible to change this behaviour by using a modified startup file and linker
44 config.
45
46
47
48 <sect>Memory layout<p>
49
50 cc65 generated programs for the Commodore 510 run in bank 0, the memory bank
51 reserved for BASIC programs. Since there are no ROMs in this memory bank,
52 kernal subroutines are either emulated or called by bank switching, which has
53 the disadvantage of being slow compared to a direct call.
54
55 The default memory configuration for the CBM 510 allocates all memory between
56 &dollar;0002 and &dollar;FFF0 in bank 0 for the compiled program. Some space
57 in low memory is lost, because a separate hardware stack is set up in page 1,
58 and the kernal replacement functions need some more memory locations. A few
59 more pages are lost in high memory, because the runtime sets up a copy of the
60 character ROM, a text screen and a CBM compatible jump table at &dollar;FF81.
61 The main startup code is located at &dollar;0400, so about 54K of the complete
62 bank are actually usable for applications.
63
64 Special locations:
65
66 <descrip>
67   <tag/Stack/
68   The C runtime stack is located at &dollar;FF81 and growing downwards.
69
70   <tag/Heap/
71   The C heap is located at the end of the program and grows towards the C
72   runtime stack.
73 </descrip><p>
74
75
76
77 <sect>Platform specific header files<p>
78
79 Programs containing CBM 510 specific code may use the <tt/cbm510.h/ or
80 <tt/cbm.h/ header files. Using the later may be an option when writing code
81 for more than one CBM platform, since it includes <tt/cbm510.h/ and declares
82 several functions common to all CBM platforms.
83
84 <sect1>CBM 510 specific functions<p>
85
86 The functions listed below are special for the CBM 510. See the <htmlurl
87 url="funcref.html" name="function reference"> for declaration and usage.
88
89 <itemize>
90 <item>peekbsys
91 <item>peekwsys
92 <item>pokebsys
93 <item>pokewsys
94 </itemize>
95
96
97 <sect1>CBM specific functions<p>
98
99 Some functions are available for all (or at least most) of the Commodore
100 machines. See the <htmlurl url="funcref.html" name="function reference"> for
101 declaration and usage.
102
103
104 <itemize>
105 <item>cbm_close
106 <item>cbm_closedir
107 <item>cbm_k_setlfs
108 <item>cbm_k_setnam
109 <item>cbm_k_load
110 <item>cbm_k_save
111 <item>cbm_k_open
112 <item>cbm_k_close
113 <item>cbm_k_readst
114 <item>cbm_k_chkin
115 <item>cbm_k_ckout
116 <item>cbm_k_basin
117 <item>cbm_k_bsout
118 <item>cbm_k_clrch
119 <item>cbm_load
120 <item>cbm_open
121 <item>cbm_opendir
122 <item>cbm_read
123 <item>cbm_readdir
124 <item>cbm_save
125 <item>cbm_write
126 <item>get_tv
127 </itemize>
128
129
130
131 <sect1>Hardware access<p>
132
133 The following pseudo variables declared in the <tt/cbm510.h/ header file do
134 allow access to hardware located in the address space. Some variables are
135 structures, accessing the struct fields will access the chip registers.
136
137 <bf>Note:</bf> All I/O chips are located in the system bank (bank 15) and can
138 therefore not be accessed like on other platforms. Please use one of the
139 <tt/peekbsys/, <tt/peekwsys/, <tt/pokebsys/ and <tt/pokewsys/ functions to
140 access the I/O chips. Direct reads and writes to the structures named below
141 will <em>not</em> work!
142
143 <descrip>
144
145   <tag><tt/VIC/</tag>
146   The <tt/VIC/ structure allows access to the VIC II (the graphics
147   controller). See the <tt/_vic2.h/ header file located in the include
148   directory for the declaration of the structure.
149
150   <tag><tt/SID/</tag>
151   The <tt/SID/ structure allows access to the SID (the sound interface
152   device). See the <tt/_sid.h/ header file located in the include directory
153   for the declaration of the structure.
154
155   <tag><tt/ACIA/</tag>
156   Access to the ACIA (the RS232 chip) is available via the <tt/ACIA/ variable.
157   See the <tt/_6551.h/ header file located in the include directory for the
158   declaration of the structure.
159
160   <tag><tt/CIA/</tag>
161   Access to the CIA chip is available via the <tt/CIA/ variable. See the
162   <tt/_6526.h/ header file located in the include directory for the
163   declaration of the structure.
164
165   <tag><tt/TPI1, TPI2/</tag>
166   The two 6525 triport chips may be accessed by using this variable. See the
167   <tt/_6525.h/ header file located in the include directory for the
168   declaration of the structure.
169
170 </descrip><p>
171
172
173
174 <sect>Loadable drivers<p>
175
176
177 <sect1>Graphics drivers<p>
178
179 No graphics drivers are currently available for the Commodore 510.
180
181
182 <sect1>Extended memory drivers<p>
183
184 <descrip>
185   <tag><tt/cbm510-ram.emd/</tag>
186   A driver for the RAM in bank 1. Supports up to 255 pages with 256 bytes
187   each.
188 </descrip><p>
189
190
191 <sect1>Joystick drivers<p>
192
193 <descrip>
194
195   <tag><tt/cbm510-std.joy/</tag>
196   Supports up to two standard joysticks connected to the joysticks port of
197   the Commodore 510.
198
199 </descrip><p>
200
201
202 <sect1>Mouse drivers<p>
203
204 No mouse drivers are currently available for the Commodore 510.
205
206
207 <sect1>RS232 device drivers<p>
208
209 <descrip>
210
211   <tag><tt/cbm510-std.ser/</tag>
212   Driver for the 6551 ACIA chip built into the Commodore 510. Supports up to
213   19200 baud, hardware flow control (RTS/CTS) and interrupt driven receives.
214   Note that because of the peculiarities of the 6551 chip transmits are not
215   interrupt driven, and the transceiver blocks if the receiver asserts flow
216   control because of a full buffer.
217
218 </descrip><p>
219
220
221 <sect>Limitations<label id="limitations"><p>
222
223
224 <sect1>Kernal and hardware access<p>
225
226 Since the program runs in bank 0, and the kernal and all I/O chips are located
227 in bank 15, calling ROM routines or accessing hardware needs special code. The
228 cc65 runtime implements wrappers for all functions in the kernal jump table.
229 While this simplifies things, it should be noted that the wrappers do have
230 quite an impact on performance: A cross bank call has an extra 300&micro;s
231 penalty added by the wrapper.
232
233 <sect1>Interrupts<p>
234
235 Compiled programs contain an interrupt handler that runs in the program bank.
236 This has several advantages, one of them being performance (see cross bank
237 call overhead mentioned above). However, this introduces one problem:
238 Interrupts are lost while the CPU executes code in the kernal bank. As a
239 result, the clock may go wrong and (worse) serial interrupts may get lost.
240
241 Since the cc65 runtime does only call the kernal for disk I/O, this means that
242 a program should not do file I/O while it depends on interrupts.
243
244
245 <sect>Other hints<p>
246
247 <sect1>Passing arguments to the program<p>
248
249 Command line argument passing is currently not supported for the Commodore
250 510.
251
252
253 <sect1>Program return code<p>
254
255 The program return code (signed char) is passed back to BASIC by use of the
256 <tt/ST/ variable.
257
258
259 <sect1>Interrupt handlers<p>
260
261 The runtime for the Commodore 510 uses routines marked as <tt/.INTERRUPTOR/
262 for interrupt handlers. Such routines must be written as simple machine
263 language subroutines and will be called automatically by the interrupt handler
264 code when they are linked into a program. See the discussion of the
265 <tt/.CONDES/ feature in the <htmlurl url="ca65.html" name="assembler manual">.
266
267
268
269 <sect>Bugs/Feedback<p>
270
271 If you have problems using the library, if you find any bugs, or if you're
272 doing something interesting with it, I would be glad to hear from you. Feel
273 free to contact me by email (<htmlurl url="mailto:uz@cc65.org"
274 name="uz@cc65.org">).
275
276
277
278 <sect>License<p>
279
280 This software is provided 'as-is', without any expressed or implied
281 warranty.  In no event will the authors be held liable for any damages
282 arising from the use of this software.
283
284 Permission is granted to anyone to use this software for any purpose,
285 including commercial applications, and to alter it and redistribute it
286 freely, subject to the following restrictions:
287
288 <enum>
289 <item>  The origin of this software must not be misrepresented; you must not
290         claim that you wrote the original software. If you use this software
291         in a product, an acknowledgment in the product documentation would be
292         appreciated but is not required.
293 <item>  Altered source versions must be plainly marked as such, and must not
294         be misrepresented as being the original software.
295 <item>  This notice may not be removed or altered from any source
296         distribution.
297 </enum>
298
299 </article>