+2007-04-08 Maarten Brock <sourceforge.brock AT dse.nl>
+
+ * 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 <sourceforge.brock AT dse.nl>
* device/include/math.h,
#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__ */
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
what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
-data unsigned char bp ;
+__data unsigned char bp ;
{
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
}
#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_
#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
#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
#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
#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
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;
}
#endif
-
#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
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;
}
#endif
-
#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
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;
#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
-
#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
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
-
#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
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.
}
#endif
-
-
#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
lcall fs_normalize_a
ljmp fs_round_and_return
- _endasm;
+ __endasm;
}
#else
** uunet!motown!pipeline!phw
*/
-
union float_long
{
float f;
}
#endif
-
#ifdef FLOAT_ASM_MCS51
-static void dummy(void) _naked
+static void dummy(void) __naked
{
- _asm
+ __asm
.globl fs_compare_uint32
fs_compare_uint32:
b_not_neg_zero:
ret
- _endasm;
+ __endasm;
}
#endif
-
#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:
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.
/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
-
union float_long
{
float f;
}
#endif
-
#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
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.
/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
-
union float_long
{
float f;
}
#endif
-
#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:
mov exp_a, a
mov r4, b
ret
- _endasm;
+ __endasm;
}
#endif
-
-
#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:
mov exp_b, a
mov r7, b
ret
- _endasm;
+ __endasm;
}
#endif
-
-
-
-
#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
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.
/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
-
union float_long
{
float f;
#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
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.
/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
-
union float_long
{
float f;
}
#endif
-
#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:
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.
/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
-
union float_long
{
float f;
}
#endif
-
#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
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.
/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
-
union float_long
{
float f;
}
#endif
-
#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
djnz r0, 00005$
00006$:
ret
- _endasm;
+ __endasm;
}
#endif
-
#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:
mov a, #0x7F
ret
- _endasm;
+ __endasm;
}
#endif
-
#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$
djnz r0, 00005$
00020$:
ret
- _endasm;
+ __endasm;
}
#endif
-
#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
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.
/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
-
union float_long
{
float f;
}
#endif
-
#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
// 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
xch a, r5
mov r2, a
ret
- _endasm;
+ __endasm;
}
#endif
-
* 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
;
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
;
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
;
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
;
ret ; 1
;===
;40 bytes
- _endasm ;
+ __endasm;
}
#endif
/* This is the new version */
gptr; /* hush the compiler */
- _asm
+ __asm
;
; depending on the pointer type acc. to SDCCsymt.h
;
mov r0,dph ; restore r0
mov dph,#0 ; restore dph
00006$:
- _endasm ;
+ __endasm;
}
{
gptr; /* hush the compiler */
- _asm
+ __asm
;
; depending on the pointer type acc. to SDCCsymt.h
;
00005$:
pop ar0
00006$:
- _endasm ;
+ __endasm;
}
#endif
#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
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
pop acc
xch a,r0
ret
- _endasm ;
+ __endasm;
}
#endif
#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
;
;===
;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
;
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
;
;===
;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
;
ret ; 1
;===
;46 bytes
-_endasm;
+ __endasm;
}
#endif
void
_gptrputWord ()
{
- _asm
+ __asm
;
; depending on the pointer type acc. to SDCCsymt.h
;
mov r0,dph ; restore r0
mov dph,#0 ; restore dph
00016$:
- _endasm;
+ __endasm;
}
#else
void
_gptrputWord ()
{
- _asm
+ __asm
push acc
;
; depending on the pointer type acc. to SDCCsymt.h
inc dptr
pop ar0
00016$:
- _endasm;
+ __endasm;
}
#endif
void _fs_cordic_rshift_r765_unsigned(void)
{
- _asm
+ __asm
add a, #248
jnc 00003$
mov b, r5
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
#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_
#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
#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
#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
(char)(lsb_a*msb_b)<<8
*/
- _asm
+ __asm
mov r2,dph ; msb_a
mov r3,dpl ; lsb_a
mov dph,a
mov dpl,r0
ret
- _endasm;
+ __endasm;
}
#pragma restore
#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)
#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
_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;
#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
#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
; 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
#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
/*
#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
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
-
#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)
}
void
-ser_interrupt_handler(void) interrupt 4 using 1
+ser_interrupt_handler(void) __interrupt 4 __using 1
{
ES=0;
#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'
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
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
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
; 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
; 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'
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
; 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
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
; 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
mov dpl,r3
ret
- _endasm;
+ __endasm;
}
#else
-//extern unsigned char data bp;
+//extern unsigned char __data bp;
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;
}
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;
}
#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
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
-
#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
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)
}
#endif
-
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__;
#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
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);
#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
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
-
#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
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.
}
#endif
-
#define Q(g) ((Q2*g+Q1)*g+Q0)
#ifdef SDCC_mcs51
- #define myconst code
+ #define myconst __code
#else
#define myconst const
#endif
#define K3 1.7320508076 /* sqrt(3) */
#ifdef SDCC_mcs51
- #define myconst code
+ #define myconst __code
#else
#define myconst const
#endif
if(x<0.0) r=-r;
return r;
}
-
//--------------------------------------------------------------------
//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;
#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)
// select default cpu speed
CpuSpeed(CPU_SPEED);
- _asm
+ __asm
; save the 24-bit return address
pop ar2; msb
pop ar1
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 :)
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)
{
// no buffering for transmit
static volatile char transmit0IsBusy=0;
-static data unsigned char serial0Buffered;
+static __data unsigned char serial0Buffered;
/* Initialize serial0.
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
serial0Buffered=buffered;
- if (buffered) {
+ if (buffered) {
RI_0=TI_0=0; // clear "pending" interrupts
ES0 = 1; // enable serial channel 0 interrupt
} else {
}
}
-void Serial0Baud(unsigned long baud) {
+void Serial0Baud(unsigned long baud)
+{
TR2=0; // stop timer
baud=-((long)OSCILLATOR/(32*baud));
TL2=RCAP2L= 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);
}
}
-char Serial0CharArrived(void) {
+char Serial0CharArrived(void)
+{
if (serial0Buffered) {
if (receive0BufferHead!=receive0BufferTail)
return receive0Buffer[receive0BufferTail];
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;
// no buffering for transmit
static volatile char transmit1IsBusy=0;
-static data unsigned char serial1Buffered;
+static __data unsigned char serial1Buffered;
/* Initialize serial1.
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
}
}
-void Serial1Baud(unsigned long baud) {
+void Serial1Baud(unsigned long baud)
+{
TR1=0; // stop timer
baud=-((long)OSCILLATOR/(32*baud));
TL1=TH1 = 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);
}
}
-char Serial1CharArrived(void) {
+char Serial1CharArrived(void)
+{
if (serial1Buffered) {
if (receive1BufferHead!=receive1BufferTail)
return receive1Buffer[receive1BufferTail];
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;
// 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) {
// 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
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;
return ms;
}
-void ClockMilliSecondsDelay(unsigned long delay) {
+void ClockMilliSecondsDelay(unsigned long delay)
+{
long ms=ClockTicks()+delay;
while (ms>ClockTicks())
}
// 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;
}
PSW = 0;
- _asm
+ __asm
; save the 24-bit return address
pop ar2; msb
pop ar1
push ar0; lsb
push ar1
push ar2; msb
- _endasm;
+ __endasm;
// Stub: call rom_init here, then fixup IVT.
//
// no buffering for transmit
static volatile char transmit0IsBusy=0;
-static data unsigned char serial0Buffered;
+static __data unsigned char serial0Buffered;
/* Initialize serial0.
#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
IE |= 0x80;
}
-void Serial0IrqHandler (void) interrupt 4 {
+void Serial0IrqHandler (void) __interrupt 4
+{
if (RI_0) {
receive0Buffer[receive0BufferHead]=SBUF0;
receive0BufferHead=(receive0BufferHead+1)&(S0RBS-1);
}
}
-char Serial0CharArrived(void) {
+char Serial0CharArrived(void)
+{
if (serial0Buffered) {
if (receive0BufferHead!=receive0BufferTail)
return receive0Buffer[receive0BufferTail];
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;
// 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())
// 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.
// 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;
}
heapStart = _firstHeapByte();
- heapEnd = (void xdata *)CE0_END;
+ heapEnd = (void __xdata *)CE0_END;
rc = init_rom(heapStart, heapEnd);
// 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;
#include <float.h>
// 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
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
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
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
}
#endif
-
#include <malloc.h>
#if defined(SDCC_STACK_AUTO) || defined(SDCC_z80) || defined(SDCC_gbz80)
- #define CRITICAL critical
+ #define CRITICAL __critical
#else
#define CRITICAL
#endif
//--------------------------------------------------------------------
//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
#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;
void free (void * p)
{
- register MEMHEADER xdata * pthis;
+ register MEMHEADER __xdata * pthis;
CRITICAL
{
a,b; /* reference to make compiler happy */
#if !defined(SDCC_STACK_AUTO)
- _asm
+ __asm
ais #-2
psha
pshx
ais #2
pulx
pula
- _endasm;
+ __endasm;
#else
- _asm
+ __asm
ais #-2
psha
pshx
ais #2
pulx
pula
- _endasm;
+ __endasm;
#endif
}
#pragma restore
_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;
#include <float.h>
// 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
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
}
#endif
-
#include <malloc.h>
#if defined(SDCC_STACK_AUTO) || defined(SDCC_z80) || defined(SDCC_gbz80)
- #define CRITICAL critical
+ #define CRITICAL __critical
#else
#define CRITICAL
#endif
//--------------------------------------------------------------------
//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
#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...
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)
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;
}
}
}
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
// 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 <float.h>
-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
#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)
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
printf_nondigit2:
add a, #48
-
printf_format_l:
//cjne a, #'l', printf_format_h
cjne a, #108, printf_format_h
ljmp printf_end
-
-
-
-
/* print a string... just grab each byte with __gptrget */
/* the user much pass a 24 bit generic pointer */
ljmp printf_main_loop
-
-
-
-
-
-
/* printing in hex is easy because sdcc pushes the LSB first */
printf_hex:
ljmp printf_main_loop
-
printf_uint_begin:
push dpl
push dph
ljmp printf_main_loop
-
-
-
-
-
-
#ifdef FLOAT
#ifdef FLOAT_FIXED4
// Print a float the easy way. First, extract the integer part and
#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).
ljmp printf_main_loop
-
// acc=1 for tenths, acc=2 for hundredths, etc
get_float_frac_digit:
dec a
anl a, #15
ret
-
-
-
#endif // end of normal FLOAT code (not FLOAT_FIXED4)
#endif // FLOAT
-
-
-
-
-
-
-
-
-
-
-
/* read an integer into r1/r2/r3/r4, and msb into r5 */
printf_get_int:
mov a, @r0
ret
-
-
-
#ifdef FAST_INTEGER
/* convert binary number in r4/r3/r2/r1 into bcd packed number
#endif // not FAST_INTEGER
-
-
-
-
-
-
-
-
-
-
-
#ifdef FIELD_WIDTH
printf_space_loop:
//mov a, #' '
ret
#endif
-
-
-
-
/* print a hex digit, either upper 4 bit (msn) or lower 4 bits (lsn) */
printf_phex_msn:
ljmp printf_putchar
printf_end:
- _endasm;
+ __endasm;
}
*/
#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,
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,
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,
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,
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,
/*
* #! /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])/;
* 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])/;
*/
#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
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
#endif // not FAST_INTEGER
-
-
#ifdef FLOAT
#ifndef FLOAT_FIXED4
* }
*/
-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
// 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,
* }
*/
-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
#endif // defines compatible with printf_fast
-
-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)
printf_end:
- _endasm;
+ __endasm;
}
#endif // defines compatible with printf_tiny
-
#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;
#if NICE_LIFO_IMPLEMENTATION_BUT_NOT_PORTABLE
static __data volatile char ch;
-static bit sign;
+static __bit sign;
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
}
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 ;
#include <string.h>
#if defined(SDCC_STACK_AUTO) || defined(SDCC_z80) || defined(SDCC_gbz80)
- #define CRITICAL critical
+ #define CRITICAL __critical
#else
#define CRITICAL
#endif
//--------------------------------------------------------------------
//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;
#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
{
{
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
{
((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
#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)
{
ES = 1;
}
-void ser_handler (void) interrupt 4
+void ser_handler (void) __interrupt 4
{
if (RI) {
RI = 0;
#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)
ES=1;
}
-void serial_interrupt_handler(void) interrupt 4 using 1
+void serial_interrupt_handler(void) __interrupt 4 __using 1
{
ES=0;
if ( RI )
}
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;
}
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))
name->generated = 1;
if (fatalError)
- {
- werror (E_FUNC_NO_CODE, name->name);
- goto skipall;
- }
+ goto skipall;
eBBlockFromiCode (piCode);
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:
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);
/* 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;
}
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];
{
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];
/* 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
{
if (IS_BIT(_G.currentFunc->etype))
{
- toCarry (IC_LEFT (ic));
+ if (!OP_SYMBOL (IC_LEFT (ic))->ruonly)
+ toCarry (IC_LEFT (ic));
}
else
{
{
if (IS_AGGREGATE (sym->type) || sym->isptr)
sym->type = aggrToPtr (sym->type, FALSE);
+ else if (IS_BIT(sym->type))
+ sym->regType = REG_CND;
continue;
}
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
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 */
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;
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
}
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)),
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
# 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