From: vrokas Date: Sun, 3 Oct 2004 12:05:16 +0000 (+0000) Subject: * device/include/pic16/stdio.h, X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=e13955dc79226eebc369a46bdead01e22e0d2e8d;p=fw%2Fsdcc * device/include/pic16/stdio.h, * device/include/pic16/stdlib.h, * device/include/pic16/math.h: NEW * device/lib/pic16/libsdcc/gptr/*.c (gptrget*, gptrput*): functions declared as _naked to reduce overhead git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3521 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 76920254..20ab8862 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2004-10-03 Vangelis Rokas + * device/include/pic16/stdio.h, + * device/include/pic16/stdlib.h, + * device/include/pic16/math.h: NEW + * device/lib/pic16/libsdcc/gptr/*.c (gptrget*, gptrput*): functions + declared as _naked to reduce overhead * device/lib/Makefile.in (target port-specific-objects-pic16): changed * to *.* so to ignore the CVS directory, * src/pic16/gen.c (pic16_freeAsmop): added code to store result of diff --git a/device/include/asm/pic16/features.h b/device/include/asm/pic16/features.h index 44535f2b..d0ef2bbd 100644 --- a/device/include/asm/pic16/features.h +++ b/device/include/asm/pic16/features.h @@ -13,12 +13,11 @@ #ifndef __PIC16_ASM_FEATURES_H #define __PIC16_ASM_FEATURES_H 1 -#if 0 -#define _IL_REENTRANT reentrant -#define _FS_REENTRANT reentrant -#else +#define _REENTRANT + #define _IL_REENTRANT #define _FS_REENTRANT -#endif +#define _MATH_REENTRANT + -#endif +#endif /* __PIC16_ASM_FEATURES_H */ diff --git a/device/include/pic16/math.h b/device/include/pic16/math.h new file mode 100644 index 00000000..16ecbbed --- /dev/null +++ b/device/include/pic16/math.h @@ -0,0 +1,82 @@ +/* math.h: Floating point math function declarations + + Ported to PIC16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + Copyright (C) 2001 Jesus Calvino-Fraga, jesusc@ieee.org + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* Version 1.0 - Initial release */ + +#ifndef __PIC16_MATH_H +#define __PIC16_MATH_H 1 + + +#define PI 3.1415926536 +#define TWO_PI 6.2831853071 +#define HALF_PI 1.5707963268 +#define QUART_PI 0.7853981634 +#define iPI 0.3183098862 +#define iTWO_PI 0.1591549431 +#define TWO_O_PI 0.6366197724 + +// EPS=B**(-t/2), where B is the radix of the floating-point representation +// and there are t base-B digits in the significand. Therefore, for floats +// EPS=2**(-12). Also define EPS2=EPS*EPS. +#define EPS 244.14062E-6 +#define EPS2 59.6046E-9 +#define XMAX 3.402823466E+38 + +union float_long +{ + float f; + long l; +}; + +/********************************************** + * Prototypes for float ANSI C math functions * + **********************************************/ + +/* Trigonometric functions */ +float sinf(const float x) _MATH_REENTRANT; +float cosf(const float x) _MATH_REENTRANT; +float tanf(const float x) _MATH_REENTRANT; +float cotf(const float x) _MATH_REENTRANT; +float asinf(const float x) _MATH_REENTRANT; +float acosf(const float x) _MATH_REENTRANT; +float atanf(const float x) _MATH_REENTRANT; +float atan2f(const float x, const float y); + +/* Hyperbolic functions */ +float sinhf(const float x) _MATH_REENTRANT; +float coshf(const float x) _MATH_REENTRANT; +float tanhf(const float x) _MATH_REENTRANT; + +/* Exponential, logarithmic and power functions */ +float expf(const float x); +float logf(const float x) _MATH_REENTRANT; +float log10f(const float x) _MATH_REENTRANT; +float powf(const float x, const float y); +float sqrtf(const float a) _MATH_REENTRANT; + +/* Nearest integer, absolute value, and remainder functions */ +float fabsf(const float x) _MATH_REENTRANT; +float frexpf(const float x, int *pw2); +float ldexpf(const float x, const int pw2); +float ceilf(float x) _MATH_REENTRANT; +float floorf(float x) _MATH_REENTRANT; +float modff(float x, float * y); + +#endif /* _PIC16_MATH_H */ diff --git a/device/include/pic16/stdio.h b/device/include/pic16/stdio.h new file mode 100644 index 00000000..5050b810 --- /dev/null +++ b/device/include/pic16/stdio.h @@ -0,0 +1,60 @@ +/*------------------------------------------------------------------------- + stdio.h - ANSI functions forward declarations + + Ported to PIC16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef __PIC16_STDIO_H +#define __PIC16_STDIO_H 1 + +#include + +#include + +#ifndef NULL + #define NULL (void *)0 +#endif + +#ifndef _SIZE_T_DEFINED +#define _SIZE_T_DEFINED + typedef unsigned int size_t; +#endif + +typedef void (*pfn_outputchar)(char c, void* p) _REENTRANT; + +extern int _print_format (pfn_outputchar pfn, void* pvoid, const char *format, va_list ap); + +/*-----------------------------------------------------------------------*/ + +extern void printf_small (char *,...); _REENTRANT; +extern int printf (const char *,...); +extern int vprintf (const char *, va_list); +extern int sprintf (char *, const char *, ...); +extern int vsprintf (char *, const char *, va_list); +extern int puts(const char *); +extern char *gets(char *); +extern char getchar(void); +extern void putchar(char); + + +#endif /* __PIC16_STDIO_H */ diff --git a/device/include/pic16/stdlib.h b/device/include/pic16/stdlib.h new file mode 100644 index 00000000..f13b4a02 --- /dev/null +++ b/device/include/pic16/stdlib.h @@ -0,0 +1,46 @@ +/*------------------------------------------------------------------------- + stdlib.h - ANSI functions forward declarations + + Ported to PIC16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) + + Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998) + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + In other words, you are welcome to use, share and improve this program. + You are forbidden to forbid anyone else to use, share and improve + what you give them. Help stamp out software-hoarding! +-------------------------------------------------------------------------*/ + +#ifndef __PIC16_STDLIB_H +#define __PIC16_STDLIB_H 1 + +#ifndef NULL +# define NULL (void *)0 +#endif + +//#include + +extern float atof (char *); +extern int atoi (char *); +extern long atol (char *); + +extern void uitoa(unsigned int, char*, unsigned char); +extern void itoa(unsigned int, char*, unsigned char); + +extern void ultoa(unsigned long, char*, unsigned char); +extern void ltoa(unsigned long, char*, unsigned char); + +#endif /* __PIC16_STDLIB_H */ diff --git a/device/lib/pic16/libsdcc/gptr/gptrget1.c b/device/lib/pic16/libsdcc/gptr/gptrget1.c index 084ccae6..919c89e9 100644 --- a/device/lib/pic16/libsdcc/gptr/gptrget1.c +++ b/device/lib/pic16/libsdcc/gptr/gptrget1.c @@ -43,7 +43,7 @@ extern TBLPTRU; extern TABLAT; extern PRODL; -void _gptrget1(void) +void _gptrget1(void) _naked { _asm /* decode generic pointer MSB (in WREG) bits 6 and 7: diff --git a/device/lib/pic16/libsdcc/gptr/gptrget2.c b/device/lib/pic16/libsdcc/gptr/gptrget2.c index c16581f2..6d4ca321 100644 --- a/device/lib/pic16/libsdcc/gptr/gptrget2.c +++ b/device/lib/pic16/libsdcc/gptr/gptrget2.c @@ -44,7 +44,7 @@ extern TBLPTRU; extern TABLAT; extern PRODL; -void _gptrget2(void) +void _gptrget2(void) _naked { _asm /* decode generic pointer MSB (in WREG) bits 6 and 7: diff --git a/device/lib/pic16/libsdcc/gptr/gptrget3.c b/device/lib/pic16/libsdcc/gptr/gptrget3.c index 0e5d5868..91387a32 100644 --- a/device/lib/pic16/libsdcc/gptr/gptrget3.c +++ b/device/lib/pic16/libsdcc/gptr/gptrget3.c @@ -45,7 +45,7 @@ extern TABLAT; extern PRODL; extern PRODH; -void _gptrget3(void) +void _gptrget3(void) _naked { _asm /* decode generic pointer MSB (in WREG) bits 6 and 7: diff --git a/device/lib/pic16/libsdcc/gptr/gptrget4.c b/device/lib/pic16/libsdcc/gptr/gptrget4.c index 74f0a2cc..f0721f8f 100644 --- a/device/lib/pic16/libsdcc/gptr/gptrget4.c +++ b/device/lib/pic16/libsdcc/gptr/gptrget4.c @@ -45,7 +45,7 @@ extern TABLAT; extern PRODL; extern PRODH; -void _gptrget4(void) +void _gptrget4(void) _naked { _asm /* decode generic pointer MSB (in WREG) bits 6 and 7: diff --git a/device/lib/pic16/libsdcc/gptr/gptrput1.c b/device/lib/pic16/libsdcc/gptr/gptrput1.c index edda1e99..79df3509 100644 --- a/device/lib/pic16/libsdcc/gptr/gptrput1.c +++ b/device/lib/pic16/libsdcc/gptr/gptrput1.c @@ -44,7 +44,7 @@ extern TABLAT; extern PRODL; extern PRODH; -void _gptrput1(void) +void _gptrput1(void) _naked { _asm /* decode generic pointer MSB (in WREG) bits 6 and 7: diff --git a/device/lib/pic16/libsdcc/gptr/gptrput2.c b/device/lib/pic16/libsdcc/gptr/gptrput2.c index 58e2daa5..80589c5e 100644 --- a/device/lib/pic16/libsdcc/gptr/gptrput2.c +++ b/device/lib/pic16/libsdcc/gptr/gptrput2.c @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- - gptrput1.c :- put 1 byte value at generic pointer + gptrput1.c :- put 2 byte value at generic pointer Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) @@ -44,7 +44,7 @@ extern TABLAT; extern PRODL; extern PRODH; -void _gptrput2(void) +void _gptrput2(void) _naked { _asm /* decode generic pointer MSB (in WREG) bits 6 and 7: diff --git a/device/lib/pic16/libsdcc/gptr/gptrput3.c b/device/lib/pic16/libsdcc/gptr/gptrput3.c index 7ce8762e..c699c864 100644 --- a/device/lib/pic16/libsdcc/gptr/gptrput3.c +++ b/device/lib/pic16/libsdcc/gptr/gptrput3.c @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- - gptrput1.c :- put 1 byte value at generic pointer + gptrput3.c :- put 3 byte value at generic pointer Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) @@ -44,7 +44,7 @@ extern TABLAT; extern PRODL; extern PRODH; -void _gptrput3(void) +void _gptrput3(void) _naked { _asm /* decode generic pointer MSB (in WREG) bits 6 and 7: diff --git a/device/lib/pic16/libsdcc/gptr/gptrput4.c b/device/lib/pic16/libsdcc/gptr/gptrput4.c index adf5a8f9..6f0baaec 100644 --- a/device/lib/pic16/libsdcc/gptr/gptrput4.c +++ b/device/lib/pic16/libsdcc/gptr/gptrput4.c @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- - gptrput1.c :- put 1 byte value at generic pointer + gptrput4.c :- put 4 byte value at generic pointer Adopted for pic16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr) @@ -44,7 +44,7 @@ extern TABLAT; extern PRODL; extern PRODH; -void _gptrput4(void) +void _gptrput4(void) _naked { _asm /* decode generic pointer MSB (in WREG) bits 6 and 7: