#include "newalloc.h"
+#include "main.h"
#include "pcode.h"
#include "ralloc.h"
#include "device.h"
#define STRCASECMP strcasecmp
#endif
+extern int Gstack_base_addr;
+extern int Gstack_size;
+
static PIC_device Pics[] = {
{
{"p16f627", "16f627", "pic16f627", "f627"}, /* processor name */
(memRange *)NULL,
(memRange *)NULL,
- 0, /* max ram address (calculated) */
- 0x80, /* Bank Mask */
+ 0, /* max ram address (calculated) */
+ 0x1ff, /* default max ram address */
+ 0x80, /* Bank Mask */
},
{
(memRange *)NULL,
(memRange *)NULL,
0,
+ 0x1ff,
0x80,
},
(memRange *)NULL,
(memRange *)NULL,
0,
+ 0x4f, /* 68 register available 0x0C to 0x4F (0x8C to 0xCF mapped to bank 0) */
0x80,
},
(memRange *)NULL,
(memRange *)NULL,
0,
+ 0x1ff,
0x180,
},
(memRange *)NULL,
(memRange *)NULL,
0,
+ 0x1ff,
0x180,
},
(memRange *)NULL,
(memRange *)NULL,
0,
+ 0x1ff,
0x80,
},
static int num_of_supported_PICS = sizeof(Pics)/sizeof(PIC_device);
-#define DEFAULT_PIC "f877"
-
static PIC_device *pic=NULL;
AssignedMemory *finalMapping=NULL;
static unsigned int config_word = DEFAULT_CONFIG_WORD;
+extern int is_shared (regs *reg);
+extern void emitSymbolToFile (FILE *of, const char *name, const char *section_type, int size, int addr, int useEQU, int globalize);
+
void addMemRange(memRange *r, int type)
{
int i;
for(i=0; i<=pic->maxRAMaddress; i++) {
finalMapping[i].reg = NULL;
finalMapping[i].isValid = 0;
+ finalMapping[i].bank = (i>>7);
}
}
/*-----------------------------------------------------------------*
*-----------------------------------------------------------------*/
+int isSFR(int address)
+{
+
+ if( (address > pic->maxRAMaddress) || !finalMapping[address].isSFR)
+ return 0;
+
+ return 1;
+
+}
+
/*
* dump_map -- debug stuff
*/
void dump_sfr(FILE *of)
{
-
+#if 0
int start=-1;
- int addr=0;
int bank_base;
static int udata_flag=0;
+#endif
+ int addr=0;
//dump_map(); /* display the register map */
//fprintf(stdout,";dump_sfr \n");
return;
}
- do {
+ for (addr = 0; addr <= pic->maxRAMaddress; addr++)
+ {
+ regs *reg = finalMapping[addr].reg;
+ if (reg && !reg->isEmitted)
+ {
+ if (pic14_options.isLibrarySource && is_shared (reg))
+ {
+ /* rely on external declarations for the non-fixed stack */
+ fprintf (of, "\textern\t%s\n", reg->name);
+ } else {
+ emitSymbolToFile (of, reg->name, "udata", reg->size, reg->isFixed ? reg->address : -1, 0, is_shared (reg));
+ }
+
+ reg->isEmitted = 1;
+ }
+ } // for
+
+#if 0
+ do {
+
if(finalMapping[addr].reg && !finalMapping[addr].reg->isEmitted) {
if(start<0)
} else {
if(start>=0) {
- /* clear the lower 7-bits of the start address of the first
- * variable declared in this bank. The upper bits for the mid
- * range pics are the bank select bits.
+ /* clear the lower 7-bits of the start address of the first
+ * variable declared in this bank. The upper bits for the mid
+ * range pics are the bank select bits.
*/
bank_base = start & 0xfff8;
finalMapping[start].reg->address+i);
}
} else {
+ emitSymbolToFile (of, finalMapping[start].reg->name, finalMapping[start].reg->size);
+#if 0
fprintf(of,"%s\tres\t%i\n",
finalMapping[start].reg->name,
finalMapping[start].reg->size);
+#endif
}
finalMapping[start].reg->isEmitted = 1;
}
addr++;
} while(addr <= pic->maxRAMaddress);
-
-
+
+
+#endif
}
/*-----------------------------------------------------------------*
return pic->name[0];
}
-int isSFR(int address)
-{
-
- if( (address > pic->maxRAMaddress) || !finalMapping[address].isSFR)
- return 0;
-
- return 1;
-
-}
-
/*-----------------------------------------------------------------*
*-----------------------------------------------------------------*/
int validAddress(int address, int reg_size)
return 0;
}
// fprintf(stderr, "validAddress: Checking 0x%04x\n",address);
- if(address > pic->maxRAMaddress)
+ assert (reg_size > 0);
+ if(address + (reg_size - 1) > pic->maxRAMaddress)
return 0;
for (i=0; i<reg_size; i++)
return reg->address;
}
- //fprintf(stderr, "WARNING: Ignoring Out of Range register assignment at fixed address %d, %s\n",
- // reg->address, reg->name);
+ fprintf(stderr, "WARNING: Ignoring Out of Range register assignment at fixed address %d, %s\n",
+ reg->address, reg->name);
} else {
for (reg = setFirstItem(regset) ; reg ;
reg = setNextItem(regset)) {
- //fprintf(stdout,"assigning %s isFixed=%d, wasUsed=%d\n",reg->name,reg->isFixed,reg->wasUsed);
+ //fprintf(stdout,"assigning %s (%d) isFixed=%d, wasUsed=%d\n",reg->name,reg->size,reg->isFixed,reg->wasUsed);
- if((!reg->isFixed) && ( used || reg->wasUsed)) {
+ if((!reg->isExtern) && (!reg->isFixed) && ( used || reg->wasUsed)) {
/* If register have been reused then shall not print it a second time. */
set *s;
int done = 0;
return 0;
}
+
+/*-----------------------------------------------------------------*
+*
+*-----------------------------------------------------------------*/
+void setDefMaxRam(void)
+{
+ unsigned i;
+ setMaxRAM(pic->defMaxRAMaddrs); /* Max RAM has not been included, so use default setting */
+ /* Validate full memory range for use by general purpose RAM */
+ for (i=0; i <= pic->defMaxRAMaddrs; i++) {
+ finalMapping[i].bank = (i>>7);
+ finalMapping[i].isValid = 1;
+ }
+}
+
+/*-----------------------------------------------------------------*
+*
+*-----------------------------------------------------------------*/
+unsigned getMaxRam(void)
+{
+ return pic->defMaxRAMaddrs;
+}