#include "../common.h"
#include <time.h>
-
+#include "ralloc.h"
extern symbol *interrupts[256];
-void printIval (symbol *, link *, initList *, FILE *);
+void printIval (symbol *, sym_link *, initList *, FILE *);
extern int noAlloc;
extern set *publics;
extern int maxInterrupts;
char *aopLiteral (value *val, int offset)
static void emitRegularMap (memmap * map, bool addPublics, bool arFlag)
value *initPointer (initList *ilist)
-void printIvalType (link * type, initList * ilist, FILE * oFile)
-void printIvalStruct (symbol * sym,link * type,
+void printIvalType (sym_link * type, initList * ilist, FILE * oFile)
+void printIvalStruct (symbol * sym,sym_link * type,
initList * ilist, FILE * oFile)
-int printIvalChar (link * type, initList * ilist, FILE * oFile, char *s)
-void printIvalArray (symbol * sym, link * type, initList * ilist,
+int printIvalChar (sym_link * type, initList * ilist, FILE * oFile, char *s)
+void printIvalArray (symbol * sym, sym_link * type, initList * ilist,
FILE * oFile)
-void printIvalFuncPtr (link * type, initList * ilist, FILE * oFile)
-int printIvalCharPtr (symbol * sym, link * type, value * val, FILE * oFile)
-void printIvalPtr (symbol * sym, link * type, initList * ilist, FILE * oFile)
+void printIvalFuncPtr (sym_link * type, initList * ilist, FILE * oFile)
+int printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile)
+void printIvalPtr (symbol * sym, sym_link * type, initList * ilist, FILE * oFile)
#endif
static void pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag)
{
symbol *sym;
- int i,size;
+ int i,size,bitvars=0;;
if (addPublics)
fprintf (map->oFile, ";\t.area\t%s\n", map->sname);
}
else {
/* allocate space */
- //if (options.debug || sym->level == 0)
- //fprintf(map->oFile,"==.\n");
+
+ /* 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,size);
+ fprintf (map->oFile, "\t%s_%d\n", sym->rname,i);
}
+ }
//fprintf (map->oFile, "\t.ds\t0x%04x\n", (unsigned int)getSize (sym->type) & 0xffff);
}
/*-----------------------------------------------------------------*/
/* printIvalType - generates ival for int/char */
/*-----------------------------------------------------------------*/
-void printIvalType (link * type, initList * ilist, FILE * oFile)
+void printIvalType (sym_link * type, initList * ilist, FILE * oFile)
{
value *val;
/*-----------------------------------------------------------------*/
/* printIvalStruct - generates initial value for structures */
/*-----------------------------------------------------------------*/
-void printIvalStruct (symbol * sym,link * type,
+void printIvalStruct (symbol * sym,sym_link * type,
initList * ilist, FILE * oFile)
{
symbol *sflds;
/*-----------------------------------------------------------------*/
/* printIvalChar - generates initital value for character array */
/*-----------------------------------------------------------------*/
-int printIvalChar (link * type, initList * ilist, FILE * oFile, char *s)
+int printIvalChar (sym_link * type, initList * ilist, FILE * oFile, char *s)
{
value *val;
int remain;
/*-----------------------------------------------------------------*/
/* printIvalArray - generates code for array initialization */
/*-----------------------------------------------------------------*/
-void printIvalArray (symbol * sym, link * type, initList * ilist,
+void printIvalArray (symbol * sym, sym_link * type, initList * ilist,
FILE * oFile)
{
initList *iloop;
/*-----------------------------------------------------------------*/
/* printIvalFuncPtr - generate initial value for function pointers */
/*-----------------------------------------------------------------*/
-void printIvalFuncPtr (link * type, initList * ilist, FILE * oFile)
+void printIvalFuncPtr (sym_link * type, initList * ilist, FILE * oFile)
{
value *val;
int dLvl = 0;
/*-----------------------------------------------------------------*/
/* printIvalCharPtr - generates initial values for character pointers */
/*-----------------------------------------------------------------*/
-int printIvalCharPtr (symbol * sym, link * type, value * val, FILE * oFile)
+int printIvalCharPtr (symbol * sym, sym_link * type, value * val, FILE * oFile)
{
int size = 0;
/*-----------------------------------------------------------------*/
/* printIvalPtr - generates initial value for pointers */
/*-----------------------------------------------------------------*/
-void printIvalPtr (symbol * sym, link * type, initList * ilist, FILE * oFile)
+void printIvalPtr (symbol * sym, sym_link * type, initList * ilist, FILE * oFile)
{
value *val;
/*-----------------------------------------------------------------*/
/* printIval - generates code for initial value */
/*-----------------------------------------------------------------*/
-void printIval (symbol * sym, link * type, initList * ilist, FILE * oFile)
+void printIval (symbol * sym, sym_link * type, initList * ilist, FILE * oFile)
{
if (!ilist)
return;
FILE *vFile;
FILE *asmFile;
FILE *ovrFile = tempfile();
-
+ int i;
+
addSetHead(&tmpfileSet,ovrFile);
/* print the global struct definitions */
if (options.debug)
/* Put all variables into a cblock */
fprintf (asmFile, "\n\n\tcblock 0x13\n\n");
+ for(i=0; i<pic14_nRegs; i++) {
+ if(regspic14[i].wasUsed && (regspic14[i].offset>=0x0c) )
+ fprintf (asmFile, "\t%s\n",regspic14[i].name);
+ }
+ //fprintf (asmFile, "\tr0x0C\n");
+ //fprintf (asmFile, "\tr0x0D\n");
+
+ /* For now, create a "dpl" and a "dph" in the register space */
+ /* of the pic so that we can use the same calling mechanism */
+ /* as the 8051 port */
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; dpl and dph to emulate the 8051 calling mechanism \n");
+ fprintf (asmFile, "%s", iComments2);
+
+ fprintf (asmFile, "\tdph\n");
+
+
/* copy the sbit segment */
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "%s", iComments2);
copyFile (asmFile, ovrFile);
- /* copy the bit segment */
- fprintf (asmFile, "%s", iComments2);
- fprintf (asmFile, "; bit data\n");
- fprintf (asmFile, "%s", iComments2);
- copyFile (asmFile, bit->oFile);
-
/* create the stack segment MOF */
if (mainf && mainf->fbody) {
fprintf (asmFile, "%s", iComments2);
fprintf (asmFile, "\tendc\n");
+
+
+ /* copy the bit segment */
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; bit data\n");
+ fprintf (asmFile, "%s", iComments2);
+ copyFile (asmFile, bit->oFile);
+
+
fprintf (asmFile, "\tORG 0\n");
/* copy the interrupt vector table */