From: MaartenBrock Date: Sun, 8 Apr 2007 13:05:45 +0000 (+0000) Subject: * device/include/pic16/pic18fregs.h, X-Git-Url: https://git.gag.com/?p=fw%2Fsdcc;a=commitdiff_plain;h=192a38bfafa3f31ffff65c59336261b1f3632543 * device/include/pic16/pic18fregs.h, * device/lib/_bp.c, * device/lib/_decdptr.c, * device/lib/_divsint.c, * device/lib/_divslong.c, * device/lib/_divuint.c, * device/lib/_divulong.c, * device/lib/_fs2schar.c, * device/lib/_fs2sint.c, * device/lib/_fs2slong.c, * device/lib/_fs2uchar.c, * device/lib/_fs2uint.c, * device/lib/_fs2ulong.c, * device/lib/_fsadd.c, * device/lib/_fscmp.c, * device/lib/_fsdiv.c, * device/lib/_fseq.c, * device/lib/_fsget1arg.c, * device/lib/_fsget2args.c, * device/lib/_fsgt.c, * device/lib/_fslt.c, * device/lib/_fsmul.c, * device/lib/_fsneq.c, * device/lib/_fsnormalize.c, * device/lib/_fsreturnval.c, * device/lib/_fsrshift.c, * device/lib/_fssub.c, * device/lib/_fsswapargs.c, * device/lib/_gptrget.c, * device/lib/_gptrgetc.c, * device/lib/_gptrput.c, * device/lib/_logexpf.c, * device/lib/_modsint.c, * device/lib/_modslong.c, * device/lib/_moduint.c, * device/lib/_modulong.c, * device/lib/_mulint.c, * device/lib/_mullong.c, * device/lib/_schar2fs.c, * device/lib/_ser.c, * device/lib/_setjmp.c, * device/lib/_sint2fs.c, * device/lib/_slong2fs.c, * device/lib/_spx.c, * device/lib/_uchar2fs.c, * device/lib/_uint2fs.c, * device/lib/_ulong2fs.c, * device/lib/asincosf.c, * device/lib/atanf.c, * device/lib/calloc.c, * device/lib/ds390/tinibios.c, * device/lib/ds400/tinibios.c, * device/lib/expf.c, * device/lib/free.c, * device/lib/hc08/_mulint.c, * device/lib/logf.c, * device/lib/malloc.c, * device/lib/printf_fast.c, * device/lib/printf_tiny.c, * device/lib/printfl.c, * device/lib/realloc.c, * device/lib/ser_ir.c, * device/lib/serial.c, * support/regression/tests/libmullong.c: replaced all special keywords with their double underscore equivalent * support/regression/ports/mcs51-xstack-auto/spec.mk, * device/lib/Makefile.in: compile libs with --std-c99 instead of --std-sdcc99 * src/mcs51/gen.c (outBitC): don't store if result is return-use-only, (genRet): if the bit-symbol is ruonly it already is in the carry * src/mcs51/ralloc.c (regTypeNum): make regType REG_CND for ruonly bit * src/SDCCast.c (createFunction): applied patch 887171 by Stas Sergeev * src/SDCCicode.c (ast2iCode): '!', GETHBIT, GETABIT: only set operand type UCHAR if dest is not bit git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4735 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index d16fe4fe..913d9c78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,80 @@ +2007-04-08 Maarten Brock + + * device/include/pic16/pic18fregs.h, + * device/lib/_bp.c, + * device/lib/_decdptr.c, + * device/lib/_divsint.c, + * device/lib/_divslong.c, + * device/lib/_divuint.c, + * device/lib/_divulong.c, + * device/lib/_fs2schar.c, + * device/lib/_fs2sint.c, + * device/lib/_fs2slong.c, + * device/lib/_fs2uchar.c, + * device/lib/_fs2uint.c, + * device/lib/_fs2ulong.c, + * device/lib/_fsadd.c, + * device/lib/_fscmp.c, + * device/lib/_fsdiv.c, + * device/lib/_fseq.c, + * device/lib/_fsget1arg.c, + * device/lib/_fsget2args.c, + * device/lib/_fsgt.c, + * device/lib/_fslt.c, + * device/lib/_fsmul.c, + * device/lib/_fsneq.c, + * device/lib/_fsnormalize.c, + * device/lib/_fsreturnval.c, + * device/lib/_fsrshift.c, + * device/lib/_fssub.c, + * device/lib/_fsswapargs.c, + * device/lib/_gptrget.c, + * device/lib/_gptrgetc.c, + * device/lib/_gptrput.c, + * device/lib/_logexpf.c, + * device/lib/_modsint.c, + * device/lib/_modslong.c, + * device/lib/_moduint.c, + * device/lib/_modulong.c, + * device/lib/_mulint.c, + * device/lib/_mullong.c, + * device/lib/_schar2fs.c, + * device/lib/_ser.c, + * device/lib/_setjmp.c, + * device/lib/_sint2fs.c, + * device/lib/_slong2fs.c, + * device/lib/_spx.c, + * device/lib/_uchar2fs.c, + * device/lib/_uint2fs.c, + * device/lib/_ulong2fs.c, + * device/lib/asincosf.c, + * device/lib/atanf.c, + * device/lib/calloc.c, + * device/lib/ds390/tinibios.c, + * device/lib/ds400/tinibios.c, + * device/lib/expf.c, + * device/lib/free.c, + * device/lib/hc08/_mulint.c, + * device/lib/logf.c, + * device/lib/malloc.c, + * device/lib/printf_fast.c, + * device/lib/printf_tiny.c, + * device/lib/printfl.c, + * device/lib/realloc.c, + * device/lib/ser_ir.c, + * device/lib/serial.c, + * support/regression/tests/libmullong.c: replaced all special keywords + with their double underscore equivalent + * support/regression/ports/mcs51-xstack-auto/spec.mk, + * device/lib/Makefile.in: compile libs with --std-c99 instead of + --std-sdcc99 + * src/mcs51/gen.c (outBitC): don't store if result is return-use-only, + (genRet): if the bit-symbol is ruonly it already is in the carry + * src/mcs51/ralloc.c (regTypeNum): make regType REG_CND for ruonly bit + * src/SDCCast.c (createFunction): applied patch 887171 by Stas Sergeev + * src/SDCCicode.c (ast2iCode): '!', GETHBIT, GETABIT: only set operand + type UCHAR if dest is not bit + 2007-04-03 Maarten Brock * device/include/math.h, diff --git a/device/include/pic16/pic18fregs.h b/device/include/pic16/pic18fregs.h index 6a0295cf..82a6bb43 100644 --- a/device/include/pic16/pic18fregs.h +++ b/device/include/pic16/pic18fregs.h @@ -139,10 +139,10 @@ #endif -#define Nop() do { _asm nop _endasm; } while(0) -#define ClrWdt() do { _asm clrwdt _endasm; } while(0) -#define Sleep() do { _asm sleep _endasm; } while(0) -#define Reset() do { _asm reset _endasm; } while(0) +#define Nop() do { __asm nop __endasm; } while(0) +#define ClrWdt() do { __asm clrwdt __endasm; } while(0) +#define Sleep() do { __asm sleep __endasm; } while(0) +#define Reset() do { __asm reset __endasm; } while(0) #endif /* __PIC18FREGS_H__ */ diff --git a/device/lib/Makefile.in b/device/lib/Makefile.in index 40217415..18dbff63 100644 --- a/device/lib/Makefile.in +++ b/device/lib/Makefile.in @@ -47,7 +47,7 @@ lib_dir_suffix = @lib_dir_suffix@ sdcc_libdir = $(DESTDIR)$(datadir)/$(lib_dir_suffix) CPPFLAGS = -I$(INCDIR) -I$(PORTINCDIR) -CFLAGS = $(MODELFLAGS) --nostdinc --std-sdcc99 +CFLAGS = $(MODELFLAGS) --nostdinc --std-c99 BUILDDIR = build # Default diff --git a/device/lib/_bp.c b/device/lib/_bp.c index c7a7cc00..a57b99bc 100644 --- a/device/lib/_bp.c +++ b/device/lib/_bp.c @@ -23,4 +23,4 @@ what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ -data unsigned char bp ; +__data unsigned char bp ; diff --git a/device/lib/_decdptr.c b/device/lib/_decdptr.c index 30fe9a71..e08d0379 100644 --- a/device/lib/_decdptr.c +++ b/device/lib/_decdptr.c @@ -29,20 +29,20 @@ _decdptr (char *gptr) { gptr; /* hush the compiler */ -#ifdef SDCC_ds390 - _asm - orl dps, #0xc0 - inc dptr - anl dps, #0x3f - _endasm ; +#ifdef SDCC_ds390 + __asm + orl dps, #0xc0 + inc dptr + anl dps, #0x3f + __endasm; #else - _asm - xch a,dpl - jnz 00001$ - dec dph + __asm + xch a,dpl + jnz 00001$ + dec dph 00001$: - dec a - xch a,dpl - _endasm ; -#endif + dec a + xch a,dpl + __endasm; +#endif } diff --git a/device/lib/_divsint.c b/device/lib/_divsint.c index 229bb2f4..b35be7eb 100644 --- a/device/lib/_divsint.c +++ b/device/lib/_divsint.c @@ -50,151 +50,151 @@ unsigned unsigned _divuint (unsigned x, unsigned y); #if defined _DIVSINT_ASM_SMALL static void -_divsint_dummy (void) _naked +_divsint_dummy (void) __naked { - _asm + __asm - #define xl dpl - #define xh dph + #define xl dpl + #define xh dph - .globl __divsint + .globl __divsint - // _divsint_PARM_2 shares the same memory with _divuint_PARM_2 - // and is defined in _divuint.c + // _divsint_PARM_2 shares the same memory with _divuint_PARM_2 + // and is defined in _divuint.c #if defined(SDCC_PARMS_IN_BANK1) - #define yl (b1_0) - #define yh (b1_1) + #define yl (b1_0) + #define yh (b1_1) #else - #define yl (__divsint_PARM_2) - #define yh (__divsint_PARM_2 + 1) + #define yl (__divsint_PARM_2) + #define yh (__divsint_PARM_2 + 1) #endif - __divsint: - ; xh in dph - ; yh in (__divsint_PARM_2 + 1) +__divsint: + ; xh in dph + ; yh in (__divsint_PARM_2 + 1) - clr F0 ; Flag 0 in PSW - ; available to user for general purpose - mov a,xh - jnb acc.7,a_not_negative + clr F0 ; Flag 0 in PSW + ; available to user for general purpose + mov a,xh + jnb acc.7,a_not_negative - setb F0 + setb F0 - clr a - clr c - subb a,xl - mov xl,a - clr a - subb a,xh - mov xh,a + clr a + clr c + subb a,xl + mov xl,a + clr a + subb a,xh + mov xh,a - a_not_negative: +a_not_negative: - mov a,yh - jnb acc.7,b_not_negative + mov a,yh + jnb acc.7,b_not_negative - cpl F0 + cpl F0 - clr a - clr c - subb a,yl - mov yl,a - clr a - subb a,yh - mov yh,a + clr a + clr c + subb a,yl + mov yl,a + clr a + subb a,yh + mov yh,a - b_not_negative: +b_not_negative: - lcall __divuint + lcall __divuint - jnb F0,not_negative + jnb F0,not_negative - clr a - clr c - subb a,xl - mov xl,a - clr a - subb a,xh - mov xh,a + clr a + clr c + subb a,xl + mov xl,a + clr a + subb a,xh + mov xh,a - not_negative: - ret +not_negative: + ret - _endasm ; + __endasm; } #elif defined _DIVSINT_ASM_SMALL_AUTO static void -_divsint_dummy (void) _naked +_divsint_dummy (void) __naked { - _asm + __asm - #define xl dpl - #define xh dph + #define xl dpl + #define xh dph - .globl __divsint + .globl __divsint - __divsint: +__divsint: - clr F0 ; Flag 0 in PSW - ; available to user for general purpose - mov a,xh - jnb acc.7,a_not_negative + clr F0 ; Flag 0 in PSW + ; available to user for general purpose + mov a,xh + jnb acc.7,a_not_negative - setb F0 + setb F0 - clr a - clr c - subb a,xl - mov xl,a - clr a - subb a,xh - mov xh,a + clr a + clr c + subb a,xl + mov xl,a + clr a + subb a,xh + mov xh,a - a_not_negative: +a_not_negative: - mov a,sp - add a,#-2 ; 2 bytes return address - mov r0,a ; r0 points to yh - mov a,@r0 ; a = yh + mov a,sp + add a,#-2 ; 2 bytes return address + mov r0,a ; r0 points to yh + mov a,@r0 ; a = yh - jnb acc.7,b_not_negative + jnb acc.7,b_not_negative - cpl F0 + cpl F0 - dec r0 + dec r0 - clr a - clr c - subb a,@r0 ; yl - mov @r0,a - clr a - inc r0 - subb a,@r0 ; a = yh + clr a + clr c + subb a,@r0 ; yl + mov @r0,a + clr a + inc r0 + subb a,@r0 ; a = yh - b_not_negative: +b_not_negative: - mov r1,a ; yh - dec r0 - mov a,@r0 ; yl - mov r0,a + mov r1,a ; yh + dec r0 + mov a,@r0 ; yl + mov r0,a - lcall __divint + lcall __divint - jnb F0,not_negative + jnb F0,not_negative - clr a - clr c - subb a,xl - mov xl,a - clr a - subb a,xh - mov xh,a + clr a + clr c + subb a,xl + mov xl,a + clr a + subb a,xh + mov xh,a - not_negative: - ret +not_negative: + ret - _endasm ; + __endasm; } #else // _DIVSINT_ASM_ diff --git a/device/lib/_divslong.c b/device/lib/_divslong.c index 2a8c03d0..ac4d9c57 100644 --- a/device/lib/_divslong.c +++ b/device/lib/_divslong.c @@ -49,204 +49,204 @@ unsigned long _divulong (unsigned long x, unsigned long y); #if defined _DIVSLONG_ASM_SMALL static void -_divslong_dummy (void) _naked +_divslong_dummy (void) __naked { - _asm + __asm - #define x0 dpl - #define x1 dph - #define x2 b - #define x3 r3 + #define x0 dpl + #define x1 dph + #define x2 b + #define x3 r3 - .globl __divslong + .globl __divslong - // _divslong_PARM_2 shares the same memory with _divulong_PARM_2 - // and is defined in _divulong.c + // _divslong_PARM_2 shares the same memory with _divulong_PARM_2 + // and is defined in _divulong.c #if defined(SDCC_PARMS_IN_BANK1) - #define y0 (b1_0) - #define y1 (b1_1) - #define y2 (b1_2) - #define y3 (b1_3) + #define y0 (b1_0) + #define y1 (b1_1) + #define y2 (b1_2) + #define y3 (b1_3) #else - #define y0 (__divslong_PARM_2) - #define y1 (__divslong_PARM_2 + 1) - #define y2 (__divslong_PARM_2 + 2) - #define y3 (__divslong_PARM_2 + 3) + #define y0 (__divslong_PARM_2) + #define y1 (__divslong_PARM_2 + 1) + #define y2 (__divslong_PARM_2 + 2) + #define y3 (__divslong_PARM_2 + 3) #endif - __divslong: - ; x3 in acc - ; y3 in (__divslong_PARM_2 + 3) - mov x3,a ; save x3 - - clr F0 ; Flag 0 in PSW - ; available to user for general purpose - jnb acc.7,a_not_negative - - setb F0 - - clr a - clr c - subb a,x0 - mov x0,a - clr a - subb a,x1 - mov x1,a - clr a - subb a,x2 - mov x2,a - clr a - subb a,x3 - mov x3,a - - a_not_negative: - - mov a,y3 - jnb acc.7,b_not_negative - - cpl F0 - - clr a - clr c - subb a,y0 - mov y0,a - clr a - subb a,y1 - mov y1,a - clr a - subb a,y2 - mov y2,a - clr a - subb a,y3 - mov y3,a - - b_not_negative: - - mov a,x3 ; restore x3 in acc - - lcall __divulong - - jnb F0,not_negative - - mov x3,a ; save x3 - - clr a - clr c - subb a,x0 - mov x0,a - clr a - subb a,x1 - mov x1,a - clr a - subb a,x2 - mov x2,a - clr a - subb a,x3 ; x3 ends in acc - - not_negative: - ret - - _endasm ; +__divslong: + ; x3 in acc + ; y3 in (__divslong_PARM_2 + 3) + mov x3,a ; save x3 + + clr F0 ; Flag 0 in PSW + ; available to user for general purpose + jnb acc.7,a_not_negative + + setb F0 + + clr a + clr c + subb a,x0 + mov x0,a + clr a + subb a,x1 + mov x1,a + clr a + subb a,x2 + mov x2,a + clr a + subb a,x3 + mov x3,a + +a_not_negative: + + mov a,y3 + jnb acc.7,b_not_negative + + cpl F0 + + clr a + clr c + subb a,y0 + mov y0,a + clr a + subb a,y1 + mov y1,a + clr a + subb a,y2 + mov y2,a + clr a + subb a,y3 + mov y3,a + +b_not_negative: + + mov a,x3 ; restore x3 in acc + + lcall __divulong + + jnb F0,not_negative + + mov x3,a ; save x3 + + clr a + clr c + subb a,x0 + mov x0,a + clr a + subb a,x1 + mov x1,a + clr a + subb a,x2 + mov x2,a + clr a + subb a,x3 ; x3 ends in acc + +not_negative: + ret + + __endasm; } #elif defined _DIVSLONG_ASM_SMALL_AUTO static void -_divslong_dummy (void) _naked +_divslong_dummy (void) __naked { - _asm - - #define x0 dpl - #define x1 dph - #define x2 b - #define x3 r3 - - .globl __divslong - - __divslong: - - ; x3 in acc - mov x3,a ; save x3 - - clr F0 ; Flag 0 in PSW - ; available to user for general purpose - jnb acc.7,a_not_negative - - setb F0 - - clr a - clr c - subb a,x0 - mov x0,a - clr a - subb a,x1 - mov x1,a - clr a - subb a,x2 - mov x2,a - clr a - subb a,x3 - mov x3,a - - a_not_negative: - - mov a,sp - add a,#-2 ; 2 bytes return address - mov r0,a ; r0 points to y3 - mov a,@r0 ; y3 - - jnb acc.7,b_not_negative - - cpl F0 - - dec r0 - dec r0 - dec r0 - - clr a - clr c - subb a,@r0 ; y0 - mov @r0,a - clr a - inc r0 - subb a,@r0 ; y1 - mov @r0,a - clr a - inc r0 - subb a,@r0 ; y2 - mov @r0,a - clr a - inc r0 - subb a,@r0 ; y3 - mov @r0,a - - b_not_negative: - dec r0 - dec r0 - dec r0 ; r0 points to y0 - - lcall __divlong - - jnb F0,not_negative - - mov x3,a ; save x3 - - clr a - clr c - subb a,x0 - mov x0,a - clr a - subb a,x1 - mov x1,a - clr a - subb a,x2 - mov x2,a - clr a - subb a,x3 ; x3 ends in acc - - not_negative: - ret - - _endasm ; + __asm + + #define x0 dpl + #define x1 dph + #define x2 b + #define x3 r3 + + .globl __divslong + +__divslong: + + ; x3 in acc + mov x3,a ; save x3 + + clr F0 ; Flag 0 in PSW + ; available to user for general purpose + jnb acc.7,a_not_negative + + setb F0 + + clr a + clr c + subb a,x0 + mov x0,a + clr a + subb a,x1 + mov x1,a + clr a + subb a,x2 + mov x2,a + clr a + subb a,x3 + mov x3,a + +a_not_negative: + + mov a,sp + add a,#-2 ; 2 bytes return address + mov r0,a ; r0 points to y3 + mov a,@r0 ; y3 + + jnb acc.7,b_not_negative + + cpl F0 + + dec r0 + dec r0 + dec r0 + + clr a + clr c + subb a,@r0 ; y0 + mov @r0,a + clr a + inc r0 + subb a,@r0 ; y1 + mov @r0,a + clr a + inc r0 + subb a,@r0 ; y2 + mov @r0,a + clr a + inc r0 + subb a,@r0 ; y3 + mov @r0,a + +b_not_negative: + dec r0 + dec r0 + dec r0 ; r0 points to y0 + + lcall __divlong + + jnb F0,not_negative + + mov x3,a ; save x3 + + clr a + clr c + subb a,x0 + mov x0,a + clr a + subb a,x1 + mov x1,a + clr a + subb a,x2 + mov x2,a + clr a + subb a,x3 ; x3 ends in acc + +not_negative: + ret + + __endasm; } #else // _DIVSLONG_ASM diff --git a/device/lib/_divuint.c b/device/lib/_divuint.c index 03b91998..8d1344f4 100644 --- a/device/lib/_divuint.c +++ b/device/lib/_divuint.c @@ -44,102 +44,103 @@ #if defined _DIVUINT_ASM_SMALL || defined _DIVUINT_ASM_SMALL_AUTO static void -_divuint_dummy (void) _naked +_divuint_dummy (void) __naked { - _asm + __asm - .globl __divuint + .globl __divuint - __divuint: +__divuint: - #define count r2 - #define reste_l r3 - #define reste_h r4 - #define xl dpl - #define xh dph + #define count r2 + #define reste_l r3 + #define reste_h r4 + #define xl dpl + #define xh dph #if defined(SDCC_PARMS_IN_BANK1) - #define yl (b1_0) - #define yh (b1_1) + #define yl (b1_0) + #define yh (b1_1) #else // SDCC_PARMS_IN_BANK1 #if defined(SDCC_STACK_AUTO) - .globl __divint + .globl __divint - mov a,sp - add a,#-2 ; 2 bytes return address - mov r0,a ; r0 points to yh - mov a,@r0 ; load yh - mov r1,a - dec r0 - mov a,@r0 ; load yl - mov r0,a + mov a,sp + add a,#-2 ; 2 bytes return address + mov r0,a ; r0 points to yh + mov a,@r0 ; load yh + mov r1,a + dec r0 + mov a,@r0 ; load yl + mov r0,a - #define yl r0 - #define yh r1 + #define yl r0 + #define yh r1 - __divint: ; entry point for __divsint +__divint: ; entry point for __divsint #else // SDCC_STACK_AUTO #if defined(SDCC_NOOVERLAY) - .area DSEG (DATA) + .area DSEG (DATA) #else - .area OSEG (OVR,DATA) + .area OSEG (OVR,DATA) #endif - .globl __divuint_PARM_2 - .globl __divsint_PARM_2 + .globl __divuint_PARM_2 + .globl __divsint_PARM_2 - __divuint_PARM_2: - __divsint_PARM_2: - .ds 2 +__divuint_PARM_2: +__divsint_PARM_2: + .ds 2 - .area CSEG (CODE) + .area CSEG (CODE) - #define yl (__divuint_PARM_2) - #define yh (__divuint_PARM_2 + 1) + #define yl (__divuint_PARM_2) + #define yh (__divuint_PARM_2 + 1) #endif // SDCC_STACK_AUTO #endif // SDCC_PARMS_IN_BANK1 - mov count,#16 - clr a - mov reste_l,a - mov reste_h,a - - loop: mov a,xl ; x <<= 1 - add a,acc - mov xl,a - mov a,xh - rlc a - mov xh,a - - mov a,reste_l ; reste <<= 1 - rlc a ; feed in carry - mov reste_l,a - mov a,reste_h - rlc a - mov reste_h,a - - mov a,reste_l ; reste - y - subb a,yl ; here carry is always clear, because + mov count,#16 + clr a + mov reste_l,a + mov reste_h,a + +loop: + mov a,xl ; x <<= 1 + add a,acc + mov xl,a + mov a,xh + rlc a + mov xh,a + + mov a,reste_l ; reste <<= 1 + rlc a ; feed in carry + mov reste_l,a + mov a,reste_h + rlc a + mov reste_h,a + + mov a,reste_l ; reste - y + subb a,yl ; here carry is always clear, because ; reste <<= 1 never overflows - mov b,a - mov a,reste_h - subb a,yh + mov b,a + mov a,reste_h + subb a,yh - jc smaller ; reste >= y? + jc smaller ; reste >= y? - mov reste_h,a ; -> yes; reste = reste - y; - mov reste_l,b - orl xl,#1 - smaller: ; -> no - djnz count,loop - ret + mov reste_h,a ; -> yes; reste = reste - y; + mov reste_l,b + orl xl,#1 +smaller: ; -> no + djnz count,loop + ret - _endasm ; + __endasm; } #else // defined _DIVUINT_ASM_SMALL || defined _DIVUINT_ASM_SMALL_AUTO diff --git a/device/lib/_divulong.c b/device/lib/_divulong.c index 53a2b87c..4ec6d2dd 100644 --- a/device/lib/_divulong.c +++ b/device/lib/_divulong.c @@ -44,279 +44,279 @@ #if defined _DIVULONG_ASM_SMALL static void -_divlong_dummy (void) _naked +_divlong_dummy (void) __naked { - _asm + __asm - .globl __divulong + .globl __divulong - __divulong: +__divulong: - #define count r2 + #define count r2 - #define x0 dpl - #define x1 dph - #define x2 b - #define x3 r3 + #define x0 dpl + #define x1 dph + #define x2 b + #define x3 r3 - #define reste0 r4 - #define reste1 r5 - #define reste2 r6 - #define reste3 r7 + #define reste0 r4 + #define reste1 r5 + #define reste2 r6 + #define reste3 r7 #if !defined(SDCC_PARMS_IN_BANK1) #if defined(SDCC_NOOVERLAY) - .area DSEG (DATA) + .area DSEG (DATA) #else - .area OSEG (OVR,DATA) + .area OSEG (OVR,DATA) #endif - .globl __divulong_PARM_2 - .globl __divslong_PARM_2 + .globl __divulong_PARM_2 + .globl __divslong_PARM_2 - __divulong_PARM_2: - __divslong_PARM_2: - .ds 4 +__divulong_PARM_2: +__divslong_PARM_2: + .ds 4 - .area CSEG (CODE) + .area CSEG (CODE) - #define y0 (__divulong_PARM_2) - #define y1 (__divulong_PARM_2 + 1) - #define y2 (__divulong_PARM_2 + 2) - #define y3 (__divulong_PARM_2 + 3) + #define y0 (__divulong_PARM_2) + #define y1 (__divulong_PARM_2 + 1) + #define y2 (__divulong_PARM_2 + 2) + #define y3 (__divulong_PARM_2 + 3) #else - #define y0 (b1_0) - #define y1 (b1_1) - #define y2 (b1_2) - #define y3 (b1_3) + #define y0 (b1_0) + #define y1 (b1_1) + #define y2 (b1_2) + #define y3 (b1_3) #endif // !SDCC_PARMS_IN_BANK1 - ; parameter x comes in a, b, dph, dpl - mov x3,a ; save parameter x3 + ; parameter x comes in a, b, dph, dpl + mov x3,a ; save parameter x3 - mov count,#32 - clr a - mov reste0,a - mov reste1,a - mov reste2,a - mov reste3,a + mov count,#32 + clr a + mov reste0,a + mov reste1,a + mov reste2,a + mov reste3,a ; optimization loop in lp0 until the first bit is shifted into rest - lp0: mov a,x0 ; x <<= 1 - add a,x0 - mov x0,a - mov a,x1 - rlc a - mov x1,a - mov a,x2 - rlc a - mov x2,a - mov a,x3 - rlc a - mov x3,a - - jc in_lp - djnz count,lp0 - - sjmp exit - - loop: mov a,x0 ; x <<= 1 - add a,x0 - mov x0,a - mov a,x1 - rlc a - mov x1,a - mov a,x2 - rlc a - mov x2,a - mov a,x3 - rlc a - mov x3,a - - in_lp: mov a,reste0 ; reste <<= 1 - rlc a ; feed in carry - mov reste0,a - mov a,reste1 - rlc a - mov reste1,a - mov a,reste2 - rlc a - mov reste2,a - mov a,reste3 - rlc a - mov reste3,a - - mov a,reste0 ; reste - y - subb a,y0 ; carry is always clear here, because +lp0: mov a,x0 ; x <<= 1 + add a,x0 + mov x0,a + mov a,x1 + rlc a + mov x1,a + mov a,x2 + rlc a + mov x2,a + mov a,x3 + rlc a + mov x3,a + + jc in_lp + djnz count,lp0 + + sjmp exit + +loop: mov a,x0 ; x <<= 1 + add a,x0 + mov x0,a + mov a,x1 + rlc a + mov x1,a + mov a,x2 + rlc a + mov x2,a + mov a,x3 + rlc a + mov x3,a + +in_lp: mov a,reste0 ; reste <<= 1 + rlc a ; feed in carry + mov reste0,a + mov a,reste1 + rlc a + mov reste1,a + mov a,reste2 + rlc a + mov reste2,a + mov a,reste3 + rlc a + mov reste3,a + + mov a,reste0 ; reste - y + subb a,y0 ; carry is always clear here, because ; reste <<= 1 never overflows - mov a,reste1 - subb a,y1 - mov a,reste2 - subb a,y2 - mov a,reste3 - subb a,y3 - - jc minus ; reste >= y? - - ; -> yes; reste -= y; - mov a,reste0 - subb a,y0 ; carry is always clear here (jc) - mov reste0,a - mov a,reste1 - subb a,y1 - mov reste1,a - mov a,reste2 - subb a,y2 - mov reste2,a - mov a,reste3 - subb a,y3 - mov reste3,a - - orl x0,#1 - - minus: djnz count,loop ; -> no - - exit: mov a,x3 ; prepare the return value - ret - - _endasm ; + mov a,reste1 + subb a,y1 + mov a,reste2 + subb a,y2 + mov a,reste3 + subb a,y3 + + jc minus ; reste >= y? + + ; -> yes; reste -= y; + mov a,reste0 + subb a,y0 ; carry is always clear here (jc) + mov reste0,a + mov a,reste1 + subb a,y1 + mov reste1,a + mov a,reste2 + subb a,y2 + mov reste2,a + mov a,reste3 + subb a,y3 + mov reste3,a + + orl x0,#1 + +minus: djnz count,loop ; -> no + +exit: mov a,x3 ; prepare the return value + ret + + __endasm; } #elif defined _DIVULONG_ASM_SMALL_AUTO static void -_divlong_dummy (void) _naked +_divlong_dummy (void) __naked { - _asm + __asm - .globl __divulong + .globl __divulong - __divulong: +__divulong: - #define count r2 + #define count r2 - #define x0 dpl - #define x1 dph - #define x2 b - #define x3 r3 + #define x0 dpl + #define x1 dph + #define x2 b + #define x3 r3 - #define reste0 r4 - #define reste1 r5 - #define reste2 r6 - #define reste3 r7 + #define reste0 r4 + #define reste1 r5 + #define reste2 r6 + #define reste3 r7 - .globl __divlong ; entry point for __divslong + .globl __divlong ; entry point for __divslong - #define y0 r1 + #define y0 r1 - ; parameter x comes in a, b, dph, dpl - mov x3,a ; save parameter x3 + ; parameter x comes in a, b, dph, dpl + mov x3,a ; save parameter x3 - mov a,sp - add a,#-2-3 ; 2 bytes return address, 3 bytes param y - mov r0,a ; r0 points to y0 + mov a,sp + add a,#-2-3 ; 2 bytes return address, 3 bytes param y + mov r0,a ; r0 points to y0 - __divlong: ; entry point for __divslong +__divlong: ; entry point for __divslong - mov a,@r0 ; load y0 - mov r1,a - inc r0 ; r0 points to y1 + mov a,@r0 ; load y0 + mov r1,a + inc r0 ; r0 points to y1 - mov count,#32 - clr a - mov reste0,a - mov reste1,a - mov reste2,a - mov reste3,a + mov count,#32 + clr a + mov reste0,a + mov reste1,a + mov reste2,a + mov reste3,a ; optimization loop in lp0 until the first bit is shifted into rest - lp0: mov a,x0 ; x <<= 1 - add a,x0 - mov x0,a - mov a,x1 - rlc a - mov x1,a - mov a,x2 - rlc a - mov x2,a - mov a,x3 - rlc a - mov x3,a - - jc in_lp - djnz count,lp0 - - sjmp exit - - loop: mov a,x0 ; x <<= 1 - add a,x0 - mov x0,a - mov a,x1 - rlc a - mov x1,a - mov a,x2 - rlc a - mov x2,a - mov a,x3 - rlc a - mov x3,a - - in_lp: mov a,reste0 ; reste <<= 1 - rlc a ; feed in carry - mov reste0,a - mov a,reste1 - rlc a - mov reste1,a - mov a,reste2 - rlc a - mov reste2,a - mov a,reste3 - rlc a - mov reste3,a - - mov a,reste0 ; reste - y - subb a,y0 ; carry is always clear here, because - ; reste <<= 1 never overflows - mov a,reste1 - subb a,@r0 ; y1 - mov a,reste2 - inc r0 - subb a,@r0 ; y2 - mov a,reste3 - inc r0 - subb a,@r0 ; y3 - dec r0 - dec r0 - - jc minus ; reste >= y? - - ; -> yes; reste -= y; - mov a,reste0 - subb a,y0 ; carry is always clear here (jc) - mov reste0,a - mov a,reste1 - subb a,@r0 ; y1 - mov reste1,a - mov a,reste2 - inc r0 - subb a,@r0 ; y2 - mov reste2,a - mov a,reste3 - inc r0 - subb a,@r0 ; y3 - mov reste3,a - dec r0 - dec r0 - - orl x0,#1 - - minus: djnz count,loop ; -> no - - exit: mov a,x3 ; prepare the return value - ret - - _endasm ; +lp0: mov a,x0 ; x <<= 1 + add a,x0 + mov x0,a + mov a,x1 + rlc a + mov x1,a + mov a,x2 + rlc a + mov x2,a + mov a,x3 + rlc a + mov x3,a + + jc in_lp + djnz count,lp0 + + sjmp exit + +loop: mov a,x0 ; x <<= 1 + add a,x0 + mov x0,a + mov a,x1 + rlc a + mov x1,a + mov a,x2 + rlc a + mov x2,a + mov a,x3 + rlc a + mov x3,a + +in_lp: mov a,reste0 ; reste <<= 1 + rlc a ; feed in carry + mov reste0,a + mov a,reste1 + rlc a + mov reste1,a + mov a,reste2 + rlc a + mov reste2,a + mov a,reste3 + rlc a + mov reste3,a + + mov a,reste0 ; reste - y + subb a,y0 ; carry is always clear here, because + ; reste <<= 1 never overflows + mov a,reste1 + subb a,@r0 ; y1 + mov a,reste2 + inc r0 + subb a,@r0 ; y2 + mov a,reste3 + inc r0 + subb a,@r0 ; y3 + dec r0 + dec r0 + + jc minus ; reste >= y? + + ; -> yes; reste -= y; + mov a,reste0 + subb a,y0 ; carry is always clear here (jc) + mov reste0,a + mov a,reste1 + subb a,@r0 ; y1 + mov reste1,a + mov a,reste2 + inc r0 + subb a,@r0 ; y2 + mov reste2,a + mov a,reste3 + inc r0 + subb a,@r0 ; y3 + mov reste3,a + dec r0 + dec r0 + + orl x0,#1 + +minus: djnz count,loop ; -> no + +exit: mov a,x3 ; prepare the return value + ret + + __endasm; } #else // _DIVULONG_ASM diff --git a/device/lib/_fs2schar.c b/device/lib/_fs2schar.c index f63d342a..b9b6ac6d 100644 --- a/device/lib/_fs2schar.c +++ b/device/lib/_fs2schar.c @@ -25,17 +25,17 @@ #ifdef FLOAT_ASM_MCS51 // char __fs2schar (float x) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___fs2schar ___fs2schar: lcall ___fs2slong - jnz fs2schar_not_zero - mov a, dpl - orl a, dph - orl a, b - jnz fs2schar_clr_a + jnz fs2schar_not_zero + mov a, dpl + orl a, dph + orl a, b + jnz fs2schar_clr_a ret fs2schar_clr_a: clr a @@ -68,15 +68,14 @@ fs2schar_pos: fs2schar_maxval_pos: mov dpl, #0x7F ret - _endasm; + __endasm; } - #else - /* convert float to signed char */ -signed char __fs2schar (float f) { +signed char __fs2schar (float f) +{ signed long sl=__fs2slong(f); if (sl>=CHAR_MAX) return CHAR_MAX; @@ -86,4 +85,3 @@ signed char __fs2schar (float f) { } #endif - diff --git a/device/lib/_fs2sint.c b/device/lib/_fs2sint.c index 9da46173..53f2e2d3 100644 --- a/device/lib/_fs2sint.c +++ b/device/lib/_fs2sint.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 // int __fs2sint (float x) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___fs2sint ___fs2sint: lcall ___fs2slong @@ -62,16 +62,14 @@ fs2sint_pos: fs2sint_maxval_pos: mov dptr, #0x7FFF ret - _endasm; + __endasm; } - #else - - /* convert float to signed int */ -signed int __fs2sint (float f) { +signed int __fs2sint (float f) +{ signed long sl=__fs2slong(f); if (sl>=INT_MAX) return INT_MAX; @@ -81,4 +79,3 @@ signed int __fs2sint (float f) { } #endif - diff --git a/device/lib/_fs2slong.c b/device/lib/_fs2slong.c index 87d662df..961bff9c 100644 --- a/device/lib/_fs2slong.c +++ b/device/lib/_fs2slong.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 // long __fs2slong (float x) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___fs2slong ___fs2slong: lcall fsgetarg @@ -89,14 +89,14 @@ fs2slong_maxval_pos: mov b, a mov a, #0x7F ret - _endasm; + __endasm; } #else - /* convert float to signed long */ -signed long __fs2slong (float f) { +signed long __fs2slong (float f) +{ if (!f) return 0; diff --git a/device/lib/_fs2uchar.c b/device/lib/_fs2uchar.c index 2b021fd0..cc3f6b1a 100644 --- a/device/lib/_fs2uchar.c +++ b/device/lib/_fs2uchar.c @@ -23,29 +23,26 @@ #ifdef FLOAT_ASM_MCS51 // unsigned char __fs2uchar (float x) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___fs2uchar ___fs2uchar: mov r7, #134 lcall fs2ulong_begin mov dpl, a ret - _endasm; + __endasm; } #else - - - /* convert float to unsigned char */ -unsigned char __fs2uchar (float f) { +unsigned char __fs2uchar (float f) +{ unsigned long ul=__fs2ulong(f); if (ul>=UCHAR_MAX) return UCHAR_MAX; return ul; } #endif - diff --git a/device/lib/_fs2uint.c b/device/lib/_fs2uint.c index 0ed5db64..5c50546b 100644 --- a/device/lib/_fs2uint.c +++ b/device/lib/_fs2uint.c @@ -23,9 +23,9 @@ #ifdef FLOAT_ASM_MCS51 // unsigned int __fs2uint (float x) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___fs2uint ___fs2uint: mov r7, #142 @@ -33,20 +33,19 @@ ___fs2uint: mov dph, a mov dpl, b ret - _endasm; + __endasm; } #else - unsigned long __fs2ulong (float a1); /* convert float to unsigned int */ -unsigned int __fs2uint (float f) { +unsigned int __fs2uint (float f) +{ unsigned long ul=__fs2ulong(f); if (ul>=UINT_MAX) return UINT_MAX; return ul; } #endif - diff --git a/device/lib/_fs2ulong.c b/device/lib/_fs2ulong.c index 4a2da50d..e792fd17 100644 --- a/device/lib/_fs2ulong.c +++ b/device/lib/_fs2ulong.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 // unsigned long __fs2ulong (float x) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___fs2ulong ___fs2ulong: mov r7, #158 @@ -58,15 +58,11 @@ fs2ulong_done: mov b, r3 mov a, r4 ret - _endasm; + __endasm; } - #else - - - /* ** libgcc support for software floating point. ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. @@ -114,5 +110,3 @@ __fs2ulong (float a1) } #endif - - diff --git a/device/lib/_fsadd.c b/device/lib/_fsadd.c index 8d3c6ab3..567582e8 100644 --- a/device/lib/_fsadd.c +++ b/device/lib/_fsadd.c @@ -23,10 +23,10 @@ #ifdef FLOAT_ASM_MCS51 -// float __fsadd (float a, float b) reentrant -static void dummy(void) _naked +// float __fsadd (float a, float b) __reentrant +static void dummy(void) __naked { - _asm + __asm // extract the two inputs, placing them into: // sign exponent mantiassa @@ -128,7 +128,7 @@ fsadd_direct_entry: lcall fs_normalize_a ljmp fs_round_and_return - _endasm; + __endasm; } #else @@ -150,7 +150,6 @@ fsadd_direct_entry: ** uunet!motown!pipeline!phw */ - union float_long { float f; @@ -233,4 +232,3 @@ float __fsadd (float a1, float a2) } #endif - diff --git a/device/lib/_fscmp.c b/device/lib/_fscmp.c index c53a8081..e28d0d20 100644 --- a/device/lib/_fscmp.c +++ b/device/lib/_fscmp.c @@ -23,9 +23,9 @@ #ifdef FLOAT_ASM_MCS51 -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl fs_compare_uint32 fs_compare_uint32: @@ -86,8 +86,7 @@ b_not_neg_zero_cleanup_1: b_not_neg_zero: ret - _endasm; + __endasm; } #endif - diff --git a/device/lib/_fsdiv.c b/device/lib/_fsdiv.c index fd50c96c..5a1a21a7 100644 --- a/device/lib/_fsdiv.c +++ b/device/lib/_fsdiv.c @@ -23,10 +23,10 @@ #ifdef FLOAT_ASM_MCS51 -// float __fsdiv (float a, float b) reentrant -static void dummy(void) _naked +// float __fsdiv (float a, float b) __reentrant +static void dummy(void) __naked { - _asm + __asm .globl ___fsdiv ___fsdiv: // extract the two inputs, placing them into: @@ -231,14 +231,11 @@ ___fsdiv: lcall fs_normalize_a ljmp fs_zerocheck_return - _endasm; + __endasm; } #else - - - /* ** libgcc support for software floating point. ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. @@ -257,7 +254,6 @@ ___fsdiv: /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */ - union float_long { float f; @@ -341,4 +337,3 @@ float __fsdiv (float a1, float a2) } #endif - diff --git a/device/lib/_fseq.c b/device/lib/_fseq.c index ee744d8a..5c3b0274 100644 --- a/device/lib/_fseq.c +++ b/device/lib/_fseq.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 // char __fseq (float a, float b) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___fseq ___fseq: mov r7, a @@ -39,14 +39,11 @@ ___fseq: xrl a, #1 mov dpl, a ret - _endasm; + __endasm; } #else - - - /* ** libgcc support for software floating point. ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. @@ -65,7 +62,6 @@ ___fseq: /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */ - union float_long { float f; @@ -87,4 +83,3 @@ __fseq (float a1, float a2) } #endif - diff --git a/device/lib/_fsget1arg.c b/device/lib/_fsget1arg.c index f55554b5..eec67af4 100644 --- a/device/lib/_fsget1arg.c +++ b/device/lib/_fsget1arg.c @@ -23,10 +23,10 @@ #ifdef FLOAT_ASM_MCS51 -static void dummy(void) _naked +static void dummy(void) __naked { // input passed in a,b,dph,dpl - _asm + __asm .globl fsgetarg fsgetarg: // extract the input, placing it into: @@ -45,9 +45,7 @@ fsgetarg: mov exp_a, a mov r4, b ret - _endasm; + __endasm; } #endif - - diff --git a/device/lib/_fsget2args.c b/device/lib/_fsget2args.c index d386be05..e46738f7 100644 --- a/device/lib/_fsget2args.c +++ b/device/lib/_fsget2args.c @@ -24,11 +24,11 @@ #ifdef FLOAT_ASM_MCS51 -static void dummy(void) _naked +static void dummy(void) __naked { // arg1: passed in a,b,dph,dpl // arg2: passed on stack - _asm + __asm .globl fsgetargs fsgetargs: // extract the two inputs, placing them into: @@ -69,11 +69,7 @@ fsgetargs: mov exp_b, a mov r7, b ret - _endasm; + __endasm; } #endif - - - - diff --git a/device/lib/_fsgt.c b/device/lib/_fsgt.c index 81b7cc8a..53df3022 100644 --- a/device/lib/_fsgt.c +++ b/device/lib/_fsgt.c @@ -23,10 +23,10 @@ #ifdef FLOAT_ASM_MCS51 -// char __fsgt (float a, float b) reentrant -static void dummy(void) _naked +// char __fsgt (float a, float b) __reentrant +static void dummy(void) __naked { - _asm + __asm .globl ___fsgt ___fsgt: mov r7, a @@ -65,13 +65,11 @@ skip_invert: rlc a mov dpl, a ret - _endasm; + __endasm; } #else - - /* ** libgcc support for software floating point. ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. @@ -90,7 +88,6 @@ skip_invert: /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */ - union float_long { float f; diff --git a/device/lib/_fslt.c b/device/lib/_fslt.c index b5e4311f..854d43da 100644 --- a/device/lib/_fslt.c +++ b/device/lib/_fslt.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 // char __fslt (float a, float b) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___fslt ___fslt: mov r7, a @@ -65,13 +65,11 @@ skip_invert: rlc a mov dpl, a ret - _endasm; + __endasm; } #else - - /* ** libgcc support for software floating point. ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. @@ -90,7 +88,6 @@ skip_invert: /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */ - union float_long { float f; @@ -117,4 +114,3 @@ char __fslt (float a1, float a2) } #endif - diff --git a/device/lib/_fsmul.c b/device/lib/_fsmul.c index 553234fb..97f46e94 100644 --- a/device/lib/_fsmul.c +++ b/device/lib/_fsmul.c @@ -23,10 +23,10 @@ #ifdef FLOAT_ASM_MCS51 -// float __fsmul (float a, float b) reentrant -static void dummy(void) _naked +// float __fsmul (float a, float b) __reentrant +static void dummy(void) __naked { - _asm + __asm .globl ___fsmul ___fsmul: // extract the two inputs, placing them into: @@ -198,12 +198,11 @@ ___fsmul: 00010$: ljmp fs_round_and_return - _endasm; + __endasm; } #else - /* ** libgcc support for software floating point. ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. @@ -222,7 +221,6 @@ ___fsmul: /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */ - union float_long { float f; @@ -282,4 +280,3 @@ float __fsmul (float a1, float a2) { } #endif - diff --git a/device/lib/_fsneq.c b/device/lib/_fsneq.c index 68ed7fde..56112a0e 100644 --- a/device/lib/_fsneq.c +++ b/device/lib/_fsneq.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 // char __fsneq (float a, float b) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___fsneq ___fsneq: mov r7, a @@ -37,13 +37,11 @@ ___fsneq: lcall fs_compare_uint32 mov dpl, r1 ret - _endasm; + __endasm; } #else - - /* ** libgcc support for software floating point. ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. @@ -62,7 +60,6 @@ ___fsneq: /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */ - union float_long { float f; @@ -91,4 +88,3 @@ char __fsneq (float a1, float a2) } #endif - diff --git a/device/lib/_fsnormalize.c b/device/lib/_fsnormalize.c index 4eeeca96..b47ebfde 100644 --- a/device/lib/_fsnormalize.c +++ b/device/lib/_fsnormalize.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl fs_normalize_a fs_normalize_a: #ifdef FLOAT_SHIFT_SPEEDUP @@ -71,8 +71,7 @@ fs_normalize_a: djnz r0, 00005$ 00006$: ret - _endasm; + __endasm; } #endif - diff --git a/device/lib/_fsreturnval.c b/device/lib/_fsreturnval.c index 6dfc85cf..c14894cb 100644 --- a/device/lib/_fsreturnval.c +++ b/device/lib/_fsreturnval.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl fs_round_and_return fs_round_and_return: @@ -99,8 +99,7 @@ fs_return_nan: mov a, #0x7F ret - _endasm; + __endasm; } #endif - diff --git a/device/lib/_fsrshift.c b/device/lib/_fsrshift.c index 1f32f26a..e874020c 100644 --- a/device/lib/_fsrshift.c +++ b/device/lib/_fsrshift.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl fs_rshift_a fs_rshift_a: jz 00020$ @@ -94,8 +94,7 @@ fs_rshift_a: djnz r0, 00005$ 00020$: ret - _endasm; + __endasm; } #endif - diff --git a/device/lib/_fssub.c b/device/lib/_fssub.c index f0856748..114ffc04 100644 --- a/device/lib/_fssub.c +++ b/device/lib/_fssub.c @@ -23,10 +23,10 @@ #ifdef FLOAT_ASM_MCS51 -//float __fssub (float a, float b) reentrant -static void dummy(void) _naked +//float __fssub (float a, float b) __reentrant +static void dummy(void) __naked { - _asm + __asm .globl ___fssub ___fssub: mov r0, sp @@ -36,14 +36,11 @@ ___fssub: cpl acc.7 xch a, @r0 ljmp ___fsadd - _endasm; + __endasm; } #else - - - /* ** libgcc support for software floating point. ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. @@ -62,7 +59,6 @@ ___fssub: /* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */ - union float_long { float f; @@ -89,4 +85,3 @@ float __fssub (float a1, float a2) } #endif - diff --git a/device/lib/_fsswapargs.c b/device/lib/_fsswapargs.c index d2573b02..219ac0b3 100644 --- a/device/lib/_fsswapargs.c +++ b/device/lib/_fsswapargs.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl fs_swap_a_b fs_swap_a_b: mov a, exp_a @@ -37,12 +37,12 @@ fs_swap_a_b: // mov a, psw // swap a // depends on sign bits in psw.1 & psw.5 // mov psw, a - mov c, sign_a - rlc a - mov c, sign_b - mov sign_a, c - rrc a - mov sign_b, c + mov c, sign_a + rlc a + mov c, sign_b + mov sign_a, c + rrc a + mov sign_b, c mov a, r4 xch a, r7 mov r4, a @@ -53,8 +53,7 @@ fs_swap_a_b: xch a, r5 mov r2, a ret - _endasm; + __endasm; } #endif - diff --git a/device/lib/_gptrget.c b/device/lib/_gptrget.c index ed36448b..d7711e43 100644 --- a/device/lib/_gptrget.c +++ b/device/lib/_gptrget.c @@ -38,14 +38,14 @@ __sbit __at (0xF5) B_5; * location dpl. Therefore we choose return type void here: */ #if defined DSDCC_MODEL_HUGE void -_gptrget (char *gptr) _naked +_gptrget (char *gptr) __naked { /* This is the banked version with pointers up to 23 bits. B cannot be trashed */ gptr; /* hush the compiler */ - _asm + __asm ; ; depending on the pointer type acc. to SDCCsymt.h ; @@ -97,20 +97,20 @@ _gptrget (char *gptr) _naked ret ; 1 ;=== ;44 bytes - _endasm ; + __endasm; } #elif defined DSDCC_MODEL_MEDIUM void -_gptrget (char *gptr) _naked +_gptrget (char *gptr) __naked { /* This is the non-banked version with pointers up to 15 bits. Assumes B is free to be used */ gptr; /* hush the compiler */ - _asm + __asm ; ; depending on the pointer type acc. to SDCCsymt.h ; @@ -155,20 +155,20 @@ _gptrget (char *gptr) _naked ret ; 1 ;=== ;35 bytes - _endasm ; + __endasm; } #elif 1 void -_gptrget (char *gptr) _naked +_gptrget (char *gptr) __naked { /* This is the new version with pointers up to 16 bits. B cannot be trashed */ gptr; /* hush the compiler */ - _asm + __asm ; ; depending on the pointer type acc. to SDCCsymt.h ; @@ -208,19 +208,19 @@ _gptrget (char *gptr) _naked ret ; 1 ;=== ;27 bytes - _endasm ; + __endasm; } #else void -_gptrget (char *gptr) _naked +_gptrget (char *gptr) __naked { /* This is the old version with pointers up to 16 bits. */ gptr; /* hush the compiler */ - _asm + __asm ; ; depending on the pointer type acc. to SDCCsymt.h ; @@ -281,7 +281,7 @@ _gptrget (char *gptr) _naked ret ; 1 ;=== ;40 bytes - _endasm ; + __endasm; } #endif @@ -297,7 +297,7 @@ _gptrgetWord (unsigned *gptr) /* This is the new version */ gptr; /* hush the compiler */ - _asm + __asm ; ; depending on the pointer type acc. to SDCCsymt.h ; @@ -352,7 +352,7 @@ _gptrgetWord (unsigned *gptr) mov r0,dph ; restore r0 mov dph,#0 ; restore dph 00006$: - _endasm ; + __endasm; } @@ -363,7 +363,7 @@ _gptrgetWord (unsigned *gptr) { gptr; /* hush the compiler */ - _asm + __asm ; ; depending on the pointer type acc. to SDCCsymt.h ; @@ -431,7 +431,7 @@ _gptrgetWord (unsigned *gptr) 00005$: pop ar0 00006$: - _endasm ; + __endasm; } #endif diff --git a/device/lib/_gptrgetc.c b/device/lib/_gptrgetc.c index 1ea7c5b9..400af364 100644 --- a/device/lib/_gptrgetc.c +++ b/device/lib/_gptrgetc.c @@ -30,14 +30,14 @@ #if 1 void -_gptrgetc (char *gptr) _naked +_gptrgetc (char *gptr) __naked { /* This is the new version with pointers up to 16 bits. B cannot be trashed */ gptr; /* hush the compiler */ - _asm + __asm ; save values passed ; ; depending on the pointer type acc. to SDCCsymt.h @@ -75,17 +75,17 @@ _gptrgetc (char *gptr) _naked ret ; 1 ;=== ;28 bytes - _endasm ; + __endasm; } #else void -_gptrgetc (char *gptr) _naked +_gptrgetc (char *gptr) __naked { gptr; /* hush the compiler */ - _asm + __asm ; save values passed xch a,r0 push acc @@ -136,7 +136,7 @@ _gptrgetc (char *gptr) _naked pop acc xch a,r0 ret - _endasm ; + __endasm; } #endif diff --git a/device/lib/_gptrput.c b/device/lib/_gptrput.c index cc374ce0..eced890c 100644 --- a/device/lib/_gptrput.c +++ b/device/lib/_gptrput.c @@ -36,14 +36,14 @@ __sbit __at (0xF5) B_5; #if defined DSDCC_MODEL_HUGE void -_gptrput (char *gptr, char c) _naked +_gptrput (char *gptr, char c) __naked { /* This is the banked version with pointers up to 22 bits. B cannot be trashed */ gptr; c; /* hush the compiler */ - _asm + __asm ; ; depending on the pointer type according to SDCCsymt.h ; @@ -81,20 +81,20 @@ _gptrput (char *gptr, char c) _naked ;=== ;27 bytes -_endasm; + __endasm; } #elif defined DSDCC_MODEL_MEDIUM void -_gptrput (char *gptr, char c) _naked +_gptrput (char *gptr, char c) __naked { /* This is the non-banked version with pointers up to 14 bits. Assumes B is free to be used */ gptr; c; /* hush the compiler */ - _asm + __asm ; ; depending on the pointer type according to SDCCsymt.h ; @@ -130,20 +130,20 @@ _gptrput (char *gptr, char c) _naked ret ; 1 ;=== ;25 bytes - _endasm; + __endasm; } #elif 1 void -_gptrput (char *gptr, char c) _naked +_gptrput (char *gptr, char c) __naked { /* This is the new version with pointers up to 16 bits. B cannot be trashed */ gptr; c; /* hush the compiler */ - _asm + __asm ; ; depending on the pointer type according to SDCCsymt.h ; @@ -179,19 +179,19 @@ _gptrput (char *gptr, char c) _naked ;=== ;24 bytes -_endasm; + __endasm; } #else void -_gptrput (char *gptr, char c) _naked +_gptrput (char *gptr, char c) __naked { /* This is the old version with pointers up to 16 bits. */ gptr; c; /* hush the compiler */ - _asm + __asm ar0 = 0x00 push acc ; 2 ; @@ -243,7 +243,7 @@ _gptrput (char *gptr, char c) _naked ret ; 1 ;=== ;46 bytes -_endasm; + __endasm; } #endif @@ -254,7 +254,7 @@ _endasm; void _gptrputWord () { - _asm + __asm ; ; depending on the pointer type acc. to SDCCsymt.h ; @@ -302,7 +302,7 @@ _gptrputWord () mov r0,dph ; restore r0 mov dph,#0 ; restore dph 00016$: - _endasm; + __endasm; } #else @@ -310,7 +310,7 @@ _gptrputWord () void _gptrputWord () { - _asm + __asm push acc ; ; depending on the pointer type acc. to SDCCsymt.h @@ -365,7 +365,7 @@ _gptrputWord () inc dptr pop ar0 00016$: - _endasm; + __endasm; } #endif diff --git a/device/lib/_logexpf.c b/device/lib/_logexpf.c index bd9b1003..5890fc2f 100644 --- a/device/lib/_logexpf.c +++ b/device/lib/_logexpf.c @@ -10,7 +10,7 @@ void _fs_cordic_rshift_r765_unsigned(void) { - _asm + __asm add a, #248 jnc 00003$ mov b, r5 @@ -52,10 +52,10 @@ void _fs_cordic_rshift_r765_unsigned(void) djnz r0, 00010$ pop ar0 00030$: - _endasm; + __endasm; } -code unsigned char _fs_natural_log_table[] = { +__code unsigned char _fs_natural_log_table[] = { 0xFF, 0x42, 0x2E, 0x16, // 0.693147180560 0xF6, 0x91, 0xF9, 0x0C, // 0.405465108108 0xF2, 0xFD, 0x23, 0x07, // 0.223143551314 diff --git a/device/lib/_modsint.c b/device/lib/_modsint.c index 6aa6bdf1..6ca1f520 100644 --- a/device/lib/_modsint.c +++ b/device/lib/_modsint.c @@ -49,149 +49,149 @@ unsigned unsigned _moduint (unsigned a, unsigned b); #if defined _MODSINT_ASM_SMALL static void -_modsint_dummy (void) _naked +_modsint_dummy (void) __naked { - _asm + __asm - #define a0 dpl - #define a1 dph + #define a0 dpl + #define a1 dph - .globl __modsint + .globl __modsint #if defined(SDCC_PARMS_IN_BANK1) - #define b0 (b1_0) - #define b1 (b1_1) + #define b0 (b1_0) + #define b1 (b1_1) #else - // _modsint_PARM_2 shares the same memory with _moduint_PARM_2 - // and is defined in _moduint.c - #define b0 (__modsint_PARM_2) - #define b1 (__modsint_PARM_2 + 1) + // _modsint_PARM_2 shares the same memory with _moduint_PARM_2 + // and is defined in _moduint.c + #define b0 (__modsint_PARM_2) + #define b1 (__modsint_PARM_2 + 1) #endif - __modsint: - ; a1 in dph - ; b1 in (__modsint_PARM_2 + 1) +__modsint: + ; a1 in dph + ; b1 in (__modsint_PARM_2 + 1) - clr F0 ; Flag 0 in PSW - ; available to user for general purpose - mov a,a1 - jnb acc.7,a_not_negative + clr F0 ; Flag 0 in PSW + ; available to user for general purpose + mov a,a1 + jnb acc.7,a_not_negative - setb F0 + setb F0 - clr a - clr c - subb a,a0 - mov a0,a - clr a - subb a,a1 - mov a1,a + clr a + clr c + subb a,a0 + mov a0,a + clr a + subb a,a1 + mov a1,a - a_not_negative: +a_not_negative: - mov a,b1 - jnb acc.7,b_not_negative + mov a,b1 + jnb acc.7,b_not_negative - clr a - clr c - subb a,b0 - mov b0,a - clr a - subb a,b1 - mov b1,a + clr a + clr c + subb a,b0 + mov b0,a + clr a + subb a,b1 + mov b1,a - b_not_negative: +b_not_negative: - lcall __moduint + lcall __moduint - jnb F0,not_negative + jnb F0,not_negative - clr a - clr c - subb a,a0 - mov a0,a - clr a - subb a,a1 - mov a1,a + clr a + clr c + subb a,a0 + mov a0,a + clr a + subb a,a1 + mov a1,a - not_negative: - ret +not_negative: + ret - _endasm ; + __endasm; } #elif defined _MODSINT_ASM_SMALL_AUTO static void -_modsint_dummy (void) _naked +_modsint_dummy (void) __naked { - _asm + __asm - #define a0 dpl - #define a1 dph + #define a0 dpl + #define a1 dph - ar0 = 0 ; BUG register set is not considered - ar1 = 1 + ar0 = 0 ; BUG register set is not considered + ar1 = 1 - .globl __modsint + .globl __modsint - __modsint: +__modsint: - clr F0 ; Flag 0 in PSW - ; available to user for general purpose - mov a,a1 - jnb acc.7,a_not_negative + clr F0 ; Flag 0 in PSW + ; available to user for general purpose + mov a,a1 + jnb acc.7,a_not_negative - setb F0 + setb F0 - clr a - clr c - subb a,a0 - mov a0,a - clr a - subb a,a1 - mov a1,a + clr a + clr c + subb a,a0 + mov a0,a + clr a + subb a,a1 + mov a1,a - a_not_negative: +a_not_negative: - mov a,sp - add a,#-2 ; 2 bytes return address - mov r0,a ; r0 points to b1 - mov a,@r0 ; b1 + mov a,sp + add a,#-2 ; 2 bytes return address + mov r0,a ; r0 points to b1 + mov a,@r0 ; b1 - jnb acc.7,b_not_negative + jnb acc.7,b_not_negative - dec r0 + dec r0 - clr a - clr c - subb a,@r0 ; b0 - mov @r0,a - clr a - inc r0 - subb a,@r0 ; b1 - mov @r0,a + clr a + clr c + subb a,@r0 ; b0 + mov @r0,a + clr a + inc r0 + subb a,@r0 ; b1 + mov @r0,a - b_not_negative: +b_not_negative: - mov ar1,@r0 ; b1 - dec r0 - mov ar0,@r0 ; b0 + mov ar1,@r0 ; b1 + dec r0 + mov ar0,@r0 ; b0 - lcall __modint + lcall __modint - jnb F0,not_negative + jnb F0,not_negative - clr a - clr c - subb a,a0 - mov a0,a - clr a - subb a,a1 - mov a1,a + clr a + clr c + subb a,a0 + mov a0,a + clr a + subb a,a1 + mov a1,a - not_negative: - ret +not_negative: + ret - _endasm ; + __endasm; } #else // _MODSINT_ASM_ diff --git a/device/lib/_modslong.c b/device/lib/_modslong.c index 975168ed..1ad4e1e7 100644 --- a/device/lib/_modslong.c +++ b/device/lib/_modslong.c @@ -48,206 +48,205 @@ unsigned long _modulong (unsigned long a, unsigned long b); #if defined _MODSLONG_ASM_SMALL static void -_modslong_dummy (void) _naked +_modslong_dummy (void) __naked { - _asm + __asm - #define a0 dpl - #define a1 dph - #define a2 b - #define a3 r1 + #define a0 dpl + #define a1 dph + #define a2 b + #define a3 r1 - .globl __modslong + .globl __modslong #if defined(SDCC_PARMS_IN_BANK1) - #define b0 (b1_0) - #define b1 (b1_1) - #define b2 (b1_2) - #define b3 (b1_3) + #define b0 (b1_0) + #define b1 (b1_1) + #define b2 (b1_2) + #define b3 (b1_3) #else - // _modslong_PARM_2 shares the same memory with _modulong_PARM_2 - // and is defined in _modulong.c - #define b0 (__modslong_PARM_2) - #define b1 (__modslong_PARM_2 + 1) - #define b2 (__modslong_PARM_2 + 2) - #define b3 (__modslong_PARM_2 + 3) + // _modslong_PARM_2 shares the same memory with _modulong_PARM_2 + // and is defined in _modulong.c + #define b0 (__modslong_PARM_2) + #define b1 (__modslong_PARM_2 + 1) + #define b2 (__modslong_PARM_2 + 2) + #define b3 (__modslong_PARM_2 + 3) #endif - __modslong: - ; a3 in acc - ; b3 in (__modslong_PARM_2 + 3) - mov a3,a ; save a3 - - clr F0 ; Flag 0 in PSW - ; available to user for general purpose - jnb acc.7,a_not_negative - - setb F0 - - clr a ; a = -a; - clr c - subb a,a0 - mov a0,a - clr a - subb a,a1 - mov a1,a - clr a - subb a,a2 - mov a2,a - clr a - subb a,a3 - mov a3,a - - a_not_negative: - - mov a,b3 - jnb acc.7,b_not_negative - - clr a ; b = -b; - clr c - subb a,b0 - mov b0,a - clr a - subb a,b1 - mov b1,a - clr a - subb a,b2 - mov b2,a - clr a - subb a,b3 - mov b3,a - - b_not_negative: - - mov a,a3 ; restore a3 in acc - - lcall __modulong - - jnb F0,not_negative +__modslong: + ; a3 in acc + ; b3 in (__modslong_PARM_2 + 3) + mov a3,a ; save a3 + + clr F0 ; Flag 0 in PSW + ; available to user for general purpose + jnb acc.7,a_not_negative + + setb F0 + + clr a ; a = -a; + clr c + subb a,a0 + mov a0,a + clr a + subb a,a1 + mov a1,a + clr a + subb a,a2 + mov a2,a + clr a + subb a,a3 + mov a3,a + +a_not_negative: + + mov a,b3 + jnb acc.7,b_not_negative + + clr a ; b = -b; + clr c + subb a,b0 + mov b0,a + clr a + subb a,b1 + mov b1,a + clr a + subb a,b2 + mov b2,a + clr a + subb a,b3 + mov b3,a + +b_not_negative: + + mov a,a3 ; restore a3 in acc + + lcall __modulong + + jnb F0,not_negative ; result in (a == r1), b, dph, dpl - clr a - clr c - subb a,a0 - mov a0,a - clr a - subb a,a1 - mov a1,a - clr a - subb a,a2 - mov a2,a - clr a - subb a,a3 + clr a + clr c + subb a,a0 + mov a0,a + clr a + subb a,a1 + mov a1,a + clr a + subb a,a2 + mov a2,a + clr a + subb a,a3 ; result in a, b, dph, dpl - not_negative: - ret +not_negative: + ret - _endasm ; + __endasm; } #elif defined _MODSLONG_ASM_SMALL_AUTO static void -_modslong_dummy (void) _naked +_modslong_dummy (void) __naked { - _asm - - #define a0 dpl - #define a1 dph - #define a2 b - #define a3 r1 - - #define b0 r2 - #define b1 r3 - #define b2 r4 - #define b3 r5 - - ar2 = 2 ; BUG register set is not considered - ar3 = 3 - ar4 = 4 - ar5 = 5 - - .globl __modslong - - __modslong: - - ; a3 in acc - mov a3,a ; save a3 - - clr F0 ; F0 (Flag 0) - ; available to user for general purpose - jnb acc.7,a_not_negative - - setb F0 - - clr a ; a = -a; - clr c - subb a,a0 - mov a0,a - clr a - subb a,a1 - mov a1,a - clr a - subb a,a2 - mov a2,a - clr a - subb a,a3 - mov a3,a - - a_not_negative: - - mov a,sp - add a,#-2-3 ; 2 bytes return address, 3 bytes param b - mov r0,a ; r1 points to b0 - - - mov ar2,@r0 ; load b0 - inc r0 ; r0 points to b1 - mov ar3,@r0 ; b1 - inc r0 - mov ar4,@r0 ; b2 - inc r0 - mov a,@r0 ; b3 - mov b3,a - - jnb acc.7,b_not_negative - - clr a ; b = -b; - clr c - subb a,b0 - mov b0,a - clr a - subb a,b1 - mov b1,a - clr a - subb a,b2 - mov b2,a - clr a - subb a,b3 - mov b3,a - - b_not_negative: - - lcall __modlong - - jnb F0,not_negative + __asm + + #define a0 dpl + #define a1 dph + #define a2 b + #define a3 r1 + + #define b0 r2 + #define b1 r3 + #define b2 r4 + #define b3 r5 + + ar2 = 2 ; BUG register set is not considered + ar3 = 3 + ar4 = 4 + ar5 = 5 + + .globl __modslong + +__modslong: + + ; a3 in acc + mov a3,a ; save a3 + + clr F0 ; F0 (Flag 0) + ; available to user for general purpose + jnb acc.7,a_not_negative + + setb F0 + + clr a ; a = -a; + clr c + subb a,a0 + mov a0,a + clr a + subb a,a1 + mov a1,a + clr a + subb a,a2 + mov a2,a + clr a + subb a,a3 + mov a3,a + +a_not_negative: + + mov a,sp + add a,#-2-3 ; 2 bytes return address, 3 bytes param b + mov r0,a ; r1 points to b0 + + mov ar2,@r0 ; load b0 + inc r0 ; r0 points to b1 + mov ar3,@r0 ; b1 + inc r0 + mov ar4,@r0 ; b2 + inc r0 + mov a,@r0 ; b3 + mov b3,a + + jnb acc.7,b_not_negative + + clr a ; b = -b; + clr c + subb a,b0 + mov b0,a + clr a + subb a,b1 + mov b1,a + clr a + subb a,b2 + mov b2,a + clr a + subb a,b3 + mov b3,a + +b_not_negative: + + lcall __modlong + + jnb F0,not_negative ; result in (a == r1), b, dph, dpl - clr a - clr c - subb a,a0 - mov a0,a - clr a - subb a,a1 - mov a1,a - clr a - subb a,a2 - mov a2,a - clr a - subb a,a3 ; result in a, b, dph, dpl - - not_negative: - ret - - _endasm ; + clr a + clr c + subb a,a0 + mov a0,a + clr a + subb a,a1 + mov a1,a + clr a + subb a,a2 + mov a2,a + clr a + subb a,a3 ; result in a, b, dph, dpl + +not_negative: + ret + + __endasm; } #else // _MODSLONG_ASM diff --git a/device/lib/_moduint.c b/device/lib/_moduint.c index 221dea74..dc6a7ec8 100644 --- a/device/lib/_moduint.c +++ b/device/lib/_moduint.c @@ -44,124 +44,122 @@ #if defined _MODUINT_ASM_SMALL || defined _MODUINT_ASM_SMALL_AUTO static void -_moduint_dummy (void) _naked +_moduint_dummy (void) __naked { - _asm + __asm - .globl __moduint + .globl __moduint - __moduint: +__moduint: - #define count r2 - #define al dpl - #define ah dph + #define count r2 + #define al dpl + #define ah dph #if defined(SDCC_STACK_AUTO) && !defined(SDCC_PARMS_IN_BANK1) - ar0 = 0 ; BUG register set is not considered - ar1 = 1 + ar0 = 0 ; BUG register set is not considered + ar1 = 1 - .globl __modint + .globl __modint - mov a,sp - add a,#-2 ; 2 bytes return address - mov r0,a ; r0 points to bh - mov ar1,@r0 ; load bh - dec r0 - mov ar0,@r0 ; load bl + mov a,sp + add a,#-2 ; 2 bytes return address + mov r0,a ; r0 points to bh + mov ar1,@r0 ; load bh + dec r0 + mov ar0,@r0 ; load bl - #define bl r0 - #define bh r1 + #define bl r0 + #define bh r1 - __modint: ; entry point for __modsint +__modint: ; entry point for __modsint #else // SDCC_STACK_AUTO #if !defined(SDCC_PARMS_IN_BANK1) #if defined(SDCC_NOOVERLAY) - .area DSEG (DATA) + .area DSEG (DATA) #else - .area OSEG (OVR,DATA) + .area OSEG (OVR,DATA) #endif - .globl __moduint_PARM_2 - .globl __modsint_PARM_2 + .globl __moduint_PARM_2 + .globl __modsint_PARM_2 - __moduint_PARM_2: - __modsint_PARM_2: - .ds 2 +__moduint_PARM_2: +__modsint_PARM_2: + .ds 2 - .area CSEG (CODE) + .area CSEG (CODE) - #define bl (__moduint_PARM_2) - #define bh (__moduint_PARM_2 + 1) + #define bl (__moduint_PARM_2) + #define bh (__moduint_PARM_2 + 1) #else - #define bl (b1_0) - #define bh (b1_1) + #define bl (b1_0) + #define bh (b1_1) #endif #endif // SDCC_STACK_AUTO - mov a,bl ; avoid endless loop - orl a,bh - jz div_by_0 - - mov count,#1 - - loop1: mov a,bl ; b <<= 1 - add a,acc - mov bl,a - mov a,bh - rlc a - jc msbset - mov bh,a - - mov a,al ; a - b - subb a,bl ; here carry is always clear - mov a,ah - subb a,bh - - jc start - - inc count - sjmp loop1 - - - start: clr c - mov a,bh ; b >>= 1; - msbset: rrc a - mov bh,a - mov a,bl - rrc a - mov bl,a - - - loop2: clr c - mov a,al ; a - b - subb a,bl - - mov b,a - mov a,ah - subb a,bh - - jc smaller ; a >= b? - - mov ah,a ; -> yes; a = a - b; - mov al,b - smaller: ; -> no - clr c - mov a,bh ; b >>= 1; - rrc a - mov bh,a - mov a,bl - rrc a - mov bl,a - - djnz count,loop2 - div_by_0: - ret - - _endasm ; + mov a,bl ; avoid endless loop + orl a,bh + jz div_by_0 + + mov count,#1 + +loop1: mov a,bl ; b <<= 1 + add a,acc + mov bl,a + mov a,bh + rlc a + jc msbset + mov bh,a + + mov a,al ; a - b + subb a,bl ; here carry is always clear + mov a,ah + subb a,bh + + jc start + + inc count + sjmp loop1 + +start: clr c + mov a,bh ; b >>= 1; +msbset: rrc a + mov bh,a + mov a,bl + rrc a + mov bl,a + +loop2: clr c + mov a,al ; a - b + subb a,bl + + mov b,a + mov a,ah + subb a,bh + + jc smaller ; a >= b? + + mov ah,a ; -> yes; a = a - b; + mov al,b +smaller: ; -> no + clr c + mov a,bh ; b >>= 1; + rrc a + mov bh,a + mov a,bl + rrc a + mov bl,a + + djnz count,loop2 +div_by_0: + ret + + __endasm; } #else // defined _MODUINT_ASM_SMALL || defined _MODUINT_ASM_SMALL_AUTO diff --git a/device/lib/_modulong.c b/device/lib/_modulong.c index 0ef610ff..97274c4c 100644 --- a/device/lib/_modulong.c +++ b/device/lib/_modulong.c @@ -44,292 +44,289 @@ #if defined _MODULONG_ASM_SMALL static void -_modlong_dummy (void) _naked +_modlong_dummy (void) __naked { - _asm + __asm - .globl __modulong + .globl __modulong - #define a0 dpl - #define a1 dph - #define a2 b - #define a3 r1 - #define count r0 + #define a0 dpl + #define a1 dph + #define a2 b + #define a3 r1 + #define count r0 - __modulong: +__modulong: #if defined(SDCC_PARMS_IN_BANK1) - #define b0 (b1_0) - #define b1 (b1_1) - #define b2 (b1_2) - #define b3 (b1_3) + #define b0 (b1_0) + #define b1 (b1_1) + #define b2 (b1_2) + #define b3 (b1_3) #else #if defined(SDCC_NOOVERLAY) - .area DSEG (DATA) + .area DSEG (DATA) #else - .area OSEG (OVR,DATA) + .area OSEG (OVR,DATA) #endif - .globl __modulong_PARM_2 - .globl __modslong_PARM_2 + .globl __modulong_PARM_2 + .globl __modslong_PARM_2 - __modulong_PARM_2: - __modslong_PARM_2: - .ds 4 +__modulong_PARM_2: +__modslong_PARM_2: + .ds 4 - .area CSEG (CODE) + .area CSEG (CODE) - - #define b0 (__modulong_PARM_2) - #define b1 (__modulong_PARM_2 + 1) - #define b2 (__modulong_PARM_2 + 2) - #define b3 (__modulong_PARM_2 + 3) + #define b0 (__modulong_PARM_2) + #define b1 (__modulong_PARM_2 + 1) + #define b2 (__modulong_PARM_2 + 2) + #define b3 (__modulong_PARM_2 + 3) #endif - ; parameter a comes in a, b, dph, dpl - mov a3,a ; save parameter a3 - - mov a,b0 ; b == 0? avoid endless loop - orl a,b1 - orl a,b2 - orl a,b3 - jz div_by_0 - - mov count,#0 - clr c ; when loop1 jumps immediately to loop2 - - loop1: inc count - - mov a,b3 ; if (!MSB_SET(b)) - jb acc.7,loop2 - - mov a,b0 ; b <<= 1 - add a,acc - mov b0,a - mov a,b1 - rlc a - mov b1,a - mov a,b2 - rlc a - mov b2,a - mov a,b3 - rlc a - mov b3,a - - mov a,a0 ; a - b - subb a,b0 ; here carry is always clear - mov a,a1 - subb a,b1 - mov a,a2 - subb a,b2 - mov a,a3 - subb a,b3 - - jnc loop1 - - - clr c - mov a,b3 ; b >>= 1; - rrc a - mov b3,a - mov a,b2 - rrc a - mov b2,a - mov a,b1 - rrc a - mov b1,a - mov a,b0 - rrc a - mov b0,a - - loop2: ; clr c never set - mov a,a0 ; a - b - subb a,b0 - mov r4,a - mov a,a1 - subb a,b1 - mov r5,a - mov a,a2 - subb a,b2 - mov r6,a - mov a,a3 - subb a,b3 - - jc smaller ; a >= b? - - mov a3,a ; -> yes; a = a - b; - mov a2,r6 - mov a1,r5 - mov a0,r4 - smaller: ; -> no - clr c - mov a,b3 ; b >>= 1; - rrc a - mov b3,a - mov a,b2 - rrc a - mov b2,a - mov a,b1 - rrc a - mov b1,a - mov a,b0 - rrc a - mov b0,a - - djnz count,loop2 - - mov a,a3 ; prepare the return value - div_by_0: - ret - - _endasm ; + ; parameter a comes in a, b, dph, dpl + mov a3,a ; save parameter a3 + + mov a,b0 ; b == 0? avoid endless loop + orl a,b1 + orl a,b2 + orl a,b3 + jz div_by_0 + + mov count,#0 + clr c ; when loop1 jumps immediately to loop2 + +loop1: inc count + + mov a,b3 ; if (!MSB_SET(b)) + jb acc.7,loop2 + + mov a,b0 ; b <<= 1 + add a,acc + mov b0,a + mov a,b1 + rlc a + mov b1,a + mov a,b2 + rlc a + mov b2,a + mov a,b3 + rlc a + mov b3,a + + mov a,a0 ; a - b + subb a,b0 ; here carry is always clear + mov a,a1 + subb a,b1 + mov a,a2 + subb a,b2 + mov a,a3 + subb a,b3 + + jnc loop1 + + + clr c + mov a,b3 ; b >>= 1; + rrc a + mov b3,a + mov a,b2 + rrc a + mov b2,a + mov a,b1 + rrc a + mov b1,a + mov a,b0 + rrc a + mov b0,a + +loop2: ; clr c never set + mov a,a0 ; a - b + subb a,b0 + mov r4,a + mov a,a1 + subb a,b1 + mov r5,a + mov a,a2 + subb a,b2 + mov r6,a + mov a,a3 + subb a,b3 + + jc smaller ; a >= b? + + mov a3,a ; -> yes; a = a - b; + mov a2,r6 + mov a1,r5 + mov a0,r4 +smaller: ; -> no + clr c + mov a,b3 ; b >>= 1; + rrc a + mov b3,a + mov a,b2 + rrc a + mov b2,a + mov a,b1 + rrc a + mov b1,a + mov a,b0 + rrc a + mov b0,a + + djnz count,loop2 + + mov a,a3 ; prepare the return value +div_by_0: + ret + + __endasm; } #elif defined _MODULONG_ASM_SMALL_AUTO static void -_modlong_dummy (void) _naked +_modlong_dummy (void) __naked { - _asm - - .globl __modulong - - __modulong: - - #define count r0 - - #define a0 dpl - #define a1 dph - #define a2 b - #define a3 r1 - - #define b0 r2 - #define b1 r3 - #define b2 r4 - #define b3 r5 - - ar2 = 2 ; BUG register set is not considered - ar3 = 3 - ar4 = 4 - ar5 = 5 - - .globl __modlong ; entry point for __modslong - - ; parameter a comes in a, b, dph, dpl - mov a3,a ; save parameter a3 - - mov a,sp - add a,#-2-3 ; 2 bytes return address, 3 bytes param b - mov r0,a ; r1 points to b0 - - - mov ar2,@r0 ; load b0 - inc r0 ; r0 points to b1 - mov ar3,@r0 ; b1 - inc r0 - mov ar4,@r0 ; b2 - inc r0 - mov ar5,@r0 ; b3 - - __modlong: ; entry point for __modslong - ; a in r1, b, dph, dpl - ; b in r5, r4, r3, r2 - - mov count,#0 - - mov a,b0 ; b == 0? avoid endless loop - orl a,b1 - orl a,b2 - orl a,b3 - jz div_by_0 - - mov count,#0 - clr c ; when loop1 jumps immediately to loop2 - - loop1: inc count - - mov a,b3 ; if (!MSB_SET(b)) - jb acc.7,loop2 - - mov a,b0 ; b <<= 1 - add a,acc - mov b0,a - mov a,b1 - rlc a - mov b1,a - mov a,b2 - rlc a - mov b2,a - mov a,b3 - rlc a - mov b3,a - - mov a,a0 ; a - b - subb a,b0 ; here carry is always clear - mov a,a1 - subb a,b1 - mov a,a2 - subb a,b2 - mov a,a3 - subb a,b3 - - jnc loop1 - - - clr c - mov a,b3 ; b >>= 1; - rrc a - mov b3,a - mov a,b2 - rrc a - mov b2,a - mov a,b1 - rrc a - mov b1,a - mov a,b0 - rrc a - mov b0,a - - loop2: ; clr c never set - mov a,a0 ; a - b - subb a,b0 - mov a,a1 - subb a,b1 - mov r6,a ; d1 - mov a,a2 - subb a,b2 - mov r7,a ; d2 - mov a,a3 - subb a,b3 - - jc smaller ; a >= b? - - mov a3,a ; -> yes; a = a - b; - mov a2,r7 - mov a1,r6 - mov a,a0 - subb a,b0 - mov a0,a - smaller: ; -> no - clr c - mov a,b3 ; b >>= 1; - rrc a - mov b3,a - mov a,b2 - rrc a - mov b2,a - mov a,b1 - rrc a - mov b1,a - mov a,b0 - rrc a - mov b0,a - - djnz count,loop2 - - mov a,a3 ; prepare the return value - div_by_0: - ret - - _endasm ; + __asm + + .globl __modulong + +__modulong: + + #define count r0 + + #define a0 dpl + #define a1 dph + #define a2 b + #define a3 r1 + + #define b0 r2 + #define b1 r3 + #define b2 r4 + #define b3 r5 + + ar2 = 2 ; BUG register set is not considered + ar3 = 3 + ar4 = 4 + ar5 = 5 + + .globl __modlong ; entry point for __modslong + + ; parameter a comes in a, b, dph, dpl + mov a3,a ; save parameter a3 + + mov a,sp + add a,#-2-3 ; 2 bytes return address, 3 bytes param b + mov r0,a ; r1 points to b0 + + mov ar2,@r0 ; load b0 + inc r0 ; r0 points to b1 + mov ar3,@r0 ; b1 + inc r0 + mov ar4,@r0 ; b2 + inc r0 + mov ar5,@r0 ; b3 + +__modlong: ; entry point for __modslong + ; a in r1, b, dph, dpl + ; b in r5, r4, r3, r2 + + mov count,#0 + + mov a,b0 ; b == 0? avoid endless loop + orl a,b1 + orl a,b2 + orl a,b3 + jz div_by_0 + + mov count,#0 + clr c ; when loop1 jumps immediately to loop2 + +loop1: inc count + + mov a,b3 ; if (!MSB_SET(b)) + jb acc.7,loop2 + + mov a,b0 ; b <<= 1 + add a,acc + mov b0,a + mov a,b1 + rlc a + mov b1,a + mov a,b2 + rlc a + mov b2,a + mov a,b3 + rlc a + mov b3,a + + mov a,a0 ; a - b + subb a,b0 ; here carry is always clear + mov a,a1 + subb a,b1 + mov a,a2 + subb a,b2 + mov a,a3 + subb a,b3 + + jnc loop1 + + clr c + mov a,b3 ; b >>= 1; + rrc a + mov b3,a + mov a,b2 + rrc a + mov b2,a + mov a,b1 + rrc a + mov b1,a + mov a,b0 + rrc a + mov b0,a + +loop2: ; clr c never set + mov a,a0 ; a - b + subb a,b0 + mov a,a1 + subb a,b1 + mov r6,a ; d1 + mov a,a2 + subb a,b2 + mov r7,a ; d2 + mov a,a3 + subb a,b3 + + jc smaller ; a >= b? + + mov a3,a ; -> yes; a = a - b; + mov a2,r7 + mov a1,r6 + mov a,a0 + subb a,b0 + mov a0,a +smaller: ; -> no + clr c + mov a,b3 ; b >>= 1; + rrc a + mov b3,a + mov a,b2 + rrc a + mov b2,a + mov a,b1 + rrc a + mov b1,a + mov a,b0 + rrc a + mov b0,a + + djnz count,loop2 + + mov a,a3 ; prepare the return value +div_by_0: + ret + + __endasm; } #else // _MODULONG_ASM diff --git a/device/lib/_mulint.c b/device/lib/_mulint.c index 387585c0..16ad56f0 100644 --- a/device/lib/_mulint.c +++ b/device/lib/_mulint.c @@ -67,7 +67,7 @@ _mulint (int a, int b) (char)(lsb_a*msb_b)<<8 */ - _asm + __asm mov r2,dph ; msb_a mov r3,dpl ; lsb_a @@ -105,7 +105,7 @@ _mulint (int a, int b) mov dph,a mov dpl,r0 ret - _endasm; + __endasm; } #pragma restore @@ -114,20 +114,20 @@ _mulint (int a, int b) #pragma save #pragma less_pedantic int -_mulint_dummy (void) _naked +_mulint_dummy (void) __naked { - _asm + __asm - __mulint: +__mulint: - .globl __mulint + .globl __mulint #if !defined(SDCC_STACK_AUTO) || defined(SDCC_PARMS_IN_BANK1) #if defined(SDCC_NOOVERLAY) - .area DSEG (DATA) + .area DSEG (DATA) #else - .area OSEG (OVR,DATA) + .area OSEG (OVR,DATA) #endif #if defined(SDCC_PARMS_IN_BANK1) #define bl (b1_0) @@ -135,70 +135,70 @@ _mulint_dummy (void) _naked #else #define bl (__mulint_PARM_2) #define bh (__mulint_PARM_2 + 1) - __mulint_PARM_2: +__mulint_PARM_2: - .globl __mulint_PARM_2 + .globl __mulint_PARM_2 - .ds 2 + .ds 2 #endif - .area CSEG (CODE) + .area CSEG (CODE) - ; globbered registers none + ; globbered registers none - mov a,dpl ; 1 al - mov b,bl ; 2 bl - mul ab ; 4 al * bl - xch a,dpl ; 1 store low-byte of return value, fetch al - push b ; 2 + mov a,dpl ; 1 al + mov b,bl ; 2 bl + mul ab ; 4 al * bl + xch a,dpl ; 1 store low-byte of return value, fetch al + push b ; 2 - mov b,bh ; 2 bh - mul ab ; 4 al * bh - pop b ; 2 - add a,b ; 1 - xch a,dph ; 1 ah -> acc + mov b,bh ; 2 bh + mul ab ; 4 al * bh + pop b ; 2 + add a,b ; 1 + xch a,dph ; 1 ah -> acc - mov b,bl ; 2 bl - mul ab ; 4 ah * bl - add a,dph ; 1 - mov dph,a ; 1 - ret ; 2 - ; 30 + mov b,bl ; 2 bl + mul ab ; 4 ah * bl + add a,dph ; 1 + mov dph,a ; 1 + ret ; 2 + ; 30 #else // SDCC_STACK_AUTO - ; globbered registers r0 + ; globbered registers r0 - mov a,#-2 ; 1 return address 2 bytes - add a,sp ; 1 - mov r0,a ; 1 r0 points to bh + mov a,#-2 ; 1 return address 2 bytes + add a,sp ; 1 + mov r0,a ; 1 r0 points to bh - mov a,@r0 ; 1 bh - mov b,dpl ; 2 al - mul ab ; 4 al * bh - push acc ; 2 + mov a,@r0 ; 1 bh + mov b,dpl ; 2 al + mul ab ; 4 al * bh + push acc ; 2 - mov b,dpl ; 2 al - dec r0 ; 1 - mov a,@r0 ; 1 bl - mul ab ; 4 al * bl + mov b,dpl ; 2 al + dec r0 ; 1 + mov a,@r0 ; 1 bl + mul ab ; 4 al * bl - mov dpl,a ; 1 low-byte of return-value + mov dpl,a ; 1 low-byte of return-value - pop acc ; 2 - add a,b ; 1 - xch a,dph ; 1 ah -> acc + pop acc ; 2 + add a,b ; 1 + xch a,dph ; 1 ah -> acc - mov b,@r0 ; 2 bl - mul ab ; 4 ah * bl - add a,dph ; 1 - mov dph,a ; 1 + mov b,@r0 ; 2 bl + mul ab ; 4 ah * bl + add a,dph ; 1 + mov dph,a ; 1 - ret + ret #endif // SDCC_STACK_AUTO - _endasm ; + __endasm; } #pragma restore @@ -213,11 +213,11 @@ 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 __xdata *x; + union uu __xdata *y; union uu t; - x = (union uu xdata *)&a; - y = (union uu xdata *)&b; + x = (union uu __xdata *)&a; + y = (union uu __xdata *)&b; #else register union uu *x; register union uu *y; diff --git a/device/lib/_mullong.c b/device/lib/_mullong.c index dee5a51e..92ec722b 100644 --- a/device/lib/_mullong.c +++ b/device/lib/_mullong.c @@ -50,24 +50,24 @@ #if defined(_MULLONG_ASM_SMALL) || defined(_MULLONG_ASM_SMALL_AUTO) void -_mullong_dummy (void) _naked +_mullong_dummy (void) __naked { - _asm + __asm - __mullong: +__mullong: - .globl __mullong + .globl __mullong - ; the result c will be stored in r4...r7 - #define c0 r4 - #define c1 r5 - #define c2 r6 - #define c3 r7 + ; the result c will be stored in r4...r7 + #define c0 r4 + #define c1 r5 + #define c2 r6 + #define c3 r7 - #define a0 dpl - #define a1 dph - #define a2 r2 - #define a3 r3 + #define a0 dpl + #define a1 dph + #define a2 r2 + #define a3 r3 ; c0 a0 * b0 ; c1 a1 * b0 + a0 * b1 @@ -76,255 +76,252 @@ _mullong_dummy (void) _naked #if !defined(SDCC_STACK_AUTO) || defined(SDCC_PARMS_IN_BANK1) #if defined(SDCC_PARMS_IN_BANK1) - #define b0 (b1_0) - #define b1 (b1_1) - #define b2 (b1_2) - #define b3 (b1_3) + #define b0 (b1_0) + #define b1 (b1_1) + #define b2 (b1_2) + #define b3 (b1_3) #else #if defined(SDCC_NOOVERLAY) - .area DSEG (DATA) + .area DSEG (DATA) #else - .area OSEG (OVR,DATA) + .area OSEG (OVR,DATA) #endif - __mullong_PARM_2: +__mullong_PARM_2: - .globl __mullong_PARM_2 + .globl __mullong_PARM_2 - .ds 4 + .ds 4 - b0 = __mullong_PARM_2 - b1 = (__mullong_PARM_2+1) - b2 = (__mullong_PARM_2+2) - b3 = (__mullong_PARM_2+3) + b0 = __mullong_PARM_2 + b1 = (__mullong_PARM_2+1) + b2 = (__mullong_PARM_2+2) + b3 = (__mullong_PARM_2+3) #endif - .area CSEG (CODE) - - ; parameter a comes in a, b, dph, dpl - mov r2,b ; save parameter a - mov r3,a - - ; Byte 0 - mov a,a0 - mov b,b0 - mul ab ; a0 * b0 - mov c0,a - mov c1,b - - ; Byte 1 - mov a,a1 - mov b,b0 - mul ab ; a1 * b0 - add a,c1 - mov c1,a - clr a - addc a,b - mov c2,a - - - mov a,a0 - mov b,b1 - mul ab ; a0 * b1 - add a,c1 - mov c1,a - mov a,b - addc a,c2 - mov c2,a - clr a - rlc a - mov c3,a - - ; Byte 2 - mov a,a2 - mov b,b0 - mul ab ; a2 * b0 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - mov a,a1 - mov b,b1 - mul ab ; a1 * b1 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - mov a,a0 - mov b,b2 - mul ab ; a0 * b2 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - ; Byte 3 - mov a,a3 - mov b,b0 - mul ab ; a3 * b0 - add a,c3 - mov c3,a - - mov a,a2 - mov b,b1 - mul ab ; a2 * b1 - add a,c3 - mov c3,a - - mov a,a1 - mov b,b2 - mul ab ; a1 * b2 - add a,c3 - mov c3,a - - mov a,a0 - mov b,b3 - mul ab ; a0 * b3 - add a,c3 - - mov b,c2 - mov dph,c1 - mov dpl,c0 - ret + .area CSEG (CODE) + + ; parameter a comes in a, b, dph, dpl + mov r2,b ; save parameter a + mov r3,a + + ; Byte 0 + mov a,a0 + mov b,b0 + mul ab ; a0 * b0 + mov c0,a + mov c1,b + + ; Byte 1 + mov a,a1 + mov b,b0 + mul ab ; a1 * b0 + add a,c1 + mov c1,a + clr a + addc a,b + mov c2,a + + mov a,a0 + mov b,b1 + mul ab ; a0 * b1 + add a,c1 + mov c1,a + mov a,b + addc a,c2 + mov c2,a + clr a + rlc a + mov c3,a + + ; Byte 2 + mov a,a2 + mov b,b0 + mul ab ; a2 * b0 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + mov a,a1 + mov b,b1 + mul ab ; a1 * b1 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + mov a,a0 + mov b,b2 + mul ab ; a0 * b2 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + ; Byte 3 + mov a,a3 + mov b,b0 + mul ab ; a3 * b0 + add a,c3 + mov c3,a + + mov a,a2 + mov b,b1 + mul ab ; a2 * b1 + add a,c3 + mov c3,a + + mov a,a1 + mov b,b2 + mul ab ; a1 * b2 + add a,c3 + mov c3,a + + mov a,a0 + mov b,b3 + mul ab ; a0 * b3 + add a,c3 + + mov b,c2 + mov dph,c1 + mov dpl,c0 + ret #else // SDCC_STACK_AUTO - ; parameter a comes in a, b, dph, dpl - mov r2,b ; save parameter a - mov r3,a - - #define a0 dpl - #define a1 dph - #define a2 r2 - #define a3 r3 - - #define b0 r1 - - mov a,#-2-3 ; 1 return address 2 bytes, b 4 bytes - add a,sp ; 1 - mov r0,a ; 1 r0 points to b0 - - ; Byte 0 - mov a,a0 - mov b,@r0 ; b0 - mov b0,b ; we need b0 several times - inc r0 ; r0 points to b1 - mul ab ; a0 * b0 - mov c0,a - mov c1,b - - ; Byte 1 - mov a,a1 - mov b,b0 - mul ab ; a1 * b0 - add a,c1 - mov c1,a - clr a - addc a,b - mov c2,a - - - mov a,a0 - mov b,@r0 ; b1 - mul ab ; a0 * b1 - add a,c1 - mov c1,a - mov a,b - addc a,c2 - mov c2,a - clr a - rlc a - mov c3,a - - ; Byte 2 - mov a,a2 - mov b,b0 - mul ab ; a2 * b0 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - mov a,a1 - mov b,@r0 ; b1 - mul ab ; a1 * b1 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - mov a,a0 - inc r0 - mov b,@r0 ; b2 - mul ab ; a0 * b2 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - ; Byte 3 - mov a,a3 - mov b,b0 - mul ab ; a3 * b0 - add a,c3 - mov c3,a - - mov a,a1 - mov b,@r0 ; b2 - mul ab ; a1 * b2 - add a,c3 - mov c3,a - - mov a,a2 - dec r0 - mov b,@r0 ; b1 - mul ab ; a2 * b1 - add a,c3 - mov c3,a - - mov a,a0 - inc r0 - inc r0 - mov b,@r0 ; b3 - mul ab ; a0 * b3 - add a,c3 - - mov b,c2 - mov dph,c1 - mov dpl,c0 - - ret + ; parameter a comes in a, b, dph, dpl + mov r2,b ; save parameter a + mov r3,a + + #define a0 dpl + #define a1 dph + #define a2 r2 + #define a3 r3 + + #define b0 r1 + + mov a,#-2-3 ; 1 return address 2 bytes, b 4 bytes + add a,sp ; 1 + mov r0,a ; 1 r0 points to b0 + + ; Byte 0 + mov a,a0 + mov b,@r0 ; b0 + mov b0,b ; we need b0 several times + inc r0 ; r0 points to b1 + mul ab ; a0 * b0 + mov c0,a + mov c1,b + + ; Byte 1 + mov a,a1 + mov b,b0 + mul ab ; a1 * b0 + add a,c1 + mov c1,a + clr a + addc a,b + mov c2,a + + mov a,a0 + mov b,@r0 ; b1 + mul ab ; a0 * b1 + add a,c1 + mov c1,a + mov a,b + addc a,c2 + mov c2,a + clr a + rlc a + mov c3,a + + ; Byte 2 + mov a,a2 + mov b,b0 + mul ab ; a2 * b0 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + mov a,a1 + mov b,@r0 ; b1 + mul ab ; a1 * b1 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + mov a,a0 + inc r0 + mov b,@r0 ; b2 + mul ab ; a0 * b2 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + ; Byte 3 + mov a,a3 + mov b,b0 + mul ab ; a3 * b0 + add a,c3 + mov c3,a + + mov a,a1 + mov b,@r0 ; b2 + mul ab ; a1 * b2 + add a,c3 + mov c3,a + + mov a,a2 + dec r0 + mov b,@r0 ; b1 + mul ab ; a2 * b1 + add a,c3 + mov c3,a + + mov a,a0 + inc r0 + inc r0 + mov b,@r0 ; b3 + mul ab ; a0 * b3 + add a,c3 + + mov b,c2 + mov dph,c1 + mov dpl,c0 + + ret #endif // SDCC_STACK_AUTO - _endasm ; + __endasm; } - #elif defined(_MULLONG_ASM_LARGE) void -_mullong_dummy (void) _naked +_mullong_dummy (void) __naked { - _asm + __asm - __mullong: +__mullong: - .globl __mullong + .globl __mullong - ; the result c will be stored in r4...r7 - #define c0 r4 - #define c1 r5 - #define c2 r6 - #define c3 r7 + ; the result c will be stored in r4...r7 + #define c0 r4 + #define c1 r5 + #define c2 r6 + #define c3 r7 ; c0 a0 * b0 ; c1 a1 * b0 + a0 * b1 @@ -332,297 +329,294 @@ _mullong_dummy (void) _naked ; c3 a3 * b0 + a2 * b1 + a1 * b2 + a0 * b3 #if !defined(SDCC_PARMS_IN_BANK1) - .area XSEG (XDATA) + .area XSEG (XDATA) - __mullong_PARM_2: +__mullong_PARM_2: - .globl __mullong_PARM_2 + .globl __mullong_PARM_2 - .ds 4 + .ds 4 #endif - .area CSEG (CODE) + .area CSEG (CODE) - ; parameter a comes in a, b, dph, dpl - mov r0,dpl ; save parameter a - mov r1,dph - mov r2,b - mov r3,a + ; parameter a comes in a, b, dph, dpl + mov r0,dpl ; save parameter a + mov r1,dph + mov r2,b + mov r3,a - #define a0 r0 - #define a1 r1 - #define a2 r2 - #define a3 r3 + #define a0 r0 + #define a1 r1 + #define a2 r2 + #define a3 r3 - ; Byte 0 - mov b,a0 + ; Byte 0 + mov b,a0 #if defined(SDCC_PARMS_IN_BANK1) - mov a,b1_0 ; b0 + mov a,b1_0 ; b0 #else - mov dptr,#__mullong_PARM_2 - movx a,@dptr ; b0 + mov dptr,#__mullong_PARM_2 + movx a,@dptr ; b0 #endif - mul ab ; a0 * b0 - mov c0,a - mov c1,b + mul ab ; a0 * b0 + mov c0,a + mov c1,b - ; Byte 1 - mov b,a1 + ; Byte 1 + mov b,a1 #if defined(SDCC_PARMS_IN_BANK1) - mov a,b1_0 ; b0 + mov a,b1_0 ; b0 #else - movx a,@dptr ; b0 + movx a,@dptr ; b0 #endif - mul ab ; a1 * b0 - add a,c1 - mov c1,a - clr a - addc a,b - mov c2,a - - - mov b,a0 + mul ab ; a1 * b0 + add a,c1 + mov c1,a + clr a + addc a,b + mov c2,a + + mov b,a0 #if defined(SDCC_PARMS_IN_BANK1) - mov a,b1_1 ; b1 + mov a,b1_1 ; b1 #else - inc dptr ; b1 - movx a,@dptr + inc dptr ; b1 + movx a,@dptr #endif - mul ab ; a0 * b1 - add a,c1 - mov c1,a - mov a,b - addc a,c2 - mov c2,a - clr a - rlc a - mov c3,a - - ; Byte 2 - mov b,a1 + mul ab ; a0 * b1 + add a,c1 + mov c1,a + mov a,b + addc a,c2 + mov c2,a + clr a + rlc a + mov c3,a + + ; Byte 2 + mov b,a1 #if defined(SDCC_PARMS_IN_BANK1) - mov a,b1_1 ; b1 + mov a,b1_1 ; b1 #else - movx a,@dptr ; b1 + movx a,@dptr ; b1 #endif - mul ab ; a1 * b1 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - mov b,a0 + mul ab ; a1 * b1 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + mov b,a0 #if defined(SDCC_PARMS_IN_BANK1) - mov a,b1_2 ; b2 + mov a,b1_2 ; b2 #else - inc dptr ; b2 - movx a,@dptr + inc dptr ; b2 + movx a,@dptr #endif - mul ab ; a0 * b2 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - mov b,a2 + mul ab ; a0 * b2 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + mov b,a2 #if defined(SDCC_PARMS_IN_BANK1) - mov a,b1_0 ; b0 + mov a,b1_0 ; b0 #else - mov dptr,#__mullong_PARM_2 - movx a,@dptr ; b0 + mov dptr,#__mullong_PARM_2 + movx a,@dptr ; b0 #endif - mul ab ; a2 * b0 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - ; Byte 3 - mov b,a3 + mul ab ; a2 * b0 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + ; Byte 3 + mov b,a3 #if defined(SDCC_PARMS_IN_BANK1) - mov a,b1_0 ; b0 + mov a,b1_0 ; b0 #else - movx a,@dptr ; b0 + movx a,@dptr ; b0 #endif - mul ab ; a3 * b0 - add a,c3 - mov c3,a + mul ab ; a3 * b0 + add a,c3 + mov c3,a - mov b,a2 + mov b,a2 #if defined(SDCC_PARMS_IN_BANK1) - mov a,b1_1 ; b1 + mov a,b1_1 ; b1 #else - inc dptr ; b1 - movx a,@dptr + inc dptr ; b1 + movx a,@dptr #endif - mul ab ; a2 * b1 - add a,c3 - mov c3,a + mul ab ; a2 * b1 + add a,c3 + mov c3,a - mov b,a1 + mov b,a1 #if defined(SDCC_PARMS_IN_BANK1) - mov a,b1_2 ; b2 + mov a,b1_2 ; b2 #else - inc dptr ; b2 - movx a,@dptr + inc dptr ; b2 + movx a,@dptr #endif - mul ab ; a1 * b2 - add a,c3 - mov c3,a + mul ab ; a1 * b2 + add a,c3 + mov c3,a - mov b,a0 + mov b,a0 #if defined(SDCC_PARMS_IN_BANK1) - mov a,b1_3 ; b3 + mov a,b1_3 ; b3 #else - inc dptr ; b3 - movx a,@dptr + inc dptr ; b3 + movx a,@dptr #endif - mul ab ; a0 * b3 - add a,c3 + mul ab ; a0 * b3 + add a,c3 - mov b,c2 - mov dph,c1 - mov dpl,c0 - ret + mov b,c2 + mov dph,c1 + mov dpl,c0 + ret - _endasm ; + __endasm; } #elif defined(SDCC_USE_XSTACK) && defined(SDCC_STACK_AUTO) void -_mullong_dummy (void) _naked +_mullong_dummy (void) __naked { - _asm + __asm - __mullong: +__mullong: - .globl __mullong + .globl __mullong - ; the result c will be stored in r4...r7 - #define c0 r4 - #define c1 r5 - #define c2 r6 - #define c3 r7 + ; the result c will be stored in r4...r7 + #define c0 r4 + #define c1 r5 + #define c2 r6 + #define c3 r7 - #define a0 dpl - #define a1 dph - #define a2 r2 - #define a3 r3 + #define a0 dpl + #define a1 dph + #define a2 r2 + #define a3 r3 - #define b0 r1 + #define b0 r1 ; c0 a0 * b0 ; c1 a1 * b0 + a0 * b1 ; c2 a2 * b0 + a1 * b1 + a0 * b2 ; c3 a3 * b0 + a2 * b1 + a1 * b2 + a0 * b3 - - ; parameter a comes in a, b, dph, dpl - mov r2,b ; save parameter a - mov r3,a - - mov a,#-4 ; 1 b 4 bytes - add a,_spx ; 1 - mov r0,a ; 1 r0 points to b0 - - ; Byte 0 - movx a,@r0 ; b0 - mov b0,a ; we need b0 several times - inc r0 ; r0 points to b1 - mov b,a0 - mul ab ; a0 * b0 - mov c0,a - mov c1,b - - ; Byte 1 - mov a,a1 - mov b,b0 - mul ab ; a1 * b0 - add a,c1 - mov c1,a - clr a - addc a,b - mov c2,a - - - mov b,a0 - movx a,@r0 ; b1 - mul ab ; a0 * b1 - add a,c1 - mov c1,a - mov a,b - addc a,c2 - mov c2,a - clr a - rlc a - mov c3,a - - ; Byte 2 - mov a,a2 - mov b,b0 - mul ab ; a2 * b0 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - mov b,a1 - movx a,@r0 ; b1 - mul ab ; a1 * b1 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - mov b,a0 - inc r0 - movx a,@r0 ; b2 - mul ab ; a0 * b2 - add a,c2 - mov c2,a - mov a,b - addc a,c3 - mov c3,a - - ; Byte 3 - mov a,a3 - mov b,b0 - mul ab ; a3 * b0 - add a,c3 - mov c3,a - - mov b,a1 - movx a,@r0 ; b2 - mul ab ; a1 * b2 - add a,c3 - mov c3,a - - mov b,a2 - dec r0 - movx a,@r0 ; b1 - mul ab ; a2 * b1 - add a,c3 - mov c3,a - - mov b,a0 - inc r0 - inc r0 - movx a,@r0 ; b3 - mul ab ; a0 * b3 - add a,c3 - - mov b,c2 - mov dph,c1 - mov dpl,c0 - - ret - - _endasm ; + ; parameter a comes in a, b, dph, dpl + mov r2,b ; save parameter a + mov r3,a + + mov a,#-4 ; 1 b 4 bytes + add a,_spx ; 1 + mov r0,a ; 1 r0 points to b0 + + ; Byte 0 + movx a,@r0 ; b0 + mov b0,a ; we need b0 several times + inc r0 ; r0 points to b1 + mov b,a0 + mul ab ; a0 * b0 + mov c0,a + mov c1,b + + ; Byte 1 + mov a,a1 + mov b,b0 + mul ab ; a1 * b0 + add a,c1 + mov c1,a + clr a + addc a,b + mov c2,a + + mov b,a0 + movx a,@r0 ; b1 + mul ab ; a0 * b1 + add a,c1 + mov c1,a + mov a,b + addc a,c2 + mov c2,a + clr a + rlc a + mov c3,a + + ; Byte 2 + mov a,a2 + mov b,b0 + mul ab ; a2 * b0 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + mov b,a1 + movx a,@r0 ; b1 + mul ab ; a1 * b1 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + mov b,a0 + inc r0 + movx a,@r0 ; b2 + mul ab ; a0 * b2 + add a,c2 + mov c2,a + mov a,b + addc a,c3 + mov c3,a + + ; Byte 3 + mov a,a3 + mov b,b0 + mul ab ; a3 * b0 + add a,c3 + mov c3,a + + mov b,a1 + movx a,@r0 ; b2 + mul ab ; a1 * b2 + add a,c3 + mov c3,a + + mov b,a2 + dec r0 + movx a,@r0 ; b1 + mul ab ; a2 * b1 + add a,c3 + mov c3,a + + mov b,a0 + inc r0 + inc r0 + movx a,@r0 ; b3 + mul ab ; a0 * b3 + add a,c3 + + mov b,c2 + mov dph,c1 + mov dpl,c0 + + ret + + __endasm; } #else // _MULLONG_ASM @@ -650,13 +644,13 @@ union bil { #endif #if defined(SDCC_USE_XSTACK) || defined(SDCC_MODEL_MEDIUM) -# define bcast(x) ((union bil pdata *)&(x)) +# define bcast(x) ((union bil __pdata *)&(x)) #elif (defined(SDCC_MODEL_LARGE) || defined (SDCC_ds390) || defined (SDCC_ds400)) && !defined(SDCC_STACK_AUTO) -# define bcast(x) ((union bil xdata *)&(x)) +# define bcast(x) ((union bil __xdata *)&(x)) #elif defined(__z80) || defined(__gbz80) # define bcast(x) ((union bil *)&(x)) #else -# define bcast(x) ((union bil near *)&(x)) +# define bcast(x) ((union bil __near *)&(x)) #endif /* diff --git a/device/lib/_schar2fs.c b/device/lib/_schar2fs.c index 73066d1b..ec1d71d3 100644 --- a/device/lib/_schar2fs.c +++ b/device/lib/_schar2fs.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 // float __schar2fs (char c) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___schar2fs ___schar2fs: mov r4, dpl @@ -36,16 +36,14 @@ ___schar2fs: mov r1, a mov a, #134 ljmp slong2fs_doit - _endasm; + __endasm; } #else - /* convert signed char to float */ float __schar2fs (signed char sc) { return __slong2fs(sc); } #endif - diff --git a/device/lib/_ser.c b/device/lib/_ser.c index b06f69af..69d18330 100644 --- a/device/lib/_ser.c +++ b/device/lib/_ser.c @@ -35,15 +35,15 @@ #define NON_BLOCKING -unsigned char xdata ser_txIndexIn; -unsigned char xdata ser_txIndexOut; -unsigned char xdata ser_rxIndexIn; -unsigned char xdata ser_rxIndexOut; +unsigned char __xdata ser_txIndexIn; +unsigned char __xdata ser_txIndexOut; +unsigned char __xdata ser_rxIndexIn; +unsigned char __xdata ser_rxIndexOut; -unsigned char xdata ser_txBuffer[0x100]; -unsigned char xdata ser_rxBuffer[0x100]; +unsigned char __xdata ser_txBuffer[0x100]; +unsigned char __xdata ser_rxBuffer[0x100]; -static bit ser_txBusy; +static __bit ser_txBusy; void ser_init(void) @@ -79,7 +79,7 @@ ser_init(void) } void -ser_interrupt_handler(void) interrupt 4 using 1 +ser_interrupt_handler(void) __interrupt 4 __using 1 { ES=0; diff --git a/device/lib/_setjmp.c b/device/lib/_setjmp.c index ff1274b8..ee31b479 100644 --- a/device/lib/_setjmp.c +++ b/device/lib/_setjmp.c @@ -26,9 +26,9 @@ #if defined(SDCC_USE_XSTACK) -static void dummy (void) _naked +static void dummy (void) __naked { - _asm + __asm ;------------------------------------------------------------ ;Allocation info for local variables in function 'setjmp' @@ -73,7 +73,7 @@ _setjmp: mov a,sp lcall __gptrput inc dptr -;../../device/lib/_setjmp.c:187:*buf++ = *((unsigned char data *) SP ); +;../../device/lib/_setjmp.c:187:*buf++ = *((unsigned char __data *) SP ); ; genCast ; genPointerGet ; genNearPointerGet @@ -83,7 +83,7 @@ _setjmp: mov a,@r0 lcall __gptrput inc dptr -;../../device/lib/_setjmp.c:188:*buf = *((unsigned char data *)SP - 1); +;../../device/lib/_setjmp.c:188:*buf = *((unsigned char __data *)SP - 1); ; genCast ; genMinus ; genMinusDec @@ -146,7 +146,7 @@ _longjmp: inc dptr ; genAssign mov r5,a -;../../device/lib/_setjmp.c:197:*((unsigned char data *) lsp) = *buf++; +;../../device/lib/_setjmp.c:197:*((unsigned char __data *) lsp) = *buf++; ; genCast mov r0,a ; genPointerGet @@ -156,7 +156,7 @@ _longjmp: ; genPointerSet ; genNearPointerSet mov @r0,a -;../../device/lib/_setjmp.c:198:*((unsigned char data *) lsp - 1) = *buf; +;../../device/lib/_setjmp.c:198:*((unsigned char __data *) lsp - 1) = *buf; ; genMinus ; genMinusDec dec r0 @@ -176,14 +176,14 @@ _longjmp: ; genRet ret - _endasm; + __endasm; } #elif defined(SDCC_STACK_AUTO) -static void dummy (void) _naked +static void dummy (void) __naked { - _asm + __asm ;------------------------------------------------------------ ;Allocation info for local variables in function 'setjmp' @@ -217,7 +217,7 @@ _setjmp: mov a,sp lcall __gptrput inc dptr -;../../device/lib/_setjmp.c:127:*buf++ = *((unsigned char data *) SP ); +;../../device/lib/_setjmp.c:127:*buf++ = *((unsigned char __data *) SP ); ; genCast mov r0,sp ; genPointerGet @@ -227,7 +227,7 @@ _setjmp: ; genGenPointerSet lcall __gptrput inc dptr -;../../device/lib/_setjmp.c:128:*buf++ = *((unsigned char data *)SP - 1); +;../../device/lib/_setjmp.c:128:*buf++ = *((unsigned char __data *)SP - 1); ; genCast ; genMinus ; genMinusDec @@ -285,7 +285,7 @@ _longjmp: inc dptr ; genAssign mov r5,a -;../../device/lib/_setjmp.c:32:*((unsigned char data *) lsp) = *buf++; +;../../device/lib/_setjmp.c:32:*((unsigned char __data *) lsp) = *buf++; ; genCast mov r0,a ; genPointerGet @@ -295,7 +295,7 @@ _longjmp: ; genPointerSet ; genNearPointerSet mov @r0,a -;../../device/lib/_setjmp.c:33:*((unsigned char data *) lsp - 1) = *buf; +;../../device/lib/_setjmp.c:33:*((unsigned char __data *) lsp - 1) = *buf; ; genCast ; genMinus ; genMinusDec @@ -315,12 +315,12 @@ _longjmp: mov dpl,r3 ret - _endasm; + __endasm; } #else -//extern unsigned char data bp; +//extern unsigned char __data bp; int setjmp (jmp_buf buf) { @@ -329,8 +329,8 @@ int setjmp (jmp_buf buf) and the return address */ // *buf++ = bp; *buf++ = SP; - *buf++ = *((unsigned char data *) SP ); - *buf = *((unsigned char data *)SP - 1); + *buf++ = *((unsigned char __data *) SP ); + *buf = *((unsigned char __data *)SP - 1); return 0; } @@ -339,8 +339,8 @@ int longjmp (jmp_buf buf, int rv) unsigned char lsp; // bp = *buf++; lsp = *buf++; - *((unsigned char data *) lsp) = *buf++; - *((unsigned char data *) lsp - 1) = *buf; + *((unsigned char __data *) lsp) = *buf++; + *((unsigned char __data *) lsp - 1) = *buf; SP = lsp; return rv; } diff --git a/device/lib/_sint2fs.c b/device/lib/_sint2fs.c index eacde5d5..7458bb01 100644 --- a/device/lib/_sint2fs.c +++ b/device/lib/_sint2fs.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 // float long __sint2fs (float x) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___sint2fs ___sint2fs: mov r4, dph @@ -35,16 +35,14 @@ ___sint2fs: mov r1, #0 mov a, #142 ljmp slong2fs_doit - _endasm; + __endasm; } #else - /* convert signed int to float */ float __sint2fs (signed int si) { return __slong2fs(si); } #endif - diff --git a/device/lib/_slong2fs.c b/device/lib/_slong2fs.c index da1938d0..b19c59c2 100644 --- a/device/lib/_slong2fs.c +++ b/device/lib/_slong2fs.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 //float __slong2fs (long x) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___slong2fs ___slong2fs: mov r4, a @@ -60,12 +60,11 @@ slong2fs_doit: slong2fs_positive: lcall fs_normalize_a ljmp fs_round_and_return - _endasm; + __endasm; } #else - /* convert signed long to float */ float __slong2fs (signed long sl) { if (sl<0) @@ -75,4 +74,3 @@ float __slong2fs (signed long sl) { } #endif - diff --git a/device/lib/_spx.c b/device/lib/_spx.c index 8c4b1777..86d94d8b 100644 --- a/device/lib/_spx.c +++ b/device/lib/_spx.c @@ -23,5 +23,5 @@ what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ -data unsigned char spx ; -data unsigned char _page_no__; +__data unsigned char spx ; +__data unsigned char _page_no__; diff --git a/device/lib/_uchar2fs.c b/device/lib/_uchar2fs.c index 31af32d8..67caf153 100644 --- a/device/lib/_uchar2fs.c +++ b/device/lib/_uchar2fs.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 // float long __uchar2fs (float x) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___uchar2fs ___uchar2fs: clr a @@ -36,13 +36,11 @@ ___uchar2fs: mov r1, a mov a, #134 ljmp ulong2fs_doit - _endasm; + __endasm; } #else - - /* convert unsigned char to float */ float __uchar2fs (unsigned char uc) { return __ulong2fs(uc); diff --git a/device/lib/_uint2fs.c b/device/lib/_uint2fs.c index bf752b02..75a04ebc 100644 --- a/device/lib/_uint2fs.c +++ b/device/lib/_uint2fs.c @@ -23,9 +23,9 @@ #ifdef FLOAT_ASM_MCS51 // float long __uint2fs (float x) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___uint2fs ___uint2fs: clr a @@ -35,17 +35,14 @@ ___uint2fs: mov r1, a mov a, #142 ljmp ulong2fs_doit - _endasm; + __endasm; } #else - - /* convert unsigned int to float */ float __uint2fs (unsigned int ui) { return __ulong2fs(ui); } #endif - diff --git a/device/lib/_ulong2fs.c b/device/lib/_ulong2fs.c index 1a4d6b58..32a8192d 100644 --- a/device/lib/_ulong2fs.c +++ b/device/lib/_ulong2fs.c @@ -24,9 +24,9 @@ #ifdef FLOAT_ASM_MCS51 // float long __ulong2fs (float x) -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl ___ulong2fs ___ulong2fs: mov r4, a @@ -41,13 +41,11 @@ long2fs_doit: mov exp_a, a lcall fs_normalize_a ljmp fs_round_and_return - _endasm; + __endasm; } #else - - /* ** libgcc support for software floating point. ** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved. @@ -110,4 +108,3 @@ float __ulong2fs (unsigned long a ) } #endif - diff --git a/device/lib/asincosf.c b/device/lib/asincosf.c index 8bfdb790..4e4c60a8 100644 --- a/device/lib/asincosf.c +++ b/device/lib/asincosf.c @@ -34,7 +34,7 @@ #define Q(g) ((Q2*g+Q1)*g+Q0) #ifdef SDCC_mcs51 - #define myconst code + #define myconst __code #else #define myconst const #endif diff --git a/device/lib/atanf.c b/device/lib/atanf.c index 135c3f90..f254ae20 100644 --- a/device/lib/atanf.c +++ b/device/lib/atanf.c @@ -37,7 +37,7 @@ #define K3 1.7320508076 /* sqrt(3) */ #ifdef SDCC_mcs51 - #define myconst code + #define myconst __code #else #define myconst const #endif @@ -73,4 +73,3 @@ float atanf(const float x) _FLOAT_FUNC_REENTRANT if(x<0.0) r=-r; return r; } - diff --git a/device/lib/calloc.c b/device/lib/calloc.c index 343b4f62..c30000c1 100644 --- a/device/lib/calloc.c +++ b/device/lib/calloc.c @@ -25,12 +25,12 @@ //-------------------------------------------------------------------- //calloc function implementation for embedded system //Non-ANSI keywords are C51 specific. -// xdata - variable in external memory (just RAM) +// __xdata - variable in external memory (just RAM) //-------------------------------------------------------------------- #if _SDCC_MALLOC_TYPE_MLH -#define xdata +#define __xdata typedef struct _MEMHEADER MEMHEADER; @@ -59,9 +59,9 @@ MEMHEADER #endif -void xdata * calloc (size_t nmemb, size_t size) +void __xdata * calloc (size_t nmemb, size_t size) { - register void xdata * ptr; + register void __xdata * ptr; ptr = malloc(nmemb * size); if (ptr) diff --git a/device/lib/ds390/tinibios.c b/device/lib/ds390/tinibios.c index b9c89688..1f6363d8 100755 --- a/device/lib/ds390/tinibios.c +++ b/device/lib/ds390/tinibios.c @@ -55,7 +55,7 @@ unsigned char _sdcc_external_startup(void) // select default cpu speed CpuSpeed(CPU_SPEED); - _asm + __asm ; save the 24-bit return address pop ar2; msb pop ar1 @@ -73,39 +73,39 @@ unsigned char _sdcc_external_startup(void) push ar0; lsb push ar1 push ar2; msb - _endasm; + __endasm; // Copy the Interrupt Vector Table (128 bytes) from 0x10000 to 0x100000 // This isn't needed for older bootloaders than the 0515, but it won't harm - _asm - push dpx - push dph - push dpl - push dps - push b - push acc - mov dps,#0x00 ; make sure no autoincrement in progress - mov dptr,#0x10000 ; from - inc dps ; switch to alternate dptr - mov dptr,#0x100000 ; to - mov b,#0x80 ; count + __asm + push dpx + push dph + push dpl + push dps + push b + push acc + mov dps,#0x00 ; make sure no autoincrement in progress + mov dptr,#0x10000 ; from + inc dps ; switch to alternate dptr + mov dptr,#0x100000 ; to + mov b,#0x80 ; count _Startup390CopyIVT: - inc dps - movx a,@dptr - inc dptr - inc dps - movx @dptr,a - inc dptr - djnz b,_Startup390CopyIVT - - pop acc - pop b - pop dps - pop dpl - pop dph - pop dpx - _endasm; + inc dps + movx a,@dptr + inc dptr + inc dps + movx @dptr,a + inc dptr + djnz b,_Startup390CopyIVT + + pop acc + pop b + pop dps + pop dpl + pop dph + pop dpx + __endasm; // global interrupt enable, all masks cleared // let the Gods be with us :) @@ -132,12 +132,12 @@ _Startup390CopyIVT: unsigned int cpuSpeed; -void CpuSpeed(unsigned int speed) { - - #if 0 +void CpuSpeed(unsigned int speed) +{ +#if 0 while (0 && (EXIF&0x04)) ; // cpu operates from ring buffer - #endif +#endif PMR = 0x80; // div4, CTM off, multiplier 2x switch (speed) { @@ -181,7 +181,7 @@ static volatile int receive0BufferTail=0; // no buffering for transmit static volatile char transmit0IsBusy=0; -static data unsigned char serial0Buffered; +static __data unsigned char serial0Buffered; /* Initialize serial0. @@ -191,8 +191,8 @@ static data unsigned char serial0Buffered; If buffered!=0, characters received are buffered using an interrupt */ -void Serial0Init (unsigned long baud, unsigned char buffered) { - +void Serial0Init (unsigned long baud, unsigned char buffered) +{ if (baud==0) { ES0=0; // disable interrupts SCON0 &= 0xef; // disable receiver @@ -217,7 +217,7 @@ void Serial0Init (unsigned long baud, unsigned char buffered) { serial0Buffered=buffered; - if (buffered) { + if (buffered) { RI_0=TI_0=0; // clear "pending" interrupts ES0 = 1; // enable serial channel 0 interrupt } else { @@ -226,7 +226,8 @@ void Serial0Init (unsigned long baud, unsigned char buffered) { } } -void Serial0Baud(unsigned long baud) { +void Serial0Baud(unsigned long baud) +{ TR2=0; // stop timer baud=-((long)OSCILLATOR/(32*baud)); TL2=RCAP2L= baud; @@ -235,7 +236,8 @@ void Serial0Baud(unsigned long baud) { TR2=1; // start timer } -void Serial0IrqHandler (void) interrupt 4 { +void Serial0IrqHandler (void) __interrupt 4 +{ if (RI_0) { receive0Buffer[receive0BufferHead]=SBUF0; receive0BufferHead=(receive0BufferHead+1)&(S0RBS-1); @@ -251,7 +253,8 @@ void Serial0IrqHandler (void) interrupt 4 { } } -char Serial0CharArrived(void) { +char Serial0CharArrived(void) +{ if (serial0Buffered) { if (receive0BufferHead!=receive0BufferTail) return receive0Buffer[receive0BufferTail]; @@ -296,13 +299,15 @@ char Serial0GetChar (void) return c; } -void Serial0SendBreak() { +void Serial0SendBreak() +{ P3 &= ~0x02; ClockMilliSecondsDelay(2); P3 |= 0x02; } -void Serial0Flush() { +void Serial0Flush() +{ ES0=0; // disable interrupts receive0BufferHead=receive0BufferTail=0; RI_0=0; @@ -328,7 +333,7 @@ static volatile int receive1BufferTail=0; // no buffering for transmit static volatile char transmit1IsBusy=0; -static data unsigned char serial1Buffered; +static __data unsigned char serial1Buffered; /* Initialize serial1. @@ -338,8 +343,8 @@ static data unsigned char serial1Buffered; If buffered!=0, characters received are buffered using an interrupt */ -void Serial1Init (unsigned long baud, unsigned char buffered) { - +void Serial1Init (unsigned long baud, unsigned char buffered) +{ if (baud==0) { ES1=0; // disable interrupt SCON1 &= 0xef; // disable receiver @@ -372,7 +377,8 @@ void Serial1Init (unsigned long baud, unsigned char buffered) { } } -void Serial1Baud(unsigned long baud) { +void Serial1Baud(unsigned long baud) +{ TR1=0; // stop timer baud=-((long)OSCILLATOR/(32*baud)); TL1=TH1 = baud; @@ -380,7 +386,8 @@ void Serial1Baud(unsigned long baud) { TR1=1; // start timer } -void Serial1IrqHandler (void) interrupt 7 { +void Serial1IrqHandler (void) __interrupt 7 +{ if (RI_1) { receive1Buffer[receive1BufferHead]=SBUF1; receive1BufferHead=(receive1BufferHead+1)&(S1RBS-1); @@ -394,7 +401,8 @@ void Serial1IrqHandler (void) interrupt 7 { } } -char Serial1CharArrived(void) { +char Serial1CharArrived(void) +{ if (serial1Buffered) { if (receive1BufferHead!=receive1BufferTail) return receive1Buffer[receive1BufferTail]; @@ -439,13 +447,15 @@ char Serial1GetChar (void) return c; } -void Serial1SendBreak() { +void Serial1SendBreak() +{ P5 &= ~0x08; ClockMilliSecondsDelay(2); P5 |= 0x08; } -void Serial1Flush() { +void Serial1Flush() +{ ES1=0; // disable interrupts receive1BufferHead=receive1BufferTail=0; RI_1=0; @@ -460,10 +470,11 @@ void Serial1Flush() { // now let's go for the clock stuff // these REALLY need to be in data space for the irq routine! -static data unsigned long milliSeconds=0; -static data unsigned int timer0ReloadValue; +static __data unsigned long milliSeconds=0; +static __data unsigned int timer0ReloadValue; -void ClockInit() { +void ClockInit() +{ unsigned long timerReloadValue=OSCILLATOR/1000; switch (cpuSpeed) { @@ -489,16 +500,17 @@ void ClockInit() { // This needs to be SUPER fast. What we really want is: #if 0 -void junk_ClockIrqHandler (void) interrupt 10 { +void junk_ClockIrqHandler (void) __interrupt 10 +{ TL0=timer0ReloadValue&0xff; TH0=timer0ReloadValue>>8; milliSeconds++; } #else // but look at the code, and the pushes and pops, so: -void ClockIrqHandler (void) interrupt 1 _naked +void ClockIrqHandler (void) __interrupt 1 __naked { - _asm + __asm push acc push psw mov _TL0,_timer0ReloadValue @@ -511,16 +523,17 @@ void ClockIrqHandler (void) interrupt 1 _naked inc _milliSeconds+2 cjne a,_milliSeconds+2,_ClockIrqHandlerDone inc _milliSeconds+3 - _ClockIrqHandlerDone: + _ClockIrqHandlerDone: pop psw pop acc reti - _endasm; + __endasm; } #endif // we can't just use milliSeconds -unsigned long ClockTicks(void) { +unsigned long ClockTicks(void) +{ unsigned long ms; ET0=0; ms=milliSeconds; @@ -528,7 +541,8 @@ unsigned long ClockTicks(void) { return ms; } -void ClockMilliSecondsDelay(unsigned long delay) { +void ClockMilliSecondsDelay(unsigned long delay) +{ long ms=ClockTicks()+delay; while (ms>ClockTicks()) @@ -536,38 +550,38 @@ void ClockMilliSecondsDelay(unsigned long delay) { } // stolen from Kevin Vigor, works only for TINI at default speed -void ClockMicroSecondsDelay(unsigned int delay) { - delay; /* shut compiler up. */ +void ClockMicroSecondsDelay(unsigned int delay) +{ + delay; /* shut compiler up. */ - _asm + __asm - ; delay is in dpl/dph - mov r0, dpl - mov r1, dph - - mov a, r0 - orl a, r1 ; quick out for zero case. - jz _usDelayDone + ; delay is in dpl/dph + mov r0, dpl + mov r1, dph + + mov a, r0 + orl a, r1 ; quick out for zero case. + jz _usDelayDone - inc r1 - cjne r0, #0, _usDelayLoop - dec r1 + inc r1 + cjne r0, #0, _usDelayLoop + dec r1 - _usDelayLoop: - nop - nop - nop - nop - nop - nop - nop ; 7 nops - djnz r0, _usDelayLoop ; 3 cycles x 1 = 3 cycles - ; 10 cycles per iter + _usDelayLoop: + nop + nop + nop + nop + nop + nop + nop ; 7 nops + djnz r0, _usDelayLoop ; 3 cycles x 1 = 3 cycles + ; 10 cycles per iter ; we want 9.216, but more is better - ; than less. - djnz r1, _usDelayLoop -_usDelayDone: + ; than less. + djnz r1, _usDelayLoop + _usDelayDone: - _endasm; - + __endasm; } diff --git a/device/lib/ds400/tinibios.c b/device/lib/ds400/tinibios.c index 1c059cf1..5c2f55d6 100755 --- a/device/lib/ds400/tinibios.c +++ b/device/lib/ds400/tinibios.c @@ -37,7 +37,7 @@ unsigned char _sdcc_external_startup(void) PSW = 0; - _asm + __asm ; save the 24-bit return address pop ar2; msb pop ar1 @@ -51,7 +51,7 @@ unsigned char _sdcc_external_startup(void) push ar0; lsb push ar1 push ar2; msb - _endasm; + __endasm; // Stub: call rom_init here, then fixup IVT. // @@ -75,7 +75,7 @@ static volatile int receive0BufferTail=0; // no buffering for transmit static volatile char transmit0IsBusy=0; -static data unsigned char serial0Buffered; +static __data unsigned char serial0Buffered; /* Initialize serial0. @@ -88,8 +88,8 @@ static data unsigned char serial0Buffered; #define TIMER_RELOAD (65536 - ((OSCILLATOR) / (32 * SERIAL_0_BAUD))) -void Serial0Init (unsigned long baud, unsigned char buffered) { - +void Serial0Init (unsigned long baud, unsigned char buffered) +{ ES0 = 0; // disable serial channel 0 interrupt #if 0 @@ -129,7 +129,8 @@ void Serial0SwitchToBuffered(void) IE |= 0x80; } -void Serial0IrqHandler (void) interrupt 4 { +void Serial0IrqHandler (void) __interrupt 4 +{ if (RI_0) { receive0Buffer[receive0BufferHead]=SBUF0; receive0BufferHead=(receive0BufferHead+1)&(S0RBS-1); @@ -145,7 +146,8 @@ void Serial0IrqHandler (void) interrupt 4 { } } -char Serial0CharArrived(void) { +char Serial0CharArrived(void) +{ if (serial0Buffered) { if (receive0BufferHead!=receive0BufferTail) return receive0Buffer[receive0BufferTail]; @@ -190,13 +192,15 @@ char Serial0GetChar (void) return c; } -void Serial0SendBreak() { +void Serial0SendBreak() +{ P3 &= ~0x02; ClockMilliSecondsDelay(2); P3 |= 0x02; } -void Serial0Flush() { +void Serial0Flush() +{ ES0=0; // disable interrupts receive0BufferHead=receive0BufferTail=0; RI_0=0; @@ -214,16 +218,19 @@ void Serial0Flush() { // for now, this timer runs too fast by about 20%. We need an implementation of // task_settickreload to fix this. -void ClockInit() { +void ClockInit() +{ // nada, all done by DSS_rom_init } // we can't just use milliSeconds -unsigned long ClockTicks(void) { +unsigned long ClockTicks(void) +{ return task_gettimemillis_long(); } -void ClockMilliSecondsDelay(unsigned long delay) { +void ClockMilliSecondsDelay(unsigned long delay) +{ unsigned long ms = task_gettimemillis_long() + delay; while (ms > task_gettimemillis_long()) @@ -234,36 +241,36 @@ void ClockMilliSecondsDelay(unsigned long delay) { // fact that the linker defined symbol (s_XISEG) isn't directly accessible // from C due to the lack of a leading underscore, and I'm too lazy to hack // the linker. -static void xdata *_xisegStart(void) _naked +static void __xdata *_xisegStart(void) __naked { -_asm + _asm mov dptr, #(s_XISEG) ret -_endasm; + _endasm; } // Return the length of the XI_SEG. Really just a workaround for the // fact that the linker defined symbol (l_XISEG) isn't directly accessible // from C due to the lack of a leading underscore, and I'm too lazy to hack // the linker. -static unsigned _xisegLen(void) _naked +static unsigned _xisegLen(void) __naked { -_asm + __asm mov dptr, #(l_XISEG) ret -_endasm; + __endasm; } // Returns the address of the first byte available for heap memory, // i.e. the first byte following the XI_SEG. -static void xdata *_firstHeapByte(void) +static void __xdata *_firstHeapByte(void) { - unsigned char xdata *start; + unsigned char __xdata *start; - start = (unsigned char xdata *) _xisegStart(); + start = (unsigned char __xdata *) _xisegStart(); start += _xisegLen(); - return (void xdata *)start; + return (void __xdata *)start; } // TINIm400 specific startup. @@ -271,11 +278,10 @@ static void xdata *_firstHeapByte(void) // The last addressible byte of the CE0 area. #define CE0_END 0xfffff -unsigned char romInit(unsigned char noisy, - char speed) +unsigned char romInit(unsigned char noisy, char speed) { - void xdata *heapStart; - void xdata *heapEnd; + void __xdata *heapStart; + void __xdata *heapEnd; unsigned long heapLen; unsigned char rc; @@ -303,7 +309,7 @@ unsigned char romInit(unsigned char noisy, } heapStart = _firstHeapByte(); - heapEnd = (void xdata *)CE0_END; + heapEnd = (void __xdata *)CE0_END; rc = init_rom(heapStart, heapEnd); @@ -334,7 +340,7 @@ unsigned char romInit(unsigned char noisy, // Install an interrupt handler. void installInterrupt(void (*isrPtr)(void), unsigned char offset) { - unsigned char xdata * vectPtr = (unsigned char xdata *) offset; + unsigned char __xdata * vectPtr = (unsigned char __xdata *) offset; unsigned long isr = (unsigned long)isrPtr; *vectPtr++ = 0x02; diff --git a/device/lib/expf.c b/device/lib/expf.c index 7328100a..a1355e8b 100644 --- a/device/lib/expf.c +++ b/device/lib/expf.c @@ -33,15 +33,15 @@ #include // TODO: share with other temps -static bit sign_bit; -static data unsigned char expf_y[4]; -static data unsigned char n; +static __bit sign_bit; +static __data unsigned char expf_y[4]; +static __data unsigned char n; float expf(float x) { x; - _asm + __asm mov c, acc.7 mov _sign_bit, c // remember sign clr acc.7 // and make input positive @@ -234,15 +234,13 @@ exp_cordic_skip: dec sp expf_done: clr acc.7 // Result is always positive! - _endasm; + __endasm; #pragma less_pedantic } - - -static void dummy1(void) _naked +static void dummy1(void) __naked { - _asm + __asm .globl fs_lshift_a expf_scale_and_add: push ar0 @@ -270,12 +268,12 @@ expf_scale_and_add: dec sp dec sp ret - _endasm; + __endasm; } -static void dummy(void) _naked +static void dummy(void) __naked { - _asm + __asm .globl fs_lshift_a fs_lshift_a: jz fs_lshift_done @@ -299,14 +297,11 @@ fs_lshift_loop: pop ar0 fs_lshift_done: ret - _endasm; + __endasm; } - - #else // not MATH_ASM_MCS51 - #define P0 0.2499999995E+0 #define P1 0.4160288626E-2 #define Q0 0.5000000000E+0 @@ -369,4 +364,3 @@ float expf(const float x) } #endif - diff --git a/device/lib/free.c b/device/lib/free.c index b592e4d6..37fd4e8d 100644 --- a/device/lib/free.c +++ b/device/lib/free.c @@ -22,7 +22,7 @@ #include #if defined(SDCC_STACK_AUTO) || defined(SDCC_z80) || defined(SDCC_gbz80) - #define CRITICAL critical + #define CRITICAL __critical #else #define CRITICAL #endif @@ -98,7 +98,7 @@ free (void *p) //-------------------------------------------------------------------- //malloc and free functions implementation for embedded system //Non-ANSI keywords are C51 specific. - // xdata - variable in external memory (just RAM) + // __xdata - variable in external memory (just RAM) //-------------------------------------------------------------------- #define MEMHEADER struct MAH// Memory Allocation Header @@ -113,19 +113,19 @@ free (void *p) #define HEADER_SIZE sizeof(MEMHEADER) //Static here means: can be accessed from this module only - extern MEMHEADER xdata * _sdcc_first_memheader; + extern MEMHEADER __xdata * _sdcc_first_memheader; - MEMHEADER xdata * _sdcc_prev_memheader; + MEMHEADER __xdata * _sdcc_prev_memheader; // apart from finding the header // this function also finds it's predecessor - MEMHEADER xdata * _sdcc_find_memheader(void xdata * p) + MEMHEADER __xdata * _sdcc_find_memheader(void __xdata * p) { - register MEMHEADER xdata * pthis; - register MEMHEADER xdata * cur_header; + register MEMHEADER __xdata * pthis; + register MEMHEADER __xdata * cur_header; if (!p) return NULL; - pthis = (MEMHEADER xdata *) p; + pthis = (MEMHEADER __xdata *) p; pthis -= 1; //to start of header cur_header = _sdcc_first_memheader; _sdcc_prev_memheader = NULL; @@ -139,7 +139,7 @@ free (void *p) void free (void * p) { - register MEMHEADER xdata * pthis; + register MEMHEADER __xdata * pthis; CRITICAL { diff --git a/device/lib/hc08/_mulint.c b/device/lib/hc08/_mulint.c index 1e8cf506..c2011ff9 100644 --- a/device/lib/hc08/_mulint.c +++ b/device/lib/hc08/_mulint.c @@ -41,7 +41,7 @@ _mulint (int a, int b) a,b; /* reference to make compiler happy */ #if !defined(SDCC_STACK_AUTO) - _asm + __asm ais #-2 psha pshx @@ -66,9 +66,9 @@ _mulint (int a, int b) ais #2 pulx pula - _endasm; + __endasm; #else - _asm + __asm ais #-2 psha pshx @@ -93,7 +93,7 @@ _mulint (int a, int b) ais #2 pulx pula - _endasm; + __endasm; #endif } #pragma restore @@ -109,11 +109,11 @@ 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 __xdata *x; + union uu __xdata *y; union uu t; - x = (union uu xdata *)&a; - y = (union uu xdata *)&b; + x = (union uu __xdata *)&a; + y = (union uu __xdata *)&b; #else register union uu *x; register union uu *y; diff --git a/device/lib/logf.c b/device/lib/logf.c index 31907a07..d499f8c1 100644 --- a/device/lib/logf.c +++ b/device/lib/logf.c @@ -32,12 +32,12 @@ #include // TODO: share with other temps -static data unsigned char logf_tmp[4]; +static __data unsigned char logf_tmp[4]; float logf(float x) { x; - _asm + __asm // extract the two input, placing it into: // sign exponent mantiassa @@ -183,16 +183,12 @@ logf_exp_scale: lcall fs_normalize_a // now just add log(fractional) +/- log(2) * abs(exp - 126) ljmp fsadd_direct_entry - _endasm; + __endasm; #pragma less_pedantic } - #else // not MATH_ASM_MCS51 - - - /*Constants for 24 bits or less (8 decimal digits)*/ #define A0 -0.5527074855E+0 #define B0 -0.6632718214E+1 @@ -239,4 +235,3 @@ float logf(const float x) _FLOAT_FUNC_REENTRANT } #endif - diff --git a/device/lib/malloc.c b/device/lib/malloc.c index 33f8fedd..e52fa7fa 100644 --- a/device/lib/malloc.c +++ b/device/lib/malloc.c @@ -22,7 +22,7 @@ #include #if defined(SDCC_STACK_AUTO) || defined(SDCC_z80) || defined(SDCC_gbz80) - #define CRITICAL critical + #define CRITICAL __critical #else #define CRITICAL #endif @@ -136,7 +136,7 @@ malloc (unsigned int size) //-------------------------------------------------------------------- //malloc and free functions implementation for embedded system //Non-ANSI keywords are C51 specific. - // xdata - variable in external memory (just RAM) + // __xdata - variable in external memory (just RAM) //-------------------------------------------------------------------- #define MEMHEADER struct MAH// Memory Allocation Header @@ -150,14 +150,14 @@ malloc (unsigned int size) #define HEADER_SIZE sizeof(MEMHEADER) - MEMHEADER xdata * _sdcc_first_memheader = NULL; + MEMHEADER __xdata * _sdcc_first_memheader = NULL; - extern xdata char _sdcc_heap[]; + extern __xdata char _sdcc_heap[]; extern const unsigned int _sdcc_heap_size; static void init_dynamic_memory(void) { - char xdata * heap = (char xdata *)_sdcc_heap; + char __xdata * heap = (char __xdata *)_sdcc_heap; unsigned int size = _sdcc_heap_size; if ( !heap ) //Reserved memory starts at 0x0000 but that's NULL... @@ -165,21 +165,21 @@ malloc (unsigned int size) heap++; size--; } - _sdcc_first_memheader = (MEMHEADER xdata * ) heap; + _sdcc_first_memheader = (MEMHEADER __xdata * ) heap; //Reserve a mem for last header - _sdcc_first_memheader->next = (MEMHEADER xdata * )(heap + size - sizeof(MEMHEADER xdata *)); - _sdcc_first_memheader->next->next = (MEMHEADER xdata * ) NULL; //And mark it as last + _sdcc_first_memheader->next = (MEMHEADER __xdata * )(heap + size - sizeof(MEMHEADER __xdata *)); + _sdcc_first_memheader->next->next = (MEMHEADER __xdata * ) NULL; //And mark it as last _sdcc_first_memheader->len = 0; //Empty and ready. } - void xdata * malloc (unsigned int size) + void __xdata * malloc (unsigned int size) { - register MEMHEADER xdata * current_header; - register MEMHEADER xdata * new_header; - register void xdata * ret; + register MEMHEADER __xdata * current_header; + register MEMHEADER __xdata * new_header; + register void __xdata * ret; if (size>(0xFFFF-HEADER_SIZE)) - return (void xdata *) NULL; //To prevent overflow in next line + return (void __xdata *) NULL; //To prevent overflow in next line size += HEADER_SIZE; //We need a memory for header too if (!_sdcc_first_memheader) @@ -208,7 +208,7 @@ malloc (unsigned int size) current_header = current_header->next; //else try next if (!current_header->next) { //if end_of_list reached - ret = (void xdata *) NULL; + ret = (void __xdata *) NULL; break; } } @@ -220,7 +220,7 @@ malloc (unsigned int size) } else { //else create new header at the begin of spare - new_header = (MEMHEADER xdata * )((char xdata *)current_header + current_header->len); + new_header = (MEMHEADER __xdata * )((char __xdata *)current_header + current_header->len); new_header->next = current_header->next; //and plug it into the chain current_header->next = new_header; new_header->len = size; //mark as used diff --git a/device/lib/printf_fast.c b/device/lib/printf_fast.c index 63a4308e..028ee2b1 100644 --- a/device/lib/printf_fast.c +++ b/device/lib/printf_fast.c @@ -91,33 +91,32 @@ // Warning: using static/global variables makes these functions NON-reentrant! // reentrant keyword is only used for parameter passing method -static bit long_flag, short_flag, print_zero_flag, negative_flag; +static __bit long_flag, short_flag, print_zero_flag, negative_flag; #ifdef FIELD_WIDTH -static bit field_width_flag; -static bit leading_zero_flag; -static data unsigned char field_width; +static __bit field_width_flag; +static __bit leading_zero_flag; +static __data unsigned char field_width; #endif #ifdef FLOAT #define SDCC_FLOAT_LIB #include -static bit continue_float; +static __bit continue_float; #ifndef FLOAT_FIXED4 -static data unsigned char frac_field_width; -static data unsigned char float_frac_bcd[4]; +static __data unsigned char frac_field_width; +static __data unsigned char float_frac_bcd[4]; // TODO: can float_frac_bcd be overlaid with temps used by trig functions #endif #endif #ifndef FAST_INTEGER #ifdef LONG -static data unsigned int i2bcd_tmp; // slow 32 int conversion needs temp space +static __data unsigned int i2bcd_tmp; // slow 32 int conversion needs temp space #endif #endif - #ifndef PRINTF_FAST #define PRINTF_FAST printf_fast #endif @@ -134,11 +133,11 @@ static data unsigned int i2bcd_tmp; // slow 32 int conversion needs temp space #else // defines are compatible with printf_fast -void PRINTF_FAST(code char *fmt, ...) reentrant +void PRINTF_FAST(__code char *fmt, ...) __reentrant { fmt; /* suppress unreferenced variable warning */ - _asm + __asm printf_begin: mov a, _bp // r0 will point to va_args (stack) @@ -149,7 +148,6 @@ printf_begin: mov dpl, @r0 // dptr has address of fmt dec r0 - printf_main_loop: clr a movc a, @a+dptr // get next byte of fmt string @@ -203,7 +201,6 @@ printf_nondigit1: printf_nondigit2: add a, #48 - printf_format_l: //cjne a, #'l', printf_format_h cjne a, #108, printf_format_h @@ -276,10 +273,6 @@ printf_eot: ljmp printf_end - - - - /* print a string... just grab each byte with __gptrget */ /* the user much pass a 24 bit generic pointer */ @@ -323,12 +316,6 @@ printf_str_done: ljmp printf_main_loop - - - - - - /* printing in hex is easy because sdcc pushes the LSB first */ printf_hex: @@ -446,7 +433,6 @@ printf_uint_zero: ljmp printf_main_loop - printf_uint_begin: push dpl push dph @@ -616,12 +602,6 @@ printf_uint8a: ljmp printf_main_loop - - - - - - #ifdef FLOAT #ifdef FLOAT_FIXED4 // Print a float the easy way. First, extract the integer part and @@ -750,8 +730,6 @@ print_float_frac_skip: #else // not FLOAT_FIXED4 - - print_float: // Print a float the not-as-easy way, with a configurable number of // fractional digits (up to 8) and proper round-off (up to 7 digits). @@ -1009,7 +987,6 @@ print_float_done: ljmp printf_main_loop - // acc=1 for tenths, acc=2 for hundredths, etc get_float_frac_digit: dec a @@ -1025,9 +1002,6 @@ get_float_frac_digit_done: anl a, #15 ret - - - #endif // end of normal FLOAT code (not FLOAT_FIXED4) @@ -1077,17 +1051,6 @@ printf_get_float_2: #endif // FLOAT - - - - - - - - - - - /* read an integer into r1/r2/r3/r4, and msb into r5 */ printf_get_int: mov a, @r0 @@ -1112,9 +1075,6 @@ printf_get_done: ret - - - #ifdef FAST_INTEGER /* convert binary number in r4/r3/r2/r1 into bcd packed number @@ -1405,17 +1365,6 @@ printf_i2bcd_add_skip: #endif // not FAST_INTEGER - - - - - - - - - - - #ifdef FIELD_WIDTH printf_space_loop: //mov a, #' ' @@ -1432,10 +1381,6 @@ printf_space: ret #endif - - - - /* print a hex digit, either upper 4 bit (msn) or lower 4 bits (lsn) */ printf_phex_msn: @@ -1481,7 +1426,7 @@ printf_zero: ljmp printf_putchar printf_end: - _endasm; + __endasm; } @@ -1504,24 +1449,24 @@ printf_end: */ #if 0 -static code unsigned char int2bcd_0[] = { +static __code unsigned char int2bcd_0[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15}; -static code unsigned char int2bcd_1[] = { +static __code unsigned char int2bcd_1[] = { 0x00, 0x16, 0x32, 0x48, 0x64, 0x80, 0x96, 0x12, 0x28, 0x44, 0x60, 0x76, 0x92, 0x08, 0x24, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02}; #endif -static code unsigned char int2bcd_2[] = { +static __code unsigned char int2bcd_2[] = { 0x00, 0x56, 0x12, 0x68, 0x24, 0x80, 0x36, 0x92, 0x48, 0x04, 0x60, 0x16, 0x72, 0x28, 0x84, 0x40, 0x00, 0x02, 0x05, 0x07, 0x10, 0x12, 0x15, 0x17, 0x20, 0x23, 0x25, 0x28, 0x30, 0x33, 0x35, 0x38}; -static code unsigned char int2bcd_3[] = { +static __code unsigned char int2bcd_3[] = { 0x00, 0x96, 0x92, 0x88, 0x84, 0x80, 0x76, 0x72, 0x68, 0x64, 0x60, 0x56, 0x52, 0x48, 0x44, 0x40, 0x00, 0x40, 0x81, 0x22, 0x63, 0x04, 0x45, 0x86, @@ -1530,7 +1475,7 @@ static code unsigned char int2bcd_3[] = { 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x06}; #ifdef LONG -static code unsigned char int2bcd_4[] = { +static __code unsigned char int2bcd_4[] = { 0x00, 0x36, 0x72, 0x08, 0x44, 0x80, 0x16, 0x52, 0x88, 0x24, 0x60, 0x96, 0x32, 0x68, 0x04, 0x40, 0x00, 0x55, 0x10, 0x66, 0x21, 0x76, 0x32, 0x87, @@ -1538,7 +1483,7 @@ static code unsigned char int2bcd_4[] = { 0x00, 0x06, 0x13, 0x19, 0x26, 0x32, 0x39, 0x45, 0x52, 0x58, 0x65, 0x72, 0x78, 0x85, 0x91, 0x98}; -static code unsigned char int2bcd_5[] = { +static __code unsigned char int2bcd_5[] = { 0x00, 0x76, 0x52, 0x28, 0x04, 0x80, 0x56, 0x32, 0x08, 0x84, 0x60, 0x36, 0x12, 0x88, 0x64, 0x40, 0x00, 0x85, 0x71, 0x57, 0x43, 0x28, 0x14, 0x00, @@ -1548,7 +1493,7 @@ static code unsigned char int2bcd_5[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15}; -static code unsigned char int2bcd_6[] = { +static __code unsigned char int2bcd_6[] = { 0x00, 0x16, 0x32, 0x48, 0x64, 0x80, 0x96, 0x12, 0x28, 0x44, 0x60, 0x76, 0x92, 0x08, 0x24, 0x40, 0x00, 0x72, 0x44, 0x16, 0x88, 0x60, 0x32, 0x05, @@ -1560,7 +1505,7 @@ static code unsigned char int2bcd_6[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02}; -static code unsigned char int2bcd_7[] = { +static __code unsigned char int2bcd_7[] = { 0x00, 0x56, 0x12, 0x68, 0x24, 0x80, 0x36, 0x92, 0x48, 0x04, 0x60, 0x16, 0x72, 0x28, 0x84, 0x40, 0x00, 0x54, 0x09, 0x63, 0x18, 0x72, 0x27, 0x81, @@ -1577,7 +1522,7 @@ static code unsigned char int2bcd_7[] = { /* * #! /usr/bin/perl - * print "code unsigned char int2bcd[] = {\n"; + * print "__code unsigned char int2bcd[] = {\n"; * for ($i=0, $n=1; $i<32; $i++, $n*=2) { * $r = sprintf "%010u", $n; * $r =~ /([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])/; @@ -1585,7 +1530,7 @@ static code unsigned char int2bcd_7[] = { * print ',' if $i < 31; * printf "\t\t// %10u\n", $n; * } - * print "}\ncode unsigned char int2bcd[] = {\n"; + * print "}\n__code unsigned char int2bcd[] = {\n"; * for ($i=0, $n=1; $i<16; $i++, $n*=2) { * $r = sprintf "%06u", $n; * $r =~ /([0-9][0-9])([0-9][0-9])([0-9][0-9])/; @@ -1597,7 +1542,7 @@ static code unsigned char int2bcd_7[] = { */ #ifdef LONG -static code unsigned char int2bcd[] = { +static __code unsigned char int2bcd[] = { 0x01, 0x00, 0x00, 0x00, 0x00, // 1 0x02, 0x00, 0x00, 0x00, 0x00, // 2 0x04, 0x00, 0x00, 0x00, 0x00, // 4 @@ -1632,7 +1577,7 @@ static code unsigned char int2bcd[] = { 0x48, 0x36, 0x48, 0x47, 0x21 // 2147483648 }; #else // not LONG -static code unsigned char int2bcd[] = { +static __code unsigned char int2bcd[] = { 0x01, 0x00, 0x00, // 1 0x02, 0x00, 0x00, // 2 0x04, 0x00, 0x00, // 4 @@ -1655,8 +1600,6 @@ static code unsigned char int2bcd[] = { #endif // not FAST_INTEGER - - #ifdef FLOAT #ifndef FLOAT_FIXED4 @@ -1673,7 +1616,7 @@ static code unsigned char int2bcd[] = { * } */ -static code unsigned char frac2bcd[] = { +static __code unsigned char frac2bcd[] = { 0x00, 0x00, 0x00, 0x50, // 0.500000000000000 0.50000000 0x00, 0x00, 0x00, 0x25, // 0.250000000000000 0.75000000 0x00, 0x00, 0x50, 0x12, // 0.125000000000000 0.87500000 @@ -1715,7 +1658,7 @@ static code unsigned char frac2bcd[] = { // 100.0 - 999.99 2 100.0 = 0x42C80000 42C8 // 1000 - 9999.9 1 1000 = 0x447A0000 447A // 10000+ 0 10000 = 0x461C4000 461C -static code unsigned int float_range_table[] = { +static __code unsigned int float_range_table[] = { 65536 - 0x3A83, 65536 - 0x3C23, 65536 - 0x3DCC, @@ -1741,7 +1684,7 @@ static code unsigned int float_range_table[] = { * } */ -static code unsigned char frac2bcd[] = { +static __code unsigned char frac2bcd[] = { 0x00, 0x50, // 0.500000000000000 0.5000 0x00, 0x25, // 0.250000000000000 0.7500 0x50, 0x12, // 0.125000000000000 0.8750 @@ -1763,4 +1706,3 @@ static code unsigned char frac2bcd[] = { #endif // defines compatible with printf_fast - diff --git a/device/lib/printf_tiny.c b/device/lib/printf_tiny.c index 3a889f40..0ebded46 100644 --- a/device/lib/printf_tiny.c +++ b/device/lib/printf_tiny.c @@ -69,11 +69,11 @@ -void printf_tiny(code char *fmt, ...) reentrant +void printf_tiny(__code char *fmt, ...) __reentrant { fmt; /* suppress unreferenced variable warning */ - _asm + __asm printf_begin: mov a, _bp // r0 will point to va_args (stack) @@ -285,9 +285,8 @@ printf_ret: printf_end: - _endasm; + __endasm; } #endif // defines compatible with printf_tiny - diff --git a/device/lib/printfl.c b/device/lib/printfl.c index 70d4235a..a5d22111 100644 --- a/device/lib/printfl.c +++ b/device/lib/printfl.c @@ -49,9 +49,9 @@ #endif static __data char radix ; -static bit long_flag = 0; -static bit string_flag =0; -static bit char_flag = 0; +static __bit long_flag = 0; +static __bit string_flag =0; +static __bit char_flag = 0; static char * __data str ; static __data long val; @@ -68,7 +68,7 @@ static __data long val; #if NICE_LIFO_IMPLEMENTATION_BUT_NOT_PORTABLE static __data volatile char ch; -static bit sign; +static __bit sign; static void pval(void) { @@ -96,13 +96,13 @@ static void pval(void) # if 1 if(radix != 16) ch = (lval % radix) + '0'; else ch = "0123456789ABCDEF"[(unsigned char)lval & 0x0f]; - _asm push _ch _endasm; + __asm push _ch __endasm; lval /= radix; # else // This only looks more efficient, but isn't. see the .map ch = (lval % radix) + '0'; if (ch>'9') ch+=7; - _asm push _ch _endasm; + __asm push _ch __endasm; lval /= radix; # endif } @@ -110,17 +110,17 @@ static void pval(void) if (sign) { ch = '-'; - _asm push _ch _endasm; + __asm push _ch __endasm; } while (sp != SP) { - _asm pop _ch _endasm; + __asm pop _ch __endasm; putchar(ch); } } #endif -void printf_small (char * fmt, ... ) reentrant +void printf_small (char * fmt, ... ) __reentrant { va_list ap ; diff --git a/device/lib/realloc.c b/device/lib/realloc.c index 4fad06e9..357063b5 100644 --- a/device/lib/realloc.c +++ b/device/lib/realloc.c @@ -23,7 +23,7 @@ #include #if defined(SDCC_STACK_AUTO) || defined(SDCC_z80) || defined(SDCC_gbz80) - #define CRITICAL critical + #define CRITICAL __critical #else #define CRITICAL #endif @@ -31,12 +31,12 @@ //-------------------------------------------------------------------- //realloc function implementation for embedded system //Non-ANSI keywords are C51 specific. -// xdata - variable in external memory (just RAM) +// __xdata - variable in external memory (just RAM) //-------------------------------------------------------------------- #if _SDCC_MALLOC_TYPE_MLH -#define xdata +#define __xdata typedef struct _MEMHEADER MEMHEADER; @@ -67,17 +67,17 @@ MEMHEADER #endif -extern MEMHEADER xdata * _sdcc_prev_memheader; +extern MEMHEADER __xdata * _sdcc_prev_memheader; // apart from finding the header // this function also finds it's predecessor -extern MEMHEADER xdata * _sdcc_find_memheader(void xdata * p); +extern MEMHEADER __xdata * _sdcc_find_memheader(void __xdata * p); -void xdata * realloc (void * p, size_t size) +void __xdata * realloc (void * p, size_t size) { - register MEMHEADER xdata * pthis; - register MEMHEADER xdata * pnew; - register void xdata * ret; + register MEMHEADER __xdata * pthis; + register MEMHEADER __xdata * pnew; + register void __xdata * ret; CRITICAL { @@ -86,7 +86,7 @@ void xdata * realloc (void * p, size_t size) { if (size > (0xFFFF-HEADER_SIZE)) { - ret = (void xdata *) NULL; //To prevent overflow in next line + ret = (void __xdata *) NULL; //To prevent overflow in next line } else { @@ -104,7 +104,7 @@ void xdata * realloc (void * p, size_t size) ((unsigned int)_sdcc_prev_memheader) - _sdcc_prev_memheader->len) >= size)) { - pnew = (MEMHEADER xdata * )((char xdata *)_sdcc_prev_memheader + _sdcc_prev_memheader->len); + pnew = (MEMHEADER __xdata * )((char __xdata *)_sdcc_prev_memheader + _sdcc_prev_memheader->len); _sdcc_prev_memheader->next = pnew; #if _SDCC_MALLOC_TYPE_MLH diff --git a/device/lib/ser_ir.c b/device/lib/ser_ir.c index 15b162a8..2523d743 100644 --- a/device/lib/ser_ir.c +++ b/device/lib/ser_ir.c @@ -41,9 +41,9 @@ #define RBUFLEN 8 /* You might want to specify idata, pdata or xdata for the buffers */ -static unsigned char pdata rbuf[RBUFLEN], xbuf[XBUFLEN]; +static unsigned char __pdata rbuf[RBUFLEN], xbuf[XBUFLEN]; static unsigned char rcnt, xcnt, rpos, xpos; -static bit busy; +static __bit busy; void ser_init (void) { @@ -58,7 +58,7 @@ void ser_init (void) ES = 1; } -void ser_handler (void) interrupt 4 +void ser_handler (void) __interrupt 4 { if (RI) { RI = 0; diff --git a/device/lib/serial.c b/device/lib/serial.c index bb48557e..58ddba15 100644 --- a/device/lib/serial.c +++ b/device/lib/serial.c @@ -12,14 +12,14 @@ #include "8052.h" -static unsigned char xdata stx_index_in, srx_index_in, stx_index_out, srx_index_out; -static unsigned char xdata stx_buffer[0x100]; -static unsigned char xdata srx_buffer[0x100]; +static unsigned char __xdata stx_index_in, srx_index_in, stx_index_out, srx_index_out; +static unsigned char __xdata stx_buffer[0x100]; +static unsigned char __xdata srx_buffer[0x100]; -static bit work_flag_byte_arrived; -static bit work_flag_buffer_transfered; -static bit tx_serial_buffer_empty; -static bit rx_serial_buffer_empty; +static __bit work_flag_byte_arrived; +static __bit work_flag_buffer_transfered; +static __bit tx_serial_buffer_empty; +static __bit rx_serial_buffer_empty; void serial_init(void) @@ -41,7 +41,7 @@ void serial_init(void) ES=1; } -void serial_interrupt_handler(void) interrupt 4 using 1 +void serial_interrupt_handler(void) __interrupt 4 __using 1 { ES=0; if ( RI ) diff --git a/src/SDCCast.c b/src/SDCCast.c index d29c998c..88e0fa18 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -2189,8 +2189,7 @@ getResultTypeFromType (sym_link *type) } if (IS_CHAR (type)) return RESULT_TYPE_CHAR; - if ( IS_INT (type) - && !IS_LONG (type)) + if (IS_INT (type) && !IS_LONG (type)) return RESULT_TYPE_INT; return RESULT_TYPE_OTHER; } @@ -6371,12 +6370,10 @@ createFunction (symbol * name, ast * body) ex = newNode (FUNCTION, ex, body); ex->values.args = FUNC_ARGS(name->type); ex->decorated=1; - if (options.dump_tree) PA(ex); + if (options.dump_tree) + PA(ex); if (fatalError) - { - werror (E_FUNC_NO_CODE, name->name); - goto skipall; - } + goto skipall; /* Do not generate code for inline functions unless extern also */ if (FUNC_ISINLINE (name->type) && !IS_EXTERN (fetype)) @@ -6389,10 +6386,7 @@ createFunction (symbol * name, ast * body) name->generated = 1; if (fatalError) - { - werror (E_FUNC_NO_CODE, name->name); - goto skipall; - } + goto skipall; eBBlockFromiCode (piCode); diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 1a165bbe..09ed8fd4 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -4239,17 +4239,33 @@ ast2iCode (ast * tree,int lvl) case GETHBIT: { operand *op = geniCodeUnary (geniCodeRValue (left, FALSE), tree->opval.op); - setOperandType (op, UCHARTYPE); + if (!IS_BIT (operandType (op))) + setOperandType (op, UCHARTYPE); return op; } case GETABIT: + { + operand *op = geniCodeBinary (geniCodeRValue (left, FALSE), + geniCodeRValue (right, FALSE), + tree->opval.op); + if (!IS_BIT (operandType (op))) + setOperandType (op, UCHARTYPE); + return op; + } case GETBYTE: + { + operand *op = geniCodeBinary (geniCodeRValue (left, FALSE), + geniCodeRValue (right, FALSE), + tree->opval.op); + setOperandType (op, UCHARTYPE); + return op; + } case GETWORD: { operand *op = geniCodeBinary (geniCodeRValue (left, FALSE), geniCodeRValue (right, FALSE), tree->opval.op); - setOperandType (op, (tree->opval.op == GETWORD) ? UINTTYPE : UCHARTYPE); + setOperandType (op, UINTTYPE); return op; } case AND_OP: @@ -4263,7 +4279,7 @@ ast2iCode (ast * tree,int lvl) case NE_OP: /* different compilers (even different gccs) evaluate the two calls in a different order. to get the same - result on all machines we've to specify a clear sequence. + result on all machines we have to specify a clear sequence. return geniCodeLogic (geniCodeRValue (left, FALSE), geniCodeRValue (right, FALSE), tree->opval.op); diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 324d8963..c7c17602 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -953,7 +953,7 @@ aopOp (operand * op, iCode * ic, bool result) /* if the type is a conditional */ if (sym->regType == REG_CND) { - aop = op->aop = sym->aop = newAsmop (AOP_CRY); + sym->aop = op->aop = aop = newAsmop (AOP_CRY); aop->size = 0; return; } @@ -975,7 +975,7 @@ aopOp (operand * op, iCode * ic, bool result) if (sym->accuse) { int i; - aop = op->aop = sym->aop = newAsmop (AOP_ACC); + sym->aop = op->aop = aop = newAsmop (AOP_ACC); aop->size = getSize (sym->type); for (i = 0; i < 2; i++) aop->aopu.aop_str[i] = accUse[i]; @@ -986,7 +986,7 @@ aopOp (operand * op, iCode * ic, bool result) { unsigned i; - aop = op->aop = sym->aop = newAsmop (AOP_STR); + sym->aop = op->aop = aop = newAsmop (AOP_STR); aop->size = getSize (sym->type); for (i = 0; i < fReturnSizeMCS51; i++) aop->aopu.aop_str[i] = fReturn[i]; @@ -1838,7 +1838,8 @@ outBitC (operand * result) /* if the result is bit */ if (AOP_TYPE (result) == AOP_CRY) { - aopPut (result, "c", 0); + if (!OP_SYMBOL (result)->ruonly) + aopPut (result, "c", 0); } else { @@ -4038,7 +4039,8 @@ genRet (iCode * ic) if (IS_BIT(_G.currentFunc->etype)) { - toCarry (IC_LEFT (ic)); + if (!OP_SYMBOL (IC_LEFT (ic))->ruonly) + toCarry (IC_LEFT (ic)); } else { diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index e1ea0943..54af801e 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -1910,6 +1910,8 @@ regTypeNum (eBBlock *ebbs) { if (IS_AGGREGATE (sym->type) || sym->isptr) sym->type = aggrToPtr (sym->type, FALSE); + else if (IS_BIT(sym->type)) + sym->regType = REG_CND; continue; } @@ -2472,8 +2474,8 @@ packRegsForOneuse (iCode * ic, operand * op, eBBlock * ebp) if (ic->op == SEND && ic->argreg != 1) return NULL; - /* this routine will mark the a symbol as used in one - instruction use only && if the defintion is local + /* this routine will mark the symbol as used in one + instruction use only && if the definition is local (ie. within the basic block) && has only one definition && that definition is either a return value from a function or does not contain any variables in @@ -2481,7 +2483,7 @@ packRegsForOneuse (iCode * ic, operand * op, eBBlock * ebp) if (bitVectnBitsOn (OP_USES (op)) > 1) return NULL; - /* if it has only one defintion */ + /* if it has only one definition */ if (bitVectnBitsOn (OP_DEFS (op)) > 1) return NULL; /* has more than one definition */ @@ -2559,11 +2561,10 @@ packRegsForOneuse (iCode * ic, operand * op, eBBlock * ebp) sic = dic; - /* also make sure the intervenening instructions - don't have any thing in far space */ + /* also make sure the intervening instructions + don't have anything in far space */ for (dic = dic->next; dic && dic != ic && sic != ic; dic = dic->next) { - /* if there is an intervening function call then no */ if (dic->op == CALL || dic->op == PCALL) return NULL; @@ -3150,7 +3151,6 @@ packRegisters (eBBlock ** ebpp, int blockno) getSize (aggrToPtr (operandType (IC_LEFT (ic)), FALSE)) > 1) packRegsForOneuse (ic, IC_LEFT (ic), ebp); - /* if this is a cast for intergral promotion then check if it's the only use of the definition of the operand being casted/ if yes then replace @@ -3185,7 +3185,6 @@ packRegisters (eBBlock ** ebpp, int blockno) } else { - /* if the type from and type to are the same then if this is the only use then packit */ if (compareType (operandType (IC_RIGHT (ic)), diff --git a/support/regression/ports/mcs51-xstack-auto/spec.mk b/support/regression/ports/mcs51-xstack-auto/spec.mk index d8d6d732..16fcc2df 100644 --- a/support/regression/ports/mcs51-xstack-auto/spec.mk +++ b/support/regression/ports/mcs51-xstack-auto/spec.mk @@ -8,8 +8,8 @@ LIBSRCDIR = $(top_srcdir)/device/lib LIBBUILDDIR = $(top_builddir)/device/lib LIBDIR = $(PORT_CASES_DIR)/lib -LIBSDCCFLAGS+=--std-sdcc99 --stack-auto --xstack -SDCCFLAGS +=$(LIBSDCCFLAGS) +LIBSDCCFLAGS+= --stack-auto --xstack --std-c99 +SDCCFLAGS += --stack-auto --xstack --std-sdcc99 # use C sources from mcs51 $(PORT_CASES_DIR)/%$(OBJEXT): $(PORTS_DIR)/mcs51/%.c diff --git a/support/regression/tests/libmullong.c b/support/regression/tests/libmullong.c index 4ab6ee75..fc26af4b 100644 --- a/support/regression/tests/libmullong.c +++ b/support/regression/tests/libmullong.c @@ -11,7 +11,7 @@ # define mullong(a,b) mullong_wrapper(a,b) # if defined(type_c) && !defined(WORDS_BIGENDIAN) # define _SDCC_NO_ASM_LIB_FUNCS 1 -# define near +# define __near # define long int # include "device/lib/_mullong.c" # endif