]> git.gag.com Git - fw/sdcc/commitdiff
Made the constant following the "interrupt" keyword optional. If omitted,
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 13 Aug 2003 04:53:07 +0000 (04:53 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 13 Aug 2003 04:53:07 +0000 (04:53 +0000)
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
src/SDCC.y
src/SDCCglue.c
src/SDCCmem.c
src/SDCCsymt.h
support/Util/SDCCerr.c
support/Util/SDCCerr.h

index caab861aa9a729d193f0df4fdcd56e3e281558f2..d92760d642b55d1a6178abb14fa9fbac7dd10435 100644 (file)
@@ -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
 
index 5847cbe78db16c5e367a4fdd63dc059e473b48dd..564837930411bdd6b7d8739ea231284dd3f10c76 100644 (file)
@@ -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
index dea2f99913b411e8e657b411b53cc226ed84f322..b053850d0c2b7baeaca0333384874c70059d3142 100644 (file)
@@ -35,7 +35,7 @@
 #include <unistd.h>
 #endif
 
-symbol *interrupts[256];
+symbol *interrupts[INTNO_MAX+1];
 
 void printIval (symbol *, sym_link *, initList *, FILE *);
 set *publics = NULL;           /* public variables */
index dece30c26ef3fe7a78237ed3aaecb0b523673e31..4c62eb07069b1456a912a6b10206cb719f75b84e 100644 (file)
@@ -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),
index cc96b76deba524bc9b948a1d37e9fe60343ffbfa..cbedb3aae910495b959af6bb96f59c8e4f763447 100644 (file)
@@ -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,
index 3fdc279f59d774575e3130d3810ef941686f2090..925b81c2b9f83b729d8f138580b1fb1be9eacea5 100644 (file)
@@ -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" },
 };
 
 /*
index bb8510e42932729a9e96970df520fa3df3f75013..221ca0b20af6b288f7b86be1a170dfb6044d847a 100644 (file)
@@ -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.