pcor->r = pc->r;
pcor->rIdx = pc->rIdx;
+ //DEBUGpic14_emitcode ("; ***","%s , copying %s, rIdx=%d",__FUNCTION__,pc->pcop.name,pc->rIdx);
return PCOP(pcor);
}
PCOR(pcop)->r = pic14_regWithIdx(rIdx);
pcop->type = PCOR(pcop)->r->pc_type;
rs = aop->aopu.aop_reg[offset]->name;
+ //DEBUGpic14_emitcode(";","%d regiser idx = %d name =%s",__LINE__,rIdx,rs);
return pcop;
}
if ( AOP_TYPE(oper) != AOP_ACC) {
emitpcode(POC_MOVFW,popGet(AOP(oper),0));
- pic14_emitcode("movf","%s,w",aopGet(AOP(oper),0,FALSE,FALSE));
}
while (size--) {
emitpcode(POC_IORFW, popGet(AOP(oper),offset++));
}
else { /* we need to get it byte by byte */
+ emitpcode(POC_MOVFW,popGet(AOP(left),0));
+ emitpcode(POC_MOVWF,popCopyReg(&pc_fsr));
+
size = AOP_SIZE(result);
offset = 0 ;
/* hack hack! see if this the FSR. If so don't load W */
if(AOP_TYPE(right) != AOP_ACC) {
- if(size==2)
- emitpcode(POC_DECF,popCopyReg(&pc_fsr));
+ emitpcode(POC_MOVFW,popGet(AOP(result),0));
+ emitpcode(POC_MOVWF,popCopyReg(&pc_fsr));
- if(size==4) {
- emitpcode(POC_MOVLW,popGetLit(0xfd));
- emitpcode(POC_ADDWF,popCopyReg(&pc_fsr));
- }
+ //if(size==2)
+ //emitpcode(POC_DECF,popCopyReg(&pc_fsr));
+ //if(size==4) {
+ // emitpcode(POC_MOVLW,popGetLit(0xfd));
+ // emitpcode(POC_ADDWF,popCopyReg(&pc_fsr));
+ //}
while(size--) {
emitpcode(POC_MOVFW,popGet(AOP(right),offset++));
lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
if( AOP_TYPE(right) == AOP_DIR && (AOP_TYPE(result) == AOP_REG) && size==1) {
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
if(aopIdx(AOP(result),0) == 4) {
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
emitpcode(POC_MOVFW, popGet(AOP(right),offset));
emitpcode(POC_MOVWF, popGet(AOP(result),offset));
goto release;
know_W=-1;
while (size--) {
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
if(AOP_TYPE(right) == AOP_LIT) {
if(lit&0xff) {
if(know_W != (lit&0xff))
emitpcode(POC_INCF, popGet(AOP(result),0));
}
} else {
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
emitpcode(POC_MOVFW, popGet(AOP(right),offset));
emitpcode(POC_MOVWF, popGet(AOP(result),offset));
}
static pFile *the_pFile = NULL;
-static int peepOptimizing = 1;
+static int peepOptimizing = 0;
static int GpCodeSequenceNumber = 1;
/****************************************************************/
pc_fsr.rIdx = 4;
pc_fsr.r = pic14_regWithIdx(4);
+ pc_indf.rIdx = 0;
+ pc_indf.r = pic14_regWithIdx(0);
+
}
/*-----------------------------------------------------------------*/
switch(pcc->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;
break;
{
char *n;
+ fprintf(stderr,"line %d\n",__LINE__);
switch(PCI(pcs)->pcop->type) {
case PO_GPR_TEMP:
case PO_FSR:
+ //case PO_INDF:
n = PCOR(PCI(pcs)->pcop)->r->name;
+
break;
default:
+ fprintf(stderr,"line %d\n",__LINE__);
n = PCI(pcs)->pcop->name;
}
case PO_GPR_REGISTER:
case PO_GPR_TEMP:
case PO_GPR_BIT:
+ case PO_FSR:
+ case PO_INDF:
fprintf(stderr,"pCodeOpCopy GPR register\n");
pcopnew = Safe_calloc(1,sizeof(pCodeOpReg) );
PCOR(pcopnew)->r = PCOR(pcop)->r;
case PO_NONE:
case PO_W:
case PO_STATUS:
- case PO_FSR:
- case PO_INDF:
case PO_PCL:
case PO_PCLATH:
{REG_STK, PO_GPR_TEMP, 0x46, "r0x46", "r0x46", 0x46, 1, 0},
{REG_STK, PO_GPR_TEMP, 0x47, "r0x47", "r0x47", 0x47, 1, 0},
- {REG_PTR, PO_FSR, 4, "FSR", "FSR", 4, 1, 0},
+ {REG_STK, PO_FSR, 4, "FSR", "FSR", 4, 1, 0},
+ {REG_STK, PO_INDF, 0, "INDF", "INDF", 0, 1, 0},
};
--- /dev/null
+
+unsigned char success=0;
+unsigned char failures=0;
+unsigned char dummy=0;
+
+bit bit0 = 0;
+bit bit1 = 0;
+bit bit2 = 0;
+
+unsigned int uint0 = 0;
+unsigned int uint1 = 0;
+unsigned char uchar0 = 0;
+unsigned char uchar1 = 0;
+unsigned long ulong0 = 0;
+unsigned long ulong1 = 0;
+
+void done()
+{
+
+ dummy++;
+
+}
+
+// uchar0 = 0;
+void or_lit2uchar(void)
+{
+
+ if(uchar0)
+ failures++;
+
+ uchar0 |= 1;
+
+ if(uchar0 != 1)
+ failures++;
+
+ uchar0 |= 2;
+
+ if(uchar0 != 3)
+ failures++;
+
+ uchar0 |= 0x0e;
+
+ if(uchar0 != 0x0f)
+ failures++;
+
+}
+
+
+void or_lit2uint(void)
+{
+
+ if(uint0)
+ failures++;
+
+ uint0 |= 1;
+ if(uint0 != 1)
+ failures++;
+
+ uint0 |= 2;
+ if(uint0 != 3)
+ failures++;
+
+ uint0 |= 0x100;
+ if(uint0 != 0x103)
+ failures++;
+
+ uint0 |= 0x102;
+ if(uint0 != 0x103)
+ failures++;
+
+ uint0 |= 0x303;
+ if(uint0 != 0x303)
+ failures++;
+
+}
+
+void or_lit2ulong(void)
+{
+
+ if(ulong0)
+ failures++;
+
+ ulong0 |= 1;
+ if(ulong0 != 1)
+ failures++;
+
+ ulong0 |= 2;
+ if(ulong0 != 3)
+ failures++;
+
+ ulong0 |= 0x100;
+ if(ulong0 != 0x103)
+ failures++;
+
+ ulong0 |= 0x102;
+ if(ulong0 != 0x103)
+ failures++;
+
+ ulong0 |= 0x303;
+ if(ulong0 != 0x303)
+ failures++;
+
+ ulong0 |= 0x80000000;
+ if(ulong0 != 0x80000303)
+ failures++;
+
+}
+
+/*-----------*/
+void or_uchar2uchar(void)
+{
+
+ uchar0 |= uchar1;
+
+ if(uchar0 != 1)
+ failures++;
+
+ uchar1 |= 0x0f;
+
+ uchar0 = uchar1 | 0x10;
+
+ if(uchar0 != 0x1f)
+ failures++;
+}
+
+void or_uint2uint(void)
+{
+ uint0 |= uint1;
+
+ if(uint0 != 1)
+ failures++;
+
+ uint1 |= 0x0f;
+
+ uint0 = uint1 | 0x10;
+
+ if(uint0 != 0x1f)
+ failures++;
+
+}
+
+void or_bits1(void)
+{
+
+ bit0 = bit0 | bit1 | bit2;
+
+}
+
+void or_bits2(void)
+{
+
+ bit0 = bit1 | bit2;
+
+}
+
+void main(void)
+{
+
+ or_lit2uchar();
+ or_lit2uint();
+ or_lit2ulong();
+
+ uchar0=0;
+ uchar1=1;
+ or_uchar2uchar();
+
+ uint0=0;
+ uint1=1;
+ or_uint2uint();
+
+ or_bits1();
+ if(bit0)
+ failures++;
+
+ or_bits2();
+ if(bit0)
+ failures++;
+
+ bit1=1;
+ or_bits1();
+ if(!bit0)
+ failures++;
+
+ or_bits2();
+ if(!bit0)
+ failures++;
+
+
+ success = failures;
+ done();
+}
--- /dev/null
+// rotate bytes left and right by a constant.
+
+unsigned char success=0;
+unsigned char failures=0;
+unsigned char dummy=0;
+
+bit bit0 = 0;
+unsigned int uint0 = 0;
+unsigned int uint1 = 0;
+unsigned char uchar0 = 0;
+unsigned char uchar1 = 0;
+unsigned char uchar2 = 0;
+
+void done()
+{
+
+ dummy++;
+
+}
+
+void check(void)
+{
+ if(uchar0 != uchar1)
+ failures++;
+}
+
+void rotate_left_1(void)
+{
+
+ uchar0 = (uchar0<<1) | (uchar0>>7);
+
+ check();
+}
+
+void rotate_left_2(void)
+{
+
+ uchar0 = (uchar0<<2) | (uchar0>>6);
+
+ check();
+}
+
+
+void rotate_left_3(void)
+{
+
+ uchar0 <<= 3;
+
+ if(uchar0 != uchar1)
+ failures++;
+}
+
+void rotate_left_4(void)
+{
+
+ uchar0 <<= 4;
+
+ if(uchar0 != uchar1)
+ failures++;
+}
+
+void rotate_left_5(void)
+{
+
+ uchar0 <<= 5;
+
+ if(uchar0 != uchar1)
+ failures++;
+}
+
+void rotate_left_6(void)
+{
+
+ uchar0 <<= 6;
+
+ if(uchar0 != uchar1)
+ failures++;
+}
+
+void rotate_left_7(void)
+{
+
+ uchar0 <<= 7;
+
+ if(uchar0 != uchar1)
+ failures++;
+}
+
+void rotate_right_1(void)
+{
+
+ uchar0 = (uchar0>>1) | (uchar0<<7);
+
+ check();
+
+}
+
+void rotate_right_2(void)
+{
+
+ uchar0 = (uchar0>>2) | (uchar0<<6);
+
+ check();
+}
+
+void rotate_right_3(void)
+{
+
+ uchar0 >>= 3;
+
+ check();
+}
+
+void rotate_right_4(void)
+{
+
+ uchar0 >>= 4;
+
+ check();
+}
+
+void rotate_right_5(void)
+{
+
+ uchar0 >>= 5;
+
+ check();
+}
+
+void rotate_right_6(void)
+{
+
+ uchar0 >>= 6;
+
+ check();
+}
+
+void rotate_right_7(void)
+{
+
+ uchar0 >>= 7;
+
+ check();
+}
+
+
+void main(void)
+{
+
+ // call with both values zero
+ rotate_left_1();
+
+ uchar0 = 1;
+ uchar1 = 2;
+
+ rotate_left_1();
+
+ uchar0 = 0x80;
+ uchar1 = 1;
+
+ rotate_left_1();
+
+ uchar1 = 2;
+ for(uchar2=0; uchar2<6; uchar2++) {
+ rotate_left_1();
+ uchar1 <<=1;
+ }
+
+
+ uchar0 = 1;
+ uchar1 = 4;
+ rotate_left_2();
+
+ uchar0 = 1;
+ uchar1 = 8;
+ rotate_left_3();
+
+ uchar0 = 1;
+ uchar1 = 0x10;
+ rotate_left_4();
+
+ uchar0 = 1;
+ uchar1 = 0x20;
+ rotate_left_5();
+
+ uchar0 = 1;
+ uchar1 = 0x40;
+ rotate_left_6();
+
+ uchar0 = 1;
+ uchar1 = 0x80;
+ rotate_left_7();
+
+
+
+
+ uchar0 = 2;
+ uchar1 = 1;
+ rotate_right_1();
+
+ uchar0 = 1;
+ uchar1 = 0x80;
+ rotate_right_1();
+
+ uchar0 = 4;
+ uchar1 = 1;
+ rotate_right_2();
+
+ uchar0 = 8;
+ rotate_right_3();
+
+ uchar0 = 0x10;
+ rotate_right_4();
+
+ uchar0 = 0x20;
+ rotate_right_5();
+
+ uchar0 = 0x40;
+ rotate_right_6();
+
+ uchar0 = 0x80;
+ rotate_right_7();
+
+ success=failures;
+ done();
+}
--- /dev/null
+unsigned char success=0;
+unsigned char failures=0;
+unsigned char dummy=0;
+
+bit bit0 = 0;
+unsigned int aint0 = 0;
+unsigned int aint1 = 0;
+unsigned char achar0 = 0;
+unsigned char achar1 = 0;
+
+
+void done()
+{
+
+ dummy++;
+
+}
+
+void switch1(void)
+{
+
+
+ switch(achar0) {
+ case 0:
+ achar0 = 9;
+ break;
+ case 1:
+ achar0 = 18;
+ break;
+
+ default:
+ achar0 = 0;
+ }
+
+
+}
+
+void switch2(void)
+{
+
+ switch(achar1) {
+ case 0: achar0 = 9; break;
+ case 1: achar0 = 8; break;
+ case 2: achar0 = 7; break;
+ case 3: achar0 = 6; break;
+ case 4: achar0 = 5; break;
+ case 5: achar0 = 4; break;
+ case 6: achar0 = 3; break;
+ case 7: achar0 = 2; break;
+ case 8: achar0 = 1; break;
+ case 9: achar0 = 0; break;
+ case 10: achar0 = 9; break;
+ case 11: achar0 = 8; break;
+ case 12: achar0 = 7; break;
+ default: achar0 = 0xff; break;
+ }
+
+}
+
+main(void)
+{
+
+ achar0 = 0;
+ switch1();
+ if(achar0 != 9)
+ failures++;
+
+ switch1();
+ if(achar0 != 0)
+ failures++;
+
+ achar0++;
+
+ switch1();
+ if(achar0 != 18)
+ failures++;
+
+ for(achar1=0; achar1<10;achar1++){
+ switch2();
+ if(achar0 != (9-achar1))
+ failures++;
+
+ }
+
+ success=failures;
+ done();
+}