diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
| commit | 268a53de823a6750d6256ee1fb1e7707b4b45740 (patch) | |
| tree | 42c1799a9a82b2f7d9790ee9fe181d72a7274751 /device/lib/s08 | |
| download | sdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz | |
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'device/lib/s08')
| -rw-r--r-- | device/lib/s08/Makefile | 97 | ||||
| -rw-r--r-- | device/lib/s08/Makefile.in | 97 | ||||
| -rw-r--r-- | device/lib/s08/_mulint.c | 138 | ||||
| -rw-r--r-- | device/lib/s08/_ret.c | 37 | ||||
| -rw-r--r-- | device/lib/s08/_setjmp.c | 135 |
5 files changed, 504 insertions, 0 deletions
diff --git a/device/lib/s08/Makefile b/device/lib/s08/Makefile new file mode 100644 index 0000000..38216cc --- /dev/null +++ b/device/lib/s08/Makefile @@ -0,0 +1,97 @@ +# libc/s08 Makefile + + +srcdir = . +top_builddir = ../../.. + +LIB_TYPE = RANLIB + +SCC = $(top_builddir)/bin/sdcc -ms08 +SAS = $(top_builddir)/bin/sdas6808 + +# override PORTDIR defined by super (parent) makefile +override PORTDIR = ../build/s08 + +include $(srcdir)/../incl.mk + +HC08_FLOAT = $(COMMON_FLOAT) + +HC08_INT = $(COMMON_INT) \ + _divsint.c \ + _divuint.c \ + _modsint.c \ + _moduint.c + +HC08_LONG = $(COMMON_LONG) \ + _mullong.c \ + _divulong.c + +HC08_LONGLONG = $(COMMON_LONGLONG) \ + _rrulonglong.c \ + _rrslonglong.c \ + _rlulonglong.c \ + _rlslonglong.c \ + _mullonglong.c \ + _divslonglong.c \ + _divulonglong.c \ + _modslonglong.c \ + _modulonglong.c + +HC08_SDCC = $(COMMON_SDCC) \ + _itoa.c \ + _ltoa.c \ + _spx.c \ + _startup.c \ + _strlen.c \ + _strcmp.c \ + _strcpy.c \ + __memcpy.c \ + memcpy.c \ + _memmove.c \ + _heap.c \ + sprintf.c \ + vprintf.c + +HC08SOURCES = $(addprefix ../,$(HC08_FLOAT) $(HC08_INT) $(HC08_LONG) $(HC08_LONGLONG) $(HC08_SDCC)) +HC08OBJECTS = $(patsubst %.c,%.rel,$(HC08_FLOAT) $(HC08_INT) $(HC08_LONG) $(HC08_LONGLONG) $(HC08_SDCC)) + +OBJ = _ret.rel _mulint.rel _setjmp.rel + +LIB = s08.lib +CC = $(SCC) +AS = $(SAS) +ASFLAGS = -plosgff + +CFLAGS = -I$(srcdir)/../../include -I. --std-c11 + +all: $(PORTDIR)/$(LIB) + +$(PORTDIR)/$(LIB): $(OBJ) $(HC08OBJECTS) Makefile +ifeq ($(LIB_TYPE), SDCCLIB) + rm -f $@; \ + $(top_builddir)/bin/sdcclib -a $@ $(OBJ) $(HC08OBJECTS) +else + ifeq ($(LIB_TYPE), AR) + $(top_builddir)/bin/sdar -rcSD $@ $(OBJ) $(HC08OBJECTS) + else + ifeq ($(LIB_TYPE), RANLIB) + $(top_builddir)/bin/sdar -rcD $@ $(OBJ) $(HC08OBJECTS) + else + rm -f $@ + for i in $(basename $(OBJ) $(HC08OBJECTS)); do echo $$i >>$@; done + cp $(OBJ) $(HC08OBJECTS) $(PORTDIR) + endif + endif +endif + +%.rel: %.c + $(CC) $(CFLAGS) -c $< + +%.rel: ../%.c + $(CC) $(CFLAGS) -c $< + +clean: + rm -f *.rel *.sym *.lst *~ $(CLEANSPEC) *.dump* *.asm *.lib + +distclean: clean + rm -f Makefile diff --git a/device/lib/s08/Makefile.in b/device/lib/s08/Makefile.in new file mode 100644 index 0000000..a74e174 --- /dev/null +++ b/device/lib/s08/Makefile.in @@ -0,0 +1,97 @@ +# libc/s08 Makefile + +VPATH = @srcdir@ +srcdir = @srcdir@ +top_builddir = @top_builddir@ + +LIB_TYPE = @LIB_TYPE@ + +SCC = $(top_builddir)/bin/sdcc -ms08 +SAS = $(top_builddir)/bin/sdas6808 + +# override PORTDIR defined by super (parent) makefile +override PORTDIR = ../build/s08 + +include $(srcdir)/../incl.mk + +HC08_FLOAT = $(COMMON_FLOAT) + +HC08_INT = $(COMMON_INT) \ + _divsint.c \ + _divuint.c \ + _modsint.c \ + _moduint.c + +HC08_LONG = $(COMMON_LONG) \ + _mullong.c \ + _divulong.c + +HC08_LONGLONG = $(COMMON_LONGLONG) \ + _rrulonglong.c \ + _rrslonglong.c \ + _rlulonglong.c \ + _rlslonglong.c \ + _mullonglong.c \ + _divslonglong.c \ + _divulonglong.c \ + _modslonglong.c \ + _modulonglong.c + +HC08_SDCC = $(COMMON_SDCC) \ + _itoa.c \ + _ltoa.c \ + _spx.c \ + _startup.c \ + _strlen.c \ + _strcmp.c \ + _strcpy.c \ + __memcpy.c \ + memcpy.c \ + _memmove.c \ + _heap.c \ + sprintf.c \ + vprintf.c + +HC08SOURCES = $(addprefix ../,$(HC08_FLOAT) $(HC08_INT) $(HC08_LONG) $(HC08_LONGLONG) $(HC08_SDCC)) +HC08OBJECTS = $(patsubst %.c,%.rel,$(HC08_FLOAT) $(HC08_INT) $(HC08_LONG) $(HC08_LONGLONG) $(HC08_SDCC)) + +OBJ = _ret.rel _mulint.rel _setjmp.rel + +LIB = s08.lib +CC = $(SCC) +AS = $(SAS) +ASFLAGS = -plosgff + +CFLAGS = -I$(srcdir)/../../include -I. --std-c11 + +all: $(PORTDIR)/$(LIB) + +$(PORTDIR)/$(LIB): $(OBJ) $(HC08OBJECTS) Makefile +ifeq ($(LIB_TYPE), SDCCLIB) + rm -f $@; \ + $(top_builddir)/bin/sdcclib -a $@ $(OBJ) $(HC08OBJECTS) +else + ifeq ($(LIB_TYPE), AR) + $(top_builddir)/bin/sdar -rcSD $@ $(OBJ) $(HC08OBJECTS) + else + ifeq ($(LIB_TYPE), RANLIB) + $(top_builddir)/bin/sdar -rcD $@ $(OBJ) $(HC08OBJECTS) + else + rm -f $@ + for i in $(basename $(OBJ) $(HC08OBJECTS)); do echo $$i >>$@; done + cp $(OBJ) $(HC08OBJECTS) $(PORTDIR) + endif + endif +endif + +%.rel: %.c + $(CC) $(CFLAGS) -c $< + +%.rel: ../%.c + $(CC) $(CFLAGS) -c $< + +clean: + rm -f *.rel *.sym *.lst *~ $(CLEANSPEC) *.dump* *.asm *.lib + +distclean: clean + rm -f Makefile diff --git a/device/lib/s08/_mulint.c b/device/lib/s08/_mulint.c new file mode 100644 index 0000000..0f7b370 --- /dev/null +++ b/device/lib/s08/_mulint.c @@ -0,0 +1,138 @@ +/*------------------------------------------------------------------------- + _mulint.c - routine for (unsigned) int (16 bit) multiplication + + Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net + + This library 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 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +/* Signed and unsigned multiplication are the same - as long as the output + has the same precision as the input. + + Assembler-functions are provided for: + hc08 + hc08 stack-auto +*/ + + +#if !defined(_SDCC_NO_ASM_LIB_FUNCS) + +#pragma save +#pragma less_pedantic +int +_mulint (int a, int b) +{ + a,b; /* reference to make compiler happy */ + +#if !defined(__SDCC_STACK_AUTO) + __asm + ais #-2 + psha + pshx + + ldx __mulint_PARM_2+1 + mul + sta 4,s + stx 3,s + + lda 1,s + ldx __mulint_PARM_2+1 + mul + add 3,s + sta 3,s + + lda 2,s + ldx __mulint_PARM_2 + mul + add 3,s + sta 3,s + + ais #2 + pulx + pula + __endasm; +#else + __asm + ais #-2 + psha + pshx + + ldx 8,s + mul + sta 4,s + stx 3,s + + lda 1,s + ldx 8,s + mul + add 3,s + sta 3,s + + lda 2,s + ldx 7,s + mul + add 3,s + sta 3,s + + ais #2 + pulx + pula + __endasm; +#endif +} +#pragma restore + +#else + +union uu { + struct { unsigned char hi,lo ;} s; + unsigned int t; +} ; + +int +_mulint (int a, int b) +{ +#if !defined(__SDCC_STACK_AUTO) && (defined(__SDCC_MODEL_LARGE) || defined(__SDCC_ds390)) // still needed for large + union uu __xdata *x; + union uu __xdata *y; + union uu t; + x = (union uu __xdata *)&a; + y = (union uu __xdata *)&b; +#else + register union uu *x; + register union uu *y; + union uu t; + x = (union uu *)&a; + y = (union uu *)&b; +#endif + + t.t = x->s.lo * y->s.lo; + t.s.hi += (x->s.lo * y->s.hi) + (x->s.hi * y->s.lo); + + return t.t; +} +#endif + + +#undef _MULINT_ASM + diff --git a/device/lib/s08/_ret.c b/device/lib/s08/_ret.c new file mode 100644 index 0000000..81315d2 --- /dev/null +++ b/device/lib/s08/_ret.c @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + _ret.c + + Copyright (C) 2003, Erik Petrich + Copyright (C) 2012, Philipp Klaus Krause + Considering how short this file is, it is probably not copyrightable, though. + + This library 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 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +__data unsigned char __SDCC_hc08_ret2; +__data unsigned char __SDCC_hc08_ret3; +__data unsigned char __SDCC_hc08_ret4; +__data unsigned char __SDCC_hc08_ret5; +__data unsigned char __SDCC_hc08_ret6; +__data unsigned char __SDCC_hc08_ret7; + diff --git a/device/lib/s08/_setjmp.c b/device/lib/s08/_setjmp.c new file mode 100644 index 0000000..f848d3a --- /dev/null +++ b/device/lib/s08/_setjmp.c @@ -0,0 +1,135 @@ +/*------------------------------------------------------------------------- + setjmp.c - source file for ANSI routines setjmp & longjmp + + Copyright (C) 2016, Maarten Brock. sourceforge.brock AT dse.nl + + This library 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 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library; see the file COPYING. If not, write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. + + As a special exception, if you link this library with other files, + some of which are compiled with SDCC, to produce an executable, + this library does not by itself cause the resulting executable to + be covered by the GNU General Public License. This exception does + not however invalidate any other reasons why the executable file + might be covered by the GNU General Public License. +-------------------------------------------------------------------------*/ + +#include <sdcc-lib.h> +#define __SDCC_HIDE_LONGJMP +#include <setjmp.h> + +static void dummy (void) __naked +{ + __asm + +;-------------------------------------------------------- +; overlayable items in ram +;-------------------------------------------------------- + .area OSEG (PAG, OVR) +___setjmp_buf: + .ds 2 + .area OSEG (PAG, OVR) +_longjmp_buf: + .ds 2 +;-------------------------------------------------------- +; extended address mode data +;-------------------------------------------------------- + .area XSEG +_longjmp_PARM_2: + .ds 2 +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area CSEG (CODE) +;------------------------------------------------------------ +;Allocation info for local variables in function '__setjmp' +;------------------------------------------------------------ +;buf Allocated with name '___setjmp_buf' +;------------------------------------------------------------ +;_setjmp.c:205: int __setjmp (jmp_buf buf) +; ----------------------------------------- +; function __setjmp +; ----------------------------------------- +; Stack space usage: 1 bytes. + .globl ___setjmp +___setjmp: + stx (___setjmp_buf + 0) ; msb(buf) + sta (___setjmp_buf + 1) ; lsb(buf) + + ; save stack pointer + tsx + pshh + txa + ldhx (___setjmp_buf) + sta 1,x + pula + sta 0,x + + ; save return address + lda 1,s + sta 2,x + lda 2,s + sta 3,x + + ; return 0 + clra + tax + rts + +;------------------------------------------------------------ +;Allocation info for local variables in function 'longjmp' +;------------------------------------------------------------ +;rv Allocated with name '_longjmp_PARM_2' +;buf Allocated with name '_longjmp_buf' +;------------------------------------------------------------ +;_setjmp.c:216: int longjmp (jmp_buf buf, int rv) +; ----------------------------------------- +; function longjmp +; ----------------------------------------- +; Stack space usage: 1 bytes. + .globl _longjmp + .globl _longjmp_PARM_2 +_longjmp: + stx (_longjmp_buf + 0) ; msb(buf) + sta (_longjmp_buf + 1) ; lsb(buf) + + ; restore stack pointer + ldhx (_longjmp_buf) + lda 0,x + psha + ldx 1,x + pulh + txs + + ; set return address + ldhx (_longjmp_buf) + lda 2,x + sta 1,s + lda 3,x + sta 2,s + +;_setjmp.c:224: return rv ? rv : 1; + ldx (_longjmp_PARM_2 + 0) + txa + ora (_longjmp_PARM_2 + 1) + beq 0001$ + lda (_longjmp_PARM_2 + 1) + rts +0001$: + lda #0x01 + rts + + __endasm; +} |
