/*-------------------------------------------------------------------------
- SDCCgen51.c - source file for code generation for 8051
+ gen.c - source file for code generation for pic
Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998)
and - Jean-Louis VERN.jlvern@writeme.com (1999)
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));
}
/* genReceive - generate code for a receive iCode */
/*-----------------------------------------------------------------*/
static void genReceive (iCode *ic)
-{
+{
DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- if (isOperandInFarSpace(IC_RESULT(ic)) &&
+ if (isOperandInFarSpace(IC_RESULT(ic)) &&
( OP_SYMBOL(IC_RESULT(ic))->isspilt ||
IS_TRUE_SYMOP(IC_RESULT(ic))) ) {
fReturn[fReturnSizePic - offset - 1] : "acc"));
offset++;
}
- aopOp(IC_RESULT(ic),ic,FALSE);
+ 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);
+ aopOp(IC_RESULT(ic),ic,FALSE);
_G.accInUse--;
- assignResultValue(IC_RESULT(ic));
+ assignResultValue(IC_RESULT(ic));
}
freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
}
+/*-----------------------------------------------------------------*/
+/* genDummyRead - generate code for dummy read of volatiles */
+/*-----------------------------------------------------------------*/
+static void
+genDummyRead (iCode * ic)
+{
+ pic14_emitcode ("; genDummyRead","");
+ pic14_emitcode ("; not implemented","");
+
+ ic = ic;
+}
+
/*-----------------------------------------------------------------*/
/* genpic14Code - generate code for pic14 based controllers */
/*-----------------------------------------------------------------*/
addSet(&_G.sendSet,ic);
break;
+ case DUMMY_READ_VOLATILE:
+ genDummyRead (ic);
+ break;
+
default :
ic = ic;
}
}
-
- /* now we are ready to call the
+
+ /* now we are ready to call the
peep hole optimizer */
if (!options.nopeep) {
peepHole (&lineHead);