X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fpic16%2Fmain.c;h=67c857909c90ce5e0edd3c37870873b4ea04332d;hb=1d1257b95e7011f5d9621b43aafd45bd87fbc34a;hp=a490a264fa16e0555080d1db40a8bf16fd8cfd48;hpb=76dd685a3e8b034b11427e0ed9ec6a074731f2a0;p=fw%2Fsdcc diff --git a/src/pic16/main.c b/src/pic16/main.c index a490a264..67c85790 100644 --- a/src/pic16/main.c +++ b/src/pic16/main.c @@ -62,6 +62,7 @@ static char *_pic16_keywords[] = "_naked", "shadowregs", "wparam", + "fixed16x16", // "bit", // "idata", @@ -115,7 +116,7 @@ _pic16_reset_regparm (void) } static int -_pic16_regparm (sym_link * l) +_pic16_regparm (sym_link * l, bool reentrant) { /* force all parameters via SEND/RECEIVE */ if(0 /*pic16_options.ip_stack*/) { @@ -187,6 +188,12 @@ _process_pragma(const char *sz) regs *reg; symbol *sym; + if (!stackPosS) { + fprintf (stderr, "%s:%d: #pragma stack [stack-pos] [stack-length] -- stack-position missing\n", filename, lineno-1); + + return 0; /* considered an error */ + } + stackPosVal = constVal( stackPosS ); stackPos = (unsigned int)floatFromVal( stackPosVal ); @@ -204,7 +211,32 @@ _process_pragma(const char *sz) } // fprintf(stderr, "Initializing stack pointer at 0x%x len 0x%x\n", stackPos, stackLen); - + + /* check sanity of stack */ + if ((stackPos >> 8) != ((stackPos+stackLen) >> 8)) { + fprintf (stderr, "%s:%u: warning: stack [0x%03X,0x%03X] crosses memory bank boundaries (not fully tested)\n", + filename,lineno-1, stackPos, stackPos+stackLen-1); + } + + if (pic16) { + if (stackPos < pic16->acsSplitOfs) { + fprintf (stderr, "%s:%u: warning: stack [0x%03X, 0x%03X] intersects with the access bank [0x000,0x%03x] -- this is highly discouraged!\n", + filename, lineno-1, stackPos, stackPos+stackLen-1, pic16->acsSplitOfs); + } + + if (stackPos+stackLen > 0xF00 + pic16->acsSplitOfs) { + fprintf (stderr, "%s:%u: warning: stack [0x%03X,0x%03X] intersects with special function registers [0x%03X,0xFFF]-- this is highly discouraged!\n", + filename, lineno-1, stackPos, stackPos+stackLen-1, 0xF00 + pic16->acsSplitOfs); + } + + if (stackPos+stackLen > pic16->RAMsize) { + fprintf (stderr, "%s:%u: error: stack [0x%03X,0x%03X] is placed outside available memory [0x000,0x%03X]!\n", + filename, lineno-1, stackPos, stackPos+stackLen-1, pic16->RAMsize-1); + exit(-1); + return 1; /* considered an error, but this reports "invalid pragma stack"... */ + } + } + reg=newReg(REG_SFR, PO_SFR_REGISTER, stackPos, "_stack", stackLen-1, 0, NULL); addSet(&pic16_fix_udata, reg); @@ -233,7 +265,8 @@ _process_pragma(const char *sz) if (!symname || !location) { fprintf (stderr, "%s:%d: #pragma code [symbol] [location] -- symbol or location missing\n", filename, lineno-1); - return 1; /* considered an error */ + exit (-1); + return 1; /* considered an error, but this reports "invalid pragma code"... */ } absS = Safe_calloc(1, sizeof(absSym)); @@ -266,7 +299,8 @@ _process_pragma(const char *sz) if (!symname || !sectname) { fprintf (stderr, "%s:%d: #pragma udata [section-name] [symbol] -- section-name or symbol missing!\n", filename, lineno-1); - return 1; /* considered an error */ + exit (-1); + return 1; /* considered an error, but this reports "invalid pragma code"... */ } while(symname) { @@ -1045,6 +1079,7 @@ PORT pic16_port = "HOME (CODE)", // home NULL, // xidata NULL, // xinit + "CONST (CODE)", // const_name - const data (code or not) NULL, // default location for auto vars NULL, // default location for global vars 1 // code is read only 1=yes