blob: 45dff3f5b6b9cbc5048e41ab5b9d78565aa93873 [file] [log] [blame]
PulkoMandy17fc7592022-07-28 18:27:54 +02001This chapter describes the C library usually provided with @command{vbcc}.
2
3
4@section Introduction
5
6To execute code compiled by @command{vbcc}, a library is needed. It
7provides basic interfaces to the underlying operating system or
8hardware as well as a set of often used functions.
9
10A big part of the library is portable across all architectures. However,
11some functions (e.g. for input/output or memory allocation) are
12naturally dependent on the operating system or hardware. There are
13several sections in this chapter dealing with different versions of
14the library.
15
16The library itself often is split into several parts. A startup-code
17will do useful initializations, like setting up IO, parsing the command
18line or initializing variables and hardware.
19
20The biggest part of the functions will usually be stored in one library file.
21The name and format of this file depends on the conventions of the underlying
22system (e.g. @file{vc.lib} or @file{libvc.a}).
23
24Often, floating point code (if available) is stored in a different file
25(e.g. @file{m.lib} or @file{libm.a}). If floating point is used in an
26application, it might be necessary to explicitly link with this library
27(e.g. by specifying @file{-lm}).
28
29In many cases, the include files provide special inline-code or similar
30optimizations. Therefore, it is recommended to always include the
31corresponding include file when using a library function. Even if it
32is not necessary in all cases, it may affect the quality of the generated
33code.
34
35The library implements the functions specified by ISO9899:1989 as well
36as a part of the new functions from ISO9899:1999.
37
38@section Legal
39
40Most parts of this library are public domain. However, for some systems,
41parts may be under a different license. Please consult the system
42specific documentation. Usually, linking against this library will
43not put any restrictions on the created executable unless otherwise
44mentioned.
45
46Parts of the math library (e.g. transcendental functions) are derived
47from Sun's free math library:
48@example
49 * ====================================================
50 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
51 *
52 * Developed at SunPro, a Sun Microsystems, Inc. business.
53 * Permission to use, copy, modify, and distribute this
54 * software is freely granted, provided that this notice
55 * is preserved.
56 * ====================================================
57@end example
58
59@node SoftfloatHauser
60The softfloat functions, used by some targets, are derived from John
61Hauser's IEC/IEEE Floating-point Artithmetic Package:
62
63@example
64This C source file is part of the SoftFloat IEC/IEEE Floating-point
65Arithmetic Package, Release 2.
66
67Written by John R. Hauser. This work was made possible in part by the
68International Computer Science Institute, located at Suite 600, 1947 Center
69Street, Berkeley, California 94704. Funding was partially provided by the
70National Science Foundation under grant MIP-9311980. The original version
71of this code was written as part of a project to build a fixed-point vector
72processor in collaboration with the University of California at Berkeley,
73overseen by Profs. Nelson Morgan and John Wawrzynek. More information
74is available through the web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
75arithmetic/softfloat.html'.
76
77THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
78has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
79TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
80PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
81AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
82
83Derivative works are acceptable, even for commercial purposes, so long as
84(1) they include prominent notice that the work is derivative, and (2) they
85include prominent notice akin to these three paragraphs for those parts of
86this code that are retained.
87@end example
88
89
90@section Global Variables
91
92@subsection timezone
93
94On some host operating systems vclib might be unable to determine the
95current time zone, which is required for functions like
96@code{mktime()} or @code{localtime()} to work. Here you can overwrite
97the following variables:
98
99@table @code
100@item long __gmtoffset
101 Offset in minutes, west of Greenwich Mean Time (GMT).
102@item int __dstflag
103 Set to non-zero, when Daylight Saving Time is active.
104@end table
105
106Targets which can determine their current time zone, will do so by
107initializing these variables on startup.
108
109
110@section Embedded Systems
111
112This section describes specifics of the C library for embedded systems.
113
114@subsection Startup
115
116The startup is usually split into two parts. The first part is done by
117assembly code that produces the object file @file{lib/startup.o}. This
118assembly code is usually provided with vbcc and may have to be adapted to
119the hardware you are using. The key actions that have to be performed by this
120code are:
121
122@table @minus
123@item hardware initialization
124 It may be necessary to perform some hardware initialization right
125 at the beginning, e.g. to configure the memory system. This has to
126 be modified by the user.
127
128@item variable initializations
129 When running code from ROM, some memory sections have to be
130 initialized. Usually, the init-values of initialized variables
131 have to be copied from ROM to the data segment and the values of
132 un-initialized variables have to be cleared in the bss segment.
133 This code is usually provided in the startup code.
134
135@item stack pointer
136 The stack pointer has to be set to a suitable memory area.
137 The startup code
138 will set the stack pointer to the value of the pointer @code{__stack}.
139 There is a default stack provided in the C library which will be used
140 unless the application defines its own stack using, for example, the
141 following code (assuming that the stack grows downwards):
142@example
143#define STACKSIZE <whatever>
144
145static long mystack[STACKSIZE/sizeof(long)];
146char *__stack=((char*)mystack)+STACKSIZE;
147@end example
148
149@item calling @code{__main}
150 After all the above initializations have been performed, the function
151 @code{__main()} has to be called. This function is provided by the
152 library and performs high-level initializations, if necessary (mainly
153 it calls constructors created by the linker) and will then call the
154 user @code{main()} function. Note that the library
155 may not work correctly if the user @code{main()} function is called
156 directly from the startup code.
157
158@end table
159
160@subsection Heap
161
162When dynamic memory management is used (e.g. by using the @code{malloc()}
163function), a heap memory area is needed to allocate memory from. The
164@code{malloc()} function assumes that @code{__heapptr} is a variable pointing
165to the beginning of the heap memory and that @code{__heapsize} specifies
166the size of the heap area in bytes. The library will provide a default heap
167memory area that can be replaced by adding, for example, the following file
168to the application:
169@example
170#define HEAPSIZE <whatever>
171
172char __heap[HEAPSIZE],*__heapptr=__heap;
173size_t __heapsize=HEAPSIZE;
174@end example
175
176
177@subsection Input/Output
178
179The standard C input/output functions are provided also for embedded systems.
180Reading/writing to a stream will be directed to void unless the following
181low-level I/O-functions are provided by the application:
182@example
183int __open(const char *name,const char *mode);
184void __close(int h);
185size_t __read(int h,char *p,size_t l);
186size_t __write(int h,const char *p,size_t l);
187off_t __seek(int h,off_t offset,int origin);
188@end example
189
190The @code{__open()} function receives a name and a mode string (as in the C
191@code{fopen()} function) as arguments and has to return a file-descriptor if
192it is possible to open this file. The other functions are equivalent to the
193corresponding POSIX functions. @code{__seek} can be implemented to return
194@code{-1} if the functionality is not needed.
195
196Also, @code{stdin, stdout} and @code{stderr} can be used with the standard
197descriptors.
198
199@subsection CTRL-C Handling
200
201Some targets implement handlers to terminate the program on ctrl-c or a
202similar signal. This usually has the same effect as calling
203@code{exit(20)}.
204
205If you want to change or disable the ctrl-c handling, you can overwrite
206the function @code{void _chkabort(void)}.
207
208@subsection Floating Point
209
210Whether floating point is supported, depends on the target architecture and
211chip. If it is supported, there will usually be a math-library that has to
212be linked (using option @option{-lm}) when floating point is used.
213
214@subsection Useless Functions
215
216Of course, some of the C library functions can not be implemented reasonably on
217embedded systems. These functions are contained in the library but will
218always return an error value. Mainly affected are:
219
220@table @minus
221@item locale
222@item time
223@item signal
224@item filesystem functions
225@end table
226
227Depending on the hardware provided by a system it is possible to implement
228these functions and add them to the application. In this case, the new
229functions will be used rather than the default ones returning only error
230values.
231
232@subsection Linking/Locating
233
234To produce ROM images (e.g. in the form of absolute ELF executables, Intel
235Hex files or Motorola S-Records), the linker is called with a linker script.
236This script can be used to join together different sections of the input files
237and locate them to suitable absolute memory areas. Also, this linker script
238can be used to set symbols that may be used by the application or the startup
239code, e.g. addresses of data sections, initialization values or small data
240pointers.
241
242Code or data that has to reside at special locations can be put into a special
243section using the @code{__section} attribute. This section can then be
244placed at the desired location using the linker script.
245
246Usually, an example linker script will be provided. While this is often not
247suitable for different chips, it may serve as a starting point.
248
249
250@section AmigaOS/68k
251
252This section describes specifics of the C library for AmigaOS/68k
253provided by the target @file{m68k-amigaos}.
254The relevant files are @file{startup.o}, @file{minstart.o}, @file{minres.o},
255@file{vc.lib}, @file{vcs.lib}, @file{mieee.lib}, @file{mieees.lib},
256@file{m881.lib}, @file{m881s.lib}, @file{m040.lib}, @file{m040s.lib},
257@file{m060.lib}, @file{m060s.lib}, @file{msoft.lib}, @file{msofts.lib},
258@file{amiga.lib}, @file{amigas.lib}, @file{auto.lib} and @file{autos.lib},
259@file{reaction.lib}, @file{reactions.lib}.
260
261Note that @file{extra.lib} is no longer part of the vbcc distribution.
262It was replaced by 'PosixLib', available on Aminet
263@file{dev/c/vbcc_PosixLib.lha}, which has a much more comprehensive
264support for POSIX and Unix functions.
265
266The following config files are available:
267@table @code
268@item aos68k
269 Standard startup code (@file{startup.o}) with command line parsing
270 and optional Workbench startup (@xref{Standard Startup}).
271@item aos68km
272 Minimal startup code (@file{minstart.o}) without command line
273 parsing. You have to open all libraries yourself (@xref{Minimal Startup}).
274@item aos68kr
275 Minimal startup code (@file{minres.o}) for resident programs.
276 Always compiles in small data mode and links with @file{vcs.lib}
277 (@xref{Minimal Resident}).
278@end table
279
280@node Standard Startup
281@subsection Startup
282
283 The startup code currently consists of a slightly modified standard
284 Amiga startup (@file{startup.o}). The startup code sets up some
285 global variables and initializes stdin, stdout and stderr.
286 The exit code closes all open files and frees all memory.
287 If you link with a math library the startup/exit code will be taken
288 from there if necessary.
289
290
291@node Floating point
292@subsection Floating point
293
294 Note that you have to link with a math library if you want to use
295 floating point. All math functions, special startup code and
296 printf/scanf functions which support floating point are contained in
297 the math libraries only.
298 At the moment there are five math libraries:
299
300@table @file
301@item mieee.lib
302 This one uses the C= math libraries. The startup code
303 will always open MathIeeeSingBas.library,
304 MathIeeeDoubBas.library and MathIeeeDoubTrans.library.
305 Float return values are passed in d0, double return
306 values are passed in d0/d1.
307 A 68000 is sufficient to use this library.
308 You must not specify @option{-fpu=...}
309 when you use this library.
310 By default all floating point routines are provided via stub functions in
311 @file{mieee.lib}. With the option @option{-amiga-softfloat} you can tell
312 @command{vbccm68k} to generate inline code for calling the
313 MathIeee libraries directly.
314
315@item msoft.lib
316 This one is based on John Hauser's IEC/IEEE Floating-point Arithmetic
317 Package (@xref{SoftfloatHauser}) and doesn't need any system libraries for
318 FP emulation. May be slower than the ROM libraries, though.
319 Otherwise everything mentioned for @file{mieee.lib} applies here
320 as well.
321 Note that you have to call the @command{vc} frontend with the
322 @option{-rmcfg-amiga-softfloat} option, when your config file contains
323 @option{-amiga-softfloat} (which is the case for @file{aos68k}
324 since vbcc V0.9h).
325
326@item m881.lib
327 This one uses direct FPU instructions and function
328 return values are passed in fp0. You must have a
329 68020 or higher and an FPU to use this library. You
330 also have to specify @option{-fpu=68881} or
331 @option{-fpu=68882}.
332 Several FPU instructions that have to be emulated on
333 040/060 may be used.
334
335@item m040.lib
336 This one uses only direct FPU instructions that do not
337 have to be emulated on a 68040. Other functions use
338 the Motorola emulation routines modified by
339 Aki M Laukkanen and Matthew Hey.
340 It should be used for programs compiled for 68040
341 with FPU.
342 Return values are passed in fp0.
343
344@item m060.lib
345 This one uses only direct FPU instructions that do not
346 have to be emulated on a 68060. Other functions use
347 the Motorola emulation routines modified by
348 Aki M Laukkanen and Matthew Hey.
349 It should be used for programs compiled for 68060
350 with FPU.
351 Return values are passed in fp0.
352@end table
353
354Depending on the CPU/FPU selected, including @file{math.h} will
355cause inline-code generated for certain math functions.
356
357@node amiga-stack
358@subsection Stack
359
360An application can specify the stack-size needed by defining a variable
361@code{__stack} (of type @code{size_t}) with external linkage, e.g.
362
363@example
364size_t __stack=65536; /* 64KB stack-size */
365@end example
366
367The startup code will check whether the stack-size specified is larger
368than the default stack-size (as set in the shell) and switch to a new
369stack of appropriate size, if necessary.
370
371If the @option{-stack-check} option is specified when compiling, the
372library will check for a stack overflow and abort the program, if the
373stack overflows. Note, however, that only code compiled with this
374option will be checked. Calls to libraries which have not been compiled
375with @option{-stack-check} or calls to OS function may cause a stack
376overflow which is not noticed.
377
378Additionally, if @option{-stack-check} is used, the maximum stack-size
379used can be read by querying the external variable @code{__stack_usage}.
380
381@example
382#include <stdio.h>
383
384extern size_t __stack_usage;
385
386main()
387@{
388 do_program();
389 printf("stack used: %lu\n",(unsigned long)__stack_usage);
390@}
391@end example
392
393Like above, the stack used by functions not compiled using
394@option{-stack-check} or OS functions is ignored.
395
396@node amigasmalldata
397@subsection Small data model
398
399When using the small data model of the 68k series CPUs, you also have
400to link with appropriate libraries. Most libraries documented here are
401also available as small data versions (with an 's' attached to the
402file name). Exceptions are the math libraries.
403
404To compile and link a program using the small data model a command like
405
406@example
407vc test.c -o test -sd -lvcs -lamigas
408@end example
409
410might be used.
411
412@subsection Restrictions
413
414The following list contains some restrictions of this version of the
415library:
416
417@table @code
418
419@item tmpfile()
420The @code{tmpfile()} function always returns an error.
421
422@item clock()
423The @code{clock()} function always returns -1. This is correct,
424according to the C standard, because on AmigaOS it is not possible to
425obtain the time used by the calling process.
426
427@end table
428
429@node Minimal Startup
430@subsection Minimal Startup
431
432If you want to write programs that use only Amiga functions and none from
433vc.lib you can use @file{minstart.o} instead of @file{startup.o} and
434produce smaller executables. You can also achieve that by simply using
435the @file{aos68km} config file instead.
436
437This startup code does not set up everything needed by vc.lib, so you
438must not use most of these functions (string and ctype functions are ok,
439but most other functions - especially I/O and memory handling - must not
440be used).
441@code{exit()} is supplied by minstart and can be used.
442
443The command line is not parsed, but passed to @code{main()} as a single
444string,
445so you can declare main as
446@code{int main(char *command)} or @code{int main(void)}.
447
448Also no Amiga libraries are opened (but @code{SysBase} is set up), so you
449have to define and open @code{DOSBase} yourself if you need it.
450If you want to use floating point with the IEEE libraries
451or @option{-amiga-softfloat} you have to
452define and open MathIeeeSingBas.library, MathIeeeDoubBas.library and
453MathIeeeDoubTrans.library (in this order!) and link with mieee.lib (if
454compiled for FPU this is not needed).
455
456A hello world using minstart could look like this:
457
458@example
459#include <proto/exec.h>
460#include <proto/dos.h>
461
462struct DosLibrary *DOSBase;
463
464int main()
465@{
466 if(DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",0))@{
467 Write(Output(),"Hello, world!\n",14);
468 CloseLibrary((struct Library *)DOSBase);
469 @}
470 return 0;
471@}
472
473@end example
474
475This can yield an executable of under 256 bytes when compiled with
476@option{-sc -sd} and linked with @file{minstart.o} and @code{amigas.lib}
477(using @command{vlink} - may not work with other linkers).
478
479@node Minimal Resident
480@subsection Minimal Startup for resident programs
481
482AmigaOS can keep special "pure" programs resident in RAM, and restart them
483from there without having to load them again from disk. To make it easy to
484create such reentrant programs, even with static data, you can link with the
485special startup code @file{minres.o}, which is a minimal startup code for
486resident programs. Or simply use the config file @file{aos68kr} instead.
487Everything mentioned for @file{minstart.o} in the previous section is also
488valid for @file{minres.o}.
489
490To create real resident programs you have to follow the following rules:
491@itemize @minus
492
493@item Compile all your code for the small data model (@option{-sd} option).
494
495@item Avoid absolute references to small data symbols.
496 Usually these are constant pointers to static data.
497 The following example creates such an illegal relocation:
498@example
499int x;
500int const *p = &x;
501@end example
502@command{vlink} warns about all potential problems.
503
504@item Link with the @file{minres.o} startup code,
505 and use the small data
506 versions of linker libraries (@file{vcs.lib}, @file{amigas.lib}, etc.).
507
508@item Set the Pure flag in the file attributes.
509 Load the program into RAM
510 with the AmigaDOS @command{resident} command.
511
512@end itemize
513
514
515@node amigalib
516@subsection amiga.lib
517
518To write programs using AmigaOS (rather than standard C functions
519only), a replacement for the original (copyrighted) @file{amiga.lib}
520is provided with @command{vbcc}. This replacement is adapted to vbcc,
521does not cause collisions with some functions (e.g. @code{sprintf})
522provided by the original @file{amiga.lib} and is available for the
523small data mode as well. It is recommended to always use this library
524rather than the original version.
525
526Additionally, there are header files (in the @file{proto}- and
527@file{inline}-subdirectories) which cause inlined calls to Amiga
528library functions.
529
530Besides some support functions @file{amiga.lib} contains stub routines
531to call functions from all common AmigaOS libraries with stack arguments.
532By including the library's proto header file you make sure that AmigaOS
533functions are called directly by inline code, unless @code{_NO_INLINE}
534is defined.
535
536Preprocessor defines to control the behaviour of vbcc's proto headers:
537@table @code
538@item __NOLIBBASE__
539 Do not declare the library base symbol.
540@item _NO_INLINE
541 Do not use optimized inline code for library function calls.
542@end table
543
544Note that the OS-call inlines have been generated using the NDK3.2 clib
545header files, while trying to keep compatibility to NDK3.9, so it is
546advised to use one of the two NDKs for development.
547Otherwise you will get warnings about missing @code{CONST} typedefs and
548similar.
549
550Specify @option{-lamiga} to link with @file{amiga.lib}.
551
552@node autolib
553@subsection auto.lib
554
555 To link with @file{auto.lib} (or the small data version
556 @file{autos.lib}) specify
557 the @option{-lauto} or @option{-lautos} option to @command{vc}.
558
559 When you are calling a standard Amiga library function without
560 having defined the corresponding library base, then the library base
561 as well as code to open/close it will be taken from @file{auto.lib}.
562
563 By default, @file{auto.lib} will try to open any library version. If you
564 need at least a certain version you can define and set a variable
565 _<library-base>Ver with external linkage, e.g. (on file-scope):
566
567@example
568 int _IntuitionBaseVer = 39;
569@end example
570
571 Note that your program will abort before reaching @code{main()} if one
572 of the libraries cannot be opened. Also note that @file{auto.lib}
573 depends on constructor/destructor handling in vclib, which means it
574 cannot work when linking without vclib, without standard startup code,
575 or only with a minimal startup code, like @file{minstart.o}.
576
577@subsection reaction.lib
578
579The @file{reaction.lib} in @command{vbcc} is a port of Stephan Rupprecht's
580rewrite of the copyrighted linker library, extended and fixed by
581Olaf Barthel for the NDK 3.2 release. This version should work in
582combination with NDK 3.9 as well.
583
584To link with @file{reaction.lib} (or the small data version
585@file{reactions.lib}) specify the @option{-lreaction} or
586@option{-lreactions} option to @command{vc}.
587
588The library contains ReAction GUI class support functions and their
589autoinitialization code. Refer to @file{reaction_lib.doc} from your
590NDK Autodocs for more information. As documented there, the version
591used to automatically open the classes can be defined by the variable
592@code{__reactionversion} with external linkage. Otherwise a default
593of version 0 is used.
594
595
596@section Kickstart1.x/68k
597
598This section describes specifics of the C library for Amiga Kickstart 1.2
599and 1.3 provided by the target @file{m68k-kick13}.
600The relevant files are @file{startup.o}, @file{minstart.o}, @file{minres.o},
601@file{startup16.o}, @file{minstart16.o}, @file{minres16.o},
602@file{vc.lib}, @file{vcs.lib}, @file{m13.lib}, @file{m13s.lib},
603@file{msoft.lib}, @file{msofts.lib}, @file{m881.lib}, @file{m881s.lib},
604@file{amiga.lib}, @file{amigas.lib}, @file{auto.lib} and @file{autos.lib},
605@file{vc16.lib}, @file{vc16s.lib}, @file{m1316.lib}, @file{m1316s.lib},
606@file{msoft16.lib}, @file{msoft16s.lib}, @file{m88116.lib}, @file{m88116s.lib},
607@file{amiga16.lib}, @file{amiga16s.lib}, @file{auto16.lib} and
608@file{auto16s.lib}.
609
610This target makes it possible to develop programs targeted for these older
611versions of the Amiga operating system, using the original Commodore
612Kickstart 1.3 header files. Note that there are also libraries and
613config files for using a 16-bit int ABI, which was common at that time,
614and may have some advantages on 16-bit CPUs, like the 68000 or 68010.
615
616The following config files are available:
617@table @code
618@item kick13
619 Standard startup code (@file{startup.o}) with command line parsing
620 and optional Workbench startup (@xref{Startup13}) using 32-bit int.
621@item kick13m
622 Minimal startup code (@file{minstart.o}) without command line
623 parsing. You have to open all libraries yourself (@xref{Minimal Startup})
624 using 32-bit int.
625@item kick13r
626 Minimal startup code (@file{minres.o}) for resident programs.
627 Always compiles in small data mode and links with @file{vcs.lib}
628 (@xref{Minimal Resident}) using 32-bit int.
629@item kick13s
630 Standard startup code (@file{startup.o}) with command line parsing
631 and optional Workbench startup (@xref{Startup13}) using 16-bit int.
632@item kick13sm
633 Minimal startup code (@file{minstart.o}) without command line
634 parsing. You have to open all libraries yourself (@xref{Minimal Startup})
635 using 16-bit int.
636@item kick13sr
637 Minimal startup code (@file{minres.o}) for resident programs.
638 Always compiles in small data mode and links with @file{vcs.lib}
639 (@xref{Minimal Resident}) using 16-bit int.
640@end table
641
642@node Startup13
643@subsection Startup
644
645 The startup code currently consists of a slightly modified standard
646 AmigaOS 1.3 startup (@file{startup.o}). The startup code sets up some
647 global variables and initializes stdin, stdout and stderr.
648 The exit code closes all open files and frees all memory.
649 If you link with a math library the startup/exit code will be taken
650 from there if necessary.
651
652
653@subsection Floating point
654
655 Note that you have to link with a math library if you want to use
656 floating point. All math functions, special startup code and
657 printf/scanf functions which support floating point are contained in
658 the math libraries only.
659 At the moment there are two math libraries:
660
661@table @file
662@item m13.lib
663 This one uses the C= math libraries present under Kickstart 1.2 and 1.3.
664 The startup code will always open mathffp.library,
665 MathIeeeDoubBas.library and MathIeeeDoubTrans.library.
666 Note that all single precision floating point calculations take place
667 in FFP format and have to be converted between FFP and IEEE by the
668 library.
669 Float return values are passed in d0, double return
670 values are passed in d0/d1.
671 A 68000 is sufficient to use this library.
672 You must not specify @option{-fpu=...}
673 when you use this library.
674
675@item msoft.lib
676 This one is based on John Hauser's IEC/IEEE Floating-point Arithmetic
677 Package (@xref{SoftfloatHauser}) and doesn't need any system libraries for
678 FP emulation. May be slower than the ROM libraries, though.
679 Otherwise everything mentioned for @file{m13.lib} applies here
680 as well.
681
682@item m881.lib
683 This one uses direct FPU instructions and function
684 return values are passed in fp0. You must have a
685 68020 or higher and an FPU to use this library. You
686 also have to specify @option{-fpu=68881}.
687 Several FPU instructions that have to be emulated on
688 040/060 may be used.
689@end table
690
691@subsection Stack
692
693Stack-checking is available similar to AmigaOS/68k (@xref{amiga-stack}).
694But there is no automatic stack-extension under Kickstart 1.3 and a
695@code{__stack} variable will be ignored.
696
697@subsection Small data model
698
699Small data is supported as described for AmigaOS/68k (@xref{amigasmalldata}).
700The startup code takes care of clearing the unititalized part of a
701small data section (which Kickstart 1.x fails to do).
702
703@subsection Restrictions
704
705The following list contains some restrictions of this version of the
706library:
707
708@table @code
709
710@item tmpfile()
711The @code{tmpfile()} function always returns an error.
712
713@item clock()
714The @code{clock()} function always returns -1. This is correct,
715according to the C standard, because on AmigaOS it is not possible to
716obtain the time used by the calling process.
717
718@end table
719
720@subsection amiga.lib
721
722@xref{amigalib}.
723
724This version of @file{amiga.lib} only supports the functionality present
725in Kickstart 1.2/1.3.
726
727@subsection auto.lib
728
729This library corresponds to the AmigaOS/68k version (@xref{autolib}), but
730only supports libraries of Kickstart 1.3.
731
732@subsection Minimal Startup
733
734You can use @file{minstart.o} similar to AmigaOS/68k (@xref{Minimal Startup}).
735
736@subsection Minimal Startup for Resident Programs
737
738You can use @file{minres.o} similar to AmigaOS/68k (@xref{Minimal Resident}).
739
740
741@section PowerUp/PPC
742
743This section describes specifics of the C library for PowerUp/PPC
744provided by the target @file{ppc-powerup}.
745The relevant files are @file{startup.o}, @file{minstart.o},
746@file{libvc.a}, @file{libvcs.a}, @file{libm.a}, @file{libms.a}
747@file{libamiga.a}, @file{libamigas.a},
748@file{libauto.a} and @file{libautos.a}.
749
750Note that @file{libextra.a} is no longer part of the vbcc distribution.
751It was replaced by 'PosixLib', available on Aminet
752@file{dev/c/vbcc_PosixLib.lha}, which has a much more comprehensive
753support for POSIX and Unix functions.
754
755@subsection Startup
756
757 The startup code @file{startup.o} sets up some
758 global variables and initializes stdin, stdout and stderr.
759 The exit code closes all open files and frees all memory.
760 If you link with a math library the startup/exit code will be taken
761 from there if necessary.
762
763@subsection Floating point
764
765 Note that you have to link with a math library if you want to use
766 floating point. All math functions, special startup code and
767 printf/scanf functions which support floating point are contained in
768 the math libraries only.
769
770 The math library (@file{libm.a}) is linked against the floating point
771 library libmoto by Motorola.
772
773Depending on the CPU/FPU selected, including @file{math.h} will
774cause inline-code generated for certain math functions.
775
776@subsection Stack
777
778Stack-handling is similar to AmigaOS/68k (@xref{amiga-stack}).
779The only difference is that stack-swapping cannot be done. If the
780default stack-size is less than the stack-size specified with
781@code{__stack} the program will abort.
782
783@subsection Small data model
784
785When using the small data model of the PPC series CPUs, you also have
786to link with appropriate libraries. Most libraries documented here are
787also available as small data versions (with an 's' attached to the
788file name). Exceptions are the math libraries.
789
790To compile and link a program using the small data model a command like
791
792@example
793vc test.c -o test -sd -lvcs -lamigas
794@end example
795
796might be used.
797
798@subsection Restrictions
799
800The following list contains some restrictions of this version of the
801library:
802
803@table @code
804
805@item tmpfile()
806The @code{tmpfile()} function always returns an error.
807
808@item clock()
809The @code{clock()} function always returns -1. This is correct,
810according to the C standard, because on AmigaOS it is not possible to
811obtain the time used by the calling process.
812
813@end table
814
815@subsection Minimal Startup
816
817The provided minimal startup code (@file{minstart.o}) is used
818similarly like the one for 68k (@xref{Minimal Startup}). Only use
819it if you know what you are doing.
820
821@subsection libamiga.a
822
823To write programs accessing AmigaOS (rather than standard C functions
824only), a replacement for the original (copyrighted) @file{amiga.lib}
825is provided with @command{vbcc}. This replacement (@file{libamiga.a})
826automatically performs a necessary context switch to the 68k to execute
827the system call. Furthermore, it is adapted to vbcc,
828does not cause collisions with some functions (e.g. @code{sprintf})
829provided by the original @file{amiga.lib} and is available in
830small data.
831
832Specify @option{-lamiga} to link with @file{libamiga.a}.
833
834@subsection libauto.a
835
836This library corresponds to the AmigaOS/68k version (@xref{autolib}).
837
838@section WarpOS/PPC
839
840This section describes specifics of the C library for WarpOS/PPC
841provided by the target @file{ppc-warpos}.
842The relevant files are @file{startup.o},
843@file{vc.lib}, @file{m.lib}, @file{amiga.lib} and @file{auto.lib}.
844
845Note that @file{extra.lib} is no longer part of the vbcc distribution.
846It was replaced by 'PosixLib', available on Aminet
847@file{dev/c/vbcc_PosixLib.lha}, which has a much more comprehensive
848support for POSIX and Unix functions.
849
850@subsection Startup
851
852 The startup code @file{startup.o} sets up some
853 global variables and initializes stdin, stdout and stderr.
854 The exit code closes all open files and frees all memory.
855 If you link with a math library the startup/exit code will be taken
856 from there if necessary.
857
858@subsection Floating point
859
860 Note that you have to link with a math library if you want to use
861 floating point. All math functions, special startup code and
862 printf/scanf functions which support floating point are contained in
863 the math libraries only.
864
865 The math library (@file{m.lib}) contains functions from Sun's
866 portable floating point library. Additionally, there is a
867 @command{vbcc} version of Andreas Heumann's @file{ppcmath.lib}.
868 These routines are linked against Motorola's floating point
869 routines optimized for PowerPC and therefore are much faster.
870
871 To make use of this library, link with @file{ppcmath.lib} before
872 @file{m.lib}, e.g.
873
874@example
875 vc test.c -lppcmath -lm
876@end example
877
878
879
880Depending on the CPU/FPU selected, including @file{math.h} will
881cause inline-code generated for certain math functions.
882
883@subsection Stack
884
885Stack-handling is similar to AmigaOS/68k (@xref{amiga-stack}).
886
887@subsection Restrictions
888
889The following list contains some restrictions of this version of the
890library:
891
892@table @code
893
894@item tmpfile()
895The @code{tmpfile()} function always returns an error.
896
897@item clock()
898The @code{clock()} function always returns -1. This is correct,
899according to the C standard, because on AmigaOS it is not possible to
900obtain the time used by the calling process.
901
902@end table
903
904@subsection amiga.lib
905
906To write programs accessing AmigaOS (rather than standard C functions
907only), a replacement for the original (copyrighted) @file{amiga.lib}
908is provided with @command{vbcc}. This replacement
909automatically performs a necessary context switch to the 68k to execute
910the system call. Furthermore, it is adapted to vbcc,
911does not cause collisions with some functions (e.g. @code{sprintf})
912provided by the original @file{amiga.lib} and is available in
913small data.
914
915Specify @option{-lamiga} to link with @file{amiga.lib}.
916
917
918@subsection auto.lib
919
920This library corresponds to the AmigaOS/68k version (@xref{autolib}).
921
922
923@section MorphOS/PPC
924
925This section describes specifics of the C library for MorphOS/PPC
926provided by the target @file{ppc-morphos}.
927The relevant files are @file{startup.o}, @file{minstart.o},
928@file{libvc.a}, @file{libvcs.a}, @file{libm.a}, @file{libms.a}
929@file{libamiga.a}, @file{libamigas.a},
930@file{libauto.a} and @file{libautos.a}.
931
932Note that @file{libextra.a} is no longer part of the vbcc distribution.
933It was replaced by 'PosixLib', available on Aminet
934@file{dev/c/vbcc_PosixLib.lha}, which has a much more comprehensive
935support for POSIX and Unix functions.
936
937@subsection Startup
938
939 The startup code @file{startup.o} sets up some
940 global variables and initializes stdin, stdout and stderr.
941 The exit code closes all open files and frees all memory.
942 If you link with a math library the startup/exit code will be taken
943 from there if necessary.
944
945@subsection Floating point
946
947 Note that you have to link with a math library if you want to use
948 floating point. All math functions, special startup code and
949 printf/scanf functions which support floating point are contained in
950 the math libraries only.
951
952 The math library (@file{libm.a}) is linked against the floating point
953 library libmoto by Motorola.
954
955Depending on the CPU/FPU selected, including @file{math.h} will
956cause inline-code generated for certain math functions.
957
958@subsection Stack
959
960Stack-handling is similar to AmigaOS/68k (@xref{amiga-stack}).
961
962@subsection Small data model
963
964When using the small data model of the PPC series CPUs, you also have
965to link with appropriate libraries. Most libraries documented here are
966also available as small data versions (with an 's' attached to the
967file name). Exceptions are the math libraries.
968
969To compile and link a program using the small data model a command like
970
971@example
972vc test.c -o test -sd -lvcs -lamigas
973@end example
974
975might be used.
976
977@subsection Restrictions
978
979The following list contains some restrictions of this version of the
980library:
981
982@table @code
983
984@item tmpfile()
985The @code{tmpfile()} function always returns an error.
986
987@item clock()
988The @code{clock()} function always returns -1. This is correct,
989according to the C standard, because on MorphOS it is not possible to
990obtain the time used by the calling process.
991
992@end table
993
994@subsection libamiga.a
995
996To write programs using AmigaOS compatible functions, a replacement for
997the original (copyrighted) @file{amiga.lib}
998is provided with @command{vbcc}. This replacement (@file{libamiga.a})
999will invoke the MorphOS 68k emulator to execute the system function.
1000Furthermore, it is adapted to vbcc and
1001does not cause collisions with some functions (e.g. @code{sprintf})
1002and is available in small data.
1003
1004Specify @option{-lamiga} to link with @file{libamiga.a}.
1005
1006
1007@subsection libauto.a
1008
1009This library corresponds to the AmigaOS/68k version (@xref{autolib}).
1010
1011
1012@section AmigaOS4/PPC
1013
1014This section describes specifics of the C library for AmigaOS4/PPC
1015provided by the target @file{ppc-amigaos}.
1016The relevant files are @file{startup.o}, @file{minstart.o},
1017@file{libvc.a}, @file{libvcs.a}, @file{libm.a}, @file{libms.a}
1018@file{libamiga.a}, @file{libamigas.a},
1019@file{libauto.a} and @file{libautos.a}.
1020
1021Note that @file{libextra.a} is no longer part of the vbcc distribution.
1022It was replaced by 'PosixLib', available on Aminet
1023@file{dev/c/vbcc_PosixLib.lha}, which has a much more comprehensive
1024support for POSIX and Unix functions.
1025
1026@subsection Startup
1027
1028The startup code @file{startup.o} sets up some
1029global variables and initializes stdin, stdout and stderr.
1030Then it runs all constructors of dynamically linked libraries, before
1031entering the main program.
1032The exit code runs all destructors of dynamically linked libraries,
1033closes all open files and frees all memory.
1034If you link with a math library the startup/exit code will be taken
1035from there if necessary.
1036
1037@subsection Floating point
1038
1039Note that you have to link with a math library if you want to use
1040floating point. All math functions, special startup code and
1041printf/scanf functions which support floating point are contained in
1042the math libraries only.
1043
1044The math library (@file{libm.a}) is linked against the floating point
1045library libmoto by Motorola.
1046
1047Depending on the CPU/FPU selected, including @file{math.h} will
1048cause inline-code generated for certain math functions.
1049
1050@subsection Stack
1051
1052There is no automatic stack extension for AmigaOS 4! This should be
1053done automatically by the operating system.
1054
1055@subsection Small data model
1056
1057When using the small data model of the PPC series CPUs, you also have
1058to link with appropriate libraries. Most libraries documented here are
1059also available as small data versions (with an 's' attached to the
1060file name). Exceptions are the math libraries.
1061
1062To compile and link a program using the small data model a command like
1063
1064@example
1065vc test.c -o test -sd -lvcs -lamigas
1066@end example
1067
1068might be used.
1069
1070@subsection Dynamic linking
1071Since @file{elf.library} @code{V52.2} AmigaOS4 supports dynamic linking with
1072shared object files (@file{.so} extension), similar to Unix. The default
1073behaviour is to prefer linking against a shared object over a static
1074library. To force static linking you might want to give the
1075@option{-static} option to the @file{vc} frontend.
1076
1077@subsection Restrictions
1078
1079The following list contains some restrictions of this version of the
1080library:
1081
1082@table @code
1083
1084@item tmpfile()
1085The @code{tmpfile()} function always returns an error.
1086
1087@item clock()
1088The @code{clock()} function always returns -1. This is correct,
1089according to the C standard, because on AmigaOS it is not possible to
1090obtain the time used by the calling process.
1091
1092@item Small data in dynamically linked executables
1093There is a bug in @file{elf.library} @code{V52.4} (and earlier), which
1094doesn't load @code{.sdata} and @code{.sbss} as a contiguous block into
1095memory, when the executable requires dynamic linking. I decided against
1096writing a workaround, as the bug should be fixed in OS4.
1097
1098@end table
1099
1100@subsection libamiga.a
1101
1102In contrast to other amigalibs the OS4 @file{libamiga.a} doesn't contain
1103any stubs for calling system functions. AmigaOS 4 system calls are done
1104through special macros in the SDK's interface header files.
1105
1106The library only includes some remaining amigalib functions, not already
1107integrated into the OS, like @code{CreateIO()}, but its use is discouraged.
1108
1109Specify @option{-lamiga} to link with @file{libamiga.a}.
1110
1111
1112@subsection libauto.a
1113
1114Include auto-open and -close functions for the most common OS libraries and
1115interfaces. May also be used together with newlib (see below).
1116
1117
1118@subsection newlib
1119
1120@subsubsection Introduction
1121
1122 newlib.library is a shared AmigaOS4 library, which is covered by
1123 several BSD like licenses,
1124 and includes standard ANSI and POSIX functions as well as some
1125 functions common in Unix, BSD and similar operating systems. It is
1126 part of the OS4 SDK.
1127
1128 The config file @file{newlib} will be created on installation to
1129 use the paths for header files and libraries pointing to the
1130 newlib from the SDK.
1131
1132 What are the main differences between vclib and newlib?
1133
1134@itemize @minus
1135@item vclib contains (almost) only standard ANSI-C and some ISO-C99
1136 functions. If you want to port Unix programs you will probably
1137 miss a lot of functions.
1138 Also newlib supports things like mapping Unix directory paths to
1139 Amiga paths or expanding wildcards in command lines automatically.
1140
1141@item Programs compiled for newlib will be shorter because the code for all
1142 functions is not contained in the executable itself.
1143
1144@item Programs compiled for newlib will need the shared object
1145 @file{libc.so} present when started.
1146
1147@item Programs compiled for newlib will probably need more memory because
1148 the entire (rather large) @file{libc.so} will be loaded into memory.
1149 With vclib only the functions your program uses will be in RAM.
1150 However if you have several programs using newlib at the same
1151 time only one copy of @file{libc.so} should be loaded.
1152@end itemize
1153
1154 Things you should note:
1155
1156@itemize @minus
1157@item With newlib you do not need extra math-libraries.
1158
1159@item You must link with a vbcc-specific @file{startup.o} from the newlib
1160 @file{lib/} directory as startup code.
1161 The config-file @file{newlib} will usually take care of this.
1162
1163@item You _must_ use the newlib-includes from the SDK
1164 rather than the ones which are for vc.lib.
1165 The config-file @file{newlib} will usually take care of this.
1166
1167@item There may be vbcc-related bugs in the SDK-newlib. Patches are
1168 automatically installed when using the Amiga Installer. When
1169 installing the target manually, you also have to fix the SDK
1170 manually. For a list of known SDK bugs at this point of time,
1171 @xref{Known Newlib Bugs}.
1172@end itemize
1173
1174@node Known Newlib Bugs
1175@subsubsection Known Newlib Bugs
1176
1177@itemize @minus
1178
1179@item The @code{__asm_toupper()} and @code{__asm_tolower()} assembler inlines
1180 in @file{newlib/include/ctype.h} are wrong, which makes
1181 @code{toupper()} and @code{tolower()} fail when including
1182 @file{ctype.h}. Fix:
1183@example
1184--- ctype.h.orig 2006-04-03 18:00:00.000000000 +0200
1185+++ ctype.h 2017-05-07 19:32:00.000000000 +0200
1186@@@@ -64,8 +64,8 @@@@
1187 #elif defined(__VBCC__)
1188 int __asm_toupper(__reg("r3") int) =
1189 "\t.extern\t__ctype_ptr\n"
1190- "\tlis\t11,(__ctype_ptr)@@ha\n"
1191- "\taddi\t11,11,(__ctype_ptr)@@l\n"
1192+ "\tlis\t11,__ctype_ptr@@ha\n"
1193+ "\tlwz\t11,11,__ctype_ptr@@l(11)\n"
1194 "\tlbzx\t12,11,3\n"
1195 "\tandi.\t12,12,2\n"
1196 "\tbeq\t$+8\n"
1197@@@@ -73,8 +73,8 @@@@
1198 "#barrier";
1199 int __asm_tolower(__reg("r3") int) =
1200 "\t.extern\t__ctype_ptr\n"
1201- "\tlis\t11,(__ctype_ptr)@@ha\n"
1202- "\taddi\t11,11,(__ctype_ptr)@@l\n"
1203+ "\tlis\t11,__ctype_ptr@@ha\n"
1204+ "\tlwz\t11,11,__ctype_ptr@@l(11)\n"
1205 "\tlbzx\t12,11,3\n"
1206 "\tandi.\t12,12,1\n"
1207 "\tbeq\t$+8\n"
1208@end example
1209Note: This should be fixed with the latest OS4 SDK, and the V0.9h
1210installer will no longer install a patch!
1211
1212@item Newlib's @file{libauto.a} contains no working vbcc-style
1213constructors or destructors for auto-opening or -closing of libraries.
1214You can work-around it, by copying vclib's @file{libauto.a} to
1215newlib's lib-directory. Rename it, if you don't want to overwrite
1216the gcc-version of it.
1217
1218@item Some header files, like @file{sys/stat.h}, use the reserved vbcc
1219attribute @code{__mask} as an argument name. The config file should
1220take care of that, by redefining it as @code{___mask}.
1221
1222@end itemize
1223
1224@subsubsection Usage
1225
1226To compile a program to use newlib for OS4 you must make sure the proper
1227config-file (@file{newlib}) is used, e.g.
1228
1229@example
1230 vc +newlib hello.c
1231@end example
1232
1233With a new SDK this will usually generate a dynamically linked executable,
1234which requires @file{libc.so}. To force a statically linked executable:
1235
1236@example
1237 vc +newlib -static hello.c
1238@end example
1239
1240
1241@section Atari TOS/MiNT
1242
1243This section describes specifics of the C library for Atari TOS and MiNT.
1244M680x0 processors are supported by the target @file{m68k-atari}, while
1245ColdFire processors are supported by the target @file{cf-atari}. Both
1246share the same startup-code and are based on common library sources and
1247header files. Executables linked with this C library run on plain TOS as
1248well as on MiNT, without modifications.
1249
1250The relevant files are @file{startup.o}, @file{minstart.o},
1251@file{libvc.a}, @file{libm.a}, @file{libgem.a}. For the M68k target
1252there are also math libs with FPU support (@file{libm881.a},
1253@file{libm040.a} and @file{libm060.a}) and 16-bit integer versions
1254of all libraries (@file{lib*16.a}).
1255
1256The following config files are available:
1257@table @code
1258@item tos
1259 M68k 32-bit @code{int} for classic TOS machines.
1260@item tos16
1261 M68k 16-bit @code{int} for classic TOS machines.
1262@item mint
1263 M68k 32-bit @code{int} for MiNT. Also works on classic machines,
1264 but uses an embedded a.out header for MiNT, includes a changeable
1265 @code{__stksize} and sets the FastLoad, FastRAM and FastAlloc flags
1266 in the header.
1267@item mintcf
1268 ColdFire 32-bit @code{int}. Otherwise same as @file{mint}.
1269@end table
1270
1271@subsection Startup
1272
1273The startup code @file{startup.o} sets up some
1274global variables and initializes stdin, stdout and stderr and returns
1275the unneeded memory to the system.
1276The exit code closes all open files and frees all memory.
1277
1278@subsection Floating point
1279
1280Note that you have to link with a math library if you want to use
1281floating point. All math functions, special startup code and
1282printf/scanf functions which support floating point are contained in
1283the math libraries only.
1284
1285On the M68k target you have the option to enable FPU support with
1286the @option{-fpu} option and choose the appropriate math library
1287(@xref{Floating point}). Otherwise, there is a soft-float library,
1288which is compatible with all the Atari models without an FPU.
1289
1290@subsection Stack
1291
1292The default stack size is 64k. There is a MiNT tool called @file{stack}
1293which can adjust the stack size of an executable to any value, by looking
1294for a symbol named @code{__stksize} (defined by vclib's startup code).
1295
1296Additionally the required stack size can be specified by defining a
1297variable @code{__stack} (of type @code{size_t}) with external linkage, as
1298in other vbcc targets.
1299
1300@subsection 16-bit integer model
1301
1302The default libraries use 32-bit @code{int} types, but you may want to
1303use 16-bit @code{int} types for compatibility reasons. In this case you
1304have to specify the config file @code{tos16} and link with the appropriate
130516-bit libraries (which have a '@file{16}' attached to their name).
1306
1307To compile and link a program using 16-bit integers a command like
1308
1309@example
1310vc +tos16 test.c -o test -lm16 -lvc16
1311@end example
1312
1313may be used. There are no 16-bit versions for ColdFire targets,
1314because this is strictly a 32-bit CPU.
1315
1316@subsection Restrictions
1317
1318The following list contains some restrictions of this version of the
1319library:
1320
1321@table @code
1322
1323@item tmpfile()
1324The @code{tmpfile()} function always returns an error.
1325
1326@item clock()
1327The @code{clock()} function always returns -1. This is correct,
1328according to the C standard, because neither under TOS nor under MiNT it
1329is possible to obtain the time used by the calling process.
1330
1331@end table
1332
1333@section VideoCore/Linux
1334
1335This section describes specifics of the C library for VideoCore under Linux
1336provided by the target @file{vidcore-linux}.
1337
1338The relevant files are @code{vcload}, @file{startup.o},
1339@file{libvc.a}, @file{libm.a}, @file{libms.a}.
1340
1341The config file @code{vc4-linux} is part of the library.
1342
1343@subsection Startup
1344
1345The startup code @file{startup.o} sets up stack and heap and provides
1346a function @code{__armcall()} to transfer control to the loader on
1347the ARM side.
1348The startup process calls constructors to set up some
1349global variables and initialize stdin, stdout and stderr if needed.
1350
1351@subsection Floating point
1352
1353Note that you have to link with a math library if you want to use
1354floating point operations that are not natively implemented.
1355All math functions, special startup code and
1356printf/scanf functions which support floating point are contained in
1357the math libraries only.
1358
1359@subsection Stack
1360
1361The library contains a default stack of 32KB. If another size is needed,
1362you can add the following to your project:
1363
1364@example
1365 .align 4
1366 .space <desired-size, suitably aligned>
1367___stackend:
1368 .global ___stackend
1369@end example
1370
1371@subsection Heap
1372
1373Currently, a global variable of 16KB is used to get memory for
1374malloc() etc. If another size is needed,
1375you can add the following to your project:
1376
1377@example
1378#define HEAPSIZE <desired size>
1379
1380char __heap[HEAPSIZE],*__heapptr=__heap;
1381size_t __heapsize=HEAPSIZE;
1382@end example
1383
1384Note that this mechanism will likely be changed in the future!
1385
1386@subsection System Calls
1387
1388To access system functions from the VideoCore-side, the function
1389@code{__armcall()} can be used. It will save the current context and return
1390to the loader. Registers @code{r0-r5} (the function arguments) will be saved
1391and are available to the loader. The loader can then execute the system
1392call and resume execution, passing the return value of the system
1393function.
1394
1395Resuming is done by calling the image with offset 2.
1396
1397This functionality can also be used for debugging purposes.
1398
1399@subsection Loader
1400
1401A loader is required to execute VideoCore code from the ARM side. For
1402standalone VideoCore code, the provided loader can be used. Usually, it
1403will be necessary to adapt the loader to communicate between ARM and
1404VideoCore side during runtime.
1405
1406@subsubsection Object Format
1407
1408Currently, the loader loads an simple binary image that must be pc-relative
1409and located to address 0x00000000. Additionally, if present, a file
1410with extension @file{.reltext} will be loaded for some limited
1411relocation. This file contains a 32bit word containing the number of
1412relocations followed by n 32bit words containing an offset. For each
1413offset, the address will be relocated to the image load address.
1414
1415@subsubsection Command line arguments
1416
1417@code{vcload [-debug] [-cache] [-offset] <image-name>}
1418
1419The loader currently has the following options:
1420
1421@table @code
1422
1423@item -debug
1424
1425 The loader will enter debug mode (see below).
1426
1427@item -cache
1428
1429 The loader will set the LSB in the start address when executing
1430 code. This is supposed to inhibit a cache flush.
1431
1432 Just for testing!
1433
1434@item -offset
1435
1436 The loader will allocate 1 KB more memory than required and leaves
1437 this space unused at the beginning of the allocated memory.
1438
1439 Just for testing!
1440
1441@end table
1442
1443@subsubsection Debug Mode
1444
1445In debug mode, the loader will wait for user input before starting the
1446VideoCore code as well as after every @code{__armcall}.
1447
1448The following commands are available:
1449
1450@table @code
1451@item w <addr> [<num>]
1452 Display <num> 32bit words starting at <addr>.
1453 <addr> must be the offset into the image. If <num> is omitted,
1454 one unit is displayed.
1455
1456 If one word is displayed, it is additionally displayed translated
1457 as an offset into the image.
1458
1459@item h <addr> [<num>]
1460 Display <num> 16bit halfwords starting at <addr>.
1461 <addr> must be the offset into the image. If <num> is omitted,
1462 one unit is displayed.
1463
1464@item b <addr> [<num>]
1465 Display <num> 8bit bytes starting at <addr>.
1466 <addr> must be the offset into the image. If <num> is omitted,
1467 one unit is displayed.
1468
1469@item c
1470 Start/continue execution.
1471
1472@item q
1473 Quit.
1474
1475@item bp <addr>
1476 Set a breakpoint at <addr>.
1477
1478 This is currently a very crude implementation. It will just write
1479 a branch to @code{__armcall()} to <addr>. If everything works well,
1480 you will end in the debugger if <addr> is reached. However, the
1481 arguments passed are random (and might be dangerous syscalls by
1482 accident). Also, the old code at this address is currently not
1483 restored.
1484
1485 As a result, you must not continue execution after hitting a
1486 breakpoint!
1487@end table
1488
1489
1490@subsection Restrictions
1491
1492The following list contains some restrictions of this version of the
1493library:
1494
1495@itemize @minus
1496
1497@item no real floating point support yet
1498
1499@item lots, lots, lots...
1500
1501
1502@end itemize
1503
1504@section ATARI Jaguar/68k
1505
1506This section describes specifics of the C library for ATARI Jaguar
1507provided by the target @file{m68k-jaguar}.
1508
1509The relevant files are @file{startup.o},
1510@file{libvc.a}, @file{libm.a}, @file{libjag.a}.
1511
1512The config files @code{jaguar_unix} and @code{jaguar_windows} are part of the library.
1513
1514@subsection Startup
1515
1516The startup code @file{startup.o} sets up stack and heap.
1517The startup process calls constructors to set up some
1518global variables and initialize stdin, stdout and stderr.
1519
1520The ATARI Jaguar has no OS, so it is impossible to define how input, output and files
1521can be handled. There are a few set of function you have to define if you want to use stdio.
1522
1523Alternatively you can use the @file{libjag.a}. This library initializes a console window with stdout
1524support and uses optionally a SkunkBoard to redirect stderr and file I/O.
1525
1526@subsection Floating point
1527
1528Note that you have to link with a math library if you want to use
1529floating point operations that are not natively implemented.
1530All math functions, special startup code and
1531printf/scanf functions which support floating point are contained in
1532the math library only. Consider the ATARI Jaguar does not own a FPU so this library is pretty slow.
1533
1534@subsection Stack
1535
1536The library contains a default stack of 32KB. If another size is needed,
1537you can add a global variable named __stack to your code:
1538
1539@example
1540
1541/* Set 64kB stack */
1542unsigned long __stack = 65536;
1543
1544@end example
1545
1546@subsection Heap
1547
1548Currently the free RAM is used as global heapsize for malloc() etc.
1549
1550It is necessary to place a symbol named _BSS_END at the end of the BSS segment.
1551The heap allocates the free RAM between _BSS_END and the bottom of the stack.
1552
1553If less size is needed feel free to manipulate the value of _BSS_END.
1554
1555All allocated heap objects can be used as internal JAGUAR objects, because they are qhrase aligned.
1556
1557@subsection stdio support
1558
1559The ATARI Jaguar lacks stdio support. So the @file{libvc.a} has just empty stub functions for
1560open, close, read and write, which you may overwrite if you need stdio.
1561Alternatively you can use @file{libjag.a} which has simple stdio
1562and file I/O functionality.
1563
1564@example
1565/**
1566 * param name: name mentioned in fopen
1567 * param mode: mode mentioned in fopen
1568 * returns: > 0 a valid file handle
1569 * < 0 to indicate an error
1570 * the values 0,1,2 are used by stdin, stdout and stderr
1571 *
1572 * No need to handle stdin, stdout and stderr here
1573 */
1574int jagopen(const char *name,const char *mode)
1575
1576/**
1577 * param handle: handle from jagopen
1578 *
1579 * No need to handle stdin, stdout and stderr here
1580 */
1581void jagclose(int handle)
1582
1583/**
1584 * param handle: handle from jagopen
1585 * param p: points to the char buffer to fill.
1586 * param l: buffer size of p
1587 * returns: >=0 number of read bytes
1588 <0 indicate an error
1589 *
1590 * Handle stdin, stdout and stderr here
1591 */
1592size_t jagread(int handle,char *p,size_t l)
1593
1594/**
1595 * param handle: handle from jagopen
1596 * param p: points to the char buffer to write.
1597 * param l: number of bytes of p
1598 * returns: >=0 number of bytes written
1599 <0 indicate an error
1600 *
1601 * Handle stdin, stdout and stderr here
1602 */
1603size_t jagwrite(int handle,const char *p, size_t l)
1604
1605/**
1606 * param handle: handle from jagopen
1607 * param offset: number of bytes to seek.
1608 * param direction: see fseek direction
1609 * returns: =0 successful seek
1610 <>0 indicate an error
1611 -1: seek not supported
1612 *
1613 * Handle stdin, stdout and stderr here
1614 */
1615long jagseek(int handle,long offset,int direction)
1616@end example
1617
1618@subsection The jaglib
1619
1620The jaglib @file{libjag.a} provides simple functions to support your first
1621steps in ATARI Jaguar programming. It initializes a simple console output window and comes with
1622an old ATARI character set.
1623If a SkunkBoard is available I/O functionality can be redirected.
1624
1625Your first Jaguar program can look like this:
1626
1627@example
1628
1629#include <stdio.h>
1630
1631int main()
1632@{
1633 printf("Hello, world\n");
1634@}
1635
1636@end example
1637
1638Keep in mind: Your JAGUAR will get a red background color to indicate @code{main()} has exited.
1639
1640The jaglib API documentation is available in a separate document. There is more demo code
1641available in the @uref{https://github.com/toarnold/jaglib-demo, jaglib-demo} gibhub repository.
1642
1643@section 6502/C64
1644
1645This is a port of vclib to the C64.
1646
1647@subsection Startup and Memory
1648
1649Startup and memory layout is described in the following paragraphs.
1650
1651@subsubsection Startup
1652
1653The default linker file creates program files that are loaded to address
16540x801. A BASIC line is included so that the program can be started using @code{RUN}
1655from BASIC. The startup code
1656will turn off the BASIC ROM to allow usage of RAM until 0xD000 and most of the
1657zero page without need for any special handling. The BSS segment will be cleared
1658during startup.
1659
1660With the default configuration, after exiting the C program, an infinite loop will
1661be entered. When using the @code{+c64r} config, the program will return to BASIC
1662an can be started again.
1663However, this needs additional memory as the init values for the data section have
1664to be stored in RAM. Also, some register values and zero page contents have to be
1665saved. The overhead depends on the amount of initialized variables.
1666
1667@subsubsection Command line
1668
1669Command line parameters are supported by using the convention/code submitted by
1670Stefan Haubenthal.
1671
1672Command-lines look like these lines:
1673
1674@example
1675 run
1676 run : rem
1677 run:rem arg1 " arg 2 is quoted " arg3 "" arg5
1678@end example
1679
1680
1681
1682@subsubsection Zero Page
1683
1684@code{vbcc} uses a number of zero page locations for register variables, stack
1685pointer etc. in section @code{zpage}. Also, variables can be mapped to zero page using
1686the @code{__zpage} attribute. By default the area @code{0x02..0x8d}
1687is used, but this can be changed in the linker file.
1688
1689@subsubsection Stack
1690
1691By default, the user stack is mapped from @code{0xC800..0xD000}. The size can be
1692changed at the top of @code{vlink.cmd}.
1693
1694@subsubsection Heap
1695
1696Code and data/BSS are mapped starting after the BASIC init line.
1697The heap is placed in the remaining space to stack start.
1698
1699@subsubsection Banking
1700
1701The following banking models are supported:
1702
1703@table @code
1704@item -reuflat
1705 This library supports a REU using a flat 16MB address space. The memory has to
1706 be addressed through far-pointers. It is not possible to declare variables in
1707 the REU nor to place code in the REU. The memory is addressed as 0x000000 to
1708 0xFFFFFF. All accesses through far-pointers are addressing the REU. It is not
1709 possible to address the C64 memory through a far-pointer.
1710
1711 Far-pointer arithmetic only works on the lower 16bits. It is not possible to
1712 cross a bank boundary using far-pointers. Huge-pointers will support this, but
1713 are not yet fully implemented. In the meantime it is possible to use long integers
1714 and cast them to far-pointers.
1715
1716 Use @code{-lreuflat} to link with this library. Note that the library does
1717 not check for the presence of a REU.
1718
1719@item -reubank
1720 This configuration reserves a 16KB memory space within the C64 memory as window
1721 for banking. As the bank number is stored as a single byte (with bank
1722 255 denoting the unbanked memory), it is only possible to address up to
1723 about 4MB of memory in the REU.
1724
1725 Variables and code can be mapped into the REU using the @code{__bank()} attribute
1726 or @code{#pragma bank}. When calling a banked function, the corresponding bank
1727 will be copied from the REU into the C64 memory window.
1728
1729 Use the @code{+c64reu} configuration to use this mechanism. Currently the
1730 linker file provides 8 banks resulting in a 128K REU image. More banks can
1731 be added for larger expansions.
1732
1733 The configuration will create a usually C64 prg file containing the unbanked
1734 code and data as well as a REU image with extension @code{.b0}. It must
1735 be loaded (e.g. with an emulator or the TurboChameleon) before the prg file
1736 can is executed.
1737@end table
1738
1739
1740@subsection Runtime
1741
1742Apart from standard C library functions, @code{libvc.a} also provides a few
1743runtime support functions needed by the compiler. Apart from the math and
1744floating point functions mentioned in the documentation of the 6502 backend,
1745it includes functions for saving/restoring registers.
1746
1747@subsection @code{stdio}
1748
1749stdio supports @code{stdout}, @code{stderr} (both using the
1750screen) and @code{stdin} (keyboard). Both are unbuffered by default.
1751
1752Furthermore, file IO with standard C functions is supported
1753for 1541 and compatible disk drives. Other devices have not been tested.
1754Only sequential reading and writing of files is supported. No seeking etc.
1755There are hardcoded limits for the maximum number of open files and the
1756maximum length of filenames.
1757
1758The @code{remove()} and @code{rename()} functions are supported using 1541
1759
1760By default, device ID 8 is used. Another device ID can be specified as prefix
1761to the filename:
1762
1763@example
1764 /* try to open file "test" on the second drive */
1765 FILE *f;
1766 f=fopen("9:test","r");
1767 ...
1768@end example
1769
1770@code{printf/scanf} functions which support floating point are contained in
1771the math library only.
1772
1773
1774@subsection Floating Point / wozfp
1775
1776When using floating point, the math library @code{libm.a} must be linked using
1777the @code{-lm} option. It contains the floating routines as well as versions of
1778the @code{printf/scanf} family that support floating point.
1779
1780The floating point routines are based on Steve Wozniaks routines from the 70s,
1781somewhat adapted to the ABI of @code{vbcc}. These functions are small and
1782reasonably usable, but they do not fully satisfy the requirements of C99.
1783
1784Only a part of the C library functions for floating point is implemented. The
1785list currently includes:
1786
1787@itemize
1788@item @code{exp()}
1789@item @code{pow()}
1790@item @code{log()}
1791@item @code{log10()}
1792@end itemize
1793
1794@subsection Floating Point / IEEE
1795
1796When using IEEE floating point, @code{-ieee} must be specified and the math library
1797@code{libmieee.a} must be linked using
1798the @code{-lmieee} option. It contains the floating routines as well as versions of
1799the @code{printf/scanf} family that support floating point.
1800
1801The floating point routines are based on SANE,
1802somewhat adapted to the ABI of @code{vbcc} using wrapper functions.
1803These functions should be fully C and IEEE compliant and provide precise results for
180432 and 64bit floating point numbers (the library actually internally calculates
1805all operation using 80bits, but vbcc currently only uses up to 64 bits).
1806
1807Currently, this library probably must be run from RAM.
1808
1809Most parts of the C library functions for floating point are implemented. The
1810list currently includes:
1811
1812@itemize
1813@item @code{exp(), expf(), expl()}
1814@item @code{exp2(), exp2f(), exp2l()}
1815@item @code{exp1m(), exp1mf(), exp1ml()}
1816@item @code{pow(), powf(), powl()}
1817@item @code{log(), logf(), logl()}
1818@item @code{log1p(), log1pf(), log1pl()}
1819@item @code{log2(), log2f(), log2l()}
1820@item @code{log10(), log10f(), log10l()}
1821@item @code{sqrt(), sqrtf(), sqrtl()}
1822@item @code{sin(), sinf(), sinl()}
1823@item @code{cos(), cosf(), cosl()}
1824@item @code{tan(), tanf(), tanl()}
1825@item @code{atan(), atanf(), atanl()}
1826
1827
1828@end itemize
1829
1830@section 6502/NES
1831
1832This is a port of vclib to the NES console.
1833
1834
1835@subsection Startup and Memory
1836
1837Startup and memory layout is dependent on the ROM used. Currently two example configurations
1838are provided. They can be selected with @code{+nrom256v} and @code{+unrom512v}. Have a
1839look at the corresponding linker scripts in @code{vbcc/targets/6502-nes} for further
1840details.
1841
1842The necessary library routines to support configurations with several ROM banks are
1843included.
1844
1845@subsubsection Zero Page
1846
1847@code{vbcc} uses a number of zero page locations for register variables, stack
1848pointer etc. in section @code{zpage}. Also, variables can be mapped to zero page using
1849the @code{__zpage} attribute. The entire zero page can be used, but this can be changed
1850in the linker file.
1851
1852@subsubsection Stack
1853
1854By default, the user stack starts from @code{0x0800} growing downwards.
1855
1856@subsubsection Heap
1857
1858By default, code and data/BSS are mapped starting after the system stack at @code{0x0200}.
1859The heap is placed in the remaining space to stack start.
1860
1861@subsection Runtime
1862
1863Apart from standard C library functions, @code{libvc.a} also provides a few
1864runtime support functions needed by the compiler. Apart from the math and
1865floating point functions mentioned in the documentation of the 6502 backend,
1866it includes functions for saving/restoring registers.
1867
1868@subsection @code{stdio}
1869
1870At the moment, stdio only supports @code{stdout}, @code{stderr} (both using the
1871screen) and @code{stdin} (simple input via joypad).
1872
1873@code{printf/scanf} functions which support floating point are contained in
1874the math library only.
1875
1876For input, up/down changes the current character, left/right moves the cursor,
1877the B button deletes from the cursor position, and the A button confirms the input.
1878You do not want to use this in real code.
1879
1880The library contains a default character set. To replace it, link an object that
1881contains a character set mapped to section @code{chars} and defines the global symbol
1882@code{___stdchr}.
1883
1884To replace stdio, the function @code{__read()} and @code{__write()} have to be
1885implemented.
1886
1887@subsection Interrupts
1888
1889The library contains a default NMI implementation that is used for stdio handling
1890and the @code{clock()}-function. It can be replaced by linking with an own
1891implementation that starts at the global symbol @code{___nmi}. In this case the stdio and
1892timing functions from vclib can not be used.
1893
1894@code{___irq} can be used to overwrite the other IRQ vector. The default implementation
1895in the library immediately returns.
1896
1897@subsection Floating Point / wozfp
1898
1899When using floating point, the math library @code{libm.a} must be linked using
1900the @code{-lm} option. It contains the floating routines as well as versions of
1901the @code{printf/scanf} family that support floating point.
1902
1903The floating point routines are based on Steve Wozniaks routines from the 70s,
1904somewhat adapted to the ABI of @code{vbcc}. These functions are small and
1905reasonably usable, but they do not fully satisfy the requirements of C99.
1906
1907Only a part of the C library functions for floating point is implemented. The
1908list currently includes:
1909
1910@itemize
1911@item @code{exp()}
1912@item @code{pow()}
1913@item @code{log()}
1914@item @code{log10()}
1915@end itemize
1916
1917@subsection Floating Point / IEEE
1918
1919IEEE floating point is currently not available for this target.
1920
1921
1922@section 6502/Atari
1923
1924This is a port of vclib to Atari 8bit computers.
1925
1926@subsection Startup and Memory
1927
1928Startup and memory layout is described in the following paragraphs.
1929
1930@subsubsection Startup
1931
1932The default linker file creates program files that are loaded to address
19330x600. The memory area can be adapted by changing @code{MEMSTART} and
1934@code{MEMEND} in @code{vlink.cmd}.
1935
1936With the default configuration, after exiting the C program, it will wait
1937for pressing the return key before returning to DOS.
1938
1939@subsubsection Command line
1940
1941Command line parameters are not yet supported.
1942
1943@subsubsection Zero Page
1944
1945@code{vbcc} uses a number of zero page locations for register variables, stack
1946pointer etc. in section @code{zpage}. Also, variables can be mapped to zero page using
1947the @code{__zpage} attribute. By default the area @code{0x82..0xFF}
1948is used, but this can be changed in the linker file.
1949
1950@subsubsection Stack
1951
1952By default, the startup code maps the user stack from
1953@code{MEMTOP-STACKLEN..MEMTOP}.
1954The size can be changed at the top of @code{vlink.cmd}.
1955
1956@subsubsection Heap
1957
1958Code and data/BSS are mapped starting at @code{MEMSTART}.
1959The heap is placed in the remaining space to stack start.
1960
1961@subsubsection Banking
1962
1963Banking support for this target has not yet been implemented.
1964
1965@subsection Runtime
1966
1967Apart from standard C library functions, @code{libvc.a} also provides a few
1968runtime support functions needed by the compiler. Apart from the math and
1969floating point functions mentioned in the documentation of the 6502 backend,
1970it includes functions for saving/restoring registers.
1971
1972@subsection @code{stdio}
1973
1974At the moment, stdio only supports @code{stdout}, @code{stderr} (both using the
1975screen) and @code{stdin} (keyboard). Both are line-buffered by default.
1976
1977@code{printf/scanf} functions which support floating point are contained in
1978the math library only.
1979
1980
1981@subsection Floating Point / wozfp
1982
1983When using floating point, the math library @code{libm.a} must be linked using
1984the @code{-lm} option. It contains the floating routines as well as versions of
1985the @code{printf/scanf} family that support floating point.
1986
1987The floating point routines are based on Steve Wozniaks routines from the 70s,
1988somewhat adapted to the ABI of @code{vbcc}. These functions are small and
1989reasonably usable, but they do not fully satisfy the requirements of C99.
1990
1991Only a part of the C library functions for floating point is implemented. The
1992list currently includes:
1993
1994@itemize
1995@item @code{exp()}
1996@item @code{pow()}
1997@item @code{log()}
1998@item @code{log10()}
1999@end itemize
2000
2001@subsection Floating Point / IEEE
2002
2003When using IEEE floating point, @code{-ieee} must be specified and the math library
2004@code{libmieee.a} must be linked using
2005the @code{-lmieee} option. It contains the floating routines as well as versions of
2006the @code{printf/scanf} family that support floating point.
2007
2008The floating point routines are based on SANE,
2009somewhat adapted to the ABI of @code{vbcc} using wrapper functions.
2010These functions should be fully C and IEEE compliant and provide precise results for
201132 and 64bit floating point numbers (the library actually internally calculates
2012all operation using 80bits, but vbcc currently only uses up to 64 bits).
2013
2014Currently, this library probably must be run from RAM.
2015
2016Most parts of the C library functions for floating point are implemented. The
2017list currently includes:
2018
2019@itemize
2020@item @code{exp(), expf(), expl()}
2021@item @code{exp2(), exp2f(), exp2l()}
2022@item @code{exp1m(), exp1mf(), exp1ml()}
2023@item @code{pow(), powf(), powl()}
2024@item @code{log(), logf(), logl()}
2025@item @code{log1p(), log1pf(), log1pl()}
2026@item @code{log2(), log2f(), log2l()}
2027@item @code{log10(), log10f(), log10l()}
2028@item @code{sqrt(), sqrtf(), sqrtl()}
2029@item @code{sin(), sinf(), sinl()}
2030@item @code{cos(), cosf(), cosl()}
2031@item @code{tan(), tanf(), tanl()}
2032@item @code{atan(), atanf(), atanl()}
2033
2034
2035@end itemize
2036
2037@section 6502/BBC Micro/Master
2038
2039This is a port of vclib to BBC 8bit computers.
2040
2041@subsection Startup and Memory
2042
2043Startup and memory layout is described in the following paragraphs.
2044
2045@subsubsection Startup
2046
2047The default linker file creates program files that are loaded to address
20480x1900 up to 0x7B00 with 256 bytes of software stack. The memory area can be adapted by
2049changing @code{OSHWM}, @code{HIMEM} and @code{STACKSTART} in @code{vlink.cmd}.
2050
2051With the default configuration (@code{+bbc}), after exiting the C program, the code will
2052enter an endless loop. If the reentrant configs are used (@code{+bbcr} or
2053@code{+bbcbr}), the program will return to the command prompt. As this
2054requires saving the zero page, a bit more memory is used.
2055
2056
2057@subsubsection Command line
2058
2059If @code{main()} uses arguments, the command line parameters will be passed
2060accordingly. There are hardcoded limits to the number of arguments (currently 8)
2061and the maximum total command length (currently 80).
2062
2063Space is used to separate arguments. The quote character (@code{"}) can be used
2064to group arguments containing spaces.
2065
2066
2067@subsubsection Zero Page
2068
2069@code{vbcc} uses a number of zero page locations for register variables, stack
2070pointer etc. in section @code{zpage}. Also, variables can be mapped to zero page using
2071the @code{__zpage} attribute. By default the area @code{0x00..0x90}
2072is used, but this can be changed in the linker file.
2073
2074@subsubsection Stack
2075
2076By default, the startup code maps the user stack from
2077@code{STACKSTART..HIMEM}.
2078The size can be changed at the top of @code{vlink.cmd}.
2079
2080@subsubsection Heap
2081
2082Code and data/BSS are mapped starting at @code{OSHWM}.
2083The heap is placed in the remaining space to stack start.
2084
2085@subsubsection Banking
2086
2087When using the @code{+bbcb} or @code{bbcbr} configurations, vbcc supports
2088banked memory, including automated bank-switching. Up to 16 sections of 16K
2089size are supported. Each section starts at 0x8000.
2090
2091The corresponding linker
2092files @code{vlinkb.cmd} and @code{vlinkbr.cmd} can be edited to choose the
2093banks that are required. Unused banks can be removed by commenting out
2094(using old-style C-comments) the corresponding entries in the @code{SECTIONS}
2095part of the linker file. When using bank 1-3 the section in the linker file
2096could look like this:
2097
2098@example
2099 ...
2100
2101SECTIONS
2102@{
2103 text : @{*(text)@} >ram
2104 .dtors : @{ *(.dtors) @} > ram
2105 .ctors : @{ *(.ctors) @} > ram
2106 rodata : @{*(rodata)@} >ram
2107 data: @{*(data)@} >ram
2108 init : @{*(init)@} >ram
2109 zpage (NOLOAD) : @{*(zpage) *(zp1) *(zp2)@} >zero
2110 bss (NOLOAD): @{*(bss)@} >ram
2111
2112/*
2113 b0 : @{.=PAGEADDR; *(text0) *(rodata0) *(data0) *(bss0)
2114 RESERVE(PAGEADDR+PAGESIZE-.);
2115 @} >b0 AT>dummy0
2116*/
2117
2118 b1 : @{.=PAGEADDR; *(text1) *(rodata1) *(data1) *(bss1)
2119 RESERVE(PAGEADDR+PAGESIZE-.);
2120 @} >b1 AT>dummy1
2121
2122 b2 : @{.=PAGEADDR; *(text2) *(rodata2) *(data2) *(bss2)
2123 RESERVE(PAGEADDR+PAGESIZE-.);
2124 @} >b2 AT>dummy2
2125
2126 b3 : @{.=PAGEADDR; *(text3) *(rodata3) *(data3) *(bss3)
2127 RESERVE(PAGEADDR+PAGESIZE-.);
2128 @} >b3 AT>dummy3
2129/*
2130 b4 : @{.=PAGEADDR; *(text4) *(rodata4) *(data4) *(bss4)
2131 RESERVE(PAGEADDR+PAGESIZE-.);
2132 @} >b4 AT>dummy4
2133*/
2134
2135 ...
2136
2137@end example
2138
2139During the linking process, apart from the normal output file, a 16K large
2140image for each bank and a loader script will be generated. E.g. when using banks
21411-3 and using the output file name test, the following files will be generated:
2142
2143@table @code
2144@item @code{test}
2145 The unbanked code/data.
2146
2147@item @code{test.inf}
2148 Info file with start address.
2149
2150@item @code{testb1}
2151 Image for bank1.
2152
2153@item @code{testb2}
2154 Image for bank2.
2155
2156@item @code{testb2}
2157 Image for bank2.
2158
2159@item @code{loadtest}
2160 Loader
2161
2162@end table
2163
2164The contents of the loader @code{loadtest} will look like this:
2165
2166@example
2167*srload testb1 8000 1
2168*srload testb2 8000 2
2169*srload testb3 8000 3
2170*run test
2171@end example
2172
2173The program can be started with @code{*exec loadtest}.
2174
2175@subsection Runtime
2176
2177Apart from standard C library functions, @code{libvc.a} also provides a few
2178runtime support functions needed by the compiler. Apart from the math and
2179floating point functions mentioned in the documentation of the 6502 backend,
2180it includes functions for saving/restoring registers.
2181
2182@subsection @code{stdio}
2183
2184@code{stdout}, @code{stderr} (both using the screen) and @code{stdin} (keyboard)
2185are supported. Furthermore normal file operations are possible using the
2186usual C functions. There are hardcoded limits on the maximum number of
2187simultaneously open files as well as the length of filenames.
2188
2189Sequential reading and writing is supported, but no seeking. Furthermore, the
2190@code{remove()} call is supported.
2191
2192When using stdio to emit VDU control sequences, the function
2193@code{__vdu_sequence()} is available to ensure verbatim 1:1 transmission
2194of all characters:
2195
2196@example
2197 /* print diagonal line */
2198 __vdu_sequence(1);
2199 for(int i=0;i<20;i++)
2200 printf("\x1f%c%cO",i,i);
2201 __vdu_sequence(0);
2202@end example
2203
2204@code{printf/scanf} functions which support floating point are contained in
2205the math library only.
2206
2207
2208@subsection Floating Point / wozfp
2209
2210When using floating point, the math library @code{libm.a} must be linked using
2211the @code{-lm} option. It contains the floating routines as well as versions of
2212the @code{printf/scanf} family that support floating point.
2213
2214The floating point routines are based on Steve Wozniaks routines from the 70s,
2215somewhat adapted to the ABI of @code{vbcc}. These functions are small and
2216reasonably usable, but they do not fully satisfy the requirements of C99.
2217
2218Only a part of the C library functions for floating point is implemented. The
2219list currently includes:
2220
2221@itemize
2222@item @code{exp()}
2223@item @code{pow()}
2224@item @code{log()}
2225@item @code{log10()}
2226@end itemize
2227
2228@subsection Floating Point / IEEE
2229
2230When using IEEE floating point, @code{-ieee} must be specified and the math library
2231@code{libmieee.a} must be linked using
2232the @code{-lmieee} option. It contains the floating routines as well as versions of
2233the @code{printf/scanf} family that support floating point.
2234
2235The floating point routines are based on SANE,
2236somewhat adapted to the ABI of @code{vbcc} using wrapper functions.
2237These functions should be fully C and IEEE compliant and provide precise results for
223832 and 64bit floating point numbers (the library actually internally calculates
2239all operation using 80bits, but vbcc currently only uses up to 64 bits).
2240
2241Currently, this library probably must be run from RAM.
2242
2243Most parts of the C library functions for floating point are implemented. The
2244list currently includes:
2245
2246@itemize
2247@item @code{exp(), expf(), expl()}
2248@item @code{exp2(), exp2f(), exp2l()}
2249@item @code{exp1m(), exp1mf(), exp1ml()}
2250@item @code{pow(), powf(), powl()}
2251@item @code{log(), logf(), logl()}
2252@item @code{log1p(), log1pf(), log1pl()}
2253@item @code{log2(), log2f(), log2l()}
2254@item @code{log10(), log10f(), log10l()}
2255@item @code{sqrt(), sqrtf(), sqrtl()}
2256@item @code{sin(), sinf(), sinl()}
2257@item @code{cos(), cosf(), cosl()}
2258@item @code{tan(), tanf(), tanl()}
2259@item @code{atan(), atanf(), atanl()}
2260
2261
2262@end itemize
2263
2264
2265
2266@section 6502/MEGA65
2267
2268This is a port of vclib to the MEGA65. This port is intended for the C65 mode
2269with a C65 or compatible ROM (although the ROM is not used after the
2270program is started). The C64 configuration can be used to create programs for
2271the C64 mode.
2272
2273
2274@subsection Startup and Memory
2275
2276Startup and memory layout is described in the following paragraphs.
2277
2278The following basic configurations are available. See below for more details:
2279
2280@table @code
2281@item +m65s
2282 Standard unbanked configuration.
2283
2284@item +m65sr
2285 Standard unbanked reentrant configuration.
2286
2287@item +m65sb
2288 Standard banked configuration.
2289
2290@item +m65l
2291 Large unbanked configuration.
2292
2293@item +m65lr
2294 Large unbanked reentrant configuration.
2295
2296@item +m65lb
2297 Large banked configuration.
2298
2299@end table
2300
2301@subsubsection Startup
2302
2303The default linker file creates program files that are loaded to address
23040x2001. A BASIC line is included so that the program can be started using @code{RUN}
2305from BASIC. The startup code
2306will switch to VIC-IV mode, remove write protection of ROM banks, turn on full
2307speed and change to a suitable mapping.
2308The BSS segment will be cleared during startup.
2309
2310There are two sets of configurations that affect the configuration of
2311upper memory. The standard versions (@code{+m65s, +m65sr, +m65sb})
2312will keep the IO area mapped in at $D000.
2313This will limit the contiguous memory block for unbanked configurations to 0xCFFF.
2314For banked configurations (see below) it will make a 16K window from
23150x8000..0xBFFF available for banking. The large configurations
2316(@code{+m65l, +m65lr, +m65lb}) will move the upper bound for unbanked programs
2317to 0xFFFF. With banking, 32K window will be available from 0x8000..0xFFFF.
2318In both cases the total amount of memory available for banking is the same in
2319both configurations.
2320
2321While the large configurations provide larger contiguous memory areas, accesses
2322to the IO area have to be made through extended 28bit instructions which are
2323much larger and slower. For programs doing many IO accesses, the standard
2324configurations are recommended.
2325
2326With the default configurations, after exiting the C program, an infinite loop will
2327be entered. When using the reentrant (@code{+m65sr, +m65lr}) configs, the
2328program will return to BASIC an can be started again.
2329However, this needs additional memory as the init values for the data section have
2330to be stored in RAM. Also, some register values and zero page contents have to be
2331saved. The overhead depends on the amount of initialized variables.
2332
2333Caution: The current configuration assumes that the Z register always contains 0.
2334To work correctly, the Z register has to be 0 when C code is
2335executed. The startup code will set it correctly and the compiler generated code will
2336not touch it. However, when calling other code you may have to take care
2337to save/restore the Z register or to set the Z register to 0 again.
2338
2339@subsubsection Command line
2340
2341Command line parameters are supported by using the convention/code submitted by
2342Stefan Haubenthal.
2343
2344Command-lines look like these lines:
2345
2346@example
2347 run
2348 run : rem
2349 run:rem arg1 " arg 2 is quoted " arg3 "" arg5
2350@end example
2351
2352
2353
2354@subsubsection Zero Page
2355
2356@code{vbcc} uses a number of zero page locations for register variables, stack
2357pointer etc. in section @code{zpage}. Also, variables can be mapped to zero page using
2358the @code{__zpage} attribute. By default the area @code{0x02..0xFF}
2359is used, but this can be changed in the linker file.
2360
2361@subsubsection Stack
2362
2363By default, the user stack is mapped from @code{0xB800..0xC000}. For the banked version,
2364it is mapped from @code{0x7800..0x8000}. The size can be
2365changed at the top of @code{vlink.cmd} and @code{vlinkbank.cmd}.
2366
2367@subsubsection Heap
2368
2369Code and data/BSS are mapped starting after the BASIC init line.
2370The heap is placed in the remaining space depending on the configuration.
2371
2372@subsubsection Banking
2373
2374The following banking models are supported:
2375
2376@table @code
2377@item +m65sb
2378 16K window at 0x8000 with IO area mapped in at all times.
2379
2380@item +m65lb
2381 32K window at 0x8000.
2382@end table
2383
2384
2385Automated bank switching is supported in both modes. The mapping of banks to
2386real memory in the standard configuration is like this:
2387@example
2388Unbanked: 0x000000..0x007FFF
2389Bank0: 0x008000..0x00BFFF
2390Bank1: 0x00C000..0x00FFFF
2391Bank2: 0x010000..0x013FFF
2392Bank3: 0x014000..0x017FFF
2393 ...
2394@end example
2395
2396On the large configuration, it looks like this:
2397@example
2398Unbanked: 0x000000..0x007FFF
2399Bank0: 0x008000..0x00FFFF
2400Bank1: 0x010000..0x017FFF
2401Bank2: 0x018000..0x01FFFF
2402Bank3: 0x020000..0x027FFF
2403 ...
2404@end example
2405
2406In both cases, the program start is moved to 0x1000.
2407When using the banked configurations, the code can not be simply loaded from
2408BASIC. The linker will create on large image without any BASIC lines. The
2409file can be executed from SD-card by using a special loader that can be loaded
2410from BASIC off a disk or disk image. When specifying a name as command line
2411argument (see above), the loader will try to load this image from SD-card. If
2412no argument is given, the loader will look for a file of the same name.
2413Therefore by renaming the loader it can be made to automatically run a
2414specific file.
2415
2416If the loader is on the current disk/image and @code{myimage} on the SD:
2417@example
2418LOAD "LOADER"
2419RUN:REM MYIMAGE
2420@end example
2421
2422After renaming @code{LOADER} to @code{MYIMAGE}, it can be done like this:
2423@example
2424RUN "MYIMAGE"
2425@end example
2426
2427The colour RAM will be relocated to 0xFF80800 before loading to avoid being
2428overwritten through the window at 0x1F800.
2429
2430@subsection Runtime
2431
2432Apart from standard C library functions, @code{libvc.a} also provides a few
2433runtime support functions needed by the compiler. Apart from the math and
2434floating point functions mentioned in the documentation of the 6502 backend,
2435it includes functions for saving/restoring registers.
2436
2437@subsection @code{stdio}
2438
2439At the moment, stdio only supports @code{stdout}, @code{stderr} (both using the
2440screen) and @code{stdin} (keyboard). Both are unbuffered by default.
2441Using those streams will directly access the screen buffer and keyboard
2442hardware. No ROM functions are needed once the program runs.
2443
2444Furthermore it is possible to read files on the SD-card using standard
2445C functions after opening them using @code{fopen()}. Hyppo services are
2446used to read those files. There are several limitations due to the
2447restrictions of Hyppo:
2448
2449@itemize
2450@item Files can only be read sequentially, no seeking etc.
2451@item Files can not be written to.
2452@item Only one file can be open at the same time.
2453@end itemize
2454
2455
2456@code{printf/scanf} functions which support floating point are contained in
2457the math library only.
2458
2459@subsection Multiplication/Division
2460
2461When generating code for the MEGA65, @code{vbcc} will make use of hardware
2462multiplier/divider. This can greatly improve performance of such operations.
2463Please note the following issues:
2464
2465@itemize
2466@item Some versions of the MEGA65 core contain a bug in the hardware divider
2467 which will calculate wrong results in certain cases. As workaround you can
2468 specify option @code{-div-bug} to use (much slower) 6502 software
2469 routines instead. Multiplication is not affected by the bug and will still
2470 be using the hardware multiplier.
2471
2472@item The hardware multiplier registers are mapped in the IO area. When using
2473 the large configurations (@code{+m65l, +m65lr, +m65lb}), they can only
2474 be accessed using extended 28bit instructions. The code generator and
2475 library functions will handle this, but there is some overhead (still
2476 nowhere near using software multiplication). If your code is speed
2477 critical and uses many multiplications we strongly recomment to use
2478 the standard configurations (@code{+m65s, +m65sr, +m65sb}). Those will
2479 set the option @code{-m65io} that tells @code{vbcc} to use faster
2480 direct IO accesses.
2481@end itemize
2482
2483@subsection Interrupts
2484
2485The provided configurations will disable interrupts on the MEGA65. All the
2486library functions are written to work with disabled interrupts and do not use
2487any ROM routines. The interrupt handlers in existing C65 ROMs do not work well
2488with assembly language code and deficiencies in the mapping hardware make it
2489very hard to use the ROM in a non-BASIC environment.
2490
2491If an application wants to use interrupts, interrupt vectors have to be
2492installed at 0xFFFA..0xFFFF. Take care that there are always valid vectors
2493visible at this address (especially in a banked configuration). Also take
2494care that those always point to a valid handler that is visible (i.e. do
2495not use an ISR in banked memory).
2496
2497
2498@subsection Floating Point / wozfp
2499
2500When using floating point, the math library @code{libm.a} must be linked using
2501the @code{-lm} option. It contains the floating routines as well as versions of
2502the @code{printf/scanf} family that support floating point.
2503
2504The floating point routines are based on Steve Wozniaks routines from the 70s,
2505somewhat adapted to the ABI of @code{vbcc}. These functions are small and
2506reasonably usable, but they do not fully satisfy the requirements of C99.
2507
2508Only a part of the C library functions for floating point is implemented. The
2509list currently includes:
2510
2511@itemize
2512@item @code{exp()}
2513@item @code{pow()}
2514@item @code{log()}
2515@item @code{log10()}
2516@end itemize
2517
2518@subsection Floating Point / IEEE
2519
2520When using IEEE floating point, @code{-ieee} must be specified and the math library
2521@code{libmieee.a} must be linked using
2522the @code{-lmieee} option. It contains the floating routines as well as versions of
2523the @code{printf/scanf} family that support floating point.
2524
2525The floating point routines are based on SANE,
2526somewhat adapted to the ABI of @code{vbcc} using wrapper functions.
2527These functions should be fully C and IEEE compliant and provide precise results for
252832 and 64bit floating point numbers (the library actually internally calculates
2529all operation using 80bits, but vbcc currently only uses up to 64 bits).
2530
2531Currently, this library probably must be run from RAM.
2532
2533Most parts of the C library functions for floating point are implemented. The
2534list currently includes:
2535
2536@itemize
2537@item @code{exp(), expf(), expl()}
2538@item @code{exp2(), exp2f(), exp2l()}
2539@item @code{exp1m(), exp1mf(), exp1ml()}
2540@item @code{pow(), powf(), powl()}
2541@item @code{log(), logf(), logl()}
2542@item @code{log1p(), log1pf(), log1pl()}
2543@item @code{log2(), log2f(), log2l()}
2544@item @code{log10(), log10f(), log10l()}
2545@item @code{sqrt(), sqrtf(), sqrtl()}
2546@item @code{sin(), sinf(), sinl()}
2547@item @code{cos(), cosf(), cosl()}
2548@item @code{tan(), tanf(), tanl()}
2549@item @code{atan(), atanf(), atanl()}
2550
2551
2552@end itemize
2553
2554@section 6502/X16
2555
2556This is a port of vclib to the Commander X16.
2557
2558
2559@subsection Startup and Memory
2560
2561Startup and memory layout is described in the following paragraphs.
2562
2563@subsubsection Startup
2564
2565The default linker file creates program files that are loaded to address
25660x801. A BASIC line is included so that the program can be started using @code{RUN}
2567from BASIC. The startup code
2568will turn off the BASIC ROM to allow usage of RAM until 0x9F00 and most of the
2569zero page without need for any special handling. The BSS segment will be cleared
2570during startup.
2571
2572With the default configuration, after exiting the C program, an infinite loop will
2573be entered. When using the @code{+x16r} config, the program will return to BASIC
2574an can be started again.
2575However, this needs additional memory as the init values for the data section have
2576to be stored in RAM. Also, some register values and zero page contents have to be
2577saved. The overhead depends on the amount of initialized variables.
2578
2579@subsubsection Command line
2580
2581Command line parameters are supported by using the convention/code submitted by
2582Stefan Haubenthal.
2583
2584Command-lines look like these lines:
2585
2586@example
2587 run
2588 run : rem
2589 run:rem arg1 " arg 2 is quoted " arg3 "" arg5
2590@end example
2591
2592
2593
2594@subsubsection Zero Page
2595
2596@code{vbcc} uses a number of zero page locations for register variables, stack
2597pointer etc. in section @code{zpage}. Also, variables can be mapped to zero page using
2598the @code{__zpage} attribute. By default the area @code{0x02..0x7e}
2599is used, but this can be changed in the linker file.
2600
2601@subsubsection Stack
2602
2603By default, the user stack is mapped from @code{0x9700..0x9F00}. The size can be
2604changed at the top of @code{vlink.cmd}.
2605
2606@subsubsection Heap
2607
2608Code and data/BSS are mapped starting after the BASIC init line.
2609The heap is placed in the remaining space to stack start.
2610
2611@subsubsection Banking
2612
2613Banking support for this target is not yet implemented.
2614
2615
2616@subsection Runtime
2617
2618Apart from standard C library functions, @code{libvc.a} also provides a few
2619runtime support functions needed by the compiler. Apart from the math and
2620floating point functions mentioned in the documentation of the 6502 backend,
2621it includes functions for saving/restoring registers.
2622
2623@subsection @code{stdio}
2624
2625At the moment, stdio only supports @code{stdout}, @code{stderr} (both using the
2626screen) and @code{stdin} (keyboard). Both are unbuffered by default.
2627
2628@code{printf/scanf} functions which support floating point are contained in
2629the math library only.
2630
2631
2632@subsection Floating Point / wozfp
2633
2634When using floating point, the math library @code{libm.a} must be linked using
2635the @code{-lm} option. It contains the floating routines as well as versions of
2636the @code{printf/scanf} family that support floating point.
2637
2638The floating point routines are based on Steve Wozniaks routines from the 70s,
2639somewhat adapted to the ABI of @code{vbcc}. These functions are small and
2640reasonably usable, but they do not fully satisfy the requirements of C99.
2641
2642Only a part of the C library functions for floating point is implemented. The
2643list currently includes:
2644
2645@itemize
2646@item @code{exp()}
2647@item @code{pow()}
2648@item @code{log()}
2649@item @code{log10()}
2650@end itemize
2651
2652@subsection Floating Point / IEEE
2653
2654When using IEEE floating point, @code{-ieee} must be specified and the math library
2655@code{libmieee.a} must be linked using
2656the @code{-lmieee} option. It contains the floating routines as well as versions of
2657the @code{printf/scanf} family that support floating point.
2658
2659The floating point routines are based on SANE,
2660somewhat adapted to the ABI of @code{vbcc} using wrapper functions.
2661These functions should be fully C and IEEE compliant and provide precise results for
266232 and 64bit floating point numbers (the library actually internally calculates
2663all operation using 80bits, but vbcc currently only uses up to 64 bits).
2664
2665Currently, this library probably must be run from RAM.
2666
2667Most parts of the C library functions for floating point are implemented. The
2668list currently includes:
2669
2670@itemize
2671@item @code{exp(), expf(), expl()}
2672@item @code{exp2(), exp2f(), exp2l()}
2673@item @code{exp1m(), exp1mf(), exp1ml()}
2674@item @code{pow(), powf(), powl()}
2675@item @code{log(), logf(), logl()}
2676@item @code{log1p(), log1pf(), log1pl()}
2677@item @code{log2(), log2f(), log2l()}
2678@item @code{log10(), log10f(), log10l()}
2679@item @code{sqrt(), sqrtf(), sqrtl()}
2680@item @code{sin(), sinf(), sinl()}
2681@item @code{cos(), cosf(), cosl()}
2682@item @code{tan(), tanf(), tanl()}
2683@item @code{atan(), atanf(), atanl()}
2684
2685
2686@end itemize
2687
2688@section 6502/PET
2689
2690This is a port of vclib to the CBM PET series of computers.
2691
2692@subsection Startup and Memory
2693
2694Startup and memory layout is described in the following paragraphs.
2695
2696@subsubsection Startup
2697
2698The default linker file creates program files that are loaded to address
26990x401. A BASIC line is included so that the program can be started using @code{RUN}
2700from BASIC. RAM is available until 0x7FFF and most of the
2701zero page without need for any special handling. The BSS segment will be cleared
2702during startup.
2703
2704With the default configuration, after exiting the C program, an infinite loop will
2705be entered. When using the @code{+petr} config, the program will return to BASIC
2706an can be started again.
2707However, this needs additional memory as the init values for the data section have
2708to be stored in RAM. Also, some register values and zero page contents have to be
2709saved. The overhead depends on the amount of initialized variables.
2710
2711@subsubsection Command line
2712
2713Command line parameters are supported by using the convention/code submitted by
2714Stefan Haubenthal.
2715
2716Command-lines look like these lines:
2717
2718@example
2719 run
2720 run : rem
2721 run:rem arg1 " arg 2 is quoted " arg3 "" arg5
2722@end example
2723
2724
2725
2726@subsubsection Zero Page
2727
2728@code{vbcc} uses a number of zero page locations for register variables, stack
2729pointer etc. in section @code{zpage}. Also, variables can be mapped to zero page using
2730the @code{__zpage} attribute. By default the area @code{0x02..0x8d}
2731is used, but this can be changed in the linker file.
2732
2733@subsubsection Stack
2734
2735By default, the user stack is mapped from @code{0x7F00..0x7FFF}. The size can be
2736changed at the top of @code{vlink.cmd}.
2737
2738@subsubsection Heap
2739
2740Code and data/BSS are mapped starting after the BASIC init line.
2741The heap is placed in the remaining space to stack start.
2742
2743@subsubsection Banking
2744
2745Automated banking is currently not supported.
2746
2747
2748@subsection Runtime
2749
2750Apart from standard C library functions, @code{libvc.a} also provides a few
2751runtime support functions needed by the compiler. Apart from the math and
2752floating point functions mentioned in the documentation of the 6502 backend,
2753it includes functions for saving/restoring registers.
2754
2755@subsection @code{stdio}
2756
2757At the moment, stdio only supports @code{stdout}, @code{stderr} (both using the
2758screen) and @code{stdin} (keyboard). Both are unbuffered by default.
2759
2760@code{printf/scanf} functions which support floating point are contained in
2761the math library only.
2762
2763
2764@subsection Floating Point / wozfp
2765
2766When using floating point, the math library @code{libm.a} must be linked using
2767the @code{-lm} option. It contains the floating routines as well as versions of
2768the @code{printf/scanf} family that support floating point.
2769
2770The floating point routines are based on Steve Wozniaks routines from the 70s,
2771somewhat adapted to the ABI of @code{vbcc}. These functions are small and
2772reasonably usable, but they do not fully satisfy the requirements of C99.
2773
2774Only a part of the C library functions for floating point is implemented. The
2775list currently includes:
2776
2777@itemize
2778@item @code{exp()}
2779@item @code{pow()}
2780@item @code{log()}
2781@item @code{log10()}
2782@end itemize
2783
2784@subsection Floating Point / IEEE
2785
2786When using IEEE floating point, @code{-ieee} must be specified and the math library
2787@code{libmieee.a} must be linked using
2788the @code{-lmieee} option. It contains the floating routines as well as versions of
2789the @code{printf/scanf} family that support floating point.
2790
2791The floating point routines are based on SANE,
2792somewhat adapted to the ABI of @code{vbcc} using wrapper functions.
2793These functions should be fully C and IEEE compliant and provide precise results for
279432 and 64bit floating point numbers (the library actually internally calculates
2795all operation using 80bits, but vbcc currently only uses up to 64 bits).
2796
2797Currently, this library probably must be run from RAM.
2798
2799Most parts of the C library functions for floating point are implemented. The
2800list currently includes:
2801
2802@itemize
2803@item @code{exp(), expf(), expl()}
2804@item @code{exp2(), exp2f(), exp2l()}
2805@item @code{exp1m(), exp1mf(), exp1ml()}
2806@item @code{pow(), powf(), powl()}
2807@item @code{log(), logf(), logl()}
2808@item @code{log1p(), log1pf(), log1pl()}
2809@item @code{log2(), log2f(), log2l()}
2810@item @code{log10(), log10f(), log10l()}
2811@item @code{sqrt(), sqrtf(), sqrtl()}
2812@item @code{sin(), sinf(), sinl()}
2813@item @code{cos(), cosf(), cosl()}
2814@item @code{tan(), tanf(), tanl()}
2815@item @code{atan(), atanf(), atanl()}
2816
2817
2818@end itemize