]> git.gag.com Git - fw/sdcc/commitdiff
* src/pic/main.c (_pic14_parseOptions): added --stack-loc=NUM and
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 10 Oct 2006 18:20:41 +0000 (18:20 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 10 Oct 2006 18:20:41 +0000 (18:20 +0000)
  --stack-siz=NUM options to configure the argument passing stack
* src/pic/main.h: added stackLocation and stackSize to pic14_options_t
* src/pic/device.c (mapRegister): catch out-of-memory SIGSEGVs,
  (pic14_getSharebankSize): obey --stack-siz=NUM,
  (pic14_getSharebankAddress): obey --stack-loc=NUM

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

ChangeLog
src/pic/device.c
src/pic/main.c
src/pic/main.h

index ee1638e955ce9bbd7be002c4d18e78c5b030d1f4..47c3baddf3fc984a4936dd7e198f7ba6d5b8c391 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-10-10 Raphael Neider <rneider AT web.de>
+
+       * src/pic/main.c (_pic14_parseOptions): added --stack-loc=NUM and
+         --stack-siz=NUM options to configure the argument passing stack
+       * src/pic/main.h: added stackLocation and stackSize to pic14_options_t
+       * src/pic/device.c (mapRegister): catch out-of-memory SIGSEGVs,
+         (pic14_getSharebankSize): obey --stack-siz=NUM,
+         (pic14_getSharebankAddress): obey --stack-loc=NUM
+
 2006-10-08 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
 
        * doc/sdccman.lyx: added to the manual
index fa970737f15901620341b190fe271f187ecb23d3..9cfdb553340199570258ee84ce1c77914e7bfa2e 100644 (file)
@@ -800,6 +800,8 @@ void mapRegister(regs *reg)
        
        for(i=0; i<reg->size; i++) {
                
+               assert(reg->address >= 0 && reg->address < maxRAMaddress);
+               
                alias = finalMapping[reg->address].alias;
                reg->alias = alias;
                
@@ -1024,13 +1026,17 @@ int pic14_getHasSecondConfigReg(void)
  *-----------------------------------------------------------------*/
 int pic14_getSharebankSize(void)
 {
-       return 16;
+       if (pic14_options.stackSize <= 0) {
+               // default size: 16 bytes
+               return 16;
+       } else {
+               return pic14_options.stackSize;
+       }
 }
 
 /*-----------------------------------------------------------------*
  * Query the highest byte address occupied by the sharebank of the
  * selected device.
- * FIXME: Currently always returns 0x7f.
  * THINK: Might not be needed, if we assign all shareable objects to
  *        a `udata_shr' section and let the linker do the rest...
  * Tried it, but yields `no target memory available' for pic16f877...
@@ -1038,10 +1044,21 @@ int pic14_getSharebankSize(void)
 int pic14_getSharebankAddress(void)
 {
        int sharebankAddress = 0x7f;
-       /* If total RAM is less than 0x7f as with 16f84 then reduce
-        * sharebankAddress to fit */
-       if ((unsigned)sharebankAddress > pic14_getMaxRam())
-               sharebankAddress = (int)pic14_getMaxRam();
+       if (pic14_options.stackLocation != 0) {
+           // permanent (?) workaround for pic16f84a-like devices with hardly
+           // any memory:
+           // 0x00-0x0B SFR
+           // 0x0C-0x4F memory,
+           // 0x50-0x7F unimplemented (reads as 0),
+           // 0x80-0x8B SFRs (partly mapped to 0x0?)
+           // 0x8c-0xCF mapped to 0x0C-0x4F
+           sharebankAddress = pic14_options.stackLocation + pic14_getSharebankSize() - 1;
+       } else {
+           /* If total RAM is less than 0x7f as with 16f84 then reduce
+            * sharebankAddress to fit */
+           if ((unsigned)sharebankAddress > pic14_getMaxRam())
+                   sharebankAddress = (int)pic14_getMaxRam();
+       }
        return sharebankAddress;
 }
 
index dba9b231623140d09fe0fbc320c8a207cf64bb21..71d8ad89c0f17a31ce8c62a5b2e477b88a7ef36d 100644 (file)
@@ -12,6 +12,7 @@
 #include "SDCCmacro.h"
 #include "MySystem.h"
 #include "glue.h"
+#include <errno.h>
 //#include "gen.h"
 
 
@@ -51,10 +52,15 @@ static char *_pic14_keywords[] =
 
 pic14_options_t pic14_options;
 
+#define ARG_STACKLOC   "--stack-loc"
+#define ARG_STACKSIZ   "--stack-siz"
+
 extern int debug_verbose;      /* from pcode.c */
 static OPTION _pic14_poptions[] = {
        { 0 , "--debug-xtra", &debug_verbose, "show more debug info in assembly output" },
        { 0 , "--no-pcode-opt", &pic14_options.disable_df, "disable (slightly faulty) optimization on pCode" },
+       { 0 , ARG_STACKLOC, &pic14_options.stackLocation, "sets the lowest address of the argument passing stack" },
+       { 0 , ARG_STACKSIZ, &pic14_options.stackSize, "sets the size if the argument passing stack (default: 16, minimum: 4)" },
        { 0 , NULL, NULL, NULL }
 };
 
@@ -153,6 +159,7 @@ static bool
 _pic14_parseOptions (int *pargc, char **argv, int *i)
 {
        char buf[128];
+       int len;
        
        /* TODO: allow port-specific command line options to specify
        * segment names here.
@@ -173,6 +180,37 @@ _pic14_parseOptions (int *pargc, char **argv, int *i)
                return 1;
        }
 
+       len = strlen(ARG_STACKLOC);
+       if (!strncmp(ARG_STACKLOC, argv[ *i ], len)) {
+               if (argv[*i][len] != '=' || argv[*i][len+1] == 0) {
+                   printf("ERROR: no number entered for %s=num\n", ARG_STACKLOC);
+                   exit(EXIT_FAILURE);
+               }
+               // extract number from "--stack-loc=0x70"
+               pic14_options.stackLocation = strtol(argv[ *i ] + len + 1, NULL, 0);
+
+               if (errno) {
+                   printf("ERROR: Could not parse number after %s=num\n", ARG_STACKLOC);
+                   exit(EXIT_FAILURE);
+               }
+               return 1;
+       }
+
+       len = strlen(ARG_STACKLOC);
+       if (!strncmp(ARG_STACKSIZ, argv[*i], len)) {
+               if (argv[*i][len] != '=' || argv[*i][len+1] == 0) {
+                   printf("ERROR: no number entered for %s=num\n", ARG_STACKSIZ);
+                   exit(EXIT_FAILURE);
+               }
+               // extract number from "--stack-size=16"
+               pic14_options.stackSize = strtol(argv[ *i ] + len + 1, NULL, 0);
+               if (errno) {
+                   printf("ERROR: Could not parse number after %s=num\n", ARG_STACKLOC);
+                   exit(EXIT_FAILURE);
+               }
+               return 1;
+       }
+
        return FALSE;
 }
 
index da5f40a1d26ae24593aa3e27bb2aebb935aa2e10..b84b42a808ab2eaaa633604bc7139e6a991ad8fa 100644 (file)
@@ -4,6 +4,8 @@
 typedef struct {
   unsigned int isLibrarySource:1;
   int disable_df;
+  int stackLocation;
+  int stackSize;
 } pic14_options_t;
 
 extern pic14_options_t pic14_options;