├── ArdionoHostToSerial └── ArdionoHostToSerial.ino ├── CH559.h ├── CH559USB.bin ├── CH559USB.hex ├── LICENSE ├── README.md ├── SDCC ├── bin │ ├── as2gbmap.cmd │ ├── hex2bin.exe │ ├── libgcc_s_seh-1.dll │ ├── libgcc_s_sjlj-1.dll │ ├── libstdc++-6.dll │ ├── libwinpthread-1.dll │ ├── makebin.exe │ ├── packihx.exe │ ├── readline5.dll │ ├── s51.exe │ ├── sdar.exe │ ├── sdas390.exe │ ├── sdas6808.exe │ ├── sdas8051.exe │ ├── sdasgb.exe │ ├── sdaspdk13.exe │ ├── sdaspdk14.exe │ ├── sdaspdk15.exe │ ├── sdasrab.exe │ ├── sdasstm8.exe │ ├── sdastlcs90.exe │ ├── sdasz80.exe │ ├── sdcc.exe │ ├── sdcdb.el │ ├── sdcdb.exe │ ├── sdcdbsrc.el │ ├── sdcpp.exe │ ├── sdld.exe │ ├── sdld6808.exe │ ├── sdldgb.exe │ ├── sdldpdk.exe │ ├── sdldstm8.exe │ ├── sdldz80.exe │ ├── sdnm.exe │ ├── sdobjcopy.exe │ ├── sdranlib.exe │ ├── shc08.exe │ ├── spdk.exe │ ├── sstm8.exe │ ├── stlcs.exe │ └── sz80.exe ├── include │ ├── asm │ │ ├── default │ │ │ └── features.h │ │ ├── mcs51 │ │ │ └── features.h │ │ └── temp.txt │ ├── assert.h │ ├── ctype.h │ ├── ds80c390.h │ ├── errno.h │ ├── float.h │ ├── iso646.h │ ├── limits.h │ ├── math.h │ ├── mcs51 │ │ ├── 8051.h │ │ ├── 8052.h │ │ ├── ADuC84x.h │ │ ├── AT89C513xA.h │ │ ├── C8051F000.h │ │ ├── C8051F018.h │ │ ├── C8051F020.h │ │ ├── C8051F040.h │ │ ├── C8051F060.h │ │ ├── C8051F120.h │ │ ├── C8051F200.h │ │ ├── C8051F300.h │ │ ├── C8051F310.h │ │ ├── C8051F320.h │ │ ├── C8051F326.h │ │ ├── C8051F330.h │ │ ├── C8051F336.h │ │ ├── C8051F340.h │ │ ├── C8051F350.h │ │ ├── C8051F360.h │ │ ├── C8051F410.h │ │ ├── C8051F520.h │ │ ├── C8051F920.h │ │ ├── C8051T600.h │ │ ├── C8051T610.h │ │ ├── C8051T630.h │ │ ├── EFM8BB1.h │ │ ├── P89LPC901.h │ │ ├── P89LPC922.h │ │ ├── P89LPC925.h │ │ ├── P89LPC932.h │ │ ├── P89c51RD2.h │ │ ├── SST89x5xRDx.h │ │ ├── XC866.h │ │ ├── at89S8252.h │ │ ├── at89Sx051.h │ │ ├── at89c51ed2.h │ │ ├── at89c51id2.h │ │ ├── at89c51snd1c.h │ │ ├── at89c55.h │ │ ├── at89s53.h │ │ ├── at89s8253.h │ │ ├── at89x051.h │ │ ├── at89x51.h │ │ ├── at89x52.h │ │ ├── ax8052.h │ │ ├── ax8052f131.h │ │ ├── ax8052f142.h │ │ ├── ax8052f143.h │ │ ├── ax8052f151.h │ │ ├── cc1110.h │ │ ├── cc2430.h │ │ ├── cc2510fx.h │ │ ├── cc2530.h │ │ ├── compiler.h │ │ ├── lint.h │ │ ├── mcs51reg.h │ │ ├── msc1210.h │ │ ├── msm8xc154s.h │ │ ├── p89c66x.h │ │ ├── p89lpc9321.h │ │ ├── p89lpc9331.h │ │ ├── p89lpc933_4.h │ │ ├── p89lpc9351.h │ │ ├── p89lpc935_6.h │ │ ├── p89lpc938.h │ │ ├── p89v51rd2.h │ │ ├── p89v66x.h │ │ ├── reg51.h │ │ ├── reg764.h │ │ ├── regc515c.h │ │ ├── sab80515.h │ │ ├── ser.h │ │ ├── ser_ir.h │ │ ├── serial.h │ │ ├── serial_IO.h │ │ ├── stc12.h │ │ ├── uPSD32xx.h │ │ ├── uPSD33xx.h │ │ └── w7100.h │ ├── sdcc-lib.h │ ├── setjmp.h │ ├── signal.h │ ├── stdalign.h │ ├── stdarg.h │ ├── stdbool.h │ ├── stddef.h │ ├── stdint.h │ ├── stdio.h │ ├── stdlib.h │ ├── stdnoreturn.h │ ├── string.h │ ├── time.h │ ├── tinibios.h │ ├── typeof.h │ ├── uchar.h │ └── wchar.h └── lib │ ├── huge │ ├── libfloat.lib │ ├── libint.lib │ ├── liblong.lib │ ├── liblonglong.lib │ ├── libsdcc.lib │ └── mcs51.lib │ ├── large-stack-auto │ ├── libfloat.lib │ ├── libint.lib │ ├── liblong.lib │ ├── liblonglong.lib │ ├── libsdcc.lib │ └── mcs51.lib │ ├── large │ ├── libfloat.lib │ ├── libint.lib │ ├── liblong.lib │ ├── liblonglong.lib │ ├── libsdcc.lib │ └── mcs51.lib │ ├── medium │ ├── libfloat.lib │ ├── libint.lib │ ├── liblong.lib │ ├── liblonglong.lib │ ├── libsdcc.lib │ └── mcs51.lib │ ├── small-stack-auto │ ├── libfloat.lib │ ├── libint.lib │ ├── liblong.lib │ ├── liblonglong.lib │ ├── libsdcc.lib │ └── mcs51.lib │ ├── small │ ├── libfloat.lib │ ├── libint.lib │ ├── liblong.lib │ ├── liblonglong.lib │ ├── libsdcc.lib │ └── mcs51.lib │ └── src │ ├── _atof.c │ ├── _autobaud.c │ ├── _bp.c │ ├── abs.c │ ├── acosf.c │ ├── aligned_alloc.c │ ├── asincosf.c │ ├── asinf.c │ ├── atan2f.c │ ├── atanf.c │ ├── atoi.c │ ├── atol.c │ ├── atoll.c │ ├── bpx.c │ ├── bsearch.c │ ├── btowc.c │ ├── c16rtomb.c │ ├── c16stombs.c │ ├── c32rtomb.c │ ├── calloc.c │ ├── ceilf.c │ ├── cosf.c │ ├── coshf.c │ ├── cotf.c │ ├── errno.c │ ├── expf.c │ ├── fabsf.c │ ├── floorf.c │ ├── free.c │ ├── frexpf.c │ ├── gets.c │ ├── isalnum.c │ ├── isalpha.c │ ├── isblank.c │ ├── iscntrl.c │ ├── isdigit.c │ ├── isgraph.c │ ├── isinf.c │ ├── islower.c │ ├── isnan.c │ ├── isprint.c │ ├── ispunct.c │ ├── isspace.c │ ├── isupper.c │ ├── isxdigit.c │ ├── labs.c │ ├── ldexpf.c │ ├── log10f.c │ ├── logf.c │ ├── malloc.c │ ├── mblen.c │ ├── mbrlen.c │ ├── mbrtoc16.c │ ├── mbrtoc32.c │ ├── mbrtowc.c │ ├── mbsinit.c │ ├── mbstoc16s.c │ ├── mbstowcs.c │ ├── mbtowc.c │ ├── mcs51 │ ├── README │ ├── crtbank.asm │ ├── crtcall.asm │ ├── crtclear.asm │ ├── crtpagesfr.asm │ ├── crtstart.asm │ ├── crtxclear.asm │ ├── crtxinit.asm │ ├── crtxpop.asm │ ├── crtxpopr0.asm │ ├── crtxpush.asm │ ├── crtxpushr0.asm │ ├── crtxstack.asm │ └── gptr_cmp.asm │ ├── memccpy.c │ ├── memcpy.c │ ├── modff.c │ ├── powf.c │ ├── printf_fast.c │ ├── printf_fast_f.c │ ├── printf_large.c │ ├── printf_tiny.c │ ├── printfl.c │ ├── puts.c │ ├── qsort.c │ ├── rand.c │ ├── realloc.c │ ├── ser_ir.c │ ├── ser_ir_cts_rts.c │ ├── serial.c │ ├── sincosf.c │ ├── sincoshf.c │ ├── sinf.c │ ├── sinhf.c │ ├── sprintf.c │ ├── sqrtf.c │ ├── strdup.c │ ├── strndup.c │ ├── strtol.c │ ├── strtoul.c │ ├── strxfrm.c │ ├── tancotf.c │ ├── tanf.c │ ├── tanhf.c │ ├── time.c │ ├── tolower.c │ ├── toupper.c │ ├── vprintf.c │ ├── wcrtomb.c │ ├── wcscmp.c │ ├── wcslen.c │ ├── wcstombs.c │ ├── wctob.c │ └── wctomb.c ├── USBHost.c ├── USBHost.h ├── USBhostDisplayDemo ├── GFX.cpp ├── GFX.h ├── ST7789.cpp ├── ST7789.h ├── USBhostDisplayDemo.ino ├── gfxfont.h └── glcdfont.c ├── chflasher.exe ├── compile.bat ├── config.h ├── main.c ├── uart.c ├── uart.h ├── util.c └── util.h /CH559USB.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/CH559USB.bin -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CH559sdccUSBHost 2 | 3 | 4 | 5 | Code for the CH559 chip from WCH to use as a USB host, you can connect a mouse or keyboard to it and it will output a simple protocol via serial port 1. 6 | 7 | you can edit the files and compile it via the compile.bat on windows, sdcc is included, so no extra tools needed. 8 | 9 | This repo is made together with this explanation video:(click on it) 10 | [![YoutubeVideo](https://img.youtube.com/vi/Th88RiSmj2w/0.jpg)](https://www.youtube.com/watch?v=Th88RiSmj2w) 11 | 12 | NEW: the chflasher.exe can be used to upload a bin firmware to ch55x chips, it will be uploaded directly after compile, no WCH tool needed anymore. 13 | Please install the libusb-win32 driver with the zadig tool ( https://zadig.akeo.ie/ ) to enable access to usb for the tool. 14 | 15 | Including Arduino Example code to either output the data to serial or onto an st7789 display. 16 | 17 | -------------------------------------------------------------------------------- /SDCC/bin/hex2bin.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/hex2bin.exe -------------------------------------------------------------------------------- /SDCC/bin/libgcc_s_seh-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/libgcc_s_seh-1.dll -------------------------------------------------------------------------------- /SDCC/bin/libgcc_s_sjlj-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/libgcc_s_sjlj-1.dll -------------------------------------------------------------------------------- /SDCC/bin/libstdc++-6.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/libstdc++-6.dll -------------------------------------------------------------------------------- /SDCC/bin/libwinpthread-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/libwinpthread-1.dll -------------------------------------------------------------------------------- /SDCC/bin/makebin.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/makebin.exe -------------------------------------------------------------------------------- /SDCC/bin/packihx.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/packihx.exe -------------------------------------------------------------------------------- /SDCC/bin/readline5.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/readline5.dll -------------------------------------------------------------------------------- /SDCC/bin/s51.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/s51.exe -------------------------------------------------------------------------------- /SDCC/bin/sdar.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdar.exe -------------------------------------------------------------------------------- /SDCC/bin/sdas390.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdas390.exe -------------------------------------------------------------------------------- /SDCC/bin/sdas6808.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdas6808.exe -------------------------------------------------------------------------------- /SDCC/bin/sdas8051.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdas8051.exe -------------------------------------------------------------------------------- /SDCC/bin/sdasgb.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdasgb.exe -------------------------------------------------------------------------------- /SDCC/bin/sdaspdk13.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdaspdk13.exe -------------------------------------------------------------------------------- /SDCC/bin/sdaspdk14.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdaspdk14.exe -------------------------------------------------------------------------------- /SDCC/bin/sdaspdk15.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdaspdk15.exe -------------------------------------------------------------------------------- /SDCC/bin/sdasrab.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdasrab.exe -------------------------------------------------------------------------------- /SDCC/bin/sdasstm8.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdasstm8.exe -------------------------------------------------------------------------------- /SDCC/bin/sdastlcs90.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdastlcs90.exe -------------------------------------------------------------------------------- /SDCC/bin/sdasz80.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdasz80.exe -------------------------------------------------------------------------------- /SDCC/bin/sdcc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdcc.exe -------------------------------------------------------------------------------- /SDCC/bin/sdcdb.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdcdb.exe -------------------------------------------------------------------------------- /SDCC/bin/sdcpp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdcpp.exe -------------------------------------------------------------------------------- /SDCC/bin/sdld.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdld.exe -------------------------------------------------------------------------------- /SDCC/bin/sdld6808.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdld6808.exe -------------------------------------------------------------------------------- /SDCC/bin/sdldgb.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdldgb.exe -------------------------------------------------------------------------------- /SDCC/bin/sdldpdk.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdldpdk.exe -------------------------------------------------------------------------------- /SDCC/bin/sdldstm8.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdldstm8.exe -------------------------------------------------------------------------------- /SDCC/bin/sdldz80.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdldz80.exe -------------------------------------------------------------------------------- /SDCC/bin/sdnm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdnm.exe -------------------------------------------------------------------------------- /SDCC/bin/sdobjcopy.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdobjcopy.exe -------------------------------------------------------------------------------- /SDCC/bin/sdranlib.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sdranlib.exe -------------------------------------------------------------------------------- /SDCC/bin/shc08.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/shc08.exe -------------------------------------------------------------------------------- /SDCC/bin/spdk.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/spdk.exe -------------------------------------------------------------------------------- /SDCC/bin/sstm8.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sstm8.exe -------------------------------------------------------------------------------- /SDCC/bin/stlcs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/stlcs.exe -------------------------------------------------------------------------------- /SDCC/bin/sz80.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/bin/sz80.exe -------------------------------------------------------------------------------- /SDCC/include/asm/default/features.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | features.h - default features. 3 | 4 | Copyright (C) 2001, Michael Hope 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #ifndef __SDC51_ASM_FEATURES_H 30 | #define __SDC51_ASM_FEATURES_H 1 31 | 32 | #define _REENTRANT __reentrant 33 | #define _CODE __code 34 | #define _AUTOMEM 35 | #define _STATMEM 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /SDCC/include/asm/temp.txt: -------------------------------------------------------------------------------- 1 | * -------------------------------------------------------------------------------- /SDCC/include/assert.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | assert.h - header file for assert ANSI routine 3 | 4 | Copyright (C) 2018, Philipp Klaus Krause . pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #undef assert 30 | 31 | #ifdef NDEBUG 32 | 33 | /* Debugging disabled -- do not evaluate assertions. */ 34 | #define assert(x) ((void)0) 35 | 36 | #else 37 | 38 | /* Debugging enabled -- verify assertions at run time. */ 39 | void __assert(const char *expression, const char *functionname, const char *filename, unsigned int linenumber); 40 | #define assert(x) ((x) ? (void)0 : __assert(#x, __func__, __FILE__, __LINE__)) 41 | 42 | #if __STDC_VERSION__ >= 201112L 43 | #define static_assert _Static_assert 44 | #endif 45 | 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /SDCC/include/errno.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | errno.h: Error codes used in the math functions 3 | 4 | Copyright (C) 2001, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #ifndef _INC_ERRNO 32 | #define _INC_ERRNO 33 | 34 | extern int errno; 35 | 36 | /* Error Codes: */ 37 | 38 | #define EDOM 33 /* Math argument out of domain of functions */ 39 | #define ERANGE 34 /* Math result not representable */ 40 | #define EILSEQ 84 /* Illegal byte sequence */ 41 | 42 | /* Bounds-checking interfaces from annex K of the C11 standard. */ 43 | #if defined (__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ 44 | 45 | #ifndef __ERRNO_T_DEFINED 46 | #define __ERRNO_T_DEFINED 47 | typedef int errno_t; 48 | #endif 49 | 50 | #endif 51 | 52 | #endif /* _INC_ERRNO */ 53 | 54 | -------------------------------------------------------------------------------- /SDCC/include/iso646.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | iso646.h 3 | 4 | Copyright (C) 2011, Philipp Klaus Krause . pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #ifndef __SDCC_ISO646_H 30 | #define __SDCC_ISO646_H 31 | 32 | #define and && 33 | #define and_eq &= 34 | #define bitand & 35 | #define bitor | 36 | #define complement ~ 37 | #define not ! 38 | #define not_eq != 39 | #define or || 40 | #define or_eq |= 41 | #define xor ^ 42 | #define xor_eq ^= 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /SDCC/include/limits.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | limits.h - ANSI defines constants for sizes of integral types 3 | 4 | Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #ifndef __SDC51_LIMITS_H 30 | #define __SDC51_LIMITS_H 1 31 | 32 | #define CHAR_BIT 8 /* bits in a char */ 33 | #define SCHAR_MAX 127 34 | #define SCHAR_MIN -128 35 | #define UCHAR_MAX 0xff 36 | 37 | #ifdef __SDCC_CHAR_UNSIGNED 38 | #define CHAR_MAX UCHAR_MAX 39 | #define CHAR_MIN 0 40 | #else 41 | #define CHAR_MAX SCHAR_MAX 42 | #define CHAR_MIN SCHAR_MIN 43 | #endif 44 | 45 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199409L 46 | #define MB_LEN_MAX 4 47 | #endif 48 | 49 | #define INT_MIN (-32767 - 1) 50 | #define INT_MAX 32767 51 | #define SHRT_MAX INT_MAX 52 | #define SHRT_MIN INT_MIN 53 | #define UINT_MAX 0xffff 54 | #define UINT_MIN 0 55 | #define USHRT_MAX UINT_MAX 56 | #define USHRT_MIN UINT_MIN 57 | #define LONG_MIN (-2147483647L-1) 58 | #define LONG_MAX 2147483647L 59 | #define ULONG_MAX 0xffffffff 60 | #define ULONG_MIN 0 61 | 62 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 63 | #define LLONG_MIN (-9223372036854775807LL-1) 64 | #define LLONG_MAX 9223372036854775807LL 65 | #define ULLONG_MAX 18446744073709551615ULL 66 | #endif 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /SDCC/include/mcs51/P89LPC901.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/include/mcs51/P89LPC901.h -------------------------------------------------------------------------------- /SDCC/include/mcs51/P89LPC922.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/include/mcs51/P89LPC922.h -------------------------------------------------------------------------------- /SDCC/include/mcs51/P89LPC925.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/include/mcs51/P89LPC925.h -------------------------------------------------------------------------------- /SDCC/include/mcs51/P89LPC932.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/include/mcs51/P89LPC932.h -------------------------------------------------------------------------------- /SDCC/include/mcs51/P89c51RD2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/include/mcs51/P89c51RD2.h -------------------------------------------------------------------------------- /SDCC/include/mcs51/at89x051.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | at89x051.h - Register Declarations for Atmel AT89C1051, AT89C2051 and AT89C4051 Processors 3 | based on 8051.h (8051.h must be in mcs51 subdirectory) 4 | KEIL C compatible definitions are included 5 | 6 | Copyright (C) 2000, Bela Torok / bela.torok@kssg.ch 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | #ifndef AT89Cx051_H 32 | #define AT89Cx051_H 33 | 34 | #include <8051.h> /* load difinitions for the 8051 core */ 35 | 36 | #ifdef REG8051_H 37 | #undef REG8051_H 38 | #endif 39 | 40 | /* remove non existing registers */ 41 | 42 | #ifdef P0 /* P0 is defined in <8051.h> */ 43 | #undef P0 /* AT89Cx051 has no P0 */ 44 | #undef P0_0 /* undefine bit addressable registers in P0 */ 45 | #undef P0_1 46 | #undef P0_2 47 | #undef P0_3 48 | #undef P0_4 49 | #undef P0_5 50 | #undef P0_6 51 | #undef P0_7 52 | #endif 53 | 54 | #ifdef P2 /* P2 is defined in <8051.h> */ 55 | #undef P2 /* AT89Cx051 has no P2 */ 56 | #undef P2_0 /* undefine bit addressable registers in P2 */ 57 | #undef P2_1 58 | #undef P2_2 59 | #undef P2_3 60 | #undef P2_4 61 | #undef P2_5 62 | #undef P2_6 63 | #undef P2_7 64 | #endif 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /SDCC/include/mcs51/cc1110.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/include/mcs51/cc1110.h -------------------------------------------------------------------------------- /SDCC/include/mcs51/cc2430.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/include/mcs51/cc2430.h -------------------------------------------------------------------------------- /SDCC/include/mcs51/cc2530.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/include/mcs51/cc2530.h -------------------------------------------------------------------------------- /SDCC/include/mcs51/p89lpc9321.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/include/mcs51/p89lpc9321.h -------------------------------------------------------------------------------- /SDCC/include/mcs51/p89lpc9331.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/include/mcs51/p89lpc9331.h -------------------------------------------------------------------------------- /SDCC/include/mcs51/p89lpc9351.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/include/mcs51/p89lpc9351.h -------------------------------------------------------------------------------- /SDCC/include/mcs51/reg51.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | reg51.h - Register Declarations for 8051 Processor 3 | 4 | Copyright (C) 1998, Sandeep Dutta . sandeep.dutta@usa.net 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #ifndef REG51_H 30 | #define REG51_H 31 | 32 | #warning This file (reg51.h) is obsolete, use one appropriate for your harware! 33 | #warning Falling back to include <8052.h> 34 | 35 | #include <8052.h> 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /SDCC/include/mcs51/ser_ir.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | ser_ir.h - header file for serial routines 3 | 4 | Copyright (C) 1999, Josef Wolf 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #ifndef __SER_IR_H 30 | #define __SER_IR_H 31 | 32 | /* call this one first on startup */ 33 | void ser_init (void); 34 | 35 | /* the following ones should be obvious */ 36 | void ser_putc (unsigned char c); 37 | void ser_puts (unsigned char *s); 38 | void ser_gets (unsigned char *s, unsigned char len); 39 | unsigned char ser_getc (void); 40 | 41 | /* return the number of chars that can be received/transmitted without 42 | * blocking. 43 | */ 44 | unsigned char ser_can_rcv (void); 45 | unsigned char ser_can_xmt (void); 46 | 47 | /* needs to be defined somewhere :-() */ 48 | void ser_handler (void) __interrupt 4; 49 | 50 | #endif /* __SER_IR_H */ 51 | -------------------------------------------------------------------------------- /SDCC/include/mcs51/serial.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | serial.c - this module implements serial interrupt handler and IO 3 | routinwes using two 256 byte cyclic buffers. Bit variables 4 | can be used as flags for real-time kernel tasks 5 | 6 | Copyright (C) 1996, Dmitry S. Obukhov 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | void serial_init (void); 32 | void serial_interrupt_handler (void) __interrupt 4 __using 1; 33 | void serial_putc (unsigned char); 34 | unsigned char serial_getc (void); 35 | void autobaud (); 36 | -------------------------------------------------------------------------------- /SDCC/include/sdcc-lib.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | sdcc-lib.h - Top level header file for the sdcc libraries that enables 3 | target specific features. 4 | 5 | Copyright (C) 2004, Maarten Brock, sourceforge.brock@dse.nl 6 | 7 | This library is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 2, or (at your option) any 10 | later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this library; see the file COPYING. If not, write to the 19 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 20 | MA 02110-1301, USA. 21 | 22 | As a special exception, if you link this library with other files, 23 | some of which are compiled with SDCC, to produce an executable, 24 | this library does not by itself cause the resulting executable to 25 | be covered by the GNU General Public License. This exception does 26 | not however invalidate any other reasons why the executable file 27 | might be covered by the GNU General Public License. 28 | -------------------------------------------------------------------------*/ 29 | 30 | #ifndef __SDC51_SDCC_LIB_H 31 | #define __SDC51_SDCC_LIB_H 1 32 | 33 | #if defined(__SDCC_z80) 34 | #include 35 | 36 | #elif defined(__SDCC_z180) 37 | #include 38 | 39 | #elif defined(__SDCC_r2k) 40 | #include 41 | 42 | #elif defined(__SDCC_r3ka) 43 | #include 44 | 45 | #elif defined(__SDCC_tlcs90) 46 | #include 47 | 48 | #elif defined(__SDCC_gbz80) 49 | #include 50 | 51 | #elif defined(__SDCC_ez80_z80) 52 | #include 53 | 54 | #elif defined(__SDCC_mcs51) 55 | #include 56 | 57 | #elif defined(__SDCC_ds390) 58 | #include 59 | 60 | #elif defined(__SDCC_stm8) 61 | #include 62 | 63 | #else 64 | /* PENDING */ 65 | #include 66 | 67 | #endif 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /SDCC/include/signal.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | stdint.h - ISO C99 7.14 Signal handing 3 | 4 | Copyright (C) 2019, Philipp Klaus Krause, krauseph@informatik.uni-freiburg.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #ifndef _SIGNAL_H 30 | #define _SIGNAL_H 1 31 | 32 | typedef unsigned char sig_atomic_t; 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /SDCC/include/stdalign.h: -------------------------------------------------------------------------------- 1 | #ifndef __SDCC_STDALIGN_H 2 | #define __SDCC_STDALIGN_H 1 3 | 4 | #ifndef __alignas_is_defined 5 | #define __alignas_is_defined 1 6 | 7 | #define alignas _Alignas 8 | 9 | #endif 10 | 11 | 12 | #ifndef __alignof_is_defined 13 | #define __alignof_is_defined 1 14 | 15 | #define alignof _Alignof 16 | 17 | #endif 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /SDCC/include/stdbool.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | stdbool.h - ANSI functions forward declarations 3 | 4 | Copyright (C) 2004, Maarten Brock, sourceforge.brock@dse.nl 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #ifndef __SDC51_STDBOOL_H 30 | #define __SDC51_STDBOOL_H 1 31 | 32 | /* Define true and false of type _Bool in a way compatible with the preprocessor (see N 2229 for details). */ 33 | #define true ((_Bool)+1) 34 | #define false ((_Bool)+0) 35 | 36 | #define bool _Bool 37 | #define __bool_true_false_are_defined 1 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /SDCC/include/stdnoreturn.h: -------------------------------------------------------------------------------- 1 | #ifndef __SDCC_STDNORETURN_H 2 | #define __SDCC_STDNORETURN_H 1 3 | 4 | #define noreturn _Noreturn 5 | 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /SDCC/include/typeof.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | typeof.h - Contains enumerations of values returned by __typeof 3 | 4 | Copyright (C) 2001, Sandeep Dutta . sandeep.dutta@usa.net 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #ifndef __SDC51_TYPEOF_H 30 | #define __SDC51_TYPEOF_H 1 31 | 32 | #define TYPEOF_INT 1 33 | #define TYPEOF_SHORT 2 34 | #define TYPEOF_CHAR 3 35 | #define TYPEOF_LONG 4 36 | #define TYPEOF_FLOAT 5 37 | #define TYPEOF_FIXED16X16 6 38 | #define TYPEOF_BIT 7 39 | #define TYPEOF_BITFIELD 8 40 | #define TYPEOF_SBIT 9 41 | #define TYPEOF_SFR 10 42 | #define TYPEOF_VOID 11 43 | #define TYPEOF_STRUCT 12 44 | #define TYPEOF_ARRAY 13 45 | #define TYPEOF_FUNCTION 14 46 | #define TYPEOF_POINTER 15 47 | #define TYPEOF_FPOINTER 16 48 | #define TYPEOF_CPOINTER 17 49 | #define TYPEOF_GPOINTER 18 50 | #define TYPEOF_PPOINTER 19 51 | #define TYPEOF_IPOINTER 20 52 | #define TYPEOF_EEPPOINTER 21 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /SDCC/include/uchar.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | uchar.h: Unicode utilities (ISO C 11 7.28) 3 | 4 | Copyright (C) 2015-2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #ifndef __SDCC_UCHAR_H 30 | #define __SDCC_UCHAR_H 1 31 | 32 | #ifndef __MBSTATE_T_DEFINED 33 | #define __MBSTATE_T_DEFINED 34 | typedef struct {unsigned char c[3];} mbstate_t; 35 | #endif 36 | 37 | #ifndef __SIZE_T_DEFINED 38 | #define __SIZE_T_DEFINED 39 | typedef unsigned int size_t; 40 | #endif 41 | 42 | #ifndef __CHAR16_T_DEFINED 43 | #define __CHAR16_T_DEFINED 44 | typedef unsigned int char16_t; 45 | #endif 46 | 47 | #ifndef __CHAR32_T_DEFINED 48 | #define __CHAR32_T_DEFINED 49 | typedef unsigned long int char32_t; 50 | #endif 51 | 52 | size_t mbrtoc16(char16_t *restrict pc16, const char *restrict s, size_t n, mbstate_t *restrict ps); 53 | size_t c16rtomb(char *restrict s, char16_t c16, mbstate_t *restrict ps); 54 | size_t mbrtoc32(char32_t *restrict pc32, const char *restrict s, size_t n, mbstate_t *restrict ps); 55 | size_t c32rtomb(char *restrict s, char32_t c32, mbstate_t *restrict ps); 56 | 57 | size_t __mbstoc16s(char16_t *restrict c16s, const char *restrict s, size_t n); 58 | size_t __c16stombs(char *restrict s, const char16_t *restrict c16s, size_t n); 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /SDCC/lib/huge/libfloat.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/huge/libfloat.lib -------------------------------------------------------------------------------- /SDCC/lib/huge/liblong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/huge/liblong.lib -------------------------------------------------------------------------------- /SDCC/lib/huge/liblonglong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/huge/liblonglong.lib -------------------------------------------------------------------------------- /SDCC/lib/huge/libsdcc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/huge/libsdcc.lib -------------------------------------------------------------------------------- /SDCC/lib/huge/mcs51.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/huge/mcs51.lib -------------------------------------------------------------------------------- /SDCC/lib/large-stack-auto/libfloat.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/large-stack-auto/libfloat.lib -------------------------------------------------------------------------------- /SDCC/lib/large-stack-auto/libint.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/large-stack-auto/libint.lib -------------------------------------------------------------------------------- /SDCC/lib/large-stack-auto/liblong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/large-stack-auto/liblong.lib -------------------------------------------------------------------------------- /SDCC/lib/large-stack-auto/liblonglong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/large-stack-auto/liblonglong.lib -------------------------------------------------------------------------------- /SDCC/lib/large-stack-auto/libsdcc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/large-stack-auto/libsdcc.lib -------------------------------------------------------------------------------- /SDCC/lib/large-stack-auto/mcs51.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/large-stack-auto/mcs51.lib -------------------------------------------------------------------------------- /SDCC/lib/large/libfloat.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/large/libfloat.lib -------------------------------------------------------------------------------- /SDCC/lib/large/liblong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/large/liblong.lib -------------------------------------------------------------------------------- /SDCC/lib/large/liblonglong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/large/liblonglong.lib -------------------------------------------------------------------------------- /SDCC/lib/large/libsdcc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/large/libsdcc.lib -------------------------------------------------------------------------------- /SDCC/lib/large/mcs51.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/large/mcs51.lib -------------------------------------------------------------------------------- /SDCC/lib/medium/libfloat.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/medium/libfloat.lib -------------------------------------------------------------------------------- /SDCC/lib/medium/libint.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/medium/libint.lib -------------------------------------------------------------------------------- /SDCC/lib/medium/liblong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/medium/liblong.lib -------------------------------------------------------------------------------- /SDCC/lib/medium/liblonglong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/medium/liblonglong.lib -------------------------------------------------------------------------------- /SDCC/lib/medium/libsdcc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/medium/libsdcc.lib -------------------------------------------------------------------------------- /SDCC/lib/medium/mcs51.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/medium/mcs51.lib -------------------------------------------------------------------------------- /SDCC/lib/small-stack-auto/libfloat.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small-stack-auto/libfloat.lib -------------------------------------------------------------------------------- /SDCC/lib/small-stack-auto/libint.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small-stack-auto/libint.lib -------------------------------------------------------------------------------- /SDCC/lib/small-stack-auto/liblong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small-stack-auto/liblong.lib -------------------------------------------------------------------------------- /SDCC/lib/small-stack-auto/liblonglong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small-stack-auto/liblonglong.lib -------------------------------------------------------------------------------- /SDCC/lib/small-stack-auto/libsdcc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small-stack-auto/libsdcc.lib -------------------------------------------------------------------------------- /SDCC/lib/small-stack-auto/mcs51.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small-stack-auto/mcs51.lib -------------------------------------------------------------------------------- /SDCC/lib/small/libfloat.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small/libfloat.lib -------------------------------------------------------------------------------- /SDCC/lib/small/libint.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small/libint.lib -------------------------------------------------------------------------------- /SDCC/lib/small/liblong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small/liblong.lib -------------------------------------------------------------------------------- /SDCC/lib/small/liblonglong.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small/liblonglong.lib -------------------------------------------------------------------------------- /SDCC/lib/small/libsdcc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small/libsdcc.lib -------------------------------------------------------------------------------- /SDCC/lib/small/mcs51.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/SDCC/lib/small/mcs51.lib -------------------------------------------------------------------------------- /SDCC/lib/src/_bp.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | _bp.c - just declares bp as a variable 3 | 4 | Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | __data unsigned char bp ; 30 | -------------------------------------------------------------------------------- /SDCC/lib/src/abs.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | abs.c - computes absolute value of an integer. 3 | 4 | Copyright (C) 2004, Maarten Brock, sourceforge.brock@dse.nl 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #if defined (__SDCC_mcs51) 32 | 33 | #if defined(__SDCC) 34 | #include 35 | #endif 36 | 37 | static void dummy(void) __naked 38 | { 39 | __asm 40 | .globl _abs 41 | _abs: 42 | mov a, dph 43 | jnb acc.7, 00001$ 44 | xrl dpl,#0xFF 45 | xrl dph,#0xFF 46 | inc dptr 47 | 00001$: 48 | _RETURN 49 | __endasm; 50 | } 51 | 52 | #else 53 | 54 | int abs(int j) 55 | { 56 | return (j < 0) ? -j : j; 57 | } 58 | 59 | #endif 60 | 61 | //END OF MODULE 62 | -------------------------------------------------------------------------------- /SDCC/lib/src/acosf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | acosf.c - Computes arc cosine of a 32-bit float 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | 34 | float asincosf(float x, bool isacos); 35 | 36 | float acosf(float x) _FLOAT_FUNC_REENTRANT 37 | { 38 | if (x == 1.0) return 0.0; 39 | else if (x ==-1.0) return PI; 40 | else if (x == 0.0) return HALF_PI; 41 | else return asincosf(x, true); 42 | } 43 | -------------------------------------------------------------------------------- /SDCC/lib/src/aligned_alloc.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | aligned_alloc.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2015 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | #pragma std_c11 32 | 33 | #include 34 | 35 | /* it is important to declare this function extern before including 36 | the inline definition to give it external linkage */ 37 | 38 | extern void *aligned_alloc(size_t alignment, size_t size); 39 | 40 | #include 41 | 42 | -------------------------------------------------------------------------------- /SDCC/lib/src/asinf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | asinf.c - Computes asin(x) 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | 34 | float asincosf(float x, bool isacos); 35 | 36 | float asinf(float x) _FLOAT_FUNC_REENTRANT 37 | { 38 | if (x == 1.0) return HALF_PI; 39 | else if (x ==-1.0) return -HALF_PI; 40 | else if (x == 0.0) return 0.0; 41 | else return asincosf(x, false); 42 | } 43 | -------------------------------------------------------------------------------- /SDCC/lib/src/atan2f.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | atan2f.c - Computes atan2(x) where x is a 32-bit float. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | 34 | float atan2f(float x, float y) 35 | { 36 | float r; 37 | 38 | if ((x==0.0) && (y==0.0)) 39 | { 40 | errno=EDOM; 41 | return 0.0; 42 | } 43 | 44 | if(fabsf(y)>=fabsf(x)) 45 | { 46 | r=atanf(x/y); 47 | if(y<0.0) r+=(x>=0?PI:-PI); 48 | } 49 | else 50 | { 51 | r=-atanf(y/x); 52 | r+=(x<0.0?-HALF_PI:HALF_PI); 53 | } 54 | return r; 55 | } 56 | -------------------------------------------------------------------------------- /SDCC/lib/src/atoi.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------- 2 | atoi() - convert a string to an integer and return it 3 | 4 | Copyright (C) 2015, Philipp Klaus Krause . pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | int atoi(const char *nptr) 35 | { 36 | int ret = 0; 37 | bool neg; 38 | 39 | while (isblank (*nptr)) 40 | nptr++; 41 | 42 | neg = (*nptr == '-'); 43 | 44 | if (*nptr == '-' || *nptr == '+') 45 | nptr++; 46 | 47 | while (isdigit (*nptr)) 48 | ret = ret * 10 + (*(nptr++) - '0'); 49 | 50 | return (neg ? -ret : ret); // Since -INT_MIN is INT_MIN in sdcc, the result value always turns out ok. 51 | } 52 | 53 | -------------------------------------------------------------------------------- /SDCC/lib/src/atol.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------- 2 | atol() - convert a string to a long integer and return it 3 | 4 | Copyright (C) 2015, Philipp Klaus Krause . pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | long int atol(const char *nptr) 35 | { 36 | long int ret = 0; 37 | bool neg; 38 | 39 | while (isblank (*nptr)) 40 | nptr++; 41 | 42 | neg = (*nptr == '-'); 43 | 44 | if (*nptr == '-' || *nptr == '+') 45 | nptr++; 46 | 47 | while (isdigit (*nptr)) 48 | ret = ret * 10 + (*(nptr++) - '0'); 49 | 50 | return (neg ? -ret : ret); // Since -LONG_MIN is LONG_MIN in sdcc, the result value always turns out ok. 51 | } 52 | 53 | -------------------------------------------------------------------------------- /SDCC/lib/src/atoll.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------- 2 | atoll() - convert a string to a long long integer and return it 3 | 4 | Copyright (C) 2015, Philipp Klaus Krause . pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | #ifdef __SDCC_LONGLONG 35 | long long int atoll(const char *nptr) 36 | { 37 | long long int ret = 0; 38 | bool neg; 39 | 40 | while (isblank (*nptr)) 41 | nptr++; 42 | 43 | neg = (*nptr == '-'); 44 | 45 | if (*nptr == '-' || *nptr == '+') 46 | nptr++; 47 | 48 | while (isdigit (*nptr)) 49 | ret = ret * 10 + (*(nptr++) - '0'); 50 | 51 | return (neg ? -ret : ret); // Since -LLONG_MIN is LLONG_MIN in sdcc, the result value always turns out ok. 52 | } 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /SDCC/lib/src/bpx.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | bpx.c - just declares bpx as a variable 3 | 4 | Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #if defined(__SDCC_mcs51) 30 | __data unsigned char bpx ; 31 | #else 32 | __data unsigned int bpx ; 33 | #endif 34 | -------------------------------------------------------------------------------- /SDCC/lib/src/bsearch.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------- 2 | bsearch() - search a sorted array 3 | 4 | Copyright (C) 2018, Philipp Klaus Krause . pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *) __reentrant) 32 | { 33 | for(const char *left = base; nmemb;) 34 | { 35 | const char *middle = left + nmemb / 2 * size; 36 | int c = (*compar)(key, middle); 37 | 38 | if(c < 0) 39 | nmemb = nmemb / 2; 40 | else if(c > 0) 41 | { 42 | left = middle + size; 43 | nmemb = (nmemb - 1) / 2; 44 | } 45 | else 46 | return(middle); 47 | } 48 | 49 | return(0); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /SDCC/lib/src/btowc.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | btowc.c - convert a single-byte character to a wide character 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | 33 | _Static_assert(EOF & 0x80, "Invalid EOF"); 34 | 35 | wint_t btowc(int c) 36 | { 37 | if(c & 0x80) 38 | return WEOF; 39 | return c; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /SDCC/lib/src/c32rtomb.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | c32rtomb.c - convert a wide character to a multibyte sequence 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | 33 | size_t c32rtomb(char *restrict s, char32_t c32, mbstate_t *restrict ps) 34 | { 35 | ps; 36 | return(wctomb(s, c32)); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /SDCC/lib/src/calloc.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | calloc.c - allocate memory. 3 | 4 | Copyright (C) 2015, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400) 34 | #define HEAPSPACE __xdata 35 | #elif defined(__SDCC_pdk13) || defined(__SDCC_pdk14) || defined(__SDCC_pdk15) 36 | #define HEAPSPACE __near 37 | #else 38 | #define HEAPSPACE 39 | #endif 40 | 41 | #if defined(__SDCC_mcs51) || defined(__SDCC_ds390) || defined(__SDCC_ds400) 42 | void HEAPSPACE *calloc (size_t nmemb, size_t size) 43 | #else 44 | void *calloc (size_t nmemb, size_t size) 45 | #endif 46 | { 47 | void HEAPSPACE *ptr; 48 | 49 | unsigned long msize = (unsigned long)nmemb * (unsigned long)size; 50 | 51 | _Static_assert(sizeof(unsigned long) >= sizeof(size_t) * 2, 52 | "size_t too large wrt. unsigned long for overflow check"); 53 | 54 | if (msize > SIZE_MAX) 55 | return(0); 56 | 57 | if (ptr = malloc(msize)) 58 | memset(ptr, 0, msize); 59 | 60 | return(ptr); 61 | } 62 | 63 | -------------------------------------------------------------------------------- /SDCC/lib/src/ceilf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | ceilf.c - Returns the integer larger or equal than x 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | 33 | float ceilf(float x) _FLOAT_FUNC_REENTRANT 34 | { 35 | long r; 36 | r=x; 37 | if (r<0) 38 | return r; 39 | else 40 | return (r+((r 32 | #include 33 | 34 | float sincosf(float x, bool iscos); 35 | 36 | float cosf(float x) _FLOAT_FUNC_REENTRANT 37 | { 38 | if (x==0.0) return 1.0; 39 | return sincosf(x, 1); 40 | } 41 | -------------------------------------------------------------------------------- /SDCC/lib/src/coshf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | coshf.c - Computes cosh(x) where x is a 32-bit float. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | 34 | float sincoshf(float x, bool iscosh); 35 | 36 | float coshf(float x) _FLOAT_FUNC_REENTRANT 37 | { 38 | return sincoshf(x, 1); 39 | } 40 | -------------------------------------------------------------------------------- /SDCC/lib/src/cotf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | cotf.c - Computes cot(x) where x is a 32-bit float. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | float tancotf(float x, bool iscotan); 36 | 37 | float cotf(float x) _FLOAT_FUNC_REENTRANT 38 | { 39 | float y; 40 | 41 | y=fabsf(x); 42 | if (y<1.0E-30) //This one requires more thinking... 43 | { 44 | errno = ERANGE; 45 | if (x<0.0) 46 | return -HUGE_VALF; 47 | else 48 | return +HUGE_VALF; 49 | } 50 | return tancotf(x, 1); 51 | } 52 | -------------------------------------------------------------------------------- /SDCC/lib/src/errno.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | errno.c - just declares errno as a variable 3 | 4 | Copyright (C) 2003, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | int errno; 30 | -------------------------------------------------------------------------------- /SDCC/lib/src/fabsf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | fabsf.c - Returns the absolute value of a 32-bit float. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | 34 | float fabsf(float x) _FLOAT_FUNC_REENTRANT 35 | { 36 | union float_long fl; 37 | 38 | fl.f = x; 39 | fl.l &= 0x7fffffff; 40 | return fl.f; 41 | } 42 | -------------------------------------------------------------------------------- /SDCC/lib/src/floorf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | floorf.c - Returns the integer smaller or equal than x 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | 33 | float floorf (float x) _FLOAT_FUNC_REENTRANT 34 | { 35 | long r; 36 | r=x; 37 | if (r<=0) 38 | return (r+((r>x)?-1:0)); 39 | else 40 | return r; 41 | } 42 | -------------------------------------------------------------------------------- /SDCC/lib/src/frexpf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | frexpf.c - Returns the exponent and mantisa of a 32 bit float. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | 34 | float frexpf(float x, int *pw2) 35 | { 36 | union float_long fl; 37 | long int i; 38 | 39 | fl.f=x; 40 | /* Find the exponent (power of 2) */ 41 | i = ( fl.l >> 23) & 0x000000ff; 42 | i -= 0x7e; 43 | *pw2 = i; 44 | fl.l &= 0x807fffff; /* strip all exponent bits */ 45 | fl.l |= 0x3f000000; /* mantissa between 0.5 and 1 */ 46 | return(fl.f); 47 | } 48 | -------------------------------------------------------------------------------- /SDCC/lib/src/gets.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | gets.c 3 | 4 | Copyright (C) 2000, Johan Knol 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | char * 32 | gets (char *s) 33 | { 34 | char c; 35 | unsigned int count = 0; 36 | 37 | while (1) 38 | { 39 | c = getchar (); 40 | switch(c) 41 | { 42 | case '\b': /* backspace */ 43 | if (count) 44 | { 45 | putchar ('\b'); 46 | putchar (' '); 47 | putchar ('\b'); 48 | --s; 49 | --count; 50 | } 51 | break; 52 | 53 | case '\n': 54 | case '\r': /* CR or LF */ 55 | putchar ('\r'); 56 | putchar ('\n'); 57 | *s = 0; 58 | return s; 59 | 60 | default: 61 | *s++ = c; 62 | ++count; 63 | putchar (c); 64 | break; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /SDCC/lib/src/isalnum.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isalnum.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | #include 32 | 33 | #ifdef isalnum 34 | #undef isalnum 35 | #endif 36 | 37 | int isalnum (int c) 38 | { 39 | return (isalpha (c) || isdigit (c)); 40 | } 41 | 42 | -------------------------------------------------------------------------------- /SDCC/lib/src/isalpha.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isalpha.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | #include 32 | 33 | #ifdef isalpha 34 | #undef isalpha 35 | #endif 36 | 37 | int isalpha (int c) 38 | { 39 | return (isupper (c) || islower (c)); 40 | } 41 | 42 | -------------------------------------------------------------------------------- /SDCC/lib/src/isblank.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isblank.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | /* it is important to declare this function extern before including 32 | the inline definition to give it external linkage */ 33 | extern int isblank (int c); 34 | 35 | /* also include stdio.h before ctype.h here so ctype can perform a 36 | _Static_assert on EOF */ 37 | #include 38 | 39 | #include 40 | 41 | -------------------------------------------------------------------------------- /SDCC/lib/src/iscntrl.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | iscntrl.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | #include 32 | 33 | int iscntrl (int c) 34 | { 35 | return (c < ' ' || c == 0x7f); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /SDCC/lib/src/isdigit.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isdigit.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | /* it is important to declare this function extern before including 32 | the inline definition to give it external linkage */ 33 | extern int isdigit (int c); 34 | 35 | /* also include stdio.h before ctype.h here so ctype can perform a 36 | _Static_assert on EOF */ 37 | #include 38 | 39 | #include 40 | -------------------------------------------------------------------------------- /SDCC/lib/src/isgraph.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isgraph.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | #include 32 | 33 | int isgraph (int c) 34 | { 35 | return (c > ' ' && c <= '~'); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /SDCC/lib/src/isinf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isinf.c - Check if a float value is an infinite (positive or negative) 3 | 4 | Copyright (C) 2016, Ben Shi, powerstudio1st@163.com 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #define __SDCC_FLOAT_LIB 30 | #include 31 | #include 32 | 33 | int isinf (float f) 34 | { 35 | unsigned long *pl = (unsigned long *) &f; 36 | return *pl == 0x7f800000 || *pl == 0xff800000; 37 | } 38 | -------------------------------------------------------------------------------- /SDCC/lib/src/islower.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isslower.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | /* it is important to declare this function extern before including 32 | the inline definition to give it external linkage */ 33 | extern int islower (int c); 34 | 35 | /* also include stdio.h before ctype.h here so ctype can perform a 36 | _Static_assert on EOF */ 37 | #include 38 | 39 | #include 40 | -------------------------------------------------------------------------------- /SDCC/lib/src/isnan.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isnan.c - Check if a float value is an NaN (Not a Number) 3 | 4 | Copyright (C) 2016, Ben Shi, powerstudio1st@163.com 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #define __SDCC_FLOAT_LIB 30 | #include 31 | #include 32 | 33 | int isnan (float f) 34 | { 35 | unsigned long *pl = (unsigned long *) &f; 36 | //return (*pl & 0x7f800000) == 0x7f800000 && (*pl & 0x007fffff) != 0; 37 | return (*pl & 0x7fffffff) > 0x7f800000; 38 | } 39 | -------------------------------------------------------------------------------- /SDCC/lib/src/isprint.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isprint.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | #include 32 | 33 | int isprint (int c) 34 | { 35 | return (c >= ' ' && c <= '~'); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /SDCC/lib/src/ispunct.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | ispunct.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | #include 32 | 33 | int ispunct (int c) 34 | { 35 | return (isprint (c) && !isspace (c) && !isalnum (c)); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /SDCC/lib/src/isspace.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isspace.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | #include 32 | 33 | #ifdef isspace 34 | #undef isspace 35 | #endif 36 | 37 | int isspace (int c) 38 | { 39 | return (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v'); 40 | } 41 | 42 | -------------------------------------------------------------------------------- /SDCC/lib/src/isupper.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isupper.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | /* it is important to declare this function extern before including 32 | the inline definition to give it external linkage */ 33 | extern int isupper (int c); 34 | 35 | /* also include stdio.h before ctype.h here so ctype can perform a 36 | _Static_assert on EOF */ 37 | #include 38 | 39 | #include 40 | -------------------------------------------------------------------------------- /SDCC/lib/src/isxdigit.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | isxdigit.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | #include 32 | 33 | int isxdigit (int c) 34 | { 35 | return (c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F'); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /SDCC/lib/src/labs.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | labs.c - computes absolute value of an integer. 3 | 4 | Copyright (C) 2004, Maarten Brock, sourceforge.brock@dse.nl 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #if defined (__SDCC_mcs51) 32 | 33 | #if defined(__SDCC) 34 | #include 35 | #endif 36 | 37 | static void dummy(void) __naked 38 | { 39 | __asm 40 | .globl _labs 41 | _labs: 42 | jnb acc.7, 00001$ 43 | mov r2,a 44 | clr c 45 | clr a 46 | subb a,dpl 47 | mov dpl,a 48 | clr a 49 | subb a,dph 50 | mov dph,a 51 | clr a 52 | subb a,b 53 | mov b,a 54 | clr a 55 | subb a,r2 56 | 00001$: 57 | _RETURN 58 | __endasm; 59 | } 60 | 61 | #else 62 | 63 | long int labs(long int j) 64 | { 65 | return (j < 0) ? -j : j; 66 | } 67 | 68 | #endif 69 | 70 | //END OF MODULE 71 | -------------------------------------------------------------------------------- /SDCC/lib/src/ldexpf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | ldexpf.c - Build a float from a mantisa and exponent. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | 34 | float ldexpf(float x, int pw2) 35 | { 36 | union float_long fl; 37 | long e; 38 | 39 | fl.f = x; 40 | 41 | e=(fl.l >> 23) & 0x000000ff; 42 | e+=pw2; 43 | fl.l= ((e & 0xff) << 23) | (fl.l & 0x807fffff); 44 | 45 | return(fl.f); 46 | } 47 | -------------------------------------------------------------------------------- /SDCC/lib/src/log10f.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | log10f.c - Computes the base 10 log of a 32 bit float. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | 34 | float log10f(float x) _FLOAT_FUNC_REENTRANT 35 | { 36 | return logf(x)*0.4342944819; 37 | } 38 | -------------------------------------------------------------------------------- /SDCC/lib/src/mblen.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | mblen.c - determine number of bytes in next multibyte character 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | int mblen(const char *s, size_t n) 32 | { 33 | unsigned char m = 0; 34 | unsigned char c; 35 | 36 | if(!s) 37 | return(0); 38 | 39 | if(!n) 40 | return(-1); 41 | 42 | c = *s; 43 | 44 | if(!c) 45 | return(0); 46 | 47 | if(c <= 0x7f) 48 | return(1); 49 | 50 | while(c & 0x80) 51 | { 52 | c <<= 1; 53 | m++; 54 | } 55 | 56 | if(m > n) 57 | return(-1); 58 | 59 | n = m; 60 | while(--m) 61 | if((*++s & 0xc0) != 0x80) 62 | return(-1); 63 | 64 | return(n); 65 | } 66 | 67 | -------------------------------------------------------------------------------- /SDCC/lib/src/mbrlen.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | mbrlen.c - determine number of bytes in next multibyte character 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | size_t mbrlen(const char *restrict s, size_t n, mbstate_t *restrict ps) 32 | { 33 | static mbstate_t sps; 34 | 35 | return(mbrtowc(0, s, n, ps ? ps : &sps)); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /SDCC/lib/src/mbrtoc16.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | mbrtoc32.c - convert UTF-8 to UTF-16 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | size_t mbrtoc16(char16_t *restrict pc16, const char *restrict s, size_t n, mbstate_t *restrict ps) 35 | { 36 | char32_t codepoint; 37 | size_t ret; 38 | static mbstate_t sps; 39 | char16_t low_surrogate; 40 | 41 | if(!s) 42 | return(mbrtoc16(0, "", 1, ps)); 43 | 44 | if(!ps) 45 | ps = &sps; 46 | 47 | if(!ps->c[0] && (ps->c[1] || ps->c[2])) 48 | { 49 | if(pc16) 50 | *pc16 = ps->c[1] + (ps->c[2] << 8); 51 | ps->c[1] = ps->c[2] = 0; 52 | return(-3); 53 | } 54 | 55 | ret = mbrtowc(&codepoint, s, n, ps); 56 | 57 | if(ret > MB_LEN_MAX) 58 | return(ret); 59 | 60 | if (codepoint <= 0xffff) // Basic multilingual plane 61 | { 62 | if(pc16) 63 | *pc16 = codepoint; 64 | return(ret); 65 | } 66 | 67 | codepoint -= 0x100000; 68 | if(pc16) 69 | *pc16 = ((codepoint >> 10) & 0x3ff) + 0xd800; 70 | low_surrogate = (codepoint & 0x3ff) + 0xdc00; 71 | ps->c[0] = 0; 72 | ps->c[1] = low_surrogate & 0xff; 73 | ps->c[2] = low_surrogate >> 8; 74 | 75 | return(ret); 76 | } 77 | 78 | -------------------------------------------------------------------------------- /SDCC/lib/src/mbrtoc32.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | mbrtoc32.c - convert a multibyte sequence to a wide character 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | size_t mbrtoc32(char32_t *restrict pc32, const char *restrict s, size_t n, mbstate_t *restrict ps) 35 | { 36 | char32_t wc; 37 | size_t ret; 38 | static mbstate_t sps; 39 | 40 | if(!ps) 41 | ps = &sps; 42 | 43 | if(!pc32) 44 | return(mbrtowc(0, s, n, ps)); 45 | 46 | ret = mbrtowc(&wc, s, n, ps); 47 | 48 | if(ret <= MB_LEN_MAX) 49 | *pc32 = wc; 50 | 51 | return(ret); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /SDCC/lib/src/mbsinit.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | mbsinit.c - determine conversion state 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | int mbsinit(const mbstate_t *ps) 32 | { 33 | return(!ps || !ps->c[0] && !ps->c[1] && !ps->c[2]); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /SDCC/lib/src/mbstowcs.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | mbstowcs.c - convert a multibyte string to a wide character string 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | 33 | size_t mbstowcs(wchar_t *restrict pwcs, const char *restrict s, size_t n) 34 | { 35 | size_t m = 0; 36 | while(n--) 37 | { 38 | int b = mbtowc(pwcs++, s, MB_LEN_MAX); 39 | if(!b) 40 | break; 41 | if(b < 0) 42 | return(-1); 43 | s += b; 44 | m++; 45 | } 46 | 47 | return(m); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /SDCC/lib/src/mbtowc.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | mbtowc.c - convert a multibyte sequence to a wide character 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | int mbtowc(wchar_t *pwc, const char *restrict s, size_t n) 32 | { 33 | wchar_t codepoint; 34 | unsigned char seqlen, i; 35 | unsigned char first_byte; 36 | 37 | if(!s) 38 | return(0); 39 | 40 | seqlen = 1; 41 | first_byte = *s; 42 | 43 | if(first_byte & 0x80) 44 | { 45 | while (first_byte & (0x80 >> seqlen)) 46 | seqlen++; 47 | first_byte &= (0xff >> (seqlen + 1)); 48 | } 49 | 50 | if(seqlen > 4 || n < seqlen) 51 | return(-1); 52 | 53 | for(i = 1; i < seqlen; i++) 54 | if((s[i] & 0xc0) != 0x80) 55 | return(-1); 56 | 57 | codepoint = first_byte; 58 | 59 | for(s++, i = seqlen - 1; i; i--) 60 | { 61 | codepoint <<= 6; 62 | codepoint |= (*s & 0x3f); 63 | s++; 64 | } 65 | 66 | if(codepoint >= 0xd800 && codepoint <= 0xdfff) // UTF-16 surrogate. 67 | return(-1); 68 | 69 | if(pwc) 70 | *pwc = codepoint; 71 | return(codepoint ? seqlen : 0); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /SDCC/lib/src/mcs51/README: -------------------------------------------------------------------------------- 1 | sdcc/device/lib/mcs51 2 | ------------------- 3 | 4 | mcs51 specific routines. 5 | -------------------------------------------------------------------------------- /SDCC/lib/src/mcs51/crtcall.asm: -------------------------------------------------------------------------------- 1 | ;-------------------------------------------------------------------------- 2 | ; crtcall.asm - C run-time: indirect function call 3 | ; 4 | ; Copyright (C) 2007, Maarten Brock 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundation; either version 2, or (at your option) any 9 | ; later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this library; see the file COPYING. If not, write to the 18 | ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | ; MA 02110-1301, USA. 20 | ; 21 | ; As a special exception, if you link this library with other files, 22 | ; some of which are compiled with SDCC, to produce an executable, 23 | ; this library does not by itself cause the resulting executable to 24 | ; be covered by the GNU General Public License. This exception does 25 | ; not however invalidate any other reasons why the executable file 26 | ; might be covered by the GNU General Public License. 27 | ;-------------------------------------------------------------------------- 28 | 29 | .area HOME (CODE) 30 | .area GSINIT0 (CODE) 31 | .area GSINIT1 (CODE) 32 | .area GSINIT2 (CODE) 33 | .area GSINIT3 (CODE) 34 | .area GSINIT4 (CODE) 35 | .area GSINIT5 (CODE) 36 | .area GSINIT (CODE) 37 | .area GSFINAL (CODE) 38 | .area CSEG (CODE) 39 | 40 | .area HOME (CODE) 41 | 42 | __sdcc_call_dptr:: 43 | clr a 44 | jmp @a+dptr 45 | -------------------------------------------------------------------------------- /SDCC/lib/src/mcs51/crtclear.asm: -------------------------------------------------------------------------------- 1 | ;-------------------------------------------------------------------------- 2 | ; crtclear.asm - C run-time: clear DATA/IDATA 3 | ; 4 | ; Copyright (C) 2004, Erik Petrich 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundation; either version 2, or (at your option) any 9 | ; later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this library; see the file COPYING. If not, write to the 18 | ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | ; MA 02110-1301, USA. 20 | ; 21 | ; As a special exception, if you link this library with other files, 22 | ; some of which are compiled with SDCC, to produce an executable, 23 | ; this library does not by itself cause the resulting executable to 24 | ; be covered by the GNU General Public License. This exception does 25 | ; not however invalidate any other reasons why the executable file 26 | ; might be covered by the GNU General Public License. 27 | ;-------------------------------------------------------------------------- 28 | 29 | .area CSEG (CODE) 30 | .area GSINIT0 (CODE) 31 | .area GSINIT1 (CODE) 32 | .area GSINIT2 (CODE) 33 | .area GSINIT3 (CODE) 34 | .area GSINIT4 (CODE) 35 | .area GSINIT5 (CODE) 36 | .area GSINIT (CODE) 37 | .area GSFINAL (CODE) 38 | 39 | .area GSINIT4 (CODE) 40 | 41 | __mcs51_genRAMCLEAR:: 42 | clr a 43 | mov r0,#(l_IRAM-1) ; mov r0,a will do for most devices 44 | 00004$: mov @r0,a 45 | djnz r0,00004$ 46 | ; _mcs51_genRAMCLEAR() end 47 | -------------------------------------------------------------------------------- /SDCC/lib/src/mcs51/crtpagesfr.asm: -------------------------------------------------------------------------------- 1 | ;-------------------------------------------------------------------------- 2 | ; crtpagesfr.asm - C run-time: define page sfr for movx @r0/r1 instructions 3 | ; 4 | ; Copyright (C) 2004, Erik Petrich 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundation; either version 2, or (at your option) any 9 | ; later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this library; see the file COPYING. If not, write to the 18 | ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | ; MA 02110-1301, USA. 20 | ; 21 | ; As a special exception, if you link this library with other files, 22 | ; some of which are compiled with SDCC, to produce an executable, 23 | ; this library does not by itself cause the resulting executable to 24 | ; be covered by the GNU General Public License. This exception does 25 | ; not however invalidate any other reasons why the executable file 26 | ; might be covered by the GNU General Public License. 27 | ;-------------------------------------------------------------------------- 28 | 29 | __XPAGE == 0xa0 ; 0xa0 is P2 on the original 8051 30 | -------------------------------------------------------------------------------- /SDCC/lib/src/mcs51/crtstart.asm: -------------------------------------------------------------------------------- 1 | ;-------------------------------------------------------------------------- 2 | ; crtstart.asm - C run-time: startup 3 | ; 4 | ; Copyright (C) 2004, Erik Petrich 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundation; either version 2, or (at your option) any 9 | ; later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this library; see the file COPYING. If not, write to the 18 | ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | ; MA 02110-1301, USA. 20 | ; 21 | ; As a special exception, if you link this library with other files, 22 | ; some of which are compiled with SDCC, to produce an executable, 23 | ; this library does not by itself cause the resulting executable to 24 | ; be covered by the GNU General Public License. This exception does 25 | ; not however invalidate any other reasons why the executable file 26 | ; might be covered by the GNU General Public License. 27 | ;-------------------------------------------------------------------------- 28 | 29 | .area CSEG (CODE) 30 | .area GSINIT0 (CODE) 31 | .area GSINIT1 (CODE) 32 | .area GSINIT2 (CODE) 33 | .area GSINIT3 (CODE) 34 | .area GSINIT4 (CODE) 35 | .area GSINIT5 (CODE) 36 | .area GSINIT (CODE) 37 | .area GSFINAL (CODE) 38 | 39 | .globl __start__stack 40 | 41 | .area GSINIT0 (CODE) 42 | 43 | __sdcc_gsinit_startup:: 44 | mov sp,#__start__stack - 1 45 | 46 | .area GSINIT2 (CODE) 47 | 48 | lcall __sdcc_external_startup 49 | mov a,dpl 50 | jz __sdcc_init_data 51 | ljmp __sdcc_program_startup 52 | __sdcc_init_data: 53 | -------------------------------------------------------------------------------- /SDCC/lib/src/mcs51/crtxclear.asm: -------------------------------------------------------------------------------- 1 | ;-------------------------------------------------------------------------- 2 | ; crtxclear.asm - C run-time: clear XSEG 3 | ; 4 | ; Copyright (C) 2004, Erik Petrich 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundation; either version 2, or (at your option) any 9 | ; later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this library; see the file COPYING. If not, write to the 18 | ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | ; MA 02110-1301, USA. 20 | ; 21 | ; As a special exception, if you link this library with other files, 22 | ; some of which are compiled with SDCC, to produce an executable, 23 | ; this library does not by itself cause the resulting executable to 24 | ; be covered by the GNU General Public License. This exception does 25 | ; not however invalidate any other reasons why the executable file 26 | ; might be covered by the GNU General Public License. 27 | ;-------------------------------------------------------------------------- 28 | 29 | .area CSEG (CODE) 30 | .area GSINIT0 (CODE) 31 | .area GSINIT1 (CODE) 32 | .area GSINIT2 (CODE) 33 | .area GSINIT3 (CODE) 34 | .area GSINIT4 (CODE) 35 | .area GSINIT5 (CODE) 36 | .area GSINIT (CODE) 37 | .area GSFINAL (CODE) 38 | 39 | .area GSINIT4 (CODE) 40 | 41 | __mcs51_genXRAMCLEAR:: 42 | mov r0,#l_PSEG 43 | mov a,r0 44 | orl a,#(l_PSEG >> 8) 45 | jz 00006$ 46 | mov r1,#s_PSEG 47 | mov __XPAGE,#(s_PSEG >> 8) 48 | clr a 49 | 00005$: movx @r1,a 50 | inc r1 51 | djnz r0,00005$ 52 | 53 | 00006$: 54 | mov r0,#l_XSEG 55 | mov a,r0 56 | orl a,#(l_XSEG >> 8) 57 | jz 00008$ 58 | mov r1,#((l_XSEG + 255) >> 8) 59 | mov dptr,#s_XSEG 60 | clr a 61 | 00007$: movx @dptr,a 62 | inc dptr 63 | djnz r0,00007$ 64 | djnz r1,00007$ 65 | 00008$: 66 | 67 | -------------------------------------------------------------------------------- /SDCC/lib/src/mcs51/crtxpopr0.asm: -------------------------------------------------------------------------------- 1 | ;-------------------------------------------------------------------------- 2 | ; crtxpopbits.asm - C run-time: pop bits and other registers from xstack 3 | ; 4 | ; Copyright (C) 2009, Maarten Brock 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundation; either version 2, or (at your option) any 9 | ; later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this library; see the file COPYING. If not, write to the 18 | ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | ; MA 02110-1301, USA. 20 | ; 21 | ; As a special exception, if you link this library with other files, 22 | ; some of which are compiled with SDCC, to produce an executable, 23 | ; this library does not by itself cause the resulting executable to 24 | ; be covered by the GNU General Public License. This exception does 25 | ; not however invalidate any other reasons why the executable file 26 | ; might be covered by the GNU General Public License. 27 | ;-------------------------------------------------------------------------- 28 | 29 | ;-------------------------------------------------------- 30 | ; overlayable bit register bank 31 | ;-------------------------------------------------------- 32 | .area BIT_BANK (REL,OVR,DATA) 33 | bits: 34 | .ds 1 35 | 36 | ar0 = 0x00 37 | ar1 = 0x01 38 | 39 | .area HOME (CODE) 40 | 41 | ; Pop registers r0..r7 & bits from xstack (r0 always) 42 | ; Expect mask in B 43 | ___sdcc_xpop_regs_r0:: 44 | mov r0,_spx 45 | dec r0 46 | movx a,@r0 ;pop R0 47 | ljmp ___sdcc_xpop 48 | -------------------------------------------------------------------------------- /SDCC/lib/src/mcs51/crtxpushr0.asm: -------------------------------------------------------------------------------- 1 | ;-------------------------------------------------------------------------- 2 | ; crtxpush0.asm - C run-time: push R0 and other registers to xstack 3 | ; 4 | ; Copyright (C) 2009, Maarten Brock 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundation; either version 2, or (at your option) any 9 | ; later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this library; see the file COPYING. If not, write to the 18 | ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | ; MA 02110-1301, USA. 20 | ; 21 | ; As a special exception, if you link this library with other files, 22 | ; some of which are compiled with SDCC, to produce an executable, 23 | ; this library does not by itself cause the resulting executable to 24 | ; be covered by the GNU General Public License. This exception does 25 | ; not however invalidate any other reasons why the executable file 26 | ; might be covered by the GNU General Public License. 27 | ;-------------------------------------------------------------------------- 28 | 29 | ;-------------------------------------------------------- 30 | ; overlayable bit register bank 31 | ;-------------------------------------------------------- 32 | .area BIT_BANK (REL,OVR,DATA) 33 | bits: 34 | .ds 1 35 | 36 | ar0 = 0x00 37 | ar1 = 0x01 38 | 39 | .area HOME (CODE) 40 | 41 | ; Push registers r0..r7 & bits on xstack (r0 always) 42 | ; Expect allocation size in ACC and mask in B 43 | ___sdcc_xpush_regs_r0:: 44 | add a,_spx 45 | mov _spx,a 46 | xch a,r0 ;push R0 47 | dec r0 48 | movx @r0,a 49 | ljmp ___sdcc_xpush 50 | -------------------------------------------------------------------------------- /SDCC/lib/src/mcs51/crtxstack.asm: -------------------------------------------------------------------------------- 1 | ;-------------------------------------------------------------------------- 2 | ; crtxstack.asm - C run-time: setup xstack 3 | ; 4 | ; Copyright (C) 2004, Erik Petrich 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundation; either version 2, or (at your option) any 9 | ; later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this library; see the file COPYING. If not, write to the 18 | ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | ; MA 02110-1301, USA. 20 | ; 21 | ; As a special exception, if you link this library with other files, 22 | ; some of which are compiled with SDCC, to produce an executable, 23 | ; this library does not by itself cause the resulting executable to 24 | ; be covered by the GNU General Public License. This exception does 25 | ; not however invalidate any other reasons why the executable file 26 | ; might be covered by the GNU General Public License. 27 | ;-------------------------------------------------------------------------- 28 | 29 | .area CSEG (CODE) 30 | .area GSINIT0 (CODE) 31 | .area GSINIT1 (CODE) 32 | .area GSINIT2 (CODE) 33 | .area GSINIT3 (CODE) 34 | .area GSINIT4 (CODE) 35 | .area GSINIT5 (CODE) 36 | .area GSINIT (CODE) 37 | .area GSFINAL (CODE) 38 | 39 | .globl __start__xstack 40 | .globl __XPAGE 41 | 42 | .area GSINIT1 (CODE) 43 | 44 | __sdcc_init_xstack:: 45 | 46 | ; Need to initialize in GSINIT1 in case the user's __sdcc_external_startup 47 | ; uses the xstack. 48 | 49 | mov __XPAGE,#(__start__xstack >> 8) 50 | mov _spx,#__start__xstack 51 | 52 | .area GSINIT5 (CODE) 53 | 54 | ; Need to initialize in GSINIT5 because __mcs51_genXINIT modifies __XPAGE 55 | ; and __mcs51_genRAMCLEAR modifies _spx. 56 | 57 | mov __XPAGE,#(__start__xstack >> 8) 58 | mov _spx,#__start__xstack 59 | -------------------------------------------------------------------------------- /SDCC/lib/src/memccpy.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | memccpy.c - part of string library functions 3 | 4 | Copyright (C) 2019, Philipp Klaus Krause . krauseph@informatik.uni-freiburg.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | void *memccpy (void *restrict dst, const void *restrict src, int c, size_t n) 32 | { 33 | char *d = dst; 34 | const char *s = src; 35 | 36 | while (n--) 37 | if ((*d++ = *s++) == (unsigned char)c) 38 | return (d); 39 | 40 | return (0); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /SDCC/lib/src/memcpy.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | memcpy.c - part of string library functions 3 | 4 | Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #undef memcpy /* Avoid conflict with wrapper macro of the same name */ 32 | 33 | void * __memcpy (void *dst, const void *src, size_t n); 34 | 35 | void *memcpy (void *dst, const void *src, size_t n) 36 | { 37 | return __memcpy (dst, src, n); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /SDCC/lib/src/modff.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | modff.c - Returns both the integer and fraction of a float. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | 33 | float modff(float x, float * y) 34 | { 35 | *y=(long)x; 36 | return (x-*y); 37 | } 38 | -------------------------------------------------------------------------------- /SDCC/lib/src/powf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | powf.c - Computes x**y where x and y are 32-bit floats. 3 | WARNING: less that 6 digits accuracy. 4 | 5 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 6 | 7 | This library is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 2, or (at your option) any 10 | later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this library; see the file COPYING. If not, write to the 19 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 20 | MA 02110-1301, USA. 21 | 22 | As a special exception, if you link this library with other files, 23 | some of which are compiled with SDCC, to produce an executable, 24 | this library does not by itself cause the resulting executable to 25 | be covered by the GNU General Public License. This exception does 26 | not however invalidate any other reasons why the executable file 27 | might be covered by the GNU General Public License. 28 | -------------------------------------------------------------------------*/ 29 | 30 | /* Version 1.0 - Initial release */ 31 | 32 | #include 33 | #include 34 | 35 | float powf(float x, float y) 36 | { 37 | if(y == 0.0) return 1.0; 38 | if(y == 1.0) return x; 39 | if(x <= 0.0) return 0.0; 40 | return expf(logf(x) * y); 41 | } 42 | -------------------------------------------------------------------------------- /SDCC/lib/src/printf_fast_f.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | printf_fast_f.c - Same as printf_fast, but with floating point enabled 3 | 4 | Copyright (C) 2004, Paul Stoffregen, paul@pjrc.com 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #define __SDCC_FLOAT_LIB 30 | #include 31 | 32 | #ifdef FLOAT_ASM_MCS51 33 | 34 | #define FLOAT 35 | #define PRINTF_FAST printf_fast_f 36 | 37 | #include "printf_fast.c" 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /SDCC/lib/src/puts.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------- 2 | puts.c - source file for C function puts() 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause . pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | int puts (const char *s) 32 | { 33 | while (*s) 34 | if (putchar(*s++) == EOF) 35 | return EOF; 36 | return putchar('\n'); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /SDCC/lib/src/qsort.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------- 2 | qsort() - sort an array 3 | 4 | Copyright (C) 2018, Philipp Klaus Krause . krauseph@informatik.uni-freiburg.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | // Despite the name, this is an insertion sort, since it tends to be smaller in code size. 32 | 33 | static void swap(void *restrict dst, void *restrict src, size_t n) 34 | { 35 | unsigned char *restrict d = dst; 36 | unsigned char *restrict s = src; 37 | 38 | while(n--) 39 | { 40 | unsigned char tmp = *d; 41 | *d = *s; 42 | *s = tmp; 43 | d++; 44 | s++; 45 | } 46 | } 47 | 48 | void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *) __reentrant) 49 | { 50 | unsigned char *b = base; 51 | 52 | if(nmemb <= 1) 53 | return; 54 | 55 | for(unsigned char *i = base; i < b + nmemb * size; i += size) 56 | { 57 | for(unsigned char *j = i; (j > b) && (*compar)(j, j - size) < 0; j -= size) 58 | swap(j, j - size, size); 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /SDCC/lib/src/rand.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | rand.c - random number generator 3 | 4 | Copyright (C) 2017, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | 28 | This is an xorshift PRNG. See George Marsaglia, "Xorshift RNGs" for details. 29 | The width of 32 bits was chosen to not regress in period length vs. the 30 | PRNG from the C standard, while at the same time minimizing RAM usage. 31 | The parameters a, b, c were chosen to allow the generation of efficient code. 32 | -------------------------------------------------------------------------*/ 33 | 34 | #include 35 | 36 | #include 37 | 38 | static uint32_t s = 0x80000001; 39 | 40 | int rand(void) 41 | { 42 | register unsigned long t = s; 43 | 44 | t ^= t >> 10; 45 | t ^= t << 9; 46 | t ^= t >> 25; 47 | 48 | s = t; 49 | 50 | return(t & RAND_MAX); 51 | } 52 | 53 | void srand(unsigned int seed) 54 | { 55 | s = seed | 0x80000000; /* s shall not become 0 */ 56 | } 57 | 58 | -------------------------------------------------------------------------------- /SDCC/lib/src/sinf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | sinf.c - Computes sin(x) where x is a 32-bit float. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | 34 | float sincosf(float x, bool iscos); 35 | 36 | float sinf(float x) _FLOAT_FUNC_REENTRANT 37 | { 38 | if (x==0.0) return 0.0; 39 | return sincosf(x, 0); 40 | } 41 | -------------------------------------------------------------------------------- /SDCC/lib/src/sinhf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | sinhf.c - Computes sinh(x) where x is a 32-bit float. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | 34 | float sincoshf(float x, bool iscosh); 35 | 36 | float sinhf(float x) _FLOAT_FUNC_REENTRANT 37 | { 38 | return sincoshf(x, 0); 39 | } 40 | -------------------------------------------------------------------------------- /SDCC/lib/src/sprintf.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------- 2 | sprintf.c - formatted output conversion 3 | 4 | Copyright (C) 1999, Martijn van Balen 5 | Refactored by - Maarten Brock (2004) 6 | 7 | This library is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 2, or (at your option) any 10 | later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this library; see the file COPYING. If not, write to the 19 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 20 | MA 02110-1301, USA. 21 | 22 | As a special exception, if you link this library with other files, 23 | some of which are compiled with SDCC, to produce an executable, 24 | this library does not by itself cause the resulting executable to 25 | be covered by the GNU General Public License. This exception does 26 | not however invalidate any other reasons why the executable file 27 | might be covered by the GNU General Public License. 28 | -------------------------------------------------------------------------*/ 29 | 30 | #include 31 | #include 32 | 33 | static void 34 | put_char_to_string (char c, void* p) _REENTRANT 35 | { 36 | char **buf = (char **)p; 37 | *(*buf)++ = c; 38 | } 39 | 40 | int 41 | vsprintf (char *buf, const char *format, va_list ap) 42 | { 43 | int i; 44 | i = _print_format (put_char_to_string, &buf, format, ap); 45 | *buf = 0; 46 | return i; 47 | } 48 | 49 | int 50 | sprintf (char *buf, const char *format, ...) 51 | { 52 | va_list arg; 53 | int i; 54 | 55 | va_start (arg, format); 56 | i = _print_format (put_char_to_string, &buf, format, arg); 57 | *buf = 0; 58 | va_end (arg); 59 | 60 | return i; 61 | } 62 | -------------------------------------------------------------------------------- /SDCC/lib/src/sqrtf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | sqrtf.c - Computes square root of a 32-bit float as outlined in [1] 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* [1] William James Cody and W. M. Waite. _Software manual for the 30 | elementary functions_, Englewood Cliffs, N.J.:Prentice-Hall, 1980. */ 31 | 32 | /* Version 1.0 - Initial release */ 33 | 34 | #include 35 | #include 36 | 37 | float sqrtf(float x) _FLOAT_FUNC_REENTRANT 38 | { 39 | float f, y; 40 | int n; 41 | 42 | if (x==0.0) return x; 43 | else if (x==1.0) return 1.0; 44 | else if (x<0.0) 45 | { 46 | errno=EDOM; 47 | return 0.0; 48 | } 49 | f=frexpf(x, &n); 50 | y=0.41731+0.59016*f; /*Educated guess*/ 51 | /*For a 24 bit mantisa (float), two iterations are sufficient*/ 52 | y+=f/y; 53 | y=ldexpf(y, -2) + f/y; /*Faster version of 0.25 * y + f/y*/ 54 | 55 | if (n&1) 56 | { 57 | y*=0.7071067812; 58 | ++n; 59 | } 60 | return ldexpf(y, n/2); 61 | } 62 | -------------------------------------------------------------------------------- /SDCC/lib/src/strdup.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | strdup.c - part of string library functions 3 | 4 | Copyright (C) 2019, Philipp Klaus Krause . krauseph@informatik.uni-freiburg.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | 33 | char *strdup (const char *s) 34 | { 35 | char *r = malloc(strlen(s) + 1); 36 | if (r) 37 | strcpy(r, s); 38 | return (r); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /SDCC/lib/src/strndup.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | strndup.c - part of string library functions 3 | 4 | Copyright (C) 2019, Philipp Klaus Krause . krauseph@informatik.uni-freiburg.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | 33 | char *strndup (const char *s, size_t n) 34 | { 35 | size_t l = strlen (s); 36 | if (l > n) 37 | l = n; 38 | char *r = malloc (l + 1); 39 | if (r) 40 | { 41 | memcpy (r, s, l); 42 | r[l] = 0; 43 | } 44 | return (r); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /SDCC/lib/src/strxfrm.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | _strcmp.c - part of string library functions 3 | 4 | Copyright (C) 2011, Philipp Klaus Krause . pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include "string.h" 30 | 31 | size_t strxfrm(char *dest, const char *src, size_t n) 32 | { 33 | strncpy(dest, src, n); 34 | return(strlen(src) + 1); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /SDCC/lib/src/tanf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | tanf.c - Computes tan(x) where x is a 32-bit float. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* Version 1.0 - Initial release */ 30 | 31 | #include 32 | #include 33 | 34 | float tancotf(float x, bool iscotan); 35 | 36 | float tanf(float x) _FLOAT_FUNC_REENTRANT 37 | { 38 | return tancotf(x, 0); 39 | } 40 | -------------------------------------------------------------------------------- /SDCC/lib/src/tanhf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | tanhf.c - Computes tanh(x) where x is a 32-bit float as outlined in [1]. 3 | 4 | Copyright (C) 2001, 2002, Jesus Calvino-Fraga, jesusc@ieee.org 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | /* [1] William James Cody and W. M. Waite. _Software manual for the 30 | elementary functions_, Englewood Cliffs, N.J.:Prentice-Hall, 1980. */ 31 | 32 | /* Version 1.0 - Initial release */ 33 | 34 | #include 35 | #include 36 | 37 | #define P0 -0.8237728127E+0 38 | #define P1 -0.3831010665E-2 39 | #define Q0 0.2471319654E+1 40 | #define Q1 0.1000000000E+1 41 | 42 | /* ln(3)/2 */ 43 | #define K1 0.5493061443E+0 44 | /* SBIG=[ln(2)+(t+1)*ln(B)]/2 */ 45 | #define SBIG 9.01091 46 | 47 | #define P(g) ((P1*g+P0)*g) 48 | #define Q(g) (Q1*g+Q0) 49 | 50 | float tanhf(float x) _FLOAT_FUNC_REENTRANT 51 | { 52 | float f, g, r; 53 | 54 | f=fabsf(x); 55 | if(f>SBIG) r=1.0; 56 | else if(f>K1) 57 | { 58 | r=0.5-1.0/(expf(f+f)+1.0); 59 | r+=r; 60 | } 61 | else if(f 32 | 33 | int tolower (int c) 34 | { 35 | return (isupper (c) ? c + ('a' - 'A') : c); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /SDCC/lib/src/toupper.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | toupper.c 3 | 4 | Philipp Klaus Krause, philipp@informatik.uni-frankfurt.de 2013 5 | 6 | (c) 2013 Goethe-Universität Frankfurt 7 | 8 | This library is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2, or (at your option) any 11 | later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this library; see the file COPYING. If not, write to the 20 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21 | MA 02110-1301, USA. 22 | 23 | As a special exception, if you link this library with other files, 24 | some of which are compiled with SDCC, to produce an executable, 25 | this library does not by itself cause the resulting executable to 26 | be covered by the GNU General Public License. This exception does 27 | not however invalidate any other reasons why the executable file 28 | might be covered by the GNU General Public License. 29 | -------------------------------------------------------------------------*/ 30 | 31 | #include 32 | 33 | int toupper (int c) 34 | { 35 | return (islower (c) ? c + ('A' - 'a') : c); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /SDCC/lib/src/vprintf.c: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------- 2 | vprintf.c - formatted output conversion 3 | 4 | Copyright (C) 1999, Martijn van Balen 5 | Refactored by - Maarten Brock (2004) 6 | 7 | This library is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 2, or (at your option) any 10 | later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this library; see the file COPYING. If not, write to the 19 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 20 | MA 02110-1301, USA. 21 | 22 | As a special exception, if you link this library with other files, 23 | some of which are compiled with SDCC, to produce an executable, 24 | this library does not by itself cause the resulting executable to 25 | be covered by the GNU General Public License. This exception does 26 | not however invalidate any other reasons why the executable file 27 | might be covered by the GNU General Public License. 28 | -------------------------------------------------------------------------*/ 29 | 30 | #include 31 | #include 32 | 33 | static void 34 | put_char_to_stdout (char c, void* p) _REENTRANT 35 | { 36 | p; //make compiler happy 37 | putchar (c); 38 | } 39 | 40 | int 41 | vprintf (const char *format, va_list ap) 42 | { 43 | return _print_format (put_char_to_stdout, NULL, format, ap); 44 | } 45 | 46 | int 47 | printf (const char *format, ...) 48 | { 49 | va_list arg; 50 | int i; 51 | 52 | va_start (arg, format); 53 | i = _print_format (put_char_to_stdout, NULL, format, arg); 54 | va_end (arg); 55 | 56 | return i; 57 | } 58 | -------------------------------------------------------------------------------- /SDCC/lib/src/wcrtomb.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | wcrtomb.c - convert a wide character to a multibyte sequence 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | size_t wcrtomb(char *restrict s, wchar_t wc, mbstate_t *restrict ps) 35 | { 36 | size_t ret; 37 | 38 | ps; 39 | 40 | ret = wctomb(s, wc); 41 | 42 | if(ret == (size_t)(-1)) 43 | errno = EILSEQ; 44 | 45 | return(ret); 46 | } 47 | 48 | -------------------------------------------------------------------------------- /SDCC/lib/src/wcscmp.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | wcscmp.c - compare strings 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | int wcscmp(const wchar_t *s1, const wchar_t *s2) 32 | { 33 | while(*s1 == *s2 && *s1) 34 | s1++, s2++; 35 | 36 | if(*s1 < *s2) 37 | return(-1); 38 | if(*s1 > *s2) 39 | return(1); 40 | return(0); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /SDCC/lib/src/wcslen.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | wcslen.c - compute the length of a string 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | size_t wcslen(const wchar_t *s) 32 | { 33 | register size_t n = 0; 34 | while (*s) 35 | { 36 | n++; 37 | s++; 38 | } 39 | 40 | return n; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /SDCC/lib/src/wcstombs.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | wctomb.c - convert a wide character string to a multibyte string 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | 33 | size_t wcstombs(char *restrict s, const wchar_t *restrict pwcs, size_t n) 34 | { 35 | size_t m = 0; 36 | char buffer[MB_LEN_MAX]; 37 | 38 | while(n > MB_LEN_MAX || n >= wctomb(buffer, *pwcs)) 39 | { 40 | int b = wctomb(s, *pwcs); 41 | 42 | if(b == 1 && !*s) 43 | break; 44 | if(b < 0) 45 | return(-1); 46 | 47 | n -= b; 48 | m += b; 49 | s += b; 50 | pwcs++; 51 | } 52 | 53 | return(m); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /SDCC/lib/src/wctob.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | wctob.c - convert a wide character to a single-byte character 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | #include 32 | 33 | _Static_assert(WEOF & 0xffffff80, "Invalid WEOF"); 34 | 35 | int wctob(wint_t c) 36 | { 37 | if(c & 0xffffff80) 38 | return WEOF; 39 | return c; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /SDCC/lib/src/wctomb.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | wctomb.c - convert a wide character to a multibyte sequence 3 | 4 | Copyright (C) 2016, Philipp Klaus Krause, pkk@spth.de 5 | 6 | This library is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU General Public License as published by the 8 | Free Software Foundation; either version 2, or (at your option) any 9 | later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this library; see the file COPYING. If not, write to the 18 | Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 19 | MA 02110-1301, USA. 20 | 21 | As a special exception, if you link this library with other files, 22 | some of which are compiled with SDCC, to produce an executable, 23 | this library does not by itself cause the resulting executable to 24 | be covered by the GNU General Public License. This exception does 25 | not however invalidate any other reasons why the executable file 26 | might be covered by the GNU General Public License. 27 | -------------------------------------------------------------------------*/ 28 | 29 | #include 30 | 31 | int wctomb(char *s, wchar_t wc) 32 | { 33 | if(!s) 34 | return(0); 35 | 36 | if(wc < 0x80) 37 | { 38 | s[0] = wc; 39 | return(1); 40 | } 41 | else if(wc < 0x800) 42 | { 43 | s[0] = (wc >> 6) & 0x1f | 0xc0; 44 | s[1] = (wc >> 0) & 0x3f | 0x80; 45 | return(2); 46 | } 47 | else if(wc >= 0xd800 && wc < 0xe000) // Unpaired surrogate 48 | return(-1); 49 | else if(wc < 0x10000) 50 | { 51 | s[0] = (wc >> 12) & 0x0f | 0xe0; 52 | s[1] = (wc >> 6) & 0x3f | 0x80; 53 | s[2] = (wc >> 0) & 0x3f | 0x80; 54 | return(3); 55 | } 56 | else if(wc < 0x110000) 57 | { 58 | s[0] = (wc >> 18) & 0x07 | 0xf0; 59 | s[1] = (wc >> 12) & 0x3f | 0x80; 60 | s[2] = (wc >> 6) & 0x3f | 0x80; 61 | s[3] = (wc >> 0) & 0x3f | 0x80; 62 | return(4); 63 | } 64 | else 65 | return(-1); 66 | } 67 | 68 | -------------------------------------------------------------------------------- /USBhostDisplayDemo/gfxfont.h: -------------------------------------------------------------------------------- 1 | // Font structures for newer Adafruit_GFX (1.1 and later). 2 | // Example fonts are included in 'Fonts' directory. 3 | // To use a font in your Arduino sketch, #include the corresponding .h 4 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 5 | // revert to 'classic' fixed-space bitmap font. 6 | 7 | #ifndef _GFXFONT_H_ 8 | #define _GFXFONT_H_ 9 | 10 | /// Font data stored PER GLYPH 11 | typedef struct { 12 | uint16_t bitmapOffset; ///< Pointer into GFXfont->bitmap 13 | uint8_t width; ///< Bitmap dimensions in pixels 14 | uint8_t height; ///< Bitmap dimensions in pixels 15 | uint8_t xAdvance; ///< Distance to advance cursor (x axis) 16 | int8_t xOffset; ///< X dist from cursor pos to UL corner 17 | int8_t yOffset; ///< Y dist from cursor pos to UL corner 18 | } GFXglyph; 19 | 20 | /// Data stored for FONT AS A WHOLE 21 | typedef struct { 22 | uint8_t *bitmap; ///< Glyph bitmaps, concatenated 23 | GFXglyph *glyph; ///< Glyph array 24 | uint8_t first; ///< ASCII extents (first char) 25 | uint8_t last; ///< ASCII extents (last char) 26 | uint8_t yAdvance; ///< Newline distance (y axis) 27 | } GFXfont; 28 | 29 | #endif // _GFXFONT_H_ 30 | -------------------------------------------------------------------------------- /chflasher.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atc1441/CH559sdccUSBHost/6b132f0543bd4027b3c65af046157bcb7704fbeb/chflasher.exe -------------------------------------------------------------------------------- /compile.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set project_name=CH559USB 3 | set xram_size=0x0800 4 | set xram_loc=0x0600 5 | set code_size=0xEFFF 6 | set dfreq_sys=48000000 7 | 8 | if not exist "config.h" echo //add your personal defines here > config.h 9 | 10 | SDCC\bin\sdcc -c -V -mmcs51 --model-large --xram-size %xram_size% --xram-loc %xram_loc% --code-size %code_size% -I/ -DFREQ_SYS=%dfreq_sys% main.c 11 | SDCC\bin\sdcc -c -V -mmcs51 --model-large --xram-size %xram_size% --xram-loc %xram_loc% --code-size %code_size% -I/ -DFREQ_SYS=%dfreq_sys% util.c 12 | SDCC\bin\sdcc -c -V -mmcs51 --model-large --xram-size %xram_size% --xram-loc %xram_loc% --code-size %code_size% -I/ -DFREQ_SYS=%dfreq_sys% USBHost.c 13 | SDCC\bin\sdcc -c -V -mmcs51 --model-large --xram-size %xram_size% --xram-loc %xram_loc% --code-size %code_size% -I/ -DFREQ_SYS=%dfreq_sys% uart.c 14 | 15 | SDCC\bin\sdcc main.rel util.rel USBHost.rel uart.rel -V -mmcs51 --model-large --xram-size %xram_size% --xram-loc %xram_loc% --code-size %code_size% -I/ -DFREQ_SYS=%dfreq_sys% -o %project_name%.ihx 16 | 17 | SDCC\bin\packihx %project_name%.ihx > %project_name%.hex 18 | 19 | SDCC\bin\hex2bin -c %project_name%.hex 20 | 21 | del %project_name%.lk 22 | del %project_name%.map 23 | del %project_name%.mem 24 | del %project_name%.ihx 25 | 26 | del *.asm 27 | del *.lst 28 | del *.rel 29 | del *.rst 30 | del *.sym 31 | 32 | 33 | Rem This tool flashes the bin file directly to the ch559 chip, you need to install the libusb-win32 driver with the zadig( https://zadig.akeo.ie/ ) tool so the tool can access the usb device 34 | chflasher.exe %project_name%.bin 35 | -------------------------------------------------------------------------------- /config.h: -------------------------------------------------------------------------------- 1 | //add your personal defines here 2 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | typedef unsigned char *PUINT8; 2 | typedef unsigned char __xdata *PUINT8X; 3 | typedef const unsigned char __code *PUINT8C; 4 | typedef unsigned char __xdata UINT8X; 5 | typedef unsigned char __data UINT8D; 6 | 7 | #include 8 | #include 9 | #include 10 | #include "CH559.h" 11 | #include "util.h" 12 | #include "USBHost.h" 13 | #include "uart.h" 14 | 15 | SBIT(LED, 0x90, 6); 16 | 17 | void main() 18 | { 19 | unsigned char s; 20 | initClock(); 21 | initUART0(1000000, 1); 22 | DEBUG_OUT("Startup\n"); 23 | resetHubDevices(0); 24 | resetHubDevices(1); 25 | initUSB_Host(); 26 | DEBUG_OUT("Ready\n"); 27 | sendProtocolMSG(MSG_TYPE_STARTUP,0, 0x00, 0x00, 0x00, 0); 28 | while(1) 29 | { 30 | if(!(P4_IN & (1 << 6))) 31 | runBootloader(); 32 | processUart(); 33 | s = checkRootHubConnections(); 34 | pollHIDdevice(); 35 | } 36 | } -------------------------------------------------------------------------------- /uart.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include "CH559.h" 6 | #include "util.h" 7 | #include "uart.h" 8 | 9 | uint8_t __xdata uartRxBuff[64]; 10 | uint8_t __xdata rxPos = 0; 11 | 12 | 13 | void processUart(){ 14 | while(RI){ 15 | RI=0; 16 | uartRxBuff[rxPos] = SBUF; 17 | if (uartRxBuff[rxPos]=='\n' || rxPos >= 64){ 18 | for (uint8_t i = 0; i < rxPos; i ++ ) 19 | { 20 | printf( "0x%02X ",uartRxBuff[i]); 21 | } 22 | printf("\n"); 23 | if(uartRxBuff[0]=='k'){ 24 | //if(uartRxBuff[1]==0x61)LED=0; 25 | //if(uartRxBuff[1]==0x73)LED=1; 26 | if(uartRxBuff[1]=='b')runBootloader(); 27 | } 28 | rxPos=0; 29 | }else{ 30 | rxPos++; 31 | } 32 | } 33 | } 34 | 35 | void sendProtocolMSG(unsigned char msgtype, unsigned short length, unsigned char type, unsigned char device, unsigned char endpoint, unsigned char __xdata *msgbuffer){ 36 | unsigned short i; 37 | putchar(0xFE); 38 | putchar(length); 39 | putchar((unsigned char)(length>>8)); 40 | putchar(msgtype); 41 | putchar(type); 42 | putchar(device); 43 | putchar(endpoint); 44 | putchar(0); 45 | putchar(0); 46 | putchar(0); 47 | putchar(0); 48 | for (i = 0; i < length; i++) 49 | { 50 | putchar(msgbuffer[i]); 51 | } 52 | putchar('\n'); 53 | } 54 | 55 | void sendHidPollMSG(unsigned char msgtype, unsigned short length, unsigned char type, unsigned char device, unsigned char endpoint, unsigned char __xdata *msgbuffer,unsigned char idVendorL,unsigned char idVendorH,unsigned char idProductL,unsigned char idProductH){ 56 | unsigned short i; 57 | putchar(0xFE); 58 | putchar(length); 59 | putchar((unsigned char)(length>>8)); 60 | putchar(msgtype); 61 | putchar(type); 62 | putchar(device); 63 | putchar(endpoint); 64 | putchar(idVendorL); 65 | putchar(idVendorH); 66 | putchar(idProductL); 67 | putchar(idProductH); 68 | for (i = 0; i < length; i++) 69 | { 70 | putchar(msgbuffer[i]); 71 | } 72 | putchar('\n'); 73 | } -------------------------------------------------------------------------------- /uart.h: -------------------------------------------------------------------------------- 1 | #ifndef __uart_H__ 2 | #define __uart_H__ 3 | 4 | #define MSG_TYPE_CONNECTED 0x01 5 | #define MSG_TYPE_DISCONNECTED 0x02 6 | #define MSG_TYPE_ERROR 0x03 7 | #define MSG_TYPE_DEVICE_POLL 0x04 8 | #define MSG_TYPE_DEVICE_STRING 0x05 9 | #define MSG_TYPE_DEVICE_INFO 0x06 10 | #define MSG_TYPE_HID_INFO 0x07 11 | #define MSG_TYPE_STARTUP 0x08 12 | 13 | void processUart(); 14 | void sendHidPollMSG(unsigned char msgtype, unsigned short length, unsigned char type, unsigned char device, unsigned char endpoint, unsigned char __xdata *msgbuffer,unsigned char idVendorL,unsigned char idVendorH,unsigned char idProductL,unsigned char idProductH); 15 | void sendProtocolMSG(unsigned char msgtype, unsigned short length, unsigned char type, unsigned char device, unsigned char endpoint, unsigned char __xdata *msgbuffer); 16 | 17 | #endif -------------------------------------------------------------------------------- /util.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTIL_H__ 2 | #define __UTIL_H__ 3 | #include 4 | #if 0 5 | #define DEBUG_OUT(...) printf(__VA_ARGS__); 6 | #else 7 | #define DEBUG_OUT(...) (void)0; 8 | #endif 9 | 10 | void initClock(); 11 | void delayUs(unsigned short n); 12 | void delay(unsigned short n); 13 | void initUART0(unsigned long baud, int alt); 14 | unsigned char UART0Receive(); 15 | void UART0Send(unsigned char b); 16 | 17 | #define PIN_MODE_INPUT 0 18 | #define PIN_MODE_INPUT_PULLUP 1 19 | #define PIN_MODE_OUTPUT 2 20 | #define PIN_MODE_OUTPUT_OPEN_DRAIN 3 21 | #define PIN_MODE_OUTPUT_OPEN_DRAIN_2CLK 4 22 | #define PIN_MODE_INPUT_OUTPUT_PULLUP 5 23 | #define PIN_MODE_INPUT_OUTPUT_PULLUP_2CLK 6 24 | void pinMode(unsigned char port, unsigned char pin, unsigned char mode); 25 | 26 | typedef void(* __data FunctionReference)(); 27 | extern FunctionReference runBootloader; 28 | 29 | #endif --------------------------------------------------------------------------------