From 76f52d057ef7acd8100cc4621c5aac9da1e3b2f3 Mon Sep 17 00:00:00 2001 From: tecodev Date: Fri, 28 Apr 2006 16:23:34 +0000 Subject: [PATCH] * 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() git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4133 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 18 ++++++++++++++---- src/pic/gen.c | 2 ++ src/pic/glue.c | 37 +++++++++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 04eb4cb8..a9e7530d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-04-28 Raphael Neider + + * 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 * support/librarian/sdcclib.c: moved include up to enable @@ -73,14 +81,16 @@ 2006-04-24 Raphael Neider - * 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 diff --git a/src/pic/gen.c b/src/pic/gen.c index 7370a3ba..51e51cc5 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -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"); diff --git a/src/pic/glue.c b/src/pic/glue.c index f1809b7f..11a8664d 100644 --- a/src/pic/glue.c +++ b/src/pic/glue.c @@ -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"); -- 2.30.2