0, // literal operand
POC_NOP,
PCC_NONE, // inCond /* FIXME: what's TRIS doing? */
- PCC_REGISTER // outCond /* FIXME: what's TIS doing */
+ PCC_REGISTER // outCond /* FIXME: what's TRIS doing */
};
pCodeInstruction pciXORWF = {
extern void initStack(int base_address, int size);
extern regs *allocProcessorRegister(int rIdx, char * name, short po_type, int alias);
-extern regs *allocInternalRegister(int rIdx, char * name, short po_type, int alias);
+extern regs *allocInternalRegister(int rIdx, char * name, PIC_OPTYPE po_type, int alias);
extern void init_pic(char *);
void pCodeInitRegisters(void)
initialized = 1;
init_pic(port->processor);
- shareBankAddress = 0x7f; /* FIXME - some PIC ICs like 16C7X which do not have a shared bank need a different approach. */
- if ((unsigned)shareBankAddress > getMaxRam()) /* If total RAM is less than 0x7f as with 16f84 then reduce shareBankAddress to fit */
- shareBankAddress = (int)getMaxRam();
- stkSize = 15; /* Set pseudo stack size to 15, on multi memory bank ICs this leaves room for WSAVE (used for interrupts) to fit into the shared portion of the memory bank */
- initStack(shareBankAddress, stkSize); /* Putting the pseudo stack in shared memory so all modules use the same register when passing fn parameters */
+ /* FIXME - some PIC ICs like 16C7X which do not have a shared bank
+ * need a different approach.
+ * The fixed address might not be needed anyway, possibly the
+ * linker will assign udata_shr sections correctly... */
+ shareBankAddress = pic14_getSharebankAddress();
+ /* Set pseudo stack size to SHAREBANKSIZE - 3.
+ * On multi memory bank ICs this leaves room for WSAVE/SSAVE/PSAVE
+ * (used for interrupts) to fit into the shared portion of the
+ * memory bank */
+ stkSize = pic14_getSharebankSize()-3;
+ /* Putting the pseudo stack in shared memory so all modules use the same register when passing fn parameters */
+ initStack(shareBankAddress, stkSize);
pc_status.r = allocProcessorRegister(IDX_STATUS,"STATUS", PO_STATUS, 0x180);
pc_pcl.r = allocProcessorRegister(IDX_PCL,"PCL", PO_PCL, 0x80);
for(i=0; i<MAX_PIC14MNEMONICS; i++)
if(pic14Mnemonics[i])
- hTabAddItem(&pic14MnemonicsHash, mnem2key(pic14Mnemonics[i]->mnemonic), pic14Mnemonics[i]);
+ hTabAddItem(&pic14MnemonicsHash, mnem2key((unsigned char *)pic14Mnemonics[i]->mnemonic), pic14Mnemonics[i]);
pci = hTabFirstItem(pic14MnemonicsHash, &key);
while(pci) {
{
pCodeInstruction *pci;
- int key = mnem2key(mnem);
+ int key = mnem2key((unsigned char *)mnem);
if(!mnemonics_initialized)
pic14initMnemonics();
i = 0;
do {
hTabAddItem(&pic14pCodePeepCommandsHash,
- mnem2key(peepCommands[i].cmd), &peepCommands[i]);
+ mnem2key((unsigned char *)peepCommands[i].cmd), &peepCommands[i]);
i++;
} while (peepCommands[i].cmd);
{
peepCommand *pcmd;
- int key = mnem2key(cmd);
+ int key = mnem2key((unsigned char *)cmd);
pcmd = hTabFirstItemWK(pic14pCodePeepCommandsHash, key);
PCI(pc)->pcflow = PCFL(pflow);
//fprintf(stderr," build: ");
+ //pc->print(stderr, pc);
//pflow->print(stderr,pflow);
if (checkLabel(pc)) {
void LinkFlow_pCode(pCodeInstruction *from, pCodeInstruction *to)
{
pCodeFlowLink *fromLink, *toLink;
-
+#if 0
+ fprintf(stderr, "%s: linking ", __FUNCTION__ );
+ if (from) from->pc.print(stderr, &from->pc);
+ else fprintf(stderr, "(null)");
+ fprintf(stderr, " -(%u)-> with -(%u)-> ",
+ from && from->pcflow ? from->pcflow->pc.seq : 0,
+ to && to->pcflow ? to->pcflow->pc.seq : 0);
+ if (to) to->pc.print(stderr, &to->pc);
+ else fprintf(stderr, "(null)");
+#endif
+
if(!from || !to || !to->pcflow || !from->pcflow)
return;
/* find last instruction in flow */
pc = findPrevInstruction (PCFL(pcflow)->end);
- if (!pc) continue;
+ if (!pc) {
+ fprintf(stderr, "%s: flow without end (%u)?\n",
+ __FUNCTION__, pcflow->seq );
+ continue;
+ }
//fprintf(stderr, "LinkFlow - flow block (seq=%d) ", pcflow->seq);
+ //pc->print(stderr, pc);
if(isPCI_SKIP(pc)) {
//fprintf(stderr, "ends with skip\n");
//pc->print(stderr,pc);
//pc->print(stderr,pc);
if(!(pcol && isPCOLAB(pcol))) {
- if((PCI(pc)->op != POC_RETLW) && (PCI(pc)->op != POC_RETURN) && (PCI(pc)->op != POC_CALL) && (PCI(pc)->op != POC_RETFIE) ) {
+ if((PCI(pc)->op != POC_RETLW)
+ && (PCI(pc)->op != POC_RETURN)
+ && (PCI(pc)->op != POC_CALL)
+ && (PCI(pc)->op != POC_RETFIE) )
+ {
pc->print(stderr,pc);
fprintf(stderr, "ERROR: %s, branch instruction doesn't have label\n",__FUNCTION__);
}
- continue;
- }
-
- if( (pct = findLabelinpBlock(pb,pcol)) != NULL)
- LinkFlow_pCode(PCI(pc),PCI(pct));
- else
- fprintf(stderr, "ERROR: %s, couldn't find label. key=%d,lab=%s\n",
- __FUNCTION__,pcol->key,((PCOP(pcol)->name)?PCOP(pcol)->name:"-"));
- //fprintf(stderr,"newpCodeOpLabel: key=%d, name=%s\n",key,((s)?s:""));
+ } else {
+ if( (pct = findLabelinpBlock(pb,pcol)) != NULL)
+ LinkFlow_pCode(PCI(pc),PCI(pct));
+ else
+ fprintf(stderr, "ERROR: %s, couldn't find label. key=%d,lab=%s\n",
+ __FUNCTION__,pcol->key,((PCOP(pcol)->name)?PCOP(pcol)->name:"-"));
+ //fprintf(stderr,"newpCodeOpLabel: key=%d, name=%s\n",key,((s)?s:""));
+ }
/* link CALLs to next instruction */
if (PCI(pc)->op != POC_CALL) continue;
}
}
if(pc) {
- fprintf(stderr, "ends with unknown\n");
- pc->print(stderr,pc);
+ //fprintf(stderr, "ends with unknown\n");
+ //pc->print(stderr,pc);
continue;
}
insertBankSel(pci, reg->name); // Let linker choose the bank selection
} else if ((cur_bank == -1)||(cur_bank == 'L')||(cur_bank == 'E')) { // Current bank unknown and new register bank is known then can set bank bits
insertBankSwitch(pci, bank&1, PIC_RP0_BIT);
- if (getMaxRam()&0x100)
+ if (pic14_getMaxRam()&0x100)
insertBankSwitch(pci, bank&2, PIC_RP1_BIT);
} else { // Current bank and new register banks known - can set bank bits
switch((cur_bank^bank) & 3) {
break;
case 3:
insertBankSwitch(pci, bank&1, PIC_RP0_BIT);
- if (getMaxRam()&0x100)
+ if (pic14_getMaxRam()&0x100)
insertBankSwitch(pci, bank&2, PIC_RP1_BIT);
break;
}
pBlock *pb;
if(!picIsInitialized()) {
- setDefMaxRam(); // Max RAM has not been included, so use default setting
+ werror(E_FILE_OPEN_ERR, "no memory size is known for this processor");
+ exit(1);
}
if (!the_pFile) return;
void ReuseReg(void)
{
pBlock *pb;
- InitReuseReg();
if (!the_pFile) return;
+ InitReuseReg();
for(pb = the_pFile->pbHead; pb; pb = pb->next) {
/* Non static functions can be called from other modules so their registers must reassign */
if (pb->function_entries&&(PCF(setFirstItem(pb->function_entries))->isPublic||!pb->visited))