--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
+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
for(i=0; i<reg->size; i++) {
+ assert(reg->address >= 0 && reg->address < maxRAMaddress);
+
alias = finalMapping[reg->address].alias;
reg->alias = alias;
*-----------------------------------------------------------------*/
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...
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;
}
#include "SDCCmacro.h"
#include "MySystem.h"
#include "glue.h"
+#include <errno.h>
//#include "gen.h"
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 }
};
_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.
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;
}
typedef struct {
unsigned int isLibrarySource:1;
int disable_df;
+ int stackLocation;
+ int stackSize;
} pic14_options_t;
extern pic14_options_t pic14_options;