static int max_key=0;
static int GpsuedoStkPtr=0;
-pCodeOp *popGetImmd(char *name, unsigned int offset);
+pCodeOp *popGetImmd(char *name, unsigned int offset, int index);
unsigned int pic14aopLiteral (value *val, int offset);
const char *AopType(short type);
static iCode *ifxForOp ( operand *op, iCode *ic );
/* only remaining is far space */
/* in which case DPTR gets the address */
+ sym->aop = aop = newAsmop(AOP_PCODE);
+
+ aop->aopu.pcop = popGetImmd(sym->rname,0,0);
+ PCOI(aop->aopu.pcop)->_const = IN_CODESPACE(space);
+ PCOI(aop->aopu.pcop)->index = 0;
+
+ DEBUGpic14_emitcode(";"," rname %s, val %d, const = %d",
+ sym->rname, 0, PCOI(aop->aopu.pcop)->_const);
+
+ allocDirReg (IC_LEFT(ic));
+
+ aop->size = FPTRSIZE;
+/*
+ DEBUGpic14_emitcode(";","%d size = %d, name =%s",__LINE__,aop->size,sym->rname);
sym->aop = aop = newAsmop(AOP_DPTR);
pic14_emitcode ("mov","dptr,#%s", sym->rname);
aop->size = getSize(sym->type);
DEBUGpic14_emitcode(";","%d size = %d",__LINE__,aop->size);
+*/
+
/* if it is in code space */
if (IN_CODESPACE(space))
aop->code = 1;
/*-----------------------------------------------------------------*/
/* aopForRemat - rematerialzes an object */
/*-----------------------------------------------------------------*/
-static asmop *aopForRemat (symbol *sym)
+static asmop *aopForRemat (operand *op) // x symbol *sym)
{
- iCode *ic = sym->rematiCode;
- //X asmop *aop = newAsmop(AOP_IMMD);
- asmop *aop = newAsmop(AOP_PCODE);
- int val = 0;
- int offset = 0;
+ symbol *sym = OP_SYMBOL(op);
+ iCode *ic = NULL;
+ asmop *aop = newAsmop(AOP_PCODE);
+ int val = 0;
+ int offset = 0;
+
+ ic = sym->rematiCode;
DEBUGpic14_emitcode(";","%s %d",__FUNCTION__,__LINE__);
ic = OP_SYMBOL(IC_LEFT(ic))->rematiCode;
}
-/* X
- if (val) {
- sprintf(buffer,"(%s %c 0x%04x)",
- OP_SYMBOL(IC_LEFT(ic))->rname,
- val >= 0 ? '+' : '-',
- abs(val) & 0xffff);
- fprintf(stderr,"hmmm %s\n",buffer);
- } else
- strcpy(buffer,OP_SYMBOL(IC_LEFT(ic))->rname);
-*/
- //ic = sym->rematiCode;
+
offset = OP_SYMBOL(IC_LEFT(ic))->offset;
- aop->aopu.pcop = popGetImmd(OP_SYMBOL(IC_LEFT(ic))->rname,val);
- DEBUGpic14_emitcode(";"," rname %s, val %d ",OP_SYMBOL(IC_LEFT(ic))->rname,val);
- //X aop->aopu.aop_immd = Safe_calloc(1,strlen(buffer)+1);
- //X strcpy(aop->aopu.aop_immd,buffer);
+ aop->aopu.pcop = popGetImmd(OP_SYMBOL(IC_LEFT(ic))->rname,0,val);
+ PCOI(aop->aopu.pcop)->_const = IS_PTR_CONST(operandType(op));
+ PCOI(aop->aopu.pcop)->index = val;
+
+ DEBUGpic14_emitcode(";"," rname %s, val %d, const = %d",
+ OP_SYMBOL(IC_LEFT(ic))->rname,
+ val, IS_PTR_CONST(operandType(op)));
+
+ // DEBUGpic14_emitcode(";","aop type %s",AopType(AOP_TYPE(IC_LEFT(ic))));
allocDirReg (IC_LEFT(ic));
DEBUGpic14_emitcode(";","%d",__LINE__);
/* rematerialize it NOW */
if (sym->remat) {
+
sym->aop = op->aop = aop =
- aopForRemat (sym);
+ aopForRemat (op);
aop->size = getSize(sym->type);
//DEBUGpic14_emitcode(";"," %d: size %d, %s\n",__LINE__,aop->size,aop->aopu.aop_immd);
return;
sym->rname, sym->usl.spillLoc->offset);
// X sym->aop = op->aop = aop = aopForSym(ic,sym->usl.spillLoc,result);
sym->aop = op->aop = aop = newAsmop(AOP_PCODE);
- aop->aopu.pcop = popGetImmd(sym->usl.spillLoc->rname,sym->usl.spillLoc->offset);
+ aop->aopu.pcop = popGetImmd(sym->usl.spillLoc->rname,0,sym->usl.spillLoc->offset);
//allocDirReg (IC_LEFT(ic));
aop->size = getSize(sym->type);
/*-----------------------------------------------------------------*/
/* popGetImmd - asm operator to pcode immediate conversion */
/*-----------------------------------------------------------------*/
-pCodeOp *popGetImmd(char *name, unsigned int offset)
+pCodeOp *popGetImmd(char *name, unsigned int offset, int index)
{
- return newpCodeOpImmd(name, offset);
+ return newpCodeOpImmd(name, offset,index, 0);
}
case AOP_IMMD:
DEBUGpic14_emitcode(";","%d",__LINE__);
- return popGetImmd(aop->aopu.aop_immd,offset);
+ return popGetImmd(aop->aopu.aop_immd,offset,0);
case AOP_DIR:
pcop = Safe_calloc(1,sizeof(pCodeOpReg) );
case AOP_PCODE:
DEBUGpic14_emitcode(";","popGet AOP_PCODE%d",__LINE__);
- return pCodeOpCopy(aop->aopu.pcop);
+ pcop = pCodeOpCopy(aop->aopu.pcop);
+ PCOI(pcop)->offset = offset;
+ return pcop;
}
werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
emitpcode(POC_CLRF,popGet(aop,offset));
break;
} else
- emitpcode(POC_MOVLW,popGetImmd(s,offset));
+ emitpcode(POC_MOVLW,popGetImmd(s,offset,0));
}
emitpcode(POC_MOVWF,popGet(aop,offset));
//if (strcmp(l,fReturn[offset])) {
- if ( ((AOP(IC_LEFT(sic))->type) == AOP_IMMD) ||
+ if ( ((AOP(IC_LEFT(sic))->type) == AOP_PCODE) ||
((AOP(IC_LEFT(sic))->type) == AOP_LIT) )
emitpcode(POC_MOVLW,popGet(AOP(IC_LEFT(sic)),offset));
else
emitpcode(POC_GOTO,popGetLabel(blbl->key));
emitpLabel(albl->key);
- poc = ( (AOP_TYPE(left) == AOP_IMMD) ? POC_MOVLW : POC_MOVFW);
+ poc = ( (AOP_TYPE(left) == AOP_PCODE) ? POC_MOVLW : POC_MOVFW);
emitpcode(poc,popGet(AOP(left),1));
emitpcode(POC_MOVWF,popCopyReg(&pc_pclath));
/*-----------------------------------------------------------------*/
static void genAddrOf (iCode *ic)
{
- //symbol *sym = OP_SYMBOL(IC_LEFT(ic));
operand *right, *result, *left;
- //int size, offset ;
+ int size, offset ;
DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
DEBUGpic14_AopType(__LINE__,left,right,result);
- emitpcode(POC_MOVLW, popGet(AOP(left),0));
- emitpcode(POC_MOVWF, popGet(AOP(result),0));
-
-#if 0
- /* object not on stack then we need the name */
size = AOP_SIZE(IC_RESULT(ic));
offset = 0;
while (size--) {
- char s[SDCC_NAME_MAX];
- if (offset)
- sprintf(s,"#(%s >> %d)",
- sym->rname,
- offset*8);
- else
- sprintf(s,"#%s",sym->rname);
- aopPut(AOP(IC_RESULT(ic)),s,offset++);
+ emitpcode(POC_MOVLW, popGet(AOP(left),offset));
+ emitpcode(POC_MOVWF, popGet(AOP(result),offset));
+ offset++;
}
-#endif
-
- // freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
freeAsmop(left,NULL,ic,FALSE);
freeAsmop(result,NULL,ic,TRUE);
if (IS_PTR_CONST(operandType(IC_RESULT(ic))))
DEBUGpic14_emitcode ("; ***","%d - result is const pointer",__LINE__);
+ if ((AOP_TYPE(right) == AOP_PCODE) && AOP(right)->aopu.pcop->type == PO_IMMEDIATE) {
+ emitpcode(POC_MOVLW, popGet(AOP(right),0));
+ emitpcode(POC_MOVWF, popGet(AOP(result),0));
+ emitpcode(POC_MOVLW, popGet(AOP(right),1));
+ emitpcode(POC_MOVWF, popGet(AOP(result),1));
+ if(AOP_SIZE(result) <2)
+ fprintf(stderr,"%d -- result is not big enough to hold a ptr\n",__LINE__);
+
+ } else {
+
/* if they in different places then copy */
size = AOP_SIZE(result);
offset = 0 ;
while (size--) {
- 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));
+ emitpcode(POC_MOVFW, popGet(AOP(right),offset));
+ emitpcode(POC_MOVWF, popGet(AOP(result),offset));
//aopPut(AOP(result),
// aopGet(AOP(right),offset,FALSE,FALSE),
offset++;
}
- goto release;
+ }
+ goto release;
}