#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#include "SDCCglobl.h"
+
+#include <common.h>
+#include "ralloc.h"
+#include "gen.h"
#ifdef HAVE_SYS_ISA_DEFS_H
#include <sys/isa_defs.h>
#endif
#endif
-#include "common.h"
-#include "SDCCpeeph.h"
-#include "ralloc.h"
-#include "gen.h"
-
char *aopLiteral (value *val, int offset);
+#if 0
+//REMOVE ME!!!
extern int allocInfo;
+#endif
/* this is the down and dirty file with all kinds of
kludgy & hacky stuff. This is what it is all about
set *sendSet;
} _G;
-extern int ds390_ptrRegReq ;
-extern int ds390_nRegs;
-extern FILE *codeOutFile;
static void saverbank (int, iCode *,bool);
+
#define RESULTONSTACK(x) \
(IC_RESULT(x) && IC_RESULT(x)->aop && \
IC_RESULT(x)->aop->type == AOP_STK )
} \
free(_mova_tmp); \
}
-#define CLRC emitcode("clr","c");
+#define CLRC emitcode("clr","c")
+#define SETC emitcode("setb","c")
static lineNode *lineHead = NULL;
static lineNode *lineCurr = NULL;
/* 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;
}
+/* Turn this off if the world goes to hell. */
+#define LAZY_DPS_OPT
+
+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(";", "Select standard DPTR");
emitcode("mov", "dps, #0x00");
}
else
{
- emitcode(";", "Select alternate DPTR");
emitcode("mov", "dps, #0x01");
}
}
+/*-----------------------------------------------------------------*/
+/* _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
if (sym->ruonly ) {
int i;
+
+ if (useDP2)
+ {
+ /* a AOP_STR uses DPTR, but DPTR is already in use;
+ * we're just hosed.
+ */
+ fprintf(stderr, "*** Internal error: AOP_STR with DPTR in use!\n");
+ }
+
aop = op->aop = sym->aop = newAsmop(AOP_STR);
aop->size = getSize(sym->type);
for ( i = 0 ; i < fReturnSize_390 ; i++ )
}
}
-/*-----------------------------------------------------------------*/
-/* aopGet - for fetching value of the aop */
-/*-----------------------------------------------------------------*/
-static char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
+/*------------------------------------------------------------------*/
+/* aopGet - for fetching value of the aop */
+/* */
+/* Set canClobberACC if you are aure it is OK to clobber the value */
+/* in the accumulator. Set it FALSE otherwise; FALSE is always safe,*/
+/* just less efficient. */
+/*------------------------------------------------------------------*/
+
+static char *aopGet (asmop *aop,
+ int offset,
+ bool bit16,
+ bool dname,
+ bool canClobberACC)
{
char *s = buffer ;
char *rs;
case AOP_DPTR:
case AOP_DPTR2:
- if (aop->type == AOP_DPTR2)
- {
- genSetDPTR(1);
- emitcode("xch", "a, ap");
- }
+ if (aop->type == AOP_DPTR2)
+ {
+ genSetDPTR(1);
+
+#ifndef KEVIN_BROKE_IT
+ if (!canClobberACC)
+#endif
+ {
+ 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)
- {
- emitcode("xch", "a, ap");
- genSetDPTR(0);
- return "ap";
- }
+ if (aop->type == AOP_DPTR2)
+ {
+ genSetDPTR(0);
+
+#ifndef KEVIN_BROKE_IT
+ if (!canClobberACC)
+#endif
+ {
+ 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 0
-/*-----------------------------------------------------------------*/
-/* pointToEnd :- points to the last byte of the operand */
-/*-----------------------------------------------------------------*/
-static void pointToEnd (asmop *aop)
-{
- int count ;
- if (!aop)
- return ;
-
- aop->coff = count = (aop->size - 1);
- switch (aop->type) {
- case AOP_R0 :
- case AOP_R1 :
- while (count--)
- emitcode("inc","%s",aop->aopu.aop_ptr->name);
- break;
- case AOP_DPTR :
- while (count--)
- emitcode("inc","dptr");
- break;
- }
-
-}
-#endif
-
/*-----------------------------------------------------------------*/
/* reAdjustPreg - points a register back to where it should */
/*-----------------------------------------------------------------*/
if (aop->type == AOP_DPTR2)
{
genSetDPTR(1);
+ _flushLazyDPS();
}
while (size--)
{
(x->aopu.aop_reg[0] == ds390_regWithIdx(R0_IDX) || \
x->aopu.aop_reg[0] == ds390_regWithIdx(R1_IDX) )))
+/* Workaround for DS80C390 bug: div ab may return bogus results
+ * if A is accessed in instruction immediately before the div.
+ *
+ * Will be fixed in B4 rev of processor, Dallas claims.
+ */
+
+#define LOAD_AB_FOR_DIV(LEFT, RIGHT, L) \
+ if (!AOP_NEEDSACC(RIGHT)) \
+ { \
+ /* We can load A first, then B, since \
+ * B (the RIGHT operand) won't clobber A, \
+ * thus avoiding touching A right before the div. \
+ */ \
+ D(emitcode(";", "DS80C390 div bug: rearranged ops.");); \
+ L = aopGet(AOP(LEFT),0,FALSE,FALSE,TRUE); \
+ MOVA(L); \
+ emitcode("mov","b,%s",aopGet(AOP(RIGHT),0,FALSE,FALSE,FALSE));\
+ } \
+ else \
+ { \
+ /* Just stuff in a nop after loading A. */ \
+ emitcode("mov","b,%s",aopGet(AOP(RIGHT),0,FALSE,FALSE,FALSE));\
+ L = aopGet(AOP(LEFT),0,FALSE,FALSE,TRUE); \
+ MOVA(L); \
+ emitcode("nop", "; workaround for DS80C390 div bug."); \
+ }
+
/*-----------------------------------------------------------------*/
/* genNotFloat - generates not for float operations */
/*-----------------------------------------------------------------*/
size = AOP_SIZE(op) - 1;
offset = 1;
- l = aopGet(op->aop,offset++,FALSE,FALSE);
+ _startLazyDPSEvaluation();
+ l = aopGet(op->aop,offset++,FALSE,FALSE,TRUE);
MOVA(l);
while(size--) {
emitcode("orl","a,%s",
aopGet(op->aop,
- offset++,FALSE,FALSE));
+ 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");
- emitcode("mov", "b, %s", aopGet(AOP(oper),0,FALSE,FALSE));
+ emitcode("mov", "b, %s", aopGet(AOP(oper),0,FALSE,FALSE,FALSE));
}
else
{
- MOVA(aopGet(AOP(oper),0,FALSE,FALSE));
+ MOVA(aopGet(AOP(oper),0,FALSE,FALSE,TRUE));
}
while (size--)
{
if (AOP_NEEDSACC(oper))
{
- emitcode("orl","b,%s",aopGet(AOP(oper),offset++,FALSE,FALSE));
+ emitcode("orl","b,%s",aopGet(AOP(oper),offset++,FALSE,FALSE,FALSE));
}
else
{
- emitcode("orl","a,%s",aopGet(AOP(oper),offset++,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);
+ 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:
char *l;
/* for this we just need to flip the
first it then copy the rest in place */
- size = AOP_SIZE(op) - 1;
- l = aopGet(AOP(op),3,FALSE,FALSE);
-
D(emitcode(";", "genUminusFloat"););
-
+
+ _startLazyDPSEvaluation();
+ size = AOP_SIZE(op) - 1;
+ l = aopGet(AOP(op),3,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("cpl","acc.7");
while(size--) {
aopPut(AOP(result),
- aopGet(AOP(op),offset,FALSE,FALSE),
+ aopGet(AOP(op),offset,FALSE,FALSE,FALSE),
offset);
offset++;
- }
+ }
+ _endLazyDPSEvaluation();
}
/*-----------------------------------------------------------------*/
/* otherwise subtract from zero */
size = AOP_SIZE(IC_LEFT(ic));
offset = 0 ;
- CLRC ;
+ _startLazyDPSEvaluation();
while(size--) {
- char *l = aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE);
+ char *l = aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE,TRUE);
if (!strcmp(l,"a")) {
- emitcode("cpl","a");
- emitcode("inc","a");
+ if (offset==0)
+ SETC;
+ emitcode("cpl","a");
+ emitcode("addc", "a,#0");
} else {
- emitcode("clr","a");
- emitcode("subb","a,%s",l);
+ if (offset==0)
+ CLRC;
+ emitcode("clr","a");
+ emitcode("subb","a,%s",l);
}
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);
+ char *l = aopGet(AOP(oper),offset++,FALSE,TRUE,FALSE);
if (AOP_TYPE(oper) != AOP_REG &&
AOP_TYPE(oper) != AOP_DIR &&
strcmp(l,"a") ) {
} 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)),
- offset++,FALSE,FALSE);
+ offset++,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("movx","@%s,a",r->name);
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);
+ l = aopGet(AOP(IC_LEFT(ic)),offset++,FALSE,TRUE,TRUE);
if (*l == '#') {
MOVA(l);
l = "acc";
}
emitcode("push","%s",l);
}
+ _endLazyDPSEvaluation();
return ;
}
/* then do the push */
aopOp(IC_LEFT(ic),ic,FALSE, FALSE);
-
- // pushSide(IC_LEFT(ic), AOP_SIZE(IC_LEFT(ic)));
+ // 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);
+ l = aopGet(AOP(IC_LEFT(ic)),offset++,FALSE,TRUE,FALSE);
if (AOP_TYPE(IC_LEFT(ic)) != AOP_REG &&
AOP_TYPE(IC_LEFT(ic)) != AOP_DIR &&
strcmp(l,"a") ) {
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));
+ 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, 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...
+ */
+#define FAR_RETURN_OPT
+#ifdef FAR_RETURN_OPT
+ if (isOperandInFarSpace(IC_RESULT(ic))
+ && getSize(operandType(IC_RESULT(ic))) <= 2)
+ {
+ 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)
+ {
+ emitcode("mov", "b,%s", fReturn[1]);
+ }
+
+ aopOp(IC_RESULT(ic),ic,FALSE, FALSE);
+ aopPut(AOP(IC_RESULT(ic)),"a",0);
+
+ if (size > 1)
+ {
+ aopPut(AOP(IC_RESULT(ic)),"b",1);
+ }
+ freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
+ }
+ else
+#endif
+ {
+ _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);
- 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) {
- /* #NOCHANGE */
l = aopGet(AOP(IC_LEFT(ic)),offset++,
- FALSE,TRUE);
+ FALSE,TRUE,FALSE);
emitcode("push","%s",l);
pushed++;
} else {
l = aopGet(AOP(IC_LEFT(ic)),offset,
- FALSE,FALSE);
+ FALSE,FALSE,FALSE);
if (strcmp(fReturn[offset],l))
emitcode("mov","%s,%s",fReturn[offset++],l);
}
- }
+ }
+ _endLazyDPSEvaluation();
if (pushed) {
while(pushed) {
int labelRange;
/* If the next instruction is a goto and the goto target
- * is < 10 instructions previous to this, we can generate
+ * is <= 5 instructions previous to this, we can generate
* jumps straight to that target.
*/
if (ic->next && ic->next->op == GOTO
&& (labelRange = findLabelBackwards(ic, IC_LABEL(ic->next)->key)) != 0
- && labelRange <= 10 )
+ && labelRange <= 5 )
{
- emitcode(";", "tail increment optimized");
+ emitcode(";", "tail increment optimized (range %d)", labelRange);
tlbl = IC_LABEL(ic->next);
emitTlbl = 0;
}
tlbl = newiTempLabel(NULL);
emitTlbl = 1;
}
- emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
+ emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE,FALSE));
if(AOP_TYPE(IC_RESULT(ic)) == AOP_REG ||
IS_AOP_PREG(IC_RESULT(ic)))
emitcode("cjne","%s,#0x00,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE,FALSE)
,tlbl->key+100);
else {
emitcode("clr","a");
emitcode("cjne","a,%s,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE,FALSE)
,tlbl->key+100);
}
- emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE));
+ emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE,FALSE));
if (size > 2)
{
if(AOP_TYPE(IC_RESULT(ic)) == AOP_REG ||
IS_AOP_PREG(IC_RESULT(ic)))
emitcode("cjne","%s,#0x00,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE,FALSE)
,tlbl->key+100);
else
emitcode("cjne","a,%s,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE,FALSE)
,tlbl->key+100);
- emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE));
+ emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE,FALSE));
}
if (size > 3)
{
if(AOP_TYPE(IC_RESULT(ic)) == AOP_REG ||
IS_AOP_PREG(IC_RESULT(ic)))
emitcode("cjne","%s,#0x00,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE,FALSE)
,tlbl->key+100);
else{
emitcode("cjne","a,%s,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE,FALSE)
,tlbl->key+100);
}
- emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),MSB32,FALSE,FALSE));
+ emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),MSB32,FALSE,FALSE,FALSE));
}
if (emitTlbl)
sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
if (icount > 3) {
- MOVA(aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
+ MOVA(aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE,TRUE));
emitcode("add","a,#0x%02x",((char) icount) & 0xff);
aopPut(AOP(IC_RESULT(ic)),"a",0);
} else {
+ _startLazyDPSEvaluation();
while (icount--)
- emitcode ("inc","%s",aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE));
+ {
+ emitcode ("inc","%s",aopGet(AOP(IC_LEFT(ic)),0,FALSE,FALSE,FALSE));
+ }
+ _endLazyDPSEvaluation();
}
return TRUE ;
}
}
-
-
-#if 0
-/* This is the original version of this code.
- *
- * This is being kept around for reference,
- * because I am not entirely sure I got it right...
- */
-static void adjustArithmeticResult(iCode *ic)
-{
- if (AOP_SIZE(IC_RESULT(ic)) == 3 &&
- AOP_SIZE(IC_LEFT(ic)) == 3 &&
- !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))))
- aopPut(AOP(IC_RESULT(ic)),
- aopGet(AOP(IC_LEFT(ic)),2,FALSE,FALSE),
- 2);
-
- if (AOP_SIZE(IC_RESULT(ic)) == 3 &&
- AOP_SIZE(IC_RIGHT(ic)) == 3 &&
- !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic))))
- aopPut(AOP(IC_RESULT(ic)),
- aopGet(AOP(IC_RIGHT(ic)),2,FALSE,FALSE),
- 2);
-
- if (AOP_SIZE(IC_RESULT(ic)) == 3 &&
- AOP_SIZE(IC_LEFT(ic)) < 3 &&
- AOP_SIZE(IC_RIGHT(ic)) < 3 &&
- !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))) &&
- !sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic)))) {
- char buffer[5];
- sprintf(buffer,"#%d",pointerCode(getSpec(operandType(IC_LEFT(ic)))));
- aopPut(AOP(IC_RESULT(ic)),buffer,2);
- }
-}
-#else
-/* This is the pure and virtuous version of this code.
- * I'm pretty certain it's right, but not enough to toss the old
- * code just yet...
- */
static void adjustArithmeticResult(iCode *ic)
{
if (opIsGptr(IC_RESULT(ic)) &&
!sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))))
{
aopPut(AOP(IC_RESULT(ic)),
- aopGet(AOP(IC_LEFT(ic)), GPTRSIZE - 1,FALSE,FALSE),
+ aopGet(AOP(IC_LEFT(ic)), GPTRSIZE - 1,FALSE,FALSE,FALSE),
GPTRSIZE - 1);
}
!sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic))))
{
aopPut(AOP(IC_RESULT(ic)),
- aopGet(AOP(IC_RIGHT(ic)),GPTRSIZE - 1,FALSE,FALSE),
+ aopGet(AOP(IC_RIGHT(ic)),GPTRSIZE - 1,FALSE,FALSE,FALSE),
GPTRSIZE - 1);
}
aopPut(AOP(IC_RESULT(ic)),buffer,GPTRSIZE - 1);
}
}
-#endif
#define AOP_OP_3(ic) \
aopOp (IC_LEFT(ic),ic,FALSE, FALSE); \
{
int size, offset = 0;
bool pushResult = FALSE;
+ int rSize;
D(emitcode(";", "genPlus "););
/* special cases :- */
+#ifdef LAZY_DPS_OPT
+ aopOp (IC_RIGHT(ic),ic,FALSE, FALSE);
+ aopOp (IC_LEFT(ic),ic,FALSE,
+ (AOP_TYPE(IC_RIGHT(ic)) == AOP_DPTR));
+#else
aopOp (IC_LEFT(ic),ic,FALSE, TRUE);
aopOp (IC_RIGHT(ic),ic,FALSE, FALSE);
+#endif
if ((AOP_TYPE(IC_LEFT(ic)) == AOP_DPTR2) &&
(AOP_TYPE(IC_RIGHT(ic)) == AOP_DPTR))
{
}
else
{
- aopOp (IC_RESULT(ic),ic,TRUE, AOP_TYPE(IC_RIGHT(ic)) == AOP_DPTR);
+ aopOp (IC_RESULT(ic),ic,TRUE,
+ ((AOP_TYPE(IC_RIGHT(ic)) == AOP_DPTR)
+ || (AOP_TYPE(IC_LEFT(ic)) == AOP_DPTR)));
/* if literal, literal on the right or
if left requires ACC or right is already
outBitC(IC_RESULT(ic));
} else {
size = getDataSize(IC_RESULT(ic));
+ _startLazyDPSEvaluation();
while (size--) {
- MOVA(aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
+ 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) {
- MOVA(aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
+ _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",
- aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
+ aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE,FALSE));
else
emitcode("addc","a,%s",
- aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
+ aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE,FALSE));
} else {
- MOVA(aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE,TRUE));
if(offset == 0)
emitcode("add","a,%s",
- aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
+ aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE,FALSE));
else
emitcode("addc","a,%s",
- aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE));
+ aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE,FALSE));
}
if (!pushResult)
{
}
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++;
+ }
+ }
+ _startLazyDPSEvaluation();
while(size--)
{
emitcode("pop", "acc");
aopPut(AOP(IC_RESULT(ic)), "a", --offset);
}
+ _endLazyDPSEvaluation();
}
adjustArithmeticResult(ic);
int labelRange;
/* If the next instruction is a goto and the goto target
- * is <= 10 instructions previous to this, we can generate
+ * is <= 5 instructions previous to this, we can generate
* jumps straight to that target.
*/
if (ic->next && ic->next->op == GOTO
&& (labelRange = findLabelBackwards(ic, IC_LABEL(ic->next)->key)) != 0
- && labelRange <= 10 )
+ && labelRange <= 5 )
{
- emitcode(";", "tail decrement optimized");
+ emitcode(";", "tail decrement optimized (range %d)", labelRange);
tlbl = IC_LABEL(ic->next);
emitTlbl = 0;
}
emitTlbl = 1;
}
- emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE));
+ emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE,FALSE));
if(AOP_TYPE(IC_RESULT(ic)) == AOP_REG ||
AOP_TYPE(IC_RESULT(ic)) == AOP_DPTR ||
IS_AOP_PREG(IC_RESULT(ic)))
emitcode("cjne","%s,#0xff,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE,FALSE)
,tlbl->key+100);
else{
emitcode("mov","a,#0xff");
emitcode("cjne","a,%s,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),LSB,FALSE,FALSE,FALSE)
,tlbl->key+100);
}
- emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE));
+ emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE,FALSE));
if (size > 2)
{
if(AOP_TYPE(IC_RESULT(ic)) == AOP_REG ||
AOP_TYPE(IC_RESULT(ic)) == AOP_DPTR ||
IS_AOP_PREG(IC_RESULT(ic)))
emitcode("cjne","%s,#0xff,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE,FALSE)
,tlbl->key+100);
else{
emitcode("cjne","a,%s,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE,FALSE,FALSE)
,tlbl->key+100);
}
- emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE));
+ emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE,FALSE));
}
if (size > 3)
{
AOP_TYPE(IC_RESULT(ic)) == AOP_DPTR ||
IS_AOP_PREG(IC_RESULT(ic)))
emitcode("cjne","%s,#0xff,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE,FALSE)
,tlbl->key+100);
else{
emitcode("cjne","a,%s,%05d$"
- ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE)
+ ,aopGet(AOP(IC_RESULT(ic)),MSB24,FALSE,FALSE,FALSE)
,tlbl->key+100);
}
- emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),MSB32,FALSE,FALSE));
+ emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),MSB32,FALSE,FALSE,FALSE));
}
if (emitTlbl)
{
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));
+ {
+ 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));
+ MOVA(aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE,TRUE));
if (AOP_TYPE(IC_RIGHT(ic)) != AOP_LIT)
emitcode("subb","a,%s",
- aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE));
+ aopGet(AOP(IC_RIGHT(ic)),offset,FALSE,FALSE,FALSE));
else{
/* first add without previous c */
if(!offset)
}
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--)
{
size = AOP_SIZE(result);
/* signed or unsigned */
- emitcode("mov","b,%s", aopGet(AOP(right),0,FALSE,FALSE));
- l = aopGet(AOP(left),0,FALSE,FALSE);
+ emitcode("mov","b,%s", aopGet(AOP(right),0,FALSE,FALSE,FALSE));
+ l = aopGet(AOP(left),0,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("mul","ab");
/* if result size = 1, mul signed = mul unsigned */
/* AND literal negative */
if((int) floatFromVal (AOP(right)->aopu.aop_lit) < 0){
/* adjust MSB (c==0 after mul) */
- emitcode("subb","a,%s", aopGet(AOP(left),0,FALSE,FALSE));
+ emitcode("subb","a,%s", aopGet(AOP(left),0,FALSE,FALSE,FALSE));
}
}
else{
lbl = newiTempLabel(NULL);
- emitcode("xch","a,%s",aopGet(AOP(right),0,FALSE,FALSE));
+ emitcode("xch","a,%s",aopGet(AOP(right),0,FALSE,FALSE,FALSE));
emitcode("cjne","a,#0x80,%05d$", (lbl->key+100));
emitcode("","%05d$:",(lbl->key+100));
- emitcode("xch","a,%s",aopGet(AOP(right),0,FALSE,FALSE));
+ emitcode("xch","a,%s",aopGet(AOP(right),0,FALSE,FALSE,FALSE));
lbl = newiTempLabel(NULL);
emitcode("jc","%05d$",(lbl->key+100));
- emitcode("subb","a,%s", aopGet(AOP(left),0,FALSE,FALSE));
+ emitcode("subb","a,%s", aopGet(AOP(left),0,FALSE,FALSE,FALSE));
emitcode("","%05d$:",(lbl->key+100));
}
lbl = newiTempLabel(NULL);
- emitcode("xch","a,%s",aopGet(AOP(left),0,FALSE,FALSE));
+ emitcode("xch","a,%s",aopGet(AOP(left),0,FALSE,FALSE,FALSE));
emitcode("cjne","a,#0x80,%05d$", (lbl->key+100));
emitcode("","%05d$:",(lbl->key+100));
- emitcode("xch","a,%s",aopGet(AOP(left),0,FALSE,FALSE));
+ emitcode("xch","a,%s",aopGet(AOP(left),0,FALSE,FALSE,FALSE));
lbl = newiTempLabel(NULL);
emitcode("jc","%05d$",(lbl->key+100));
- emitcode("subb","a,%s", aopGet(AOP(right),0,FALSE,FALSE));
+ emitcode("subb","a,%s", aopGet(AOP(right),0,FALSE,FALSE,FALSE));
emitcode("","%05d$:",(lbl->key+100));
aopPut(AOP(result),"a",1);
char *l;
- /* the result must be bit */
- emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE));
- l = aopGet(AOP(left),0,FALSE,FALSE);
-
- MOVA(l);
-
+ /* the result must be bit */
+ LOAD_AB_FOR_DIV(left, right, l);
emitcode("div","ab");
emitcode("rrc","a");
aopPut(AOP(result),"c",0);
/* signed or unsigned */
if (SPEC_USIGN(opetype)) {
/* unsigned is easy */
- emitcode("mov","b,%s", aopGet(AOP(right),0,FALSE,FALSE));
- l = aopGet(AOP(left),0,FALSE,FALSE);
- MOVA(l);
+ LOAD_AB_FOR_DIV(left, right, l);
emitcode("div","ab");
aopPut(AOP(result),"a",0);
while (size--)
/* signed is a little bit more difficult */
/* save the signs of the operands */
- l = aopGet(AOP(left),0,FALSE,FALSE);
+ l = aopGet(AOP(left),0,FALSE,FALSE,TRUE);
MOVA(l);
- emitcode("xrl","a,%s",aopGet(AOP(right),0,FALSE,TRUE));
+ emitcode("xrl","a,%s",aopGet(AOP(right),0,FALSE,TRUE,FALSE));
emitcode("push","acc"); /* save it on the stack */
/* now sign adjust for both left & right */
- l = aopGet(AOP(right),0,FALSE,FALSE);
+ l = aopGet(AOP(right),0,FALSE,FALSE,TRUE);
MOVA(l);
lbl = newiTempLabel(NULL);
emitcode("jnb","acc.7,%05d$",(lbl->key+100));
emitcode("mov","b,a");
/* sign adjust left side */
- l = aopGet(AOP(left),0,FALSE,FALSE);
+ l = aopGet(AOP(left),0,FALSE,FALSE,TRUE);
MOVA(l);
lbl = newiTempLabel(NULL);
emitcode("","%05d$:",(lbl->key+100));
/* now the division */
+ emitcode("nop", "; workaround for DS80C390 div bug.");
emitcode("div","ab");
/* we are interested in the lower order
only */
char *l;
/* the result must be bit */
- emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE));
- l = aopGet(AOP(left),0,FALSE,FALSE);
-
- MOVA(l);
-
+ LOAD_AB_FOR_DIV(left, right, l);
emitcode("div","ab");
emitcode("mov","a,b");
emitcode("rrc","a");
/* signed or unsigned */
if (SPEC_USIGN(opetype)) {
/* unsigned is easy */
- emitcode("mov","b,%s", aopGet(AOP(right),0,FALSE,FALSE));
- l = aopGet(AOP(left),0,FALSE,FALSE);
- MOVA(l);
+ LOAD_AB_FOR_DIV(left, right, l);
emitcode("div","ab");
aopPut(AOP(result),"b",0);
return ;
/* signed is a little bit more difficult */
/* save the signs of the operands */
- l = aopGet(AOP(left),0,FALSE,FALSE);
+ l = aopGet(AOP(left),0,FALSE,FALSE,TRUE);
MOVA(l);
- emitcode("xrl","a,%s",aopGet(AOP(right),0,FALSE,FALSE));
+ emitcode("xrl","a,%s",aopGet(AOP(right),0,FALSE,FALSE,FALSE));
emitcode("push","acc"); /* save it on the stack */
/* now sign adjust for both left & right */
- l = aopGet(AOP(right),0,FALSE,FALSE);
+ l = aopGet(AOP(right),0,FALSE,FALSE,TRUE);
MOVA(l);
lbl = newiTempLabel(NULL);
emitcode("mov","b,a");
/* sign adjust left side */
- l = aopGet(AOP(left),0,FALSE,FALSE);
+ l = aopGet(AOP(left),0,FALSE,FALSE,TRUE);
MOVA(l);
lbl = newiTempLabel(NULL);
emitcode("","%05d$:",(lbl->key+100));
/* now the multiplication */
+ emitcode("nop", "; workaround for DS80C390 div bug.");
emitcode("div","ab");
/* we are interested in the lower order
only */
{
werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
"both CMP operands need ACC!");
- exit(-1);
+ exit(1);
}
else
{
(AOP_TYPE(right) == AOP_LIT && AOP_TYPE(left) != AOP_DIR )){
symbol *lbl = newiTempLabel(NULL);
emitcode("cjne","%s,%s,%05d$",
- aopGet(AOP(left),offset,FALSE,FALSE),
- aopGet(AOP(right),offset,FALSE,FALSE),
+ aopGet(AOP(left),offset,FALSE,FALSE,FALSE),
+ aopGet(AOP(right),offset,FALSE,FALSE,FALSE),
lbl->key+100);
emitcode("","%05d$:",lbl->key+100);
} else {
CLRC;
}
else{
- MOVA(aopGet(AOP(left),AOP_SIZE(left)-1,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),AOP_SIZE(left)-1,FALSE,FALSE,TRUE));
if(!(AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)) && ifx){
genIfxJump (ifx,"acc.7");
return;
while (size--)
{
emitcode(";", "genCmp #1: %d/%d/%d", size, sign, offset);
- MOVA(aopGet(AOP(left),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),offset,FALSE,FALSE,TRUE));
emitcode(";", "genCmp #2");
if (sign && (size == 0))
{
emitcode("push", "acc");
}
emitcode("mov","b,%s",aopGet(AOP(right),offset++,
- FALSE,FALSE));
+ FALSE,FALSE,FALSE));
emitcode("xrl","b,#0x80");
if (AOP_NEEDSACC(right))
{
/* Yuck!! */
emitcode(";", "genCmp #4.1");
emitcode("xch", "a, b");
- MOVA(aopGet(AOP(right),offset++,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),offset++,FALSE,FALSE,TRUE));
emitcode("xch", "a, b");
s = "b";
}
else
{
emitcode(";", "genCmp #4.2");
- s = aopGet(AOP(right),offset++,FALSE,FALSE);
+ s = aopGet(AOP(right),offset++,FALSE,FALSE,FALSE);
}
emitcode("subb","a,%s",s);
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 &&
AOP_TYPE(left) != AOP_DIR ) {
while (size--) {
- char *l = aopGet(AOP(left), offset, FALSE, FALSE);
+ char *l = aopGet(AOP(left), offset, FALSE, FALSE,TRUE);
MOVA(l);
emitcode("cjne","a,%s,%05d$",
- aopGet(AOP(right),offset,FALSE,FALSE),
+ aopGet(AOP(right),offset,FALSE,FALSE,FALSE),
lbl->key+100);
offset++;
}
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--) {
- MOVA(aopGet(AOP(left),offset,FALSE,FALSE));
+ (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))
emitcode("jnz","%05d$",lbl->key+100);
else
emitcode("cjne","a,%s,%05d$",
- aopGet(AOP(right),offset,FALSE,TRUE),
+ aopGet(AOP(right),offset,FALSE,TRUE,FALSE),
lbl->key+100);
offset++;
}
} else {
/* right is a pointer reg need both a & b */
while(size--) {
- char *l = aopGet(AOP(left),offset,FALSE,FALSE);
+ char *l = aopGet(AOP(left),offset,FALSE,FALSE,TRUE);
if(strcmp(l,"b"))
emitcode("mov","b,%s",l);
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
emitcode("cjne","a,b,%05d$",lbl->key+100);
offset++;
}
emitcode("anl","c,%s",AOP(left)->aopu.aop_dir);
} else {
// c = bit & val;
- MOVA(aopGet(AOP(right),0,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),0,FALSE,FALSE,TRUE));
// c = lsb
emitcode("rrc","a");
emitcode("anl","c,%s",AOP(left)->aopu.aop_dir);
/* left & 2^n */
if(posbit){
posbit--;
- MOVA(aopGet(AOP(left),posbit>>3,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),posbit>>3,FALSE,FALSE,TRUE));
// bit = left & 2^n
if(size)
emitcode("mov","c,acc.%d",posbit&0x07);
emitcode("setb","c");
while(sizel--){
if((bytelit = ((lit >> (offset*8)) & 0x0FFL)) != 0x0L){
- MOVA( aopGet(AOP(left),offset,FALSE,FALSE));
+ MOVA( aopGet(AOP(left),offset,FALSE,FALSE,TRUE));
// byte == 2^n ?
if((posbit = isLiteralBit(bytelit)) != 0)
emitcode("jb","acc.%d,%05d$",(posbit-1)&0x07,tlbl->key+100);
else{
if(bytelit != 0x0FFL)
emitcode("anl","a,%s",
- aopGet(AOP(right),offset,FALSE,TRUE));
+ aopGet(AOP(right),offset,FALSE,TRUE,FALSE));
emitcode("jnz","%05d$",tlbl->key+100);
}
}
aopPut(AOP(result),zero,offset);
else
if (IS_AOP_PREG(result)) {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("anl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
+ emitcode("anl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE,FALSE));
aopPut(AOP(result),"a",offset);
} else
emitcode("anl","%s,%s",
- aopGet(AOP(left),offset,FALSE,TRUE),
- aopGet(AOP(right),offset,FALSE,FALSE));
+ aopGet(AOP(left),offset,FALSE,TRUE,FALSE),
+ aopGet(AOP(right),offset,FALSE,FALSE,FALSE));
} else {
if (AOP_TYPE(left) == AOP_ACC)
- emitcode("anl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
+ emitcode("anl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE,FALSE));
else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
if (IS_AOP_PREG(result)) {
- emitcode("anl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
+ emitcode("anl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE,FALSE));
aopPut(AOP(result),"a",offset);
} else
emitcode("anl","%s,a",
- aopGet(AOP(left),offset,FALSE,TRUE));
+ aopGet(AOP(left),offset,FALSE,TRUE,FALSE));
}
}
}
if(size)
emitcode("setb","c");
while(sizer--){
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
emitcode("anl","a,%s",
- aopGet(AOP(left),offset,FALSE,FALSE));
+ aopGet(AOP(left),offset,FALSE,FALSE,FALSE));
emitcode("jnz","%05d$",tlbl->key+100);
offset++;
}
if(AOP_TYPE(right) == AOP_LIT){
if((bytelit = (int)((lit >> (offset*8)) & 0x0FFL)) == 0x0FF){
aopPut(AOP(result),
- aopGet(AOP(left),offset,FALSE,FALSE),
+ aopGet(AOP(left),offset,FALSE,FALSE,FALSE),
offset);
continue;
} else if(bytelit == 0){
// faster than result <- left, anl result,right
// and better if result is SFR
if (AOP_TYPE(left) == AOP_ACC)
- emitcode("anl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
+ emitcode("anl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE,FALSE));
else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
emitcode("anl","a,%s",
- aopGet(AOP(left),offset,FALSE,FALSE));
+ aopGet(AOP(left),offset,FALSE,FALSE,FALSE));
}
aopPut(AOP(result),"a",offset);
}
AOP_OP_3(ic);
AOP_SET_LOCALS(ic);
- #if 0
+#if 0
aopOp((left = IC_LEFT(ic)),ic,FALSE, FALSE);
aopOp((right= IC_RIGHT(ic)),ic,FALSE, TRUE);
aopOp((result=IC_RESULT(ic)),ic,TRUE, FALSE);
- #endif
+#endif
#ifdef DEBUG_TYPE
emitcode("","; Type res[%d] = l[%d]&r[%d]",
continue;
else
if (IS_AOP_PREG(left)) {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("orl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
+ emitcode("orl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE,FALSE));
aopPut(AOP(result),"a",offset);
} else
emitcode("orl","%s,%s",
- aopGet(AOP(left),offset,FALSE,TRUE),
- aopGet(AOP(right),offset,FALSE,FALSE));
+ aopGet(AOP(left),offset,FALSE,TRUE,FALSE),
+ aopGet(AOP(right),offset,FALSE,FALSE,FALSE));
} else {
if (AOP_TYPE(left) == AOP_ACC)
- emitcode("orl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
+ emitcode("orl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE,FALSE));
else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
if (IS_AOP_PREG(left)) {
- emitcode("orl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
+ emitcode("orl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE,FALSE));
aopPut(AOP(result),"a",offset);
} else
emitcode("orl","%s,a",
- aopGet(AOP(left),offset,FALSE,TRUE));
+ aopGet(AOP(left),offset,FALSE,TRUE,FALSE));
}
}
}
if(size)
emitcode("setb","c");
while(sizer--){
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
emitcode("orl","a,%s",
- aopGet(AOP(left),offset,FALSE,FALSE));
+ aopGet(AOP(left),offset,FALSE,FALSE,FALSE));
emitcode("jnz","%05d$",tlbl->key+100);
offset++;
}
if(AOP_TYPE(right) == AOP_LIT){
if(((lit >> (offset*8)) & 0x0FFL) == 0x00L){
aopPut(AOP(result),
- aopGet(AOP(left),offset,FALSE,FALSE),
+ aopGet(AOP(left),offset,FALSE,FALSE,FALSE),
offset);
continue;
}
// faster than result <- left, anl result,right
// and better if result is SFR
if (AOP_TYPE(left) == AOP_ACC)
- emitcode("orl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
+ emitcode("orl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE,FALSE));
else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
emitcode("orl","a,%s",
- aopGet(AOP(left),offset,FALSE,FALSE));
+ aopGet(AOP(left),offset,FALSE,FALSE,FALSE));
}
aopPut(AOP(result),"a",offset);
}
// if val>>1 != 0, result = 1
emitcode("setb","c");
while(sizer){
- MOVA(aopGet(AOP(right),sizer-1,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),sizer-1,FALSE,FALSE,TRUE));
if(sizer == 1)
// test the msb of the lsb
emitcode("anl","a,#0xfe");
continue;
else
if (IS_AOP_PREG(left)) {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("xrl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
+ emitcode("xrl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE,FALSE));
aopPut(AOP(result),"a",offset);
} else
emitcode("xrl","%s,%s",
- aopGet(AOP(left),offset,FALSE,TRUE),
- aopGet(AOP(right),offset,FALSE,FALSE));
+ aopGet(AOP(left),offset,FALSE,TRUE,FALSE),
+ aopGet(AOP(right),offset,FALSE,FALSE,FALSE));
} else {
if (AOP_TYPE(left) == AOP_ACC)
- emitcode("xrl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
+ emitcode("xrl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE,FALSE));
else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
if (IS_AOP_PREG(left)) {
- emitcode("xrl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
+ emitcode("xrl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE,FALSE));
aopPut(AOP(result),"a",offset);
} else
emitcode("xrl","%s,a",
- aopGet(AOP(left),offset,FALSE,TRUE));
+ aopGet(AOP(left),offset,FALSE,TRUE,FALSE));
}
}
}
while(sizer--){
if((AOP_TYPE(right) == AOP_LIT) &&
(((lit >> (offset*8)) & 0x0FFL) == 0x00L)){
- MOVA(aopGet(AOP(left),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),offset,FALSE,FALSE,TRUE));
} else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
emitcode("xrl","a,%s",
- aopGet(AOP(left),offset,FALSE,FALSE));
+ aopGet(AOP(left),offset,FALSE,FALSE,FALSE));
}
emitcode("jnz","%05d$",tlbl->key+100);
offset++;
if(AOP_TYPE(right) == AOP_LIT){
if(((lit >> (offset*8)) & 0x0FFL) == 0x00L){
aopPut(AOP(result),
- aopGet(AOP(left),offset,FALSE,FALSE),
+ aopGet(AOP(left),offset,FALSE,FALSE,FALSE),
offset);
continue;
}
// faster than result <- left, anl result,right
// and better if result is SFR
if (AOP_TYPE(left) == AOP_ACC)
- emitcode("xrl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
+ emitcode("xrl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE,FALSE));
else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+ MOVA(aopGet(AOP(right),offset,FALSE,FALSE,TRUE));
emitcode("xrl","a,%s",
- aopGet(AOP(left),offset,FALSE,TRUE));
+ aopGet(AOP(left),offset,FALSE,TRUE,FALSE));
}
aopPut(AOP(result),"a",offset);
}
size = AOP_SIZE(result);
offset = size - 1 ;
CLRC;
+
+ _startLazyDPSEvaluation();
while (size--) {
- l = aopGet(AOP(left),offset,FALSE,FALSE);
+ l = aopGet(AOP(left),offset,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("rrc","a");
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) {
- l = aopGet(AOP(result),AOP_SIZE(result)-1,FALSE,FALSE);
+ l = aopGet(AOP(result),AOP_SIZE(result)-1,FALSE,FALSE,TRUE);
MOVA(l);
}
emitcode("mov","acc.7,c");
size = AOP_SIZE(result);
offset = 0 ;
if (size--) {
- l = aopGet(AOP(left),offset,FALSE,FALSE);
+ l = aopGet(AOP(left),offset,FALSE,FALSE,TRUE);
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);
+ l = aopGet(AOP(left),offset,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("rlc","a");
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) {
- l = aopGet(AOP(result),0,FALSE,FALSE);
+ l = aopGet(AOP(result),0,FALSE,FALSE,TRUE);
MOVA(l);
}
emitcode("mov","acc.0,c");
D(emitcode(";", "genGetHbit "););
/* get the highest order byte into a */
- MOVA(aopGet(AOP(left),AOP_SIZE(left) - 1,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),AOP_SIZE(left) - 1,FALSE,FALSE,TRUE));
if(AOP_TYPE(result) == AOP_CRY){
emitcode("rlc","a");
outBitC(result);
}
}
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* AccSRsh - signed right shift accumulator by known count */
/*-----------------------------------------------------------------*/
}
}
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftR1Left2Result - shift right one byte from left to result */
/*-----------------------------------------------------------------*/
operand *result, int offr,
int shCount, int sign)
{
- MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),offl,FALSE,FALSE,TRUE));
/* shift right accumulator */
if(sign)
AccSRsh(shCount);
AccRsh(shCount);
aopPut(AOP(result),"a",offr);
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftL1Left2Result - shift left one byte from left to result */
/*-----------------------------------------------------------------*/
operand *result, int offr, int shCount)
{
char *l;
- l = aopGet(AOP(left),offl,FALSE,FALSE);
+ l = aopGet(AOP(left),offl,FALSE,FALSE,TRUE);
MOVA(l);
/* shift left accumulator */
AccLsh(shCount);
aopPut(AOP(result),"a",offr);
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* movLeft2Result - move byte from left to result */
/*-----------------------------------------------------------------*/
{
char *l;
if(!sameRegs(AOP(left),AOP(result)) || (offl != offr)){
- l = aopGet(AOP(left),offl,FALSE,FALSE);
+ l = aopGet(AOP(left),offl,FALSE,FALSE,FALSE);
if (*l == '@' && (IS_AOP_PREG(result))) {
emitcode("mov","a,%s",l);
}
}
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* AccAXRrl1 - right rotate c->a:x->c by 1 */
/*-----------------------------------------------------------------*/
emitcode("rrc","a");
emitcode("xch","a,%s", x);
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* AccAXLrl1 - left rotate c<-a:x<-c by 1 */
/*-----------------------------------------------------------------*/
emitcode("xch","a,%s",x);
emitcode("rlc","a");
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* AccAXLsh1 - left shift a:x<-0 by 1 */
/*-----------------------------------------------------------------*/
emitcode("xch","a,%s",x);
emitcode("rlc","a");
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* AccAXLsh - left shift a:x by known count (0..7) */
/*-----------------------------------------------------------------*/
break;
}
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* AccAXRsh - right shift a:x known count (0..7) */
/*-----------------------------------------------------------------*/
break;
}
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* AccAXRshS - right shift signed a:x known count (0..7) */
/*-----------------------------------------------------------------*/
break;
}
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftL2Left2Result - shift left two bytes from left to result */
/*-----------------------------------------------------------------*/
if(sameRegs(AOP(result), AOP(left)) &&
((offl + MSB16) == offr)){
/* don't crash result[offr] */
- MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
- emitcode("xch","a,%s", aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),offl,FALSE,FALSE,TRUE));
+ emitcode("xch","a,%s", aopGet(AOP(left),offl+MSB16,FALSE,FALSE,FALSE));
} else {
movLeft2Result(left,offl, result, offr, 0);
- MOVA(aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),offl+MSB16,FALSE,FALSE,TRUE));
}
/* ax << shCount (x = lsb(result))*/
- AccAXLsh( aopGet(AOP(result),offr,FALSE,FALSE) , shCount);
+ AccAXLsh( aopGet(AOP(result),offr,FALSE,FALSE,FALSE), shCount);
aopPut(AOP(result),"a",offr+MSB16);
}
+#endif
-
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftR2Left2Result - shift right two bytes from left to result */
/*-----------------------------------------------------------------*/
if(sameRegs(AOP(result), AOP(left)) &&
((offl + MSB16) == offr)){
/* don't crash result[offr] */
- MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
- emitcode("xch","a,%s", aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),offl,FALSE,FALSE,TRUE));
+ emitcode("xch","a,%s", aopGet(AOP(left),offl+MSB16,FALSE,FALSE,FALSE));
} else {
movLeft2Result(left,offl, result, offr, 0);
- MOVA(aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),offl+MSB16,FALSE,FALSE,TRUE));
}
/* a:x >> shCount (x = lsb(result))*/
if(sign)
- AccAXRshS( aopGet(AOP(result),offr,FALSE,FALSE) , shCount);
+ AccAXRshS( aopGet(AOP(result),offr,FALSE,FALSE,FALSE) , shCount);
else
- AccAXRsh( aopGet(AOP(result),offr,FALSE,FALSE) , shCount);
+ AccAXRsh( aopGet(AOP(result),offr,FALSE,FALSE,FALSE) , shCount);
if(getDataSize(result) > 1)
aopPut(AOP(result),"a",offr+MSB16);
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftLLeftOrResult - shift left one byte from left, or to result*/
/*-----------------------------------------------------------------*/
static void shiftLLeftOrResult (operand *left, int offl,
operand *result, int offr, int shCount)
{
- MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),offl,FALSE,FALSE,TRUE));
/* shift left accumulator */
AccLsh(shCount);
/* or with result */
- emitcode("orl","a,%s", aopGet(AOP(result),offr,FALSE,FALSE));
+ emitcode("orl","a,%s", aopGet(AOP(result),offr,FALSE,FALSE,FALSE));
/* back to result */
aopPut(AOP(result),"a",offr);
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftRLeftOrResult - shift right one byte from left,or to result*/
/*-----------------------------------------------------------------*/
static void shiftRLeftOrResult (operand *left, int offl,
operand *result, int offr, int shCount)
{
- MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),offl,FALSE,FALSE,TRUE));
/* shift right accumulator */
AccRsh(shCount);
/* or with result */
- emitcode("orl","a,%s", aopGet(AOP(result),offr,FALSE,FALSE));
+ emitcode("orl","a,%s", aopGet(AOP(result),offr,FALSE,FALSE,FALSE));
/* back to result */
aopPut(AOP(result),"a",offr);
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* genlshOne - left shift a one byte quantity by known count */
/*-----------------------------------------------------------------*/
D(emitcode(";", "genlshOne "););
shiftL1Left2Result(left, LSB, result, LSB, shCount);
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* genlshTwo - left shift two bytes by known amount != 0 */
/*-----------------------------------------------------------------*/
shiftL2Left2Result(left, LSB, result, LSB, shCount);
}
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftLLong - shift left one long from left to result */
/* offl = LSB or MSB16 */
int size = AOP_SIZE(result);
if(size >= LSB+offr){
- l = aopGet(AOP(left),LSB,FALSE,FALSE);
+ l = aopGet(AOP(left),LSB,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("add","a,acc");
if (sameRegs(AOP(left),AOP(result)) &&
size >= MSB16+offr && offr != LSB )
emitcode("xch","a,%s",
- aopGet(AOP(left),LSB+offr,FALSE,FALSE));
+ aopGet(AOP(left),LSB+offr,FALSE,FALSE,FALSE));
else
aopPut(AOP(result),"a",LSB+offr);
}
if(size >= MSB16+offr){
if (!(sameRegs(AOP(result),AOP(left)) && size >= MSB16+offr && offr != LSB) ) {
- l = aopGet(AOP(left),MSB16,FALSE,FALSE);
+ l = aopGet(AOP(left),MSB16,FALSE,FALSE,TRUE);
MOVA(l);
}
emitcode("rlc","a");
if (sameRegs(AOP(left),AOP(result)) &&
size >= MSB24+offr && offr != LSB)
emitcode("xch","a,%s",
- aopGet(AOP(left),MSB16+offr,FALSE,FALSE));
+ aopGet(AOP(left),MSB16+offr,FALSE,FALSE,FALSE));
else
aopPut(AOP(result),"a",MSB16+offr);
}
if(size >= MSB24+offr){
if (!(sameRegs(AOP(left),AOP(left)) && size >= MSB24+offr && offr != LSB)) {
- l = aopGet(AOP(left),MSB24,FALSE,FALSE);
+ l = aopGet(AOP(left),MSB24,FALSE,FALSE,TRUE);
MOVA(l);
}
emitcode("rlc","a");
if (sameRegs(AOP(left),AOP(result)) &&
size >= MSB32+offr && offr != LSB )
emitcode("xch","a,%s",
- aopGet(AOP(left),MSB24+offr,FALSE,FALSE));
+ aopGet(AOP(left),MSB24+offr,FALSE,FALSE,FALSE));
else
aopPut(AOP(result),"a",MSB24+offr);
}
if(size > MSB32+offr){
if (!(sameRegs(AOP(result),AOP(left)) && size >= MSB32+offr && offr != LSB)) {
- l = aopGet(AOP(left),MSB32,FALSE,FALSE);
+ l = aopGet(AOP(left),MSB32,FALSE,FALSE,TRUE);
MOVA(l);
}
emitcode("rlc","a");
if(offr != LSB)
aopPut(AOP(result),zero,LSB);
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* genlshFour - shift four byte by a known amount != 0 */
/*-----------------------------------------------------------------*/
shiftL2Left2Result(left, LSB, result, LSB, shCount);
}
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* genLeftShiftLiteral - left shifting by known count */
/*-----------------------------------------------------------------*/
freeAsmop(left,NULL,ic,TRUE);
freeAsmop(result,NULL,ic,TRUE);
}
+#endif
/*-----------------------------------------------------------------*/
/* genLeftShift - generates code for left shifting */
aopOp(right,ic,FALSE, FALSE);
- #if 0
+#if 0
/* if the shift count is known then do it
as efficiently as possible */
if (AOP_TYPE(right) == AOP_LIT) {
genLeftShiftLiteral (left,right,result,ic);
return ;
}
- #endif
+#endif
/* shift count is unknown then we have to form
a loop get the loop count in B : Note: we take
more that 32 bits make no sense anyway, ( the
largest size of an object can be only 32 bits ) */
- emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE));
+ emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE,FALSE));
emitcode("inc","b");
freeAsmop (right,NULL,ic,TRUE);
aopOp(left,ic,FALSE, FALSE);
size = AOP_SIZE(result);
offset=0;
+ _startLazyDPSEvaluation();
while (size--) {
- l = aopGet(AOP(left),offset,FALSE,TRUE);
+ l = aopGet(AOP(left),offset,FALSE,TRUE,FALSE);
if (*l == '@' && (IS_AOP_PREG(result))) {
emitcode("mov","a,%s",l);
aopPut(AOP(result),l,offset);
offset++;
}
+ _endLazyDPSEvaluation();
}
tlbl = newiTempLabel(NULL);
if (size == 1) {
symbol *tlbl1 = newiTempLabel(NULL);
- l = aopGet(AOP(left),0,FALSE,FALSE);
+ l = aopGet(AOP(left),0,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("sjmp","%05d$",tlbl1->key+100);
emitcode("","%05d$:",tlbl->key+100);
emitcode("sjmp","%05d$",tlbl1->key+100);
emitcode("","%05d$:",tlbl->key+100);
- l = aopGet(AOP(result),offset,FALSE,FALSE);
+ l = aopGet(AOP(result),offset,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("add","a,acc");
aopPut(AOP(result),"a",offset++);
+ _startLazyDPSEvaluation();
while (--size) {
- l = aopGet(AOP(result),offset,FALSE,FALSE);
+ 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);
freeAsmop(result,NULL,ic,TRUE);
}
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* genrshOne - right shift a one byte quantity by known count */
/*-----------------------------------------------------------------*/
D(emitcode(";", "genrshOne"););
shiftR1Left2Result(left, LSB, result, LSB, shCount, sign);
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* genrshTwo - right shift two bytes by known amount != 0 */
/*-----------------------------------------------------------------*/
else
shiftR2Left2Result(left, LSB, result, LSB, shCount, sign);
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftRLong - shift right one long from left to result */
/* offl = LSB or MSB16 */
{
if(!sign)
emitcode("clr","c");
- MOVA(aopGet(AOP(left),MSB32,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),MSB32,FALSE,FALSE,TRUE));
if(sign)
emitcode("mov","c,acc.7");
emitcode("rrc","a");
/* add sign of "a" */
addSign(result, MSB32, sign);
- MOVA(aopGet(AOP(left),MSB24,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),MSB24,FALSE,FALSE,TRUE));
emitcode("rrc","a");
aopPut(AOP(result),"a",MSB24-offl);
- MOVA(aopGet(AOP(left),MSB16,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),MSB16,FALSE,FALSE,TRUE));
emitcode("rrc","a");
aopPut(AOP(result),"a",MSB16-offl);
if(offl == LSB){
- MOVA(aopGet(AOP(left),LSB,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),LSB,FALSE,FALSE,TRUE));
emitcode("rrc","a");
aopPut(AOP(result),"a",LSB);
}
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* genrshFour - shift four byte by a known amount != 0 */
/*-----------------------------------------------------------------*/
}
}
}
+#endif
+#if 0
+//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* genRightShiftLiteral - right shifting by known count */
/*-----------------------------------------------------------------*/
else if(shCount >= (size * 8)){
if(sign)
/* get sign in acc.7 */
- MOVA(aopGet(AOP(left),size-1,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),size-1,FALSE,FALSE,TRUE));
addSign(result, LSB, sign);
} else{
switch (size) {
freeAsmop(result,NULL,ic,TRUE);
}
}
+#endif
/*-----------------------------------------------------------------*/
/* genSignedRightShift - right shift of signed number */
aopOp(right,ic,FALSE, FALSE);
- #if 0
+#if 0
if ( AOP_TYPE(right) == AOP_LIT) {
genRightShiftLiteral (left,right,result,ic,1);
return ;
}
- #endif
- /* shift count is unknown then we have to form
+#endif
+ /* shift count is unknown then we have to form
a loop get the loop count in B : Note: we take
only the lower order byte since shifting
more that 32 bits make no sense anyway, ( the
largest size of an object can be only 32 bits ) */
- emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE));
+ emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE,FALSE));
emitcode("inc","b");
freeAsmop (right,NULL,ic,TRUE);
aopOp(left,ic,FALSE, FALSE);
size = AOP_SIZE(result);
offset=0;
+ _startLazyDPSEvaluation();
while (size--) {
- l = aopGet(AOP(left),offset,FALSE,TRUE);
+ l = aopGet(AOP(left),offset,FALSE,TRUE,FALSE);
if (*l == '@' && IS_AOP_PREG(result)) {
emitcode("mov","a,%s",l);
aopPut(AOP(result),l,offset);
offset++;
}
+ _endLazyDPSEvaluation();
}
/* mov the highest order bit to OVR */
size = AOP_SIZE(result);
offset = size - 1;
- emitcode("mov","a,%s",aopGet(AOP(left),offset,FALSE,FALSE));
+ emitcode("mov","a,%s",aopGet(AOP(left),offset,FALSE,FALSE,FALSE));
emitcode("rlc","a");
emitcode("mov","ov,c");
/* if it is only one byte then */
if (size == 1) {
- l = aopGet(AOP(left),0,FALSE,FALSE);
+ l = aopGet(AOP(left),0,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("sjmp","%05d$",tlbl1->key+100);
emitcode("","%05d$:",tlbl->key+100);
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);
+ 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);
aopOp(right,ic,FALSE, FALSE);
- #if 0
+#if 0
/* if the shift count is known then do it
as efficiently as possible */
if (AOP_TYPE(right) == AOP_LIT) {
genRightShiftLiteral (left,right,result,ic, 0);
return ;
}
- #endif
+#endif
/* shift count is unknown then we have to form
a loop get the loop count in B : Note: we take
more that 32 bits make no sense anyway, ( the
largest size of an object can be only 32 bits ) */
- emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE));
+ emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE,FALSE));
emitcode("inc","b");
freeAsmop (right,NULL,ic,TRUE);
aopOp(left,ic,FALSE, FALSE);
size = AOP_SIZE(result);
offset=0;
+ _startLazyDPSEvaluation();
while (size--) {
- l = aopGet(AOP(left),offset,FALSE,TRUE);
+ l = aopGet(AOP(left),offset,FALSE,TRUE,FALSE);
if (*l == '@' && IS_AOP_PREG(result)) {
emitcode("mov","a,%s",l);
aopPut(AOP(result),l,offset);
offset++;
}
+ _endLazyDPSEvaluation();
}
tlbl = newiTempLabel(NULL);
/* if it is only one byte then */
if (size == 1) {
- l = aopGet(AOP(left),0,FALSE,FALSE);
+ l = aopGet(AOP(left),0,FALSE,FALSE,TRUE);
MOVA(l);
emitcode("sjmp","%05d$",tlbl1->key+100);
emitcode("","%05d$:",tlbl->key+100);
emitcode("sjmp","%05d$",tlbl1->key+100);
emitcode("","%05d$:",tlbl->key+100);
CLRC;
+ _startLazyDPSEvaluation();
while (size--) {
- l = aopGet(AOP(result),offset,FALSE,FALSE);
+ 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);
aopOp(result,ic,TRUE, FALSE);
/* get the string representation of the name */
- l = aopGet(AOP(left),0,FALSE,TRUE);
+ 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);
preg = getFreePtr(ic,&aop,FALSE);
emitcode("mov","%s,%s",
preg->name,
- aopGet(AOP(left),0,FALSE,TRUE));
+ aopGet(AOP(left),0,FALSE,TRUE,FALSE));
rname = preg->name ;
} else
- rname = aopGet(AOP(left),0,FALSE,FALSE);
+ rname = aopGet(AOP(left),0,FALSE,FALSE,FALSE);
freeAsmop(left,NULL,ic,TRUE);
aopOp (result,ic,FALSE, FALSE);
preg = getFreePtr(ic,&aop,FALSE);
emitcode("mov","%s,%s",
preg->name,
- aopGet(AOP(left),0,FALSE,TRUE));
+ aopGet(AOP(left),0,FALSE,TRUE,FALSE));
rname = preg->name ;
} else
- rname = aopGet(AOP(left),0,FALSE,FALSE);
+ rname = aopGet(AOP(left),0,FALSE,FALSE,FALSE);
freeAsmop(left,NULL,ic,TRUE);
aopOp (result,ic,FALSE, FALSE);
/* if this is remateriazable */
if (AOP_TYPE(left) == AOP_IMMD)
{
- emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE));
+ emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE,FALSE));
}
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));
- emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE));
- }
+ emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE,TRUE));
+ emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE,TRUE));
+ emitcode("mov","dpx,%s",aopGet(AOP(left),2,FALSE,FALSE,TRUE));
}
else
{
/* We need to generate a load to DPTR indirect through DPTR. */
D(emitcode(";", "genFarPointerGet -- indirection special case."););
- emitcode("push", "%s", aopGet(AOP(left),0,FALSE,TRUE));
- emitcode("push", "%s", aopGet(AOP(left),1,FALSE,TRUE));
- emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE));
- emitcode("pop", "acc");
- emitcode("mov", "dph,a");
- emitcode("pop", "acc");
- emitcode("mov", "dpl,a");
+ emitcode("push", "%s", aopGet(AOP(left),0,FALSE,TRUE,TRUE));
+ emitcode("push", "%s", aopGet(AOP(left),1,FALSE,TRUE,TRUE));
+ emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE,TRUE));
+ emitcode("pop", "dph");
+ emitcode("pop", "dpl");
}
+ _endLazyDPSEvaluation();
}
}
/* so dptr know contains the address */
size = AOP_SIZE(result);
offset = 0 ;
+ _startLazyDPSEvaluation();
while (size--) {
+
+ genSetDPTR(0);
+ _flushLazyDPS();
+
emitcode("movx","a,@dptr");
- aopPut(AOP(result),"a",offset++);
if (size)
- emitcode("inc","dptr");
+ emitcode("inc","dptr");
+
+ aopPut(AOP(result),"a",offset++);
}
+ _endLazyDPSEvaluation();
}
freeAsmop(result,NULL,ic,TRUE);
if (AOP_TYPE(left) != AOP_STR) {
/* if this is remateriazable */
if (AOP_TYPE(left) == AOP_IMMD)
- emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE));
+ emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE,FALSE));
else { /* we need to get it byte by byte */
- emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE));
- emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE));
- }
+ _startLazyDPSEvaluation();
+ emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE,TRUE));
+ emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE,TRUE));
+ emitcode("mov","dpx,%s",aopGet(AOP(left),2,FALSE,FALSE,TRUE));
+ _endLazyDPSEvaluation();
}
}
/* so dptr know contains the address */
freeAsmop(left,NULL,ic,TRUE);
- aopOp(result,ic,FALSE, FALSE);
+ aopOp(result,ic,FALSE, TRUE);
/* if bit then unpack */
if (IS_BITVAR(retype))
size = AOP_SIZE(result);
offset = 0 ;
- while (size--) {
+ _startLazyDPSEvaluation();
+ while (size--)
+ {
+ genSetDPTR(0);
+ _flushLazyDPS();
+
emitcode("clr","a");
emitcode("movc","a,@a+dptr");
- aopPut(AOP(result),"a",offset++);
if (size)
- emitcode("inc","dptr");
+ emitcode("inc","dptr");
+ aopPut(AOP(result),"a",offset++);
}
+ _endLazyDPSEvaluation();
}
freeAsmop(result,NULL,ic,TRUE);
if (AOP_TYPE(left) != AOP_STR) {
/* if this is remateriazable */
if (AOP_TYPE(left) == AOP_IMMD) {
- emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE));
+ emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE,FALSE));
emitcode("mov","b,#%d",pointerCode(retype));
}
else { /* we need to get it byte by byte */
- emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE));
- emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE));
+ _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));
- emitcode("mov","b,%s",aopGet(AOP(left),3,FALSE,FALSE));
+ emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE,TRUE));
+ emitcode("mov","b,%s",aopGet(AOP(left),3,FALSE,FALSE,TRUE));
}
else
{
- emitcode("mov","b,%s",aopGet(AOP(left),2,FALSE,FALSE));
+ emitcode("mov","b,%s",aopGet(AOP(left),2,FALSE,FALSE,TRUE));
}
+ _endLazyDPSEvaluation();
}
}
/* so dptr know contains the address */
blen = SPEC_BLEN(etype);
bstr = SPEC_BSTR(etype);
- l = aopGet(AOP(right),offset++,FALSE,FALSE);
+ l = aopGet(AOP(right),offset++,FALSE,FALSE,TRUE);
MOVA(l);
/* if the bit lenth is less than or */
/* now generate for lengths greater than one byte */
while (1) {
- l = aopGet(AOP(right),offset++,FALSE,TRUE);
+ l = aopGet(AOP(right),offset++,FALSE,TRUE,FALSE);
rLen -= 8 ;
if (rLen <= 0 )
aopOp(right,ic,FALSE, FALSE);
- l = aopGet(AOP(result),0,FALSE,TRUE);
+ l = aopGet(AOP(result),0,FALSE,TRUE,FALSE);
size = AOP_SIZE(right);
while (size--) {
if (offset)
else
sprintf(buffer,"%s",l+1);
emitcode("mov","%s,%s",buffer,
- aopGet(AOP(right),offset++,FALSE,FALSE));
+ aopGet(AOP(right),offset++,FALSE,FALSE,FALSE));
}
freeAsmop(right,NULL,ic,TRUE);
preg = getFreePtr(ic,&aop,FALSE);
emitcode("mov","%s,%s",
preg->name,
- aopGet(AOP(result),0,FALSE,TRUE));
+ aopGet(AOP(result),0,FALSE,TRUE,FALSE));
rname = preg->name ;
} else
- rname = aopGet(AOP(result),0,FALSE,FALSE);
+ rname = aopGet(AOP(result),0,FALSE,FALSE,FALSE);
freeAsmop(result,NULL,ic,TRUE);
aopOp (right,ic,FALSE, FALSE);
int offset = 0 ;
while (size--) {
- l = aopGet(AOP(right),offset,FALSE,TRUE);
+ l = aopGet(AOP(right),offset,FALSE,TRUE,FALSE);
if (*l == '@' ) {
MOVA(l);
emitcode("mov","@%s,a",rname);
preg = getFreePtr(ic,&aop,FALSE);
emitcode("mov","%s,%s",
preg->name,
- aopGet(AOP(result),0,FALSE,TRUE));
+ aopGet(AOP(result),0,FALSE,TRUE,FALSE));
rname = preg->name ;
} else
- rname = aopGet(AOP(result),0,FALSE,FALSE);
+ rname = aopGet(AOP(result),0,FALSE,FALSE,FALSE);
freeAsmop(result,NULL,ic,TRUE);
aopOp (right,ic,FALSE, FALSE);
int offset = 0 ;
while (size--) {
- l = aopGet(AOP(right),offset,FALSE,TRUE);
+ l = aopGet(AOP(right),offset,FALSE,TRUE,TRUE);
MOVA(l);
emitcode("movx","@%s,a",rname);
if (AOP_TYPE(result) != AOP_STR) {
/* if this is remateriazable */
if (AOP_TYPE(result) == AOP_IMMD)
- emitcode("mov","dptr,%s",aopGet(AOP(result),0,TRUE,FALSE));
+ emitcode("mov","dptr,%s",aopGet(AOP(result),0,TRUE,FALSE,FALSE));
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));
- emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE));
- }
+ emitcode("mov","dpl,%s",aopGet(AOP(result),0,FALSE,FALSE,TRUE));
+ emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE,TRUE));
+ emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE,TRUE));
}
else
{
/* We need to generate a load to DPTR indirect through DPTR. */
D(emitcode(";", "genFarPointerSet -- indirection special case."););
- emitcode("push", "%s", aopGet(AOP(result),0,FALSE,TRUE));
- emitcode("push", "%s", aopGet(AOP(result),1,FALSE,TRUE));
- emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE));
- emitcode("pop", "acc");
- emitcode("mov", "dph,a");
- emitcode("pop", "acc");
- emitcode("mov", "dpl,a");
+ emitcode("push", "%s", aopGet(AOP(result),0,FALSE,TRUE,TRUE));
+ emitcode("push", "%s", aopGet(AOP(result),1,FALSE,TRUE,TRUE));
+ emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE,TRUE));
+ 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);
+ char *l = aopGet(AOP(right),offset++,FALSE,FALSE,TRUE);
MOVA(l);
+
+ genSetDPTR(0);
+ _flushLazyDPS();
+
emitcode("movx","@dptr,a");
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));
- emitcode("mov","b,%s + 1",aopGet(AOP(result),0,TRUE,FALSE));
+ emitcode("mov","dptr,%s",aopGet(AOP(result),0,TRUE,FALSE,FALSE));
+ emitcode("mov","b,%s + 1",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));
- emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE));
- if (options.model == MODEL_FLAT24)
- {
- emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE));
- emitcode("mov","b,%s",aopGet(AOP(result),3,FALSE,FALSE));
- }
- else
- {
- emitcode("mov","b,%s",aopGet(AOP(result),2,FALSE,FALSE));
- }
+ emitcode("mov","dpl,%s",aopGet(AOP(result),0,FALSE,FALSE,TRUE));
+ emitcode("mov","dph,%s",aopGet(AOP(result),1,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);
size = AOP_SIZE(right);
offset = 0 ;
+ _startLazyDPSEvaluation();
while (size--) {
- char *l = aopGet(AOP(right),offset++,FALSE,FALSE);
+ char *l = aopGet(AOP(right),offset++,FALSE,FALSE,TRUE);
MOVA(l);
+
+ genSetDPTR(0);
+ _flushLazyDPS();
+
emitcode("lcall","__gptrput");
if (size)
emitcode("inc","dptr");
}
+ _endLazyDPSEvaluation();
}
freeAsmop(right,NULL,ic,TRUE);
{
int size = AOP_SIZE(right);
int offset = 0;
- char *l ;
+ char *l;
+
+#ifdef LAZY_DPS_OPT
+ if (size > 1)
+ {
+ /* This is a net loss for size == 1, but a big gain
+ * otherwise.
+ */
+ D(emitcode(";", "genFarFarAssign (improved)"););
+
+ aopOp(result,ic,TRUE, TRUE);
+
+ _startLazyDPSEvaluation();
+ while (size--)
+ {
+ aopPut(AOP(result),
+ aopGet(AOP(right),offset,FALSE,FALSE,FALSE),
+ offset);
+ offset++;
+ }
+ _endLazyDPSEvaluation();
+ freeAsmop(result,NULL,ic,FALSE);
+ freeAsmop(right,NULL,ic,FALSE);
+ }
+ else
+#endif
+ {
+ D(emitcode(";", "genFarFarAssign "););
+
/* first push the right side on to the stack */
+ _startLazyDPSEvaluation();
while (size--) {
- l = aopGet(AOP(right),offset++,FALSE,FALSE);
+ 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)) != 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
aopPut(AOP(result),
- aopGet(AOP(right),size,FALSE,FALSE),
+ 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),
+ 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)
{
aopOp(IC_JTCOND(ic),ic,FALSE, FALSE);
/* get the condition into accumulator */
- l = aopGet(AOP(IC_JTCOND(ic)),0,FALSE,FALSE);
+ l = aopGet(AOP(IC_JTCOND(ic)),0,FALSE,FALSE,TRUE);
MOVA(l);
- /* multiply by three */
+ /* multiply by four! */
+ emitcode("add","a,acc");
emitcode("add","a,acc");
- emitcode("add","a,%s",aopGet(AOP(IC_JTCOND(ic)),0,FALSE,FALSE));
freeAsmop(IC_JTCOND(ic),NULL,ic,TRUE);
jtab = newiTempLabel(NULL);
/* 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),
+ 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),
+ 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),
+ 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),
+ 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);
/* if unsigned or not an integral type */
- if (SPEC_USIGN(rtype) || !IS_SPEC(rtype)) {
+ /* 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)
+ {
while (size--)
+ {
aopPut(AOP(result),zero,offset++);
- } else {
+ }
+ }
+ else
+ {
/* we need to extend the sign :{ */
char *l = aopGet(AOP(right),AOP_SIZE(right) - 1,
- FALSE,FALSE);
+ FALSE,FALSE,TRUE);
MOVA(l);
emitcode("rlc","a");
emitcode("subb","a,acc");
if (IS_AOP_PREG(IC_RESULT(ic))) {
emitcode("dec","%s",
- aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
- emitcode("mov","a,%s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
+ aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE,FALSE));
+ emitcode("mov","a,%s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE,FALSE));
emitcode("jnz","%05d$",lbl->key+100);
} else {
- emitcode ("djnz","%s,%05d$",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE),
+ emitcode ("djnz","%s,%05d$",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE,FALSE),
lbl->key+100);
}
emitcode ("sjmp","%05d$",lbl1->key+100);
}
/*-----------------------------------------------------------------*/
-/* gen390Code - generate code for 8051 based controllers */
+/* gen390Code - generate code for Dallas 390 based controllers */
/*-----------------------------------------------------------------*/
void gen390Code (iCode *lic)
{
lineHead = lineCurr = NULL;
+#if 0
+ //REMOVE ME!!!
/* print the allocation information */
if (allocInfo)
printAllocInfo( currFunc, codeOutFile);
+#endif
/* if debug information required */
-/* if (options.debug && currFunc) { */
- if (currFunc) {
+ if (options.debug && currFunc) {
+ //jwk if (currFunc) {
cdbSymbol(currFunc,cdbFile,FALSE,TRUE);
_G.debugLine = 1;
if (IS_STATIC(currFunc->etype))