From 09f8f154e4e1b559fbd075da8dd3b7efcd69161a Mon Sep 17 00:00:00 2001 From: epetrich Date: Tue, 16 Sep 2003 08:12:15 +0000 Subject: [PATCH] * src/mcs51/gen.c (genFunction, genEndFunction), * src/ds390/gen.c (genFunction, genEndFunction): Moved save and restore of EA so that stack offsets to parameters are correct when using both critical and reentrant/stack-auto. * src/z80/gen.c (aopOp): removed erroneous assertion about sloc size (can be triggered in error if sloc is shared between different sized objects) * device/include/float.h: fixed macros to explicitly use unsigned long where needed git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2892 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 12 ++++++++++++ device/include/float.h | 8 ++++---- src/ds390/gen.c | 33 ++++++++++++++------------------- src/mcs51/gen.c | 35 ++++++++++++++--------------------- src/z80/gen.c | 1 - 5 files changed, 44 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95d26821..1dd4cf08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2003-09-16 Erik Petrich + + * src/mcs51/gen.c (genFunction, genEndFunction), + * src/ds390/gen.c (genFunction, genEndFunction): Moved save + and restore of EA so that stack offsets to parameters are + correct when using both critical and reentrant/stack-auto. + * src/z80/gen.c (aopOp): removed erroneous assertion about sloc + size (can be triggered in error if sloc is shared between + different sized objects) + * device/include/float.h: fixed macros to explicitly use + unsigned long where needed + 2003-09-15 Bernhard Held Feature req. 799831: added code to allow nesting of critical functions diff --git a/device/include/float.h b/device/include/float.h index 5870fdb8..c1d3c26b 100644 --- a/device/include/float.h +++ b/device/include/float.h @@ -41,12 +41,12 @@ /* the following deal with IEEE single-precision numbers */ #define EXCESS 126 #define SIGNBIT ((unsigned long)0x80000000) -#define HIDDEN (unsigned long)(1 << 23) -#define SIGN(fp) ((fp >> (8*sizeof(fp)-1)) & 1) -#define EXP(fp) (((fp) >> 23) & (unsigned int) 0x00FF) +#define HIDDEN (unsigned long)(1ul << 23) +#define SIGN(fp) (((unsigned long)(fp) >> (8*sizeof(fp)-1)) & 1) +#define EXP(fp) (((unsigned long)(fp) >> 23) & (unsigned int) 0x00FF) #define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN) #define NORM 0xff000000 -#define PACK(s,e,m) ((s) | ((e) << 23) | (m)) +#define PACK(s,e,m) ((s) | ((unsigned long)(e) << 23) | (m)) float __uchar2fs (unsigned char); float __schar2fs (signed char); diff --git a/src/ds390/gen.c b/src/ds390/gen.c index c8cb2895..83ceb8bc 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -2897,13 +2897,6 @@ genFunction (iCode * ic) if (options.stack_probe) emitcode ("lcall","__stack_probe"); - /* if critical function then turn interrupts off */ - if (IFFUNC_ISCRITICAL (ftype)) - { - emitcode ("mov", "c,ea"); - emitcode ("push", "psw"); /* save old ea via c in psw */ - emitcode ("clr", "ea"); - } /* here we need to generate the equates for the register bank if required */ @@ -3182,6 +3175,14 @@ genFunction (iCode * ic) emitcode ("add", "a,#!constbyte", ((char) sym->xstack & 0xff)); emitcode ("mov", "_spx,a"); } + + /* if critical function then turn interrupts off */ + if (IFFUNC_ISCRITICAL (ftype)) + { + emitcode ("mov", "c,ea"); + emitcode ("push", "psw"); /* save old ea via c in psw */ + emitcode ("clr", "ea"); + } } @@ -3201,6 +3202,12 @@ genEndFunction (iCode * ic) return; } + if (IFFUNC_ISCRITICAL (sym->type)) + { + emitcode ("pop", "psw"); /* restore ea via c in psw */ + emitcode ("mov", "ea,c"); + } + if ((IFFUNC_ISREENT (sym->type) || options.stackAuto) && (sym->stack || FUNC_HASSTACKPARM(sym->type))) { @@ -3345,12 +3352,6 @@ genEndFunction (iCode * ic) if (!inExcludeList ("acc")) emitcode ("pop", "acc"); - if (IFFUNC_ISCRITICAL (sym->type)) - { - emitcode ("pop", "psw"); /* restore ea via c in psw */ - emitcode ("mov", "ea,c"); - } - /* if debug then send end of function */ if (options.debug && currFunc) { _G.debugLine = 1; @@ -3368,12 +3369,6 @@ genEndFunction (iCode * ic) } else { - if (IFFUNC_ISCRITICAL (sym->type)) - { - emitcode ("pop", "psw"); /* restore ea via c in psw */ - emitcode ("mov", "ea,c"); - } - if (IFFUNC_CALLEESAVES(sym->type)) { int i; diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index cb33e3ef..b7193055 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -2291,14 +2291,6 @@ genFunction (iCode * ic) return; } - /* if critical function then turn interrupts off */ - if (IFFUNC_ISCRITICAL (ftype)) - { - emitcode ("mov", "c,ea"); - emitcode ("push", "psw"); /* save old ea via c in psw */ - emitcode ("clr", "ea"); - } - /* here we need to generate the equates for the register bank if required */ if (FUNC_REGBANK (ftype) != rbank) @@ -2575,7 +2567,14 @@ genFunction (iCode * ic) emitcode ("add", "a,#0x%02x", ((char) sym->xstack & 0xff)); emitcode ("mov", "_spx,a"); } - + + /* if critical function then turn interrupts off */ + if (IFFUNC_ISCRITICAL (ftype)) + { + emitcode ("mov", "c,ea"); + emitcode ("push", "psw"); /* save old ea via c in psw */ + emitcode ("clr", "ea"); + } } /*-----------------------------------------------------------------*/ @@ -2591,6 +2590,12 @@ genEndFunction (iCode * ic) emitcode(";", "naked function: no epilogue."); return; } + + if (IFFUNC_ISCRITICAL (sym->type)) + { + emitcode ("pop", "psw"); /* restore ea via c in psw */ + emitcode ("mov", "ea,c"); + } if (IFFUNC_ISREENT (sym->type) || options.stackAuto) { @@ -2715,12 +2720,6 @@ genEndFunction (iCode * ic) if (!inExcludeList ("acc")) emitcode ("pop", "acc"); - if (IFFUNC_ISCRITICAL (sym->type)) - { - emitcode ("pop", "psw"); /* restore ea via c in psw */ - emitcode ("mov", "ea,c"); - } - /* if debug then send end of function */ if (options.debug && currFunc) { @@ -2739,12 +2738,6 @@ genEndFunction (iCode * ic) } else { - if (IFFUNC_ISCRITICAL (sym->type)) - { - emitcode ("pop", "psw"); /* restore ea via c in psw */ - emitcode ("mov", "ea,c"); - } - if (IFFUNC_CALLEESAVES(sym->type)) { int i; diff --git a/src/z80/gen.c b/src/z80/gen.c index 0ab78841..f8229961 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -1039,7 +1039,6 @@ aopOp (operand * op, iCode * ic, bool result, bool requires_a) } sym->aop = op->aop = aop = aopForSym (ic, sym->usl.spillLoc, result, requires_a); - wassertl (aop->size >= getSize (sym->type), "Operand doesn't fit in the spill location"); aop->size = getSize (sym->type); return; } -- 2.30.2