if (stack_val < 0 && stack_val > -5) { /* between -5 & -1 */
if (useDP2) {
if (options.model == MODEL_FLAT24)
- emitcode ("mov", "dpx1,#!constbyte", (options.stack_loc >> 16) & 0xff);
- TR_DPTR("#2");
+ {
+ emitcode ("mov", "dpx1,#!constbyte",
+ (options.stack_loc >> 16) & 0xff);
+ }
emitcode ("mov", "dph1,_bpx+1");
+
emitcode ("mov", "dpl1,_bpx");
emitcode ("mov","dps,#1");
} else {
if (options.model == MODEL_FLAT24)
- emitcode ("mov", "dpx,#!constbyte", (options.stack_loc >> 16) & 0xff);
+ {
+ emitcode ("mov", "dpx,#!constbyte",
+ (options.stack_loc >> 16) & 0xff);
+ }
emitcode ("mov", "dph,_bpx+1");
emitcode ("mov", "dpl,_bpx");
}
emitcode ("subb","a,#!constbyte",(stack_val >> 8) & 0xff);
if (useDP2) {
if (options.model == MODEL_FLAT24)
- emitcode ("mov", "dpx1,#!constbyte", (options.stack_loc >> 16) & 0xff);
- TR_DPTR("#2");
+ {
+ emitcode ("mov", "dpx1,#!constbyte",
+ (options.stack_loc >> 16) & 0xff);
+ }
emitcode ("mov", "dph1,a");
emitcode ("mov", "dpl1,b");
} else {
if (options.model == MODEL_FLAT24)
- emitcode ("mov", "dpx,#!constbyte", (options.stack_loc >> 16) & 0xff);
+ {
+ emitcode ("mov", "dpx,#!constbyte",
+ (options.stack_loc >> 16) & 0xff);
+ }
emitcode ("mov", "dph,a");
emitcode ("mov", "dpl,b");
}
}
}
+static void
+adjustEsp(const char *reg)
+{
+ emitcode ("anl","%s,#3", reg);
+ if (TARGET_IS_DS400)
+ {
+ emitcode ("orl","%s,#!constbyte",
+ reg,
+ (options.stack_loc >> 8) & 0xff);
+ }
+}
+
/*-----------------------------------------------------------------*/
/* genCall - generates a call statement */
/*-----------------------------------------------------------------*/
emitcode ("subb","a,#!constbyte",ic->parmBytes & 0xff);
emitcode ("mov","sp,a");
emitcode ("mov","a,esp");
- emitcode ("anl","a,#3");
+ adjustEsp("a");
emitcode ("subb","a,#!constbyte",(ic->parmBytes >> 8) & 0xff);
emitcode ("mov","esp,a");
UNPROTECT_SP;
emitcode ("subb","a,#!constbyte",ic->parmBytes & 0xff);
emitcode ("mov","sp,a");
emitcode ("mov","a,esp");
- emitcode ("anl","a,#3");
+ adjustEsp("a");
emitcode ("subb","a,#!constbyte",(ic->parmBytes >> 8) & 0xff);
emitcode ("mov","esp,a");
UNPROTECT_SP;
emitcode ("push","_bpx+1");
emitcode ("mov","_bpx,%s",spname);
emitcode ("mov","_bpx+1,esp");
- emitcode ("anl","_bpx+1,#3");
+ adjustEsp("_bpx+1");
} else {
if (options.useXstack) {
emitcode ("mov", "r0,%s", spname);
emitcode ("add","a,#!constbyte", ((short) sym->stack & 0xff));
emitcode ("mov","sp,a");
emitcode ("mov","a,esp");
- emitcode ("anl","a,#3");
+ adjustEsp("a");
emitcode ("addc","a,#!constbyte", (((short) sym->stack) >> 8) & 0xff);
emitcode ("mov","esp,a");
UNPROTECT_SP;
// AOP_IS_DPTRn(IC_LEFT(ic)) ? "true" : "false",
// AOP_IS_DPTRn(IC_RIGHT(ic)) ? "true" : "false",
// AOP_IS_DPTRn(IC_RESULT(ic)) ? "true" : "false");
-// );
-
+// );
- // Right uses DPTR unless left or result is an AOP_STR.
- aopOp (IC_RIGHT(ic),ic,FALSE, AOP_IS_STR(IC_LEFT(ic)) || AOP_IS_STR(IC_RESULT(ic)));
+ // Right uses DPTR unless left or result is an AOP_STR; however,
+ // if right is an AOP_STR, it must use DPTR regardless.
+ if ((AOP_IS_STR(IC_LEFT(ic)) || AOP_IS_STR(IC_RESULT(ic)))
+ && !AOP_IS_STR(IC_RIGHT(ic)))
+ {
+ useDp2 = TRUE;
+ }
+ else
+ {
+ useDp2 = FALSE;
+ }
+
+ aopOp (IC_RIGHT(ic),ic,FALSE, useDp2);
// if the right used DPTR, left MUST use DPTR2.
// if the right used DPTR2, left MUST use DPTR.
AOP_TYPE (right) == AOP_CRY)
{
emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir);
- emitcode ("anl", "c,/%s", AOP (left)->aopu.aop_dir);
+ emitcode ("anl", "c,%s", AOP (left)->aopu.aop_dir);
}
else
{
}
#endif
-#if 0
-//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftLLeftOrResult - shift left one byte from left, or to result */
/*-----------------------------------------------------------------*/
/* back to result */
aopPut (AOP (result), "a", offr);
}
-#endif
#if 0
//REMOVE ME!!!
}
#endif
-#if 0
-//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftRLong - shift right one long from left to result */
/* offl = LSB or MSB16 */
werror(E_INTERNAL_ERROR, __FILE__, __LINE__);
}
- MOVA (aopGet (AOP (left), MSB32, FALSE, NULL));
+ MOVA (aopGet (AOP (left), MSB32, FALSE, FALSE, NULL));
if (offl==MSB16) {
// shift is > 8
emitcode ("rlc", "a");
emitcode ("subb", "a,acc");
emitcode ("xch", "a,%s",
- aopGet(AOP(left), MSB32, FALSE, DP2_RESULT_REG));
+ aopGet(AOP(left), MSB32, FALSE, FALSE, DP2_RESULT_REG));
} else {
aopPut (AOP(result), zero, MSB32);
}
if (isSameRegs && offl==MSB16) {
emitcode ("xch",
- "a,%s",aopGet (AOP (left), MSB24, FALSE, DP2_RESULT_REG));
+ "a,%s",aopGet (AOP (left), MSB24, FALSE, FALSE, DP2_RESULT_REG));
} else {
aopPut (AOP (result), "a", MSB32);
- MOVA (aopGet (AOP (left), MSB24, FALSE, NULL));
+ MOVA (aopGet (AOP (left), MSB24, FALSE, FALSE, NULL));
}
emitcode ("rrc", "a");
if (isSameRegs && offl==1) {
emitcode ("xch", "a,%s",
- aopGet (AOP (left), MSB16, FALSE, DP2_RESULT_REG));
+ aopGet (AOP (left), MSB16, FALSE, FALSE, DP2_RESULT_REG));
} else {
aopPut (AOP (result), "a", MSB24);
- MOVA (aopGet (AOP (left), MSB16, FALSE, NULL));
+ MOVA (aopGet (AOP (left), MSB16, FALSE, FALSE, NULL));
}
emitcode ("rrc", "a");
aopPut (AOP (result), "a", MSB16 - offl);
if (offl == LSB)
{
- MOVA (aopGet (AOP (left), LSB, FALSE, NULL));
+ MOVA (aopGet (AOP (left), LSB, FALSE, FALSE, NULL));
emitcode ("rrc", "a");
aopPut (AOP (result), "a", LSB);
}
}
-#endif
-#if 0
-//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* genrshFour - shift four byte by a known amount != 0 */
/*-----------------------------------------------------------------*/
genrshFour (operand * result, operand * left,
int shCount, int sign)
{
- D (emitcode (";", "genrshFour");
- );
+ D (emitcode (";", "genrshFour"););
/* if shifting more that 3 bytes */
if (shCount >= 24)
{
shCount -= 24;
+ _startLazyDPSEvaluation();
if (shCount)
shiftR1Left2Result (left, MSB32, result, LSB, shCount, sign);
else
movLeft2Result (left, MSB32, result, LSB, sign);
addSign (result, MSB16, sign);
+ _endLazyDPSEvaluation();
}
else if (shCount >= 16)
{
shCount -= 16;
+ _startLazyDPSEvaluation();
if (shCount)
shiftR2Left2Result (left, MSB24, result, LSB, shCount, sign);
else
movLeft2Result (left, MSB32, result, MSB16, sign);
}
addSign (result, MSB24, sign);
+ _endLazyDPSEvaluation();
}
else if (shCount >= 8)
{
shCount -= 8;
+ _startLazyDPSEvaluation();
if (shCount == 1)
- shiftRLong (left, MSB16, result, sign);
+ {
+ shiftRLong (left, MSB16, result, sign);
+ }
else if (shCount == 0)
{
movLeft2Result (left, MSB16, result, LSB, 0);
shiftR1Left2Result (left, MSB32, result, MSB24, shCount, sign);
addSign (result, MSB32, sign);
}
+ _endLazyDPSEvaluation();
}
else
- { /* 1 <= shCount <= 7 */
+ {
+ /* 1 <= shCount <= 7 */
if (shCount <= 2)
{
shiftRLong (left, LSB, result, sign);
}
}
}
-#endif
#ifdef BETTER_LITERAL_SHIFT
/*-----------------------------------------------------------------*/
if ((shCount != 0)
&& (shCount < (size * 8))
&& (size != 1)
- && (size != 2))
+ && (size != 2)
+ /* && (size != 4) in a minute... */)
{
D(emitcode (";", "genRightShiftLiteral wimping out"););
return FALSE;
case 2:
genrshTwo (result, left, shCount, sign);
break;
-#if 0
+#if 1
case 4:
genrshFour (result, left, shCount, sign);
break;
/* if 10 bit stack */
if (options.stack10bit) {
char buff[10];
+ int offset;
+
tsprintf(buff, sizeof(buff),
"#!constbyte",(options.stack_loc >> 16) & 0xff);
/* if it has an offset then we need to compute it */
((char) sym->stack )) & 0xff);
emitcode ("mov", "b,a");
emitcode ("mov", "a,_bpx+1");
- emitcode ("addc","a,#!constbyte", (((sym->stack < 0) ?
- ((short) (sym->stack - _G.nRegsSaved)) :
- ((short) sym->stack )) >> 8) & 0xff);
+
+ offset = (((sym->stack < 0) ?
+ ((short) (sym->stack - _G.nRegsSaved)) :
+ ((short) sym->stack )) >> 8) & 0xff;
+
+ emitcode ("addc","a,#!constbyte", offset);
+
aopPut (AOP (IC_RESULT (ic)), "b", 0);
aopPut (AOP (IC_RESULT (ic)), "a", 1);
aopPut (AOP (IC_RESULT (ic)), buff, 2);
}
+#if 0 // obsolete, and buggy for != xdata
/*-----------------------------------------------------------------*/
/* genArrayInit - generates code for address of */
/*-----------------------------------------------------------------*/
freeAsmop (IC_LEFT(ic), NULL, ic, TRUE);
}
+#endif
/*-----------------------------------------------------------------*/
/* genFarFarAssign - assignment when both are in far space */
/* also, if the source is a bit, we don't need to sign extend, because
* it can't possibly have set the sign bit.
*/
- if (SPEC_USIGN (rtype) || !IS_SPEC (rtype) || AOP_TYPE (right) == AOP_CRY)
+ if (!IS_SPEC (rtype) || SPEC_USIGN (rtype) || AOP_TYPE (right) == AOP_CRY)
{
while (size--)
{
}
#if 1
/* print the allocation information */
- if (allocInfo)
+ if (allocInfo && currFunc)
printAllocInfo (currFunc, codeOutFile);
#endif
/* if debug information required */
else addSet (&_G.sendSet, ic);
break;
+#if 0 // obsolete, and buggy for != xdata
case ARRAYINIT:
genArrayInit(ic);
break;
+#endif
default:
ic = ic;