#endif
#endif
-// #define BETTER_LITERAL_SHIFT
+#define BETTER_LITERAL_SHIFT
char *aopLiteral (value * val, int offset);
}
_G;
-static void saverbank (int, iCode *, bool);
+static void saveRBank (int, iCode *, bool);
#define RESULTONSTACK(x) \
(IC_RESULT(x) && IC_RESULT(x)->aop && \
emitcode (char *inst, char *fmt,...)
{
va_list ap;
- char lb[MAX_INLINEASM];
+ char lb[INITIAL_INLINEASM];
char *lbp = lb;
va_start (ap, fmt);
if (useDP2)
{
- /* genSetDPTR(1); */
emitcode ("mov", "dpx1,#0x40");
emitcode ("mov", "dph1,#0x00");
emitcode ("mov", "dpl1, a");
- /* genSetDPTR(0); */
}
else
{
for (i = 0; i < ds390_nRegs; i++)
{
if (bitVectBitValue (rsave, i))
- emitcode ("push", "%s ;jwk saveRegisters", ds390_regWithIdx (i)->dname);
+ emitcode ("push", "%s", ds390_regWithIdx (i)->dname);
}
detype = getSpec (operandType (IC_LEFT (ic)));
+
+#if 0 // why should we do this here??? jwk20011105
if (detype &&
(SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)) &&
IS_ISR (currFunc->etype) &&
!ic->bankSaved)
-
- saverbank (SPEC_BANK (detype), ic, TRUE);
+ saveRBank (SPEC_BANK (detype), ic, TRUE);
+#endif
}
/*-----------------------------------------------------------------*/
for (i = ds390_nRegs; i >= 0; i--)
{
if (bitVectBitValue (rsave, i))
- emitcode ("pop", "%s ;jwk unsaveRegisters", ds390_regWithIdx (i)->dname);
+ emitcode ("pop", "%s", ds390_regWithIdx (i)->dname);
}
}
MOVA (l);
l = "acc";
}
- emitcode ("push", "%s ;jwk genIpush: !parm", l);
+ emitcode ("push", "%s", l);
}
_endLazyDPSEvaluation ();
return;
emitcode ("push", "acc");
}
else
- emitcode ("push", "%s ;jwk genIpush", l);
+ emitcode ("push", "%s", l);
}
_endLazyDPSEvaluation ();
_startLazyDPSEvaluation ();
while (size--)
{
- emitcode ("pop", "%s ;jwk genIpop", aopGet (AOP (IC_LEFT (ic)), offset--,
+ emitcode ("pop", "%s", aopGet (AOP (IC_LEFT (ic)), offset--,
FALSE, TRUE, TRUE));
}
_endLazyDPSEvaluation ();
}
/*-----------------------------------------------------------------*/
-/* unsaverbank - restores the resgister bank from stack */
+/* unsaveRBank - restores the resgister bank from stack */
/*-----------------------------------------------------------------*/
static void
-unsaverbank (int bank, iCode * ic, bool popPsw)
+unsaveRBank (int bank, iCode * ic, bool popPsw)
{
int i;
asmop *aop;
}
/*-----------------------------------------------------------------*/
-/* saverbank - saves an entire register bank on the stack */
+/* saveRBank - saves an entire register bank on the stack */
/*-----------------------------------------------------------------*/
static void
-saverbank (int bank, iCode * ic, bool pushPsw)
+saveRBank (int bank, iCode * ic, bool pushPsw)
{
int i;
asmop *aop;
D (emitcode (";", "genCall ");
);
- /* if caller saves & we have not saved then */
- if (!ic->regsSaved)
- saveRegisters (ic);
-
- /* if we are calling a function that is not using
- the same register bank then we need to save the
- destination registers on the stack */
- detype = getSpec (operandType (IC_LEFT (ic)));
- if (detype &&
- (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)) &&
- IS_ISR (currFunc->etype) &&
- !ic->bankSaved)
-
- saverbank (SPEC_BANK (detype), ic, TRUE);
-
/* if send set is not empty the assign */
if (_G.sendSet)
{
if (strcmp (l, fReturn[offset])) {
genSetDPTR(0);
_flushLazyDPS();
- emitcode ("mov", "%s,%s ;jwk lazy genCall",
+ emitcode ("mov", "%s,%s",
fReturn[offset],
l);
}
}
_G.sendSet = NULL;
}
+
+ /* if we are calling a function that is not using
+ the same register bank then we need to save the
+ destination registers on the stack */
+ detype = getSpec (operandType (IC_LEFT (ic)));
+ if (detype &&
+ (SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)) &&
+ IS_ISR (currFunc->etype) &&
+ !ic->bankSaved) {
+ saveRBank (SPEC_BANK (detype), ic, TRUE);
+ } else /* no need to save if we just saved the whole bank */ {
+ /* if caller saves & we have not saved then */
+ if (!ic->regsSaved)
+ saveRegisters (ic);
+ }
+
/* make the call */
emitcode ("lcall", "%s", (OP_SYMBOL (IC_LEFT (ic))->rname[0] ?
OP_SYMBOL (IC_LEFT (ic))->rname :
int size = getSize (operandType (IC_RESULT (ic)));
/* Special case for 1 or 2 byte return in far space. */
- emitcode (";", "Kevin function call abuse #1");
-
MOVA (fReturn[0]);
if (size > 1)
{
/* if register bank was saved then pop them */
if (ic->bankSaved)
- unsaverbank (SPEC_BANK (detype), ic, TRUE);
+ unsaveRBank (SPEC_BANK (detype), ic, TRUE);
/* if we hade saved some registers then unsave them */
if (ic->regsSaved && !(OP_SYMBOL (IC_LEFT (ic))->calleeSave))
if (detype &&
IS_ISR (currFunc->etype) &&
(SPEC_BANK (currFunc->etype) != SPEC_BANK (detype)))
- saverbank (SPEC_BANK (detype), ic, TRUE);
+ saveRBank (SPEC_BANK (detype), ic, TRUE);
/* push the return address on to the stack */
if (detype &&
(SPEC_BANK (currFunc->etype) !=
SPEC_BANK (detype)))
- unsaverbank (SPEC_BANK (detype), ic, TRUE);
+ unsaveRBank (SPEC_BANK (detype), ic, TRUE);
/* if we hade saved some registers then
unsave them */
else
{
/* this function has a function call cannot
- determines register usage so we will have the
+ determines register usage so we will have to push the
entire bank */
- saverbank (0, ic, FALSE);
+ saveRBank (0, ic, FALSE);
}
}
}
else
{
/* this function has a function call cannot
- determines register usage so we will have the
+ determines register usage so we will have to pop the
entire bank */
- unsaverbank (0, ic, FALSE);
+ unsaveRBank (0, ic, FALSE);
}
}
}
else
{
+ /* Since A is the last element of fReturn,
+ * is is OK to clobber it in the aopGet.
+ */
l = aopGet (AOP (IC_LEFT (ic)), offset,
- FALSE, FALSE, FALSE);
+ FALSE, FALSE, TRUE);
if (strcmp (fReturn[offset], l))
emitcode ("mov", "%s,%s", fReturn[offset++], l);
}
symbol *lbl;
int size=AOP_SIZE(result);
- emitcode (";",__FUNCTION__);
if (size<1 || size>2) {
// this should never happen
fprintf (stderr, "size!=1||2 (%d) in %s at line:%d \n",
- AOP_SIZE(result), __FUNCTION__, lineno);
+ AOP_SIZE(result), __FILE__, lineno);
exit (1);
}
static void
genInline (iCode * ic)
{
- char buffer[MAX_INLINEASM];
- char *bp = buffer;
- char *bp1 = buffer;
+ char *buffer, *bp, *bp1;
D (emitcode (";", "genInline ");
);
_G.inLine += (!options.asmpeep);
+
+ buffer = bp = bp1 = Safe_calloc(1, strlen(IC_INLINE(ic))+1);
strcpy (buffer, IC_INLINE (ic));
/* emit each line as a code */
{
char *leftByte;
- D(emitcode(";", "watch me do the hambone!"););
_startLazyDPSEvaluation();
if (AOP_TYPE(left) == AOP_DPTR2)
{
shCount -= 8;
_startLazyDPSEvaluation();
- aopPut (AOP (result), zero, LSB);
+
if (size > 1)
{
if (shCount)
{
_endLazyDPSEvaluation();
shiftL1Left2Result (left, LSB, result, MSB16, shCount);
+ aopPut (AOP (result), zero, LSB);
}
else
{
movLeft2Result (left, LSB, result, MSB16, 0);
+ aopPut (AOP (result), zero, LSB);
_endLazyDPSEvaluation();
}
}
else
{
+ aopPut (AOP (result), zero, LSB);
_endLazyDPSEvaluation();
}
}
l=aopGet(AOP(left),0,FALSE,FALSE,TRUE);
genSetDPTR(0);
_flushLazyDPS();
- emitcode ("mov", "dpl,%s ;jwk lazy genGenPointerGet", l);
+ emitcode ("mov", "dpl,%s", l);
l=aopGet(AOP(left),1,FALSE,FALSE,TRUE);
genSetDPTR(0);
_flushLazyDPS();
- emitcode ("mov", "dph,%s ;jwk lazy genGenPointerGet", l);
+ emitcode ("mov", "dph,%s", l);
l=aopGet(AOP(left),2,FALSE,FALSE,TRUE);
genSetDPTR(0);
_flushLazyDPS();
- emitcode ("mov", "dpx,%s ;jwk lazy genGenPointerGet", l);
+ emitcode ("mov", "dpx,%s", l);
emitcode ("mov", "b,%s", aopGet (AOP(left),3,FALSE,FALSE,TRUE));
} else {
emitcode ("mov", "dpl,%s", aopGet (AOP(left),0,FALSE,FALSE,TRUE));
{
int size = AOP_SIZE (right);
int offset = 0;
- char *l;
-
- if (size > 1)
- {
- /* This is a net loss for size == 1, but a big gain
- * otherwise.
- */
- D (emitcode (";", "genFarFarAssign (improved)");
- );
+ symbol *rSym = NULL;
+ if (size == 1)
+ {
+ /* quick & easy case. */
+ D(emitcode(";","genFarFarAssign (1 byte case)"););
+ MOVA(aopGet(AOP(right), 0, FALSE, FALSE, TRUE));
+ freeAsmop (right, NULL, ic, FALSE);
+ /* now assign DPTR to result */
+ _G.accInUse++;
+ aopOp(result, ic, FALSE, FALSE);
+ _G.accInUse--;
+ aopPut(AOP(result), "a", 0);
+ freeAsmop(result, NULL, ic, FALSE);
+ return;
+ }
+
+ /* See if we've got an underlying symbol to abuse. */
+ if (IS_SYMOP(result) && OP_SYMBOL(result))
+ {
+ if (IS_TRUE_SYMOP(result))
+ {
+ rSym = OP_SYMBOL(result);
+ }
+ else if (IS_ITEMP(result) && OP_SYMBOL(result)->isspilt && OP_SYMBOL(result)->usl.spillLoc)
+ {
+ rSym = OP_SYMBOL(result)->usl.spillLoc;
+ }
+ }
+
+ if (size > 1 && rSym && rSym->rname && !rSym->onStack)
+ {
+ /* We can use the '390 auto-toggle feature to good effect here. */
+
+ D(emitcode(";","genFarFarAssign ('390 auto-toggle fun)"););
+ emitcode("mov", "dps, #0x21"); /* Select DPTR2 & auto-toggle. */
+ emitcode ("mov", "dptr,#%s", rSym->rname);
+ /* DP2 = result, DP1 = right, DP1 is current. */
+ while (size)
+ {
+ emitcode("movx", "a,@dptr");
+ emitcode("movx", "@dptr,a");
+ if (--size)
+ {
+ emitcode("inc", "dptr");
+ emitcode("inc", "dptr");
+ }
+ }
+ emitcode("mov", "dps, #0");
+ freeAsmop (right, NULL, ic, FALSE);
+ }
+ else
+ {
+ D (emitcode (";", "genFarFarAssign"););
aopOp (result, ic, TRUE, TRUE);
_startLazyDPSEvaluation ();
+
while (size--)
{
aopPut (AOP (result),
_endLazyDPSEvaluation ();
freeAsmop (result, NULL, ic, FALSE);
freeAsmop (right, NULL, ic, FALSE);
- }
- else
- {
- D (emitcode (";", "genFarFarAssign ");
- );
-
- /* first push the right side on to the stack */
- _startLazyDPSEvaluation ();
- while (size--)
- {
- l = aopGet (AOP (right), offset++, FALSE, FALSE, TRUE);
- MOVA (l);
- emitcode ("push", "acc");
- }
-
- freeAsmop (right, NULL, ic, FALSE);
- /* now assign DPTR to result */
- aopOp (result, ic, FALSE, FALSE);
- size = AOP_SIZE (result);
- while (size--)
- {
- emitcode ("pop", "acc");
- aopPut (AOP (result), "a", --offset);
- }
- freeAsmop (result, NULL, ic, FALSE);
- _endLazyDPSEvaluation ();
- }
+ }
}
/*-----------------------------------------------------------------*/
(AOP_TYPE (right) == AOP_LIT) &&
!IS_FLOAT (operandType (right)))
{
- D (emitcode (";", "Kevin's better literal load code");
- );
_startLazyDPSEvaluation ();
while (size && ((unsigned int) (lit >> (offset * 8)) != 0))
{