static int max_key=0;
static int GpsuedoStkPtr=0;
-pCodeOp *popGetImmd(char *name, unsigned int offset, int index);
+pCodeOp *popGetImmd(char *name, unsigned int offset, int index,int is_func);
unsigned int pic14aopLiteral (value *val, int offset);
const char *AopType(short type);
static iCode *ifxForOp ( operand *op, iCode *ic );
/* special case for a function */
if (IS_FUNC(sym->type)) {
+
+ sym->aop = aop = newAsmop(AOP_PCODE);
+ aop->aopu.pcop = popGetImmd(sym->rname,0,0,1);
+ PCOI(aop->aopu.pcop)->_const = IN_CODESPACE(space);
+ PCOI(aop->aopu.pcop)->_function = 1;
+ PCOI(aop->aopu.pcop)->index = 0;
+ aop->size = FPTRSIZE;
+ /*
sym->aop = aop = newAsmop(AOP_IMMD);
- //_ALLOC_ATOMIC(aop->aopu.aop_immd,strlen(sym->rname)+1);
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;
}
/* in which case DPTR gets the address */
sym->aop = aop = newAsmop(AOP_PCODE);
- aop->aopu.pcop = popGetImmd(sym->rname,0,0);
+ aop->aopu.pcop = popGetImmd(sym->rname,0,0,0);
PCOI(aop->aopu.pcop)->_const = IN_CODESPACE(space);
PCOI(aop->aopu.pcop)->index = 0;
}
offset = OP_SYMBOL(IC_LEFT(ic))->offset;
- aop->aopu.pcop = popGetImmd(OP_SYMBOL(IC_LEFT(ic))->rname,0,val);
+ aop->aopu.pcop = popGetImmd(OP_SYMBOL(IC_LEFT(ic))->rname,0,val,0);
PCOI(aop->aopu.pcop)->_const = IS_PTR_CONST(operandType(op));
PCOI(aop->aopu.pcop)->index = val;
/*-----------------------------------------------------------------*/
/* popGetImmd - asm operator to pcode immediate conversion */
/*-----------------------------------------------------------------*/
-pCodeOp *popGetImmd(char *name, unsigned int offset, int index)
+pCodeOp *popGetImmd(char *name, unsigned int offset, int index,int is_func)
{
- return newpCodeOpImmd(name, offset,index, 0);
+ return newpCodeOpImmd(name, offset,index, 0, is_func);
}
case AOP_IMMD:
DEBUGpic14_emitcode(";","%d",__LINE__);
- return popGetImmd(aop->aopu.aop_immd,offset,0);
+ return popGetImmd(aop->aopu.aop_immd,offset,0,0);
case AOP_DIR:
return popRegFromString(aop->aopu.aop_dir, aop->size, offset);
emitpcode(POC_CLRF,popGet(aop,offset));
break;
} else
- emitpcode(POC_MOVLW,popGetImmd(s,offset,0));
+ emitpcode(POC_MOVLW,popGetImmd(s,offset,0,0));
}
emitpcode(POC_MOVWF,popGet(aop,offset));
emitpcode(POC_BTFSS, popGet(AOP(right),0));
emitpcode(POC_INCF, popGet(AOP(result),0));
}
- } else if (AOP_TYPE(right) == AOP_IMMD) {
- DEBUGpic14_emitcode ("; ***","%s %d AOP_IMMD",__FUNCTION__,__LINE__);
- emitpcode(POC_MOVLW, popGet(AOP(right),offset));
- emitpcode(POC_MOVWF, popGet(AOP(result),offset));
} else {
- DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- emitpcode(POC_MOVFW, popGet(AOP(right),offset));
+ mov2w (AOP(right), offset);
emitpcode(POC_MOVWF, popGet(AOP(result),offset));
}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
-pCodeOp *newpCodeOpImmd(char *name, int offset, int index, int code_space)
+pCodeOp *newpCodeOpImmd(char *name, int offset, int index, int code_space, int is_func)
{
pCodeOp *pcop;
pcop = Safe_calloc(1,sizeof(pCodeOpImmd) );
pcop->type = PO_IMMEDIATE;
if(name) {
- regs *r = dirregWithName(name);
+ regs *r = NULL;
pcop->name = Safe_strdup(name);
+
+ if(!is_func)
+ r = dirregWithName(name);
+
PCOI(pcop)->r = r;
if(r) {
//fprintf(stderr, " newpCodeOpImmd reg %s exists\n",name);
PCOI(pcop)->index = index;
PCOI(pcop)->offset = offset;
PCOI(pcop)->_const = code_space;
+ PCOI(pcop)->_function = is_func;
return pcop;
}
typedef struct pCodeOpImmd
{
pCodeOp pcop;
- int offset; /* low,med, or high byte of immediat value */
+ int offset; /* low,med, or high byte of immediate value */
int index; /* add this to the immediate value */
unsigned _const:1; /* is in code space */
+ unsigned _function:1; /* is a (pointer to a) function */
int rIdx; /* If this immd points to a register */
struct regs *r; /* then this is the reg. */
void pBlockConvert2ISR(pBlock *pb);
pCodeOp *newpCodeOpLabel(char *name, int key);
-pCodeOp *newpCodeOpImmd(char *name, int offset, int index, int code_space);
+pCodeOp *newpCodeOpImmd(char *name, int offset, int index, int code_space,int is_func);
pCodeOp *newpCodeOpLit(int lit);
pCodeOp *newpCodeOpBit(char *name, int bit,int inBitSpace);
pCodeOp *newpCodeOpRegFromStr(char *name);