-
- /* if extern then do nothing */
- if (IS_EXTERN (sym->etype))
- continue;
-
- /* if allocation required check is needed
- then check if the symbol really requires
- allocation only for local variables */
- if (arFlag && !IS_AGGREGATE (sym->type) &&
- !(sym->_isparm && !IS_REGPARM (sym->etype)) &&
- !sym->allocreq && sym->level)
- continue;
-
- /* if global variable & not static or extern
- and addPublics allowed then add it to the public set */
- if ((sym->level == 0 ||
- (sym->_isparm && !IS_REGPARM (sym->etype))) &&
- addPublics &&
- !IS_STATIC (sym->etype))
- addSetHead (&publics, sym);
-
- /* if extern then do nothing or is a function
- then do nothing */
- if (IS_FUNC (sym->type))
- continue;
-#if 0
- /* print extra debug info if required */
- if (options.debug || sym->level == 0)
- {
-
- cdbSymbol (sym, cdbFile, FALSE, FALSE);
-
- if (!sym->level) /* global */
- if (IS_STATIC (sym->etype))
- fprintf (map->oFile, "F%s_", moduleName); /* scope is file */
- else
- fprintf (map->oFile, "G_"); /* scope is global */
- else
- /* symbol is local */
- fprintf (map->oFile, "L%s_", (sym->localof ? sym->localof->name : "-null-"));
- fprintf (map->oFile, "%s_%d_%d", sym->name, sym->level, sym->block);
- }
-#endif
-
- /* if is has an absolute address then generate
- an equate for this no need to allocate space */
- if (SPEC_ABSA (sym->etype))
- {
- //if (options.debug || sym->level == 0)
- //fprintf (map->oFile,"; == 0x%04x\n",SPEC_ADDR (sym->etype));
-
- fprintf (map->oFile, "%s\tEQU\t0x%04x\n",
- sym->rname,
- SPEC_ADDR (sym->etype));
- }
- else
- {
- /* allocate space */
-
- /* If this is a bit variable, then allocate storage after 8 bits have been declared */
- /* unlike the 8051, the pic does not have a separate bit area. So we emulate bit ram */
- /* by grouping the bits together into groups of 8 and storing them in the normal ram. */
- if (IS_BITVAR (sym->etype))
- {
- if ((bitvars % 8) == 0)
- {
- fprintf (map->oFile, " cblock\n");
- fprintf (map->oFile, "\tbitfield%d\n", bitvars);
- fprintf (map->oFile, " endc\n");
- }
-
- fprintf (map->oFile, "%s\tEQU\t( (bitfield%d<<3)+%d)\n",
- sym->rname,
- bitvars & 0xfff8,
- bitvars & 0x0007);
-
- bitvars++;
- }
- else
- {
- fprintf (map->oFile, "\t%s\n", sym->rname);
- if ((size = (unsigned int) getSize (sym->type) & 0xffff) > 1)
- {
- for (i = 1; i < size; i++)
- fprintf (map->oFile, "\t%s_%d\n", sym->rname, i);
- }
- }
- //fprintf (map->oFile, "\t.ds\t0x%04x\n", (unsigned int)getSize (sym->type) & 0xffff);
- }
-
- /* if it has a initial value then do it only if
- it is a global variable */
- if (sym->ival && sym->level == 0)
- {
- ast *ival = NULL;
-
- if (IS_AGGREGATE (sym->type))
- ival = initAggregates (sym, sym->ival, NULL);
- else
- ival = newNode ('=', newAst_VALUE (symbolVal (sym)),
- decorateType (resolveSymbols (list2expr (sym->ival))));
- codeOutFile = statsg->oFile;
- eBBlockFromiCode (iCodeFromAst (ival));
- sym->ival = NULL;
- }
+ pic = pic14_getPIC();
+
+ dbuf_printf (oBuf, "\n");
+ dbuf_printf (oBuf, "\tglobal PSAVE\n");
+ dbuf_printf (oBuf, "\tglobal SSAVE\n");
+ dbuf_printf (oBuf, "\tglobal WSAVE\n");
+ for (i = size - 4; i >= 0; i--) {
+ dbuf_printf (oBuf, "\tglobal STK%02d\n", i);
+ } // for i
+ dbuf_printf (oBuf, "\n");
+
+ // 16f84 has no SHAREBANK (in linkerscript) but memory aliased in two
+ // banks, sigh...
+ if (1 || !shared) {
+ // for single banked devices: use normal, "banked" RAM
+ dbuf_printf (oBuf, "sharebank udata_ovr 0x%04X\n", low);
+ } else {
+ // for devices with at least two banks, require a sharebank section
+ dbuf_printf (oBuf, "sharebank udata_shr\n");
+ }
+ dbuf_printf (oBuf, "PSAVE\tres 1\n");
+ dbuf_printf (oBuf, "SSAVE\tres 1\n");
+ dbuf_printf (oBuf, "WSAVE\tres 1\n"); // WSAVE *must* be in sharebank (IRQ handlers)
+ /* fill rest of sharebank with stack STKxx .. STK00 */
+ for (i = size - 4; i >= 0; i--) {
+ dbuf_printf (oBuf, "STK%02d\tres 1\n", i);
+ } // for i
+ } else {
+ /* declare STKxx as extern for all files
+ * except the one containing main() */
+ dbuf_printf (oBufExt, "\n");
+ dbuf_printf (oBufExt, "\textern PSAVE\n");
+ dbuf_printf (oBufExt, "\textern SSAVE\n");
+ dbuf_printf (oBufExt, "\textern WSAVE\n");
+ for (i = size - 4; i >= 0; i--) {
+ char buffer[128];
+ SNPRINTF(&buffer[0], 127, "STK%02d", i);
+ dbuf_printf (oBufExt, "\textern %s\n", &buffer[0]);
+ pic14_stringInSet(&buffer[0], &emitted, 1);
+ } // for i