/* if the registers have been saved already then
do nothing */
- if (ic->regsSaved || IFFUNC_CALLEESAVES(OP_SYMBOL (IC_LEFT (ic))->type) ||
- IFFUNC_ISNAKED(OP_SYM_TYPE(IC_LEFT(ic))))
- return;
-
- /* find the registers in use at this time
- and push them away to safety */
- rsave = bitVectCplAnd (bitVectCopy (ic->rMask),
- ic->rUsed);
-
+ if (ic->regsSaved || IFFUNC_ISNAKED(OP_SYM_TYPE(IC_LEFT(ic)))) return ;
+
+ /* special case if DPTR alive across a function call then must save it
+ even though callee saves */
+ if (IFFUNC_CALLEESAVES(OP_SYMBOL (IC_LEFT (ic))->type)) {
+ int i =0;
+ rsave = newBitVect(ic->rMask->size);
+ for (i = DPL_IDX ; i <= B_IDX ; i++ ) {
+ if (bitVectBitValue(ic->rMask,i))
+ rsave = bitVectSetBit(rsave,i);
+ }
+ } else {
+ /* find the registers in use at this time
+ and push them away to safety */
+ rsave = bitVectCplAnd (bitVectCopy (ic->rMask),
+ ic->rUsed);
+ }
ic->regsSaved = 1;
if (options.useXstack)
{
{
int i;
bitVect *rsave;
- /* find the registers in use at this time
- and push them away to safety */
- rsave = bitVectCplAnd (bitVectCopy (ic->rMask),
- ic->rUsed);
+ if (IFFUNC_CALLEESAVES(OP_SYMBOL (IC_LEFT (ic))->type)) {
+ int i =0;
+ rsave = newBitVect(ic->rMask->size);
+ for (i = DPL_IDX ; i <= B_IDX ; i++ ) {
+ if (bitVectBitValue(ic->rMask,i))
+ rsave = bitVectSetBit(rsave,i);
+ }
+ } else {
+ /* find the registers in use at this time
+ and push them away to safety */
+ rsave = bitVectCplAnd (bitVectCopy (ic->rMask),
+ ic->rUsed);
+ }
if (options.useXstack)
{
emitcode ("mov", "r0,%s", spname);
emitcode ("subb","a,#0x%02x",ic->parmBytes & 0xff);
emitcode ("mov","sp,a");
emitcode ("mov","a,#0x%02x",(ic->parmBytes >> 8) & 0xff);
- emitcode ("subb","a,_ESP");
- emitcode ("mov","_ESP,a");
+ emitcode ("subb","a,esp");
+ emitcode ("mov","esp,a");
} else {
int i;
if (ic->parmBytes > 3) {
}
/* if we hade saved some registers then unsave them */
- if (ic->regsSaved && !IFFUNC_CALLEESAVES(dtype))
+ if (ic->regsSaved)
unsaveRegisters (ic);
/* if register bank was saved then pop them */
/* if we hade saved some registers then
unsave them */
- if (ic->regsSaved && !IFFUNC_CALLEESAVES(dtype))
+ if (ic->regsSaved)
unsaveRegisters (ic);
}
emitcode ("push","_bpx");
emitcode ("push","_bpx+1");
emitcode ("mov","_bpx,%s",spname);
- emitcode ("mov","_bpx+1,_ESP");
+ emitcode ("mov","_bpx+1,esp");
emitcode ("anl","_bpx+1,#3");
} else {
if (options.useXstack) {
emitcode ("mov","a,sp");
emitcode ("add","a,#0x%02x", ((short) sym->stack & 0xff));
emitcode ("mov","sp,a");
- emitcode ("mov","a,_ESP");
+ emitcode ("mov","a,esp");
emitcode ("addc","a,0x%02x", (((short) sym->stack) >> 8) & 0xff);
- emitcode ("mov","_ESP,a");
+ emitcode ("mov","esp,a");
} else {
if (i > 256)
werror (W_STACK_OVERFLOW, sym->name);
if (IFFUNC_ISREENT (sym->type) || options.stackAuto) {
if (options.stack10bit) {
emitcode ("mov", "sp,_bpx", spname);
- emitcode ("mov", "_ESP,_bpx+1", spname);
+ emitcode ("mov", "esp,_bpx+1", spname);
} else {
emitcode ("mov", "%s,_bp", spname);
}
isOperandLiteral(IC_RIGHT(ic)) && OP_SYMBOL(IC_RESULT(ic))->ruonly) {
aopOp (IC_RIGHT (ic), ic, TRUE, FALSE);
size = floatFromVal (AOP (IC_RIGHT(ic))->aopu.aop_lit);
- while (size--) emitcode ("inc","dptr");
+ if (size <= 9) {
+ while (size--) emitcode ("inc","dptr");
+ } else {
+ emitcode ("mov","a,dpl");
+ emitcode ("add","a,#0x%02x",size & 0xff);
+ emitcode ("mov","dpl,a");
+ emitcode ("mov","a,dph");
+ emitcode ("addc","a,#0x%02x",(size >> 8) & 0xff);
+ emitcode ("mov","dph,a");
+ emitcode ("mov","a,dpx");
+ emitcode ("addc","a,#0x%02x",(size >> 16) & 0xff);
+ emitcode ("mov","dpx,a");
+ }
freeAsmop (IC_RIGHT (ic), NULL, ic, FALSE);
return ;
}
genFarPointerGet (operand * left,
operand * result, iCode * ic, iCode *pi)
{
- int size, offset;
+ int size, offset, dopi=1;
sym_link *retype = getSpec (operandType (result));
sym_link *letype = getSpec (operandType (left));
D (emitcode (";", "genFarPointerGet");
emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE));
emitcode ("pop", "dph");
emitcode ("pop", "dpl");
+ dopi =0;
}
_endLazyDPSEvaluation ();
}
_flushLazyDPS ();
emitcode ("movx", "a,@dptr");
- if (size || (pi && AOP_TYPE (left) != AOP_IMMD))
+ if (size || (dopi && pi && AOP_TYPE (left) != AOP_IMMD))
emitcode ("inc", "dptr");
aopPut (AOP (result), "a", offset++);
}
_endLazyDPSEvaluation ();
}
- if (pi && AOP_TYPE (left) != AOP_IMMD) {
+ if (dopi && pi && AOP_TYPE (left) != AOP_IMMD) {
aopPut ( AOP (left), "dpl", 0);
aopPut ( AOP (left), "dph", 1);
if (options.model == MODEL_FLAT24)
emitcodePointerGet (operand * left,
operand * result, iCode * ic, iCode *pi)
{
- int size, offset;
+ int size, offset, dopi=1;
sym_link *retype = getSpec (operandType (result));
aopOp (left, ic, FALSE, FALSE);
emitcode ("mov", "dpx,%s", aopGet (AOP (left), 2, FALSE, FALSE, TRUE));
emitcode ("pop", "dph");
emitcode ("pop", "dpl");
+ dopi=0;
}
_endLazyDPSEvaluation ();
}
emitcode ("clr", "a");
emitcode ("movc", "a,@a+dptr");
- if (size || (pi && AOP_TYPE (left) != AOP_IMMD))
+ if (size || (dopi && pi && AOP_TYPE (left) != AOP_IMMD))
emitcode ("inc", "dptr");
aopPut (AOP (result), "a", offset++);
}
_endLazyDPSEvaluation ();
}
- if (pi && AOP_TYPE (left) != AOP_IMMD) {
+ if (dopi && pi && AOP_TYPE (left) != AOP_IMMD) {
aopPut ( AOP (left), "dpl", 0);
aopPut ( AOP (left), "dph", 1);
if (options.model == MODEL_FLAT24)
genFarPointerSet (operand * right,
operand * result, iCode * ic, iCode *pi)
{
- int size, offset;
+ int size, offset, dopi=1;
sym_link *retype = getSpec (operandType (right));
sym_link *letype = getSpec (operandType (result));
emitcode ("mov", "dpx,%s", aopGet (AOP (result), 2, FALSE, FALSE, TRUE));
emitcode ("pop", "dph");
emitcode ("pop", "dpl");
+ dopi=0;
}
_endLazyDPSEvaluation ();
}
_flushLazyDPS ();
emitcode ("movx", "@dptr,a");
- if (size || (pi && AOP_TYPE (result) != AOP_IMMD))
+ if (size || (dopi && pi && AOP_TYPE (result) != AOP_IMMD))
emitcode ("inc", "dptr");
}
_endLazyDPSEvaluation ();
}
- if (pi && AOP_TYPE (result) != AOP_IMMD) {
+ if (dopi && pi && AOP_TYPE (result) != AOP_IMMD) {
aopPut (AOP(result),"dpl",0);
aopPut (AOP(result),"dph",1);
if (options.model == MODEL_FLAT24)
/* if 10 bit stack */
if (options.stack10bit) {
/* if it has an offset then we need to compute it */
+ emitcode ("subb", "a,#0x%02x",
+ -((sym->stack < 0) ?
+ ((short) (sym->stack - _G.nRegsSaved)) :
+ ((short) sym->stack)) & 0xff);
+ emitcode ("mov","b,a");
+ emitcode ("mov","a,#0x%02x",(-((sym->stack < 0) ?
+ ((short) (sym->stack - _G.nRegsSaved)) :
+ ((short) sym->stack)) >> 8) & 0xff);
if (sym->stack) {
emitcode ("mov", "a,_bpx");
- emitcode ("add", "a,#0x%02x", ((char) sym->stack & 0xff));
+ emitcode ("add", "a,#0x%02x", ((sym->stack < 0) ?
+ ((char) (sym->stack - _G.nRegsSaved)) :
+ ((char) sym->stack )) & 0xff);
emitcode ("mov", "b,a");
emitcode ("mov", "a,_bpx+1");
- emitcode ("addc","a,#0x%02x", (((short) sym->stack) >> 8) & 0xff);
+ emitcode ("addc","a,#0x%02x", (((sym->stack < 0) ?
+ ((short) (sym->stack - _G.nRegsSaved)) :
+ ((short) sym->stack )) >> 8) & 0xff);
aopPut (AOP (IC_RESULT (ic)), "b", 0);
aopPut (AOP (IC_RESULT (ic)), "a", 1);
aopPut (AOP (IC_RESULT (ic)), "#0x40", 2);