* src/pic/gen.c (genFunction): set global pic14_hasInterrupt on
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 28 Apr 2006 16:23:34 +0000 (16:23 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 28 Apr 2006 16:23:34 +0000 (16:23 +0000)
    definition of an interrupt handler,
* src/pic/glue.c (pic14_emitInterruptHandler): moved output of
    interrupt handler stuff from picglue() to separate routine,
  (picglue): enabled definition of intr handlers in files w/o main()

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

ChangeLog
src/pic/gen.c
src/pic/glue.c

index 04eb4cb89fb49e6ef73c2b55d73a3c62e80dfe11..a9e7530d01536ca8dd70acea1c7e2f9ea5a578a0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-04-28 Raphael Neider <rneider AT web.de>
+
+       * src/pic/gen.c (genFunction): set global pic14_hasInterrupt on
+           definition of an interrupt handler,
+       * src/pic/glue.c (pic14_emitInterruptHandler): moved output of
+           interrupt handler stuff from picglue() to separate routine,
+         (picglue): enabled definition of intr handlers in files w/o main()
+
 2006-04-26 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * support/librarian/sdcclib.c: moved include <limits.h> up to enable
 
 2006-04-24 Raphael Neider <rneider AT web.de>
 
-       * src/pic/device.c (pic14_assignConfigWordValue): remember assignments to
-           config word, "pic14_"-prefixed some extern functions
+       * src/pic/device.c (pic14_assignConfigWordValue): remember assignments
+           to config word, "pic14_"-prefixed some extern functions
          (pic14_emitConfigWord): emit __config directive(s) if assignment to
            config word has been found
        * src/pic/device.h: added prototypes
        * src/pic/pcode.c: added "pic14_"-prefix where needed
-       * src/pic/ralloc.c (IS_CONFIG_ADDRESS,pic14_assignRegisters): cosmetic fixup
-       * src/pic/glue.c (pic14_constructAbsMap): handle assignments to config words,
+       * src/pic/ralloc.c (IS_CONFIG_ADDRESS,pic14_assignRegisters): cosmetic
+           fixup
+       * src/pic/glue.c (pic14_constructAbsMap): handle assignments to config
+           words,
          (pic14emitRegularMap): ignore config words,
          (pic14createInterruptVect): moved generating __config directives away
          (picglue): have __config directives emitted
index 7370a3bace7d2812b1c364c66efc2f0431355aa1..51e51cc5ca240645629bd71649f2f8f536d1f330 100644 (file)
@@ -59,6 +59,7 @@ extern void printpBlock(FILE *of, pBlock *pb);
 
 static int labelOffset=0;
 extern int debug_verbose;
+extern int pic14_hasInterrupt;
 //static int optimized_for_speed = 0;
 
 /* max_key keeps track of the largest label number used in 
@@ -2925,6 +2926,7 @@ static void genFunction (iCode *ic)
                emitpcode(POC_CLRF,   popCopyReg(&pc_pclath));/* during an interrupt PCLATH must be cleared before a goto or call statement */
                
                pBlockConvert2ISR(pb);
+               pic14_hasInterrupt = 1;
 #if 0  
                if (!inExcludeList("acc"))              
                        pic14_emitcode ("push","acc");  
index f1809b7fddb620e1d0202aef2d91a1ed96543d49..11a8664dd654fb13c13c80505c085cc7da64ee76 100644 (file)
@@ -76,6 +76,7 @@ int pic14_getSharebankSize(void);
 int pic14_getSharebankAddress(void);
 
 char *udata_section_name=0;            // FIXME Temporary fix to change udata section name -- VR
+int pic14_hasInterrupt = 0;            // Indicates whether to emit interrupt handler or not
 
 /*-----------------------------------------------------------------*/
 /* aopLiteral - string from a literal value                        */
@@ -1176,6 +1177,26 @@ pic14emitOverlay (FILE * afile)
 }
 
 
+void
+pic14_emitInterruptHandler (FILE * asmFile)
+{
+       if (pic14_hasInterrupt)
+       {
+
+               fprintf (asmFile, "%s", iComments2);
+               fprintf (asmFile, "; interrupt and initialization code\n");
+               fprintf (asmFile, "%s", iComments2);
+               // Note - for mplink may have to enlarge section vectors in .lnk file
+               // Note: Do NOT name this code_interrupt to avoid nameclashes with
+               //       source files's code segment (interrupt.c -> code_interrupt)
+               fprintf (asmFile, "c_interrupt\t%s\t0x4\n", CODE_NAME);
+               
+               /* interrupt service routine */
+               fprintf (asmFile, "__sdcc_interrupt\n");
+               copypCode(asmFile, 'I');
+       }       
+}
+
 /*-----------------------------------------------------------------*/
 /* glue - the final glue that hold the whole thing together        */
 /*-----------------------------------------------------------------*/
@@ -1380,16 +1401,12 @@ picglue ()
        /* copy the interrupt vector table */
        if (mainf && IFFUNC_HASBODY(mainf->type)) {
                copyFile (asmFile, vFile);
-               
-               fprintf (asmFile, "%s", iComments2);
-               fprintf (asmFile, "; interrupt and initialization code\n");
-               fprintf (asmFile, "%s", iComments2);
-               fprintf (asmFile, "code_interrupt\t%s\t0x4\n", CODE_NAME); // Note - for mplink may have to enlarge section vectors in .lnk file
-               
-               /* interrupt service routine */
-               fprintf (asmFile, "__sdcc_interrupt\n");
-               copypCode(asmFile, 'I');
-               
+       }
+       
+       /* create interupt ventor handler */
+       pic14_emitInterruptHandler (asmFile);
+       
+       if (mainf && IFFUNC_HASBODY(mainf->type)) {
                /* initialize data memory */
                fprintf (asmFile, "code_init\t%s\n", CODE_NAME); // Note - for mplink may have to enlarge section vectors in .lnk file
                fprintf (asmFile,"__sdcc_gsinit_startup\n");