int pic16_getpCodePeepCommand(char *cmd);
void pic16_pBlockMergeLabels(pBlock *pb);
char *pic16_pCode2str(char *str, int size, pCode *pc);
-char *pic16_get_op( pCodeOp *pcop,char *buf,int buf_size);
+//char *pic16_get_op(pCodeOp *pcop,char *buf, size_t buf_size);
pCodeOp *pic16_popCombine2(pCodeOp *, pCodeOp *, int);
extern pCodeInstruction *pic16Mnemonics[];
// just check first letter for now
- if(toupper(*pp->pct[0].tok.s) == 'F')
+ if(toupper((unsigned char)*pp->pct[0].tok.s) == 'F')
return 1;
} else if (pp->pct[0].tt == PCT_NUMBER) {
if(len == 1) {
// check C,Z
- if(toupper(*bit) == 'C')
+ if(toupper((unsigned char)*bit) == 'C')
return PCOP(pic16_popCopyGPR2Bit(&pic16_pc_status,PIC_C_BIT));
- if(toupper(*bit) == 'Z')
+ if(toupper((unsigned char)*bit) == 'Z')
return PCOP(pic16_popCopyGPR2Bit(&pic16_pc_status,PIC_Z_BIT));
}
// Check DC
- if(len ==2 && toupper(bit[0]) == 'D' && toupper(bit[1]) == 'C')
+ if(len ==2 && toupper((unsigned char)bit[0]) == 'D' && toupper((unsigned char)bit[1]) == 'C')
return PCOP(pic16_popCopyGPR2Bit(&pic16_pc_status,PIC_DC_BIT));
return NULL;
// fprintf(stderr, "%s:%d: processing %s\n", __FILE__, __LINE__, ln);
while(*ln) {
- if(isspace(*ln)) {
+ if(isspace((unsigned char)*ln)) {
// add a SPACE token and eat the extra spaces.
tokArr[tokIdx++].tt = PCT_SPACE;
- while (isspace (*ln))
+ while (isspace ((unsigned char)*ln))
ln++;
continue;
}
- if(isdigit(*ln)) {
+ if(isdigit((unsigned char)*ln)) {
tokArr[tokIdx].tt = PCT_NUMBER;
tokArr[tokIdx++].tok.n = strtol(ln, &ln, 0);
default: // hack to allow : goto $
- if(isalpha(*ln) || (*ln == '_') || (!parsing_peeps && (*ln == '$'))) {
+ if(isalpha((unsigned char)*ln) || (*ln == '_') || (!parsing_peeps && (*ln == '$'))) {
char buffer[50];
int i=0;
- while( (isalpha(*ln) || isdigit(*ln) || (*ln == '_') || (*ln == '$')) && i<49)
+ while( (isalpha((unsigned char)*ln) || isdigit((unsigned char)*ln) || (*ln == '_') || (*ln == '$')) && i<49)
buffer[i++] = *ln++;
ln--;
*-----------------------------------------------------------------*/
static int pCodeOpCompare(pCodeOp *pcops, pCodeOp *pcopd)
{
- char b[50], *n2;
+ char b[1024], *n2;
if(!pcops || !pcopd)
return 0;
return 0;
}
- b[0]=0;
- pic16_get_op(pcops,b,50);
+ memset(b, 0, sizeof(b) ); //b[0]=0;
+ pic16_get_op(pcops,b, sizeof(b) );
n2 = pic16_get_op(pcopd,NULL,0);
/* Compare the operands */
if(PCI(pcd)->pcop) {
- if (PCI(pcd)->pcop->type == PO_WILD) {
+ /* assert that optimizations do not touch operations that work on SFRs or INDF registers */
+ if ((PCI(pcd)->pcop->type == PO_WILD) && (!(PCI(pcs)->pcop) || ((PCI(pcs)->pcop->type != PO_SFR_REGISTER) && (PCI(pcs)->pcop->type != PO_INDF0)))) {
index = PCOW(PCI(pcd)->pcop)->id;
//DFPRINTF((stderr,"destination is wild\n"));
#ifdef DEBUG_PCODEPEEP
// return 1;
}
}
-
+
/* now check whether the second operand matches */
- if(PCOW2(PCI(pcd)->pcop) && (PCOR2(PCI(pcd)->pcop)->pcop2->type == PO_WILD)) {
+ /* assert that optimizations do not touch operations that work on SFRs or INDF registers */
+ if(PCOW2(PCI(pcd)->pcop) && (PCOR2(PCI(pcd)->pcop)->pcop2->type == PO_WILD) && (!(PCOR2(PCI(pcs)->pcop)->pcop2) || ((PCOR2(PCI(pcs)->pcop)->pcop2->type != PO_SFR_REGISTER) && (PCOR2(PCI(pcs)->pcop)->pcop2) && (PCOR2(PCI(pcs)->pcop)->pcop2->type != PO_INDF0)))) {
// fprintf(stderr, "%s:%d %s second operand is wild\n", __FILE__, __LINE__, __FUNCTION__);
}
}
- } else return (havematch);
+ } else if (PCOW2(PCI(pcd)->pcop) && (PCOR2(PCI(pcd)->pcop)->pcop2->type == PO_WILD) && PCOR2(PCI(pcs)->pcop)->pcop2)
+ {
+ return 0;
+ } else {
+ return havematch;
+ }
#if 0
else if (PCI(pcd)->pcop->type == PO_LITERAL) {
return (havematch &&
- pCodeOpCompare(PCOR2(PCI(pcs)->pcop)->pcop2, PCOR2(PCI(pcd)->pcop)->pcop2);
+ pCodeOpCompare(PCOR2(PCI(pcs)->pcop)->pcop2, PCOR2(PCI(pcd)->pcop)->pcop2));
}
#endif
case PO_GPR_TEMP:
case PO_FSR0:
case PO_INDF0:
+ case PO_WREG: // moved from below
+ case PO_PRODL: // moved from below
+ case PO_PRODH: // moved from below
//DFPRINTF((stderr,"pCodeOpCopy GPR register\n"));
pcopnew = Safe_calloc(1,sizeof(pCodeOpReg) );
PCOR(pcopnew)->r = PCOR(pcop)->r;
case PO_STR:
case PO_NONE:
case PO_W:
- case PO_WREG:
+ //case PO_WREG: // moved up
case PO_INTCON:
case PO_PCL:
case PO_PCLATH:
case PO_PCLATU:
- case PO_PRODL:
- case PO_PRODH:
+ //case PO_PRODL: // moved up
+ //case PO_PRODH: // moved up
case PO_REL_ADDR:
//DFPRINTF((stderr,"pCodeOpCopy register type %d\n", pcop->type));
pcopnew = Safe_calloc(1,sizeof(pCodeOp) );
pcin->prev = pc->prev;
-#if 0
+#if 1
{
/* DEBUG */
/* Converted the deleted pCodes into comments */
- char buf[256];
+ char buf[1024];
pCodeCSource *pc_cline2=NULL;
- buf[0] = ';';
- buf[1] = '#';
+// buf[0] = ';';
+ buf[0] = '#';
while(pc && pc!=pcin) {
}
}
- pic16_pCode2str(&buf[2], 254, pc);
+ pic16_pCode2str(&buf[1], sizeof( buf )-1, pc);
pic16_pCodeInsertAfter(pcprev, pic16_newpCodeCharP(buf));
pcprev = pcprev->next;
pc = pc->next;