static char *one = "#0x01";
static char *spname = "sp";
-char *fReturnpic14[] = {"FSR","dph","b","a" };
+char *fReturnpic14[] = {"temp1","temp2","temp3","temp4" };
//char *fReturn390[] = {"dpl","dph","dpx", "b","a" };
unsigned fReturnSizePic = 4; /* shared with ralloc.c */
static char **fReturn = fReturnpic14;
static void emitpLabel(int key)
{
- addpCode2pBlock(pb,newpCodeLabel(key+100+labelOffset));
+ addpCode2pBlock(pb,newpCodeLabel(NULL,key+100+labelOffset));
}
void emitpcode(PIC_OPCODE poc, pCodeOp *pcop)
if (!r0iu) {
/* push it if not already pushed */
if (!_G.r0Pushed) {
- pic14_emitcode ("push","%s",
- pic14_regWithIdx(R0_IDX)->dname);
+ //pic14_emitcode ("push","%s",
+ // pic14_regWithIdx(R0_IDX)->dname);
_G.r0Pushed++ ;
}
if (!r1iu) {
/* push it if not already pushed */
if (!_G.r1Pushed) {
- pic14_emitcode ("push","%s",
- pic14_regWithIdx(R1_IDX)->dname);
+ //pic14_emitcode ("push","%s",
+ // pic14_regWithIdx(R1_IDX)->dname);
_G.r1Pushed++ ;
}
aop->aopu.aop_immd = Safe_calloc(1,strlen(sym->rname)+1);
strcpy(aop->aopu.aop_immd,sym->rname);
aop->size = FPTRSIZE;
+ DEBUGpic14_emitcode(";","%d size = %d, name =%s",__LINE__,aop->size,sym->rname);
return aop;
}
//DEBUGpic14_emitcode(";","%s",buffer);
aop->aopu.aop_immd = Safe_calloc(1,strlen(buffer)+1);
strcpy(aop->aopu.aop_immd,buffer);
+ //aop->aopu.aop_alloc_reg = allocDirReg (IC_LEFT(ic));
+ allocDirReg (IC_LEFT(ic));
return aop;
}
return;
}
+ {
+ sym_link *type = operandType(op);
+ if(IS_PTR_CONST(type))
+ DEBUGpic14_emitcode(";","%d aop type is const pointer",__LINE__);
+ }
+
/* if already has a asmop then continue */
if (op->aop)
return ;
return;
}
+ {
+ sym_link *type = operandType(op);
+ if(IS_PTR_CONST(type))
+ DEBUGpic14_emitcode(";","%d aop type is const pointer",__LINE__);
+ }
+
/* must be in a register */
sym->aop = op->aop = aop = newAsmop(AOP_REG);
aop->size = sym->nRegs;
case AOP_IMMD:
- DEBUGpic14_emitcode(";","%d",__LINE__);
if (bit16)
sprintf (s,"%s",aop->aopu.aop_immd);
else
else
sprintf(s,"%s",
aop->aopu.aop_immd);
+ DEBUGpic14_emitcode(";","%d immd %s",__LINE__,s);
rs = Safe_calloc(1,strlen(s)+1);
strcpy(rs,s);
return rs;
return rs;
case AOP_REG:
- if (dname)
- return aop->aopu.aop_reg[offset]->dname;
- else
+ //if (dname)
+ // return aop->aopu.aop_reg[offset]->dname;
+ //else
return aop->aopu.aop_reg[offset]->name;
case AOP_CRY:
if(key>max_key)
max_key = key;
- return newpCodeOpLabel(key+100+labelOffset);
+ return newpCodeOpLabel(NULL,key+100+labelOffset);
}
/*-----------------------------------------------------------------*/
fprintf(stderr,"oops %s %d",__FILE__,__LINE__);
pcor->r = pc->r;
pcor->rIdx = pc->rIdx;
+ pcor->r->wasUsed=1;
//DEBUGpic14_emitcode ("; ***","%s , copying %s, rIdx=%d",__FUNCTION__,pc->pcop.name,pc->rIdx);
return PCOP(pcor);
}
-
/*-----------------------------------------------------------------*/
-/* popCopy - copy a pcode operator */
+/* popGet - asm operator to pcode operator conversion */
/*-----------------------------------------------------------------*/
-pCodeOp *popCopyGPR2Bit(pCodeOp *pc, int bitval)
+pCodeOp *popGetLit(unsigned int lit)
{
- pCodeOp *pcop;
-
- pcop = Safe_calloc(1,sizeof(pCodeOpBit) );
- pcop->type = PO_BIT;
- if(!(pcop->name = Safe_strdup(pc->name)))
- fprintf(stderr,"oops %s %d",__FILE__,__LINE__);
- ((pCodeOpBit *)pcop)->bit = bitval;
-
- ((pCodeOpBit *)pcop)->inBitSpace = 0; //(pc->type == PO_BIT) ? 1 : 0;
- return pcop;
+ return newpCodeOpLit(lit);
}
+
/*-----------------------------------------------------------------*/
-/* popGet - asm operator to pcode operator conversion */
+/* popGetImmd - asm operator to pcode immediate conversion */
/*-----------------------------------------------------------------*/
-pCodeOp *popGetLit(unsigned int lit)
+pCodeOp *popGetImmd(char *name, unsigned int offset)
{
- return newpCodeOpLit(lit);
+ return newpCodeOpImmd(name, offset);
}
pCodeOp *popRegFromString(char *str)
{
- pCodeOp *pcop = Safe_calloc(1,sizeof(pCodeOpReg) );
- pcop->type = PO_GPR_REGISTER;
-
- PCOR(pcop)->rIdx = -1;
- PCOR(pcop)->r = NULL;
+ pCodeOp *pcop = Safe_calloc(1,sizeof(pCodeOp) );
+ pcop->type = PO_DIR;
DEBUGpic14_emitcode(";","%d",__LINE__);
pcop->name = Safe_strdup( ( (str) ? str : "BAD STRING"));
pCodeOp *popGet (asmop *aop, int offset) //, bool bit16, bool dname)
{
char *s = buffer ;
- char *rs;
+ //char *rs;
pCodeOp *pcop;
case AOP_DPTR2:
case AOP_ACC:
DEBUGpic14_emitcode(";8051 legacy","%d type = %s",__LINE__,AopType(aop->type));
- //pcop = Safe_calloc(1,sizeof(pCodeOpReg) );
- //pcop->type = PO_SFR_REGISTER;
-
- //PCOR(pcop)->rIdx = -1;
- //PCOR(pcop)->r = NULL;
- // Really nasty hack to check for temporary registers
-
- //pcop->name = Safe_strdup("BAD_REGISTER");
-
return NULL;
case AOP_IMMD:
DEBUGpic14_emitcode(";","%d",__LINE__);
- pcop = Safe_calloc(1,sizeof(pCodeOp) );
- pcop->type = PO_IMMEDIATE;
- //if (bit16)
- // sprintf (s,"%s",aop->aopu.aop_immd);
- //else
- if (offset)
- sprintf(s,"(%s >> %d)",
- aop->aopu.aop_immd,
- offset*8);
- else
- sprintf(s,"%s",
- aop->aopu.aop_immd);
- pcop->name = Safe_calloc(1,strlen(s)+1);
- strcpy(pcop->name,s);
- return pcop;
-
+ return popGetImmd(aop->aopu.aop_immd,offset);
+
case AOP_DIR:
- pcop = Safe_calloc(1,sizeof(pCodeOp) );
+ pcop = Safe_calloc(1,sizeof(pCodeOpReg) );
pcop->type = PO_DIR;
+
if (offset)
sprintf(s,"(%s + %d)",
aop->aopu.aop_dir,
sprintf(s,"%s",aop->aopu.aop_dir);
pcop->name = Safe_calloc(1,strlen(s)+1);
strcpy(pcop->name,s);
+ PCOR(pcop)->r = dirregWithName(aop->aopu.aop_dir);
+ if(PCOR(pcop)->r == NULL)
+ fprintf(stderr,"%d - couldn't find %s in allocated registers\n",__LINE__,aop->aopu.aop_dir);
+ else
+ PCOR(pcop)->instance = offset;
+
return pcop;
case AOP_REG:
pcop = Safe_calloc(1,sizeof(pCodeOpReg) );
PCOR(pcop)->rIdx = rIdx;
PCOR(pcop)->r = pic14_regWithIdx(rIdx);
+ PCOR(pcop)->instance = offset;
pcop->type = PCOR(pcop)->r->pc_type;
- rs = aop->aopu.aop_reg[offset]->name;
+ //rs = aop->aopu.aop_reg[offset]->name;
//DEBUGpic14_emitcode(";","%d regiser idx = %d name =%s",__LINE__,rIdx,rs);
return pcop;
}
case AOP_CRY:
pcop = newpCodeOpBit(aop->aopu.aop_dir,-1,1);
+ PCOR(pcop)->r = dirregWithName(aop->aopu.aop_dir);
+ if(PCOR(pcop)->r == NULL)
+ fprintf(stderr,"%d - couldn't find %s in allocated registers\n",__LINE__,aop->aopu.aop_dir);
return pcop;
case AOP_LIT:
case AOP_STR:
DEBUGpic14_emitcode(";","%d",__LINE__);
+ return newpCodeOpRegFromStr(aop->aopu.aop_str[offset]);
+ /*
+ pcop = Safe_calloc(1,sizeof(pCodeOpReg) );
+ PCOR(pcop)->r = allocRegByName(aop->aopu.aop_str[offset]);
+ PCOR(pcop)->rIdx = PCOR(pcop)->r->rIdx;
+ pcop->type = PCOR(pcop)->r->pc_type;
+ pcop->name = PCOR(pcop)->r->name;
- pcop = Safe_calloc(1,sizeof(pCodeOp) );
- pcop->type = PO_STR;
-
- //aop->coff = offset ;
- //if (strcmp(aop->aopu.aop_str[offset],"a") == 0 && dname)
- // sprintf(s,"%s","acc");
- //else
- sprintf(s,"%s",aop->aopu.aop_str[offset]);
- pcop->name = Safe_calloc(1,strlen(s)+1);
- strcpy(pcop->name,s);
return pcop;
-
+ */
}
werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
pic14_emitcode("movf","%s,w",s);
pic14_emitcode("movwf","%s",d);
- if(strcmp(s,"W"))
- pic14_emitcode(";BUG! should have this:movf","%s,w %d",s,__LINE__);
+ if(strcmp(s,"W")) {
+ pic14_emitcode(";BUG!? should have this:movf","%s,w %d",s,__LINE__);
+ if(offset >= aop->size) {
+ emitpcode(POC_CLRF,popGet(aop,offset));
+ break;
+ } else
+ emitpcode(POC_MOVLW,popGetImmd(s,offset));
+ }
+
emitpcode(POC_MOVWF,popGet(aop,offset));
break;
case AOP_REG:
- if (strcmp(aop->aopu.aop_reg[offset]->name,s) != 0 &&
- strcmp(aop->aopu.aop_reg[offset]->dname,s)!= 0){
+ if (strcmp(aop->aopu.aop_reg[offset]->name,s) != 0) { // &&
+ //strcmp(aop->aopu.aop_reg[offset]->dname,s)!= 0){
/*
if (*s == '@' ||
strcmp(s,"r0") == 0 ||
DEBUGpic14_AopType(__LINE__,IC_LEFT(ic),NULL,IC_RESULT(ic));
/* if in bit space then a special case */
if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY) {
- pic14_emitcode("movlw","1<<%s");
+ pic14_emitcode("movlw","1<<garbage");
//pic14_emitcode("mov","c,%s",IC_LEFT(ic)->aop->aopu.aop_dir);
//pic14_emitcode("cpl","c");
//pic14_outBitC(IC_RESULT(ic));
pic14_emitcode("mov","%s,r0",spname);
if (bitVectBitValue(rsave,R0_IDX))
pic14_emitcode("mov","r0,b");
- } else
- for (i = 0 ; i < pic14_nRegs ; i++) {
- if (bitVectBitValue(rsave,i))
- pic14_emitcode("push","%s",pic14_regWithIdx(i)->dname);
- }
+ }// else
+ //for (i = 0 ; i < pic14_nRegs ; i++) {
+ // if (bitVectBitValue(rsave,i))
+ // pic14_emitcode("push","%s",pic14_regWithIdx(i)->dname);
+ //}
dtype = operandType(IC_LEFT(ic));
if (currFunc && dtype &&
pic14_emitcode("mov","%s,r0",spname);
if (bitVectBitValue(rsave,R0_IDX))
pic14_emitcode("mov","r0,b");
- } else
- for (i = pic14_nRegs ; i >= 0 ; i--) {
- if (bitVectBitValue(rsave,i))
- pic14_emitcode("pop","%s",pic14_regWithIdx(i)->dname);
- }
+ } //else
+ //for (i = pic14_nRegs ; i >= 0 ; i--) {
+ // if (bitVectBitValue(rsave,i))
+ // pic14_emitcode("pop","%s",pic14_regWithIdx(i)->dname);
+ //}
}
DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ DEBUGpic14_AopType(__LINE__,oper,NULL,NULL);
+
if(!GpsuedoStkPtr) {
/* The last byte in the assignment is in W */
size--;
/* if this is an interrupt service routine then
save acc, b, dpl, dph */
if (IFFUNC_ISISR(sym->type)) {
-
+ addpCode2pBlock(pb,newpCode(POC_GOTO,newpCodeOp("END_OF_INTERRUPT+1",PO_STR)));
+ emitpcodeNULLop(POC_NOP);
+ emitpcodeNULLop(POC_NOP);
+ emitpcodeNULLop(POC_NOP);
+ emitpcode(POC_MOVWF, popCopyReg(&pc_wsave));
+ emitpcode(POC_SWAPFW, popCopyReg(&pc_status));
+ emitpcode(POC_CLRF, popCopyReg(&pc_status));
+ emitpcode(POC_MOVWF, popCopyReg(&pc_ssave));
+
+ pBlockConvert2ISR(pb);
+#if 0
if (!inExcludeList("acc"))
pic14_emitcode ("push","acc");
if (!inExcludeList("b"))
for ( i = 0 ; i < sym->regsUsed->size ; i++) {
if (bitVectBitValue(sym->regsUsed,i) ||
(pic14_ptrRegReq && (i == R0_IDX || i == R1_IDX)) )
- pic14_emitcode("push","%s",pic14_regWithIdx(i)->dname);
+ pic14_emitcode("push","junk");//"%s",pic14_regWithIdx(i)->dname);
}
}
saverbank(0,ic,FALSE);
}
}
+#endif
} else {
/* if callee-save to be used for this function
then save the registers being used in this function */
for ( i = 0 ; i < sym->regsUsed->size ; i++) {
if (bitVectBitValue(sym->regsUsed,i) ||
(pic14_ptrRegReq && (i == R0_IDX || i == R1_IDX)) ) {
- pic14_emitcode("push","%s",pic14_regWithIdx(i)->dname);
+ //pic14_emitcode("push","%s",pic14_regWithIdx(i)->dname);
_G.nRegsSaved++;
}
}
for ( i = sym->regsUsed->size ; i >= 0 ; i--) {
if (bitVectBitValue(sym->regsUsed,i) ||
(pic14_ptrRegReq && (i == R0_IDX || i == R1_IDX)) )
- pic14_emitcode("pop","%s",pic14_regWithIdx(i)->dname);
+ pic14_emitcode("pop","junk");//"%s",pic14_regWithIdx(i)->dname);
}
}
unsaverbank(0,ic,FALSE);
}
}
-
+#if 0
if (options.model == MODEL_FLAT24 && !inExcludeList("dpx"))
{
if (options.stack10bit)
if (IFFUNC_ISCRITICAL(sym->type))
pic14_emitcode("setb","ea");
+#endif
/* if debug then send end of function */
/* if (options.debug && currFunc) { */
}
pic14_emitcode ("reti","");
+
+ emitpcode(POC_CLRF, popCopyReg(&pc_status));
+ emitpcode(POC_SWAPFW, popCopyReg(&pc_ssave));
+ emitpcode(POC_MOVWF, popCopyReg(&pc_status));
+ emitpcode(POC_SWAPF, popCopyReg(&pc_wsave));
+ emitpcode(POC_MOVFW, popCopyReg(&pc_wsave));
+ addpCode2pBlock(pb,newpCodeLabel("END_OF_INTERRUPT",-1));
+
+ emitpcodeNULLop(POC_RETFIE);
+
}
else {
if (IFFUNC_ISCRITICAL(sym->type))
for ( i = sym->regsUsed->size ; i >= 0 ; i--) {
if (bitVectBitValue(sym->regsUsed,i) ||
(pic14_ptrRegReq && (i == R0_IDX || i == R1_IDX)) )
- pic14_emitcode("pop","%s",pic14_regWithIdx(i)->dname);
+ pic14_emitcode("pop","junk");//"%s",pic14_regWithIdx(i)->dname);
}
}
// lit>>1 != 0 => result = 1
if(AOP_TYPE(result) == AOP_CRY){
if(size)
- pic14_emitcode("setb","%s",AOP(result)->aopu.aop_dir);
+ {emitpcode(POC_BSF, popGet(AOP(result),offset));
+ pic14_emitcode("setb","%s",AOP(result)->aopu.aop_dir);}
else if(ifx)
continueIfTrue(ifx);
goto release;
} else{
// lit == 1, result = not(left)
if(size && pic14_sameRegs(AOP(result),AOP(left))){
+ emitpcode(POC_MOVLW, popGet(AOP(result),offset));
+ emitpcode(POC_XORWF, popGet(AOP(result),offset));
pic14_emitcode("cpl","%s",AOP(result)->aopu.aop_dir);
goto release;
} else {
freeAsmop(result,NULL,ic,TRUE);
}
+/*-----------------------------------------------------------------*
+ * genMultiAsm - repeat assembly instruction for size of register.
+ * if endian == 1, then the high byte (i.e base address + size of
+ * register) is used first else the low byte is used first;
+ *-----------------------------------------------------------------*/
+static void genMultiAsm( PIC_OPCODE poc, operand *reg, int size, int endian)
+{
+
+ int offset = 0;
+
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+
+ if(!reg)
+ return;
+
+ if(!endian) {
+ endian = 1;
+ } else {
+ endian = -1;
+ offset = size-1;
+ }
+
+ while(size--) {
+ emitpcode(poc, popGet(AOP(reg),offset));
+ offset += endian;
+ }
+
+}
/*-----------------------------------------------------------------*/
/* genLeftShift - generates code for left shifting */
/*-----------------------------------------------------------------*/
goto release ;
}
+ if (pic14_sameRegs(AOP(left),AOP(result))) {
+
+ tlbl = newiTempLabel(NULL);
+ emitpcode(POC_COMFW, popGet(AOP(right),0));
+ genMultiAsm(POC_RRF, result, size,1);
+ emitpLabel(tlbl->key);
+ genMultiAsm(POC_RLF, result, size,0);
+ emitpcode(POC_ADDLW, popGetLit(1));
+ emitSKPC;
+ emitpcode(POC_GOTO,popGetLabel(tlbl->key));
+ goto release;
+ }
tlbl = newiTempLabel(NULL);
offset = 0 ;
freeAsmop(result,NULL,ic,TRUE);
}
-
+#if 0
/*-----------------------------------------------------------------*/
-/* pic14_emitcodePointerGet - gget value from code space */
+/* genCodePointerGet - get value from code space */
/*-----------------------------------------------------------------*/
-static void pic14_emitcodePointerGet (operand *left,
+static void genCodePointerGet (operand *left,
operand *result, iCode *ic)
{
int size, offset ;
freeAsmop(result,NULL,ic,TRUE);
}
-
+#endif
/*-----------------------------------------------------------------*/
/* genGenPointerGet - gget value from generic pointer space */
/*-----------------------------------------------------------------*/
/* if the operand is already in dptr
then we do nothing else we move the value to dptr */
- if (AOP_TYPE(left) != AOP_STR) {
+ // if (AOP_TYPE(left) != AOP_STR) {
/* if this is remateriazable */
if (AOP_TYPE(left) == AOP_IMMD) {
pic14_emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE));
}
goto release;
}
- }
+ //}
/* so dptr know contains the address */
/* if bit then unpack */
- if (IS_BITVAR(retype))
- genUnpackBits(result,"dptr",GPOINTER);
+ //if (IS_BITVAR(retype))
+ // genUnpackBits(result,"dptr",GPOINTER);
release:
freeAsmop(left,NULL,ic,TRUE);
}
+/*-----------------------------------------------------------------*/
+/* genConstPointerGet - get value from const generic pointer space */
+/*-----------------------------------------------------------------*/
+static void genConstPointerGet (operand *left,
+ operand *result, iCode *ic)
+{
+ sym_link *retype = getSpec(operandType(result));
+ symbol *albl = newiTempLabel(NULL);
+ symbol *blbl = newiTempLabel(NULL);
+ PIC_OPCODE poc;
+
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ aopOp(left,ic,FALSE);
+ aopOp(result,ic,FALSE);
+
+
+ DEBUGpic14_AopType(__LINE__,left,NULL,result);
+
+ DEBUGpic14_emitcode ("; "," %d getting const pointer",__LINE__);
+
+ emitpcode(POC_CALL,popGetLabel(albl->key));
+ emitpcode(POC_GOTO,popGetLabel(blbl->key));
+ emitpLabel(albl->key);
+
+ poc = ( (AOP_TYPE(left) == AOP_IMMD) ? POC_MOVLW : POC_MOVFW);
+
+ emitpcode(poc,popGet(AOP(left),1));
+ emitpcode(POC_MOVWF,popCopyReg(&pc_pclath));
+ emitpcode(poc,popGet(AOP(left),0));
+ emitpcode(POC_MOVWF,popCopyReg(&pc_pcl));
+
+ emitpLabel(blbl->key);
+
+ emitpcode(POC_MOVWF,popGet(AOP(result),0));
+
+
+ freeAsmop(left,NULL,ic,TRUE);
+ freeAsmop(result,NULL,ic,TRUE);
+
+}
/*-----------------------------------------------------------------*/
/* genPointerGet - generate code for pointer get */
/*-----------------------------------------------------------------*/
move it to the correct pointer register */
type = operandType(left);
etype = getSpec(type);
+
+ if (IS_PTR_CONST(type))
+ DEBUGpic14_emitcode ("; ***","%d - const pointer",__LINE__);
+
/* if left is of type of pointer then it is simple */
if (IS_PTR(type) && !IS_FUNC(type->next))
p_type = DCL_TYPE(type);
/* we have to go by the storage class */
p_type = PTR_TYPE(SPEC_OCLS(etype));
-/* if (SPEC_OCLS(etype)->codesp ) { */
-/* p_type = CPOINTER ; */
-/* } */
-/* else */
-/* if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged) */
-/* p_type = FPOINTER ; */
-/* else */
-/* if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged) */
+ DEBUGpic14_emitcode ("; ***","%d - resolve pointer by storage class",__LINE__);
+
+ if (SPEC_OCLS(etype)->codesp ) {
+ DEBUGpic14_emitcode ("; ***","%d - cpointer",__LINE__);
+ //p_type = CPOINTER ;
+ }
+ else
+ if (SPEC_OCLS(etype)->fmap && !SPEC_OCLS(etype)->paged)
+ DEBUGpic14_emitcode ("; ***","%d - fpointer",__LINE__);
+ /*p_type = FPOINTER ;*/
+ else
+ if (SPEC_OCLS(etype)->fmap && SPEC_OCLS(etype)->paged)
+ DEBUGpic14_emitcode ("; ***","%d - ppointer",__LINE__);
/* p_type = PPOINTER; */
-/* else */
-/* if (SPEC_OCLS(etype) == idata ) */
+ else
+ if (SPEC_OCLS(etype) == idata )
+ DEBUGpic14_emitcode ("; ***","%d - ipointer",__LINE__);
/* p_type = IPOINTER; */
-/* else */
+ else
+ DEBUGpic14_emitcode ("; ***","%d - pointer",__LINE__);
/* p_type = POINTER ; */
}
break;
case CPOINTER:
- pic14_emitcodePointerGet (left,result,ic);
+ genConstPointerGet (left,result,ic);
+ //pic14_emitcodePointerGet (left,result,ic);
break;
case GPOINTER:
+ if (IS_PTR_CONST(type))
+ genConstPointerGet (left,result,ic);
+ else
genGenPointerGet (left,result,ic);
- break;
+ break;
}
}
} else {
pic14_emitcode("clrf","%s",buffer);
- emitpcode(POC_CLRF, popRegFromString(buffer));
+ //emitpcode(POC_CLRF, popRegFromString(buffer));
+ emitpcode(POC_CLRF, popGet(AOP(result),offset));
}
}else {
pic14_emitcode("movf","%s,w",aopGet(AOP(right),offset,FALSE,FALSE));
case GPOINTER:
genGenPointerSet (right,result,ic);
break;
- }
+ default:
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ "genPointerSet: illegal pointer type");
+ }
}
/*-----------------------------------------------------------------*/
{
operand *result = IC_RESULT(ic);
sym_link *ctype = operandType(IC_LEFT(ic));
+ sym_link *rtype = operandType(IC_RIGHT(ic));
operand *right = IC_RIGHT(ic);
int size, offset ;
if (AOP_TYPE(result) == AOP_CRY) {
/* if the right size is a literal then
we know what the value is */
+ DEBUGpic14_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
if (AOP_TYPE(right) == AOP_LIT) {
emitpcode( ( ((int) operandLitValue(right)) ? POC_BSF : POC_BCF),
int offset = 1;
size = AOP_SIZE(result);
+ DEBUGpic14_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
+
emitpcode(POC_CLRF, popGet(AOP(result),0));
emitpcode(POC_BTFSC, popGet(AOP(right),0));
emitpcode(POC_INCF, popGet(AOP(result),0));
if (AOP_SIZE(result) <= AOP_SIZE(right)) {
/* if they are in the same place */
- if (pic14_sameRegs(AOP(right),AOP(result)))
- goto release;
+ if (pic14_sameRegs(AOP(right),AOP(result)))
+ goto release;
+
+ DEBUGpic14_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
+ if (IS_PTR_CONST(rtype))
+ DEBUGpic14_emitcode ("; ***","%d - right is const pointer",__LINE__);
+ if (IS_PTR_CONST(operandType(IC_RESULT(ic))))
+ DEBUGpic14_emitcode ("; ***","%d - result is const pointer",__LINE__);
/* if they in different places then copy */
size = AOP_SIZE(result);
offset = 0 ;
while (size--) {
- aopPut(AOP(result),
- aopGet(AOP(right),offset,FALSE,FALSE),
- offset);
- offset++;
+ if(AOP_TYPE(right) == AOP_IMMD)
+ emitpcode(POC_MOVLW, popGetImmd(AOP(right)->aopu.aop_dir,offset));
+ else
+ emitpcode(POC_MOVFW, popGet(AOP(right),offset));
+ emitpcode(POC_MOVWF, popGet(AOP(result),offset));
+
+ //aopPut(AOP(result),
+ // aopGet(AOP(right),offset,FALSE,FALSE),
+ // offset);
+
+ offset++;
}
goto release;
}
int p_type;
sym_link *type = operandType(right);
sym_link *etype = getSpec(type);
+ DEBUGpic14_emitcode("; ***","%s %d - pointer cast",__FUNCTION__,__LINE__);
/* pointer to generic pointer */
if (IS_GENPTR(ctype)) {
size = GPTRSIZE - 1;
offset = 0 ;
while (size--) {
+ if(offset < AOP_SIZE(right))
aopPut(AOP(result),
aopGet(AOP(right),offset,FALSE,FALSE),
offset);
- offset++;
+ else
+ emitpcode(POC_CLRF,popGet(AOP(result),offset));
+ offset++;
}
/* the last byte depending on type */
switch (p_type) {
case IPOINTER:
case POINTER:
- l = zero;
+ emitpcode(POC_CLRF,popGet(AOP(result),GPTRSIZE - 1));
break;
case FPOINTER:
+ pic14_emitcode(";BUG!? ","%d",__LINE__);
l = one;
break;
case CPOINTER:
+ pic14_emitcode(";BUG!? ","%d",__LINE__);
l = "#0x02";
break;
case PPOINTER:
+ pic14_emitcode(";BUG!? ","%d",__LINE__);
l = "#0x03";
break;
"got unknown pointer type");
exit(1);
}
- aopPut(AOP(result),l, GPTRSIZE - 1);
+ //aopPut(AOP(result),l, GPTRSIZE - 1);
goto release ;
}
if(genMixedOperation(ic))
goto release;
+ DEBUGpic14_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
/* we move to result for the size of source */
size = AOP_SIZE(right);
/* now depending on the sign of the destination */
size = AOP_SIZE(result) - AOP_SIZE(right);
/* if unsigned or not an integral type */
- if (SPEC_USIGN(ctype) || !IS_SPEC(ctype)) {
+ if (SPEC_USIGN(rtype) || !IS_SPEC(rtype)) {
while (size--)
emitpcode(POC_CLRF, popGet(AOP(result),offset++));
} else {
/*-----------------------------------------------------------------*/
static void genReceive (iCode *ic)
{
- DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- if (isOperandInFarSpace(IC_RESULT(ic)) &&
- ( OP_SYMBOL(IC_RESULT(ic))->isspilt ||
- IS_TRUE_SYMOP(IC_RESULT(ic))) ) {
+ if (isOperandInFarSpace(IC_RESULT(ic)) &&
+ ( OP_SYMBOL(IC_RESULT(ic))->isspilt ||
+ IS_TRUE_SYMOP(IC_RESULT(ic))) ) {
- int size = getSize(operandType(IC_RESULT(ic)));
- int offset = fReturnSizePic - size;
- while (size--) {
- pic14_emitcode ("push","%s", (strcmp(fReturn[fReturnSizePic - offset - 1],"a") ?
+ int size = getSize(operandType(IC_RESULT(ic)));
+ int offset = fReturnSizePic - size;
+ while (size--) {
+ pic14_emitcode ("push","%s", (strcmp(fReturn[fReturnSizePic - offset - 1],"a") ?
fReturn[fReturnSizePic - offset - 1] : "acc"));
- offset++;
- }
- aopOp(IC_RESULT(ic),ic,FALSE);
- size = AOP_SIZE(IC_RESULT(ic));
- offset = 0;
- while (size--) {
- pic14_emitcode ("pop","acc");
- aopPut (AOP(IC_RESULT(ic)),"a",offset++);
- }
-
- } else {
- _G.accInUse++;
- aopOp(IC_RESULT(ic),ic,FALSE);
- _G.accInUse--;
- assignResultValue(IC_RESULT(ic));
+ offset++;
}
+ aopOp(IC_RESULT(ic),ic,FALSE);
+ size = AOP_SIZE(IC_RESULT(ic));
+ offset = 0;
+ while (size--) {
+ pic14_emitcode ("pop","acc");
+ aopPut (AOP(IC_RESULT(ic)),"a",offset++);
+ }
+
+ } else {
+ _G.accInUse++;
+ aopOp(IC_RESULT(ic),ic,FALSE);
+ _G.accInUse--;
+ assignResultValue(IC_RESULT(ic));
+ }
- freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
+ freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
}
/*-----------------------------------------------------------------*/
addpBlock(pb);
/* if debug information required */
-/* if (options.debug && currFunc) { */
- if (currFunc) {
+ if (options.debug && currFunc) {
+ if (currFunc) {
cdbSymbol(currFunc,cdbFile,FALSE,TRUE);
_G.debugLine = 1;
if (IS_STATIC(currFunc->etype)) {
- pic14_emitcode("",";F%s$%s$0$0 %d",moduleName,currFunc->name,__LINE__);
- //addpCode2pBlock(pb,newpCodeLabel(moduleName,currFunc->name));
+ pic14_emitcode("",";F%s$%s$0$0 %d",moduleName,currFunc->name,__LINE__);
+ //addpCode2pBlock(pb,newpCodeLabel(moduleName,currFunc->name));
} else {
- pic14_emitcode("",";G$%s$0$0 %d",currFunc->name,__LINE__);
- //addpCode2pBlock(pb,newpCodeLabel(NULL,currFunc->name));
+ pic14_emitcode("",";G$%s$0$0 %d",currFunc->name,__LINE__);
+ //addpCode2pBlock(pb,newpCodeLabel(NULL,currFunc->name));
}
_G.debugLine = 0;
+ }
}
/* now we are ready to call the
peep hole optimizer */
if (!options.nopeep) {
- printf("peep hole optimizing\n");
- peepHole (&lineHead);
+ peepHole (&lineHead);
}
/* now do the actual printing */
printLine (lineHead,codeOutFile);
- printf("printing pBlock\n\n");
+#ifdef PCODE_DEBUG
+ DFPRINTF((stderr,"printing pBlock\n\n"));
printpBlock(stdout,pb);
+#endif
return;
}