* src/pic16/gen.c (genFunction, genEndFunction): fixed return
authorvrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 29 Aug 2004 10:26:33 +0000 (10:26 +0000)
committervrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 29 Aug 2004 10:26:33 +0000 (10:26 +0000)
instruction for interrupt handlers, use fast returns when returning
from high priority interrupts

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

ChangeLog
src/pic16/gen.c

index dda98b7dab2d7e66dd74914124e8b2b317b45ee1..ccde82b2c98ee36b65e510949ec513a8d311058f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-08-29 Vangelis Rokas (vrokas AT otenet.gr>
+
+       * src/pic16/gen.c (genFunction, genEndFunction): fixed return
+       instruction for interrupt handlers, use fast returns when returning
+       from high priority interrupts
+
 2004-08-29 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
 
        * src/hc08/gen.c (genAnd, genOr, transferAopAop, rmwWithAop): optimized
index 49dbd23523e7531fc4b57b26b0bbce1cbfdf5e87..6d6e8bd669bb16b4cb2dfc2b47d77e2bae6c0b32 100644 (file)
@@ -132,6 +132,7 @@ static struct {
     short ipushRegs;
     set *sendSet;
     int interruptvector;
+    int usefastretfie;
 } _G;
 
 /* Resolved ifx structure. This structure stores information
@@ -414,6 +415,7 @@ static regs *getFreePtr (iCode *ic, asmop **aopp, bool result)
     fprintf(stderr, "%s:%d could not allocate a free pointer\n", __FILE__, __LINE__);
     assert( 0 );
 
+    return NULL;
 #if 0
     /* the logic: if r0 & r1 used in the instruction
     then we are in trouble otherwise */
@@ -3466,17 +3468,22 @@ static void genFunction (iCode *ic)
         * save acc, b, dpl, dph  */
        if (IFFUNC_ISISR(sym->type)) {
          int i;
+
+               _G.usefastretfie = 1;   /* use shadow registers by default */
                /* an ISR should save: WREG, STATUS, BSR, PRODL, PRODH, FSR0L, FSR0H */
                if(!(_G.interruptvector == 1)) {
 
                        /* do not save WREG,STATUS,BSR for high priority interrupts
                         * because they are stored in the hardware shadow registers already */
-                        
+                       _G.usefastretfie = 0;
                        pic16_pushpCodeOp( pic16_popCopyReg( &pic16_pc_wreg ));
                        pic16_pushpCodeOp( pic16_popCopyReg( &pic16_pc_status ));
                        pic16_pushpCodeOp( pic16_popCopyReg( &pic16_pc_bsr ));
                }
 
+
+                /* these should really be optimized somehow, because not all
+                 * interrupt handlers modify them */
                pic16_pushpCodeOp( pic16_popCopyReg( &pic16_pc_prodl ));
                pic16_pushpCodeOp( pic16_popCopyReg( &pic16_pc_prodh ));
                pic16_pushpCodeOp( pic16_popCopyReg( &pic16_pc_fsr0l ));
@@ -3712,7 +3719,11 @@ static void genEndFunction (iCode *ic)
                        debugFile->writeEndFunction (currFunc, ic, 1);
                }
        
+               if(_G.usefastretfie)
+                       pic16_emitpcode(POC_RETFIE, pic16_newpCodeOpLit(1));
+               else
                pic16_emitpcodeNULLop(POC_RETFIE);
+               _G.usefastretfie = 0;
        } else {
                if (IFFUNC_ISCRITICAL(sym->type))
                        pic16_emitcode("setb","ea");
@@ -3764,7 +3775,6 @@ static void genEndFunction (iCode *ic)
                        }
                }
 
-               pic16_emitcode ("return","");
                pic16_emitpcodeNULLop(POC_RETURN);
 
                /* Mark the end of a function */