1 <!doctype linuxdoc system>
4 <title>cc65 function reference
5 <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
9 cc65 is a C compiler for 6502 based systems. This function reference describes
10 the C functions available in the standard library.
13 <!-- Table of contents -->
16 <!-- Begin the document -->
20 cc65 is a C compiler for 6502 based systems. It implements a subset of the ISO
21 C standard plus additional functions specially crafted for 6502 systems or
22 just some of the supported machines. This function refrence describes the
23 available functions together with any limitations.
25 For an overview about the available libraries, their purpose, and any
26 differences to the ISO standard, please have a look at the <htmlurl
27 url="library.html" name="cc65 Library Overview">.
29 <bf/Note:/ Standard C functions are listed here, but not described in detail.
30 Since these functions behave identical on all standard compliant systems, they
31 are described in any book covering standard C.
33 Each entry for a function contains a detailed description
37 <tag/Function/Summary of what <bf/function/ does.
38 <tag/Header/The header file that contains the declaration.
39 <tag/Declaration/Describes the needed header files and declaration of the
41 <tag/Description/Description of the function.
43 <tag/Availability/The availability of the function.
44 <tag/See also/Other related functions.
45 <tag/Example/A piece of actual code using the function.
50 <sect>Functions by header file<p>
52 <sect1><tt/6502.h/<label id="6502.h"><p>
55 <item><ref id="BRK" name="BRK">
56 <item><ref id="CLI" name="CLI">
57 <item><ref id="SEI" name="SEI">
58 <item><ref id="_sys" name="_sys">
59 <item><ref id="getcpu" name="getcpu">
60 <item><ref id="reset_brk" name="reset_brk">
61 <item><ref id="set_brk" name="set_brk">
65 <sect1><tt/apple2.h/<label id="apple2.h"><p>
68 <sect1><tt/atari.h/<label id="atari.h"><p>
71 <sect1><tt/atmos.h/<label id="atmos.h"><p>
74 <sect1><tt/assert.h/<label id="assert.h"><p>
77 <item><ref id="assert" name="assert">
81 <sect1><tt/c128.h/<label id="c128.h"><p>
84 <item><ref id="c64mode" name="c64mode">
85 <item><ref id="fast" name="fast">
86 <item><ref id="toggle_videomode" name="toggle_videomode">
87 <item><ref id="slow" name="slow">
91 <sect1><tt/c16.h/<label id="c16.h"><p>
94 <sect1><tt/c64.h/<label id="c64.h"><p>
97 <sect1><tt/conio.h/<label id="conio.h"><p>
100 <item><ref id="bgcolor" name="bgcolor">
101 <item><ref id="bordercolor" name="bordercolor">
102 <item><ref id="cclear" name="cclear">
103 <item><ref id="cclearxy" name="cclearxy">
104 <item><ref id="cgetc" name="cgetc">
105 <item><ref id="chline" name="chline">
106 <item><ref id="chlinexy" name="chlinexy">
107 <item><ref id="clrscr" name="clrscr">
108 <item><ref id="cprintf" name="cprintf">
109 <item><ref id="cputc" name="cputc">
110 <item><ref id="cputcxy" name="cputcxy">
111 <item><ref id="cputs" name="cputs">
112 <item><ref id="cputsxy" name="cputsxy">
113 <item><ref id="cursor" name="cursor">
114 <item><ref id="cvline" name="cvline">
115 <item><ref id="cvlinexy" name="cvlinexy">
116 <item><ref id="gotox" name="gotox">
117 <item><ref id="gotoxy" name="gotoxy">
118 <item><ref id="gotoy" name="gotoy">
119 <item><ref id="kbhit" name="kbhit">
120 <item><ref id="revers" name="revers">
121 <item><ref id="screensize" name="screensize">
122 <item><ref id="textcolor" name="textcolor">
123 <item><ref id="vcprintf" name="vcprintf">
124 <item><ref id="wherex" name="wherex">
125 <item><ref id="wherey" name="wherey">
129 <sect1><tt/ctype.h/<label id="ctype.h"><p>
132 <item><ref id="isalnum" name="isalnum">
133 <item><ref id="isalpha" name="isalpha">
134 <item><ref id="isascii" name="isascii">
135 <item><ref id="isblank" name="isblank">
136 <item><ref id="iscntrl" name="iscntrl">
137 <item><ref id="isdigit" name="isdigit">
138 <item><ref id="isgraph" name="isgraph">
139 <item><ref id="islower" name="islower">
140 <item><ref id="isprint" name="isprint">
141 <item><ref id="ispunct" name="ispunct">
142 <item><ref id="isspace" name="isspace">
143 <item><ref id="isupper" name="isupper">
144 <item><ref id="isxdigit" name="isxdigit">
145 <item><ref id="tolower" name="tolower">
146 <item><ref id="toupper" name="toupper">
150 <sect1><tt/dbg.h/<label id="dbg.h"><p>
153 <sect1><tt/dio.h/<label id="dio.h"><p>
156 <sect1><tt/em.h/<label id="em.h"><p>
159 <item><ref id="em_commit" name="em_commit">
160 <item><ref id="em_copyfrom" name="em_copyfrom">
161 <item><ref id="em_copyto" name="em_copyto">
162 <item><ref id="em_load_driver" name="em_load_driver">
163 <item><ref id="em_map" name="em_map">
164 <item><ref id="em_pagecount" name="em_pagecount">
165 <item><ref id="em_unload" name="em_unload">
166 <item><ref id="em_use" name="em_use">
170 <sect1><tt/errno.h/<label id="errno.h"><p>
173 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
176 <item><ref id="close" name="close">
177 <item><ref id="creat" name="creat">
178 <item><ref id="open" name="open">
182 <sect1><tt/geos.h/<label id="geos.h"><p>
185 <sect1><tt/joystick.h/<label id="joystick.h"><p>
188 <sect1><tt/locale.h/<label id="locale.h"><p>
191 <item><ref id="localeconv" name="localeconv">
192 <item><ref id="setlocale" name="setlocale">
196 <sect1><tt/modload.h/<label id="modload.h"><p>
199 <item><ref id="mod_load" name="mod_load">
200 <item><ref id="mod_free" name="mod_free">
204 <sect1><tt/mouse.h/<label id="mouse.h"><p>
207 <!-- <item><ref id="mouse_load_driver" name="mouse_load_driver"> -->
208 <!-- <item><ref id="mouse_unload" name="mouse_unload"> -->
209 <!-- <item><ref id="mouse_install" name="mouse_install"> -->
210 <!-- <item><ref id="mouse_uninstall" name="mouse_uninstall"> -->
211 <!-- <item><ref id="mouse_hide" name="mouse_hide"> -->
212 <!-- <item><ref id="mouse_show" name="mouse_show"> -->
213 <!-- <item><ref id="mouse_box" name="mouse_box"> -->
214 <!-- <item><ref id="mouse_move" name="mouse_move"> -->
215 <!-- <item><ref id="mouse_buttons" name="mouse_buttons"> -->
216 <!-- <item><ref id="mouse_pos" name="mouse_pos"> -->
217 <!-- <item><ref id="mouse_info" name="mouse_info"> -->
218 <!-- <item><ref id="mouse_ioctl" name="mouse_ioctl"> -->
222 <sect1><tt/nes.h/<label id="nes.h"><p>
225 <sect1><tt/o65.h/<label id="o65.h"><p>
228 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
231 <item><ref id="PEEK" name="PEEK">
232 <item><ref id="PEEKW" name="PEEKW">
233 <item><ref id="POKE" name="POKE">
234 <item><ref id="POKEW" name="POKEW">
238 <sect1><tt/pet.h/<label id="pet.h"><p>
241 <sect1><tt/plus4.h/<label id="plus4.h"><p>
244 <sect1><tt/serial.h/<label id="serial.h"><p>
247 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
250 <sect1><tt/signal.h/<label id="signal.h"><p>
253 <item><ref id="raise" name="raise">
254 <item><ref id="signal" name="signal">
258 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
261 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
264 <sect1><tt/stddef.h/<label id="stddef.h"><p>
267 <item><ref id="offsetof" name="offsetof">
271 <sect1><tt/stdio.h/<label id="stdio.h"><p>
274 <item><ref id="clearerr" name="clearerr">
275 <!-- <item><ref id="fclose" name="fclose"> -->
276 <!-- <item><ref id="fdopen" name="fdopen"> -->
277 <item><ref id="feof" name="feof">
278 <item><ref id="ferror" name="ferror">
279 <!-- <item><ref id="fflush" name="fflush"> -->
280 <!-- <item><ref id="fgetc" name="fgetc"> -->
281 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
282 <!-- <item><ref id="fgets" name="fgets"> -->
283 <item><ref id="fileno" name="fileno">
284 <!-- <item><ref id="flushall" name="flushall"> -->
285 <!-- <item><ref id="fopen" name="fopen"> -->
286 <!-- <item><ref id="fprintf" name="fprintf"> -->
287 <!-- <item><ref id="fputc" name="fputc"> -->
288 <!-- <item><ref id="fputs" name="fputs"> -->
289 <!-- <item><ref id="fread" name="fread"> -->
290 <!-- <item><ref id="freopen" name="freopen"> -->
291 <!-- <item><ref id="fscanf" name="fscanf"> -->
292 <!-- <item><ref id="fseek" name="fseek"> -->
293 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
294 <!-- <item><ref id="ftell" name="ftell"> -->
295 <!-- <item><ref id="fwrite" name="fwrite"> -->
296 <!-- <item><ref id="getc" name="getc"> -->
297 <!-- <item><ref id="getchar" name="getchar"> -->
298 <!-- <item><ref id="gets" name="gets"> -->
299 <!-- <item><ref id="printf" name="printf"> -->
300 <!-- <item><ref id="putc" name="putc"> -->
301 <!-- <item><ref id="putchar" name="putchar"> -->
302 <!-- <item><ref id="puts" name="puts"> -->
303 <!-- <item><ref id="rename" name="rename"> -->
304 <!-- <item><ref id="rewind" name="rewind"> -->
305 <!-- <item><ref id="scanf" name="scanf"> -->
306 <!-- <item><ref id="sprintf" name="sprintf"> -->
307 <!-- <item><ref id="sscanf" name="sscanf"> -->
308 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
309 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
310 <!-- <item><ref id="vprintf" name="vprintf"> -->
311 <!-- <item><ref id="vscanf" name="vscanf"> -->
312 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
313 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
317 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
320 <item><ref id="_heapadd" name="_heapadd">
321 <item><ref id="_heapblocksize" name="_heapblocksize">
322 <item><ref id="_heapmaxavail" name="_heapmaxavail">
323 <item><ref id="_heapmemavail" name="_heapmemavail">
324 <item><ref id="_poserror" name="_poserror">
325 <item><ref id="_randomize" name="_randomize">
326 <item><ref id="_swap" name="_swap">
327 <item><ref id="abort" name="abort">
328 <item><ref id="abs" name="abs">
329 <item><ref id="atexit" name="atexit">
330 <item><ref id="atoi" name="atoi">
331 <item><ref id="atol" name="atol">
332 <item><ref id="bsearch" name="bsearch">
333 <item><ref id="calloc" name="calloc">
334 <item><ref id="div" name="div">
335 <item><ref id="exit" name="exit">
336 <item><ref id="free" name="free">
337 <item><ref id="getenv" name="getenv">
338 <item><ref id="itoa" name="itoa">
339 <item><ref id="labs" name="labs">
340 <item><ref id="ltoa" name="ltoa">
341 <item><ref id="malloc" name="malloc">
342 <item><ref id="perror" name="perror">
343 <item><ref id="qsort" name="qsort">
344 <item><ref id="rand" name="rand">
345 <item><ref id="realloc" name="realloc">
346 <item><ref id="remove" name="remove">
347 <item><ref id="srand" name="srand">
348 <item><ref id="ultoa" name="ultoa">
349 <item><ref id="utoa" name="utoa">
353 <sect1><tt/string.h/<label id="string.h"><p>
356 <item><ref id="_stroserror" name="_stroserror">
357 <item><ref id="bzero" name="bzero">
358 <item><ref id="memchr" name="memchr">
359 <item><ref id="memcpy" name="memcpy">
360 <item><ref id="memmove" name="memmove">
361 <item><ref id="memset" name="memset">
362 <item><ref id="strcasecmp" name="strcasecmp">
363 <item><ref id="strcat" name="strcat">
364 <item><ref id="strchr" name="strchr">
365 <item><ref id="strcmp" name="strcmp">
366 <item><ref id="strcoll" name="strcoll">
367 <item><ref id="strcpy" name="strcpy">
368 <item><ref id="strcspn" name="strcspn">
369 <item><ref id="strdup" name="strdup">
370 <item><ref id="strerror" name="strerror">
371 <item><ref id="stricmp" name="stricmp">
372 <item><ref id="strlen" name="strlen">
373 <item><ref id="strlower" name="strlower">
374 <item><ref id="strlwr" name="strlwr">
375 <item><ref id="strncat" name="strncat">
376 <item><ref id="strncmp" name="strncmp">
377 <item><ref id="strncpy" name="strncpy">
378 <item><ref id="strrchr" name="strrchr">
379 <item><ref id="strspn" name="strspn">
380 <item><ref id="strstr" name="strstr">
381 <!-- <item><ref id="strtok" name="strtok"> -->
382 <!-- <item><ref id="strxfrm" name="strxfrm"> -->
383 <item><ref id="strupper" name="strupper">
384 <item><ref id="strupr" name="strupr">
388 <sect1><tt/tgi.h/<label id="tgi.h"><p>
391 <sect1><tt/time.h/<label id="time.h"><p>
394 <!-- <item><ref id="_systime" name="_systime"> -->
395 <!-- <item><ref id="asctime" name="asctime"> -->
396 <!-- <item><ref id="clock" name="clock"> -->
397 <!-- <item><ref id="ctime" name="ctime"> -->
398 <!-- <item><ref id="gmtime" name="gmtime"> -->
399 <!-- <item><ref id="localtime" name="localtime"> -->
400 <!-- <item><ref id="mktime" name="mktime"> -->
401 <!-- <item><ref id="strftime" name="strftime"> -->
402 <item><ref id="time" name="time">
406 <sect1><tt/unistd.h/<label id="unistd.h"><p>
409 <!-- <item><ref id="chdir" name="chdir"> -->
410 <!-- <item><ref id="getcwd" name="getcwd"> -->
411 <!-- <item><ref id="lseek" name="lseek"> -->
412 <!-- <item><ref id="mkdir" name="mkdir"> -->
413 <!-- <item><ref id="read" name="read"> -->
414 <!-- <item><ref id="rmdir" name="rmdir"> -->
415 <item><ref id="sleep" name="sleep">
416 <item><ref id="unlink" name="unlink">
417 <!-- <item><ref id="write" name="write"> -->
421 <sect1><tt/vic20.h/<label id="vic20.h"><p>
424 <sect1><tt/zlib.h/<label id="zlib.h"><p>
429 <sect>Alphabetical function reference<p>
431 <sect1>_heapadd<label id="_heapadd"><p>
435 <tag/Function/Add a block to the heap.
436 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
437 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
438 <tag/Description/The function adds a block of raw memory to the heap.
441 <item>The minimum blocksize that can be added is 6 bytes; the function will
442 ignore blocks with smaller sizes.
444 <tag/Availability/cc65
446 <ref id="_heapblocksize" name="_heapblocksize">,
447 <ref id="_heapmaxavail" name="_heapmaxavail">,
448 <ref id="_heapmemavail" name="_heapmemavail">,
449 <ref id="calloc" name="calloc">,
450 <ref id="free" name="free">,
451 <ref id="malloc" name="malloc">,
452 <ref id="realloc" name="realloc">
458 <sect1>_heapblocksize<label id="_heapblocksize"><p>
462 <tag/Function/Return the size of an allocated block.
463 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
464 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
465 <tag/Description/The function returns the size of a block that must have
466 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
467 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
470 <item>Passing a pointer to a block that was is not the result of one of the
471 allocation functions, or that has been free'd will give unpredicable results.
473 <tag/Availability/cc65
475 <ref id="_heapadd" name="_heapadd">,
476 <ref id="_heapmaxavail" name="_heapmaxavail">,
477 <ref id="_heapmemavail" name="_heapmemavail">,
478 <ref id="calloc" name="calloc">,
479 <ref id="free" name="free">,
480 <ref id="malloc" name="malloc">,
481 <ref id="realloc" name="realloc">
487 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
491 <tag/Function/Return the largest block that is available on the heap.
492 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
493 <tag/Declaration/<tt/size_t __fastcall__ _heapmaxavail (void);/
494 <tag/Description/The function returns the size of the largest block that may
495 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
496 <tag/Availability/cc65
498 <ref id="_heapadd" name="_heapadd">,
499 <ref id="_heapblocksize" name="_heapblocksize">,
500 <ref id="_heapmemavail" name="_heapmemavail">,
501 <ref id="calloc" name="calloc">,
502 <ref id="free" name="free">,
503 <ref id="malloc" name="malloc">,
504 <ref id="realloc" name="realloc">
510 <sect1>_heapmemavail<label id="_heapmemavail"><p>
514 <tag/Function/Return the total available space on the heap.
515 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
516 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
517 <tag/Description/The function returns the total number of bytes available on
521 <item>This function is of less use than usually assumed, since the returned
522 heap space may be available but not in one block. So even if this function
523 says that several times more heap space is available than needed, <ref
524 id="malloc" name="malloc"> may still return <tt/NULL/.
526 <tag/Availability/cc65
528 <ref id="_heapadd" name="_heapadd">,
529 <ref id="_heapblocksize" name="_heapblocksize">,
530 <ref id="_heapmaxavail" name="_heapmaxavail">,
531 <ref id="calloc" name="calloc">,
532 <ref id="free" name="free">,
533 <ref id="malloc" name="malloc">,
534 <ref id="realloc" name="realloc">
540 <sect1>_poserror<label id="_poserror"><p>
544 <tag/Function/Print an error message for the error in <tt/_oserrno/.
545 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
546 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
547 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
548 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
549 a colon and a blank. Then the error message for the current contents of
550 <tt/_oserrno/ are printed followed by a newline. The message output is the
551 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
552 argument of <tt/_oserrno/.
555 <item>Since operating system specific error code are - you guessed it -
556 operating system specific, the value in <tt/_oserror/ and the message that is
557 printed depend on the cc65 target.
558 <item>The function is only available as fastcall function, so it may only
559 be used in presence of a prototype.
561 <tag/Availability/cc65
563 <ref id="_stroserror" name="_stroserror">,
564 <ref id="perror" name="perror">
570 <sect1>_randomize<label id="_randomize"><p>
574 <tag/Function/Initialize the pseudo random number generator.
575 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
576 <tag/Declaration/<tt/void _randomize (void);/
577 <tag/Description/The function initializes the random number generator with
578 a seed derived from fast changing hardware events, so the seed itself can be
579 considered random to a certain degree.
580 <tag/Limits/<itemize>
581 <item>The randomness of the seed depends on the machine hardware.
583 <tag/Availability/cc65
585 <ref id="rand" name="rand">,
586 <ref id="srand" name="srand">
592 <sect1>_stroserror<label id="_stroserror"><p>
596 <tag/Function/Return a string describing an OS specific error code.
597 <tag/Header/<tt/<ref id="string.h" name="string.h">/
598 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
599 <tag/Description/<tt/_stroserror/ will return a string describing the given
600 operating system specific error code.
601 <tag/Limits/<itemize>
602 <item>Since operating system specific error code are - you guessed it -
603 operating system specific, the parameter and the string returned depend on the
605 <item>The function is only available as fastcall function, so it may only be
606 used in presence of a prototype.
608 <tag/Availability/cc65
610 <ref id="strerror" name="strerror">
616 <sect1>_swap<label id="_swap"><p>
620 <tag/Function/Swap the contents of memory areas.
621 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
622 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
623 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
624 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
625 <tt/size/ bytes in size.
626 <tag/Limits/<itemize>
627 <item>The memory areas may not overlap, otherwise the results are undefined.
628 <item>The function is only available as fastcall function, so it may only be
629 used in presence of a prototype.
631 <tag/Availability/cc65
633 <ref id="memcpy" name="memcpy">,
634 <ref id="memmove" name="memmove">
640 <sect1>_sys<label id="_sys"><p>
644 <tag/Function/Call a subroutine passing register values.
645 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
646 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
647 <tag/Description/The function will call the subroutine at the address
648 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
649 registers and the CPU flags are set to the values given in the <tt/regs/
650 structure. On return from the subroutine, the new values of the registers and
651 flags are stored back overwriting the old values.
652 <tag/Limits/<itemize>
653 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
654 when calling the subroutine (they are unchanged from their current values).
655 <item>The function is only available as fastcall function, so it may only be
656 used in presence of a prototype.
658 <tag/Availability/cc65
664 <sect1>BRK<label id="BRK"><p>
668 <tag/Function/Insert a 6502 BRK instrunction into the code.
669 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
670 <tag/Declaration/<tt/void BRK (void);/
671 <tag/Description/The function will insert a 6502 BRK instruction into the code
672 which may be used to trigger a debugger.
673 <tag/Limits/<itemize>
674 <item>The function is actually a macro.
675 <item>The inserted instruction may lead to unexpected results if no debugger
678 <tag/Availability/cc65
680 <ref id="CLI" name="CLI">,
681 <ref id="SEI" name="SEI">
687 <sect1>CLI<label id="CLI"><p>
691 <tag/Function/Insert a 6502 CLI instrunction into the code.
692 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
693 <tag/Declaration/<tt/void CLI (void);/
694 <tag/Description/The function will insert a 6502 CLI instruction into the code,
695 so interrupts are disabled. Note that non maskable interrupts cannot be
697 <tag/Limits/<itemize>
698 <item>The function is actually a macro.
699 <item>Disabling interrupts may lead to unexpected results.
701 <tag/Availability/cc65
703 <ref id="BRK" name="BRK">,
704 <ref id="SEI" name="SEI">
710 <sect1>PEEK<label id="PEEK"><p>
714 <tag/Function/Read a byte from memory.
715 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
716 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
717 <tag/Description/The function will read the absolute memory given by <tt/addr/
718 and return the value read.
719 <tag/Limits/<itemize>
720 <item>The function is actually a macro.
721 <item>This function depends highly on the platform and environment.
723 <tag/Availability/cc65
725 <ref id="PEEKW" name="PEEKW">,
726 <ref id="POKE" name="POKE">
732 <sect1>PEEKW<label id="PEEKW"><p>
736 <tag/Function/Read a word (two bytes) from memory.
737 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
738 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
739 <tag/Description/The function will read the absolute memory given by <tt/addr/
740 and return the value read. The byte read from the higher address is the high
741 byte of the return value.
742 <tag/Limits/<itemize>
743 <item>The function is actually a macro.
744 <item>This function depends highly on the platform and environment.
745 <item>The order in which the two bytes are read is unspecified and may
746 depend of the address expression used.
748 <tag/Availability/cc65
750 <ref id="PEEK" name="PEEK">,
751 <ref id="POKE" name="POKE">
757 <sect1>POKE<label id="POKE"><p>
761 <tag/Function/Write a byte to memory.
762 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
763 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
764 <tag/Description/The function writes the value <tt/val/ to the absolute
765 memory address given by <tt/addr/.
766 <tag/Limits/<itemize>
767 <item>The function is actually a macro.
768 <item>This function depends highly on the platform and environment.
769 <item>Careless use will cause the program to act strange or may crash the
772 <tag/Availability/cc65
774 <ref id="PEEK" name="PEEK">,
775 <ref id="POKEW" name="POKEW">
781 <sect1>POKEW<label id="POKEW"><p>
785 <tag/Function/Write a word (two bytes) to memory.
786 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
787 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
788 <tag/Description/The function writes the value <tt/val/ to the absolute
789 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
790 the <tt/addr/, the high byte is written to <tt/addr+1/.
791 <tag/Limits/<itemize>
792 <item>The function is actually a macro.
793 <item>This function depends highly on the platform and environment.
794 <item>Careless use will cause the program to act strange or may crash the
796 <item>The order in which the two bytes are written is unspecified and may
797 depend of the address expression used.
799 <tag/Availability/cc65
801 <ref id="PEEK" name="PEEK">,
802 <ref id="POKE" name="POKE">
808 <sect1>SEI<label id="SEI"><p>
812 <tag/Function/Insert a 6502 SEI instrunction into the code.
813 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
814 <tag/Declaration/<tt/void SEI (void);/
815 <tag/Description/The function will insert a 6502 SEI instruction into the code,
816 so interrupts are enabled. Enabling interrupts has no effects if they are
817 already enabled (the default).
818 <tag/Limits/<itemize>
819 <item>The function is actually a macro.
821 <tag/Availability/cc65
823 <ref id="BRK" name="BRK">,
824 <ref id="CLI" name="CLI">
830 <sect1>abort<label id="abort"><p>
834 <tag/Function/Terminates a program abnormally.
835 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
836 <tag/Declaration/<tt/void abort (void);/
837 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
838 on stderr, then terminates the program with an exit code of 3.
839 <tag/Availability/ISO 9899
841 <ref id="assert" name="assert">,
842 <ref id="exit" name="exit">,
843 <ref id="raise" name="raise">
849 <sect1>abs<label id="abs"><p>
853 <tag/Function/Returns the absolute value of an integer.
854 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
855 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
856 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
858 <tag/Limits/<itemize>
859 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
860 <item>The function is only available as fastcall function, so it may only be
861 used in presence of a prototype.
863 <tag/Availability/ISO 9899
865 <ref id="labs" name="labs">
871 <sect1>assert<label id="assert"><p>
875 <tag/Function/Test a condition and possibly abort.
876 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
877 <tag/Declaration/<tt/void assert (int cond);/
878 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
879 statement. If the condition evaluates t zero (false), assert prints a message
880 on stderr and aborts the program.
881 <tag/Limits/<itemize>
882 <item>The function is actually a macro.
884 <tag/Availability/ISO 9899
886 <ref id="abort" name="abort">,
887 <ref id="exit" name="exit">
893 <sect1>atexit<label id="atexit"><p>
897 <tag/Function/Register an exit function.
898 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
899 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
900 <tag/Description/<tt/atexit/ registers the function pointed to by
901 <tt/exitfunc/ as an exit function. Exit functions are called when the program
902 terminates, they are called in LIFO order (the last function registered is
903 called first). <tt/atexit/ returns zero on success and a nonzero value on
905 <tag/Limits/<itemize>
906 <item>A maximum of 5 exit functions can be registered.
907 <item>There is no way to unregister an exit function.
908 <item>The function is only available as fastcall function, so it may only be
909 used in presence of a prototype.
911 <tag/Availability/ISO 9899
913 <ref id="abort" name="abort">,
914 <ref id="exit" name="exit">
920 <sect1>atoi<label id="atoi"><p>
924 <tag/Function/Convert a string to an integer.
925 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
926 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
927 <tag/Description/<tt/atoi/ converts the given string into an integer.
928 Conversion stops as soon as any invalid character is encountered.
929 <tag/Limits/<itemize>
930 <item>There is no way to detect any conversion errors.
931 <item>The function does not check for an numerical overflow when converting.
932 <item>The function is only available as fastcall function, so it may only be
933 used in presence of a prototype.
935 <tag/Availability/ISO 9899
937 <ref id="atol" name="atol">,
938 <ref id="itoa" name="itoa">,
939 <ref id="ltoa" name="ltoa">,
940 <ref id="ultoa" name="ultoa">,
941 <ref id="utoa" name="utoa">
947 <sect1>atol<label id="atol"><p>
951 <tag/Function/Convert a string to a long integer.
952 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
953 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
954 <tag/Description/<tt/atol/ converts the given string into a long integer.
955 Conversion stops as soon as any invalid character is encountered.
956 <tag/Limits/<itemize>
957 <item>There is no way to detect any conversion errors.
958 <item>The function does not check for an numerical overflow when converting.
959 <item>The function is only available as fastcall function, so it may only be
960 used in presence of a prototype.
962 <tag/Availability/ISO 9899
964 <ref id="atoi" name="atoi">,
965 <ref id="itoa" name="itoa">,
966 <ref id="ltoa" name="ltoa">,
967 <ref id="ultoa" name="ultoa">,
968 <ref id="utoa" name="utoa">
974 <sect1>bgcolor<label id="bgcolor"><p>
978 <tag/Function/Set the background text color.
979 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
980 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
981 <tag/Description/The function will set a new background color and return the
982 old (current) one. The background color is valid for the whole text output
983 area of the screen, not just for new text.
984 <tag/Limits/<itemize>
985 <item>Background colors are system dependent. The function may have no effect
986 on systems where the background color cannot be changed.
987 <item>The function is only available as fastcall function, so it may only be
988 used in presence of a prototype.
990 <tag/Availability/cc65
992 <ref id="bordercolor" name="bordercolor">,
993 <ref id="textcolor" name="textcolor">
999 <sect1>bordercolor<label id="bordercolor"><p>
1003 <tag/Function/Set the border (frame) color.
1004 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1005 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1006 <tag/Description/The function will set a new border color. It returns the old
1007 (current) border color.
1008 <tag/Limits/<itemize>
1009 <item>Border colors are system dependent. The function may have no effect
1010 on systems where the border color cannot be changed.
1011 <item>The function is only available as fastcall function, so it may only
1012 be used in presence of a prototype.
1014 <tag/Availability/cc65
1016 <ref id="bgcolor" name="bgcolor">,
1017 <ref id="textcolor" name="textcolor">
1023 <sect1>bsearch<label id="bsearch"><p>
1027 <tag/Function/Do a binary search in a sorted array.
1028 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1029 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1030 const void* base, size_t n, size_t size,
1031 int (*cmp) (const void*, const void*));/
1032 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1033 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1034 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1035 the function used to compare the members against the key. The function returns
1036 a pointer to the member found, or <tt/NULL/ if there was no match.
1039 <item>The contents of the array must be sorted in ascending order according to
1040 the compare function given.
1041 <item>If there are multiple members that match the key, the function will
1042 return one of the members.
1043 <item>The function is only available as fastcall function, so it may only
1044 be used in presence of a prototype.
1046 <tag/Availability/ISO 9899
1048 <ref id="qsort" name="qsort">
1054 <sect1>bzero<label id="bzero"><p>
1058 <tag/Function/Fill a memory area with zeroes.
1059 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1060 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1061 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1065 <item>The function is non standard and therefore only available in non ANSI
1066 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1067 <item>The function is only available as fastcall function, so it may only
1068 be used in presence of a prototype.
1070 <tag/Availability/cc65
1072 <ref id="_swap" name="_swap">,
1073 <ref id="memcpy" name="memcpy">,
1074 <ref id="memmove" name="memmove">,
1075 <ref id="memset" name="memset">,
1081 <sect1>c64mode<label id="c64mode"><p>
1085 <tag/Function/Switch the C128 into C64 compatible mode.
1086 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1087 <tag/Declaration/<tt/void c64mode (void);/
1088 <tag/Description/The function will cause the machine to reboot into C64 mode.
1089 <tag/Limits/<itemize>
1090 <item>The function is specific to the C128.
1091 <item>The function will not return to the caller.
1093 <tag/Availability/C128
1099 <sect1>calloc<label id="calloc"><p>
1103 <tag/Function/Allocate and clear memory.
1104 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1105 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1106 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1107 of size <tt/size/, clears the whole block with binary zeroes and returns a
1108 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1112 <item>Clearing the memory may not have the expected effect on all platforms:
1113 pointers in the block may not be <tt/NULL/ and floating point variables may
1114 not be zero (0.0). In other words: The "clearing" effect of this function
1115 should be used with care for portable programs.
1116 <item>The function is only available as fastcall function, so it may only
1117 be used in presence of a prototype.
1119 <tag/Availability/ISO 9899
1121 <ref id="_heapadd" name="_heapadd">,
1122 <ref id="_heapblocksize" name="_heapblocksize">,
1123 <ref id="_heapmaxavail" name="_heapmaxavail">,
1124 <ref id="_heapmemavail" name="_heapmemavail">,
1125 <ref id="free" name="free">,
1126 <ref id="malloc" name="malloc">,
1127 <ref id="realloc" name="realloc">
1133 <sect1>cclear<label id="cclear"><p>
1137 <tag/Function/Clear part of a line (write a given number of spaces).
1138 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1139 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1140 <tag/Description/The function clears part of a line by writing <tt/length/
1141 spaces in the current text color.
1142 <tag/Limits/<itemize>
1143 <item>The function is only available as fastcall function, so it may
1144 only be used in presence of a prototype.
1146 <tag/Availability/cc65
1148 <ref id="cclearxy" name="cclearxy">,
1149 <ref id="clrscr" name="clrscr">
1155 <sect1>cclearxy<label id="cclearxy"><p>
1159 <tag/Function/Clear part of a line (write a given number of spaces) starting
1160 at a specific screen position.
1161 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1162 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1163 <tag/Description/The function moves the cursor to a specific position, and
1164 will then clear part of the line by writing <tt/length/ spaces in the current
1166 <tag/Limits/<itemize>
1167 <item>The function is only available as fastcall function, so it may
1168 only be used in presence of a prototype.
1170 <tag/Availability/cc65
1172 <ref id="cclear" name="cclear">,
1173 <ref id="clrscr" name="clrscr">
1179 <sect1>cgetc<label id="cgetc"><p>
1183 <tag/Function/Read a character from the keyboard.
1184 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1185 <tag/Declaration/<tt/char cgetc (void);/
1186 <tag/Description/The function reads a character from the keyboard. If there is
1187 no character available, <tt/cgetc/ waits until the user presses a key. If the
1188 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1189 displayed while waiting.
1190 <tag/Limits/<itemize>
1191 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1192 from this buffer and wait only if the buffer is empty.
1194 <tag/Availability/cc65
1196 <ref id="cursor" name="cursor">,
1197 <ref id="kbhit" name="kbhit">
1203 <sect1>chline<label id="chline"><p>
1207 <tag/Function/Output a horizontal line in text mode.
1208 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1209 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1210 <tag/Description/The function outputs a horizontal line with the given length
1211 starting at the current cursor position.
1212 <tag/Limits/<itemize>
1213 <item>The character used to draw the horizontal line is system dependent.
1214 If available, a line drawing character is used. Drawing a line that is partially
1215 off screen leads to undefined behaviour.
1216 <item>The function is only available as fastcall function, so it may only be
1217 used in presence of a prototype.
1219 <tag/Availability/cc65
1221 <ref id="chlinexy" name="chlinexy">,
1222 <ref id="cvline" name="cvline">,
1223 <ref id="cvlinexy" name="cvlinexy">
1229 <sect1>chlinexy<label id="chlinexy"><p>
1233 <tag/Function/Output a horizontal line at a given position in text mode.
1234 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1235 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1236 <tag/Description/The function outputs a horizontal line with the given length
1237 starting at a given position.
1238 <tag/Limits/<itemize>
1239 <item>The character used to draw the horizontal line is system dependent.
1240 If available, a line drawing character is used. Drawing a line that is partially
1241 off screen leads to undefined behaviour.
1242 <item>The function is only available as fastcall function, so it may only be
1243 used in presence of a prototype.
1245 <tag/Availability/cc65
1247 <ref id="chline" name="chline">,
1248 <ref id="cvline" name="cvline">,
1249 <ref id="cvlinexy" name="cvlinexy">
1255 <sect1>clearerr<label id="clearerr"><p>
1259 <tag/Function/Clear error and end-of-file status of a stream.
1260 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1261 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1262 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1263 indicators for the stream <tt/f/.
1264 <tag/Limits/<itemize>
1265 <item>The function is only available as fastcall function, so it may only be
1266 used in presence of a prototype.
1268 <tag/Availability/ISO 9899
1270 <ref id="feof" name="feof">,
1271 <ref id="ferror" name="ferror">
1277 <sect1>clrscr<label id="clrscr"><p>
1281 <tag/Function/Clear the text screen.
1282 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1283 <tag/Declaration/<tt/void clrscr (void);/
1284 <tag/Description/The function clears the text screen and moves the cursor to
1285 the upper left corner.
1286 <tag/Availability/cc65
1288 <ref id="cclear" name="cclear">,
1289 <ref id="cclearxy" name="cclearxy">
1295 <sect1>close<label id="close"><p>
1299 <tag/Function/Close a file descriptor.
1300 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1301 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1302 <tag/Description/The function closes the given file descriptor. It returns zero
1303 on success and -1 on error. If an error occurs, the cause can be determined by
1304 reading the <tt/errno/ variable.
1305 <tag/Limits/<itemize>
1306 <item>The function is only available as fastcall function, so it may only
1307 be used in presence of a prototype.
1309 <tag/Availability/POSIX 1003.1
1311 <ref id="creat" name="creat">,
1312 <ref id="open" name="open">
1318 <sect1>creat<label id="creat"><p>
1322 <tag/Function/Create a file.
1323 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1324 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1325 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1326 associated with it. On error, -1 is returned and an error code is stored in
1328 <tag/Limits/<itemize>
1329 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1330 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1331 <item>The function is only available as fastcall function, so it may only
1332 be used in presence of a prototype.
1334 <tag/Availability/POSIX 1003.1
1336 <ref id="close" name="close">,
1337 <ref id="open" name="open">
1343 <sect1>cprintf<label id="cprintf"><p>
1347 <tag/Function/Formatted output to the console.
1348 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1349 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1350 <tag/Description/The arguments are converted to text where necessary and
1351 formatted according to the format string given. The resulting string is output
1352 to the console. <tt/cprintf/ supports the same format specifiers as
1353 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1354 <tag/Limits/<itemize>
1355 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1356 between <tt/\r/ and <tt/\n/.
1358 <tag/Availability/cc65
1360 <ref id="cputc" name="cputc">,
1361 <ref id="cputcxy" name="cputcxy">,
1362 <ref id="cputs" name="cputs">,
1363 <ref id="cputsxy" name="cputsxy">,
1364 <ref id="vcprintf" name="vcprintf">
1370 <sect1>cputc<label id="cputc"><p>
1374 <tag/Function/Output a character directly to the console.
1375 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1376 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1377 <tag/Description/Output one character to the console at the current cursor
1379 <tag/Limits/<itemize>
1380 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1381 between <tt/\r/ and <tt/\n/.
1382 <item>The function is only available as fastcall function, so it may only
1383 be used in presence of a prototype.
1385 <tag/Availability/cc65
1387 <ref id="cprintf" name="cprintf">,
1388 <ref id="cputcxy" name="cputcxy">,
1389 <ref id="cputs" name="cputs">,
1390 <ref id="cputsxy" name="cputsxy">,
1391 <ref id="vcprintf" name="vcprintf">
1397 <sect1>cputcxy<label id="cputcxy"><p>
1401 <tag/Function/Output a character at a specific screen position.
1402 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1403 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1404 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1405 the screen and outputs one character.
1406 <tag/Limits/<itemize>
1407 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1408 between <tt/\r/ and <tt/\n/.
1409 <item>The function is only available as fastcall function, so it may only
1410 be used in presence of a prototype.
1412 <tag/Availability/cc65
1414 <ref id="cprintf" name="cprintf">,
1415 <ref id="cputc" name="cputc">,
1416 <ref id="cputs" name="cputs">,
1417 <ref id="cputsxy" name="cputsxy">,
1418 <ref id="vcprintf" name="vcprintf">
1424 <sect1>cputs<label id="cputs"><p>
1428 <tag/Function/Output a string directly to the console.
1429 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1430 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1431 <tag/Description/The function outputs the given string on the console at the
1432 current cursor position.
1433 <tag/Limits/<itemize>
1434 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1435 between <tt/\r/ and <tt/\n/.
1436 <item>The function is only available as fastcall function, so it may only
1437 be used in presence of a prototype.
1439 <tag/Availability/cc65
1441 <ref id="cprintf" name="cprintf">,
1442 <ref id="cputc" name="cputc">,
1443 <ref id="cputcxy" name="cputcxy">,
1444 <ref id="cputsxy" name="cputsxy">,
1445 <ref id="vcprintf" name="vcprintf">
1451 <sect1>cputsxy<label id="cputsxy"><p>
1455 <tag/Function/Output a string to the console at a given position.
1456 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1457 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1458 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1459 and outputs the string <tt/s/.
1460 <tag/Limits/<itemize>
1461 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1462 between <tt/\r/ and <tt/\n/.
1463 <item>The function is only available as fastcall function, so it may only
1464 be used in presence of a prototype.
1466 <tag/Availability/cc65
1468 <ref id="cprintf" name="cprintf">,
1469 <ref id="cputc" name="cputc">,
1470 <ref id="cputcxy" name="cputcxy">,
1471 <ref id="cputs" name="cputs">,
1472 <ref id="vcprintf" name="vcprintf">
1478 <sect1>cursor<label id="cursor"><p>
1482 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1483 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1484 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1485 <tag/Description/If the argument to the function is non zero, a blinking cursor
1486 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1487 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1488 <tag/Limits/<itemize>
1489 <item>The function is only available as fastcall function, so it may only
1490 be used in presence of a prototype.
1492 <tag/Availability/cc65
1494 <ref id="cgetc" name="cgetc">,
1495 <ref id="kbhit" name="kbhit">
1501 <sect1>cvline<label id="cvline"><p>
1505 <tag/Function/Output a vertical line in text mode.
1506 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1507 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1508 <tag/Description/The function outputs a vertical line with the given length
1509 starting at the current cursor position.
1510 <tag/Limits/<itemize>
1511 <item>The character used to draw the vertical line is system dependent.
1512 If available, a line drawing character is used. Drawing a line that is partially
1513 off screen leads to undefined behaviour.
1514 <item>The function is only available as fastcall function, so it may only be
1515 used in presence of a prototype.
1517 <tag/Availability/cc65
1519 <ref id="chline" name="chline">,
1520 <ref id="chlinexy" name="chlinexy">,
1521 <ref id="cvlinexy" name="cvlinexy">
1527 <sect1>cvlinexy<label id="cvlinexy"><p>
1531 <tag/Function/Output a vertical line at a given position in text mode.
1532 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1533 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1534 <tag/Description/The function outputs a vertical line with the given length
1535 starting at a given position.
1536 <tag/Limits/<itemize>
1537 <item>The character used to draw the vertical line is system dependent.
1538 If available, a line drawing character is used. Drawing a line that is partially
1539 off screen leads to undefined behaviour.
1540 <item>The function is only available as fastcall function, so it may only be
1541 used in presence of a prototype.
1543 <tag/Availability/cc65
1545 <ref id="chline" name="chline">,
1546 <ref id="chlinexy" name="chlinexy">,
1547 <ref id="cvline" name="cvline">
1553 <sect1>div<label id="div"><p>
1557 <tag/Function/Divide two ints and return quotient and remainder.
1558 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1559 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1560 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1561 quotient and remainder in a <tt/div_t/ structure.
1564 <item>The function is only available as fastcall function, so it may only
1565 be used in presence of a prototype.
1567 <tag/Availability/ISO 9899
1575 <sect1>em_commit<label id="em_commit"><p>
1579 <tag/Function/Commit changes into extended memory.
1580 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1581 <tag/Declaration/<tt/void __fastcall__ em_commit (void);/
1582 <tag/Description/Commit changes in the memory window to extended storage. If
1583 the contents of the memory window have been changed, these changes may be lost
1584 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1585 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1586 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1587 <tag/Limits/<itemize>
1588 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1589 memory window are discarded, it does just mean that the drivers is allowed
1591 <item>The function is only available as fastcall function, so it may only be
1592 used in presence of a prototype.
1593 <item>The function produces undefined results if no extended memory driver is
1596 <tag/Availability/cc65
1598 <ref id="em_load_driver" name="em_load_driver">,
1599 <ref id="em_map" name="em_map">,
1600 <ref id="em_use" name="em_use">
1606 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1610 <tag/Function/Copy from extended into normal memory.
1611 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1612 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1613 <tag/Description/Copy data from extended memory into linear memory. Source and
1614 target addresses as well as the number of bytes to transfer are specified in
1615 the <tt/em_copy/ structure that is passed as a parameter.
1616 <tag/Limits/<itemize>
1617 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1618 made any changes to the data in the window, call <tt/<ref id="em_commit"
1619 name="em_commit">/ first, or the changes are lost.
1620 <item>The function is only available as fastcall function, so it may only be
1621 used in presence of a prototype.
1622 <item>The function produces undefined results if no extended memory driver is
1625 <tag/Availability/cc65
1627 <ref id="em_commit" name="em_commit">,
1628 <ref id="em_copyto" name="em_copyto">,
1629 <ref id="em_load_driver" name="em_load_driver">
1635 <sect1>em_copyto<label id="em_copyto"><p>
1639 <tag/Function/Copy from normal into extended memory.
1640 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1641 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
1642 <tag/Description/Copy data from linear into extended memory. Source and
1643 target addresses as well as the number of bytes to transfer are specified in
1644 the <tt/em_copy/ structure that is passed as a parameter.
1645 <tag/Limits/<itemize>
1646 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
1647 made any changes to the data in the window, call <tt/<ref id="em_commit"
1648 name="em_commit">/ first, or the changes are lost.
1649 <item>The function is only available as fastcall function, so it may only be
1650 used in presence of a prototype.
1651 <item>The function produces undefined results if no extended memory driver is
1654 <tag/Availability/cc65
1656 <ref id="em_commit" name="em_commit">,
1657 <ref id="em_copyfrom" name="em_copyfrom">,
1658 <ref id="em_load_driver" name="em_load_driver">
1664 <sect1>em_load_driver<label id="em_load_driver"><p>
1668 <tag/Function/Load and initialize an extended memory driver.
1669 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1670 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
1671 <tag/Description/Load an extended memory driver into memory and initialize
1672 it. The function returns an error code that tells if all this has been
1674 <tag/Limits/<itemize>
1675 <item>Not all drivers are able to detect if the supported hardware is really
1677 <item>The function is only available as fastcall function, so it may only be
1678 used in presence of a prototype.
1679 <item>The driver is loaded by name, so currently you must know the type of
1680 extended memory that should be supported. There is no autodetect capability.
1682 <tag/Availability/cc65
1684 <ref id="em_unload" name="em_unload">
1690 <sect1>em_map<label id="em_map"><p>
1694 <tag/Function/Make a page of extended memory accessible.
1695 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1696 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
1697 <tag/Description/The function maps one page of extended memory into linear
1698 memory and returns a pointer to the page frame. Depending on the hardware
1699 and driver, the data is either mapped into the address space or transfered
1700 into a buffer. If you don't need the actual contents of the page (for example
1701 because you're going to overwrite it completely, it is better to call
1702 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
1703 data if it is possible to avoid that.
1704 <tag/Limits/<itemize>
1705 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
1706 made any changes to the data in the window, call <tt/<ref id="em_commit"
1707 name="em_commit">/ first, or the changes are lost.
1708 <item>The function is only available as fastcall function, so it may only be
1709 used in presence of a prototype.
1710 <item>The function produces undefined results if no extended memory driver is
1713 <tag/Availability/cc65
1715 <ref id="em_commit" name="em_commit">,
1716 <ref id="em_load_driver" name="em_load_driver">,
1717 <ref id="em_use" name="em_use">
1723 <sect1>em_pagecount<label id="em_pagecount"><p>
1727 <tag/Function/Return the number of available extended memory pages.
1728 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1729 <tag/Declaration/<tt/unsigned __fastcall__ em_pagecount (void);/
1730 <tag/Description/The function returns the size of the extended memory supported
1731 by the driver in 256 byte pages.
1732 <tag/Limits/<itemize>
1733 <item>The function returns zero if no extended memory driver is loaded.
1734 <item>The function may return zero if the supported hardware was not detected.
1736 <tag/Availability/cc65
1738 <ref id="em_load_driver" name="em_load_driver">
1744 <sect1>em_unload<label id="em_unload"><p>
1748 <tag/Function/Unload an extended memory driver.
1749 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1750 <tag/Declaration/<tt/void __fastcall__ em_unload (void);/
1751 <tag/Description/The function unloads a loaded extended memory driver and
1752 frees all memory allocated for the driver.
1753 <tag/Limits/<itemize>
1754 <item>The function does nothing if no driver is loaded.
1756 <tag/Availability/cc65
1758 <ref id="em_load_driver" name="em_load_driver">
1764 <sect1>em_use<label id="em_use"><p>
1768 <tag/Function/Prepare an extended memory page for use.
1769 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1770 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
1771 <tag/Description/The function maps one page of extended memory into linear
1772 memory and returns a pointer to the page frame. This function is similar to
1773 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
1774 actual memory window in the assumption that the existing data is wrong or
1775 will get overwritten.
1776 <tag/Limits/<itemize>
1777 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
1778 made any changes to the data in the window, call <tt/<ref id="em_commit"
1779 name="em_commit">/ first, or the changes are lost.
1780 <item>The function is only available as fastcall function, so it may only be
1781 used in presence of a prototype.
1782 <item>The function produces undefined results if no extended memory driver is
1785 <tag/Availability/cc65
1787 <ref id="em_commit" name="em_commit">,
1788 <ref id="em_load_driver" name="em_load_driver">,
1789 <ref id="em_map" name="em_map">
1795 <sect1>exit<label id="exit"><p>
1799 <tag/Function/Terminate the program.
1800 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1801 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
1802 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
1803 return code of the program. Before termination, all files are closed, buffered
1804 output is written and any functions registered with <tt/<ref id="atexit"
1805 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
1806 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
1808 <tag/Limits/<itemize>
1809 <item>The function is only available as fastcall function, so it may only
1810 be used in presence of a prototype.
1811 <item>It depends on the host machine if the program return code can be
1812 evaluated or is ignored.
1814 <tag/Availability/ISO 9899
1816 <ref id="abort" name="abort">,
1817 <ref id="exit" name="exit">
1823 <sect1>fast<label id="fast"><p>
1827 <tag/Function/Switch the C128 into 2MHz mode.
1828 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1829 <tag/Declaration/<tt/void fast (void);/
1830 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
1831 will nearly double the speed compared to slow mode.
1832 <tag/Limits/<itemize>
1833 <item>The function is specific to the C128.
1834 <item>2MHz clock will not work in 40 column mode.
1836 <tag/Availability/C128
1838 <ref id="slow" name="slow">,
1839 <ref id="toggle_videomode" name="toggle_videomode">
1845 <sect1>feof<label id="feof"><p>
1849 <tag/Function/Return the end-of-file indicator of a stream.
1850 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1851 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
1852 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
1853 <tt/f/, and returns a non zero value if it is set.
1854 <tag/Limits/<itemize>
1855 <item>The indicator is set only after a read past the end of a file is
1857 <item>The function is only available as fastcall function, so it may only be
1858 used in presence of a prototype.
1860 <tag/Availability/ISO 9899
1862 <ref id="feof" name="clearerr">,
1863 <ref id="ferror" name="ferror">
1869 <sect1>ferror<label id="ferror"><p>
1873 <tag/Function/Return the error indicator of a stream.
1874 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1875 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
1876 <tag/Description/<tt/ferror/ tests the error indicator of the stream
1877 <tt/f/, and returns a non zero value if it is set.
1878 <tag/Limits/<itemize>
1879 <item>The function is only available as fastcall function, so it may only be
1880 used in presence of a prototype.
1882 <tag/Availability/ISO 9899
1884 <ref id="feof" name="clearerr">,
1885 <ref id="ferror" name="feof">
1891 <sect1>fileno<label id="fileno"><p>
1895 <tag/Function/Return the file handle used by a stream.
1896 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1897 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
1898 <tag/Description/The <tt/fileno/ function returns the file handle used
1899 internally by a C stream. This file handle (an integer) can be used as a
1900 handle for the POSIX input/output functions.
1901 <tag/Limits/<itemize>
1902 <item>The function is only available as fastcall function, so it may only be
1903 used in presence of a prototype.
1904 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
1905 file may have unpredictable results.
1907 <tag/Availability/POSIX 1003.1
1909 <ref id="creat" name="creat">,
1910 <ref id="open" name="open"> <!-- , -->
1911 <!-- <ref id="read" name="read">, -->
1912 <!-- <ref id="write" name="write"> -->
1918 <sect1>free<label id="free"><p>
1922 <tag/Function/Free a block of dynamic memory.
1923 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1924 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
1925 <tag/Description/Free a block of dynamic memory previously allocated with
1926 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
1927 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
1928 pointer is <tt/NULL/, no action is performed.
1931 <item>Passing an already free'd block to <tt/free/ again will cause undefined
1932 behaviour and may crash your program.
1933 <item>The function is only available as fastcall function, so it may only
1934 be used in presence of a prototype.
1936 <tag/Availability/ISO 9899
1938 <ref id="_heapadd" name="_heapadd">,
1939 <ref id="_heapblocksize" name="_heapblocksize">,
1940 <ref id="_heapmaxavail" name="_heapmaxavail">,
1941 <ref id="_heapmemavail" name="_heapmemavail">,
1942 <ref id="calloc" name="calloc">,
1943 <ref id="malloc" name="malloc">,
1944 <ref id="realloc" name="realloc">
1950 <sect1>getenv<label id="getenv"><p>
1954 <tag/Function/Return a value from the environment.
1955 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1956 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
1957 <tag/Description/The function searches the environment for an entry that
1958 matches <tt/name/ and returns its value. The environment consists of a list
1959 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
1961 <tag/Limits/<itemize>
1962 <item>What exactly is stored in the environment depends on the machine the
1963 program is running on.
1964 <item>The function is only available as fastcall function, so it may only
1965 be used in presence of a prototype.
1967 <tag/Availability/ISO 9899
1973 <sect1>getcpu<label id="getcpu"><p>
1977 <tag/Function/Determine on which CPU the program is running.
1978 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
1979 <tag/Declaration/<tt/unsigned char getcpu (void);/
1980 <tag/Description/The function checks on which CPU the code is running. It
1981 returns one of the constants<itemize>
1983 <item><tt/CPU_65C02/
1984 <item><tt/CPU_65816/
1986 <tag/Limits/<itemize>
1987 <item>Other, more exotic CPU types are not disinguished.
1989 <tag/Availability/cc65
1995 <sect1>gotox<label id="gotox"><p>
1999 <tag/Function/Move the text mode cursor to a new X position.
2000 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2001 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2002 <tag/Description/The function moves the text mode cursor to the specified X
2003 position while leaving the Y position untouched. The leftmost position on the
2004 screen has the coordinate 0.
2005 <tag/Limits/<itemize>
2006 <item>The function is only available as fastcall function, so it may
2007 only be used in presence of a prototype.
2008 <item>Invalid values for the X position (out of screen coordinates) may
2009 lead to undefined behaviour.
2011 <tag/Availability/cc65
2013 <ref id="gotoy" name="gotoy">,
2014 <ref id="gotoxy" name="gotoxy">,
2015 <ref id="wherex" name="wherex">,
2016 <ref id="wherey" name="wherey">
2022 <sect1>gotoxy<label id="gotoxy"><p>
2026 <tag/Function/Move the text mode cursor to a new position.
2027 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2028 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2029 <tag/Description/The function moves the text mode cursor to the specified
2030 position. The leftmost position on the screen has the X coordinate 0, the
2031 topmost line has the Y coordinate 0.
2032 <tag/Limits/<itemize>
2033 <item>The function is only available as fastcall function, so it may only be
2034 used in presence of a prototype.
2035 <item>Invalid values for any of both coordinates (out of screen positions) may
2036 lead to undefined behaviour.
2038 <tag/Availability/cc65
2040 <ref id="gotox" name="gotox">,
2041 <ref id="gotoy" name="gotoy">,
2042 <ref id="wherex" name="wherex">,
2043 <ref id="wherey" name="wherey">
2049 <sect1>gotoy<label id="gotoy"><p>
2053 <tag/Function/Move the text mode cursor to a new Y position.
2054 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2055 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2056 <tag/Description/The function moves the text mode cursor to the specified Y
2057 position while leaving the X position untouched. The uppermost position on the
2058 screen has the coordinate 0.
2059 <tag/Limits/<itemize>
2060 <item>The function is only available as fastcall function, so it may
2061 only be used in presence of a prototype.
2062 <item>Invalid values for the Y position (out of screen coordinates) may lead
2063 to undefined behaviour.
2065 <tag/Availability/cc65
2067 <ref id="gotox" name="gotox">,
2068 <ref id="gotoxy" name="gotoxy">,
2069 <ref id="wherex" name="wherex">,
2070 <ref id="wherey" name="wherey">
2076 <sect1>isalnum<label id="isalnum"><p>
2080 <tag/Function/Check if a given character is a letter or digit.
2081 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2082 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2083 <tag/Description/The function returns a value of zero if the given argument
2084 is a letter or digit. The return value is non zero if the character
2086 <tag/Limits/<itemize>
2087 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2088 inline sequence generated by the macro will not work correctly for values
2089 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2090 this range. The non inline function may be accessed by <tt/#undef/'ing
2092 <item>When compiling without <tt/-Os/, the function is only available as
2093 fastcall function, so it may only be used in presence of a prototype.
2095 <tag/Availability/ISO 9899
2097 <ref id="isalpha" name="isalpha">,
2098 <ref id="isascii" name="isascii">,
2099 <ref id="isblank" name="isblank">,
2100 <ref id="iscntrl" name="iscntrl">,
2101 <ref id="isdigit" name="isdigit">,
2102 <ref id="isgraph" name="isgraph">,
2103 <ref id="islower" name="islower">,
2104 <ref id="isprint" name="isprint">,
2105 <ref id="ispunct" name="ispunct">,
2106 <ref id="isspace" name="isspace">,
2107 <ref id="isupper" name="isupper">,
2108 <ref id="isxdigit" name="isxdigit">
2114 <sect1>isalpha<label id="isalpha"><p>
2118 <tag/Function/Check if a given character is a letter.
2119 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2120 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2121 <tag/Description/The function returns a value of zero if the given argument
2122 is a letter. The return value is non zero if the character is anything else.
2123 <tag/Limits/<itemize>
2124 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2125 inline sequence generated by the macro will not work correctly for values
2126 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2127 this range. The non inline function may be accessed by <tt/#undef/'ing the
2129 <item>When compiling without <tt/-Os/, the function is only available as
2130 fastcall function, so it may only be used in presence of a prototype.
2132 <tag/Availability/ISO 9899
2134 <ref id="isalnum" name="isalnum">,
2135 <ref id="isascii" name="isascii">,
2136 <ref id="isblank" name="isblank">,
2137 <ref id="iscntrl" name="iscntrl">,
2138 <ref id="isdigit" name="isdigit">,
2139 <ref id="isgraph" name="isgraph">,
2140 <ref id="islower" name="islower">,
2141 <ref id="isprint" name="isprint">,
2142 <ref id="ispunct" name="ispunct">,
2143 <ref id="isspace" name="isspace">,
2144 <ref id="isupper" name="isupper">,
2145 <ref id="isxdigit" name="isxdigit">
2151 <sect1>isascii<label id="isascii"><p>
2155 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2156 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2157 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2158 <tag/Description/The function returns a value of zero if the given argument
2159 is in the range 0..127 (the range of valid ASCII characters) and a non zero
2161 <tag/Limits/<itemize>
2162 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2163 inline sequence generated by the macro will not work correctly for values
2164 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2165 this range. The non inline function may be accessed by <tt/#undef/'ing the
2167 <item>When compiling without <tt/-Os/, the function is only available as
2168 fastcall function, so it may only be used in presence of a prototype.
2170 <tag/Availability/ISO 9899
2172 <ref id="isalnum" name="isalnum">,
2173 <ref id="isalpha" name="isalpha">,
2174 <ref id="isblank" name="isblank">,
2175 <ref id="iscntrl" name="iscntrl">,
2176 <ref id="isdigit" name="isdigit">,
2177 <ref id="isgraph" name="isgraph">,
2178 <ref id="islower" name="islower">,
2179 <ref id="isprint" name="isprint">,
2180 <ref id="ispunct" name="ispunct">,
2181 <ref id="isspace" name="isspace">,
2182 <ref id="isupper" name="isupper">,
2183 <ref id="isxdigit" name="isxdigit">
2189 <sect1>isblank<label id="isblank"><p>
2193 <tag/Function/Check if a given character is a space or tab.
2194 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2195 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2196 <tag/Description/The function returns a value of zero if the given argument
2197 is a space or tab character. The return value is non zero if the character
2199 <tag/Limits/<itemize>
2200 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2201 inline sequence generated by the macro will not work correctly for values
2202 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2203 this range. The non inline function may be accessed by <tt/#undef/'ing the
2205 <item>When compiling without <tt/-Os/, the function is only available as
2206 fastcall function, so it may only be used in presence of a prototype.
2208 <tag/Availability/cc65
2210 <ref id="isalnum" name="isalnum">,
2211 <ref id="isalpha" name="isalpha">,
2212 <ref id="isascii" name="isascii">,
2213 <ref id="iscntrl" name="iscntrl">,
2214 <ref id="isdigit" name="isdigit">,
2215 <ref id="isgraph" name="isgraph">,
2216 <ref id="islower" name="islower">,
2217 <ref id="isprint" name="isprint">,
2218 <ref id="ispunct" name="ispunct">,
2219 <ref id="isspace" name="isspace">,
2220 <ref id="isupper" name="isupper">,
2221 <ref id="isxdigit" name="isxdigit">
2227 <sect1>iscntrl<label id="iscntrl"><p>
2231 <tag/Function/Check if a given character is a control character.
2232 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2233 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2234 <tag/Description/The function returns a value of zero if the given argument
2235 is a control character. The return value is non zero if the character
2237 <tag/Limits/<itemize>
2238 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2239 inline sequence generated by the macro will not work correctly for values
2240 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2241 this range. The non inline function may be accessed by <tt/#undef/'ing the
2243 <item>When compiling without <tt/-Os/, the function is only available as
2244 fastcall function, so it may only be used in presence of a prototype.
2246 <tag/Availability/ISO 9899
2248 <ref id="isalnum" name="isalnum">,
2249 <ref id="isalpha" name="isalpha">,
2250 <ref id="isascii" name="isascii">,
2251 <ref id="isblank" name="isblank">,
2252 <ref id="isdigit" name="isdigit">,
2253 <ref id="isgraph" name="isgraph">,
2254 <ref id="islower" name="islower">,
2255 <ref id="isprint" name="isprint">,
2256 <ref id="ispunct" name="ispunct">,
2257 <ref id="isspace" name="isspace">,
2258 <ref id="isupper" name="isupper">,
2259 <ref id="isxdigit" name="isxdigit">
2265 <sect1>isdigit<label id="isdigit"><p>
2269 <tag/Function/Check if a given character is a digit.
2270 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2271 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2272 <tag/Description/The function returns a value of zero if the given argument
2273 is a digit. The return value is non zero if the character is anything else.
2274 <tag/Limits/<itemize>
2275 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2276 inline sequence generated by the macro will not work correctly for values
2277 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2278 this range. The non inline function may be accessed by <tt/#undef/'ing the
2280 <item>When compiling without <tt/-Os/, the function is only available as
2281 fastcall function, so it may only be used in presence of a prototype.
2283 <tag/Availability/ISO 9899
2285 <ref id="isalnum" name="isalnum">,
2286 <ref id="isalpha" name="isalpha">,
2287 <ref id="isascii" name="isascii">,
2288 <ref id="isblank" name="isblank">,
2289 <ref id="iscntrl" name="iscntrl">,
2290 <ref id="isgraph" name="isgraph">,
2291 <ref id="islower" name="islower">,
2292 <ref id="isprint" name="isprint">,
2293 <ref id="ispunct" name="ispunct">,
2294 <ref id="isspace" name="isspace">,
2295 <ref id="isupper" name="isupper">,
2296 <ref id="isxdigit" name="isxdigit">
2302 <sect1>isgraph<label id="isgraph"><p>
2306 <tag/Function/Check if a given character is a printable character (except
2308 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2309 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2310 <tag/Description/The function returns a value of zero if the given argument
2311 is a printable character with the exception of space. The return value is non
2312 zero if the character is anything else.
2313 <tag/Limits/<itemize>
2314 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2315 inline sequence generated by the macro will not work correctly for values
2316 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2317 this range. The non inline function may be accessed by <tt/#undef/'ing the
2319 <item>When compiling without <tt/-Os/, the function is only available as
2320 fastcall function, so it may only be used in presence of a prototype.
2322 <tag/Availability/ISO 9899
2324 <ref id="isalnum" name="isalnum">,
2325 <ref id="isalpha" name="isalpha">,
2326 <ref id="isascii" name="isascii">,
2327 <ref id="isblank" name="isblank">,
2328 <ref id="iscntrl" name="iscntrl">,
2329 <ref id="isdigit" name="isdigit">,
2330 <ref id="islower" name="islower">,
2331 <ref id="isprint" name="isprint">,
2332 <ref id="ispunct" name="ispunct">,
2333 <ref id="isspace" name="isspace">,
2334 <ref id="isupper" name="isupper">,
2335 <ref id="isxdigit" name="isxdigit">
2341 <sect1>islower<label id="islower"><p>
2345 <tag/Function/Check if a given character is a lower case letter.
2346 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2347 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2348 <tag/Description/The function returns a value of zero if the given argument
2349 is a lower case letter. The return value is non zero if the character is
2351 <tag/Limits/<itemize>
2352 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2353 inline sequence generated by the macro will not work correctly for values
2354 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2355 this range. The non inline function may be accessed by <tt/#undef/'ing the
2357 <item>When compiling without <tt/-Os/, the function is only available as
2358 fastcall function, so it may only be used in presence of a prototype.
2360 <tag/Availability/ISO 9899
2362 <ref id="isalnum" name="isalnum">,
2363 <ref id="isalpha" name="isalpha">,
2364 <ref id="isascii" name="isascii">,
2365 <ref id="isblank" name="isblank">,
2366 <ref id="iscntrl" name="iscntrl">,
2367 <ref id="isdigit" name="isdigit">,
2368 <ref id="isgraph" name="isgraph">,
2369 <ref id="isprint" name="isprint">,
2370 <ref id="ispunct" name="ispunct">,
2371 <ref id="isspace" name="isspace">,
2372 <ref id="isupper" name="isupper">,
2373 <ref id="isxdigit" name="isxdigit">
2379 <sect1>isprint<label id="isprint"><p>
2383 <tag/Function/Check if a given character is a printable character.
2384 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2385 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2386 <tag/Description/The function returns a value of zero if the given argument
2387 is a printable character (this includes the space character). The return value
2388 is non zero if the character is anything else.
2389 <tag/Limits/<itemize>
2390 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2391 inline sequence generated by the macro will not work correctly for values
2392 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2393 this range. The non inline function may be accessed by <tt/#undef/'ing the
2395 <item>When compiling without <tt/-Os/, the function is only available as
2396 fastcall function, so it may only be used in presence of a prototype.
2398 <tag/Availability/ISO 9899
2400 <ref id="isalnum" name="isalnum">,
2401 <ref id="isalpha" name="isalpha">,
2402 <ref id="isascii" name="isascii">,
2403 <ref id="isblank" name="isblank">,
2404 <ref id="iscntrl" name="iscntrl">,
2405 <ref id="isdigit" name="isdigit">,
2406 <ref id="isgraph" name="isgraph">,
2407 <ref id="islower" name="islower">,
2408 <ref id="ispunct" name="ispunct">,
2409 <ref id="isspace" name="isspace">,
2410 <ref id="isupper" name="isupper">,
2411 <ref id="isxdigit" name="isxdigit">
2417 <sect1>ispunct<label id="ispunct"><p>
2421 <tag/Function/Check if a given character is a printable character but not a
2422 space or an alphanumeric character.
2423 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2424 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2425 <tag/Description/The function returns a value of zero if the given argument
2426 is a printable character, but not a space or anything alphanumeric. The return
2427 value is non zero if the character is anything else.
2428 <tag/Limits/<itemize>
2429 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2430 inline sequence generated by the macro will not work correctly for values
2431 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2432 this range. The non inline function may be accessed by <tt/#undef/'ing the
2434 <item>When compiling without <tt/-Os/, the function is only available as
2435 fastcall function, so it may only be used in presence of a prototype.
2437 <tag/Availability/ISO 9899
2439 <ref id="isalnum" name="isalnum">,
2440 <ref id="isalpha" name="isalpha">,
2441 <ref id="isascii" name="isascii">,
2442 <ref id="isblank" name="isblank">,
2443 <ref id="iscntrl" name="iscntrl">,
2444 <ref id="isdigit" name="isdigit">,
2445 <ref id="isgraph" name="isgraph">,
2446 <ref id="islower" name="islower">,
2447 <ref id="isprint" name="isprint">,
2448 <ref id="isspace" name="isspace">,
2449 <ref id="isupper" name="isupper">,
2450 <ref id="isxdigit" name="isxdigit">
2456 <sect1>isspace<label id="isspace"><p>
2460 <tag/Function/Check if a given character is a a white-space character.
2461 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2462 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2463 <tag/Description/The function returns a value of zero if the given argument
2464 is a white space character. The return value is non zero if the character is
2465 anything else. The standard white space characters are: space, formfeed ('\f'),
2466 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2468 <tag/Limits/<itemize>
2469 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2470 inline sequence generated by the macro will not work correctly for values
2471 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2472 this range. The non inline function may be accessed by <tt/#undef/'ing the
2474 <item>When compiling without <tt/-Os/, the function is only available as
2475 fastcall function, so it may only be used in presence of a prototype.
2477 <tag/Availability/ISO 9899
2479 <ref id="isalnum" name="isalnum">,
2480 <ref id="isalpha" name="isalpha">,
2481 <ref id="isascii" name="isascii">,
2482 <ref id="isblank" name="isblank">,
2483 <ref id="iscntrl" name="iscntrl">,
2484 <ref id="isdigit" name="isdigit">,
2485 <ref id="isgraph" name="isgraph">,
2486 <ref id="islower" name="islower">,
2487 <ref id="isprint" name="isprint">,
2488 <ref id="ispunct" name="ispunct">,
2489 <ref id="isupper" name="isupper">,
2490 <ref id="isxdigit" name="isxdigit">
2496 <sect1>isupper<label id="isupper"><p>
2500 <tag/Function/Check if a given character is an upper case letter.
2501 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2502 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2503 <tag/Description/The function returns a value of zero if the given argument
2504 is an upper case letter. The return value is non zero if the character is
2506 <tag/Limits/<itemize>
2507 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2508 inline sequence generated by the macro will not work correctly for values
2509 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2510 this range. The non inline function may be accessed by <tt/#undef/'ing the
2512 <item>When compiling without <tt/-Os/, the function is only available as
2513 fastcall function, so it may only be used in presence of a prototype.
2515 <tag/Availability/ISO 9899
2517 <ref id="isalnum" name="isalnum">,
2518 <ref id="isalpha" name="isalpha">,
2519 <ref id="isascii" name="isascii">,
2520 <ref id="isblank" name="isblank">,
2521 <ref id="iscntrl" name="iscntrl">,
2522 <ref id="isdigit" name="isdigit">,
2523 <ref id="isgraph" name="isgraph">,
2524 <ref id="islower" name="islower">,
2525 <ref id="isprint" name="isprint">,
2526 <ref id="ispunct" name="ispunct">,
2527 <ref id="isspace" name="isspace">,
2528 <ref id="isxdigit" name="isxdigit">
2534 <sect1>isxdigit<label id="isxdigit"><p>
2538 <tag/Function/Check if a given character is a hexadecimal digit.
2539 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2540 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
2541 <tag/Description/The function returns a value of zero if the given argument
2542 is a hexadecimal digit (0..9, a..f and A..F). The return value is non zero
2543 if the character is anything else.
2544 <tag/Limits/<itemize>
2545 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2546 inline sequence generated by the macro will not work correctly for values
2547 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2548 this range. The non inline function may be accessed by <tt/#undef/'ing the
2550 <item>When compiling without <tt/-Os/, the function is only available as
2551 fastcall function, so it may only be used in presence of a prototype.
2553 <tag/Availability/ISO 9899
2555 <ref id="isalnum" name="isalnum">,
2556 <ref id="isalpha" name="isalpha">,
2557 <ref id="isascii" name="isascii">,
2558 <ref id="isblank" name="isblank">,
2559 <ref id="iscntrl" name="iscntrl">,
2560 <ref id="isdigit" name="isdigit">,
2561 <ref id="isgraph" name="isgraph">,
2562 <ref id="islower" name="islower">,
2563 <ref id="isprint" name="isprint">,
2564 <ref id="ispunct" name="ispunct">,
2565 <ref id="isspace" name="isspace">,
2566 <ref id="isupper" name="isupper">
2572 <sect1>itoa<label id="itoa"><p>
2576 <tag/Function/Convert an integer into a string.
2577 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2578 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
2579 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
2580 <tt/radix/ as the base.
2581 <tag/Limits/<itemize>
2582 <item>There are no provisions to prevent a buffer overflow.
2583 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
2584 <item>The function is non standard, so it is not available in strict ANSI mode.
2585 You should probably use <tt/sprintf/ instead.
2586 <item>The function is only available as fastcall function, so it may only be
2587 used in presence of a prototype.
2589 <tag/Availability/cc65
2591 <ref id="atoi" name="atoi">,
2592 <ref id="atol" name="atol">,
2593 <ref id="ltoa" name="ltoa">,
2594 <ref id="ultoa" name="ultoa">,
2595 <ref id="utoa" name="utoa">
2601 <sect1>kbhit<label id="kbhit"><p>
2605 <tag/Function/Check if there's a key waiting in the keyboard buffer.
2606 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2607 <tag/Declaration/<tt/unsigned char kbhit (void);/
2608 <tag/Description/The function returns a value of zero if there is no character
2609 waiting to be read from the keyboard. It returns non zero otherwise.
2610 <tag/Limits/<itemize>
2611 <item>If the system does not support a keyboard buffer (most systems
2612 do), the function is rather useless.
2614 <tag/Availability/cc65
2616 <ref id="cgetc" name="cgetc">,
2617 <ref id="cursor" name="cursor">
2623 <sect1>labs<label id="labs"><p>
2627 <tag/Function/Returns the absolute value of a long integer.
2628 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2629 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
2630 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
2632 <tag/Limits/<itemize>
2633 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
2634 <item>The function is only available as fastcall function, so it may only be
2635 used in presence of a prototype.
2637 <tag/Availability/ISO 9899
2639 <ref id="abs" name="abs">
2645 <sect1>ltoa<label id="ltoa"><p>
2649 <tag/Function/Convert a long integer into a string.
2650 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2651 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
2652 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
2653 using <tt/radix/ as the base.
2654 <tag/Limits/<itemize>
2655 <item>There are no provisions to prevent a buffer overflow.
2656 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
2657 <item>The function is non standard, so it is not available in strict ANSI mode.
2658 You should probably use <tt/sprintf/ instead.
2659 <item>The function is only available as fastcall function, so it may only be
2660 used in presence of a prototype.
2662 <tag/Availability/cc65
2664 <ref id="atoi" name="atoi">,
2665 <ref id="atol" name="atol">,
2666 <ref id="itoa" name="itoa">,
2667 <ref id="ultoa" name="ultoa">,
2668 <ref id="utoa" name="utoa">
2674 <sect1>localeconv<label id="localeconv"><p>
2678 <tag/Function/Returns a pointer to the current locale structure.
2679 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
2680 <tag/Declaration/<tt/struct lconv* localeconv (void);/
2681 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
2683 <tag/Limits/<itemize>
2684 <item>cc65 supports only the "C" locale, so even after setting a new locale
2685 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
2688 <tag/Availability/ISO 9899
2690 <ref id="setlocale" name="setlocale">
2696 <sect1>malloc<label id="malloc"><p>
2700 <tag/Function/Allocate dynamic memory.
2701 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2702 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
2703 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
2704 pointer to the allocated memory block. On error (not enough memory available),
2705 <tt/malloc/ returns <tt/NULL/.
2708 <item>The function is only available as fastcall function, so it may only
2709 be used in presence of a prototype.
2711 <tag/Availability/ISO 9899
2713 <ref id="_heapadd" name="_heapadd">,
2714 <ref id="_heapblocksize" name="_heapblocksize">,
2715 <ref id="_heapmaxavail" name="_heapmaxavail">,
2716 <ref id="_heapmemavail" name="_heapmemavail">,
2717 <ref id="calloc" name="calloc">,
2718 <ref id="free" name="free">,
2719 <ref id="realloc" name="realloc">,
2720 <ref id="strdup" name="strdup">
2726 <sect1>memchr<label id="memchr"><p>
2730 <tag/Function/Search for a character in a block of raw memory.
2731 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2732 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
2733 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
2734 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
2735 that is of size <tt/count/. Upon completion, the function returns a pointer to
2736 the character found, or a null pointer if the character was not found.
2737 <tag/Limits/<itemize>
2738 <item>The function is only available as fastcall function, so it may only
2739 be used in presence of a prototype.
2741 <tag/Availability/ISO 9899
2743 <ref id="strchr" name="strchr">
2749 <sect1>memcpy<label id="memcpy"><p>
2753 <tag/Function/Copy a memory area.
2754 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2755 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
2756 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
2757 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
2761 <item>The result is undefined if the memory areas do overlap. Use
2762 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
2763 <item>The function is only available as fastcall function, so it may only
2764 be used in presence of a prototype.
2766 <tag/Availability/ISO 9899
2768 <ref id="_swap" name="_swap">,
2769 <ref id="memmove" name="memmove">,
2770 <ref id="memset" name="memset">
2776 <sect1>memmove<label id="memmove"><p>
2780 <tag/Function/Copy a memory area.
2781 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2782 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
2783 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
2784 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
2788 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
2789 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
2790 <item>The function is only available as fastcall function, so it may only
2791 be used in presence of a prototype.
2793 <tag/Availability/ISO 9899
2795 <ref id="_swap" name="_swap">,
2796 <ref id="memcpy" name="memcpy">,
2797 <ref id="memset" name="memset">
2803 <sect1>memset<label id="memset"><p>
2807 <tag/Function/Fill a memory area.
2808 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2809 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
2810 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
2811 the value <tt/val/. The function returns <tt/p/.
2814 <item>The function is only available as fastcall function, so it may only
2815 be used in presence of a prototype.
2817 <tag/Availability/ISO 9899
2819 <ref id="_swap" name="_swap">,
2820 <ref id="bzero" name="bzero">,
2821 <ref id="memcpy" name="memcpy">,
2822 <ref id="memmove" name="memmove">
2828 <sect1>mod_free<label id="mod_free"><p>
2832 <tag/Function/Free a relocatable module.
2833 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
2834 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
2835 <tag/Description/The function will free a module loaded into memory by use of
2836 the <tt/<ref id="mod_load" name="mod_load">/ function.
2837 <tag/Limits/<itemize>
2838 <item>The pointer passed as parameter is the pointer to the module memory,
2839 not the pointer to the control structure.
2841 <tag/Availability/cc65
2843 <ref id="mod_load" name="mod_load">
2849 <sect1>mod_load<label id="mod_load"><p>
2853 <tag/Function/Load a relocatable module.
2854 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
2855 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
2856 <tag/Description/The function will load a code module into memory and relocate
2857 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
2858 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
2859 the module just loaded. Possible error codes are:
2861 <item><tt/MLOAD_OK/ - Module load successful
2862 <item><tt/MLOAD_ERR_READ/ - Read error
2863 <item><tt/MLOAD_ERR_HDR/ - Header error
2864 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
2865 <item><tt/MLOAD_ERR_FMT/ - Data format error
2866 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
2868 <tag/Limits/<itemize>
2869 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
2870 relocatable o65 modules for use with this function.
2872 <tag/Availability/cc65
2874 <ref id="mod_free" name="mod_free">
2880 <sect1>offsetof<label id="offsetof"><p>
2884 <tag/Function/Calculate the offset of a struct or union member.
2885 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
2886 <tag/Declaration/<tt/size_t offsetof (type, member);/
2887 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
2888 or <tt/union/ member.
2889 <tag/Limits/<itemize>
2890 <item>The function is actually a macro.
2892 <tag/Availability/ISO 9899
2898 <sect1>open<label id="open"><p>
2902 <tag/Function/Open and possibly create a file.
2903 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
2904 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
2905 <tag/Description/<tt/open/ opens a file and returns the file descriptor
2906 associated with it. On error, -1 is returned and an error code is stored in
2907 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
2908 <tag/Limits/<itemize>
2909 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
2910 open, which is used as the permission mask when a new file is created. While
2911 cc65 allows to pass this argument, it is ignored.
2913 <tag/Availability/POSIX 1003.1
2915 <ref id="close" name="close">,
2916 <ref id="creat" name="creat">
2922 <sect1>perror<label id="perror"><p>
2926 <tag/Function/Print an error message for the error in <tt/errno/.
2927 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
2928 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
2929 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
2930 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
2931 a blank. Then the error message for the current contents of <tt/errno/ is
2932 printed followed by a newline. The message output is the same as returned by
2933 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
2936 <item>The function is only available as fastcall function, so it may only
2937 be used in presence of a prototype.
2939 <tag/Availability/ISO 9899
2941 <ref id="_poserror" name="_poserror">,
2942 <ref id="strerror" name="strerror">,
2948 <sect1>qsort<label id="qsort"><p>
2952 <tag/Function/Sort an array.
2953 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2954 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
2955 size_t size, int (*compare) (const void*, const void*));/
2956 <tag/Description/<tt/qsort/ sorts an array according to a given compare
2957 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
2958 is the number of elements, <tt/size/ the size of an element and <tt/compare/
2959 the function used to compare the members.
2962 <item>If there are multiple members with the same key, the order after calling
2963 the function is undefined.
2964 <item>The function is only available as fastcall function, so it may only
2965 be used in presence of a prototype.
2967 <tag/Availability/ISO 9899
2969 <ref id="bsearch" name="bsearch">
2975 <sect1>raise<label id="raise"><p>
2979 <tag/Function/Send a signal to the executing program.
2980 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
2981 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
2982 <tag/Description/<tt/raise/ sends the given signal to the program. If the
2983 program has installed a signal handler for the signal, this signal handler
2984 will be executed. If no handler has been installed, the default action for
2985 the raised signal will be taken. The function returns zero on success,
2987 <tag/Limits/<itemize>
2988 <item>The function is only available as fastcall function, so it may only
2989 be used in presence of a prototype.
2991 <tag/Availability/ISO 9899
2993 <ref id="abort" name="abort">,
2994 <ref id="signal" name="signal">
3000 <sect1>rand<label id="rand"><p>
3004 <tag/Function/Return a pseudo random number.
3005 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3006 <tag/Declaration/<tt/int rand (void);/
3007 <tag/Description/The function returns a pseudo random number
3008 between 0 and <tt/RAND_MAX/ (exclusive).
3009 <tag/Limits/<itemize>
3010 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
3011 flow of numbers is generated.
3012 <item>On startup, the function behaves as if <ref id="srand" name="srand">
3013 had been used with an argument of 1.
3015 <tag/Availability/ISO 9899
3017 <ref id="_randomize" name="_randomize">,
3018 <ref id="srand" name="srand">
3024 <sect1>realloc<label id="realloc"><p>
3028 <tag/Function/Change the size of an allocated memory block.
3029 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3030 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
3031 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
3032 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
3033 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
3034 behaves as if <tt/free/ had been called. On error (not enough memory
3035 available), <tt/realloc/ returns <tt/NULL/.
3038 <item>The part of the memory block that is returned will have its contents
3040 <item>This function is somewhat dangerous to use. Be careful to save the
3041 pointer you're passing somewhere else, otherwise
3043 ptr = realloc (ptr, size);
3045 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
3046 <item>The function is only available as fastcall function, so it may only
3047 be used in presence of a prototype.
3049 <tag/Availability/ISO 9899
3051 <ref id="_heapadd" name="_heapadd">,
3052 <ref id="_heapblocksize" name="_heapblocksize">,
3053 <ref id="_heapmaxavail" name="_heapmaxavail">,
3054 <ref id="_heapmemavail" name="_heapmemavail">,
3055 <ref id="calloc" name="calloc">,
3056 <ref id="free" name="free">,
3057 <ref id="realloc" name="realloc">
3063 <sect1>remove<label id="remove"><p>
3067 <tag/Function/Delete a file.
3068 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3069 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
3070 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
3071 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
3072 code describing the reason for the failure.
3075 <item>This function is not available on all cc65 targets (depends on the
3076 availability of file I/O).
3077 <item>The function is only available as fastcall function, so it may only
3078 be used in presence of a prototype.
3080 <tag/Availability/ISO 9899
3082 <ref id="unlink" name="unlink">
3084 #include <stdio.h>
3086 #define FILENAME "helloworld"
3088 if (remove (FILENAME) == 0) {
3089 printf ("We deleted %s successfully\n", FILENAME);
3091 printf ("There was a problem deleting %s\n", FILENAME);
3097 <sect1>reset_brk<label id="reset_brk"><p>
3101 <tag/Function/Resets the break vector to its original value.
3102 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3103 <tag/Declaration/<tt/void __fastcall__ reset_brk (void);/
3104 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
3105 before a call to <tt/set_brk/.
3108 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
3109 it is not strictly necessary to call this function as part of the cleanup when
3112 <tag/Availability/cc65
3114 <ref id="set_brk" name="set_brk">
3120 <sect1>revers<label id="revers"><p>
3124 <tag/Function/Control revers character display.
3125 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3126 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
3127 <tag/Description/If the argument is non zero, the function enables reverse
3128 character display. If the argument is zero, reverse character display is
3129 switched off. The old value of the setting is returned.
3130 <tag/Limits/<itemize>
3131 <item>The function may not be supported by the hardware, in which case
3132 the call is ignored.
3133 <item>The function is only available as fastcall function, so it may only
3134 be used in presence of a prototype.
3136 <tag/Availability/cc65
3138 <ref id="textcolor" name="textcolor">
3144 <sect1>screensize<label id="screensize"><p>
3148 <tag/Function/Return the dimensions of the text mode screen.
3149 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3150 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
3151 <tag/Description/The function returns the dimensions of the text mode screen.
3152 <tag/Limits/<itemize>
3153 <item>The function is only available as fastcall function, so it may only
3154 be used in presence of a prototype.
3156 <tag/Availability/cc65
3158 <ref id="gotox" name="gotox">,
3159 <ref id="gotoxy" name="gotoxy">,
3160 <ref id="gotoy" name="gotoy">,
3161 <ref id="wherex" name="wherex">,
3162 <ref id="wherey" name="wherey">
3168 <sect1>set_brk<label id="set_brk"><p>
3172 <tag/Function/Set the break vector to a user function.
3173 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3174 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
3175 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
3176 program code by letting the vector point to a user written C function. The
3177 runtime library installs a small stub that saves the registers into global
3178 variables that may be accessed (and changed) by the break handler.
3181 <item>The function is only available as fastcall function, so it may only
3182 be used in presence of a prototype.
3183 <item>The stub saves the zero page registers used by the C runtime and switches
3184 to a small break handler stack. This means that it is safe to execute C code,
3185 even if C code was interrupted. Be careful however not to use too many local
3186 variables, and do not enable stack checks for the handler function or any other
3187 function called from it.
3188 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
3189 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
3190 otherwise the <tt/BRK/ instruction will get executed over and over again.
3191 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
3192 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
3193 the program terminates.
3195 <tag/Availability/cc65
3197 <ref id="reset_brk" name="reset_brk">
3203 <sect1>setlocale<label id="setlocale"><p>
3207 <tag/Function/Selects a locale.
3208 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3209 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
3210 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
3213 <item>The function is only available as fastcall function, so it may only
3214 be used in presence of a prototype.
3215 <item>cc65 supports only the "C" locale, so calling this function to set a
3216 different locale has no effect.
3218 <tag/Availability/ISO 9899
3220 <ref id="localeconv" name="localeconv">,
3221 <ref id="strcoll" name="strcoll">
3227 <sect1>signal<label id="signal"><p>
3231 <tag/Function/Install a signal handler.
3232 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
3233 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
3234 <tag/Description/<tt/signal/ installs a handler for the given signal. The
3235 handler may either be a user supplied function, or one of the predefined
3236 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
3237 previous value if the signal , or the special function vector SIG_ERR in
3239 <tag/Limits/<itemize>
3240 <item>The function is only available as fastcall function, so it may only
3241 be used in presence of a prototype.
3243 <tag/Availability/ISO 9899
3245 <ref id="abort" name="abort">,
3246 <ref id="raise" name="raise">
3252 <sect1>sleep<label id="sleep"><p>
3256 <tag/Function/Sleep for a specified amount of time.
3257 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3258 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
3259 <tag/Description/The function will return after the specified number of
3260 seconds have elapsed.
3261 <tag/Limits/<itemize>
3262 <item>The function is only available as fastcall function, so it may only
3263 be used in presence of a prototype.
3265 <tag/Availability/POSIX 1003.1
3271 <sect1>slow<label id="slow"><p>
3275 <tag/Function/Switch the C128 into 1MHz mode.
3276 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
3277 <tag/Declaration/<tt/void slow (void);/
3278 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
3279 will halve the speed compared to fast mode.
3280 <tag/Limits/<itemize>
3281 <item>The function is specific to the C128.
3283 <tag/Availability/C128
3285 <ref id="fast" name="fast">,
3286 <ref id="toggle_videomode" name="toggle_videomode">
3292 <sect1>srand<label id="srand"><p>
3296 <tag/Function/Initialize the pseudo random number generator.
3297 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3298 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
3299 <tag/Description/The function initializes the random number generator using
3300 the given seed. On program startup, the generator behaves as if <tt/srand/ has
3301 been called with an argument of 1.
3302 <tag/Limits/<itemize>
3303 <item>The function is only available as fastcall function, so it may only
3304 be used in presence of a prototype.
3306 <tag/Availability/ISO 9899
3308 <ref id="_randomize" name="_randomize">,
3309 <ref id="rand" name="rand">
3315 <sect1>strcasecmp<label id="strcasecmp"><p>
3319 <tag/Function/Compare two strings case insensitive.
3320 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3321 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
3322 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
3323 as parameters without case sensitivity. It returns a value that is less than
3324 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
3325 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
3326 <tag/Limits/<itemize>
3327 <item>The function is only available as fastcall function, so it may only
3328 be used in presence of a prototype.
3329 <item>The function is not available in strict ANSI mode.
3331 <tag/Availability/cc65
3333 <ref id="strcmp" name="strcmp">,
3334 <ref id="strcoll" name="strcoll">,
3335 <ref id="stricmp" name="stricmp">,
3336 <ref id="strncmp" name="strncmp">
3342 <sect1>strcat<label id="strcat"><p>
3346 <tag/Function/Concatentate two strings.
3347 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3348 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
3349 <tag/Description/The <tt/strcat/ function appends a copy of the string
3350 pointed to by s2 (including the terminating null byte) to the end of the
3351 string pointed to by s1. The initial byte of s2 overwrites the null byte at
3353 <tag/Limits/<itemize>
3354 <item>The function is only available as fastcall function, so it may only
3355 be used in presence of a prototype.
3356 <item>If copying takes place between objects that overlap, the behavior
3359 <tag/Availability/ISO 9899
3361 <ref id="strcpy" name="strcpy">,
3362 <ref id="strncat" name="strncat">,
3363 <ref id="strncpy" name="strncpy">
3369 <sect1>strchr<label id="strchr"><p>
3373 <tag/Function/Search for a character in a string.
3374 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3375 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
3376 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
3377 (converted to a char) in the string pointed to by <tt/s/. The terminating null
3378 byte is considered to be part of the string. Upon completion, the function
3379 returns a pointer to the byte, or a null pointer if the byte was not found.
3380 <tag/Limits/<itemize>
3381 <item>The function is only available as fastcall function, so it may only
3382 be used in presence of a prototype.
3384 <tag/Availability/ISO 9899
3386 <ref id="memchr" name="memchr">,
3387 <ref id="strrchr" name="strrchr">
3393 <sect1>strcmp<label id="strcmp"><p>
3397 <tag/Function/Compare two strings.
3398 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3399 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
3400 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
3401 parameters. It returns a value that is less than zero if <tt/s1/ is less than
3402 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
3403 if <tt/s1/ is greater than <tt/s2/.
3404 <tag/Limits/<itemize>
3405 <item>The function is only available as fastcall function, so it may only
3406 be used in presence of a prototype.
3408 <tag/Availability/ISO 9899
3410 <ref id="strcasecmp" name="strcasecmp">,
3411 <ref id="strcoll" name="strcoll">,
3412 <ref id="stricmp" name="stricmp">,
3413 <ref id="strncmp" name="strncmp">
3419 <sect1>strcoll<label id="strcoll"><p>
3423 <tag/Function/Compare two strings.
3424 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3425 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
3426 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
3427 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
3428 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
3429 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
3430 than zero if <tt/s1/ is greater than <tt/s2/.
3431 <tag/Limits/<itemize>
3432 <item>The function is only available as fastcall function, so it may only
3433 be used in presence of a prototype.
3435 <tag/Availability/ISO 9899
3437 <ref id="setlocale" name="setlocale">,
3438 <ref id="strcasecmp" name="strcasecmp">,
3439 <ref id="strcmp" name="strcmp">,
3440 <ref id="stricmp" name="stricmp">,
3441 <ref id="strncmp" name="strncmp">
3447 <sect1>strcpy<label id="strcpy"><p>
3451 <tag/Function/Copy a string.
3452 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3453 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
3454 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
3455 <tt/s2/ (including the terminating null byte) into the array pointed to by
3456 <tt/s1/. The function will always return <tt/s1/.
3457 <tag/Limits/<itemize>
3458 <item>The function is only available as fastcall function, so it may only
3459 be used in presence of a prototype.
3460 <item>If copying takes place between objects that overlap, the behavior
3463 <tag/Availability/ISO 9899
3465 <ref id="strcat" name="strcat">,
3466 <ref id="strncat" name="strncat">,
3467 <ref id="strncpy" name="strncpy">
3470 #include <string.h>
3472 static char hello[14];
3474 strcpy (hello, "Hello world!\n");
3480 <sect1>strcspn<label id="strcspn"><p>
3484 <tag/Function/Compute the length of a substring.
3485 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3486 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
3487 <tag/Description/The <tt/strcspn/ function computes and returns the length of
3488 the substring pointed to by <tt/s/ which does <em>not</em> consist of
3489 characters contained in the string <tt/set/.
3490 <tag/Limits/<itemize>
3491 <item>The function is only available as fastcall function, so it may only
3492 be used in presence of a prototype.
3494 <tag/Availability/ISO 9899
3496 <ref id="strspn" name="strspn">,
3497 <ref id="strstr" name="strstr">
3503 <sect1>strdup<label id="strdup"><p>
3507 <tag/Function/Allocate a copy of a string on the heap.
3508 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3509 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
3510 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
3511 to hold a copy of <tt/s/ including the terminating zero. If the allocation
3512 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
3513 memory block, and a pointer to the block is returned.
3514 <tag/Limits/<itemize>
3515 <item>The function is only available as fastcall function, so it may only
3516 be used in presence of a prototype.
3517 <item>It is up to the caller to free the allocated memory block.
3519 <tag/Availability/ISO 9899
3521 <ref id="free" name="free">,
3522 <ref id="malloc" name="malloc">
3528 <sect1>strerror<label id="strerror"><p>
3532 <tag/Function/Return a string describing an error code.
3533 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3534 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
3535 <tag/Description/The <tt/strerror/ function returns a string describing the
3536 given error code. If an invalid error code is passed, the string "Unknown
3537 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
3538 <tt/errno/ is left untouched.
3539 <tag/Limits/<itemize>
3540 <item>The function is only available as fastcall function, so it may only
3541 be used in presence of a prototype.
3542 <item>While the return type of the function is a <tt/char*/, the returned
3543 string must not be modified by the caller!
3545 <tag/Availability/ISO 9899
3547 <ref id="_stroserror" name="_stroserror">
3553 <sect1>stricmp<label id="stricmp"><p>
3557 <tag/Function/Compare two strings case insensitive.
3558 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3559 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
3560 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
3561 parameters without case sensitivity. It returns a value that is less than zero
3562 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
3563 value greater than zero if <tt/s1/ is greater than <tt/s2/.
3564 <tag/Limits/<itemize>
3565 <item>The function is only available as fastcall function, so it may only
3566 be used in presence of a prototype.
3567 <item>The function is not available in strict ANSI mode.
3569 <tag/Availability/cc65
3571 <ref id="strcasecmp" name="strcasecmp">,
3572 <ref id="strcmp" name="strcmp">,
3573 <ref id="strcoll" name="strcoll">,
3574 <ref id="strncmp" name="strncmp">
3580 <sect1>strlen<label id="strlen"><p>
3584 <tag/Function/Return the length of a string.
3585 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3586 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
3587 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
3588 string to which s points, not including the terminating null byte.
3589 <tag/Limits/<itemize>
3590 <item>The function is only available as fastcall function, so it may only
3591 be used in presence of a prototype.
3592 <item>When compiling with <tt/-Os/ (inline known standard functions), the
3593 function does not work correctly for strings with more than 255 characters.
3595 <tag/Availability/ISO 9899
3597 <ref id="strcpy" name="strcpy">
3603 <sect1>strlower<label id="strlower"><p>
3607 <tag/Function/Make a string lower case.
3608 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3609 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
3610 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
3611 function to each character of a string. The function will always return <tt/s/.
3612 <tag/Limits/<itemize>
3613 <item>The function is only available as fastcall function, so it may only
3614 be used in presence of a prototype.
3615 <item>The function prototype is unavailable when compiling in strict ANSI mode.
3616 <item>An alias name for this function is <tt/strlwr/.
3618 <tag/Availability/cc65
3620 <ref id="strupper" name="strupper">,
3621 <ref id="tolower" name="tolower">
3627 <sect1>strlwr<label id="strlwr"><p>
3634 <sect1>strncat<label id="strncat"><p>
3638 <tag/Function/Concatentate two strings.
3639 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3640 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
3641 <tag/Description/The <tt/strncat/ function appends not more than n characters
3642 of the string pointed to by s2 to the end of the string pointed to by s1. The
3643 terminating null character at the end of s1 is overwritten. A terminating null
3644 character is appended to the result, even if not all of s2 is appended to s1.
3645 <tag/Limits/<itemize>
3646 <item>The function is only available as fastcall function, so it may only
3647 be used in presence of a prototype.
3648 <item>If copying takes place between objects that overlap, the behavior
3651 <tag/Availability/ISO 9899
3653 <ref id="strcpy" name="strcpy">,
3654 <ref id="strncat" name="strncat">,
3655 <ref id="strncpy" name="strncpy">
3661 <sect1>strncmp<label id="strncmp"><p>
3665 <tag/Function/Compare two strings.
3666 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3667 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
3668 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
3669 characters of the two strings passed as parameters. It returns a value that is
3670 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
3671 <tt/s2/, zero if they are identical, and a value greater than zero they are
3673 <tag/Limits/<itemize>
3674 <item>The function is only available as fastcall function, so it may only
3675 be used in presence of a prototype.
3677 <tag/Availability/ISO 9899
3679 <ref id="strcasecmp" name="strcasecmp">,
3680 <ref id="strcmp" name="strcmp">,
3681 <ref id="strcoll" name="strcoll">,
3682 <ref id="stricmp" name="stricmp">
3688 <sect1>strncpy<label id="strncpy"><p>
3692 <tag/Function/Copy part of a string.
3693 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3694 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
3695 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
3696 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
3697 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
3698 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
3699 written. The function will always return <tt/s1/.
3700 <tag/Limits/<itemize>
3701 <item>The function is only available as fastcall function, so it may only
3702 be used in presence of a prototype. If there is no null byte in the first <tt/n/
3703 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
3704 <item>If copying takes place between objects that overlap, the behavior is
3707 <tag/Availability/ISO 9899
3709 <ref id="strcat" name="strcat">,
3710 <ref id="strcpy" name="strcpy">,
3711 <ref id="strncat" name="strncat">
3716 static char hello[6];
3718 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
3725 <sect1>strrchr<label id="strrchr"><p>
3729 <tag/Function/Search for a character in a string.
3730 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3731 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
3732 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
3733 (converted to a char) in the string pointed to by <tt/s/. The terminating null
3734 byte is considered to be part of the string. Upon completion, the function
3735 returns a pointer to the byte, or a null pointer if the byte was not found.
3736 <tag/Limits/<itemize>
3737 <item>The function is only available as fastcall function, so it may only
3738 be used in presence of a prototype.
3740 <tag/Availability/ISO 9899
3742 <ref id="strchr" name="strchr">
3748 <sect1>strspn<label id="strspn"><p>
3752 <tag/Function/Compute the length of a substring.
3753 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3754 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
3755 <tag/Description/The <tt/strspn/ function computes and returns the length of
3756 the substring pointed to by <tt/s/ which does consist only of characters
3757 contained in the string <tt/set/.
3758 <tag/Limits/<itemize>
3759 <item>The function is only available as fastcall function, so it may only
3760 be used in presence of a prototype.
3762 <tag/Availability/ISO 9899
3764 <ref id="strcspn" name="strcspn">,
3765 <ref id="strstr" name="strstr">
3771 <sect1>strstr<label id="strstr"><p>
3775 <tag/Function/Find a substring.
3776 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3777 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
3778 <tag/Description/<tt/strstr/ searches for the first occurance of the string
3779 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
3780 otherwise it returns <tt/NULL/.
3781 <tag/Limits/<itemize>
3782 <item>The function is only available as fastcall function, so it may only
3783 be used in presence of a prototype.
3785 <tag/Availability/ISO 9899
3787 <ref id="strcspn" name="strcspn">,
3788 <ref id="strspn" name="strspn">
3794 <sect1>strupper<label id="strupper"><p>
3798 <tag/Function/Make a string upper case.
3799 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3800 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
3801 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
3802 function to each character of a string. The function will always return <tt/s/.
3803 <tag/Limits/<itemize>
3804 <item>The function is only available as fastcall function, so it may only
3805 be used in presence of a prototype.
3806 <item>The function prototype is unavailable when compiling in strict ANSI mode.
3807 <item>An alias name for this function is <tt/strupr/.
3809 <tag/Availability/cc65
3811 <ref id="strlower" name="strlower">
3812 <ref id="toupper" name="toupper">
3818 <sect1>strupr<label id="strupr"><p>
3825 <sect1>textcolor<label id="textcolor"><p>
3829 <tag/Function/Set the text color.
3830 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3831 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
3832 <tag/Description/The function will set a new text color. It returns the old
3833 (current) text color. Text output using any <tt/conio.h/ function will use
3834 the color set by this function.
3835 <tag/Limits/<itemize>
3836 <item>Text colors are system dependent. The function may have no effect
3837 on systems where the text color cannot be changed.
3838 <item>The function is only available as fastcall function, so it may only
3839 be used in presence of a prototype.
3841 <tag/Availability/cc65
3843 <ref id="bgcolor" name="bgcolor">,
3844 <ref id="bordercolor" name="bordercolor">
3850 <sect1>time<label id="time"><p>
3854 <tag/Function/Get the time.
3855 <tag/Header/<tt/<ref id="time.h" name="time.h">/
3856 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
3857 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
3858 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
3859 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
3860 returned and <tt/errno/ is set to <tt/ENOSYS/.
3861 <tag/Limits/<itemize>
3862 <item>The function is only available as fastcall function, so it may
3863 only be used in presence of a prototype.
3864 <item>Many platforms supported by cc65 do not have a realtime clock, so the
3865 returned value may not be valid.
3867 <tag/Availability/ISO 9899
3873 <sect1>toggle_videomode<label id="toggle_videomode"><p>
3877 <tag/Function/Toggle between 40 and 80 column mode.
3878 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
3879 <tag/Declaration/<tt/void toggle_videomode (void);/
3880 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
3881 old mode (cursor position, color and so on) are saved and restored together
3883 <tag/Limits/<itemize>
3884 <item>The function is specific to the C128.
3886 <tag/Availability/C128
3888 <ref id="fast" name="fast">,
3889 <ref id="slow" name="slow">
3895 <sect1>tolower<label id="tolower"><p>
3899 <tag/Function/Convert a character into its lower case representation.
3900 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3901 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
3902 <tag/Description/The function returns the given character converted to lower
3903 case. If the given character is not a letter, it is returned unchanged.
3904 <tag/Limits/<itemize>
3905 <item>The function is only available as fastcall function, so it may
3906 only be used in presence of a prototype.
3908 <tag/Availability/ISO 9899
3910 <ref id="islower" name="islower">,
3911 <ref id="isupper" name="isupper">,
3912 <ref id="toupper" name="toupper">
3918 <sect1>toupper<label id="toupper"><p>
3922 <tag/Function/Convert a character into its upper case representation.
3923 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
3924 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
3925 <tag/Description/The function returns the given character converted to upper
3926 case. If the given character is not a letter, it is returned unchanged.
3927 <tag/Limits/<itemize>
3928 <item>The function is only available as fastcall function, so it may
3929 only be used in presence of a prototype.
3931 <tag/Availability/ISO 9899
3933 <ref id="islower" name="islower">,
3934 <ref id="isupper" name="isupper">,
3935 <ref id="tolower" name="tolower">
3941 <sect1>ultoa<label id="ultoa"><p>
3945 <tag/Function/Convert an unsigned long integer into a string.
3946 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3947 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
3948 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
3949 string using <tt/radix/ as the base.
3950 <tag/Limits/<itemize>
3951 <item>There are no provisions to prevent a buffer overflow.
3952 <item>The function is non standard, so it is not available in strict ANSI mode.
3953 You should probably use <tt/sprintf/ instead.
3954 <item>The function is only available as fastcall function, so it may only be
3955 used in presence of a prototype.
3957 <tag/Availability/cc65
3959 <ref id="atoi" name="atoi">,
3960 <ref id="atol" name="atol">,
3961 <ref id="itoa" name="itoa">,
3962 <ref id="ltoa" name="ltoa">,
3963 <ref id="utoa" name="utoa">
3969 <sect1>unlink<label id="unlink"><p>
3973 <tag/Function/Delete a file.
3974 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3975 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
3976 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
3977 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
3978 code describing the reason for the failure.
3981 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
3982 name="remove">/ instead, which is a native ANSI C function and does the same.
3983 <item>This function is not available on all cc65 targets (depends on the
3984 availability of file I/O).
3985 <item>The function is only available as fastcall function, so it may only
3986 be used in presence of a prototype.
3987 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
3988 used, which has the same semantics, but is more portable, because it conforms
3989 to the ISO C standard.
3991 <tag/Availability/POSIX 1003.1
3993 <ref id="remove" name="remove">
3995 #include <stdio.h>
3996 #include <unistd.h>
3998 #define FILENAME "helloworld"
4000 if (unlink (FILENAME) == 0) {
4001 printf ("We deleted %s successfully\n", FILENAME);
4003 printf ("There was a problem deleting %s\n", FILENAME);
4009 <sect1>utoa<label id="utoa"><p>
4013 <tag/Function/Convert an unsigned integer into a string.
4014 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4015 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
4016 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
4017 using <tt/radix/ as the base.
4018 <tag/Limits/<itemize>
4019 <item>There are no provisions to prevent a buffer overflow.
4020 <item>The function is non standard, so it is not available in strict ANSI mode.
4021 You should probably use <tt/sprintf/ instead.
4022 <item>The function is only available as fastcall function, so it may only be
4023 used in presence of a prototype.
4025 <tag/Availability/cc65
4027 <ref id="atoi" name="atoi">,
4028 <ref id="atol" name="atol">,
4029 <ref id="itoa" name="itoa">,
4030 <ref id="ltoa" name="ltoa">,
4031 <ref id="ultoa" name="ultoa">
4037 <sect1>vcprintf<label id="vcprintf"><p>
4041 <tag/Function/Formatted output to the console.
4042 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4043 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
4044 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
4045 text where necessary and formatted according to the format string given. The
4046 resulting string is output to the console. <tt/vcprintf/ supports the same
4047 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
4048 <tag/Limits/<itemize>
4049 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
4050 between <tt/\r/ and <tt/\n/.
4051 <item>The function is only available as fastcall function, so it may only be
4052 used in presence of a prototype.
4054 <tag/Availability/cc65
4056 <ref id="cprintf" name="cprintf">,
4057 <ref id="cputc" name="cputc">,
4058 <ref id="cputcxy" name="cputcxy">,
4059 <ref id="cputs" name="cputs">,
4060 <ref id="cputsxy" name="cputsxy">
4066 <sect1>wherex<label id="wherex"><p>
4070 <tag/Function/Return the current X position of the text mode cursor.
4071 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4072 <tag/Declaration/<tt/unsigned char wherex (void);/
4073 <tag/Description/The function returns the current X position of the text mode
4074 cursor. Zero is returned for the leftmost screen position.
4075 <tag/Availability/cc65
4077 <ref id="gotox" name="gotox">,
4078 <ref id="gotoy" name="gotoy">,
4079 <ref id="gotoxy" name="gotoxy">,
4080 <ref id="wherey" name="wherey">
4086 <sect1>wherey<label id="wherey"><p>
4090 <tag/Function/Return the current Y position of the text mode cursor.
4091 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4092 <tag/Declaration/<tt/unsigned char wherey (void);/
4093 <tag/Description/The function returns the current Y position of the text mode
4094 cursor. Zero is returned for the uppermost screen position.
4095 <tag/Availability/cc65
4097 <ref id="gotox" name="gotox">,
4098 <ref id="gotoy" name="gotoy">,
4099 <ref id="gotoxy" name="gotoxy">,
4100 <ref id="wherex" name="wherex">