#define STRCASECMP strcasecmp
#endif
+/****************************************************************/
+/****************************************************************/
+
+peepCommand peepCommands[] = {
+
+ {NOTBITSKIP, "_NOTBITSKIP_"},
+ {BITSKIP, "_BITSKIP_"},
+ {INVERTBITSKIP, "_INVERTBITSKIP_"},
+
+ {-1, NULL}
+};
+
+
// Eventually this will go into device dependent files:
pCodeOpReg pc_status = {{PO_STATUS, "STATUS"}, -1, NULL,0,NULL};
pCodeOpReg pc_pclath = {{PO_PCLATH, "PCLATH"}, -1, NULL,0,NULL};
pCodeOpReg pc_kzero = {{PO_GPR_REGISTER, "KZ"}, -1, NULL,0,NULL};
-pCodeOpReg pc_wsave = {{PO_GPR_REGISTER, "W_SAVE"}, -1, NULL,0,NULL};
-pCodeOpReg pc_ssave = {{PO_GPR_REGISTER, "STATUS_SAVE"}, -1, NULL,0,NULL};
+pCodeOpReg pc_wsave = {{PO_GPR_REGISTER, "WSAVE"}, -1, NULL,0,NULL};
+pCodeOpReg pc_ssave = {{PO_GPR_REGISTER, "SSAVE"}, -1, NULL,0,NULL};
static int mnemonics_initialized = 0;
static hTab *pic14MnemonicsHash = NULL;
+static hTab *pic14pCodePeepCommandsHash = NULL;
static pFile *the_pFile = NULL;
-static int peepOptimizing = 0;
+static int peepOptimizing = 1;
static int GpCodeSequenceNumber = 1;
static int GpcFlowSeq = 1;
#define isPCI(x) ((PCODE(x)->type == PC_OPCODE))
#define isPCI_BRANCH(x) ((PCODE(x)->type == PC_OPCODE) && PCI(x)->isBranch)
#define isPCI_SKIP(x) ((PCODE(x)->type == PC_OPCODE) && PCI(x)->isSkip)
+#define isPCI_BITSKIP(x)((PCODE(x)->type == PC_OPCODE) && PCI(x)->isSkip && PCI(x)->isBitInst)
#define isPCFL(x) ((PCODE(x)->type == PC_FLOW))
#define isPCF(x) ((PCODE(x)->type == PC_FUNCTION))
#define isCALL(x) ((isPCI(x)) && (PCI(x)->op == POC_CALL))
static void pCodePrintLabel(FILE *of, pCode *pc);
static void pCodePrintFunction(FILE *of, pCode *pc);
static void pCodeOpPrint(FILE *of, pCodeOp *pcop);
-static char *get_op( pCodeInstruction *pcc);
+static char *get_op_from_instruction( pCodeInstruction *pcc);
+char *get_op( pCodeOp *pcop);
int pCodePeepMatchLine(pCodePeep *peepBlock, pCode *pcs, pCode *pcd);
int pCodePeepMatchRule(pCode *pc);
void pBlockStats(FILE *of, pBlock *pb);
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_W | PCC_REGISTER), // inCond
(PCC_REGISTER | PCC_Z) // outCond
};
// genericAnalyze,
genericDestruct,
genericPrint},
- POC_ADDWF,
+ POC_ADDFW,
"ADDWF",
NULL, // from branch
NULL, // to branch
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_W | PCC_REGISTER), // inCond
(PCC_W | PCC_Z) // outCond
};
1, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_W, // inCond
(PCC_W | PCC_Z | PCC_C | PCC_DC) // outCond
};
1, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_W, // inCond
(PCC_W | PCC_Z) // outCond
};
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_W | PCC_REGISTER), // inCond
(PCC_REGISTER | PCC_Z) // outCond
};
// genericAnalyze,
genericDestruct,
genericPrint},
- POC_ANDWF,
+ POC_ANDFW,
"ANDWF",
NULL, // from branch
NULL, // to branch
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_W | PCC_REGISTER), // inCond
(PCC_W | PCC_Z) // outCond
};
2, // num ops
1,1, // dest, bit instruction
0,0, // branch, skip
+ POC_BSF,
PCC_REGISTER, // inCond
PCC_REGISTER // outCond
};
2, // num ops
1,1, // dest, bit instruction
0,0, // branch, skip
+ POC_BCF,
PCC_REGISTER, // inCond
PCC_REGISTER // outCond
};
2, // num ops
0,1, // dest, bit instruction
1,1, // branch, skip
+ POC_BTFSS,
PCC_REGISTER, // inCond
PCC_NONE // outCond
};
2, // num ops
0,1, // dest, bit instruction
1,1, // branch, skip
+ POC_BTFSC,
PCC_REGISTER, // inCond
PCC_NONE // outCond
};
1, // num ops
0,0, // dest, bit instruction
1,0, // branch, skip
+ POC_NOP,
PCC_NONE, // inCond
PCC_NONE // outCond
};
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_REGISTER // outCond
};
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_W // outCond
};
1, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_REGISTER // outCond
};
0, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_W, // inCond
PCC_W // outCond
};
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_REGISTER // outCond
};
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_W // outCond
};
2, // num ops
1,0, // dest, bit instruction
1,1, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_REGISTER // outCond
};
2, // num ops
0,0, // dest, bit instruction
1,1, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_W // outCond
};
1, // num ops
0,0, // dest, bit instruction
1,0, // branch, skip
+ POC_NOP,
PCC_NONE, // inCond
PCC_NONE // outCond
};
-
pCodeInstruction pciINCF = {
{PC_OPCODE, NULL, NULL, 0, NULL,
// genericAnalyze,
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_REGISTER // outCond
};
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_W // outCond
};
2, // num ops
1,0, // dest, bit instruction
1,1, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_REGISTER // outCond
};
2, // num ops
0,0, // dest, bit instruction
1,1, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_W // outCond
};
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_W | PCC_REGISTER), // inCond
(PCC_REGISTER | PCC_Z) // outCond
};
// genericAnalyze,
genericDestruct,
genericPrint},
- POC_IORWF,
+ POC_IORFW,
"IORWF",
NULL, // from branch
NULL, // to branch
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_W | PCC_REGISTER), // inCond
(PCC_W | PCC_Z) // outCond
};
1, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_W, // inCond
(PCC_W | PCC_Z) // outCond
};
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
PCC_Z // outCond
};
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_REGISTER, // inCond
(PCC_W | PCC_Z) // outCond
};
1, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_W, // inCond
PCC_REGISTER // outCond
};
1, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_NONE, // inCond
PCC_W // outCond
};
0, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_NONE, // inCond
PCC_NONE // outCond
};
0, // num ops
0,0, // dest, bit instruction
1,0, // branch, skip
+ POC_NOP,
PCC_NONE, // inCond
PCC_NONE // outCond (not true... affects the GIE bit too)
};
1, // num ops
0,0, // dest, bit instruction
1,0, // branch, skip
+ POC_NOP,
PCC_NONE, // inCond
PCC_W // outCond
};
0, // num ops
0,0, // dest, bit instruction
1,0, // branch, skip
+ POC_NOP,
PCC_NONE, // inCond
PCC_NONE // outCond
};
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_C | PCC_REGISTER), // inCond
(PCC_REGISTER | PCC_Z | PCC_C | PCC_DC) // outCond
};
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_C | PCC_REGISTER), // inCond
(PCC_W | PCC_Z | PCC_C | PCC_DC) // outCond
};
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_C | PCC_REGISTER), // inCond
(PCC_REGISTER | PCC_Z | PCC_C | PCC_DC) // outCond
};
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_C | PCC_REGISTER), // inCond
(PCC_W | PCC_Z | PCC_C | PCC_DC) // outCond
};
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_W | PCC_REGISTER), // inCond
(PCC_REGISTER | PCC_Z) // outCond
};
// genericAnalyze,
genericDestruct,
genericPrint},
- POC_SUBWF,
+ POC_SUBFW,
"SUBWF",
NULL, // from branch
NULL, // to branch
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_W | PCC_REGISTER), // inCond
(PCC_W | PCC_Z) // outCond
};
1, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_W, // inCond
(PCC_W | PCC_Z | PCC_C | PCC_DC) // outCond
};
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_REGISTER), // inCond
(PCC_REGISTER) // outCond
};
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_REGISTER), // inCond
(PCC_W) // outCond
};
1, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_NONE, // inCond
PCC_REGISTER // outCond
};
2, // num ops
1,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_W | PCC_REGISTER), // inCond
(PCC_REGISTER | PCC_Z) // outCond
};
// genericAnalyze,
genericDestruct,
genericPrint},
- POC_XORWF,
+ POC_XORFW,
"XORWF",
NULL, // from branch
NULL, // to branch
2, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
(PCC_W | PCC_REGISTER), // inCond
(PCC_W | PCC_Z) // outCond
};
1, // num ops
0,0, // dest, bit instruction
0,0, // branch, skip
+ POC_NOP,
PCC_W, // inCond
(PCC_W | PCC_Z | PCC_C | PCC_DC) // outCond
};
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 void init_pic(void);
+extern void init_pic(char *);
void pCodeInitRegisters(void)
{
initStack(0x38, 8);
- init_pic();
+ init_pic(port->processor);
pc_status.r = allocProcessorRegister(IDX_STATUS,"STATUS", PO_STATUS, 0x80);
pc_pcl.r = allocProcessorRegister(IDX_PCL,"PCL", PO_PCL, 0x80);
if(mnemonics_initialized)
return;
+//FIXME - probably should NULL out the array before making the assignments
+//since we check the array contents below this initialization.
+
pic14Mnemonics[POC_ADDLW] = &pciADDLW;
pic14Mnemonics[POC_ADDWF] = &pciADDWF;
pic14Mnemonics[POC_ADDFW] = &pciADDFW;
mnemonics_initialized = 1;
}
+int getpCodePeepCommand(char *cmd);
+
int getpCode(char *mnem,unsigned dest)
{
return -1;
}
+/*-----------------------------------------------------------------*
+ * pic14initpCodePeepCommands
+ *
+ *-----------------------------------------------------------------*/
+void pic14initpCodePeepCommands(void)
+{
+
+ int key, i;
+ peepCommand *pcmd;
+
+ i = 0;
+ do {
+ hTabAddItem(&pic14pCodePeepCommandsHash,
+ mnem2key(peepCommands[i].cmd), &peepCommands[i]);
+ i++;
+ } while (peepCommands[i].cmd);
+
+ pcmd = hTabFirstItem(pic14pCodePeepCommandsHash, &key);
+
+ while(pcmd) {
+ //fprintf(stderr, "peep command %s key %d\n",pcmd->cmd,pcmd->id);
+ pcmd = hTabNextItem(pic14pCodePeepCommandsHash, &key);
+ }
+
+}
+
+/*-----------------------------------------------------------------
+ *
+ *
+ *-----------------------------------------------------------------*/
+
+int getpCodePeepCommand(char *cmd)
+{
+
+ peepCommand *pcmd;
+ int key = mnem2key(cmd);
+
+
+ pcmd = hTabFirstItemWK(pic14pCodePeepCommandsHash, key);
+
+ while(pcmd) {
+ // fprintf(stderr," comparing %s to %s\n",pcmd->cmd,cmd);
+ if(STRCASECMP(pcmd->cmd, cmd) == 0) {
+ return pcmd->id;
+ }
+
+ pcmd = hTabNextItemWK (pic14pCodePeepCommandsHash);
+
+ }
+
+ return -1;
+}
+
char getpBlock_dbName(pBlock *pb)
{
if(!pb)
pcw->operand = optional_operand;
pcw->label = optional_label;
+ pcw->mustBeBitSkipInst = 0;
+ pcw->mustNotBeBitSkipInst = 0;
+ pcw->invertBitSkipInst = 0;
+
return ( (pCode *)pcw);
+}
+
+ /*-----------------------------------------------------------------*/
+/* newPcodeInlineP - create a new pCode from a char string */
+/*-----------------------------------------------------------------*/
+
+
+pCode *newpCodeInlineP(char *cP)
+{
+
+ pCodeComment *pcc ;
+
+ pcc = Safe_calloc(1,sizeof(pCodeComment));
+
+ pcc->pc.type = PC_INLINE;
+ pcc->pc.prev = pcc->pc.next = NULL;
+ //pcc->pc.from = pcc->pc.to = pcc->pc.label = NULL;
+ pcc->pc.pb = NULL;
+
+ // pcc->pc.analyze = genericAnalyze;
+ pcc->pc.destruct = genericDestruct;
+ pcc->pc.print = genericPrint;
+
+ if(cP)
+ pcc->comment = Safe_strdup(cP);
+ else
+ pcc->comment = NULL;
+
+ return ( (pCode *)pcc);
+
}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
-pCodeOp *newpCodeOpImmd(char *name, int offset)
+pCodeOp *newpCodeOpImmd(char *name, int offset, int index, int code_space)
{
pCodeOp *pcop;
-
pcop = Safe_calloc(1,sizeof(pCodeOpImmd) );
pcop->type = PO_IMMEDIATE;
if(name) {
pcop->name = Safe_strdup(name);
+ //fprintf(stderr,"%s %s %d\n",__FUNCTION__,name,offset);
} else {
pcop->name = NULL;
}
+ PCOI(pcop)->index = index;
PCOI(pcop)->offset = offset;
+ PCOI(pcop)->_const = code_space;
return pcop;
}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
-pCodeOp *newpCodeOpWild(int id, pCodePeep *pcp, pCodeOp *subtype)
+pCodeOp *newpCodeOpWild(int id, pCodeWildBlock *pcwb, pCodeOp *subtype)
{
char *s = buffer;
pCodeOp *pcop;
- if(!pcp || !subtype) {
+ if(!pcwb || !subtype) {
fprintf(stderr, "Wild opcode declaration error: %s-%d\n",__FILE__,__LINE__);
exit(1);
}
pcop->name = Safe_strdup(s);
PCOW(pcop)->id = id;
- PCOW(pcop)->pcp = pcp;
+ PCOW(pcop)->pcwb = pcwb;
PCOW(pcop)->subtype = subtype;
PCOW(pcop)->matched = NULL;
return pcop;
}
+/*-----------------------------------------------------------------*
+ * pCodeOp *newpCodeOpReg(int rIdx) - allocate a new register
+ *
+ * If rIdx >=0 then a specific register from the set of registers
+ * will be selected. If rIdx <0, then a new register will be searched
+ * for.
+ *-----------------------------------------------------------------*/
+
pCodeOp *newpCodeOpReg(int rIdx)
{
pCodeOp *pcop;
pcop = Safe_calloc(1,sizeof(pCodeOpReg) );
pcop->name = NULL;
- PCOR(pcop)->rIdx = rIdx;
- PCOR(pcop)->r = pic14_regWithIdx(rIdx);
+
+ if(rIdx >= 0) {
+ PCOR(pcop)->rIdx = rIdx;
+ PCOR(pcop)->r = pic14_regWithIdx(rIdx);
+ } else {
+ PCOR(pcop)->r = pic14_findFreeReg(REG_GPR);
+
+ if(PCOR(pcop)->r)
+ PCOR(pcop)->rIdx = PCOR(pcop)->r->rIdx;
+ //fprintf(stderr, "newpcodeOpReg - rIdx = %d\n", PCOR(pcop)->r->rIdx);
+ }
+
pcop->type = PCOR(pcop)->r->pc_type;
return pcop;
}
+
pCodeOp *newpCodeOpRegFromStr(char *name)
{
pCodeOp *pcop;
pcop = Safe_calloc(1,sizeof(pCodeOpReg) );
- PCOR(pcop)->r = allocRegByName(name);
+ PCOR(pcop)->r = allocRegByName(name, 1);
PCOR(pcop)->rIdx = PCOR(pcop)->r->rIdx;
pcop->type = PCOR(pcop)->r->pc_type;
pcop->name = PCOR(pcop)->r->name;
case PO_LABEL:
pcop = newpCodeOpLabel(NULL,-1);
break;
+ case PO_GPR_TEMP:
+ pcop = newpCodeOpReg(-1);
+ break;
default:
pcop = Safe_calloc(1,sizeof(pCodeOp) );
}
-static char *get_op( pCodeInstruction *pcc)
+/*-----------------------------------------------------------------*/
+/*-----------------------------------------------------------------*/
+char *get_op(pCodeOp *pcop)
{
regs *r;
static char buffer[50];
char *s;
int size;
- if(pcc && pcc->pcop) {
-
- switch(pcc->pcop->type) {
+ if(pcop) {
+ switch(pcop->type) {
case PO_INDF:
case PO_FSR:
//fprintf(stderr,"get_op getting register name rIdx=%d\n",PCOR(pcc->pcop)->rIdx);
//r = pic14_regWithIdx(PCOR(pcc->pcop)->rIdx);
//return r->name;
- return PCOR(pcc->pcop)->r->name;
+ return PCOR(pcop)->r->name;
break;
case PO_GPR_TEMP:
- r = pic14_regWithIdx(PCOR(pcc->pcop)->r->rIdx);
+ r = pic14_regWithIdx(PCOR(pcop)->r->rIdx);
//fprintf(stderr,"getop: getting %s\nfrom:\n",r->name); //pcc->pcop->name);
- pBlockRegs(stderr,pcc->pc.pb);
return r->name;
// case PO_GPR_BIT:
case PO_IMMEDIATE:
s = buffer;
size = sizeof(buffer);
- if( PCOI(pcc->pcop)->offset && PCOI(pcc->pcop)->offset<4) {
- SAFE_snprintf(&s,&size,"((%s >> %d)&0xff)",
- pcc->pcop->name,
- 8 * PCOI(pcc->pcop)->offset );
- } else
- SAFE_snprintf(&s,&size,"LOW(%s)",pcc->pcop->name);
-
+ //fprintf(stderr,"PO_IMMEDIATE name = %s offset = %d\n",pcc->pcop->name,PCOI(pcc->pcop)->offset);
+ if(PCOI(pcop)->_const) {
+
+ if( PCOI(pcop)->offset && PCOI(pcop)->offset<4) {
+ SAFE_snprintf(&s,&size,"(((%s+%d) >> %d)&0xff)",
+ pcop->name,
+ PCOI(pcop)->index,
+ 8 * PCOI(pcop)->offset );
+ } else
+ SAFE_snprintf(&s,&size,"LOW(%s+%d)",pcop->name,PCOI(pcop)->index);
+ } else {
+ if( PCOI(pcop)->index) { // && PCOI(pcc->pcop)->offset<4) {
+ SAFE_snprintf(&s,&size,"(%s + %d)",
+ pcop->name,
+ PCOI(pcop)->index );
+ } else
+ SAFE_snprintf(&s,&size,"%s",pcop->name);
+ }
+
+ return buffer;
+
+ case PO_DIR:
+ s = buffer;
+ size = sizeof(buffer);
+ if( PCOR(pcop)->instance) {
+ SAFE_snprintf(&s,&size,"(%s + %d)",
+ pcop->name,
+ PCOR(pcop)->instance );
+ //fprintf(stderr,"PO_DIR %s\n",buffer);
+ } else
+ SAFE_snprintf(&s,&size,"%s",pcop->name);
return buffer;
default:
- if (pcc->pcop->name)
- return pcc->pcop->name;
+ if (pcop->name)
+ return pcop->name;
}
}
return "NO operand";
+
+}
+
+/*-----------------------------------------------------------------*/
+/*-----------------------------------------------------------------*/
+static char *get_op_from_instruction( pCodeInstruction *pcc)
+{
+
+ if(pcc )
+ return get_op(pcc->pcop);
+
+ return ("ERROR Null: "__FUNCTION__);
+
}
/*-----------------------------------------------------------------*/
PCI(pc)->pcop->name ,
PCI(pc)->pcop->name );
else
- SAFE_snprintf(&s,&size,"%s,%d", get_op(PCI(pc)),
+ SAFE_snprintf(&s,&size,"%s,%d", get_op_from_instruction(PCI(pc)),
(((pCodeOpRegBit *)(PCI(pc)->pcop))->bit ));
} else if(PCI(pc)->pcop->type == PO_GPR_BIT) {
- SAFE_snprintf(&s,&size,"%s,%d", get_op(PCI(pc)),PCORB(PCI(pc)->pcop)->bit);
+ SAFE_snprintf(&s,&size,"%s,%d", get_op_from_instruction(PCI(pc)),PCORB(PCI(pc)->pcop)->bit);
}else
- SAFE_snprintf(&s,&size,"%s,0 ; ?bug", get_op(PCI(pc)));
+ SAFE_snprintf(&s,&size,"%s,0 ; ?bug", get_op_from_instruction(PCI(pc)));
//PCI(pc)->pcop->t.bit );
} else {
if(PCI(pc)->pcop->type == PO_GPR_BIT) {
if( PCI(pc)->num_ops == 2)
- SAFE_snprintf(&s,&size,"(%s >> 3),%c",get_op(PCI(pc)),((PCI(pc)->isModReg) ? 'F':'W'));
+ SAFE_snprintf(&s,&size,"(%s >> 3),%c",get_op_from_instruction(PCI(pc)),((PCI(pc)->isModReg) ? 'F':'W'));
else
- SAFE_snprintf(&s,&size,"(1 << (%s & 7))",get_op(PCI(pc)));
+ SAFE_snprintf(&s,&size,"(1 << (%s & 7))",get_op_from_instruction(PCI(pc)));
}else {
- SAFE_snprintf(&s,&size,"%s",get_op(PCI(pc)));
+ SAFE_snprintf(&s,&size,"%s",get_op_from_instruction(PCI(pc)));
if( PCI(pc)->num_ops == 2)
SAFE_snprintf(&s,&size,",%c", ( (PCI(pc)->isModReg) ? 'F':'W'));
SAFE_snprintf(&s,&size,";%s", ((pCodeComment *)pc)->comment);
break;
+ case PC_INLINE:
+ /* assuming that inline code ends with a \n */
+ SAFE_snprintf(&s,&size,"%s", ((pCodeComment *)pc)->comment);
+ break;
+
case PC_LABEL:
SAFE_snprintf(&s,&size,";label=%s, key=%d\n",PCL(pc)->label,PCL(pc)->key);
break;
fprintf(of,";%s\n", ((pCodeComment *)pc)->comment);
break;
+ case PC_INLINE:
+ fprintf(of,"%s\n", ((pCodeComment *)pc)->comment);
+ break;
+
case PC_OPCODE:
// If the opcode has a label, print that first
{
case PO_BIT:
case PO_GPR_TEMP:
- fprintf(stderr, "getRegFromInstruction - bit or temp\n");
+ //fprintf(stderr, "getRegFromInstruction - bit or temp\n");
return PCOR(PCI(pc)->pcop)->r;
case PO_IMMEDIATE:
- fprintf(stderr, "getRegFromInstruction - immediate\n");
+ //fprintf(stderr, "getRegFromInstruction - immediate\n");
return NULL; // PCOR(PCI(pc)->pcop)->r;
case PO_GPR_BIT:
return PCOR(PCI(pc)->pcop)->r;
case PO_DIR:
- fprintf(stderr, "getRegFromInstruction - dir\n");
- //return NULL; PCOR(PCI(pc)->pcop)->r;
+ //fprintf(stderr, "getRegFromInstruction - dir\n");
return PCOR(PCI(pc)->pcop)->r;
case PO_LITERAL:
- fprintf(stderr, "getRegFromInstruction - literal\n");
+ //fprintf(stderr, "getRegFromInstruction - literal\n");
break;
default:
- fprintf(stderr, "getRegFromInstruction - unknown reg type %d\n",PCI(pc)->pcop->type);
- genericPrint(stderr, pc);
+ //fprintf(stderr, "getRegFromInstruction - unknown reg type %d\n",PCI(pc)->pcop->type);
+ //genericPrint(stderr, pc);
break;
}
}
/*-----------------------------------------------------------------*/
-/* popCopy - copy a pcode operator */
+/* popCopyGPR2Bit - copy a pcode operator */
/*-----------------------------------------------------------------*/
+
pCodeOp *popCopyGPR2Bit(pCodeOp *pc, int bitval)
{
pCodeOp *pcop;
int cur_bank;
regs *reg;
- return;
+ // return;
if(!pb)
return;
return;
/* loop through all of the flow blocks with in one pblock */
- // fprintf(stderr,"Register banking\n");
+ //fprintf(stderr,"Register banking\n");
cur_bank = 0;
do {
/* at this point, pc should point to a PC_FLOW object */
do {
if(isPCI(pc)) {
- genericPrint(stderr, pc);
+ //genericPrint(stderr, pc);
reg = getRegFromInstruction(pc);
- //#if 0
+ #if 0
if(reg) {
fprintf(stderr, " %s ",reg->name);
fprintf(stderr, "addr = 0x%03x, bank = %d\n",reg->address,REG_BANK(reg));
}
- //#endif
+ #endif
if(reg && REG_BANK(reg)!=cur_bank) {
/* Examine the instruction before this one to make sure it is
* not a skip type instruction */
pcprev = findPrevpCode(pc->prev, PC_OPCODE);
- if(pcprev && !isPCI_SKIP(pcprev)) {
+ if(!pcprev || (pcprev && !isPCI_SKIP(pcprev))) {
int b = cur_bank ^ REG_BANK(reg);
//fprintf(stderr, "Cool! can switch banks\n");
}
- } else
- fprintf(stderr, "Bummer can't switch banks\n");
+ } else {
+ //fprintf(stderr, "Bummer can't switch banks\n");
+ ;
+ }
}
}
if (PCF(pc)->fname) {
if(STRCASECMP(PCF(pc)->fname, "_main") == 0) {
- fprintf(stderr," found main \n");
+ //fprintf(stderr," found main \n");
pb->cmemmap = NULL; /* FIXME do we need to free ? */
pb->dbName = 'M';
}
while(pc) {
if(pc->type == PC_OPCODE && PCI(pc)->op == POC_CALL) {
- fprintf(of,"; %s\n",get_op(PCI(pc)));
+ fprintf(of,"; %s\n",get_op_from_instruction(PCI(pc)));
}
pc = setNextItem(pb->function_calls);
}
for( ; pc; pc = setNextItem(pb->function_calls)) {
if(pc->type == PC_OPCODE && PCI(pc)->op == POC_CALL) {
- char *dest = get_op(PCI(pc));
+ char *dest = get_op_from_instruction(PCI(pc));
pcn = findFunction(dest);
if(pcn)
for( ; pc; pc = setNextItem(pb->function_calls)) {
if(pc->type == PC_OPCODE && PCI(pc)->op == POC_CALL) {
- char *dest = get_op(PCI(pc));
+ char *dest = get_op_from_instruction(PCI(pc));
pcn = findFunction(dest);
if(pcn)
while(pc->next && !ispCodeFunction(pc->next)) {
pc = pc->next;
if(pc->type == PC_OPCODE && PCI(pc)->op == POC_CALL)
- fprintf(of,"\t%s\n",get_op(PCI(pc)));
+ fprintf(of,"\t%s\n",get_op_from_instruction(PCI(pc)));
}
}