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>
70 <sect1><tt/apple2enh.h/<label id="apple2enh.h"><p>
75 <sect1><tt/assert.h/<label id="assert.h"><p>
78 <item><ref id="assert" name="assert">
82 <sect1><tt/atari.h/<label id="atari.h"><p>
87 <sect1><tt/atmos.h/<label id="atmos.h"><p>
92 <sect1><tt/c128.h/<label id="c128.h"><p>
95 <item><ref id="c64mode" name="c64mode">
96 <item><ref id="fast" name="fast">
97 <item><ref id="toggle_videomode" name="toggle_videomode">
98 <item><ref id="slow" name="slow">
102 <sect1><tt/c16.h/<label id="c16.h"><p>
107 <sect1><tt/c64.h/<label id="c64.h"><p>
112 <sect1><tt/cbm510.h/<label id="cbm510.h"><p>
117 <sect1><tt/cbm610.h/<label id="cbm610.h"><p>
122 <sect1><tt/conio.h/<label id="conio.h"><p>
125 <item><ref id="bgcolor" name="bgcolor">
126 <item><ref id="bordercolor" name="bordercolor">
127 <item><ref id="cclear" name="cclear">
128 <item><ref id="cclearxy" name="cclearxy">
129 <item><ref id="cgetc" name="cgetc">
130 <item><ref id="chline" name="chline">
131 <item><ref id="chlinexy" name="chlinexy">
132 <item><ref id="clrscr" name="clrscr">
133 <item><ref id="cprintf" name="cprintf">
134 <item><ref id="cputc" name="cputc">
135 <item><ref id="cputcxy" name="cputcxy">
136 <item><ref id="cputs" name="cputs">
137 <item><ref id="cputsxy" name="cputsxy">
138 <item><ref id="cursor" name="cursor">
139 <item><ref id="cvline" name="cvline">
140 <item><ref id="cvlinexy" name="cvlinexy">
141 <item><ref id="gotox" name="gotox">
142 <item><ref id="gotoxy" name="gotoxy">
143 <item><ref id="gotoy" name="gotoy">
144 <item><ref id="kbhit" name="kbhit">
145 <item><ref id="revers" name="revers">
146 <item><ref id="screensize" name="screensize">
147 <item><ref id="textcolor" name="textcolor">
148 <item><ref id="vcprintf" name="vcprintf">
149 <item><ref id="wherex" name="wherex">
150 <item><ref id="wherey" name="wherey">
154 <sect1><tt/ctype.h/<label id="ctype.h"><p>
157 <item><ref id="isalnum" name="isalnum">
158 <item><ref id="isalpha" name="isalpha">
159 <item><ref id="isascii" name="isascii">
160 <item><ref id="isblank" name="isblank">
161 <item><ref id="iscntrl" name="iscntrl">
162 <item><ref id="isdigit" name="isdigit">
163 <item><ref id="isgraph" name="isgraph">
164 <item><ref id="islower" name="islower">
165 <item><ref id="isprint" name="isprint">
166 <item><ref id="ispunct" name="ispunct">
167 <item><ref id="isspace" name="isspace">
168 <item><ref id="isupper" name="isupper">
169 <item><ref id="isxdigit" name="isxdigit">
170 <item><ref id="tolower" name="tolower">
171 <item><ref id="toupper" name="toupper">
175 <sect1><tt/dbg.h/<label id="dbg.h"><p>
180 <sect1><tt/dio.h/<label id="dio.h"><p>
185 <sect1><tt/em.h/<label id="em.h"><p>
188 <item><ref id="em_commit" name="em_commit">
189 <item><ref id="em_copyfrom" name="em_copyfrom">
190 <item><ref id="em_copyto" name="em_copyto">
191 <item><ref id="em_load_driver" name="em_load_driver">
192 <item><ref id="em_map" name="em_map">
193 <item><ref id="em_pagecount" name="em_pagecount">
194 <item><ref id="em_unload" name="em_unload">
195 <item><ref id="em_use" name="em_use">
199 <sect1><tt/errno.h/<label id="errno.h"><p>
204 <sect1><tt/fcntl.h/<label id="fcntl.h"><p>
207 <item><ref id="close" name="close">
208 <item><ref id="creat" name="creat">
209 <item><ref id="open" name="open">
213 <sect1><tt/geos.h/<label id="geos.h"><p>
218 <sect1><tt/joystick.h/<label id="joystick.h"><p>
223 <sect1><tt/locale.h/<label id="locale.h"><p>
226 <item><ref id="localeconv" name="localeconv">
227 <item><ref id="setlocale" name="setlocale">
231 <sect1><tt/modload.h/<label id="modload.h"><p>
234 <item><ref id="mod_load" name="mod_load">
235 <item><ref id="mod_free" name="mod_free">
239 <sect1><tt/mouse.h/<label id="mouse.h"><p>
242 <!-- <item><ref id="mouse_load_driver" name="mouse_load_driver"> -->
243 <!-- <item><ref id="mouse_unload" name="mouse_unload"> -->
244 <!-- <item><ref id="mouse_install" name="mouse_install"> -->
245 <!-- <item><ref id="mouse_uninstall" name="mouse_uninstall"> -->
246 <!-- <item><ref id="mouse_hide" name="mouse_hide"> -->
247 <!-- <item><ref id="mouse_show" name="mouse_show"> -->
248 <!-- <item><ref id="mouse_box" name="mouse_box"> -->
249 <!-- <item><ref id="mouse_move" name="mouse_move"> -->
250 <!-- <item><ref id="mouse_buttons" name="mouse_buttons"> -->
251 <!-- <item><ref id="mouse_pos" name="mouse_pos"> -->
252 <!-- <item><ref id="mouse_info" name="mouse_info"> -->
253 <!-- <item><ref id="mouse_ioctl" name="mouse_ioctl"> -->
259 <sect1><tt/nes.h/<label id="nes.h"><p>
264 <sect1><tt/o65.h/<label id="o65.h"><p>
266 The <tt/o65.h/ header file contains structure and constant definitions that
267 may be used when dealing with files in <htmlurl
268 url="http://www.6502.org/users/andre/o65/fileformat.html" name="o65 format">.
269 It does not declare any functions.
272 <sect1><tt/peekpoke.h/<label id="peekpoke.h"><p>
275 <item><ref id="PEEK" name="PEEK">
276 <item><ref id="PEEKW" name="PEEKW">
277 <item><ref id="POKE" name="POKE">
278 <item><ref id="POKEW" name="POKEW">
282 <sect1><tt/pet.h/<label id="pet.h"><p>
287 <sect1><tt/plus4.h/<label id="plus4.h"><p>
292 <sect1><tt/serial.h/<label id="serial.h"><p>
296 <item><ref id="ser_load_driver" name="ser_load_driver">
297 <item><ref id="ser_unload" name="ser_unload">
298 <item><ref id="ser_install" name="ser_install">
299 <item><ref id="ser_uninstall" name="ser_uninstall">
300 <item><ref id="ser_open" name="ser_open">
301 <item><ref id="ser_close" name="ser_close">
302 <item><ref id="ser_get" name="ser_get">
303 <item><ref id="ser_put" name="ser_put">
304 <item><ref id="ser_status" name="ser_status">
305 <item><ref id="ser_ioctl" name="ser_ioctl">
312 <sect1><tt/setjmp.h/<label id="setjmp.h"><p>
315 <item><ref id="setjmp" name="setjmp">
316 <item><ref id="longjmp" name="longjmp">
320 <sect1><tt/signal.h/<label id="signal.h"><p>
323 <item><ref id="raise" name="raise">
324 <item><ref id="signal" name="signal">
328 <sect1><tt/stdarg.h/<label id="stdarg.h"><p>
333 <sect1><tt/stdbool.h/<label id="stdbool.h"><p>
338 <sect1><tt/stddef.h/<label id="stddef.h"><p>
341 <item><ref id="offsetof" name="offsetof">
345 <sect1><tt/stdio.h/<label id="stdio.h"><p>
348 <item><ref id="clearerr" name="clearerr">
349 <!-- <item><ref id="fclose" name="fclose"> -->
350 <!-- <item><ref id="fdopen" name="fdopen"> -->
351 <item><ref id="feof" name="feof">
352 <item><ref id="ferror" name="ferror">
353 <!-- <item><ref id="fflush" name="fflush"> -->
354 <!-- <item><ref id="fgetc" name="fgetc"> -->
355 <!-- <item><ref id="fgetpos" name="fgetpos"> -->
356 <!-- <item><ref id="fgets" name="fgets"> -->
357 <item><ref id="fileno" name="fileno">
358 <!-- <item><ref id="flushall" name="flushall"> -->
359 <!-- <item><ref id="fopen" name="fopen"> -->
360 <!-- <item><ref id="fprintf" name="fprintf"> -->
361 <!-- <item><ref id="fputc" name="fputc"> -->
362 <!-- <item><ref id="fputs" name="fputs"> -->
363 <!-- <item><ref id="fread" name="fread"> -->
364 <!-- <item><ref id="freopen" name="freopen"> -->
365 <!-- <item><ref id="fscanf" name="fscanf"> -->
366 <!-- <item><ref id="fseek" name="fseek"> -->
367 <!-- <item><ref id="fsetpos" name="fsetpos"> -->
368 <!-- <item><ref id="ftell" name="ftell"> -->
369 <!-- <item><ref id="fwrite" name="fwrite"> -->
370 <!-- <item><ref id="getc" name="getc"> -->
371 <!-- <item><ref id="getchar" name="getchar"> -->
372 <!-- <item><ref id="gets" name="gets"> -->
373 <!-- <item><ref id="printf" name="printf"> -->
374 <!-- <item><ref id="putc" name="putc"> -->
375 <!-- <item><ref id="putchar" name="putchar"> -->
376 <!-- <item><ref id="puts" name="puts"> -->
377 <!-- <item><ref id="rename" name="rename"> -->
378 <!-- <item><ref id="rewind" name="rewind"> -->
379 <!-- <item><ref id="scanf" name="scanf"> -->
380 <!-- <item><ref id="sprintf" name="sprintf"> -->
381 <!-- <item><ref id="sscanf" name="sscanf"> -->
382 <!-- <item><ref id="vfprintf" name="vfprintf"> -->
383 <!-- <item><ref id="vfscanf" name="vfscanf"> -->
384 <!-- <item><ref id="vprintf" name="vprintf"> -->
385 <!-- <item><ref id="vscanf" name="vscanf"> -->
386 <!-- <item><ref id="vsprintf" name="vsprintf"> -->
387 <!-- <item><ref id="vsscanf" name="vsscanf"> -->
393 <sect1><tt/stdlib.h/<label id="stdlib.h"><p>
396 <item><ref id="_heapadd" name="_heapadd">
397 <item><ref id="_heapblocksize" name="_heapblocksize">
398 <item><ref id="_heapmaxavail" name="_heapmaxavail">
399 <item><ref id="_heapmemavail" name="_heapmemavail">
400 <item><ref id="_poserror" name="_poserror">
401 <item><ref id="_randomize" name="_randomize">
402 <item><ref id="_swap" name="_swap">
403 <item><ref id="abort" name="abort">
404 <item><ref id="abs" name="abs">
405 <item><ref id="atexit" name="atexit">
406 <item><ref id="atoi" name="atoi">
407 <item><ref id="atol" name="atol">
408 <item><ref id="bsearch" name="bsearch">
409 <item><ref id="calloc" name="calloc">
410 <item><ref id="div" name="div">
411 <item><ref id="exit" name="exit">
412 <item><ref id="free" name="free">
413 <item><ref id="getenv" name="getenv">
414 <item><ref id="itoa" name="itoa">
415 <item><ref id="labs" name="labs">
416 <item><ref id="ltoa" name="ltoa">
417 <item><ref id="malloc" name="malloc">
418 <item><ref id="perror" name="perror">
419 <item><ref id="qsort" name="qsort">
420 <item><ref id="rand" name="rand">
421 <item><ref id="realloc" name="realloc">
422 <item><ref id="remove" name="remove">
423 <item><ref id="srand" name="srand">
424 <item><ref id="ultoa" name="ultoa">
425 <item><ref id="utoa" name="utoa">
429 <sect1><tt/string.h/<label id="string.h"><p>
432 <item><ref id="_stroserror" name="_stroserror">
433 <item><ref id="bzero" name="bzero">
434 <item><ref id="memchr" name="memchr">
435 <item><ref id="memcpy" name="memcpy">
436 <item><ref id="memmove" name="memmove">
437 <item><ref id="memset" name="memset">
438 <item><ref id="strcasecmp" name="strcasecmp">
439 <item><ref id="strcat" name="strcat">
440 <item><ref id="strchr" name="strchr">
441 <item><ref id="strcmp" name="strcmp">
442 <item><ref id="strcoll" name="strcoll">
443 <item><ref id="strcpy" name="strcpy">
444 <item><ref id="strcspn" name="strcspn">
445 <item><ref id="strdup" name="strdup">
446 <item><ref id="strerror" name="strerror">
447 <item><ref id="stricmp" name="stricmp">
448 <item><ref id="strlen" name="strlen">
449 <item><ref id="strlower" name="strlower">
450 <item><ref id="strlwr" name="strlwr">
451 <item><ref id="strncat" name="strncat">
452 <item><ref id="strncmp" name="strncmp">
453 <item><ref id="strncpy" name="strncpy">
454 <item><ref id="strrchr" name="strrchr">
455 <item><ref id="strspn" name="strspn">
456 <item><ref id="strstr" name="strstr">
457 <!-- <item><ref id="strtok" name="strtok"> -->
458 <!-- <item><ref id="strxfrm" name="strxfrm"> -->
459 <item><ref id="strupper" name="strupper">
460 <item><ref id="strupr" name="strupr">
466 <sect1><tt/tgi.h/<label id="tgi.h"><p>
471 <sect1><tt/time.h/<label id="time.h"><p>
474 <!-- <item><ref id="_systime" name="_systime"> -->
475 <!-- <item><ref id="asctime" name="asctime"> -->
476 <!-- <item><ref id="clock" name="clock"> -->
477 <!-- <item><ref id="ctime" name="ctime"> -->
478 <!-- <item><ref id="gmtime" name="gmtime"> -->
479 <!-- <item><ref id="localtime" name="localtime"> -->
480 <!-- <item><ref id="mktime" name="mktime"> -->
481 <!-- <item><ref id="strftime" name="strftime"> -->
482 <item><ref id="time" name="time">
488 <sect1><tt/unistd.h/<label id="unistd.h"><p>
491 <!-- <item><ref id="chdir" name="chdir"> -->
492 <!-- <item><ref id="getcwd" name="getcwd"> -->
493 <!-- <item><ref id="lseek" name="lseek"> -->
494 <!-- <item><ref id="mkdir" name="mkdir"> -->
495 <!-- <item><ref id="read" name="read"> -->
496 <!-- <item><ref id="rmdir" name="rmdir"> -->
497 <item><ref id="sleep" name="sleep">
498 <item><ref id="unlink" name="unlink">
499 <!-- <item><ref id="write" name="write"> -->
505 <sect1><tt/vic20.h/<label id="vic20.h"><p>
510 <sect1><tt/zlib.h/<label id="zlib.h"><p>
515 <sect>Alphabetical function reference<p>
517 <sect1>_heapadd<label id="_heapadd"><p>
521 <tag/Function/Add a block to the heap.
522 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
523 <tag/Declaration/<tt/void __fastcall__ _heapadd (void* mem, size_t size);/
524 <tag/Description/The function adds a block of raw memory to the heap.
527 <item>The minimum blocksize that can be added is 6 bytes; the function will
528 ignore smaller blocks.
530 <tag/Availability/cc65
532 <ref id="_heapblocksize" name="_heapblocksize">,
533 <ref id="_heapmaxavail" name="_heapmaxavail">,
534 <ref id="_heapmemavail" name="_heapmemavail">,
535 <ref id="calloc" name="calloc">,
536 <ref id="free" name="free">,
537 <ref id="malloc" name="malloc">,
538 <ref id="realloc" name="realloc">
544 <sect1>_heapblocksize<label id="_heapblocksize"><p>
548 <tag/Function/Return the size of an allocated block.
549 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
550 <tag/Declaration/<tt/size_t __fastcall__ _heapblocksize (const void* block);/
551 <tag/Description/The function returns the size of a block that must have
552 previously been allocated by <tt/<ref id="malloc" name="malloc">/, <tt/<ref
553 id="calloc" name="calloc">/ or <tt/<ref id="realloc" name="realloc">/.
556 <item>Passing a pointer to a block that was is not the result of one of the
557 allocation functions, or that has been free'd will give unpredicable results.
559 <tag/Availability/cc65
561 <ref id="_heapadd" name="_heapadd">,
562 <ref id="_heapmaxavail" name="_heapmaxavail">,
563 <ref id="_heapmemavail" name="_heapmemavail">,
564 <ref id="calloc" name="calloc">,
565 <ref id="free" name="free">,
566 <ref id="malloc" name="malloc">,
567 <ref id="realloc" name="realloc">
573 <sect1>_heapmaxavail<label id="_heapmaxavail"><p>
577 <tag/Function/Return the largest block that is available on the heap.
578 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
579 <tag/Declaration/<tt/size_t __fastcall__ _heapmaxavail (void);/
580 <tag/Description/The function returns the size of the largest block that may
581 be allocated from the heap using <tt/<ref id="malloc" name="malloc">/.
582 <tag/Availability/cc65
584 <ref id="_heapadd" name="_heapadd">,
585 <ref id="_heapblocksize" name="_heapblocksize">,
586 <ref id="_heapmemavail" name="_heapmemavail">,
587 <ref id="calloc" name="calloc">,
588 <ref id="free" name="free">,
589 <ref id="malloc" name="malloc">,
590 <ref id="realloc" name="realloc">
596 <sect1>_heapmemavail<label id="_heapmemavail"><p>
600 <tag/Function/Return the total available space on the heap.
601 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
602 <tag/Declaration/<tt/size_t __fastcall__ _heapmemavail (void);/
603 <tag/Description/The function returns the total number of bytes available on
607 <item>This function is of less use than usually assumed, since the returned
608 heap space may be available but not in one block. So even if this function
609 says that several times more heap space is available than needed, <ref
610 id="malloc" name="malloc"> may still return <tt/NULL/.
612 <tag/Availability/cc65
614 <ref id="_heapadd" name="_heapadd">,
615 <ref id="_heapblocksize" name="_heapblocksize">,
616 <ref id="_heapmaxavail" name="_heapmaxavail">,
617 <ref id="calloc" name="calloc">,
618 <ref id="free" name="free">,
619 <ref id="malloc" name="malloc">,
620 <ref id="realloc" name="realloc">
626 <sect1>_poserror<label id="_poserror"><p>
630 <tag/Function/Print an error message for the error in <tt/_oserrno/.
631 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
632 <tag/Declaration/<tt/void __fastcall__ _poserror (const char* msg);/
633 <tag/Description/<tt/_poserror/ prints an error message to <tt/stderr/. If
634 <tt/msg/ is not <tt/NULL/ and not an empty string, it is printed followed by
635 a colon and a blank. Then the error message for the current contents of
636 <tt/_oserrno/ are printed followed by a newline. The message output is the
637 same as returned by <tt/<ref id="_stroserror" name="_stroserror">/ with an
638 argument of <tt/_oserrno/.
641 <item>Since operating system specific error code are - you guessed it -
642 operating system specific, the value in <tt/_oserror/ and the message that is
643 printed depend on the cc65 target.
644 <item>The function is only available as fastcall function, so it may only
645 be used in presence of a prototype.
647 <tag/Availability/cc65
649 <ref id="_stroserror" name="_stroserror">,
650 <ref id="perror" name="perror">
656 <sect1>_randomize<label id="_randomize"><p>
660 <tag/Function/Initialize the pseudo random number generator.
661 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
662 <tag/Declaration/<tt/void _randomize (void);/
663 <tag/Description/The function initializes the random number generator with
664 a seed derived from fast changing hardware events, so the seed itself can be
665 considered random to a certain degree.
666 <tag/Limits/<itemize>
667 <item>The randomness of the seed depends on the machine hardware.
669 <tag/Availability/cc65
671 <ref id="rand" name="rand">,
672 <ref id="srand" name="srand">
678 <sect1>_stroserror<label id="_stroserror"><p>
682 <tag/Function/Return a string describing an OS specific error code.
683 <tag/Header/<tt/<ref id="string.h" name="string.h">/
684 <tag/Declaration/<tt/const char* __fastcall__ _stroserror (unsigned char errcode);/
685 <tag/Description/<tt/_stroserror/ will return a string describing the given
686 operating system specific error code.
687 <tag/Limits/<itemize>
688 <item>Since operating system specific error code are - you guessed it -
689 operating system specific, the parameter and the string returned depend on the
691 <item>The function is only available as fastcall function, so it may only be
692 used in presence of a prototype.
694 <tag/Availability/cc65
696 <ref id="strerror" name="strerror">
702 <sect1>_swap<label id="_swap"><p>
706 <tag/Function/Swap the contents of memory areas.
707 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
708 <tag/Declaration/<tt/void __fastcall__ _swap (void* p, void* q, size_t size);/
709 <tag/Description/<tt/_swap/ will swap (exchange) the contents of the two memory
710 areas pointed to by <tt/p/ and <tt/q/. Both memory areas are assumed to be
711 <tt/size/ bytes in size.
712 <tag/Limits/<itemize>
713 <item>The memory areas may not overlap, otherwise the results are undefined.
714 <item>The function is only available as fastcall function, so it may only be
715 used in presence of a prototype.
717 <tag/Availability/cc65
719 <ref id="memcpy" name="memcpy">,
720 <ref id="memmove" name="memmove">
726 <sect1>_sys<label id="_sys"><p>
730 <tag/Function/Call a subroutine passing register values.
731 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
732 <tag/Declaration/<tt/void __fastcall__ _sys (struct regs* r);/
733 <tag/Description/The function will call the subroutine at the address
734 specified in the <tt/pc/ member of the passed <tt/regs/ structure. All
735 registers and the CPU flags are set to the values given in the <tt/regs/
736 structure. On return from the subroutine, the new values of the registers and
737 flags are stored back overwriting the old values.
738 <tag/Limits/<itemize>
739 <item>Bits 4 and 5 of the flags value in the <tt/regs/ structure are ignored
740 when calling the subroutine (they are unchanged from their current values).
741 <item>The function is only available as fastcall function, so it may only be
742 used in presence of a prototype.
744 <tag/Availability/cc65
750 <sect1>BRK<label id="BRK"><p>
754 <tag/Function/Insert a 6502 BRK instrunction into the code.
755 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
756 <tag/Declaration/<tt/void BRK (void);/
757 <tag/Description/The function will insert a 6502 BRK instruction into the code
758 which may be used to trigger a debugger.
759 <tag/Limits/<itemize>
760 <item>The function is actually a macro.
761 <item>The inserted instruction may lead to unexpected results if no debugger
764 <tag/Availability/cc65
766 <ref id="CLI" name="CLI">,
767 <ref id="SEI" name="SEI">
773 <sect1>CLI<label id="CLI"><p>
777 <tag/Function/Insert a 6502 CLI instrunction into the code.
778 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
779 <tag/Declaration/<tt/void CLI (void);/
780 <tag/Description/The function will insert a 6502 CLI instruction into the code,
781 so interrupts are disabled. Note that non maskable interrupts cannot be
783 <tag/Limits/<itemize>
784 <item>The function is actually a macro.
785 <item>Disabling interrupts may lead to unexpected results.
787 <tag/Availability/cc65
789 <ref id="BRK" name="BRK">,
790 <ref id="SEI" name="SEI">
796 <sect1>PEEK<label id="PEEK"><p>
800 <tag/Function/Read a byte from memory.
801 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
802 <tag/Declaration/<tt/unsigned char PEEK (unsigned addr);/
803 <tag/Description/The function will read the absolute memory given by <tt/addr/
804 and return the value read.
805 <tag/Limits/<itemize>
806 <item>The function is actually a macro.
807 <item>This function depends highly on the platform and environment.
809 <tag/Availability/cc65
811 <ref id="PEEKW" name="PEEKW">,
812 <ref id="POKE" name="POKE">
818 <sect1>PEEKW<label id="PEEKW"><p>
822 <tag/Function/Read a word (two bytes) from memory.
823 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
824 <tag/Declaration/<tt/unsigned PEEKW (unsigned addr);/
825 <tag/Description/The function will read the absolute memory given by <tt/addr/
826 and return the value read. The byte read from the higher address is the high
827 byte of the return value.
828 <tag/Limits/<itemize>
829 <item>The function is actually a macro.
830 <item>This function depends highly on the platform and environment.
831 <item>The order in which the two bytes are read is unspecified and may
832 depend of the address expression used.
834 <tag/Availability/cc65
836 <ref id="PEEK" name="PEEK">,
837 <ref id="POKE" name="POKE">
843 <sect1>POKE<label id="POKE"><p>
847 <tag/Function/Write a byte to memory.
848 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
849 <tag/Declaration/<tt/void POKE (unsigned addr, unsigned char val);/
850 <tag/Description/The function writes the value <tt/val/ to the absolute
851 memory address given by <tt/addr/.
852 <tag/Limits/<itemize>
853 <item>The function is actually a macro.
854 <item>This function depends highly on the platform and environment.
855 <item>Careless use will cause the program to act strange or may crash the
858 <tag/Availability/cc65
860 <ref id="PEEK" name="PEEK">,
861 <ref id="POKEW" name="POKEW">
867 <sect1>POKEW<label id="POKEW"><p>
871 <tag/Function/Write a word (two bytes) to memory.
872 <tag/Header/<tt/<ref id="peekpoke.h" name="peekpoke.h">/
873 <tag/Declaration/<tt/void POKEW (unsigned addr, unsigned val);/
874 <tag/Description/The function writes the value <tt/val/ to the absolute
875 memory address given by <tt/addr/. The low byte of <tt/val/ is written to
876 the <tt/addr/, the high byte is written to <tt/addr+1/.
877 <tag/Limits/<itemize>
878 <item>The function is actually a macro.
879 <item>This function depends highly on the platform and environment.
880 <item>Careless use will cause the program to act strange or may crash the
882 <item>The order in which the two bytes are written is unspecified and may
883 depend of the address expression used.
885 <tag/Availability/cc65
887 <ref id="PEEK" name="PEEK">,
888 <ref id="POKE" name="POKE">
894 <sect1>SEI<label id="SEI"><p>
898 <tag/Function/Insert a 6502 SEI instrunction into the code.
899 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
900 <tag/Declaration/<tt/void SEI (void);/
901 <tag/Description/The function will insert a 6502 SEI instruction into the code,
902 so interrupts are enabled. Enabling interrupts has no effects if they are
903 already enabled (the default).
904 <tag/Limits/<itemize>
905 <item>The function is actually a macro.
907 <tag/Availability/cc65
909 <ref id="BRK" name="BRK">,
910 <ref id="CLI" name="CLI">
916 <sect1>abort<label id="abort"><p>
920 <tag/Function/Terminates a program abnormally.
921 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
922 <tag/Declaration/<tt/void abort (void);/
923 <tag/Description/<tt/abort/ raises <tt/SIGABRT/, writes a termination message
924 on stderr, then terminates the program with an exit code of 3.
925 <tag/Availability/ISO 9899
927 <ref id="assert" name="assert">,
928 <ref id="exit" name="exit">,
929 <ref id="raise" name="raise">
935 <sect1>abs<label id="abs"><p>
939 <tag/Function/Returns the absolute value of an integer.
940 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
941 <tag/Declaration/<tt/int __fastcall__ abs (int v);/
942 <tag/Description/<tt/abs/ returns the absolute value of the argument passed to
944 <tag/Limits/<itemize>
945 <item>The return value is undefined if <tt/INT_MIN/ is passed to the function.
946 <item>The function is only available as fastcall function, so it may only be
947 used in presence of a prototype.
949 <tag/Availability/ISO 9899
951 <ref id="labs" name="labs">
957 <sect1>assert<label id="assert"><p>
961 <tag/Function/Test a condition and possibly abort.
962 <tag/Header/<tt/<ref id="assert.h" name="assert.h">/
963 <tag/Declaration/<tt/void assert (int cond);/
964 <tag/Description/<tt/assert/ is a macro that expands to a <tt/id/
965 statement. If the condition evaluates t zero (false), assert prints a message
966 on stderr and aborts the program.
967 <tag/Limits/<itemize>
968 <item>The function is actually a macro.
970 <tag/Availability/ISO 9899
972 <ref id="abort" name="abort">,
973 <ref id="exit" name="exit">
979 <sect1>atexit<label id="atexit"><p>
983 <tag/Function/Register an exit function.
984 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
985 <tag/Declaration/<tt/int __fastcall__ atexit (void (*exitfunc) (void));/
986 <tag/Description/<tt/atexit/ registers the function pointed to by
987 <tt/exitfunc/ as an exit function. Exit functions are called when the program
988 terminates, they are called in LIFO order (the last function registered is
989 called first). <tt/atexit/ returns zero on success and a nonzero value on
991 <tag/Limits/<itemize>
992 <item>A maximum of 5 exit functions can be registered.
993 <item>There is no way to unregister an exit function.
994 <item>The function is only available as fastcall function, so it may only be
995 used in presence of a prototype.
997 <tag/Availability/ISO 9899
999 <ref id="abort" name="abort">,
1000 <ref id="exit" name="exit">
1006 <sect1>atoi<label id="atoi"><p>
1010 <tag/Function/Convert a string to an integer.
1011 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1012 <tag/Declaration/<tt/int __fastcall__ atoi (const char* s);/
1013 <tag/Description/<tt/atoi/ converts the given string into an integer.
1014 Conversion stops as soon as any invalid character is encountered.
1015 <tag/Limits/<itemize>
1016 <item>There is no way to detect any conversion errors.
1017 <item>The function does not check for an numerical overflow when converting.
1018 <item>The function is only available as fastcall function, so it may only be
1019 used in presence of a prototype.
1021 <tag/Availability/ISO 9899
1023 <ref id="atol" name="atol">,
1024 <ref id="itoa" name="itoa">,
1025 <ref id="ltoa" name="ltoa">,
1026 <ref id="ultoa" name="ultoa">,
1027 <ref id="utoa" name="utoa">
1033 <sect1>atol<label id="atol"><p>
1037 <tag/Function/Convert a string to a long integer.
1038 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1039 <tag/Declaration/<tt/long __fastcall__ atol (const char* s);/
1040 <tag/Description/<tt/atol/ converts the given string into a long integer.
1041 Conversion stops as soon as any invalid character is encountered.
1042 <tag/Limits/<itemize>
1043 <item>There is no way to detect any conversion errors.
1044 <item>The function does not check for an numerical overflow when converting.
1045 <item>The function is only available as fastcall function, so it may only be
1046 used in presence of a prototype.
1048 <tag/Availability/ISO 9899
1050 <ref id="atoi" name="atoi">,
1051 <ref id="itoa" name="itoa">,
1052 <ref id="ltoa" name="ltoa">,
1053 <ref id="ultoa" name="ultoa">,
1054 <ref id="utoa" name="utoa">
1060 <sect1>bgcolor<label id="bgcolor"><p>
1064 <tag/Function/Set the background text color.
1065 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1066 <tag/Declaration/<tt/unsigned char __fastcall__ bgcolor (unsigned char color);/
1067 <tag/Description/The function will set a new background color and return the
1068 old (current) one. The background color is valid for the whole text output
1069 area of the screen, not just for new text.
1070 <tag/Limits/<itemize>
1071 <item>Background colors are system dependent. The function may have no effect
1072 on systems where the background color cannot be changed.
1073 <item>The function is only available as fastcall function, so it may only be
1074 used in presence of a prototype.
1076 <tag/Availability/cc65
1078 <ref id="bordercolor" name="bordercolor">,
1079 <ref id="textcolor" name="textcolor">
1085 <sect1>bordercolor<label id="bordercolor"><p>
1089 <tag/Function/Set the border (frame) color.
1090 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1091 <tag/Declaration/<tt/unsigned char __fastcall__ bordercolor (unsigned char color);/
1092 <tag/Description/The function will set a new border color. It returns the old
1093 (current) border color.
1094 <tag/Limits/<itemize>
1095 <item>Border colors are system dependent. The function may have no effect
1096 on systems where the border color cannot be changed.
1097 <item>The function is only available as fastcall function, so it may only
1098 be used in presence of a prototype.
1100 <tag/Availability/cc65
1102 <ref id="bgcolor" name="bgcolor">,
1103 <ref id="textcolor" name="textcolor">
1109 <sect1>bsearch<label id="bsearch"><p>
1113 <tag/Function/Do a binary search in a sorted array.
1114 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1115 <tag/Declaration/<tt/void* __fastcall__ bsearch (const void* key,
1116 const void* base, size_t n, size_t size,
1117 int (*cmp) (const void*, const void*));/
1118 <tag/Description/<tt/bsearch/ searches a sorted array for a member that
1119 matches the one pointed to by <tt/key/. <tt/base/ is the address of the array,
1120 <tt/n/ is the number of elements, <tt/size/ the size of an element and <tt/cmp/
1121 the function used to compare the members against the key. The function returns
1122 a pointer to the member found, or <tt/NULL/ if there was no match.
1125 <item>The contents of the array must be sorted in ascending order according to
1126 the compare function given.
1127 <item>If there are multiple members that match the key, the function will
1128 return one of the members.
1129 <item>The function is only available as fastcall function, so it may only
1130 be used in presence of a prototype.
1132 <tag/Availability/ISO 9899
1134 <ref id="qsort" name="qsort">
1140 <sect1>bzero<label id="bzero"><p>
1144 <tag/Function/Fill a memory area with zeroes.
1145 <tag/Header/<tt/<ref id="string.h" name="string.h">/
1146 <tag/Declaration/<tt/void __fastcall__ bzero (void* p, size_t count);/
1147 <tag/Description/<tt/bzero/ fills the memory area pointed to by <tt/p/ with
1151 <item>The function is non standard and therefore only available in non ANSI
1152 mode. You should use <tt/<ref id="memset" name="memset">/ instead.
1153 <item>The function is only available as fastcall function, so it may only
1154 be used in presence of a prototype.
1156 <tag/Availability/cc65
1158 <ref id="_swap" name="_swap">,
1159 <ref id="memcpy" name="memcpy">,
1160 <ref id="memmove" name="memmove">,
1161 <ref id="memset" name="memset">,
1167 <sect1>c64mode<label id="c64mode"><p>
1171 <tag/Function/Switch the C128 into C64 compatible mode.
1172 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1173 <tag/Declaration/<tt/void c64mode (void);/
1174 <tag/Description/The function will cause the machine to reboot into C64 mode.
1175 <tag/Limits/<itemize>
1176 <item>The function is specific to the C128.
1177 <item>The function will not return to the caller.
1179 <tag/Availability/C128
1185 <sect1>calloc<label id="calloc"><p>
1189 <tag/Function/Allocate and clear memory.
1190 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1191 <tag/Declaration/<tt/void* __fastcall__ calloc (size_t n, size_t size);/
1192 <tag/Description/<tt/calloc/ allocates memory for an array of <tt/n/ elements
1193 of size <tt/size/, clears the whole block with binary zeroes and returns a
1194 pointer to it. On error (not enough memory available), <tt/calloc/ returns
1198 <item>Clearing the memory may not have the expected effect on all platforms:
1199 pointers in the block may not be <tt/NULL/ and floating point variables may
1200 not be zero (0.0). In other words: The "clearing" effect of this function
1201 should be used with care for portable programs.
1202 <item>The function is only available as fastcall function, so it may only
1203 be used in presence of a prototype.
1205 <tag/Availability/ISO 9899
1207 <ref id="_heapadd" name="_heapadd">,
1208 <ref id="_heapblocksize" name="_heapblocksize">,
1209 <ref id="_heapmaxavail" name="_heapmaxavail">,
1210 <ref id="_heapmemavail" name="_heapmemavail">,
1211 <ref id="free" name="free">,
1212 <ref id="malloc" name="malloc">,
1213 <ref id="realloc" name="realloc">
1219 <sect1>cclear<label id="cclear"><p>
1223 <tag/Function/Clear part of a line (write a given number of spaces).
1224 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1225 <tag/Declaration/<tt/void __fastcall__ cclear (unsigned char length);/
1226 <tag/Description/The function clears part of a line by writing <tt/length/
1227 spaces in the current text color.
1228 <tag/Limits/<itemize>
1229 <item>The function is only available as fastcall function, so it may
1230 only be used in presence of a prototype.
1232 <tag/Availability/cc65
1234 <ref id="cclearxy" name="cclearxy">,
1235 <ref id="clrscr" name="clrscr">
1241 <sect1>cclearxy<label id="cclearxy"><p>
1245 <tag/Function/Clear part of a line (write a given number of spaces) starting
1246 at a specific screen position.
1247 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1248 <tag/Declaration/<tt/void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);/
1249 <tag/Description/The function moves the cursor to a specific position, and
1250 will then clear part of the line by writing <tt/length/ spaces in the current
1252 <tag/Limits/<itemize>
1253 <item>The function is only available as fastcall function, so it may
1254 only be used in presence of a prototype.
1256 <tag/Availability/cc65
1258 <ref id="cclear" name="cclear">,
1259 <ref id="clrscr" name="clrscr">
1265 <sect1>cgetc<label id="cgetc"><p>
1269 <tag/Function/Read a character from the keyboard.
1270 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1271 <tag/Declaration/<tt/char cgetc (void);/
1272 <tag/Description/The function reads a character from the keyboard. If there is
1273 no character available, <tt/cgetc/ waits until the user presses a key. If the
1274 cursor is enabled by use of the <tt/cursor/ function, a blinking cursor is
1275 displayed while waiting.
1276 <tag/Limits/<itemize>
1277 <item>If the system supports a keyboard buffer, <tt/cgetc/ will fetch a key
1278 from this buffer and wait only if the buffer is empty.
1280 <tag/Availability/cc65
1282 <ref id="cursor" name="cursor">,
1283 <ref id="kbhit" name="kbhit">
1289 <sect1>chline<label id="chline"><p>
1293 <tag/Function/Output a horizontal line in text mode.
1294 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1295 <tag/Declaration/<tt/void __fastcall__ chline (unsigned char length);/
1296 <tag/Description/The function outputs a horizontal line with the given length
1297 starting at the current cursor position.
1298 <tag/Limits/<itemize>
1299 <item>The character used to draw the horizontal line is system dependent.
1300 If available, a line drawing character is used. Drawing a line that is partially
1301 off screen leads to undefined behaviour.
1302 <item>The function is only available as fastcall function, so it may only be
1303 used in presence of a prototype.
1305 <tag/Availability/cc65
1307 <ref id="chlinexy" name="chlinexy">,
1308 <ref id="cvline" name="cvline">,
1309 <ref id="cvlinexy" name="cvlinexy">
1315 <sect1>chlinexy<label id="chlinexy"><p>
1319 <tag/Function/Output a horizontal line at a given position in text mode.
1320 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1321 <tag/Declaration/<tt/void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);/
1322 <tag/Description/The function outputs a horizontal line with the given length
1323 starting at a given position.
1324 <tag/Limits/<itemize>
1325 <item>The character used to draw the horizontal line is system dependent.
1326 If available, a line drawing character is used. Drawing a line that is partially
1327 off screen leads to undefined behaviour.
1328 <item>The function is only available as fastcall function, so it may only be
1329 used in presence of a prototype.
1331 <tag/Availability/cc65
1333 <ref id="chline" name="chline">,
1334 <ref id="cvline" name="cvline">,
1335 <ref id="cvlinexy" name="cvlinexy">
1341 <sect1>clearerr<label id="clearerr"><p>
1345 <tag/Function/Clear error and end-of-file status of a stream.
1346 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1347 <tag/Declaration/<tt/void __fastcall__ clearerr (FILE* f);/
1348 <tag/Description/<tt/clearerr/ clears the error and end-of-file status
1349 indicators for the stream <tt/f/.
1350 <tag/Limits/<itemize>
1351 <item>The function is only available as fastcall function, so it may only be
1352 used in presence of a prototype.
1354 <tag/Availability/ISO 9899
1356 <ref id="feof" name="feof">,
1357 <ref id="ferror" name="ferror">
1363 <sect1>clrscr<label id="clrscr"><p>
1367 <tag/Function/Clear the text screen.
1368 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1369 <tag/Declaration/<tt/void clrscr (void);/
1370 <tag/Description/The function clears the text screen and moves the cursor to
1371 the upper left corner.
1372 <tag/Availability/cc65
1374 <ref id="cclear" name="cclear">,
1375 <ref id="cclearxy" name="cclearxy">
1381 <sect1>close<label id="close"><p>
1385 <tag/Function/Close a file descriptor.
1386 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1387 <tag/Declaration/<tt/int __fastcall__ close (int fd);/
1388 <tag/Description/The function closes the given file descriptor. It returns zero
1389 on success and -1 on error. If an error occurs, the cause can be determined by
1390 reading the <tt/errno/ variable.
1391 <tag/Limits/<itemize>
1392 <item>The function is only available as fastcall function, so it may only
1393 be used in presence of a prototype.
1395 <tag/Availability/POSIX 1003.1
1397 <ref id="creat" name="creat">,
1398 <ref id="open" name="open">
1404 <sect1>creat<label id="creat"><p>
1408 <tag/Function/Create a file.
1409 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
1410 <tag/Declaration/<tt/int __fastcall__ creat (const char* name, unsigned mode);/
1411 <tag/Description/<tt/creat/ creates a new file and returns the file descriptor
1412 associated with it. On error, -1 is returned and an error code is stored in
1414 <tag/Limits/<itemize>
1415 <item><tt/creat/ is identical to calling <tt/<ref id="open" name="open">/ with
1416 <tt/flags/ equal to <tt/O_WRONLY | O_CREAT | O_TRUNC/.
1417 <item>The function is only available as fastcall function, so it may only
1418 be used in presence of a prototype.
1420 <tag/Availability/POSIX 1003.1
1422 <ref id="close" name="close">,
1423 <ref id="open" name="open">
1429 <sect1>cprintf<label id="cprintf"><p>
1433 <tag/Function/Formatted output to the console.
1434 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1435 <tag/Declaration/<tt/int cprintf (const char* format, ...);/
1436 <tag/Description/The arguments are converted to text where necessary and
1437 formatted according to the format string given. The resulting string is output
1438 to the console. <tt/cprintf/ supports the same format specifiers as
1439 <tt/printf/. <!-- <tt/<ref id="printf" name="printf">/. -->
1440 <tag/Limits/<itemize>
1441 <item>Like all other <tt/conio/ output functions, <tt/cprintf/ distinguishes
1442 between <tt/\r/ and <tt/\n/.
1444 <tag/Availability/cc65
1446 <ref id="cputc" name="cputc">,
1447 <ref id="cputcxy" name="cputcxy">,
1448 <ref id="cputs" name="cputs">,
1449 <ref id="cputsxy" name="cputsxy">,
1450 <ref id="vcprintf" name="vcprintf">
1456 <sect1>cputc<label id="cputc"><p>
1460 <tag/Function/Output a character directly to the console.
1461 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1462 <tag/Declaration/<tt/void __fastcall__ cputc (char c);/
1463 <tag/Description/Output one character to the console at the current cursor
1465 <tag/Limits/<itemize>
1466 <item>Like all other <tt/conio/ output functions, <tt/cputc/ distinguishes
1467 between <tt/\r/ and <tt/\n/.
1468 <item>The function is only available as fastcall function, so it may only
1469 be used in presence of a prototype.
1471 <tag/Availability/cc65
1473 <ref id="cprintf" name="cprintf">,
1474 <ref id="cputcxy" name="cputcxy">,
1475 <ref id="cputs" name="cputs">,
1476 <ref id="cputsxy" name="cputsxy">,
1477 <ref id="vcprintf" name="vcprintf">
1483 <sect1>cputcxy<label id="cputcxy"><p>
1487 <tag/Function/Output a character at a specific screen position.
1488 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1489 <tag/Declaration/<tt/void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);/
1490 <tag/Description/<tt/cputcxy/ moves the cursor to the given x/y position on
1491 the screen and outputs one character.
1492 <tag/Limits/<itemize>
1493 <item>Like all other <tt/conio/ output functions, <tt/cputcxy/ distinguishes
1494 between <tt/\r/ and <tt/\n/.
1495 <item>The function is only available as fastcall function, so it may only
1496 be used in presence of a prototype.
1498 <tag/Availability/cc65
1500 <ref id="cprintf" name="cprintf">,
1501 <ref id="cputc" name="cputc">,
1502 <ref id="cputs" name="cputs">,
1503 <ref id="cputsxy" name="cputsxy">,
1504 <ref id="vcprintf" name="vcprintf">
1510 <sect1>cputs<label id="cputs"><p>
1514 <tag/Function/Output a string directly to the console.
1515 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1516 <tag/Declaration/<tt/void __fastcall__ cputs (const char* s);/
1517 <tag/Description/The function outputs the given string on the console at the
1518 current cursor position.
1519 <tag/Limits/<itemize>
1520 <item>Like all other <tt/conio/ output functions, <tt/cputs/ distinguishes
1521 between <tt/\r/ and <tt/\n/.
1522 <item>The function is only available as fastcall function, so it may only
1523 be used in presence of a prototype.
1525 <tag/Availability/cc65
1527 <ref id="cprintf" name="cprintf">,
1528 <ref id="cputc" name="cputc">,
1529 <ref id="cputcxy" name="cputcxy">,
1530 <ref id="cputsxy" name="cputsxy">,
1531 <ref id="vcprintf" name="vcprintf">
1537 <sect1>cputsxy<label id="cputsxy"><p>
1541 <tag/Function/Output a string to the console at a given position.
1542 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1543 <tag/Declaration/<tt/void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);/
1544 <tag/Description/<tt/cputsxy/ moves the cursor to the given x/y position,
1545 and outputs the string <tt/s/.
1546 <tag/Limits/<itemize>
1547 <item>Like all other <tt/conio/ output functions, <tt/cputsxy/ distinguishes
1548 between <tt/\r/ and <tt/\n/.
1549 <item>The function is only available as fastcall function, so it may only
1550 be used in presence of a prototype.
1552 <tag/Availability/cc65
1554 <ref id="cprintf" name="cprintf">,
1555 <ref id="cputc" name="cputc">,
1556 <ref id="cputcxy" name="cputcxy">,
1557 <ref id="cputs" name="cputs">,
1558 <ref id="vcprintf" name="vcprintf">
1564 <sect1>cursor<label id="cursor"><p>
1568 <tag/Function/Enable/disable a blinking cursor when waiting for keyboard input.
1569 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1570 <tag/Declaration/<tt/unsigned char __fastcall__ cursor (unsigned char onoff);/
1571 <tag/Description/If the argument to the function is non zero, a blinking cursor
1572 will be enabled when the <tt/cgetc/ function waits for input from the keyboard.
1573 If the argument is zero, <tt/cgetc/ will wait without a blinking cursor.
1574 <tag/Limits/<itemize>
1575 <item>The function is only available as fastcall function, so it may only
1576 be used in presence of a prototype.
1578 <tag/Availability/cc65
1580 <ref id="cgetc" name="cgetc">,
1581 <ref id="kbhit" name="kbhit">
1587 <sect1>cvline<label id="cvline"><p>
1591 <tag/Function/Output a vertical line in text mode.
1592 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1593 <tag/Declaration/<tt/void __fastcall__ cvline (unsigned char length);/
1594 <tag/Description/The function outputs a vertical line with the given length
1595 starting at the current cursor position.
1596 <tag/Limits/<itemize>
1597 <item>The character used to draw the vertical line is system dependent.
1598 If available, a line drawing character is used. Drawing a line that is partially
1599 off screen leads to undefined behaviour.
1600 <item>The function is only available as fastcall function, so it may only be
1601 used in presence of a prototype.
1603 <tag/Availability/cc65
1605 <ref id="chline" name="chline">,
1606 <ref id="chlinexy" name="chlinexy">,
1607 <ref id="cvlinexy" name="cvlinexy">
1613 <sect1>cvlinexy<label id="cvlinexy"><p>
1617 <tag/Function/Output a vertical line at a given position in text mode.
1618 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
1619 <tag/Declaration/<tt/void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);/
1620 <tag/Description/The function outputs a vertical line with the given length
1621 starting at a given position.
1622 <tag/Limits/<itemize>
1623 <item>The character used to draw the vertical line is system dependent.
1624 If available, a line drawing character is used. Drawing a line that is partially
1625 off screen leads to undefined behaviour.
1626 <item>The function is only available as fastcall function, so it may only be
1627 used in presence of a prototype.
1629 <tag/Availability/cc65
1631 <ref id="chline" name="chline">,
1632 <ref id="chlinexy" name="chlinexy">,
1633 <ref id="cvline" name="cvline">
1639 <sect1>div<label id="div"><p>
1643 <tag/Function/Divide two ints and return quotient and remainder.
1644 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1645 <tag/Declaration/<tt/div_t __fastcall__ div (int numer, int denom);/
1646 <tag/Description/<tt/div/ divides <tt/numer/ by <tt/denom/ and returns the
1647 quotient and remainder in a <tt/div_t/ structure.
1650 <item>The function is only available as fastcall function, so it may only
1651 be used in presence of a prototype.
1653 <tag/Availability/ISO 9899
1661 <sect1>em_commit<label id="em_commit"><p>
1665 <tag/Function/Commit changes into extended memory.
1666 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1667 <tag/Declaration/<tt/void __fastcall__ em_commit (void);/
1668 <tag/Description/Commit changes in the memory window to extended storage. If
1669 the contents of the memory window have been changed, these changes may be lost
1670 if <tt/<ref id="em_map" name="em_map">/, <tt/<ref id="em_use" name="em_use">/,
1671 <tt/<ref id="em_copyfrom" name="em_copyfrom">/ or <tt/<ref id="em_copyto"
1672 name="em_copyto">/ are called without calling <tt/em_commit/ first.
1673 <tag/Limits/<itemize>
1674 <item>Calling <tt/em_commit/ does not necessarily mean that changes to the
1675 memory window are discarded, it does just mean that the drivers is allowed
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 function produces undefined results if no extended memory driver is
1682 <tag/Availability/cc65
1684 <ref id="em_load_driver" name="em_load_driver">,
1685 <ref id="em_map" name="em_map">,
1686 <ref id="em_use" name="em_use">
1692 <sect1>em_copyfrom<label id="em_copyfrom"><p>
1696 <tag/Function/Copy from extended into normal memory.
1697 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1698 <tag/Declaration/<tt/void __fastcall__ em_copyfrom (const struct em_copy* copy_data);/
1699 <tag/Description/Copy data from extended memory into linear memory. Source and
1700 target addresses as well as the number of bytes to transfer are specified in
1701 the <tt/em_copy/ structure that is passed as a parameter.
1702 <tag/Limits/<itemize>
1703 <item>Calling <tt/em_copyfrom/ will invalidate the memory window, so if you
1704 made any changes to the data in the window, call <tt/<ref id="em_commit"
1705 name="em_commit">/ first, or the changes are lost.
1706 <item>The function is only available as fastcall function, so it may only be
1707 used in presence of a prototype.
1708 <item>The function produces undefined results if no extended memory driver is
1711 <tag/Availability/cc65
1713 <ref id="em_commit" name="em_commit">,
1714 <ref id="em_copyto" name="em_copyto">,
1715 <ref id="em_load_driver" name="em_load_driver">
1721 <sect1>em_copyto<label id="em_copyto"><p>
1725 <tag/Function/Copy from normal into extended memory.
1726 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1727 <tag/Declaration/<tt/void __fastcall__ em_copyto (const struct em_copy* copy_data);/
1728 <tag/Description/Copy data from linear into extended memory. Source and
1729 target addresses as well as the number of bytes to transfer are specified in
1730 the <tt/em_copy/ structure that is passed as a parameter.
1731 <tag/Limits/<itemize>
1732 <item>Calling <tt/em_copyto/ will invalidate the memory window, so if you
1733 made any changes to the data in the window, call <tt/<ref id="em_commit"
1734 name="em_commit">/ first, or the changes are lost.
1735 <item>The function is only available as fastcall function, so it may only be
1736 used in presence of a prototype.
1737 <item>The function produces undefined results if no extended memory driver is
1740 <tag/Availability/cc65
1742 <ref id="em_commit" name="em_commit">,
1743 <ref id="em_copyfrom" name="em_copyfrom">,
1744 <ref id="em_load_driver" name="em_load_driver">
1750 <sect1>em_load_driver<label id="em_load_driver"><p>
1754 <tag/Function/Load and initialize an extended memory driver.
1755 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1756 <tag/Declaration/<tt/void __fastcall__ em_load_driver (const char* name);/
1757 <tag/Description/Load an extended memory driver into memory and initialize
1758 it. The function returns an error code that tells if all this has been
1760 <tag/Limits/<itemize>
1761 <item>Not all drivers are able to detect if the supported hardware is really
1763 <item>The function is only available as fastcall function, so it may only be
1764 used in presence of a prototype.
1765 <item>The driver is loaded by name, so currently you must know the type of
1766 extended memory that should be supported. There is no autodetect capability.
1768 <tag/Availability/cc65
1770 <ref id="em_unload" name="em_unload">
1776 <sect1>em_map<label id="em_map"><p>
1780 <tag/Function/Make a page of extended memory accessible.
1781 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1782 <tag/Declaration/<tt/void* __fastcall__ em_map (unsigned page);/
1783 <tag/Description/The function maps one page of extended memory into linear
1784 memory and returns a pointer to the page frame. Depending on the hardware
1785 and driver, the data is either mapped into the address space or transfered
1786 into a buffer. If you don't need the actual contents of the page (for example
1787 because you're going to overwrite it completely, it is better to call
1788 <tt/<ref id="em_use" name="em_use">/ instead. <tt/em_use/ will not transfer the
1789 data if it is possible to avoid that.
1790 <tag/Limits/<itemize>
1791 <item>Calling <tt/em_map/ will invalidate the memory window, so if you
1792 made any changes to the data in the window, call <tt/<ref id="em_commit"
1793 name="em_commit">/ first, or the changes are lost.
1794 <item>The function is only available as fastcall function, so it may only be
1795 used in presence of a prototype.
1796 <item>The function produces undefined results if no extended memory driver is
1799 <tag/Availability/cc65
1801 <ref id="em_commit" name="em_commit">,
1802 <ref id="em_load_driver" name="em_load_driver">,
1803 <ref id="em_use" name="em_use">
1809 <sect1>em_pagecount<label id="em_pagecount"><p>
1813 <tag/Function/Return the number of available extended memory pages.
1814 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1815 <tag/Declaration/<tt/unsigned __fastcall__ em_pagecount (void);/
1816 <tag/Description/The function returns the size of the extended memory supported
1817 by the driver in 256 byte pages.
1818 <tag/Limits/<itemize>
1819 <item>The function returns zero if no extended memory driver is loaded.
1820 <item>The function may return zero if the supported hardware was not detected.
1822 <tag/Availability/cc65
1824 <ref id="em_load_driver" name="em_load_driver">
1830 <sect1>em_unload<label id="em_unload"><p>
1834 <tag/Function/Unload an extended memory driver.
1835 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1836 <tag/Declaration/<tt/void __fastcall__ em_unload (void);/
1837 <tag/Description/The function unloads a loaded extended memory driver and
1838 frees all memory allocated for the driver.
1839 <tag/Limits/<itemize>
1840 <item>The function does nothing if no driver is loaded.
1842 <tag/Availability/cc65
1844 <ref id="em_load_driver" name="em_load_driver">
1850 <sect1>em_use<label id="em_use"><p>
1854 <tag/Function/Prepare an extended memory page for use.
1855 <tag/Header/<tt/<ref id="em.h" name="em.h">/
1856 <tag/Declaration/<tt/void* __fastcall__ em_use (unsigned page);/
1857 <tag/Description/The function maps one page of extended memory into linear
1858 memory and returns a pointer to the page frame. This function is similar to
1859 <tt/<ref id="em_map" name="em_map">/, but will not transfer data into the
1860 actual memory window in the assumption that the existing data is wrong or
1861 will get overwritten.
1862 <tag/Limits/<itemize>
1863 <item>Calling <tt/em_use/ will invalidate the memory window, so if you
1864 made any changes to the data in the window, call <tt/<ref id="em_commit"
1865 name="em_commit">/ first, or the changes are lost.
1866 <item>The function is only available as fastcall function, so it may only be
1867 used in presence of a prototype.
1868 <item>The function produces undefined results if no extended memory driver is
1871 <tag/Availability/cc65
1873 <ref id="em_commit" name="em_commit">,
1874 <ref id="em_load_driver" name="em_load_driver">,
1875 <ref id="em_map" name="em_map">
1881 <sect1>exit<label id="exit"><p>
1885 <tag/Function/Terminate the program.
1886 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
1887 <tag/Declaration/<tt/void __fastcall__ exit (int status);/
1888 <tag/Description/<tt/exit/ terminates the program. The argument specifies the
1889 return code of the program. Before termination, all files are closed, buffered
1890 output is written and any functions registered with <tt/<ref id="atexit"
1891 name="atexit">/ are called. Common values for status are <tt/EXIT_SUCCESS/ and
1892 <tt/EXIT_FAILURE/ which are also defined in <tt/<ref id="stdlib.h"
1894 <tag/Limits/<itemize>
1895 <item>The function is only available as fastcall function, so it may only
1896 be used in presence of a prototype.
1897 <item>It depends on the host machine if the program return code can be
1898 evaluated or is ignored.
1900 <tag/Availability/ISO 9899
1902 <ref id="abort" name="abort">,
1903 <ref id="exit" name="exit">
1909 <sect1>fast<label id="fast"><p>
1913 <tag/Function/Switch the C128 into 2MHz mode.
1914 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
1915 <tag/Declaration/<tt/void fast (void);/
1916 <tag/Description/The function will switch the clock of the C128 to 2MHz. This
1917 will nearly double the speed compared to slow mode.
1918 <tag/Limits/<itemize>
1919 <item>The function is specific to the C128.
1920 <item>2MHz clock will not work in 40 column mode.
1922 <tag/Availability/C128
1924 <ref id="slow" name="slow">,
1925 <ref id="toggle_videomode" name="toggle_videomode">
1931 <sect1>feof<label id="feof"><p>
1935 <tag/Function/Return the end-of-file indicator of a stream.
1936 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1937 <tag/Declaration/<tt/int __fastcall__ feof (FILE* f);/
1938 <tag/Description/<tt/feof/ tests the end-of-file indicator ofthe stream
1939 <tt/f/, and returns a non zero value if it is set.
1940 <tag/Limits/<itemize>
1941 <item>The indicator is set only after a read past the end of a file is
1943 <item>The function is only available as fastcall function, so it may only be
1944 used in presence of a prototype.
1946 <tag/Availability/ISO 9899
1948 <ref id="feof" name="clearerr">,
1949 <ref id="ferror" name="ferror">
1955 <sect1>ferror<label id="ferror"><p>
1959 <tag/Function/Return the error indicator of a stream.
1960 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1961 <tag/Declaration/<tt/int __fastcall__ ferror (FILE* f);/
1962 <tag/Description/<tt/ferror/ tests the error indicator of the stream
1963 <tt/f/, and returns a non zero value if it is set.
1964 <tag/Limits/<itemize>
1965 <item>The function is only available as fastcall function, so it may only be
1966 used in presence of a prototype.
1968 <tag/Availability/ISO 9899
1970 <ref id="feof" name="clearerr">,
1971 <ref id="ferror" name="feof">
1977 <sect1>fileno<label id="fileno"><p>
1981 <tag/Function/Return the file handle used by a stream.
1982 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
1983 <tag/Declaration/<tt/int __fastcall__ fileno (FILE* f);/
1984 <tag/Description/The <tt/fileno/ function returns the file handle used
1985 internally by a C stream. This file handle (an integer) can be used as a
1986 handle for the POSIX input/output functions.
1987 <tag/Limits/<itemize>
1988 <item>The function is only available as fastcall function, so it may only be
1989 used in presence of a prototype.
1990 <item>Mixing C file I/O functions and POSIX file I/O functions for the same
1991 file may have unpredictable results.
1993 <tag/Availability/POSIX 1003.1
1995 <ref id="creat" name="creat">,
1996 <ref id="open" name="open"> <!-- , -->
1997 <!-- <ref id="read" name="read">, -->
1998 <!-- <ref id="write" name="write"> -->
2004 <sect1>free<label id="free"><p>
2008 <tag/Function/Free a block of dynamic memory.
2009 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2010 <tag/Declaration/<tt/void __fastcall__ free (void* block);/
2011 <tag/Description/Free a block of dynamic memory previously allocated with
2012 <tt/<ref id="malloc" name="malloc">/, <tt/<ref id="calloc" name="calloc">/
2013 or <tt/<ref id="realloc" name="realloc">/. As an exception, if the passed
2014 pointer is <tt/NULL/, no action is performed.
2017 <item>Passing an already free'd block to <tt/free/ again will cause undefined
2018 behaviour and may crash your program.
2019 <item>The function is only available as fastcall function, so it may only
2020 be used in presence of a prototype.
2022 <tag/Availability/ISO 9899
2024 <ref id="_heapadd" name="_heapadd">,
2025 <ref id="_heapblocksize" name="_heapblocksize">,
2026 <ref id="_heapmaxavail" name="_heapmaxavail">,
2027 <ref id="_heapmemavail" name="_heapmemavail">,
2028 <ref id="calloc" name="calloc">,
2029 <ref id="malloc" name="malloc">,
2030 <ref id="realloc" name="realloc">
2036 <sect1>getenv<label id="getenv"><p>
2040 <tag/Function/Return a value from the environment.
2041 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2042 <tag/Declaration/<tt/char* __fastcall__ getenv (const char* name);/
2043 <tag/Description/The function searches the environment for an entry that
2044 matches <tt/name/ and returns its value. The environment consists of a list
2045 of strings in the form <tt/name=value/. If there is no match, <tt/getenv/
2047 <tag/Limits/<itemize>
2048 <item>What exactly is stored in the environment depends on the machine the
2049 program is running on.
2050 <item>The function is only available as fastcall function, so it may only
2051 be used in presence of a prototype.
2053 <tag/Availability/ISO 9899
2059 <sect1>getcpu<label id="getcpu"><p>
2063 <tag/Function/Determine on which CPU the program is running.
2064 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
2065 <tag/Declaration/<tt/unsigned char getcpu (void);/
2066 <tag/Description/The function checks on which CPU the code is running. It
2067 returns one of the constants<itemize>
2069 <item><tt/CPU_65C02/
2070 <item><tt/CPU_65816/
2072 <tag/Limits/<itemize>
2073 <item>Other, more exotic CPU types are not disinguished.
2075 <tag/Availability/cc65
2081 <sect1>gotox<label id="gotox"><p>
2085 <tag/Function/Move the text mode cursor to a new X position.
2086 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2087 <tag/Declaration/<tt/void __fastcall__ gotox (unsigned char x);/
2088 <tag/Description/The function moves the text mode cursor to the specified X
2089 position while leaving the Y position untouched. The leftmost position on the
2090 screen has the coordinate 0.
2091 <tag/Limits/<itemize>
2092 <item>The function is only available as fastcall function, so it may
2093 only be used in presence of a prototype.
2094 <item>Invalid values for the X position (out of screen coordinates) may
2095 lead to undefined behaviour.
2097 <tag/Availability/cc65
2099 <ref id="gotoy" name="gotoy">,
2100 <ref id="gotoxy" name="gotoxy">,
2101 <ref id="wherex" name="wherex">,
2102 <ref id="wherey" name="wherey">
2108 <sect1>gotoxy<label id="gotoxy"><p>
2112 <tag/Function/Move the text mode cursor to a new position.
2113 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2114 <tag/Declaration/<tt/void __fastcall__ gotoxy (unsigned char x, unsigned char y);/
2115 <tag/Description/The function moves the text mode cursor to the specified
2116 position. The leftmost position on the screen has the X coordinate 0, the
2117 topmost line has the Y coordinate 0.
2118 <tag/Limits/<itemize>
2119 <item>The function is only available as fastcall function, so it may only be
2120 used in presence of a prototype.
2121 <item>Invalid values for any of both coordinates (out of screen positions) may
2122 lead to undefined behaviour.
2124 <tag/Availability/cc65
2126 <ref id="gotox" name="gotox">,
2127 <ref id="gotoy" name="gotoy">,
2128 <ref id="wherex" name="wherex">,
2129 <ref id="wherey" name="wherey">
2135 <sect1>gotoy<label id="gotoy"><p>
2139 <tag/Function/Move the text mode cursor to a new Y position.
2140 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2141 <tag/Declaration/<tt/void __fastcall__ gotoy (unsigned char x);/
2142 <tag/Description/The function moves the text mode cursor to the specified Y
2143 position while leaving the X position untouched. The uppermost position on the
2144 screen has the coordinate 0.
2145 <tag/Limits/<itemize>
2146 <item>The function is only available as fastcall function, so it may
2147 only be used in presence of a prototype.
2148 <item>Invalid values for the Y position (out of screen coordinates) may lead
2149 to undefined behaviour.
2151 <tag/Availability/cc65
2153 <ref id="gotox" name="gotox">,
2154 <ref id="gotoxy" name="gotoxy">,
2155 <ref id="wherex" name="wherex">,
2156 <ref id="wherey" name="wherey">
2162 <sect1>isalnum<label id="isalnum"><p>
2166 <tag/Function/Check if a given character is a letter or digit.
2167 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2168 <tag/Declaration/<tt/int __fastcall__ isalnum (int c);/
2169 <tag/Description/The function returns a value of zero if the given argument
2170 is a letter or digit. The return value is non zero if the character
2172 <tag/Limits/<itemize>
2173 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2174 inline sequence generated by the macro will not work correctly for values
2175 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2176 this range. The non inline function may be accessed by <tt/#undef/'ing
2178 <item>When compiling without <tt/-Os/, the function is only available as
2179 fastcall function, so it may only be used in presence of a prototype.
2181 <tag/Availability/ISO 9899
2183 <ref id="isalpha" name="isalpha">,
2184 <ref id="isascii" name="isascii">,
2185 <ref id="isblank" name="isblank">,
2186 <ref id="iscntrl" name="iscntrl">,
2187 <ref id="isdigit" name="isdigit">,
2188 <ref id="isgraph" name="isgraph">,
2189 <ref id="islower" name="islower">,
2190 <ref id="isprint" name="isprint">,
2191 <ref id="ispunct" name="ispunct">,
2192 <ref id="isspace" name="isspace">,
2193 <ref id="isupper" name="isupper">,
2194 <ref id="isxdigit" name="isxdigit">
2200 <sect1>isalpha<label id="isalpha"><p>
2204 <tag/Function/Check if a given character is a letter.
2205 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2206 <tag/Declaration/<tt/int __fastcall__ isalpha (int c);/
2207 <tag/Description/The function returns a value of zero if the given argument
2208 is a letter. The return value is non zero if the character is anything else.
2209 <tag/Limits/<itemize>
2210 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2211 inline sequence generated by the macro will not work correctly for values
2212 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2213 this range. The non inline function may be accessed by <tt/#undef/'ing the
2215 <item>When compiling without <tt/-Os/, the function is only available as
2216 fastcall function, so it may only be used in presence of a prototype.
2218 <tag/Availability/ISO 9899
2220 <ref id="isalnum" name="isalnum">,
2221 <ref id="isascii" name="isascii">,
2222 <ref id="isblank" name="isblank">,
2223 <ref id="iscntrl" name="iscntrl">,
2224 <ref id="isdigit" name="isdigit">,
2225 <ref id="isgraph" name="isgraph">,
2226 <ref id="islower" name="islower">,
2227 <ref id="isprint" name="isprint">,
2228 <ref id="ispunct" name="ispunct">,
2229 <ref id="isspace" name="isspace">,
2230 <ref id="isupper" name="isupper">,
2231 <ref id="isxdigit" name="isxdigit">
2237 <sect1>isascii<label id="isascii"><p>
2241 <tag/Function/Check if a given character is in the ASCII (0..127) range.
2242 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2243 <tag/Declaration/<tt/int __fastcall__ isascii (int c);/
2244 <tag/Description/The function returns a value of zero if the given argument
2245 is in the range 0..127 (the range of valid ASCII characters) and a non zero
2247 <tag/Limits/<itemize>
2248 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2249 inline sequence generated by the macro will not work correctly for values
2250 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2251 this range. The non inline function may be accessed by <tt/#undef/'ing the
2253 <item>When compiling without <tt/-Os/, the function is only available as
2254 fastcall function, so it may only be used in presence of a prototype.
2256 <tag/Availability/ISO 9899
2258 <ref id="isalnum" name="isalnum">,
2259 <ref id="isalpha" name="isalpha">,
2260 <ref id="isblank" name="isblank">,
2261 <ref id="iscntrl" name="iscntrl">,
2262 <ref id="isdigit" name="isdigit">,
2263 <ref id="isgraph" name="isgraph">,
2264 <ref id="islower" name="islower">,
2265 <ref id="isprint" name="isprint">,
2266 <ref id="ispunct" name="ispunct">,
2267 <ref id="isspace" name="isspace">,
2268 <ref id="isupper" name="isupper">,
2269 <ref id="isxdigit" name="isxdigit">
2275 <sect1>isblank<label id="isblank"><p>
2279 <tag/Function/Check if a given character is a space or tab.
2280 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2281 <tag/Declaration/<tt/int __fastcall__ isblank (int c);/
2282 <tag/Description/The function returns a value of zero if the given argument
2283 is a space or tab character. The return value is non zero if the character
2285 <tag/Limits/<itemize>
2286 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2287 inline sequence generated by the macro will not work correctly for values
2288 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2289 this range. The non inline function may be accessed by <tt/#undef/'ing the
2291 <item>When compiling without <tt/-Os/, the function is only available as
2292 fastcall function, so it may only be used in presence of a prototype.
2294 <tag/Availability/cc65
2296 <ref id="isalnum" name="isalnum">,
2297 <ref id="isalpha" name="isalpha">,
2298 <ref id="isascii" name="isascii">,
2299 <ref id="iscntrl" name="iscntrl">,
2300 <ref id="isdigit" name="isdigit">,
2301 <ref id="isgraph" name="isgraph">,
2302 <ref id="islower" name="islower">,
2303 <ref id="isprint" name="isprint">,
2304 <ref id="ispunct" name="ispunct">,
2305 <ref id="isspace" name="isspace">,
2306 <ref id="isupper" name="isupper">,
2307 <ref id="isxdigit" name="isxdigit">
2313 <sect1>iscntrl<label id="iscntrl"><p>
2317 <tag/Function/Check if a given character is a control character.
2318 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2319 <tag/Declaration/<tt/int __fastcall__ iscntrl (int c);/
2320 <tag/Description/The function returns a value of zero if the given argument
2321 is a control character. The return value is non zero if the character
2323 <tag/Limits/<itemize>
2324 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2325 inline sequence generated by the macro will not work correctly for values
2326 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2327 this range. The non inline function may be accessed by <tt/#undef/'ing the
2329 <item>When compiling without <tt/-Os/, the function is only available as
2330 fastcall function, so it may only be used in presence of a prototype.
2332 <tag/Availability/ISO 9899
2334 <ref id="isalnum" name="isalnum">,
2335 <ref id="isalpha" name="isalpha">,
2336 <ref id="isascii" name="isascii">,
2337 <ref id="isblank" name="isblank">,
2338 <ref id="isdigit" name="isdigit">,
2339 <ref id="isgraph" name="isgraph">,
2340 <ref id="islower" name="islower">,
2341 <ref id="isprint" name="isprint">,
2342 <ref id="ispunct" name="ispunct">,
2343 <ref id="isspace" name="isspace">,
2344 <ref id="isupper" name="isupper">,
2345 <ref id="isxdigit" name="isxdigit">
2351 <sect1>isdigit<label id="isdigit"><p>
2355 <tag/Function/Check if a given character is a digit.
2356 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2357 <tag/Declaration/<tt/int __fastcall__ isdigit (int c);/
2358 <tag/Description/The function returns a value of zero if the given argument
2359 is a digit. The return value is non zero if the character is anything else.
2360 <tag/Limits/<itemize>
2361 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2362 inline sequence generated by the macro will not work correctly for values
2363 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2364 this range. The non inline function may be accessed by <tt/#undef/'ing the
2366 <item>When compiling without <tt/-Os/, the function is only available as
2367 fastcall function, so it may only be used in presence of a prototype.
2369 <tag/Availability/ISO 9899
2371 <ref id="isalnum" name="isalnum">,
2372 <ref id="isalpha" name="isalpha">,
2373 <ref id="isascii" name="isascii">,
2374 <ref id="isblank" name="isblank">,
2375 <ref id="iscntrl" name="iscntrl">,
2376 <ref id="isgraph" name="isgraph">,
2377 <ref id="islower" name="islower">,
2378 <ref id="isprint" name="isprint">,
2379 <ref id="ispunct" name="ispunct">,
2380 <ref id="isspace" name="isspace">,
2381 <ref id="isupper" name="isupper">,
2382 <ref id="isxdigit" name="isxdigit">
2388 <sect1>isgraph<label id="isgraph"><p>
2392 <tag/Function/Check if a given character is a printable character (except
2394 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2395 <tag/Declaration/<tt/int __fastcall__ isgraph (int c);/
2396 <tag/Description/The function returns a value of zero if the given argument
2397 is a printable character with the exception of space. The return value is non
2398 zero if the character is anything else.
2399 <tag/Limits/<itemize>
2400 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2401 inline sequence generated by the macro will not work correctly for values
2402 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2403 this range. The non inline function may be accessed by <tt/#undef/'ing the
2405 <item>When compiling without <tt/-Os/, the function is only available as
2406 fastcall function, so it may only be used in presence of a prototype.
2408 <tag/Availability/ISO 9899
2410 <ref id="isalnum" name="isalnum">,
2411 <ref id="isalpha" name="isalpha">,
2412 <ref id="isascii" name="isascii">,
2413 <ref id="isblank" name="isblank">,
2414 <ref id="iscntrl" name="iscntrl">,
2415 <ref id="isdigit" name="isdigit">,
2416 <ref id="islower" name="islower">,
2417 <ref id="isprint" name="isprint">,
2418 <ref id="ispunct" name="ispunct">,
2419 <ref id="isspace" name="isspace">,
2420 <ref id="isupper" name="isupper">,
2421 <ref id="isxdigit" name="isxdigit">
2427 <sect1>islower<label id="islower"><p>
2431 <tag/Function/Check if a given character is a lower case letter.
2432 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2433 <tag/Declaration/<tt/int __fastcall__ islower (int c);/
2434 <tag/Description/The function returns a value of zero if the given argument
2435 is a lower case letter. The return value is non zero if the character is
2437 <tag/Limits/<itemize>
2438 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2439 inline sequence generated by the macro will not work correctly for values
2440 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2441 this range. The non inline function may be accessed by <tt/#undef/'ing the
2443 <item>When compiling without <tt/-Os/, the function is only available as
2444 fastcall function, so it may only be used in presence of a prototype.
2446 <tag/Availability/ISO 9899
2448 <ref id="isalnum" name="isalnum">,
2449 <ref id="isalpha" name="isalpha">,
2450 <ref id="isascii" name="isascii">,
2451 <ref id="isblank" name="isblank">,
2452 <ref id="iscntrl" name="iscntrl">,
2453 <ref id="isdigit" name="isdigit">,
2454 <ref id="isgraph" name="isgraph">,
2455 <ref id="isprint" name="isprint">,
2456 <ref id="ispunct" name="ispunct">,
2457 <ref id="isspace" name="isspace">,
2458 <ref id="isupper" name="isupper">,
2459 <ref id="isxdigit" name="isxdigit">
2465 <sect1>isprint<label id="isprint"><p>
2469 <tag/Function/Check if a given character is a printable character.
2470 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2471 <tag/Declaration/<tt/int __fastcall__ isprint (int c);/
2472 <tag/Description/The function returns a value of zero if the given argument
2473 is a printable character (this includes the space character). The return value
2474 is non zero if the character is anything else.
2475 <tag/Limits/<itemize>
2476 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2477 inline sequence generated by the macro will not work correctly for values
2478 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2479 this range. The non inline function may be accessed by <tt/#undef/'ing the
2481 <item>When compiling without <tt/-Os/, the function is only available as
2482 fastcall function, so it may only be used in presence of a prototype.
2484 <tag/Availability/ISO 9899
2486 <ref id="isalnum" name="isalnum">,
2487 <ref id="isalpha" name="isalpha">,
2488 <ref id="isascii" name="isascii">,
2489 <ref id="isblank" name="isblank">,
2490 <ref id="iscntrl" name="iscntrl">,
2491 <ref id="isdigit" name="isdigit">,
2492 <ref id="isgraph" name="isgraph">,
2493 <ref id="islower" name="islower">,
2494 <ref id="ispunct" name="ispunct">,
2495 <ref id="isspace" name="isspace">,
2496 <ref id="isupper" name="isupper">,
2497 <ref id="isxdigit" name="isxdigit">
2503 <sect1>ispunct<label id="ispunct"><p>
2507 <tag/Function/Check if a given character is a printable character but not a
2508 space or an alphanumeric character.
2509 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2510 <tag/Declaration/<tt/int __fastcall__ ispunct (int c);/
2511 <tag/Description/The function returns a value of zero if the given argument
2512 is a printable character, but not a space or anything alphanumeric. The return
2513 value is non zero if the character is anything else.
2514 <tag/Limits/<itemize>
2515 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2516 inline sequence generated by the macro will not work correctly for values
2517 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2518 this range. The non inline function may be accessed by <tt/#undef/'ing the
2520 <item>When compiling without <tt/-Os/, the function is only available as
2521 fastcall function, so it may only be used in presence of a prototype.
2523 <tag/Availability/ISO 9899
2525 <ref id="isalnum" name="isalnum">,
2526 <ref id="isalpha" name="isalpha">,
2527 <ref id="isascii" name="isascii">,
2528 <ref id="isblank" name="isblank">,
2529 <ref id="iscntrl" name="iscntrl">,
2530 <ref id="isdigit" name="isdigit">,
2531 <ref id="isgraph" name="isgraph">,
2532 <ref id="islower" name="islower">,
2533 <ref id="isprint" name="isprint">,
2534 <ref id="isspace" name="isspace">,
2535 <ref id="isupper" name="isupper">,
2536 <ref id="isxdigit" name="isxdigit">
2542 <sect1>isspace<label id="isspace"><p>
2546 <tag/Function/Check if a given character is a a white-space character.
2547 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2548 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
2549 <tag/Description/The function returns a value of zero if the given argument
2550 is a white space character. The return value is non zero if the character is
2551 anything else. The standard white space characters are: space, formfeed ('\f'),
2552 newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab
2554 <tag/Limits/<itemize>
2555 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2556 inline sequence generated by the macro will not work correctly for values
2557 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2558 this range. The non inline function may be accessed by <tt/#undef/'ing the
2560 <item>When compiling without <tt/-Os/, the function is only available as
2561 fastcall function, so it may only be used in presence of a prototype.
2563 <tag/Availability/ISO 9899
2565 <ref id="isalnum" name="isalnum">,
2566 <ref id="isalpha" name="isalpha">,
2567 <ref id="isascii" name="isascii">,
2568 <ref id="isblank" name="isblank">,
2569 <ref id="iscntrl" name="iscntrl">,
2570 <ref id="isdigit" name="isdigit">,
2571 <ref id="isgraph" name="isgraph">,
2572 <ref id="islower" name="islower">,
2573 <ref id="isprint" name="isprint">,
2574 <ref id="ispunct" name="ispunct">,
2575 <ref id="isupper" name="isupper">,
2576 <ref id="isxdigit" name="isxdigit">
2582 <sect1>isupper<label id="isupper"><p>
2586 <tag/Function/Check if a given character is an upper case letter.
2587 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2588 <tag/Declaration/<tt/int __fastcall__ isupper (int c);/
2589 <tag/Description/The function returns a value of zero if the given argument
2590 is an upper case letter. The return value is non zero if the character is
2592 <tag/Limits/<itemize>
2593 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2594 inline sequence generated by the macro will not work correctly for values
2595 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2596 this range. The non inline function may be accessed by <tt/#undef/'ing the
2598 <item>When compiling without <tt/-Os/, the function is only available as
2599 fastcall function, so it may only be used in presence of a prototype.
2601 <tag/Availability/ISO 9899
2603 <ref id="isalnum" name="isalnum">,
2604 <ref id="isalpha" name="isalpha">,
2605 <ref id="isascii" name="isascii">,
2606 <ref id="isblank" name="isblank">,
2607 <ref id="iscntrl" name="iscntrl">,
2608 <ref id="isdigit" name="isdigit">,
2609 <ref id="isgraph" name="isgraph">,
2610 <ref id="islower" name="islower">,
2611 <ref id="isprint" name="isprint">,
2612 <ref id="ispunct" name="ispunct">,
2613 <ref id="isspace" name="isspace">,
2614 <ref id="isxdigit" name="isxdigit">
2620 <sect1>isxdigit<label id="isxdigit"><p>
2624 <tag/Function/Check if a given character is a hexadecimal digit.
2625 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
2626 <tag/Declaration/<tt/int __fastcall__ isxdigit (int c);/
2627 <tag/Description/The function returns a value of zero if the given argument
2628 is a hexadecimal digit (0..9, a..f and A..F). The return value is non zero
2629 if the character is anything else.
2630 <tag/Limits/<itemize>
2631 <item>When compiling with <tt/-Os/ the function is actually a macro. The
2632 inline sequence generated by the macro will not work correctly for values
2633 outside the range 0..255. <bf/Note:/ The constant <tt/EOF/ is not part of
2634 this range. The non inline function may be accessed by <tt/#undef/'ing the
2636 <item>When compiling without <tt/-Os/, the function is only available as
2637 fastcall function, so it may only be used in presence of a prototype.
2639 <tag/Availability/ISO 9899
2641 <ref id="isalnum" name="isalnum">,
2642 <ref id="isalpha" name="isalpha">,
2643 <ref id="isascii" name="isascii">,
2644 <ref id="isblank" name="isblank">,
2645 <ref id="iscntrl" name="iscntrl">,
2646 <ref id="isdigit" name="isdigit">,
2647 <ref id="isgraph" name="isgraph">,
2648 <ref id="islower" name="islower">,
2649 <ref id="isprint" name="isprint">,
2650 <ref id="ispunct" name="ispunct">,
2651 <ref id="isspace" name="isspace">,
2652 <ref id="isupper" name="isupper">
2658 <sect1>itoa<label id="itoa"><p>
2662 <tag/Function/Convert an integer into a string.
2663 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2664 <tag/Declaration/<tt/char* __fastcall__ itoa (int val, char* buf, int radix);/
2665 <tag/Description/<tt/itoa/ converts the integer <tt/val/ into a string using
2666 <tt/radix/ as the base.
2667 <tag/Limits/<itemize>
2668 <item>There are no provisions to prevent a buffer overflow.
2669 <item>If <tt/val/ contains <tt/INT_MIN/, the behaviour is undefined.
2670 <item>The function is non standard, so it is not available in strict ANSI mode.
2671 You should probably use <tt/sprintf/ instead.
2672 <item>The function is only available as fastcall function, so it may only be
2673 used in presence of a prototype.
2675 <tag/Availability/cc65
2677 <ref id="atoi" name="atoi">,
2678 <ref id="atol" name="atol">,
2679 <ref id="ltoa" name="ltoa">,
2680 <ref id="ultoa" name="ultoa">,
2681 <ref id="utoa" name="utoa">
2687 <sect1>kbhit<label id="kbhit"><p>
2691 <tag/Function/Check if there's a key waiting in the keyboard buffer.
2692 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
2693 <tag/Declaration/<tt/unsigned char kbhit (void);/
2694 <tag/Description/The function returns a value of zero if there is no character
2695 waiting to be read from the keyboard. It returns non zero otherwise.
2696 <tag/Limits/<itemize>
2697 <item>If the system does not support a keyboard buffer (most systems
2698 do), the function is rather useless.
2700 <tag/Availability/cc65
2702 <ref id="cgetc" name="cgetc">,
2703 <ref id="cursor" name="cursor">
2709 <sect1>labs<label id="labs"><p>
2713 <tag/Function/Returns the absolute value of a long integer.
2714 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2715 <tag/Declaration/<tt/long __fastcall__ labs (long v);/
2716 <tag/Description/<tt/labs/ returns the absolute value of the argument passed to
2718 <tag/Limits/<itemize>
2719 <item>The return value is undefined if <tt/LONG_MIN/ is passed to the function.
2720 <item>The function is only available as fastcall function, so it may only be
2721 used in presence of a prototype.
2723 <tag/Availability/ISO 9899
2725 <ref id="abs" name="abs">
2731 <sect1>ltoa<label id="ltoa"><p>
2735 <tag/Function/Convert a long integer into a string.
2736 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2737 <tag/Declaration/<tt/char* __fastcall__ ltoa (long val, char* buf, int radix);/
2738 <tag/Description/<tt/itoa/ converts the long integer <tt/val/ into a string
2739 using <tt/radix/ as the base.
2740 <tag/Limits/<itemize>
2741 <item>There are no provisions to prevent a buffer overflow.
2742 <item>If <tt/val/ contains <tt/LONG_MIN/, the behaviour is undefined.
2743 <item>The function is non standard, so it is not available in strict ANSI mode.
2744 You should probably use <tt/sprintf/ instead.
2745 <item>The function is only available as fastcall function, so it may only be
2746 used in presence of a prototype.
2748 <tag/Availability/cc65
2750 <ref id="atoi" name="atoi">,
2751 <ref id="atol" name="atol">,
2752 <ref id="itoa" name="itoa">,
2753 <ref id="ultoa" name="ultoa">,
2754 <ref id="utoa" name="utoa">
2760 <sect1>localeconv<label id="localeconv"><p>
2764 <tag/Function/Returns a pointer to the current locale structure.
2765 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
2766 <tag/Declaration/<tt/struct lconv* localeconv (void);/
2767 <tag/Description/<tt/localeconv/ returns a pointer to the current locale
2769 <tag/Limits/<itemize>
2770 <item>cc65 supports only the "C" locale, so even after setting a new locale
2771 using <tt/<ref id="setlocale" name="setlocale">/, the structure returned will
2774 <tag/Availability/ISO 9899
2776 <ref id="setlocale" name="setlocale">
2782 <sect1>longjmp<label id="longjmp"><p>
2786 <tag/Function/Non local goto.
2787 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
2788 <tag/Declaration/<tt/void __fastcall__ longjmp (jmp_buf buf, int retval);/
2789 <tag/Description/The <tt/longjmp/ function restores a program context from the
2790 data in <tt/buf/, which must have been set by a preceeding call to
2791 <tt/<ref id="setjmp" name="setjmp">/. Program execution continues as if the
2792 call to <tt/<ref id="setjmp" name="setjmp">/ has just returned the value
2796 <item>If the parameter <tt/retval/ is zero, the function will behave as if it
2797 was called with a value of one.
2798 <item>The function is only available as fastcall function, so it may only
2799 be used in presence of a prototype.
2801 <tag/Availability/ISO 9899
2803 <ref id="setjmp" name="setjmp">
2809 <sect1>malloc<label id="malloc"><p>
2813 <tag/Function/Allocate dynamic memory.
2814 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
2815 <tag/Declaration/<tt/void* __fastcall__ malloc (size_t size);/
2816 <tag/Description/<tt/malloc/ allocates size bytes on the heap and returns a
2817 pointer to the allocated memory block. On error (not enough memory available),
2818 <tt/malloc/ returns <tt/NULL/.
2821 <item>The function is only available as fastcall function, so it may only
2822 be used in presence of a prototype.
2824 <tag/Availability/ISO 9899
2826 <ref id="_heapadd" name="_heapadd">,
2827 <ref id="_heapblocksize" name="_heapblocksize">,
2828 <ref id="_heapmaxavail" name="_heapmaxavail">,
2829 <ref id="_heapmemavail" name="_heapmemavail">,
2830 <ref id="calloc" name="calloc">,
2831 <ref id="free" name="free">,
2832 <ref id="realloc" name="realloc">,
2833 <ref id="strdup" name="strdup">
2839 <sect1>memchr<label id="memchr"><p>
2843 <tag/Function/Search for a character in a block of raw memory.
2844 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2845 <tag/Declaration/<tt/void* __fastcall__ strchr (const void* mem, int c, size_t count);/
2846 <tag/Description/The <tt/memchr/ function locates the first occurrence of <tt/c/
2847 (converted to a char) in the block of raw memory string pointed to by <tt/mem/
2848 that is of size <tt/count/. Upon completion, the function returns a pointer to
2849 the character found, or a null pointer if the character was not found.
2850 <tag/Limits/<itemize>
2851 <item>The function is only available as fastcall function, so it may only
2852 be used in presence of a prototype.
2854 <tag/Availability/ISO 9899
2856 <ref id="strchr" name="strchr">
2862 <sect1>memcpy<label id="memcpy"><p>
2866 <tag/Function/Copy a memory area.
2867 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2868 <tag/Declaration/<tt/void* __fastcall__ memcpy (void* dest, const void* src, size_t count);/
2869 <tag/Description/<tt/memcpy/ copies <tt/count/ bytes from the memory area
2870 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
2874 <item>The result is undefined if the memory areas do overlap. Use
2875 <tt/<ref id="memmove" name="memmove">/ to copy overlapping memory areas.
2876 <item>The function is only available as fastcall function, so it may only
2877 be used in presence of a prototype.
2879 <tag/Availability/ISO 9899
2881 <ref id="_swap" name="_swap">,
2882 <ref id="memmove" name="memmove">,
2883 <ref id="memset" name="memset">
2889 <sect1>memmove<label id="memmove"><p>
2893 <tag/Function/Copy a memory area.
2894 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2895 <tag/Declaration/<tt/void* __fastcall__ memmove (void* dest, const void* src, size_t count);/
2896 <tag/Description/<tt/memmove/ copies <tt/count/ bytes from the memory area
2897 pointed to by <tt/src/ into the memory area pointed to by <tt/dest/. It returns
2901 <item>While <tt/memmove/ allows the memory areas to overlap, it has some
2902 additional overhead compared to <tt/<ref id="memcpy" name="memcpy">/.
2903 <item>The function is only available as fastcall function, so it may only
2904 be used in presence of a prototype.
2906 <tag/Availability/ISO 9899
2908 <ref id="_swap" name="_swap">,
2909 <ref id="memcpy" name="memcpy">,
2910 <ref id="memset" name="memset">
2916 <sect1>memset<label id="memset"><p>
2920 <tag/Function/Fill a memory area.
2921 <tag/Header/<tt/<ref id="string.h" name="string.h">/
2922 <tag/Declaration/<tt/void* __fastcall__ memset (void* p, int val, size_t count);/
2923 <tag/Description/<tt/memset/ fills the memory area pointed to by <tt/p/ with
2924 the value <tt/val/. The function returns <tt/p/.
2927 <item>The function is only available as fastcall function, so it may only
2928 be used in presence of a prototype.
2930 <tag/Availability/ISO 9899
2932 <ref id="_swap" name="_swap">,
2933 <ref id="bzero" name="bzero">,
2934 <ref id="memcpy" name="memcpy">,
2935 <ref id="memmove" name="memmove">
2941 <sect1>mod_free<label id="mod_free"><p>
2945 <tag/Function/Free a relocatable module.
2946 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
2947 <tag/Declaration/<tt/void __fastcall__ mod_free (void* module);/
2948 <tag/Description/The function will free a module loaded into memory by use of
2949 the <tt/<ref id="mod_load" name="mod_load">/ function.
2950 <tag/Limits/<itemize>
2951 <item>The pointer passed as parameter is the pointer to the module memory,
2952 not the pointer to the control structure.
2954 <tag/Availability/cc65
2956 <ref id="mod_load" name="mod_load">
2962 <sect1>mod_load<label id="mod_load"><p>
2966 <tag/Function/Load a relocatable module.
2967 <tag/Header/<tt/<ref id="modload.h" name="modload.h">/
2968 <tag/Declaration/<tt/unsigned char mod_load (struct mod_ctrl* ctrl);/
2969 <tag/Description/The function will load a code module into memory and relocate
2970 it. The function will return an error code. If <tt/MLOAD_OK/ is returned, the
2971 outgoing fields in the passed <tt/mod_ctrl/ struct contain information about
2972 the module just loaded. Possible error codes are:
2974 <item><tt/MLOAD_OK/ - Module load successful
2975 <item><tt/MLOAD_ERR_READ/ - Read error
2976 <item><tt/MLOAD_ERR_HDR/ - Header error
2977 <item><tt/MLOAD_ERR_OS/ - Wrong operating system
2978 <item><tt/MLOAD_ERR_FMT/ - Data format error
2979 <item><tt/MLOAD_ERR_MEM/ - Not enough memory
2981 <tag/Limits/<itemize>
2982 <item>The <htmlurl url="ld65.html" name="ld65"> linker is needed to create
2983 relocatable o65 modules for use with this function.
2985 <tag/Availability/cc65
2987 <ref id="mod_free" name="mod_free">
2993 <sect1>offsetof<label id="offsetof"><p>
2997 <tag/Function/Calculate the offset of a struct or union member.
2998 <tag/Header/<tt/<ref id="stddef.h" name="stddef.h">/
2999 <tag/Declaration/<tt/size_t offsetof (type, member);/
3000 <tag/Description/<tt/offsetof/ calculates the address offset of a <tt/struct/
3001 or <tt/union/ member.
3002 <tag/Limits/<itemize>
3003 <item>The function is actually a macro.
3005 <tag/Availability/ISO 9899
3011 <sect1>open<label id="open"><p>
3015 <tag/Function/Open and possibly create a file.
3016 <tag/Header/<tt/<ref id="fcntl.h" name="fcntl.h">/
3017 <tag/Declaration/<tt/int open (const char* name, int flags, ...);/
3018 <tag/Description/<tt/open/ opens a file and returns the file descriptor
3019 associated with it. On error, -1 is returned and an error code is stored in
3020 <tt/errno/. Several flags may be passed to <tt/open/ that change the behaviour.
3021 <tag/Limits/<itemize>
3022 <item>POSIX specifies an additional <tt/mode/ argument that may be passed to
3023 open, which is used as the permission mask when a new file is created. While
3024 cc65 allows to pass this argument, it is ignored.
3026 <tag/Availability/POSIX 1003.1
3028 <ref id="close" name="close">,
3029 <ref id="creat" name="creat">
3035 <sect1>perror<label id="perror"><p>
3039 <tag/Function/Print an error message for the error in <tt/errno/.
3040 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3041 <tag/Declaration/<tt/void __fastcall__ perror (const char* s);/
3042 <tag/Description/<tt/perror/ prints an error message to <tt/stderr/. If <tt/s/
3043 is not <tt/NULL/ and not an empty string, it is printed followed by a colon and
3044 a blank. Then the error message for the current contents of <tt/errno/ is
3045 printed followed by a newline. The message output is the same as returned by
3046 <tt/<ref id="strerror" name="strerror">/ with an argument of <tt/errno/.
3049 <item>The function is only available as fastcall function, so it may only
3050 be used in presence of a prototype.
3052 <tag/Availability/ISO 9899
3054 <ref id="_poserror" name="_poserror">,
3055 <ref id="strerror" name="strerror">,
3061 <sect1>qsort<label id="qsort"><p>
3065 <tag/Function/Sort an array.
3066 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3067 <tag/Declaration/<tt/void __fastcall__ qsort (void* base, size_t count,
3068 size_t size, int (*compare) (const void*, const void*));/
3069 <tag/Description/<tt/qsort/ sorts an array according to a given compare
3070 function <tt/compare/. <tt/base/ is the address of the array, <tt/count/
3071 is the number of elements, <tt/size/ the size of an element and <tt/compare/
3072 the function used to compare the members.
3075 <item>If there are multiple members with the same key, the order after calling
3076 the function is undefined.
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="bsearch" name="bsearch">
3088 <sect1>raise<label id="raise"><p>
3092 <tag/Function/Send a signal to the executing program.
3093 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
3094 <tag/Declaration/<tt/int __fastcall__ raise (int sig);/
3095 <tag/Description/<tt/raise/ sends the given signal to the program. If the
3096 program has installed a signal handler for the signal, this signal handler
3097 will be executed. If no handler has been installed, the default action for
3098 the raised signal will be taken. The function returns zero on success,
3100 <tag/Limits/<itemize>
3101 <item>The function is only available as fastcall function, so it may only
3102 be used in presence of a prototype.
3104 <tag/Availability/ISO 9899
3106 <ref id="abort" name="abort">,
3107 <ref id="signal" name="signal">
3113 <sect1>rand<label id="rand"><p>
3117 <tag/Function/Return a pseudo random number.
3118 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3119 <tag/Declaration/<tt/int rand (void);/
3120 <tag/Description/The function returns a pseudo random number
3121 between 0 and <tt/RAND_MAX/ (exclusive).
3122 <tag/Limits/<itemize>
3123 <item>Without using <tt><ref id="srand" name="srand"></tt>, always the same
3124 flow of numbers is generated.
3125 <item>On startup, the function behaves as if <ref id="srand" name="srand">
3126 had been used with an argument of 1.
3128 <tag/Availability/ISO 9899
3130 <ref id="_randomize" name="_randomize">,
3131 <ref id="srand" name="srand">
3137 <sect1>realloc<label id="realloc"><p>
3141 <tag/Function/Change the size of an allocated memory block.
3142 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3143 <tag/Declaration/<tt/void* __fastcall__ realloc (void* block, size_t size);/
3144 <tag/Description/<tt/realloc/ changes the size of the memory block pointed to
3145 by <tt/block/ to <tt/size/ bytes. If <tt/block/ is <tt/NULL/, <tt/realloc/
3146 behaves as if <tt/malloc/ had been called. If <tt/size/ is zero, <tt/realloc/
3147 behaves as if <tt/free/ had been called. On error (not enough memory
3148 available), <tt/realloc/ returns <tt/NULL/.
3151 <item>The part of the memory block that is returned will have its contents
3153 <item>This function is somewhat dangerous to use. Be careful to save the
3154 pointer you're passing somewhere else, otherwise
3156 ptr = realloc (ptr, size);
3158 will loose your only copy of <tt/ptr/ if <tt/realloc/ returns <tt/NULL/.
3159 <item>The function is only available as fastcall function, so it may only
3160 be used in presence of a prototype.
3162 <tag/Availability/ISO 9899
3164 <ref id="_heapadd" name="_heapadd">,
3165 <ref id="_heapblocksize" name="_heapblocksize">,
3166 <ref id="_heapmaxavail" name="_heapmaxavail">,
3167 <ref id="_heapmemavail" name="_heapmemavail">,
3168 <ref id="calloc" name="calloc">,
3169 <ref id="free" name="free">,
3170 <ref id="realloc" name="realloc">
3176 <sect1>remove<label id="remove"><p>
3180 <tag/Function/Delete a file.
3181 <tag/Header/<tt/<ref id="stdio.h" name="stdio.h">/
3182 <tag/Declaration/<tt/int __fastcall__ remove (const char* name);/
3183 <tag/Description/<tt/remove/ deletes the file with the given name. On success,
3184 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
3185 code describing the reason for the failure.
3188 <item>This function is not available on all cc65 targets (depends on the
3189 availability of file I/O).
3190 <item>The function is only available as fastcall function, so it may only
3191 be used in presence of a prototype.
3193 <tag/Availability/ISO 9899
3195 <ref id="unlink" name="unlink">
3197 #include <stdio.h>
3199 #define FILENAME "helloworld"
3201 if (remove (FILENAME) == 0) {
3202 printf ("We deleted %s successfully\n", FILENAME);
3204 printf ("There was a problem deleting %s\n", FILENAME);
3210 <sect1>reset_brk<label id="reset_brk"><p>
3214 <tag/Function/Resets the break vector to its original value.
3215 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3216 <tag/Declaration/<tt/void __fastcall__ reset_brk (void);/
3217 <tag/Description/<tt/reset_brk/ resets the break vector to the value it had
3218 before a call to <tt/set_brk/.
3221 <item>Since <tt/<ref id="set_brk" name="set_brk">/ installs an exit handler,
3222 it is not strictly necessary to call this function as part of the cleanup when
3225 <tag/Availability/cc65
3227 <ref id="set_brk" name="set_brk">
3233 <sect1>revers<label id="revers"><p>
3237 <tag/Function/Control revers character display.
3238 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3239 <tag/Declaration/<tt/unsigned char __fastcall__ revers (unsigned char onoff);/
3240 <tag/Description/If the argument is non zero, the function enables reverse
3241 character display. If the argument is zero, reverse character display is
3242 switched off. The old value of the setting is returned.
3243 <tag/Limits/<itemize>
3244 <item>The function may not be supported by the hardware, in which case
3245 the call is ignored.
3246 <item>The function is only available as fastcall function, so it may only
3247 be used in presence of a prototype.
3249 <tag/Availability/cc65
3251 <ref id="textcolor" name="textcolor">
3257 <sect1>screensize<label id="screensize"><p>
3261 <tag/Function/Return the dimensions of the text mode screen.
3262 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3263 <tag/Declaration/<tt/void __fastcall__ screensize (unsigned char* x, unsigned char* y);/
3264 <tag/Description/The function returns the dimensions of the text mode screen.
3265 <tag/Limits/<itemize>
3266 <item>The function is only available as fastcall function, so it may only
3267 be used in presence of a prototype.
3269 <tag/Availability/cc65
3271 <ref id="gotox" name="gotox">,
3272 <ref id="gotoxy" name="gotoxy">,
3273 <ref id="gotoy" name="gotoy">,
3274 <ref id="wherex" name="wherex">,
3275 <ref id="wherey" name="wherey">
3281 <sect1>set_brk<label id="set_brk"><p>
3285 <tag/Function/Set the break vector to a user function.
3286 <tag/Header/<tt/<ref id="6502.h" name="6502.h">/
3287 <tag/Declaration/<tt/void __fastcall__ set_brk (brk_handler func);/
3288 <tag/Description/<tt/set_brk/ allows a user program to handle breaks within the
3289 program code by letting the vector point to a user written C function. The
3290 runtime library installs a small stub that saves the registers into global
3291 variables that may be accessed (and changed) by the break handler.
3294 <item>The function is only available as fastcall function, so it may only
3295 be used in presence of a prototype.
3296 <item>The stub saves the zero page registers used by the C runtime and switches
3297 to a small break handler stack. This means that it is safe to execute C code,
3298 even if C code was interrupted. Be careful however not to use too many local
3299 variables, and do not enable stack checks for the handler function or any other
3300 function called from it.
3301 <item>The <tt/brk_pc/ variable points to the <tt/BRK/ instruction. If you want
3302 the continue with the interrupted code, you have to adjust <tt/brk_pc/,
3303 otherwise the <tt/BRK/ instruction will get executed over and over again.
3304 <item>Since <tt/set_brk/ installs an exit handler, it is not strictly necessary
3305 to call <tt/<ref id="reset_brk" name="reset_brk">/ as part of the cleanup when
3306 the program terminates.
3308 <tag/Availability/cc65
3310 <ref id="reset_brk" name="reset_brk">
3316 <sect1>setjmp<label id="setjmp"><p>
3320 <tag/Function/Save the context for use with <tt/longjmp/.
3321 <tag/Header/<tt/<ref id="setjmp.h" name="setjmp.h">/
3322 <tag/Declaration/<tt/int __fastcall__ setjmp (jmp_buf buf);/
3323 <tag/Description/The <tt/setjmp/ function saves the current context in <tt/buf/
3324 for subsequent use by the <tt/<ref id="longjmp" name="longjmp">/ function and
3328 <item>The function is only available as fastcall function, so it may only
3329 be used in presence of a prototype.
3330 <item><tt/setjmp/ is actually a macro as required by the ISO standard.
3331 <item><tt/setjmp/ will not save the signal context.
3333 <tag/Availability/ISO 9899
3335 <ref id="longjmp" name="longjmp">
3341 <sect1>setlocale<label id="setlocale"><p>
3345 <tag/Function/Selects a locale.
3346 <tag/Header/<tt/<ref id="locale.h" name="locale.h">/
3347 <tag/Declaration/<tt/char* __fastcall__ setlocale (int category, const char* locale);/
3348 <tag/Description/<tt/setlocale/ sets or queries the program's locale.
3351 <item>The function is only available as fastcall function, so it may only
3352 be used in presence of a prototype.
3353 <item>cc65 supports only the "C" locale, so calling this function to set a
3354 different locale has no effect.
3356 <tag/Availability/ISO 9899
3358 <ref id="localeconv" name="localeconv">,
3359 <ref id="strcoll" name="strcoll">
3365 <sect1>signal<label id="signal"><p>
3369 <tag/Function/Install a signal handler.
3370 <tag/Header/<tt/<ref id="signal.h" name="signal.h">/
3371 <tag/Declaration/<tt/__sigfunc __fastcall__ signal (int sig, __sigfunc func);/
3372 <tag/Description/<tt/signal/ installs a handler for the given signal. The
3373 handler may either be a user supplied function, or one of the predefined
3374 signal handlers <tt/SIG_IGN/ or <tt/SIG_DFL/. The function returns the
3375 previous value if the signal , or the special function vector SIG_ERR in
3377 <tag/Limits/<itemize>
3378 <item>The function is only available as fastcall function, so it may only
3379 be used in presence of a prototype.
3381 <tag/Availability/ISO 9899
3383 <ref id="abort" name="abort">,
3384 <ref id="raise" name="raise">
3390 <sect1>sleep<label id="sleep"><p>
3394 <tag/Function/Sleep for a specified amount of time.
3395 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
3396 <tag/Declaration/<tt/void __fastcall__ sleep (unsigned seconds);/
3397 <tag/Description/The function will return after the specified number of
3398 seconds have elapsed.
3399 <tag/Limits/<itemize>
3400 <item>The function is only available as fastcall function, so it may only
3401 be used in presence of a prototype.
3403 <tag/Availability/POSIX 1003.1
3409 <sect1>slow<label id="slow"><p>
3413 <tag/Function/Switch the C128 into 1MHz mode.
3414 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
3415 <tag/Declaration/<tt/void slow (void);/
3416 <tag/Description/The function will switch the clock of the C128 to 1MHz. This
3417 will halve the speed compared to fast mode.
3418 <tag/Limits/<itemize>
3419 <item>The function is specific to the C128.
3421 <tag/Availability/C128
3423 <ref id="fast" name="fast">,
3424 <ref id="toggle_videomode" name="toggle_videomode">
3430 <sect1>srand<label id="srand"><p>
3434 <tag/Function/Initialize the pseudo random number generator.
3435 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
3436 <tag/Declaration/<tt/void __fastcall__ srand (unsigned seed);/
3437 <tag/Description/The function initializes the random number generator using
3438 the given seed. On program startup, the generator behaves as if <tt/srand/ has
3439 been called with an argument of 1.
3440 <tag/Limits/<itemize>
3441 <item>The function is only available as fastcall function, so it may only
3442 be used in presence of a prototype.
3444 <tag/Availability/ISO 9899
3446 <ref id="_randomize" name="_randomize">,
3447 <ref id="rand" name="rand">
3453 <sect1>strcasecmp<label id="strcasecmp"><p>
3457 <tag/Function/Compare two strings case insensitive.
3458 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3459 <tag/Declaration/<tt/int __fastcall__ strcasecmp (const char* s1, const char* s2);/
3460 <tag/Description/The <tt/strcasecmp/ function compares the two strings passed
3461 as parameters without case sensitivity. It returns a value that is less than
3462 zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/,
3463 and a value greater than zero if <tt/s1/ is greater than <tt/s2/.
3464 <tag/Limits/<itemize>
3465 <item>The function is only available as fastcall function, so it may only
3466 be used in presence of a prototype.
3467 <item>The function is not available in strict ANSI mode.
3469 <tag/Availability/cc65
3471 <ref id="strcmp" name="strcmp">,
3472 <ref id="strcoll" name="strcoll">,
3473 <ref id="stricmp" name="stricmp">,
3474 <ref id="strncmp" name="strncmp">
3480 <sect1>strcat<label id="strcat"><p>
3484 <tag/Function/Concatentate two strings.
3485 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3486 <tag/Declaration/<tt/char* __fastcall__ strcat (char* s1, const char* s2);/
3487 <tag/Description/The <tt/strcat/ function appends a copy of the string
3488 pointed to by s2 (including the terminating null byte) to the end of the
3489 string pointed to by s1. The initial byte of s2 overwrites the null byte at
3491 <tag/Limits/<itemize>
3492 <item>The function is only available as fastcall function, so it may only
3493 be used in presence of a prototype.
3494 <item>If copying takes place between objects that overlap, the behaviour
3497 <tag/Availability/ISO 9899
3499 <ref id="strcpy" name="strcpy">,
3500 <ref id="strncat" name="strncat">,
3501 <ref id="strncpy" name="strncpy">
3507 <sect1>strchr<label id="strchr"><p>
3511 <tag/Function/Search for a character in a string.
3512 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3513 <tag/Declaration/<tt/char* __fastcall__ strchr (const char* s, int c);/
3514 <tag/Description/The <tt/strchr/ function locates the first occurrence of <tt/c/
3515 (converted to a char) in the string pointed to by <tt/s/. The terminating null
3516 byte is considered to be part of the string. Upon completion, the function
3517 returns a pointer to the byte, or a null pointer if the byte was not found.
3518 <tag/Limits/<itemize>
3519 <item>The function is only available as fastcall function, so it may only
3520 be used in presence of a prototype.
3522 <tag/Availability/ISO 9899
3524 <ref id="memchr" name="memchr">,
3525 <ref id="strrchr" name="strrchr">
3531 <sect1>strcmp<label id="strcmp"><p>
3535 <tag/Function/Compare two strings.
3536 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3537 <tag/Declaration/<tt/int __fastcall__ strcmp (const char* s1, const char* s2);/
3538 <tag/Description/The <tt/strcmp/ function compares the two strings passed as
3539 parameters. It returns a value that is less than zero if <tt/s1/ is less than
3540 <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater than zero
3541 if <tt/s1/ is greater than <tt/s2/.
3542 <tag/Limits/<itemize>
3543 <item>The function is only available as fastcall function, so it may only
3544 be used in presence of a prototype.
3546 <tag/Availability/ISO 9899
3548 <ref id="strcasecmp" name="strcasecmp">,
3549 <ref id="strcoll" name="strcoll">,
3550 <ref id="stricmp" name="stricmp">,
3551 <ref id="strncmp" name="strncmp">
3557 <sect1>strcoll<label id="strcoll"><p>
3561 <tag/Function/Compare two strings.
3562 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3563 <tag/Declaration/<tt/int __fastcall__ strcoll (const char* s1, const char* s2);/
3564 <tag/Description/The <tt/strcoll/ function compares the two strings passed as
3565 parameters, according to the collating sequence set by <tt/<ref id="setlocale"
3566 name="setlocale">/. It returns a value that is less than zero if <tt/s1/ is
3567 less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a value greater
3568 than zero if <tt/s1/ is greater than <tt/s2/.
3569 <tag/Limits/<itemize>
3570 <item>The function is only available as fastcall function, so it may only
3571 be used in presence of a prototype.
3573 <tag/Availability/ISO 9899
3575 <ref id="setlocale" name="setlocale">,
3576 <ref id="strcasecmp" name="strcasecmp">,
3577 <ref id="strcmp" name="strcmp">,
3578 <ref id="stricmp" name="stricmp">,
3579 <ref id="strncmp" name="strncmp">
3585 <sect1>strcpy<label id="strcpy"><p>
3589 <tag/Function/Copy a string.
3590 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3591 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2);/
3592 <tag/Description/The <tt/strcpy/ function copies the string pointed to by
3593 <tt/s2/ (including the terminating null byte) into the array pointed to by
3594 <tt/s1/. The function will always return <tt/s1/.
3595 <tag/Limits/<itemize>
3596 <item>The function is only available as fastcall function, so it may only
3597 be used in presence of a prototype.
3598 <item>If copying takes place between objects that overlap, the behaviour
3601 <tag/Availability/ISO 9899
3603 <ref id="strcat" name="strcat">,
3604 <ref id="strncat" name="strncat">,
3605 <ref id="strncpy" name="strncpy">
3608 #include <string.h>
3610 static char hello[14];
3612 strcpy (hello, "Hello world!\n");
3618 <sect1>strcspn<label id="strcspn"><p>
3622 <tag/Function/Compute the length of a substring.
3623 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3624 <tag/Declaration/<tt/size_t __fastcall__ strcspn (const char* s, const char* set);/
3625 <tag/Description/The <tt/strcspn/ function computes and returns the length of
3626 the substring pointed to by <tt/s/ which does <em>not</em> consist of
3627 characters contained in the string <tt/set/.
3628 <tag/Limits/<itemize>
3629 <item>The function is only available as fastcall function, so it may only
3630 be used in presence of a prototype.
3632 <tag/Availability/ISO 9899
3634 <ref id="strspn" name="strspn">,
3635 <ref id="strstr" name="strstr">
3641 <sect1>strdup<label id="strdup"><p>
3645 <tag/Function/Allocate a copy of a string on the heap.
3646 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3647 <tag/Declaration/<tt/char* __fastcall__ strdup (const char* s);/
3648 <tag/Description/<tt/strdup/ allocates a memory block on the heap, big enough
3649 to hold a copy of <tt/s/ including the terminating zero. If the allocation
3650 fails, <tt/NULL/ is returned, otherwise <tt/s/ is copied into the allocated
3651 memory block, and a pointer to the block is returned.
3652 <tag/Limits/<itemize>
3653 <item>The function is only available as fastcall function, so it may only
3654 be used in presence of a prototype.
3655 <item>It is up to the caller to free the allocated memory block.
3657 <tag/Availability/ISO 9899
3659 <ref id="free" name="free">,
3660 <ref id="malloc" name="malloc">
3666 <sect1>strerror<label id="strerror"><p>
3670 <tag/Function/Return a string describing an error code.
3671 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3672 <tag/Declaration/<tt/char* __fastcall__ strerror (int errcode);/
3673 <tag/Description/The <tt/strerror/ function returns a string describing the
3674 given error code. If an invalid error code is passed, the string "Unknown
3675 error" is returned, and <tt/errno/ is set to <tt/EINVAL/. In all other cases,
3676 <tt/errno/ is left untouched.
3677 <tag/Limits/<itemize>
3678 <item>The function is only available as fastcall function, so it may only
3679 be used in presence of a prototype.
3680 <item>While the return type of the function is a <tt/char*/, the returned
3681 string must not be modified by the caller!
3683 <tag/Availability/ISO 9899
3685 <ref id="_stroserror" name="_stroserror">
3691 <sect1>stricmp<label id="stricmp"><p>
3695 <tag/Function/Compare two strings case insensitive.
3696 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3697 <tag/Declaration/<tt/int __fastcall__ stricmp (const char* s1, const char* s2);/
3698 <tag/Description/The <tt/stricmp/ function compares the two strings passed as
3699 parameters without case sensitivity. It returns a value that is less than zero
3700 if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a
3701 value greater than zero if <tt/s1/ is greater than <tt/s2/.
3702 <tag/Limits/<itemize>
3703 <item>The function is only available as fastcall function, so it may only
3704 be used in presence of a prototype.
3705 <item>The function is not available in strict ANSI mode.
3707 <tag/Availability/cc65
3709 <ref id="strcasecmp" name="strcasecmp">,
3710 <ref id="strcmp" name="strcmp">,
3711 <ref id="strcoll" name="strcoll">,
3712 <ref id="strncmp" name="strncmp">
3718 <sect1>strlen<label id="strlen"><p>
3722 <tag/Function/Return the length of a string.
3723 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3724 <tag/Declaration/<tt/size_t __fastcall__ strlen (const char* s);/
3725 <tag/Description/The <tt/strlen/ function computes the number of bytes in the
3726 string to which s points, not including the terminating null byte.
3727 <tag/Limits/<itemize>
3728 <item>The function is only available as fastcall function, so it may only
3729 be used in presence of a prototype.
3730 <item>When compiling with <tt/-Os/ (inline known standard functions), the
3731 function does not work correctly for strings with more than 255 characters.
3733 <tag/Availability/ISO 9899
3735 <ref id="strcpy" name="strcpy">
3741 <sect1>strlower<label id="strlower"><p>
3745 <tag/Function/Make a string lower case.
3746 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3747 <tag/Declaration/<tt/char* __fastcall__ strlower (char* s);/
3748 <tag/Description/The <tt/strlower/ function will apply the <tt/tolower/
3749 function to each character of a string. The function will always return <tt/s/.
3750 <tag/Limits/<itemize>
3751 <item>The function is only available as fastcall function, so it may only
3752 be used in presence of a prototype.
3753 <item>The function prototype is unavailable when compiling in strict ANSI mode.
3754 <item>An alias name for this function is <tt/strlwr/.
3756 <tag/Availability/cc65
3758 <ref id="strupper" name="strupper">,
3759 <ref id="tolower" name="tolower">
3765 <sect1>strlwr<label id="strlwr"><p>
3772 <sect1>strncat<label id="strncat"><p>
3776 <tag/Function/Concatentate two strings.
3777 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3778 <tag/Declaration/<tt/char* __fastcall__ strncat (char* s1, const char* s2, size_t n);/
3779 <tag/Description/The <tt/strncat/ function appends not more than n characters
3780 of the string pointed to by s2 to the end of the string pointed to by s1. The
3781 terminating null character at the end of s1 is overwritten. A terminating null
3782 character is appended to the result, even if not all of s2 is appended to s1.
3783 <tag/Limits/<itemize>
3784 <item>The function is only available as fastcall function, so it may only
3785 be used in presence of a prototype.
3786 <item>If copying takes place between objects that overlap, the behaviour
3789 <tag/Availability/ISO 9899
3791 <ref id="strcpy" name="strcpy">,
3792 <ref id="strncat" name="strncat">,
3793 <ref id="strncpy" name="strncpy">
3799 <sect1>strncmp<label id="strncmp"><p>
3803 <tag/Function/Compare two strings.
3804 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3805 <tag/Declaration/<tt/int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);/
3806 <tag/Description/The <tt/strncmp/ function compares not more than <tt/count/
3807 characters of the two strings passed as parameters. It returns a value that is
3808 less than zero if the first <tt/count/ characters of <tt/s1/ are less than
3809 <tt/s2/, zero if they are identical, and a value greater than zero they are
3811 <tag/Limits/<itemize>
3812 <item>The function is only available as fastcall function, so it may only
3813 be used in presence of a prototype.
3815 <tag/Availability/ISO 9899
3817 <ref id="strcasecmp" name="strcasecmp">,
3818 <ref id="strcmp" name="strcmp">,
3819 <ref id="strcoll" name="strcoll">,
3820 <ref id="stricmp" name="stricmp">
3826 <sect1>strncpy<label id="strncpy"><p>
3830 <tag/Function/Copy part of a string.
3831 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3832 <tag/Declaration/<tt/char* __fastcall__ strcpy (char* s1, const char* s2, size_t n);/
3833 <tag/Description/The <tt/strncpy/ function copies not more than n bytes from
3834 the array pointed to by <tt/s2/ to the array pointed to by <tt/s1/. If the array
3835 pointed to by <tt/s2/ is a string that is shorter than n bytes, null bytes are
3836 appended to the copy in the array pointed to by <tt/s1/, until <tt/n/ bytes are
3837 written. The function will always return <tt/s1/.
3838 <tag/Limits/<itemize>
3839 <item>The function is only available as fastcall function, so it may only
3840 be used in presence of a prototype. If there is no null byte in the first <tt/n/
3841 bytes of the array pointed to by <tt/s2/, the result is not null-terminated.
3842 <item>If copying takes place between objects that overlap, the behaviour is
3845 <tag/Availability/ISO 9899
3847 <ref id="strcat" name="strcat">,
3848 <ref id="strcpy" name="strcpy">,
3849 <ref id="strncat" name="strncat">
3854 static char hello[6];
3856 strcpy (hello, "Hello world!\n", sizeof (hello) - 1);
3863 <sect1>strrchr<label id="strrchr"><p>
3867 <tag/Function/Search for a character in a string.
3868 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3869 <tag/Declaration/<tt/char* __fastcall__ strrchr (const char* s, int c);/
3870 <tag/Description/The <tt/strrchr/ function locates the last occurrence of <tt/c/
3871 (converted to a char) in the string pointed to by <tt/s/. The terminating null
3872 byte is considered to be part of the string. Upon completion, the function
3873 returns a pointer to the byte, or a null pointer if the byte was not found.
3874 <tag/Limits/<itemize>
3875 <item>The function is only available as fastcall function, so it may only
3876 be used in presence of a prototype.
3878 <tag/Availability/ISO 9899
3880 <ref id="strchr" name="strchr">
3886 <sect1>strspn<label id="strspn"><p>
3890 <tag/Function/Compute the length of a substring.
3891 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3892 <tag/Declaration/<tt/size_t __fastcall__ strspn (const char* s, const char* set);/
3893 <tag/Description/The <tt/strspn/ function computes and returns the length of
3894 the substring pointed to by <tt/s/ which does consist only of characters
3895 contained in the string <tt/set/.
3896 <tag/Limits/<itemize>
3897 <item>The function is only available as fastcall function, so it may only
3898 be used in presence of a prototype.
3900 <tag/Availability/ISO 9899
3902 <ref id="strcspn" name="strcspn">,
3903 <ref id="strstr" name="strstr">
3909 <sect1>strstr<label id="strstr"><p>
3913 <tag/Function/Find a substring.
3914 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3915 <tag/Declaration/<tt/char* __fastcall__ strstr (const char* str, const char* substr);/
3916 <tag/Description/<tt/strstr/ searches for the first occurance of the string
3917 <tt/substr/ within <tt/str/. If found, it returns a pointer to the copy,
3918 otherwise it returns <tt/NULL/.
3919 <tag/Limits/<itemize>
3920 <item>The function is only available as fastcall function, so it may only
3921 be used in presence of a prototype.
3923 <tag/Availability/ISO 9899
3925 <ref id="strcspn" name="strcspn">,
3926 <ref id="strspn" name="strspn">
3932 <sect1>strupper<label id="strupper"><p>
3936 <tag/Function/Make a string upper case.
3937 <tag/Header/<tt/<ref id="string.h" name="string.h">/
3938 <tag/Declaration/<tt/char* __fastcall__ strupper (char* s);/
3939 <tag/Description/The <tt/strupper/ function will apply the <tt/toupper/
3940 function to each character of a string. The function will always return <tt/s/.
3941 <tag/Limits/<itemize>
3942 <item>The function is only available as fastcall function, so it may only
3943 be used in presence of a prototype.
3944 <item>The function prototype is unavailable when compiling in strict ANSI mode.
3945 <item>An alias name for this function is <tt/strupr/.
3947 <tag/Availability/cc65
3949 <ref id="strlower" name="strlower">
3950 <ref id="toupper" name="toupper">
3956 <sect1>strupr<label id="strupr"><p>
3963 <sect1>textcolor<label id="textcolor"><p>
3967 <tag/Function/Set the text color.
3968 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
3969 <tag/Declaration/<tt/unsigned char __fastcall__ textcolor (unsigned char color);/
3970 <tag/Description/The function will set a new text color. It returns the old
3971 (current) text color. Text output using any <tt/conio.h/ function will use
3972 the color set by this function.
3973 <tag/Limits/<itemize>
3974 <item>Text colors are system dependent. The function may have no effect
3975 on systems where the text color cannot be changed.
3976 <item>The function is only available as fastcall function, so it may only
3977 be used in presence of a prototype.
3979 <tag/Availability/cc65
3981 <ref id="bgcolor" name="bgcolor">,
3982 <ref id="bordercolor" name="bordercolor">
3988 <sect1>time<label id="time"><p>
3992 <tag/Function/Get the time.
3993 <tag/Header/<tt/<ref id="time.h" name="time.h">/
3994 <tag/Declaration/<tt/time_t __fastcall__ time (time_t* t);/
3995 <tag/Description/The function returns the time since the 1970-01-01 00:00:00
3996 measured in seconds. If the pointer <tt/t/ is not <tt/NULL/, the function
3997 result will also be stored there. If no time is available, <tt/(time_t)-1/ is
3998 returned and <tt/errno/ is set to <tt/ENOSYS/.
3999 <tag/Limits/<itemize>
4000 <item>The function is only available as fastcall function, so it may
4001 only be used in presence of a prototype.
4002 <item>Many platforms supported by cc65 do not have a realtime clock, so the
4003 returned value may not be valid.
4005 <tag/Availability/ISO 9899
4011 <sect1>toggle_videomode<label id="toggle_videomode"><p>
4015 <tag/Function/Toggle between 40 and 80 column mode.
4016 <tag/Header/<tt/<ref id="c128.h" name="c128.h">/
4017 <tag/Declaration/<tt/void toggle_videomode (void);/
4018 <tag/Description/Toggle between 40 and 80 column mode. The settings for the
4019 old mode (cursor position, color and so on) are saved and restored together
4021 <tag/Limits/<itemize>
4022 <item>The function is specific to the C128.
4024 <tag/Availability/C128
4026 <ref id="fast" name="fast">,
4027 <ref id="slow" name="slow">
4033 <sect1>tolower<label id="tolower"><p>
4037 <tag/Function/Convert a character into its lower case representation.
4038 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4039 <tag/Declaration/<tt/int __fastcall__ tolower (int c);/
4040 <tag/Description/The function returns the given character converted to lower
4041 case. If the given character is not a letter, it is returned unchanged.
4042 <tag/Limits/<itemize>
4043 <item>The function is only available as fastcall function, so it may
4044 only be used in presence of a prototype.
4046 <tag/Availability/ISO 9899
4048 <ref id="islower" name="islower">,
4049 <ref id="isupper" name="isupper">,
4050 <ref id="toupper" name="toupper">
4056 <sect1>toupper<label id="toupper"><p>
4060 <tag/Function/Convert a character into its upper case representation.
4061 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
4062 <tag/Declaration/<tt/int __fastcall__ toupper (int c);/
4063 <tag/Description/The function returns the given character converted to upper
4064 case. If the given character is not a letter, it is returned unchanged.
4065 <tag/Limits/<itemize>
4066 <item>The function is only available as fastcall function, so it may
4067 only be used in presence of a prototype.
4069 <tag/Availability/ISO 9899
4071 <ref id="islower" name="islower">,
4072 <ref id="isupper" name="isupper">,
4073 <ref id="tolower" name="tolower">
4079 <sect1>ultoa<label id="ultoa"><p>
4083 <tag/Function/Convert an unsigned long integer into a string.
4084 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4085 <tag/Declaration/<tt/char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);/
4086 <tag/Description/<tt/itoa/ converts the unsigned long integer <tt/val/ into a
4087 string using <tt/radix/ as the base.
4088 <tag/Limits/<itemize>
4089 <item>There are no provisions to prevent a buffer overflow.
4090 <item>The function is non standard, so it is not available in strict ANSI mode.
4091 You should probably use <tt/sprintf/ instead.
4092 <item>The function is only available as fastcall function, so it may only be
4093 used in presence of a prototype.
4095 <tag/Availability/cc65
4097 <ref id="atoi" name="atoi">,
4098 <ref id="atol" name="atol">,
4099 <ref id="itoa" name="itoa">,
4100 <ref id="ltoa" name="ltoa">,
4101 <ref id="utoa" name="utoa">
4107 <sect1>unlink<label id="unlink"><p>
4111 <tag/Function/Delete a file.
4112 <tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/
4113 <tag/Declaration/<tt/int __fastcall__ unlink (const char* name);/
4114 <tag/Description/<tt/unlink/ deletes the file with the given name. On success,
4115 zero is returned. On error, -1 is returned and <tt/errno/ is set to an error
4116 code describing the reason for the failure.
4119 <item>The use of this function is discouraged. Please use <tt/<ref id="remove"
4120 name="remove">/ instead, which is a native ANSI C function and does the same.
4121 <item>This function is not available on all cc65 targets (depends on the
4122 availability of file I/O).
4123 <item>The function is only available as fastcall function, so it may only
4124 be used in presence of a prototype.
4125 <item>Instead of <tt/unlink/, <tt/<ref id="remove" name="remove">/ should be
4126 used, which has the same semantics, but is more portable, because it conforms
4127 to the ISO C standard.
4129 <tag/Availability/POSIX 1003.1
4131 <ref id="remove" name="remove">
4133 #include <stdio.h>
4134 #include <unistd.h>
4136 #define FILENAME "helloworld"
4138 if (unlink (FILENAME) == 0) {
4139 printf ("We deleted %s successfully\n", FILENAME);
4141 printf ("There was a problem deleting %s\n", FILENAME);
4147 <sect1>utoa<label id="utoa"><p>
4151 <tag/Function/Convert an unsigned integer into a string.
4152 <tag/Header/<tt/<ref id="stdlib.h" name="stdlib.h">/
4153 <tag/Declaration/<tt/char* __fastcall__ utoa (unsigned val, char* buf, int radix);/
4154 <tag/Description/<tt/itoa/ converts the unsigned integer <tt/val/ into a string
4155 using <tt/radix/ as the base.
4156 <tag/Limits/<itemize>
4157 <item>There are no provisions to prevent a buffer overflow.
4158 <item>The function is non standard, so it is not available in strict ANSI mode.
4159 You should probably use <tt/sprintf/ instead.
4160 <item>The function is only available as fastcall function, so it may only be
4161 used in presence of a prototype.
4163 <tag/Availability/cc65
4165 <ref id="atoi" name="atoi">,
4166 <ref id="atol" name="atol">,
4167 <ref id="itoa" name="itoa">,
4168 <ref id="ltoa" name="ltoa">,
4169 <ref id="ultoa" name="ultoa">
4175 <sect1>vcprintf<label id="vcprintf"><p>
4179 <tag/Function/Formatted output to the console.
4180 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4181 <tag/Declaration/<tt/int __fastcall__ vcprintf (const char* format, va_list ap);/
4182 <tag/Description/The arguments specified as a <tt/va_list/ are converted to
4183 text where necessary and formatted according to the format string given. The
4184 resulting string is output to the console. <tt/vcprintf/ supports the same
4185 format specifiers as <tt/vprintf/. <!-- <tt/<ref id="vprintf" name="vprintf">/. -->
4186 <tag/Limits/<itemize>
4187 <item>Like all other <tt/conio/ output functions, <tt/vcprintf/ distinguishes
4188 between <tt/\r/ and <tt/\n/.
4189 <item>The function is only available as fastcall function, so it may only be
4190 used in presence of a prototype.
4192 <tag/Availability/cc65
4194 <ref id="cprintf" name="cprintf">,
4195 <ref id="cputc" name="cputc">,
4196 <ref id="cputcxy" name="cputcxy">,
4197 <ref id="cputs" name="cputs">,
4198 <ref id="cputsxy" name="cputsxy">
4204 <sect1>wherex<label id="wherex"><p>
4208 <tag/Function/Return the current X position of the text mode cursor.
4209 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4210 <tag/Declaration/<tt/unsigned char wherex (void);/
4211 <tag/Description/The function returns the current X position of the text mode
4212 cursor. Zero is returned for the leftmost screen position.
4213 <tag/Availability/cc65
4215 <ref id="gotox" name="gotox">,
4216 <ref id="gotoy" name="gotoy">,
4217 <ref id="gotoxy" name="gotoxy">,
4218 <ref id="wherey" name="wherey">
4224 <sect1>wherey<label id="wherey"><p>
4228 <tag/Function/Return the current Y position of the text mode cursor.
4229 <tag/Header/<tt/<ref id="conio.h" name="conio.h">/
4230 <tag/Declaration/<tt/unsigned char wherey (void);/
4231 <tag/Description/The function returns the current Y position of the text mode
4232 cursor. Zero is returned for the uppermost screen position.
4233 <tag/Availability/cc65
4235 <ref id="gotox" name="gotox">,
4236 <ref id="gotoy" name="gotoy">,
4237 <ref id="gotoxy" name="gotoxy">,
4238 <ref id="wherex" name="wherex">