Feature request 799831: added code to allow nesting of critical functions
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 15 Sep 2003 09:50:16 +0000 (09:50 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 15 Sep 2003 09:50:16 +0000 (09:50 +0000)
* src/mcs51/gen.c (genFunction, genEndFunction)
* src/ds390/gen.c (genFunction, genEndFunction)

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2890 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/ds390/gen.c
src/mcs51/gen.c

index 3795a8d8c0bfac0213e9448ff3fe56ba333a822e..95d26821e55ff4d13dcc435b513cf7ca635e61d1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-09-15  Bernhard Held <bernhard@bernhardheld.de>
+
+       Feature req. 799831: added code to allow nesting of critical functions
+       * src/mcs51/gen.c (genFunction, genEndFunction)
+       * src/ds390/gen.c (genFunction, genEndFunction)
+
 2003-09-14  Erik Petrich <epetrich@ivorytower.norman.ok.us>
 
        * src/SDCCsymt.c (sclsFromPtr),
index 411e019f03b3c693e230c15740ede0341f316d9f..c8cb28950e3b68120da883d569e39ad8b6708bed 100644 (file)
@@ -2899,7 +2899,11 @@ genFunction (iCode * ic)
       emitcode ("lcall","__stack_probe");
   /* if critical function then turn interrupts off */
   if (IFFUNC_ISCRITICAL (ftype))
-    emitcode ("clr", "ea");
+    {
+      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 */
@@ -3342,7 +3346,10 @@ genEndFunction (iCode * ic)
        emitcode ("pop", "acc");
 
       if (IFFUNC_ISCRITICAL (sym->type))
-       emitcode ("setb", "ea");
+        {
+         emitcode ("pop", "psw"); /* restore ea via c in psw */
+         emitcode ("mov", "ea,c");
+        }
 
       /* if debug then send end of function */
       if (options.debug && currFunc) {
@@ -3362,7 +3369,10 @@ genEndFunction (iCode * ic)
   else
     {
       if (IFFUNC_ISCRITICAL (sym->type))
-       emitcode ("setb", "ea");
+        {
+         emitcode ("pop", "psw"); /* restore ea via c in psw */
+         emitcode ("mov", "ea,c");
+        }
 
       if (IFFUNC_CALLEESAVES(sym->type))
        {
index 531a758996a62fa7114948eb2d74b9fb8984d69c..cb33e3ef4c0b1a38921c5c97f7665e9b8b1ed3b5 100644 (file)
@@ -2293,7 +2293,11 @@ genFunction (iCode * ic)
 
   /* if critical function then turn interrupts off */
   if (IFFUNC_ISCRITICAL (ftype))
-    emitcode ("clr", "ea");
+    {
+      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 */
@@ -2712,7 +2716,10 @@ genEndFunction (iCode * ic)
        emitcode ("pop", "acc");
 
       if (IFFUNC_ISCRITICAL (sym->type))
-       emitcode ("setb", "ea");
+        {
+         emitcode ("pop", "psw"); /* restore ea via c in psw */
+         emitcode ("mov", "ea,c");
+        }
 
       /* if debug then send end of function */
       if (options.debug && currFunc)
@@ -2733,7 +2740,10 @@ genEndFunction (iCode * ic)
   else
     {
       if (IFFUNC_ISCRITICAL (sym->type))
-       emitcode ("setb", "ea");
+        {
+         emitcode ("pop", "psw"); /* restore ea via c in psw */
+         emitcode ("mov", "ea,c");
+        }
 
       if (IFFUNC_CALLEESAVES(sym->type))
        {