void emitpcode(PIC_OPCODE poc, pCodeOp *pcop)
{
-
if(pcop)
addpCode2pBlock(pb,newpCode(poc,pcop));
else
}
+void emitpcodePagesel(const char *label)
+{
+
+ char code[81];
+ strcpy(code,"\tpagesel ");
+ strcat(code,label);
+ addpCode2pBlock(pb,newpCodeInlineP(code));
+
+}
+
/*-----------------------------------------------------------------*/
/* pic14_emitcode - writes the code into a file : for now it is simple */
/*-----------------------------------------------------------------*/
offset = OP_SYMBOL(IC_LEFT(ic))->offset;
aop->aopu.pcop = popGetImmd(OP_SYMBOL(IC_LEFT(ic))->rname,0,val,0);
+#if 0
PCOI(aop->aopu.pcop)->_const = IS_PTR_CONST(operandType(op));
+#else
+ PCOI(aop->aopu.pcop)->_const = IS_CODEPTR(operandType(op));
+#endif
PCOI(aop->aopu.pcop)->index = val;
DEBUGpic14_emitcode(";","%d: rname %s, val %d, const = %d",
{
sym_link *type = operandType(op);
+#if 0
if(IS_PTR_CONST(type))
+#else
+ if(IS_CODEPTR(type))
+#endif
DEBUGpic14_emitcode(";","%d aop type is const pointer",__LINE__);
}
{
sym_link *type = operandType(op);
+#if 0
if(IS_PTR_CONST(type))
+#else
+ if(IS_CODEPTR(type))
+#endif
DEBUGpic14_emitcode(";","%d aop type is const pointer",__LINE__);
}
DEBUGpic14_emitcode ("; ***","%s key=%d, label offset %d",__FUNCTION__,key, labelOffset);
- if(key>max_key)
+ if(key>(unsigned int)max_key)
max_key = key;
return newpCodeOpLabel(NULL,key+100+labelOffset);
}
+/*-------------------------------------------------------------------*/
+/* popGetLabel - create a new pCodeOp of type PO_LABEL with offset=1 */
+/*-------------------------------------------------------------------*/
+pCodeOp *popGetHighLabel(unsigned int key)
+{
+ pCodeOp *pcop;
+ DEBUGpic14_emitcode ("; ***","%s key=%d, label offset %d",__FUNCTION__,key, labelOffset);
+
+ if(key>(unsigned int)max_key)
+ max_key = key;
+
+ pcop = newpCodeOpLabel(NULL,key+100+labelOffset);
+ PCOLAB(pcop)->offset = 1;
+ return pcop;
+}
+
/*-----------------------------------------------------------------*/
/* popCopyReg - copy a pcode operator */
/*-----------------------------------------------------------------*/
}
-/*-----------------------------------------------------------------*/
-/* genNotFloat - generates not for float operations */
-/*-----------------------------------------------------------------*/
-static void genNotFloat (operand *op, operand *res)
-{
- int size, offset;
- char *l;
- symbol *tlbl ;
-
- DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- /* we will put 127 in the first byte of
- the result */
- aopPut(AOP(res),"#127",0);
- size = AOP_SIZE(op) - 1;
- offset = 1;
-
- l = aopGet(op->aop,offset++,FALSE,FALSE);
- MOVA(l);
-
- while(size--) {
- pic14_emitcode("orl","a,%s",
- aopGet(op->aop,
- offset++,FALSE,FALSE));
- }
- tlbl = newiTempLabel(NULL);
-
- tlbl = newiTempLabel(NULL);
- aopPut(res->aop,one,1);
- pic14_emitcode("jz","%05d_DS_",(tlbl->key+100));
- aopPut(res->aop,zero,1);
- pic14_emitcode("","%05d_DS_:",(tlbl->key+100));
-
- size = res->aop->size - 2;
- offset = 2;
- /* put zeros in the rest */
- while (size--)
- aopPut(res->aop,zero,offset++);
-}
#if 0
/*-----------------------------------------------------------------*/
static void genNot (iCode *ic)
{
symbol *tlbl;
- sym_link *optype = operandType(IC_LEFT(ic));
int size;
DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
goto release;
}
- /* if type float then do float */
- if (IS_FLOAT(optype)) {
- genNotFloat(IC_LEFT(ic),IC_RESULT(ic));
- goto release;
- }
-
- size = AOP_SIZE(IC_RESULT(ic));
+ size = AOP_SIZE(IC_LEFT(ic));
if(size == 1) {
emitpcode(POC_COMFW,popGet(AOP(IC_LEFT(ic)),0));
emitpcode(POC_ANDLW,popGetLit(1));
}
*/
emitpcode(POC_CALL,popGetLabel(albl->key));
+ emitpcodePagesel(popGetLabel(blbl->key)->name); /* Must restore PCLATH before goto, without destroying W */
emitpcode(POC_GOTO,popGetLabel(blbl->key));
emitpLabel(albl->key);
}
#endif
- /* if this is an interrupt service routine then
- save acc, b, dpl, dph */
+ /* if this is an interrupt service routine */
if (IFFUNC_ISISR(sym->type)) {
+/* already done in pic14createInterruptVect() - delete me
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));
+ emitpcode(POC_MOVFW, popCopyReg(&pc_pclath));
+ emitpcode(POC_MOVWF, popCopyReg(&pc_psave));
+ emitpcode(POC_CLRF, popCopyReg(&pc_pclath));/* durring an interrupt PCLATH must be cleared before a goto or call statement */
pBlockConvert2ISR(pb);
#if 0
pic14_emitcode(";","XG$%s$0$0 ==.",currFunc->name);
_G.debugLine = 0;
}
-
- 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_SWAPFW, popCopyReg(&pc_wsave));
- addpCode2pBlock(pb,newpCodeLabel("END_OF_INTERRUPT",-1));
-
- emitpcodeNULLop(POC_RETFIE);
+ pic14_emitcode ("reti","");
+ emitpcode(POC_MOVFW, popCopyReg(&pc_psave));
+ emitpcode(POC_MOVWF, popCopyReg(&pc_pclath));
+ 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_SWAPFW, popCopyReg(&pc_wsave));
+ addpCode2pBlock(pb,newpCodeLabel("END_OF_INTERRUPT",-1));
+ emitpcodeNULLop(POC_RETFIE);
}
else {
if (IFFUNC_ISCRITICAL(sym->type))
} else {
pic14_emitcode("movlw","0x%x", (lit & 0xff));
pic14_emitcode("andwf","%s,f",aopGet(AOP(left),offset,FALSE,TRUE));
- if(know_W != (lit&0xff))
+ if(know_W != (int)(lit&0xff))
emitpcode(POC_MOVLW, popGetLit(lit & 0xff));
know_W = lit &0xff;
emitpcode(POC_ANDWF,popGet(AOP(left),offset));
emitpcode(POC_BSF,
newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),p,0));
} else {
- if(know_W != (lit & 0xff))
+ if(know_W != (int)(lit & 0xff))
emitpcode(POC_MOVLW, popGetLit(lit & 0xff));
know_W = lit & 0xff;
emitpcode(POC_IORWF, popGet(AOP(left),offset));
DEBUGpic14_emitcode ("; "," %d getting const pointer",__LINE__);
emitpcode(POC_CALL,popGetLabel(albl->key));
+ emitpcodePagesel(popGetLabel(blbl->key)->name); /* Must restore PCLATH before goto, without destroying W */
emitpcode(POC_GOTO,popGetLabel(blbl->key));
emitpLabel(albl->key);
type = operandType(left);
etype = getSpec(type);
+#if 0
if (IS_PTR_CONST(type))
+#else
+ if (IS_CODEPTR(type))
+#endif
DEBUGpic14_emitcode ("; ***","%d - const pointer",__LINE__);
/* if left is of type of pointer then it is simple */
break;
case GPOINTER:
+#if 0
if (IS_PTR_CONST(type))
genConstPointerGet (left,result,ic);
else
+#endif
genGenPointerGet (left,result,ic);
break;
}
DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
if(AOP_TYPE(right) == AOP_LIT) {
if(lit&0xff) {
- if(know_W != (lit&0xff))
+ if(know_W != (int)(lit&0xff))
emitpcode(POC_MOVLW,popGetLit(lit&0xff));
know_W = lit&0xff;
emitpcode(POC_MOVWF, popGet(AOP(result),offset));
pic14_emitcode("jmp","@a+dptr");
pic14_emitcode("","%05d_DS_:",jtab->key+100);
+ emitpcode(POC_MOVLW, popGetHighLabel(jtab->key));
+ emitpcode(POC_MOVWF, popCopyReg(&pc_pclath));
emitpcode(POC_MOVLW, popGetLabel(jtab->key));
emitpcode(POC_ADDFW, popGet(AOP(IC_JTCOND(ic)),0));
emitSKPNC;
goto release;
DEBUGpic14_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
+#if 0
if (IS_PTR_CONST(rtype))
+#else
+ if (IS_CODEPTR(rtype))
+#endif
DEBUGpic14_emitcode ("; ***","%d - right is const pointer",__LINE__);
+#if 0
if (IS_PTR_CONST(operandType(IC_RESULT(ic))))
+#else
+ if (IS_CODEPTR(operandType(IC_RESULT(ic))))
+#endif
DEBUGpic14_emitcode ("; ***","%d - result is const pointer",__LINE__);
if ((AOP_TYPE(right) == AOP_PCODE) && AOP(right)->aopu.pcop->type == PO_IMMEDIATE) {
pic14_emitcode ("; genDummyRead","");
pic14_emitcode ("; not implemented","");
- ic;
+ ic = ic;
}
/*-----------------------------------------------------------------*/