/* other wise this is true end of the world */
werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
"getFreePtr should never reach here");
- exit(0);
+ exit(1);
}
/*-----------------------------------------------------------------*/
return aop;
}
+/* #define LAZY_DPS_OPT */ /* turn this on after some more testing. */
+
+static int _currentDPS; /* Current processor DPS. */
+static int _desiredDPS; /* DPS value compiler thinks we should be using. */
+static int _lazyDPS = 0; /* if non-zero, we are doing lazy evaluation of DPS changes. */
+
+/*-----------------------------------------------------------------*/
+/* genSetDPTR: generate code to select which DPTR is in use (zero */
+/* selects standard DPTR (DPL/DPH/DPX), non-zero selects DS390 */
+/* alternate DPTR (DPL1/DPH1/DPX1). */
+/*-----------------------------------------------------------------*/
static void genSetDPTR(int n)
{
+
+#ifdef LAZY_DPS_OPT
+ /* If we are doing lazy evaluation, simply note the desired
+ * change, but don't emit any code yet.
+ */
+ if (_lazyDPS)
+ {
+ _desiredDPS = n;
+ return;
+ }
+#endif
+
if (!n)
{
emitcode("mov", "dps, #0x00");
}
}
+/*-----------------------------------------------------------------*/
+/* _startLazyDPSEvaluation: call to start doing lazy DPS evaluation*/
+/* */
+/* Any code that operates on DPTR (NB: not on the individual */
+/* components, like DPH) *must* call _flushLazyDPS() before using */
+/* DPTR within a lazy DPS evaluation block. */
+/* */
+/* Note that aopPut and aopGet already contain the proper calls to */
+/* _flushLazyDPS, so it is safe to use these calls within a lazy */
+/* DPS evaluation block. */
+/* */
+/* Also, _flushLazyDPS must be called before any flow control */
+/* operations that could potentially branch out of the block. */
+/* */
+/* Lazy DPS evaluation is simply an optimization (though an */
+/* important one), so if in doubt, leave it out. */
+/*-----------------------------------------------------------------*/
+static void _startLazyDPSEvaluation(void)
+{
+ _currentDPS = 0;
+ _desiredDPS = 0;
+ _lazyDPS = 1;
+}
+
+/*-----------------------------------------------------------------*/
+/* _flushLazyDPS: emit code to force the actual DPS setting to the */
+/* desired one. Call before using DPTR within a lazy DPS evaluation*/
+/* block. */
+/*-----------------------------------------------------------------*/
+static void _flushLazyDPS(void)
+{
+ if (!_lazyDPS)
+ {
+ /* nothing to do. */
+ return;
+ }
+
+ if (_desiredDPS != _currentDPS)
+ {
+ if (_desiredDPS)
+ {
+ emitcode("inc", "dps");
+ }
+ else
+ {
+ emitcode("dec", "dps");
+ }
+ _currentDPS = _desiredDPS;
+ }
+}
+
+/*-----------------------------------------------------------------*/
+/* _endLazyDPSEvaluation: end lazy DPS evaluation block. */
+/* */
+/* Forces us back to the safe state (standard DPTR selected). */
+/*-----------------------------------------------------------------*/
+static void _endLazyDPSEvaluation(void)
+{
+ if (_currentDPS)
+ {
+ genSetDPTR(0);
+ _flushLazyDPS();
+ }
+ _lazyDPS = 0;
+ _currentDPS = 0;
+ _desiredDPS = 0;
+}
+
+
+
/*-----------------------------------------------------------------*/
/* pointerCode - returns the code for a pointer type */
/*-----------------------------------------------------------------*/
if (useDP2)
{
- genSetDPTR(1);
+ /* genSetDPTR(1); */
emitcode ("mov","dpx1,#0x40");
emitcode ("mov","dph1,#0x00");
emitcode ("mov","dpl1, a");
- genSetDPTR(0);
+ /* genSetDPTR(0); */
}
else
{
if (useDP2)
{
genSetDPTR(1);
- emitcode ("mov","dptr,#%s", sym->rname);
+ _flushLazyDPS();
+ emitcode ("mov","dptr,#%s", sym->rname);
genSetDPTR(0);
}
else
case AOP_DPTR:
case AOP_DPTR2:
- if (aop->type == AOP_DPTR2)
- {
- genSetDPTR(1);
+ if (aop->type == AOP_DPTR2)
+ {
+ genSetDPTR(1);
#ifndef KEVIN_BROKE_IT
- if (!canClobberACC)
+ if (!canClobberACC)
#endif
- {
- emitcode("xch", "a, ap");
- }
- }
+ {
+ emitcode("xch", "a, ap");
+ }
+ }
+
+ _flushLazyDPS();
while (offset > aop->coff) {
emitcode ("inc","dptr");
emitcode("clr","a");
emitcode("movc","a,@a+dptr");
}
- else {
+ else {
emitcode("movx","a,@dptr");
- }
+ }
- if (aop->type == AOP_DPTR2)
- {
- genSetDPTR(0);
+ if (aop->type == AOP_DPTR2)
+ {
+ genSetDPTR(0);
#ifndef KEVIN_BROKE_IT
- if (!canClobberACC)
+ if (!canClobberACC)
#endif
- {
- emitcode("xch", "a, ap");
- return "ap";
- }
- }
+ {
+ emitcode("xch", "a, ap");
+ return "ap";
+ }
+ }
- return (dname ? "acc" : "a");
-
+ return (dname ? "acc" : "a");
case AOP_IMMD:
if (bit16)
werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
"aopget got unsupported aop->type");
- exit(0);
+ exit(1);
}
/*-----------------------------------------------------------------*/
/* aopPut - puts a string for a aop */
if (aop->size && offset > ( aop->size - 1)) {
werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
"aopPut got offset > aop->size");
- exit(0);
+ exit(1);
}
/* will assign value to value */
case AOP_DPTR:
case AOP_DPTR2:
- if (aop->type == AOP_DPTR2)
- {
- genSetDPTR(1);
- }
+ if (aop->type == AOP_DPTR2)
+ {
+ genSetDPTR(1);
+ }
+ _flushLazyDPS();
if (aop->code) {
werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
"aopPut writting to code space");
- exit(0);
+ exit(1);
}
while (offset > aop->coff) {
emitcode ("movx","@dptr,a");
- if (aop->type == AOP_DPTR2)
- {
- genSetDPTR(0);
- }
+ if (aop->type == AOP_DPTR2)
+ {
+ genSetDPTR(0);
+ }
break;
case AOP_R0:
default :
werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
"aopPut got unsupported aop->type");
- exit(0);
+ exit(1);
}
}
if (aop->type == AOP_DPTR2)
{
genSetDPTR(1);
+ _flushLazyDPS();
}
while (size--)
{
size = AOP_SIZE(op) - 1;
offset = 1;
+ _startLazyDPSEvaluation();
l = aopGet(op->aop,offset++,FALSE,FALSE,TRUE);
MOVA(l);
aopGet(op->aop,
offset++,FALSE,FALSE,FALSE));
}
+ _endLazyDPSEvaluation();
tlbl = newiTempLabel(NULL);
tlbl = newiTempLabel(NULL);
int size = AOP_SIZE(oper) - 1;
int offset = 1;
+ /* The generic part of a generic pointer should
+ * not participate in it's truth value.
+ *
+ * i.e. 0x10000000 is zero.
+ */
+ if (opIsGptr(oper))
+ {
+ D(emitcode(";", "toBoolean: generic ptr special case."););
+ size--;
+ }
+
+ _startLazyDPSEvaluation();
if (AOP_NEEDSACC(oper))
{
emitcode("push", "b");
}
else
{
- emitcode("orl","a,%s",aopGet(AOP(oper),offset++,FALSE,FALSE,FALSE));
-}
+ emitcode("orl","a,%s",aopGet(AOP(oper),offset++,FALSE,FALSE,FALSE));
+ }
}
+ _endLazyDPSEvaluation();
if (AOP_NEEDSACC(oper))
{
}
size = AOP_SIZE(IC_RESULT(ic));
+ _startLazyDPSEvaluation();
while (size--) {
char *l = aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("cpl","a");
aopPut(AOP(IC_RESULT(ic)),"a",offset++);
}
+ _endLazyDPSEvaluation();
release:
first it then copy the rest in place */
D(emitcode(";", "genUminusFloat"););
+ _startLazyDPSEvaluation();
size = AOP_SIZE(op) - 1;
l = aopGet(AOP(op),3,FALSE,FALSE,TRUE);
MOVA(l);
aopGet(AOP(op),offset,FALSE,FALSE,FALSE),
offset);
offset++;
- }
+ }
+ _endLazyDPSEvaluation();
}
/*-----------------------------------------------------------------*/
size = AOP_SIZE(IC_LEFT(ic));
offset = 0 ;
//CLRC ;
+ _startLazyDPSEvaluation();
while(size--) {
char *l = aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE,TRUE);
if (!strcmp(l,"a")) {
}
aopPut(AOP(IC_RESULT(ic)),"a",offset++);
}
+ _endLazyDPSEvaluation();
/* if any remaining bytes in the result */
/* we just need to propagate the sign */
static void pushSide(operand * oper, int size)
{
int offset = 0;
+ _startLazyDPSEvaluation();
while (size--) {
char *l = aopGet(AOP(oper),offset++,FALSE,TRUE,FALSE);
if (AOP_TYPE(oper) != AOP_REG &&
} else
emitcode("push","%s",l);
}
+ _endLazyDPSEvaluation();
}
/*-----------------------------------------------------------------*/
{
int offset = 0;
int size = AOP_SIZE(oper);
+
+ _startLazyDPSEvaluation();
while (size--) {
aopPut(AOP(oper),fReturn[offset],offset);
offset++;
}
+ _endLazyDPSEvaluation();
}
emitcode("mov","%s,_spx",r->name);
size = AOP_SIZE(IC_LEFT(ic));
+ _startLazyDPSEvaluation();
while(size--) {
char *l = aopGet(AOP(IC_LEFT(ic)),
emitcode("inc","%s",r->name);
}
+ _endLazyDPSEvaluation();
emitcode("mov","_spx,%s",r->name);
aopOp(IC_LEFT(ic),ic,FALSE, FALSE);
size = AOP_SIZE(IC_LEFT(ic));
/* push it on the stack */
+ _startLazyDPSEvaluation();
while(size--) {
l = aopGet(AOP(IC_LEFT(ic)),offset++,FALSE,TRUE,TRUE);
if (*l == '#') {
}
emitcode("push","%s",l);
}
+ _endLazyDPSEvaluation();
return ;
}
// pushSide(IC_LEFT(ic), AOP_SIZE(IC_LEFT(ic)));
size = AOP_SIZE(IC_LEFT(ic));
+ _startLazyDPSEvaluation();
while (size--) {
l = aopGet(AOP(IC_LEFT(ic)),offset++,FALSE,TRUE,FALSE);
if (AOP_TYPE(IC_LEFT(ic)) != AOP_REG &&
emitcode("push","acc");
} else
emitcode("push","%s",l);
- }
+ }
+ _endLazyDPSEvaluation();
freeAsmop(IC_LEFT(ic),NULL,ic,TRUE);
}
aopOp(IC_LEFT(ic),ic,FALSE, FALSE);
size = AOP_SIZE(IC_LEFT(ic));
offset = (size-1);
- while (size--)
+ _startLazyDPSEvaluation();
+ while (size--)
+ {
emitcode("pop","%s",aopGet(AOP(IC_LEFT(ic)),offset--,
FALSE,TRUE,TRUE));
+ }
+ _endLazyDPSEvaluation();
freeAsmop(IC_LEFT(ic),NULL,ic,TRUE);
}
iCode *sic ;
for (sic = setFirstItem(_G.sendSet) ; sic ;
- sic = setNextItem(_G.sendSet)) {
+ sic = setNextItem(_G.sendSet))
+ {
int size, offset = 0;
- aopOp(IC_LEFT(sic),sic,FALSE, TRUE);
+
+ aopOp(IC_LEFT(sic),sic,FALSE, TRUE);
size = AOP_SIZE(IC_LEFT(sic));
+
+ _startLazyDPSEvaluation();
while (size--) {
char *l = aopGet(AOP(IC_LEFT(sic)),offset,
- FALSE, FALSE, FALSE);
+ FALSE, FALSE, TRUE);
if (strcmp(l,fReturn[offset]))
emitcode("mov","%s,%s",
fReturn[offset],
l);
offset++;
}
+ _endLazyDPSEvaluation();
freeAsmop (IC_LEFT(sic),NULL,sic,TRUE);
}
_G.sendSet = NULL;
OP_SYMBOL(IC_RESULT(ic))->spildir )) ||
IS_TRUE_SYMOP(IC_RESULT(ic)) ) {
+#ifdef LAZY_DPS_OPT
+ /* Not really related to LAZY_DPS_OPT, but don't want
+ * another testing flag right now...
+ */
+ _G.accInUse++;
+ aopOp(IC_RESULT(ic),ic,FALSE, TRUE);
+ _G.accInUse--;
+
+ assignResultValue(IC_RESULT(ic));
+
+ freeAsmop(IC_RESULT(ic),NULL, ic,TRUE);
+
+#else
if (!isOperandInFarSpace(IC_RESULT(ic)))
{
- _G.accInUse++;
+ _G.accInUse++;
aopOp(IC_RESULT(ic),ic,FALSE, FALSE);
- _G.accInUse--;
+ _G.accInUse--;
- assignResultValue(IC_RESULT(ic));
+ assignResultValue(IC_RESULT(ic));
- freeAsmop(IC_RESULT(ic),NULL, ic,TRUE);
- }
+ freeAsmop(IC_RESULT(ic),NULL, ic,TRUE);
+ }
else
{
/* Result is in far space, and requires DPTR to access
aopPut(AOP(IC_RESULT(ic)),"a",++offset);
}
freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
- }
+ }
+#endif
}
/* adjust the stack for parameters if
iCode *sic ;
for (sic = setFirstItem(_G.sendSet) ; sic ;
- sic = setNextItem(_G.sendSet)) {
- int size, offset = 0;
- aopOp(IC_LEFT(sic),sic,FALSE, FALSE);
- size = AOP_SIZE(IC_LEFT(sic));
- while (size--) {
- char *l = aopGet(AOP(IC_LEFT(sic)),offset,
- FALSE,FALSE,FALSE);
- if (strcmp(l,fReturn[offset]))
- emitcode("mov","%s,%s",
- fReturn[offset],
- l);
- offset++;
+ sic = setNextItem(_G.sendSet))
+ {
+ int size, offset = 0;
+
+ aopOp(IC_LEFT(sic),sic,FALSE, FALSE);
+ size = AOP_SIZE(IC_LEFT(sic));
+ _startLazyDPSEvaluation();
+ while (size--)
+ {
+ char *l = aopGet(AOP(IC_LEFT(sic)),offset,
+ FALSE,FALSE,TRUE);
+ if (strcmp(l,fReturn[offset]))
+ {
+ emitcode("mov","%s,%s",
+ fReturn[offset],
+ l);
+ }
+ offset++;
+ }
+ _endLazyDPSEvaluation();
+ freeAsmop (IC_LEFT(sic),NULL,sic,TRUE);
}
- freeAsmop (IC_LEFT(sic),NULL,sic,TRUE);
- }
- _G.sendSet = NULL;
+ _G.sendSet = NULL;
}
emitcode("ret","");
aopOp(IC_LEFT(ic),ic,FALSE, TRUE);
size = AOP_SIZE(IC_LEFT(ic));
+ _startLazyDPSEvaluation();
while (size--) {
char *l ;
if (AOP_TYPE(IC_LEFT(ic)) == AOP_DPTR) {
if (strcmp(fReturn[offset],l))
emitcode("mov","%s,%s",fReturn[offset++],l);
}
- }
+ }
+ _endLazyDPSEvaluation();
if (pushed) {
while(pushed) {
aopPut(AOP(IC_RESULT(ic)),"a",0);
} else {
+ _startLazyDPSEvaluation();
while (icount--)
+ {
emitcode ("inc","%s",aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE,FALSE));
+ }
+ _endLazyDPSEvaluation();
}
return TRUE ;
{
int size, offset = 0;
bool pushResult = FALSE;
+ int rSize;
D(emitcode(";", "genPlus "););
outBitC(IC_RESULT(ic));
} else {
size = getDataSize(IC_RESULT(ic));
+ _startLazyDPSEvaluation();
while (size--) {
MOVA(aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE,TRUE));
emitcode("addc","a,#00");
aopPut(AOP(IC_RESULT(ic)),"a",offset++);
}
+ _endLazyDPSEvaluation();
}
goto release ;
}
}
size = getDataSize(pushResult ? IC_LEFT(ic) : IC_RESULT(ic));
- while(size--){
- if (AOP_TYPE(IC_LEFT(ic)) == AOP_ACC) {
+ _startLazyDPSEvaluation();
+ while(size--)
+ {
+ if (AOP_TYPE(IC_LEFT(ic)) == AOP_ACC)
+ {
MOVA(aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE,TRUE));
if(offset == 0)
emitcode("add","a,%s",
}
offset++;
}
-
+ _endLazyDPSEvaluation();
+
if (pushResult)
{
aopOp (IC_RESULT(ic),ic,TRUE, FALSE);
size = getDataSize(IC_LEFT(ic));
+ rSize = getDataSize(IC_RESULT(ic));
+
+ /* If the pushed data is bigger than the result,
+ * simply discard unused bytes. Icky, but works.
+ *
+ * Should we throw a warning here? We're losing data...
+ */
+ while (size > rSize)
+ {
+ D(emitcode(";", "discarding unused result byte."););
+ emitcode("pop", "acc");
+ size--;
+ offset--;
+ }
+ if (size < rSize)
+ {
+ emitcode("clr", "a");
+ /* Conversly, we haven't pushed enough here.
+ * just zero-pad, and all is well.
+ */
+ while (size < rSize)
+ {
+ emitcode("push", "acc");
+ size++;
+ offset++;
+ }
+ }
while(size--)
{
AOP_TYPE(IC_RESULT(ic)) == AOP_REG &&
sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic)))) {
+ _startLazyDPSEvaluation();
while (icount--)
+ {
emitcode ("dec","%s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE,FALSE));
+ }
+ _endLazyDPSEvaluation();
return TRUE ;
}
static void genMinus (iCode *ic)
{
int size, offset = 0;
+ int rSize;
unsigned long lit = 0L;
bool pushResult = FALSE;
/* if literal, add a,#-lit, else normal subb */
+ _startLazyDPSEvaluation();
while (size--) {
MOVA(aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE,TRUE));
if (AOP_TYPE(IC_RIGHT(ic)) != AOP_LIT)
}
offset++;
}
+ _endLazyDPSEvaluation();
if (pushResult)
{
aopOp (IC_RESULT(ic),ic,TRUE, FALSE);
size = getDataSize(IC_LEFT(ic));
+ rSize = getDataSize(IC_RESULT(ic));
+
+ /* If the pushed data is bigger than the result,
+ * simply discard unused bytes. Icky, but works.
+ *
+ * Should we throw a warning here? We're losing data...
+ */
+ while (size > getDataSize(IC_RESULT(ic)))
+ {
+ emitcode(";", "discarding unused result byte.");
+ emitcode("pop", "acc");
+ size--;
+ offset--;
+ }
+ if (size < rSize)
+ {
+ emitcode("clr", "a");
+ /* Conversly, we haven't pushed enough here.
+ * just zero-pad, and all is well.
+ */
+ while (size < rSize)
+ {
+ emitcode("push", "acc");
+ size++;
+ offset++;
+ }
+ }
while(size--)
{
{
werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
"both CMP operands need ACC!");
- exit(-1);
+ exit(1);
}
else
{
right = left;
left = t;
}
+
if(AOP_TYPE(right) == AOP_LIT)
lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
+
+ if (opIsGptr(left) || opIsGptr(right))
+ {
+ /* We are comparing a generic pointer to something.
+ * Exclude the generic type byte from the comparison.
+ */
+ size--;
+ D(emitcode(";", "cjneshort: generic ptr special case.");)
+ }
+
/* if the right side is a literal then anything goes */
if (AOP_TYPE(right) == AOP_LIT &&
else if (AOP_TYPE(right) == AOP_REG ||
AOP_TYPE(right) == AOP_DIR ||
(AOP_TYPE(left) == AOP_DIR && AOP_TYPE(right) == AOP_LIT) ||
- (IS_AOP_PREG(left) && !IS_AOP_PREG(right))) {
- while (size--) {
+ (IS_AOP_PREG(left) && !IS_AOP_PREG(right)))
+ {
+ while (size--)
+ {
MOVA(aopGet(AOP(left),offset,FALSE,FALSE,TRUE));
if((AOP_TYPE(left) == AOP_DIR && AOP_TYPE(right) == AOP_LIT) &&
((unsigned int)((lit >> (offset*8)) & 0x0FFL) == 0))
size = AOP_SIZE(result);
offset = size - 1 ;
CLRC;
+
+ _startLazyDPSEvaluation();
while (size--) {
l = aopGet(AOP(left),offset,FALSE,FALSE,TRUE);
MOVA(l);
if (AOP_SIZE(result) > 1)
aopPut(AOP(result),"a",offset--);
}
+ _endLazyDPSEvaluation();
+
/* now we need to put the carry into the
highest order byte of the result */
if (AOP_SIZE(result) > 1) {
MOVA(l);
emitcode("add","a,acc");
if (AOP_SIZE(result) > 1)
+ {
aopPut(AOP(result),"a",offset++);
+ }
+
+ _startLazyDPSEvaluation();
while (size--) {
l = aopGet(AOP(left),offset,FALSE,FALSE,TRUE);
MOVA(l);
if (AOP_SIZE(result) > 1)
aopPut(AOP(result),"a",offset++);
}
+ _endLazyDPSEvaluation();
}
/* now we need to put the carry into the
highest order byte of the result */
size = AOP_SIZE(result);
offset=0;
+ _startLazyDPSEvaluation();
while (size--) {
l = aopGet(AOP(left),offset,FALSE,TRUE,FALSE);
if (*l == '@' && (IS_AOP_PREG(result))) {
aopPut(AOP(result),l,offset);
offset++;
}
+ _endLazyDPSEvaluation();
}
tlbl = newiTempLabel(NULL);
MOVA(l);
emitcode("add","a,acc");
aopPut(AOP(result),"a",offset++);
+ _startLazyDPSEvaluation();
while (--size) {
l = aopGet(AOP(result),offset,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("rlc","a");
aopPut(AOP(result),"a",offset++);
}
+ _endLazyDPSEvaluation();
reAdjustPreg(AOP(result));
emitcode("","%05d$:",tlbl1->key+100);
size = AOP_SIZE(result);
offset=0;
+ _startLazyDPSEvaluation();
while (size--) {
l = aopGet(AOP(left),offset,FALSE,TRUE,FALSE);
if (*l == '@' && IS_AOP_PREG(result)) {
aopPut(AOP(result),l,offset);
offset++;
}
+ _endLazyDPSEvaluation();
}
/* mov the highest order bit to OVR */
emitcode("sjmp","%05d$",tlbl1->key+100);
emitcode("","%05d$:",tlbl->key+100);
emitcode("mov","c,ov");
+ _startLazyDPSEvaluation();
while (size--) {
l = aopGet(AOP(result),offset,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("rrc","a");
aopPut(AOP(result),"a",offset--);
}
+ _endLazyDPSEvaluation();
reAdjustPreg(AOP(result));
emitcode("","%05d$:",tlbl1->key+100);
emitcode("djnz","b,%05d$",tlbl->key+100);
size = AOP_SIZE(result);
offset=0;
+ _startLazyDPSEvaluation();
while (size--) {
l = aopGet(AOP(left),offset,FALSE,TRUE,FALSE);
if (*l == '@' && IS_AOP_PREG(result)) {
aopPut(AOP(result),l,offset);
offset++;
}
+ _endLazyDPSEvaluation();
}
tlbl = newiTempLabel(NULL);
emitcode("sjmp","%05d$",tlbl1->key+100);
emitcode("","%05d$:",tlbl->key+100);
CLRC;
+ _startLazyDPSEvaluation();
while (size--) {
l = aopGet(AOP(result),offset,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("rrc","a");
aopPut(AOP(result),"a",offset--);
}
+ _endLazyDPSEvaluation();
reAdjustPreg(AOP(result));
emitcode("","%05d$:",tlbl1->key+100);
/* get the string representation of the name */
l = aopGet(AOP(left),0,FALSE,TRUE,FALSE);
size = AOP_SIZE(result);
+ _startLazyDPSEvaluation();
while (size--) {
if (offset)
sprintf(buffer,"(%s + %d)",l+1,offset);
sprintf(buffer,"%s",l+1);
aopPut(AOP(result),buffer,offset++);
}
+ _endLazyDPSEvaluation();
freeAsmop(left,NULL,ic,TRUE);
freeAsmop(result,NULL,ic,TRUE);
else
{
/* we need to get it byte by byte */
+ _startLazyDPSEvaluation();
if (AOP_TYPE(left) != AOP_DPTR)
{
emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE,TRUE));
emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE,TRUE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE,TRUE));
- }
+ emitcode("mov","dpx,%s",aopGet(AOP(left),2,FALSE,FALSE,TRUE));
}
else
{
emitcode("pop", "dph");
emitcode("pop", "dpl");
}
+ _endLazyDPSEvaluation();
}
}
/* so dptr know contains the address */
if (AOP_TYPE(left) == AOP_IMMD)
emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE,FALSE));
else { /* we need to get it byte by byte */
+ _startLazyDPSEvaluation();
emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE,TRUE));
emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE,TRUE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE,TRUE));
- }
+ emitcode("mov","dpx,%s",aopGet(AOP(left),2,FALSE,FALSE,TRUE));
+ _endLazyDPSEvaluation();
}
}
/* so dptr know contains the address */
emitcode("mov","b,#%d",pointerCode(retype));
}
else { /* we need to get it byte by byte */
+ _startLazyDPSEvaluation();
emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE,TRUE));
emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE,TRUE));
if (options.model == MODEL_FLAT24)
{
emitcode("mov","b,%s",aopGet(AOP(left),2,FALSE,FALSE,TRUE));
}
+ _endLazyDPSEvaluation();
}
}
/* so dptr know contains the address */
else
{
/* we need to get it byte by byte */
+ _startLazyDPSEvaluation();
if (AOP_TYPE(result) != AOP_DPTR)
{
emitcode("mov","dpl,%s",aopGet(AOP(result),0,FALSE,FALSE,TRUE));
emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE,TRUE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE,TRUE));
- }
+ emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE,TRUE));
}
else
{
emitcode("pop", "dph");
emitcode("pop", "dpl");
}
+ _endLazyDPSEvaluation();
}
}
/* so dptr know contains the address */
size = AOP_SIZE(right);
offset = 0 ;
+ _startLazyDPSEvaluation();
while (size--) {
char *l = aopGet(AOP(right),offset++,FALSE,FALSE,TRUE);
MOVA(l);
if (size)
emitcode("inc","dptr");
}
+ _endLazyDPSEvaluation();
}
freeAsmop(right,NULL,ic,TRUE);
/* if the operand is already in dptr
then we do nothing else we move the value to dptr */
if (AOP_TYPE(result) != AOP_STR) {
+ _startLazyDPSEvaluation();
/* if this is remateriazable */
if (AOP_TYPE(result) == AOP_IMMD) {
emitcode("mov","dptr,%s",aopGet(AOP(result),0,TRUE,FALSE,FALSE));
else { /* we need to get it byte by byte */
emitcode("mov","dpl,%s",aopGet(AOP(result),0,FALSE,FALSE,TRUE));
emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE,TRUE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE,TRUE));
- emitcode("mov","b,%s",aopGet(AOP(result),3,FALSE,FALSE,TRUE));
- }
- else
- {
- emitcode("mov","b,%s",aopGet(AOP(result),2,FALSE,FALSE,TRUE));
- }
+ emitcode("mov","dpx,%s",aopGet(AOP(result),2,FALSE,FALSE,TRUE));
+ emitcode("mov","b,%s",aopGet(AOP(result),3,FALSE,FALSE,TRUE));
}
+ _endLazyDPSEvaluation();
}
/* so dptr know contains the address */
freeAsmop(result,NULL,ic,TRUE);
int size = AOP_SIZE(right);
int offset = 0;
char *l ;
+
+ 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");
}
-
- D(emitcode(";", "genFarFarAssign "););
freeAsmop(right,NULL,ic,FALSE);
/* now assign DPTR to result */
aopPut(AOP(result),"a",--offset);
}
freeAsmop(result,NULL,ic,FALSE);
+ _endLazyDPSEvaluation();
}
offset = 0 ;
if(AOP_TYPE(right) == AOP_LIT)
lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
+
if((size > 1) &&
(AOP_TYPE(result) != AOP_REG) &&
(AOP_TYPE(right) == AOP_LIT) &&
- !IS_FLOAT(operandType(right)) &&
- (lit < 256L)){
+ !IS_FLOAT(operandType(right))
+#ifndef LAZY_DPS_OPT
+ && (lit < 256L)
+#endif
+ )
+ {
+#ifdef LAZY_DPS_OPT
+ D(emitcode(";", "Kevin's better literal load code"););
+ _startLazyDPSEvaluation();
+ while (size && ((unsigned int)((lit >> (offset*8)) & 0xff) != 0))
+ {
+ aopPut(AOP(result),
+ aopGet(AOP(right),offset,FALSE,FALSE,TRUE),
+ offset);
+ offset++;
+ size--;
+ }
+ /* And now fill the rest with zeros. */
+ if (size)
+ {
+ emitcode("clr","a");
+ }
+ while (size--)
+ {
+ aopPut(AOP(result), "a", offset++);
+ }
+ _endLazyDPSEvaluation();
+#else
emitcode("clr","a");
- while (size--) {
+
+ _startLazyDPSEvaluation();
+ while (size--)
+ {
if((unsigned int)((lit >> (size*8)) & 0x0FFL)== 0)
aopPut(AOP(result),"a",size);
else
aopGet(AOP(right),size,FALSE,FALSE,FALSE),
size);
}
- } else {
- while (size--) {
+ _endLazyDPSEvaluation();
+#endif
+ }
+ else
+ {
+ _startLazyDPSEvaluation();
+ while (size--)
+ {
aopPut(AOP(result),
aopGet(AOP(right),offset,FALSE,FALSE,FALSE),
offset);
offset++;
}
+ _endLazyDPSEvaluation();
}
release:
}
/*-----------------------------------------------------------------*/
-/* genJumpTab - genrates code for jump table */
+/* genJumpTab - generates code for jump table */
/*-----------------------------------------------------------------*/
static void genJumpTab (iCode *ic)
{
/* if they in different places then copy */
size = AOP_SIZE(result);
offset = 0 ;
+ _startLazyDPSEvaluation();
while (size--) {
aopPut(AOP(result),
aopGet(AOP(right),offset,FALSE,FALSE,FALSE),
offset);
offset++;
}
+ _endLazyDPSEvaluation();
goto release;
}
int p_type;
link *type = operandType(right);
- link *etype = getSpec(type);
/* pointer to generic pointer */
if (IS_GENPTR(ctype)) {
char *l = zero;
if (IS_PTR(type))
+ {
p_type = DCL_TYPE(type);
- else {
+ }
+ else
+ {
+#if OLD_CAST_BEHAVIOR
+ /* KV: we are converting a non-pointer type to
+ * a generic pointer. This (ifdef'd out) code
+ * says that the resulting generic pointer
+ * should have the same class as the storage
+ * location of the non-pointer variable.
+ *
+ * For example, converting an int (which happens
+ * to be stored in DATA space) to a pointer results
+ * in a DATA generic pointer; if the original int
+ * in XDATA space, so will be the resulting pointer.
+ *
+ * I don't like that behavior, and thus this change:
+ * all such conversions will be forced to XDATA and
+ * throw a warning. If you want some non-XDATA
+ * type, or you want to suppress the warning, you
+ * must go through an intermediate cast, like so:
+ *
+ * char _generic *gp = (char _xdata *)(intVar);
+ */
+ link *etype = getSpec(type);
+
/* we have to go by the storage class */
- p_type = PTR_TYPE(SPEC_OCLS(etype));
+ if (SPEC_OCLS(etype) != generic)
+ {
+ p_type = PTR_TYPE(SPEC_OCLS(etype));
+ }
+ else
+#endif
+ {
+ /* Converting unknown class (i.e. register variable)
+ * to generic pointer. This is not good, but
+ * we'll make a guess (and throw a warning).
+ */
+ p_type = FPOINTER;
+ werror(W_INT_TO_GEN_PTR_CAST);
+ }
}
/* the first two bytes are known */
size = GPTRSIZE - 1;
offset = 0 ;
+ _startLazyDPSEvaluation();
while (size--) {
aopPut(AOP(result),
aopGet(AOP(right),offset,FALSE,FALSE,FALSE),
offset);
offset++;
}
+ _endLazyDPSEvaluation();
+
/* the last byte depending on type */
switch (p_type) {
case IPOINTER:
default:
/* this should never happen */
- werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
+ werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
"got unknown pointer type");
exit(1);
}
/* just copy the pointers */
size = AOP_SIZE(result);
offset = 0 ;
+ _startLazyDPSEvaluation();
while (size--) {
aopPut(AOP(result),
aopGet(AOP(right),offset,FALSE,FALSE,FALSE),
offset);
offset++;
}
+ _endLazyDPSEvaluation();
goto release ;
}
/* we move to result for the size of source */
size = AOP_SIZE(right);
offset = 0 ;
+ _startLazyDPSEvaluation();
while (size--) {
aopPut(AOP(result),
aopGet(AOP(right),offset,FALSE,FALSE,FALSE),
offset);
offset++;
}
+ _endLazyDPSEvaluation();
/* now depending on the sign of the source && destination */
size = AOP_SIZE(result) - AOP_SIZE(right);