static PIC_device *pic=NULL;
AssignedMemory *finalMapping=NULL;
+
+#define CONFIG_WORD_ADDRESS 0x2007
+#define DEFAULT_CONFIG_WORD 0x3fff
+
+static unsigned int config_word = DEFAULT_CONFIG_WORD;
+
/*-----------------------------------------------------------------*
*
* void addMem(memRange *ranges,int type)
{
int start=-1;
int addr=0;
+ int bank_base;
//dump_map(); /* display the register map */
} 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.
+ */
+
+ bank_base = start & 0xfff8;
+
/* The bank number printed in the cblock comment tacitly
* assumes that the first register in the contiguous group
* of registers represents the bank for the whole group */
+
fprintf(of," cblock 0X%04X\t; Bank %d\n",start,finalMapping[start].bank);
for( ; start < addr; start++) {
/* If this register is aliased in multiple banks, then
* mangle the variable name with the alias address: */
if(finalMapping[start].alias & start)
- fprintf(of,"_%x",finalMapping[start].alias);
+ fprintf(of,"_%x",bank_base);
if(finalMapping[start].instance)
fprintf(of,"_%d",finalMapping[start].instance);
}
+
+/*-----------------------------------------------------------------*
+ * void assignConfigWordValue(int address, int value)
+ *
+ * All midrange PICs have one config word at address 0x2007.
+ * This routine will assign a value to that address.
+ *
+ *-----------------------------------------------------------------*/
+
+void assignConfigWordValue(int address, int value)
+{
+ if(CONFIG_WORD_ADDRESS == address)
+ config_word = value;
+
+ fprintf(stderr,"setting config word to 0x%x\n",value);
+
+}
+/*-----------------------------------------------------------------*
+ * int getConfigWord(int address)
+ *
+ * Get the current value of the config word.
+ *
+ *-----------------------------------------------------------------*/
+
+int getConfigWord(int address)
+{
+ if(CONFIG_WORD_ADDRESS == address)
+ return config_word;
+
+ else
+ return 0;
+
+}
return NULL; // name wasn't found in the hash table
}
+int IS_CONFIG_ADDRESS(int address)
+{
+
+ return address == 0x2007;
+}
+
/*-----------------------------------------------------------------*/
/* allocDirReg - allocates register of given type */
/*-----------------------------------------------------------------*/
reg = dirregWithName(name);
if(!reg) {
+ int address = 0;
+
+ /* if this is at an absolute address, then get the address. */
+ if (SPEC_ABSA ( OP_SYM_ETYPE(op)) ) {
+ address = SPEC_ADDR ( OP_SYM_ETYPE(op));
+ }
/* Register wasn't found in hash, so let's create
* a new one and put it in the hash table AND in the
* dynDirectRegNames set */
+ if(!IS_CONFIG_ADDRESS(address)) {
+ reg = newReg(REG_GPR, PO_DIR, rDirectIdx++, name,getSize (OP_SYMBOL (op)->type),0 );
+ debugLog (" -- added %s to hash, size = %d\n", name,reg->size);
+
+ if (SPEC_ABSA ( OP_SYM_ETYPE(op)) ) {
+ reg->isFixed = 1;
+ reg->address = SPEC_ADDR ( OP_SYM_ETYPE(op));
+ debugLog (" -- and it is at a fixed address 0x%02x\n",reg->address);
+ }
- reg = newReg(REG_GPR, PO_DIR, rDirectIdx++, name,getSize (OP_SYMBOL (op)->type),0 );
- debugLog (" -- added %s to hash, size = %d\n", name,reg->size);
+ hTabAddItem(&dynDirectRegNames, regname2key(name), reg);
+ if (IS_BITVAR (OP_SYM_ETYPE(op)))
+ addSet(&dynDirectBitRegs, reg);
+ else
+ addSet(&dynDirectRegs, reg);
+ } else {
+ debugLog (" -- %s is declared at address 0x2007\n",name);
- if (SPEC_ABSA ( OP_SYM_ETYPE(op)) ) {
- reg->isFixed = 1;
- reg->address = SPEC_ADDR ( OP_SYM_ETYPE(op));
- debugLog (" -- and it is at a fixed address 0x%02x\n",reg->address);
}
-
- hTabAddItem(&dynDirectRegNames, regname2key(name), reg);
- if (IS_BITVAR (OP_SYM_ETYPE(op)))
- addSet(&dynDirectBitRegs, reg);
- else
- addSet(&dynDirectRegs, reg);
}
return reg;
debugAopGet (" left:", IC_LEFT (ic));
debugAopGet (" right:", IC_RIGHT (ic));
+ /* if this is at an absolute address, then get the address. */
+ if (SPEC_ABSA ( OP_SYM_ETYPE(IC_RESULT(ic))) ) {
+ if(IS_CONFIG_ADDRESS( SPEC_ADDR ( OP_SYM_ETYPE(IC_RESULT(ic))))) {
+ debugLog (" %d - found config word declaration\n", __LINE__);
+ if(IS_VALOP(IC_RIGHT(ic))) {
+ debugLog (" setting config word to %x\n",
+ (int) floatFromVal (IC_RIGHT(ic)->operand.valOperand));
+ assignConfigWordValue( SPEC_ADDR ( OP_SYM_ETYPE(IC_RESULT(ic))),
+ (int) floatFromVal (IC_RIGHT(ic)->operand.valOperand));
+ }
+
+ /* remove the assignment from the iCode chain. */
+
+ remiCodeFromeBBlock (ebp, ic);
+ bitVectUnSetBit(OP_SYMBOL(IC_RESULT(ic))->defs,ic->key);
+ hTabDeleteItem (&iCodehTab, ic->key, ic, DELETE_ITEM, NULL);
+
+ return 1;
+
+ }
+ }
+
if (!IS_ITEMP (IC_RESULT (ic))) {
allocDirReg(IC_RESULT (ic));
debugLog (" %d - result is not temp\n", __LINE__);