From 6ae24c6a59a04e149ad4fbd91a6212893aa27af7 Mon Sep 17 00:00:00 2001 From: epetrich Date: Wed, 13 Aug 2003 04:53:07 +0000 Subject: [PATCH] Made the constant following the "interrupt" keyword optional. If omitted, the function will not automatically be given an entry in the interrupt vector table (similar to #pragma NOIV, but less syntacticly kludgy). The interrupt number is also now range checked. * src/SDCC.y * src/SDCCmem.c * src/SDCCglue.c * src/SDCCsymt.h * support/Util/SDCCerr.c * support/Util/SDCCerr.h * doc/sdccman.lyx git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2823 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- doc/sdccman.lyx | 52 ++++++++++-------------------------------- src/SDCC.y | 12 +++++++++- src/SDCCglue.c | 2 +- src/SDCCmem.c | 4 ++-- src/SDCCsymt.h | 3 +++ support/Util/SDCCerr.c | 2 ++ support/Util/SDCCerr.h | 1 + 7 files changed, 32 insertions(+), 44 deletions(-) diff --git a/doc/sdccman.lyx b/doc/sdccman.lyx index caab861a..d92760d6 100644 --- a/doc/sdccman.lyx +++ b/doc/sdccman.lyx @@ -7394,7 +7394,7 @@ void timer_isr (void) interrupt 1 using 1 } \layout Standard -The number following the +The optional number following the \emph on interrupt \begin_inset LatexCommand \index{interrupt} @@ -7404,8 +7404,8 @@ interrupt \emph default keyword is the interrupt number this routine will service. - The compiler will insert a call to this routine in the interrupt vector - table for the interrupt number specified. + When present, the compiler will insert a call to this routine in the + interrupt vector table for the interrupt number specified. The \emph on using @@ -11295,9 +11295,10 @@ will generate the following code: \SpecialChar ~ \SpecialChar ~ mov\SpecialChar ~ +\SpecialChar ~ a,(_gint + 1) \newline -000C 33\SpecialChar ~ +000C 23\SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ @@ -11323,39 +11324,12 @@ will generate the following code: \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ - rlc\SpecialChar ~ - a -\newline -000D E4\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ + rl\SpecialChar ~ \SpecialChar ~ \SpecialChar ~ -\SpecialChar ~ - 64\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ - clr\SpecialChar ~ a \newline -000E 13\SpecialChar ~ +000D 54 01\SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ @@ -11370,10 +11344,7 @@ will generate the following code: \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ -\SpecialChar ~ - 65\SpecialChar ~ + 64\SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ @@ -11381,8 +11352,8 @@ will generate the following code: \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ - rrc\SpecialChar ~ - a + andl\SpecialChar ~ + a,#0x01 \newline 000F F5*02\SpecialChar ~ \SpecialChar ~ @@ -11399,7 +11370,7 @@ will generate the following code: \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ - 66\SpecialChar ~ + 65\SpecialChar ~ \SpecialChar ~ \SpecialChar ~ \SpecialChar ~ @@ -11408,6 +11379,7 @@ will generate the following code: \SpecialChar ~ \SpecialChar ~ mov\SpecialChar ~ +\SpecialChar ~ _foo_hob_1_1,a \layout Standard diff --git a/src/SDCC.y b/src/SDCC.y index 5847cbe7..56483793 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -550,7 +550,17 @@ storage_class_specifier ; Interrupt_storage - : INTERRUPT CONSTANT { $$ = (int) floatFromVal($2) ; } + : INTERRUPT { $$ = INTNO_UNSPEC ; } + | INTERRUPT CONSTANT + { int intno = (int) floatFromVal($2); + if ((intno >= 0) && (intno <= INTNO_MAX)) + $$ = intno; + else + { + werror(E_INT_BAD_INTNO, intno); + $$ = INTNO_UNSPEC; + } + } ; type_specifier diff --git a/src/SDCCglue.c b/src/SDCCglue.c index dea2f999..b053850d 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -35,7 +35,7 @@ #include #endif -symbol *interrupts[256]; +symbol *interrupts[INTNO_MAX+1]; void printIval (symbol *, sym_link *, initList *, FILE *); set *publics = NULL; /* public variables */ diff --git a/src/SDCCmem.c b/src/SDCCmem.c index dece30c2..4c62eb07 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -325,9 +325,9 @@ allocGlobal (symbol * sym) SPEC_OCLS (sym->etype) = code; /* if this is an interrupt service routine then put it in the interrupt service array */ - if (FUNC_ISISR (sym->type) && !options.noiv) + if (FUNC_ISISR (sym->type) && !options.noiv + && (FUNC_INTNO (sym->type) != INTNO_UNSPEC)) { - if (interrupts[FUNC_INTNO (sym->type)]) werror (E_INT_DEFINED, FUNC_INTNO (sym->type), diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index cc96b76d..cbedb3aa 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -30,6 +30,9 @@ #include "SDCChasht.h" #include "SDCCglobl.h" +#define INTNO_MAX 255 /* maximum allowed interrupt number */ +#define INTNO_UNSPEC (INTNO_MAX+1) /* interrupt number unspecified */ + enum { TYPEOF_INT=1, TYPEOF_SHORT, diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index 3fdc279f..925b81c2 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -389,6 +389,8 @@ struct "integer overflow in expression" }, { W_USELESS_DECL, ERROR_LEVEL_WARNING, "useless declaration (possible use of keyword as variable name)" }, +{ E_INT_BAD_INTNO, ERROR_LEVEL_ERROR, + "interrupt number '%u' is not valid" }, }; /* diff --git a/support/Util/SDCCerr.h b/support/Util/SDCCerr.h index bb8510e4..221ca0b2 100644 --- a/support/Util/SDCCerr.h +++ b/support/Util/SDCCerr.h @@ -182,6 +182,7 @@ SDCCERR - SDCC Standard error handler #define E_STACK_VIOLATION 164 /* internal stack violation */ #define W_INT_OVL 165 /* integer overflow in expression */ #define W_USELESS_DECL 166 /* useless declaration */ +#define E_INT_BAD_INTNO 167 /* invalid interrupt number */ /** Describes the maximum error level that will be logged. Any level * includes all of the levels listed after it. -- 2.30.2