#include "SDCCglobl.h"
#include "newalloc.h"
-#ifdef HAVE_SYS_ISA_DEFS_H
-#include <sys/isa_defs.h>
-#else
-#ifdef HAVE_MACHINE_ENDIAN_H
-#include <machine/endian.h>
-#else
-#ifdef HAVE_ENDIAN_H
-#include <endian.h>
-#else
-#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__)
-#warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN"
-#warning "If you running sdcc on an INTEL 80x86 Platform you are okay"
-#endif
-#endif
-#endif
-#endif
-
#define BETTER_LITERAL_SHIFT
char *aopLiteral (value * val, int offset);
(IC_RESULT(x) && IC_RESULT(x)->aop && \
IC_RESULT(x)->aop->type == AOP_STK )
-/* #define MOVA(x) if (strcmp(x,"a") && strcmp(x,"acc")) emitcode("mov","a,%s",x); */
-#define MOVA(x) { char *_mova_tmp = strdup(x); \
- if (strcmp(_mova_tmp,"a") && strcmp(_mova_tmp,"acc")) \
- { \
- emitcode("mov","a,%s",_mova_tmp); \
- } \
- free(_mova_tmp); \
- }
-#define MOVB(x) { char *_movb_tmp = strdup(x); \
- if (strcmp(_movb_tmp,"b")) \
- { \
- emitcode("mov","b,%s",_movb_tmp); \
- } \
- free(_movb_tmp); \
- }
+#define MOVA(x) _movA(x)
+#define MOVB(x) _movB(x)
+
#define CLRC emitcode("clr","c")
#define SETC emitcode("setb","c")
va_end (ap);
}
+//
+// Move the passed value into A unless it is already there.
+//
+static void
+_movA(const char *s)
+{
+ if (strcmp(s,"a") && strcmp(s,"acc"))
+ {
+ emitcode("mov","a,%s",s);
+ }
+}
+
+//
+// Move the passed value into B unless it is already there.
+//
+static void
+_movB(const char *s)
+{
+ if (strcmp(s,"b"))
+ {
+ emitcode("mov","b,%s",s);
+ }
+}
+
/*-----------------------------------------------------------------*/
/* getFreePtr - returns r0 or r1 whichever is free or can be pushed */
/*-----------------------------------------------------------------*/
if (stack_val < 0 && stack_val > -5) { /* between -5 & -1 */
if (useDP2) {
if (options.model == MODEL_FLAT24)
- emitcode ("mov", "dpx1,#!constbyte", (options.stack_loc >> 16) & 0xff);
- TR_DPTR("#2");
+ {
+ emitcode ("mov", "dpx1,#!constbyte",
+ (options.stack_loc >> 16) & 0xff);
+ }
emitcode ("mov", "dph1,_bpx+1");
+
emitcode ("mov", "dpl1,_bpx");
emitcode ("mov","dps,#1");
} else {
if (options.model == MODEL_FLAT24)
- emitcode ("mov", "dpx,#!constbyte", (options.stack_loc >> 16) & 0xff);
+ {
+ emitcode ("mov", "dpx,#!constbyte",
+ (options.stack_loc >> 16) & 0xff);
+ }
emitcode ("mov", "dph,_bpx+1");
emitcode ("mov", "dpl,_bpx");
}
emitcode ("subb","a,#!constbyte",(stack_val >> 8) & 0xff);
if (useDP2) {
if (options.model == MODEL_FLAT24)
- emitcode ("mov", "dpx1,#!constbyte", (options.stack_loc >> 16) & 0xff);
- TR_DPTR("#2");
+ {
+ emitcode ("mov", "dpx1,#!constbyte",
+ (options.stack_loc >> 16) & 0xff);
+ }
emitcode ("mov", "dph1,a");
emitcode ("mov", "dpl1,b");
} else {
if (options.model == MODEL_FLAT24)
- emitcode ("mov", "dpx,#!constbyte", (options.stack_loc >> 16) & 0xff);
+ {
+ emitcode ("mov", "dpx,#!constbyte",
+ (options.stack_loc >> 16) & 0xff);
+ }
emitcode ("mov", "dph,a");
emitcode ("mov", "dpl,b");
}
"(%s %c 0x%04x)",
OP_SYMBOL (IC_LEFT (ic))->rname,
val >= 0 ? '+' : '-',
- abs (val) & 0xffff);
+ abs (val) & 0xffffff);
}
else
{
}
}
+#define DEFAULT_ACC_WARNING 0
+static int saveAccWarn = DEFAULT_ACC_WARNING;
+
/*-------------------------------------------------------------------*/
/* aopGet - for fetching value of the aop */
/* */
if (aop->type == AOP_DPTR2)
{
genSetDPTR (1);
- if (saveAcc)
- {
- TR_AP("#1");
- emitcode ("xch", "a, %s", saveAcc);
- }
+ }
+
+ if (saveAcc)
+ {
+ TR_AP("#1");
+// if (aop->type != AOP_DPTR2)
+// {
+// if (saveAccWarn) { fprintf(stderr, "saveAcc for DPTR...\n"); }
+// emitcode(";", "spanky: saveAcc for DPTR");
+// }
+
+ emitcode ("xch", "a, %s", saveAcc);
}
_flushLazyDPS ();
if (aop->type == AOP_DPTR2)
{
genSetDPTR (0);
- if (saveAcc)
- {
+ }
+
+ if (saveAcc)
+ {
TR_AP("#2");
emitcode ("xch", "a, %s", saveAcc);
+// if (strcmp(saveAcc, "_ap"))
+// {
+// emitcode(";", "spiffy: non _ap return from aopGet.");
+// }
+
return saveAcc;
- }
}
return (dname ? "acc" : "a");
genNotFloat (operand * op, operand * res)
{
int size, offset;
- char *l;
symbol *tlbl;
D (emitcode (";", "genNotFloat "););
offset = 1;
_startLazyDPSEvaluation ();
- l = aopGet (op->aop, offset++, FALSE, FALSE, NULL);
- MOVA (l);
+ MOVA(aopGet(op->aop, offset++, FALSE, FALSE, NULL));
while (size--)
{
if (AOP_NEEDSACC (oper) && size)
{
usedB = TRUE;
- emitcode ("push", "b");
- MOVB (aopGet (AOP (oper), 0, FALSE, FALSE, "b"));
+ if (_G.bInUse)
+ {
+ emitcode ("push", "b");
+ }
+ MOVB (aopGet (AOP (oper), 0, FALSE, FALSE, NULL));
}
else
{
else
{
emitcode ("orl", "a,%s",
- aopGet (AOP (oper), offset++, FALSE, FALSE, DP2_RESULT_REG));
+ aopGet (AOP (oper), offset++, FALSE, FALSE, NULL));
}
}
_endLazyDPSEvaluation ();
if (usedB)
{
emitcode ("mov", "a,b");
- emitcode ("pop", "b");
+ if (_G.bInUse)
+ {
+ emitcode ("pop", "b");
+ }
+
}
}
/* if the registers have been saved already then
do nothing */
- if (ic->regsSaved || IFFUNC_ISNAKED(OP_SYM_TYPE(IC_LEFT(ic)))) return ;
+ if (ic->regsSaved ||
+ (IS_SYMOP(IC_LEFT(ic)) && IFFUNC_ISNAKED(OP_SYM_TYPE(IC_LEFT(ic)))))
+ return ;
/* special case if DPTR alive across a function call then must save it
even though callee saves */
- if (IFFUNC_CALLEESAVES(OP_SYMBOL (IC_LEFT (ic))->type)) {
+ if (IS_SYMOP(IC_LEFT(ic)) &&
+ IFFUNC_CALLEESAVES(OP_SYMBOL (IC_LEFT (ic))->type)) {
int i;
rsave = newBitVect(ic->rMask->size);
for (i = DPL_IDX ; i <= B_IDX ; i++ ) {
{
int offset = 0;
int size = AOP_SIZE (oper);
+ bool pushedAcc = FALSE;
+ if (size == fReturnSizeDS390)
+ {
+ /* I don't think this case can ever happen... */
+ /* ACC is the last part of this. If writing the result
+ * uses AC, we must preserve it.
+ */
+ if (AOP_NEEDSACC(oper))
+ {
+ emitcode(";", "assignResultValue special case for ACC.");
+ emitcode("push", "acc");
+ pushedAcc = TRUE;
+ size--;
+ }
+ }
+
+
_startLazyDPSEvaluation ();
while (size--)
{
offset++;
}
_endLazyDPSEvaluation ();
+
+ if (pushedAcc)
+ {
+ emitcode("pop", "acc");
+ aopPut(AOP(oper), "a", offset);
+ }
}
}
}
+static void
+adjustEsp(const char *reg)
+{
+ emitcode ("anl","%s,#3", reg);
+ if (TARGET_IS_DS400)
+ {
+ emitcode ("orl","%s,#!constbyte",
+ reg,
+ (options.stack_loc >> 8) & 0xff);
+ }
+}
+
/*-----------------------------------------------------------------*/
/* genCall - generates a call statement */
/*-----------------------------------------------------------------*/
emitcode ("subb","a,#!constbyte",ic->parmBytes & 0xff);
emitcode ("mov","sp,a");
emitcode ("mov","a,esp");
- emitcode ("anl","a,#3");
+ adjustEsp("a");
emitcode ("subb","a,#!constbyte",(ic->parmBytes >> 8) & 0xff);
emitcode ("mov","esp,a");
UNPROTECT_SP;
emitcode ("subb","a,#!constbyte",ic->parmBytes & 0xff);
emitcode ("mov","sp,a");
emitcode ("mov","a,esp");
- emitcode ("anl","a,#3");
+ adjustEsp("a");
emitcode ("subb","a,#!constbyte",(ic->parmBytes >> 8) & 0xff);
emitcode ("mov","esp,a");
UNPROTECT_SP;
}
}
}
- // jwk: this needs a closer look
+ // TODO: this needs a closer look
SPEC_ISR_SAVED_BANKS(currFunc->etype) = banksToSave;
}
}
emitcode ("push","_bpx+1");
emitcode ("mov","_bpx,%s",spname);
emitcode ("mov","_bpx+1,esp");
- emitcode ("anl","_bpx+1,#3");
+ adjustEsp("_bpx+1");
} else {
if (options.useXstack) {
emitcode ("mov", "r0,%s", spname);
emitcode ("add","a,#!constbyte", ((short) sym->stack & 0xff));
emitcode ("mov","sp,a");
emitcode ("mov","a,esp");
- emitcode ("anl","a,#3");
+ adjustEsp("a");
emitcode ("addc","a,#!constbyte", (((short) sym->stack) >> 8) & 0xff);
emitcode ("mov","esp,a");
UNPROTECT_SP;
* Restore any register banks saved by genFunction
* in reverse order.
*/
- // jwk: this needs a closer look
unsigned savedBanks = SPEC_ISR_SAVED_BANKS(currFunc->etype);
int ix;
// AOP_IS_DPTRn(IC_LEFT(ic)) ? "true" : "false",
// AOP_IS_DPTRn(IC_RIGHT(ic)) ? "true" : "false",
// AOP_IS_DPTRn(IC_RESULT(ic)) ? "true" : "false");
-// );
-
+// );
- // Right uses DPTR unless left or result is an AOP_STR.
- aopOp (IC_RIGHT(ic),ic,FALSE, AOP_IS_STR(IC_LEFT(ic)) || AOP_IS_STR(IC_RESULT(ic)));
+ // Right uses DPTR unless left or result is an AOP_STR; however,
+ // if right is an AOP_STR, it must use DPTR regardless.
+ if ((AOP_IS_STR(IC_LEFT(ic)) || AOP_IS_STR(IC_RESULT(ic)))
+ && !AOP_IS_STR(IC_RIGHT(ic)))
+ {
+ useDp2 = TRUE;
+ }
+ else
+ {
+ useDp2 = FALSE;
+ }
+
+ aopOp (IC_RIGHT(ic),ic,FALSE, useDp2);
// if the right used DPTR, left MUST use DPTR2.
// if the right used DPTR2, left MUST use DPTR.
MOVA (aopGet (AOP (IC_LEFT (ic)), offset, FALSE, FALSE, NULL));
if (offset == 0)
emitcode ("add", "a,%s",
- aopGet (AOP (IC_RIGHT (ic)), offset, FALSE, FALSE, DP2_RESULT_REG));
+ aopGet (AOP (IC_RIGHT (ic)), offset, FALSE, FALSE, NULL));
else
emitcode ("addc", "a,%s",
- aopGet (AOP (IC_RIGHT (ic)), offset, FALSE, FALSE, DP2_RESULT_REG));
+ aopGet (AOP (IC_RIGHT (ic)), offset, FALSE, FALSE, NULL));
}
else
{
emitcode ("mov", "a,#!constbyte",0xff);
emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
}
- l = aopGet (AOP (IC_RESULT (ic)), MSB16, FALSE, NULL, NULL);
+ l = aopGet (AOP (IC_RESULT (ic)), MSB16, FALSE, FALSE, NULL);
emitcode ("dec", "%s", l);
if (size > 2)
{
emitcode ("mov", "a,#!constbyte",0xff);
emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
}
- l = aopGet (AOP (IC_RESULT (ic)), MSB24, FALSE, NULL, NULL);
+ l = aopGet (AOP (IC_RESULT (ic)), MSB24, FALSE, FALSE, NULL);
emitcode ("dec", "%s", l);
}
if (size > 3)
emitcode ("mov", "a,#!constbyte",0xff);
emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
}
- l = aopGet (AOP (IC_RESULT (ic)), MSB32, FALSE, NULL, NULL);
+ l = aopGet (AOP (IC_RESULT (ic)), MSB32, FALSE, FALSE, NULL);
emitcode ("dec", "%s", l);
}
if (emitTlbl)
AOP_TYPE (right) == AOP_CRY)
{
emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir);
- emitcode ("anl", "c,/%s", AOP (left)->aopu.aop_dir);
+ emitcode ("anl", "c,%s", AOP (left)->aopu.aop_dir);
}
else
{
CLRC;
while (size--)
{
- //emitcode (";", "genCmp #1: %d/%d/%d", size, sign, offset);
+ // emitcode (";", "genCmp #1: %d/%d/%d", size, sign, offset);
MOVA (aopGet (AOP (left), offset, FALSE, FALSE, NULL));
- //emitcode (";", "genCmp #2");
+ // emitcode (";", "genCmp #2");
if (sign && (size == 0))
{
- //emitcode (";", "genCmp #3");
+ // emitcode (";", "genCmp #3");
emitcode ("xrl", "a,#!constbyte",0x80);
if (AOP_TYPE (right) == AOP_LIT)
{
unsigned long lit = (unsigned long)
floatFromVal (AOP (right)->aopu.aop_lit);
- //emitcode (";", "genCmp #3.1");
+ // emitcode (";", "genCmp #3.1");
emitcode ("subb", "a,#!constbyte",
0x80 ^ (unsigned int) ((lit >> (offset * 8)) & 0x0FFL));
}
else
{
- //emitcode (";", "genCmp #3.2");
- if (AOP_NEEDSACC (right) && AOP_TYPE(right) != AOP_DPTR2)
- {
- emitcode ("push", "acc");
- }
-
+ // emitcode (";", "genCmp #3.2");
+ saveAccWarn = 0;
MOVB(aopGet (AOP (right), offset++, FALSE, FALSE, "b"));
+ saveAccWarn = DEFAULT_ACC_WARNING;
emitcode ("xrl", "b,#!constbyte",0x80);
-
- if (AOP_NEEDSACC (right) && AOP_TYPE(right) != AOP_DPTR2)
- {
- emitcode ("pop", "acc");
- }
emitcode ("subb", "a,b");
}
}
{
const char *s;
- //emitcode (";", "genCmp #4");
- if (AOP_NEEDSACC (right))
- {
- /* Yuck!! */
- //emitcode (";", "genCmp #4.1");
- emitcode ("xch", "a, b");
- MOVA (aopGet (AOP (right), offset++, FALSE, FALSE, NULL));
- emitcode ("xch", "a, b");
- s = "b";
- }
- else
- {
- //emitcode (";", "genCmp #4.2");
- s = aopGet (AOP (right), offset++, FALSE, FALSE, DP2_RESULT_REG);
- }
+ // emitcode (";", "genCmp #4");
+ saveAccWarn = 0;
+ s = aopGet (AOP (right), offset++, FALSE, FALSE, "b");
+ saveAccWarn = DEFAULT_ACC_WARNING;
emitcode ("subb", "a,%s", s);
}
{
MOVA (aopGet (AOP (left), offset, FALSE, FALSE, NULL));
emitcode ("cjne", "a,%s,!tlabel",
- aopGet (AOP (right), offset, FALSE, FALSE, DP2_RESULT_REG),
+ aopGet (AOP (right), offset, FALSE, FALSE, NULL),
lbl->key + 100);
offset++;
}
else
emitcode ("anl", "%s,%s",
aopGet (AOP (left), offset, FALSE, TRUE, NULL),
- aopGet (AOP (right), offset, FALSE, FALSE, DP2_RESULT_REG));
+ aopGet (AOP (right), offset, FALSE, FALSE, NULL));
}
else
{
}
#endif
-#if 0
-//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftLLeftOrResult - shift left one byte from left, or to result */
/*-----------------------------------------------------------------*/
/* back to result */
aopPut (AOP (result), "a", offr);
}
-#endif
#if 0
//REMOVE ME!!!
_startLazyDPSEvaluation ();
while (size--)
{
- l = aopGet (AOP (left), offset, FALSE, TRUE, DP2_RESULT_REG);
+ l = aopGet (AOP (left), offset, FALSE, TRUE, NULL);
if (*l == '@' && (IS_AOP_PREG (result)))
{
}
#endif
-#if 0
-//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* shiftRLong - shift right one long from left to result */
/* offl = LSB or MSB16 */
werror(E_INTERNAL_ERROR, __FILE__, __LINE__);
}
- MOVA (aopGet (AOP (left), MSB32, FALSE, NULL));
+ MOVA (aopGet (AOP (left), MSB32, FALSE, FALSE, NULL));
if (offl==MSB16) {
// shift is > 8
emitcode ("rlc", "a");
emitcode ("subb", "a,acc");
emitcode ("xch", "a,%s",
- aopGet(AOP(left), MSB32, FALSE, DP2_RESULT_REG));
+ aopGet(AOP(left), MSB32, FALSE, FALSE, DP2_RESULT_REG));
} else {
aopPut (AOP(result), zero, MSB32);
}
if (isSameRegs && offl==MSB16) {
emitcode ("xch",
- "a,%s",aopGet (AOP (left), MSB24, FALSE, DP2_RESULT_REG));
+ "a,%s",aopGet (AOP (left), MSB24, FALSE, FALSE, DP2_RESULT_REG));
} else {
aopPut (AOP (result), "a", MSB32);
- MOVA (aopGet (AOP (left), MSB24, FALSE, NULL));
+ MOVA (aopGet (AOP (left), MSB24, FALSE, FALSE, NULL));
}
emitcode ("rrc", "a");
if (isSameRegs && offl==1) {
emitcode ("xch", "a,%s",
- aopGet (AOP (left), MSB16, FALSE, DP2_RESULT_REG));
+ aopGet (AOP (left), MSB16, FALSE, FALSE, DP2_RESULT_REG));
} else {
aopPut (AOP (result), "a", MSB24);
- MOVA (aopGet (AOP (left), MSB16, FALSE, NULL));
+ MOVA (aopGet (AOP (left), MSB16, FALSE, FALSE, NULL));
}
emitcode ("rrc", "a");
aopPut (AOP (result), "a", MSB16 - offl);
if (offl == LSB)
{
- MOVA (aopGet (AOP (left), LSB, FALSE, NULL));
+ MOVA (aopGet (AOP (left), LSB, FALSE, FALSE, NULL));
emitcode ("rrc", "a");
aopPut (AOP (result), "a", LSB);
}
}
-#endif
-#if 0
-//REMOVE ME!!!
/*-----------------------------------------------------------------*/
/* genrshFour - shift four byte by a known amount != 0 */
/*-----------------------------------------------------------------*/
genrshFour (operand * result, operand * left,
int shCount, int sign)
{
- D (emitcode (";", "genrshFour");
- );
+ D (emitcode (";", "genrshFour"););
/* if shifting more that 3 bytes */
if (shCount >= 24)
{
shCount -= 24;
+ _startLazyDPSEvaluation();
if (shCount)
shiftR1Left2Result (left, MSB32, result, LSB, shCount, sign);
else
movLeft2Result (left, MSB32, result, LSB, sign);
addSign (result, MSB16, sign);
+ _endLazyDPSEvaluation();
}
else if (shCount >= 16)
{
shCount -= 16;
+ _startLazyDPSEvaluation();
if (shCount)
shiftR2Left2Result (left, MSB24, result, LSB, shCount, sign);
else
movLeft2Result (left, MSB32, result, MSB16, sign);
}
addSign (result, MSB24, sign);
+ _endLazyDPSEvaluation();
}
else if (shCount >= 8)
{
shCount -= 8;
+ _startLazyDPSEvaluation();
if (shCount == 1)
- shiftRLong (left, MSB16, result, sign);
+ {
+ shiftRLong (left, MSB16, result, sign);
+ }
else if (shCount == 0)
{
movLeft2Result (left, MSB16, result, LSB, 0);
shiftR1Left2Result (left, MSB32, result, MSB24, shCount, sign);
addSign (result, MSB32, sign);
}
+ _endLazyDPSEvaluation();
}
else
- { /* 1 <= shCount <= 7 */
+ {
+ /* 1 <= shCount <= 7 */
if (shCount <= 2)
{
shiftRLong (left, LSB, result, sign);
}
}
}
-#endif
#ifdef BETTER_LITERAL_SHIFT
/*-----------------------------------------------------------------*/
if ((shCount != 0)
&& (shCount < (size * 8))
&& (size != 1)
- && (size != 2))
+ && (size != 2)
+ /* && (size != 4) in a minute... */)
{
D(emitcode (";", "genRightShiftLiteral wimping out"););
return FALSE;
case 2:
genrshTwo (result, left, shCount, sign);
break;
-#if 0
+#if 1
case 4:
genrshFour (result, left, shCount, sign);
break;
else
{
/* We need to generate a load to DPTR indirect through DPTR. */
- D (emitcode (";", "genFarPointerGet -- indirection special case.");
- );
+ D (emitcode (";", "genFarPointerGet -- indirection special case."););
emitcode ("push", "%s", aopGet (AOP (left), 0, FALSE, TRUE, NULL));
emitcode ("push", "%s", aopGet (AOP (left), 1, FALSE, TRUE, NULL));
if (options.model == MODEL_FLAT24)
}
if (dopi && pi && AOP_TYPE (left) != AOP_IMMD) {
if (!AOP_INDPTRn(left)) {
+ _startLazyDPSEvaluation ();
aopPut ( AOP (left), "dpl", 0);
aopPut ( AOP (left), "dph", 1);
if (options.model == MODEL_FLAT24)
aopPut ( AOP (left), "dpx", 2);
+ _endLazyDPSEvaluation ();
}
pi->generated = 1;
- } else if ((OP_SYMBOL(left)->ruonly || AOP_INDPTRn(left)) &&
+ } else if ((AOP_IS_STR(left) || AOP_INDPTRn(left)) &&
AOP_SIZE(result) > 1 &&
- (OP_SYMBOL (left)->liveTo > ic->seq || ic->depth)) {
+ IS_SYMOP(left) &&
+ (OP_SYMBOL(left)->liveTo > ic->seq || ic->depth)) {
size = AOP_SIZE (result) - 1;
if (AOP_INDPTRn(left)) {
else
{
/* We need to generate a load to DPTR indirect through DPTR. */
- D (emitcode (";", "gencodePointerGet -- indirection special case.");
- );
+ D (emitcode (";", "gencodePointerGet -- indirection special case."););
emitcode ("push", "%s", aopGet (AOP (left), 0, FALSE, TRUE, NULL));
emitcode ("push", "%s", aopGet (AOP (left), 1, FALSE, TRUE, NULL));
if (options.model == MODEL_FLAT24)
}
if (dopi && pi && AOP_TYPE (left) != AOP_IMMD) {
if (!AOP_INDPTRn(left)) {
+ _startLazyDPSEvaluation ();
+
aopPut ( AOP (left), "dpl", 0);
aopPut ( AOP (left), "dph", 1);
if (options.model == MODEL_FLAT24)
aopPut ( AOP (left), "dpx", 2);
+
+ _endLazyDPSEvaluation ();
}
pi->generated = 1;
} else if ((OP_SYMBOL(left)->ruonly || AOP_INDPTRn(left)) &&
}
if (pi && AOP_TYPE (left) != AOP_IMMD) {
+ _startLazyDPSEvaluation ();
+
aopPut ( AOP (left), "dpl", 0);
aopPut ( AOP (left), "dph", 1);
if (options.model == MODEL_FLAT24) {
aopPut ( AOP (left), "dpx", 2);
aopPut ( AOP (left), "b", 3);
} else aopPut ( AOP (left), "b", 2);
+
+ _endLazyDPSEvaluation ();
+
pi->generated = 1;
} else if (OP_SYMBOL(left)->ruonly && AOP_SIZE(result) > 1 &&
(OP_SYMBOL (left)->liveTo > ic->seq || ic->depth)) {
if (dopi && pi && AOP_TYPE (result) != AOP_IMMD) {
if (!AOP_INDPTRn(result)) {
+ _startLazyDPSEvaluation ();
+
aopPut (AOP(result),"dpl",0);
aopPut (AOP(result),"dph",1);
if (options.model == MODEL_FLAT24)
aopPut (AOP(result),"dpx",2);
+
+ _endLazyDPSEvaluation ();
}
pi->generated=1;
} else if ((OP_SYMBOL(result)->ruonly || AOP_INDPTRn(result)) &&
}
_endLazyDPSEvaluation ();
}
- /* so dptr know contains the address */
+ /* so dptr + b now contains the address */
+ _G.bInUse++;
aopOp (right, ic, FALSE, TRUE);
+ _G.bInUse--;
+
/* if bit then unpack */
if (IS_BITVAR (retype) || IS_BITVAR (letype))
- genPackBits ((IS_BITVAR (retype) ? retype : letype), right, "dptr", GPOINTER);
+ {
+ genPackBits ((IS_BITVAR (retype) ? retype : letype), right, "dptr", GPOINTER);
+ }
else
{
- size = AOP_SIZE (right);
- offset = 0;
+ size = AOP_SIZE (right);
+ offset = 0;
- _startLazyDPSEvaluation ();
- while (size--)
+ _startLazyDPSEvaluation ();
+ while (size--)
{
- MOVA (aopGet (AOP (right), offset++, FALSE, FALSE, NULL));
-
- genSetDPTR (0);
- _flushLazyDPS ();
+ if (size)
+ {
+ // Set two bytes at a time, passed in _AP & A.
+ // dptr will be incremented ONCE by __gptrputWord.
+ //
+ // Note: any change here must be coordinated
+ // with the implementation of __gptrputWord
+ // in device/lib/_gptrput.c
+ emitcode("mov", "_ap, %s",
+ aopGet (AOP (right), offset++, FALSE, FALSE, NULL));
+ MOVA (aopGet (AOP (right), offset++, FALSE, FALSE, NULL));
+
+ genSetDPTR (0);
+ _flushLazyDPS ();
+ emitcode ("lcall", "__gptrputWord");
+ size--;
+ }
+ else
+ {
+ // Only one byte to put.
+ MOVA (aopGet (AOP (right), offset++, FALSE, FALSE, NULL));
- emitcode ("lcall", "__gptrput");
- if (size || (pi && AOP_TYPE (result) != AOP_IMMD))
- emitcode ("inc", "dptr");
+ genSetDPTR (0);
+ _flushLazyDPS ();
+ emitcode ("lcall", "__gptrput");
+ }
+
+ if (size || (pi && AOP_TYPE (result) != AOP_IMMD))
+ {
+ emitcode ("inc", "dptr");
+ }
}
- _endLazyDPSEvaluation ();
+ _endLazyDPSEvaluation ();
}
if (pi && AOP_TYPE (result) != AOP_IMMD) {
+ _startLazyDPSEvaluation ();
+
aopPut (AOP(result),"dpl",0);
aopPut (AOP(result),"dph",1);
if (options.model == MODEL_FLAT24) {
} else {
aopPut (AOP(result),"b",2);
}
+ _endLazyDPSEvaluation ();
+
pi->generated=1;
} else if (OP_SYMBOL(result)->ruonly && AOP_SIZE(right) > 1 &&
(OP_SYMBOL (result)->liveTo > ic->seq || ic->depth)) {
/* if 10 bit stack */
if (options.stack10bit) {
char buff[10];
+ int offset;
+
tsprintf(buff, sizeof(buff),
"#!constbyte",(options.stack_loc >> 16) & 0xff);
/* if it has an offset then we need to compute it */
((char) sym->stack )) & 0xff);
emitcode ("mov", "b,a");
emitcode ("mov", "a,_bpx+1");
- emitcode ("addc","a,#!constbyte", (((sym->stack < 0) ?
- ((short) (sym->stack - _G.nRegsSaved)) :
- ((short) sym->stack )) >> 8) & 0xff);
+
+ offset = (((sym->stack < 0) ?
+ ((short) (sym->stack - _G.nRegsSaved)) :
+ ((short) sym->stack )) >> 8) & 0xff;
+
+ emitcode ("addc","a,#!constbyte", offset);
+
aopPut (AOP (IC_RESULT (ic)), "b", 0);
aopPut (AOP (IC_RESULT (ic)), "a", 1);
aopPut (AOP (IC_RESULT (ic)), buff, 2);
if (offset) {
switch (offset) {
case 1:
- tsprintf(s, sizeof(s), "!his",sym->rname);
+ tsprintf(s, sizeof(s), "#!his",sym->rname);
break;
case 2:
- tsprintf(s, sizeof(s), "!hihis",sym->rname);
+ tsprintf(s, sizeof(s), "#!hihis",sym->rname);
break;
case 3:
- tsprintf(s, sizeof(s), "!hihihis",sym->rname);
+ tsprintf(s, sizeof(s), "#!hihihis",sym->rname);
break;
default: /* should not need this (just in case) */
SNPRINTF (s, sizeof(s), "#(%s >> %d)",
}
+#if 0 // obsolete, and buggy for != xdata
/*-----------------------------------------------------------------*/
/* genArrayInit - generates code for address of */
/*-----------------------------------------------------------------*/
freeAsmop (IC_LEFT(ic), NULL, ic, TRUE);
}
+#endif
/*-----------------------------------------------------------------*/
/* genFarFarAssign - assignment when both are in far space */
/* also, if the source is a bit, we don't need to sign extend, because
* it can't possibly have set the sign bit.
*/
- if (SPEC_USIGN (rtype) || !IS_SPEC (rtype) || AOP_TYPE (right) == AOP_CRY)
+ if (!IS_SPEC (rtype) || SPEC_USIGN (rtype) || AOP_TYPE (right) == AOP_CRY)
{
while (size--)
{
static void
genReceive (iCode * ic)
{
-
int size = getSize (operandType (IC_RESULT (ic)));
int offset = 0;
int rb1off ;
- D (emitcode (";", "genReceive ");
- );
+ D (emitcode (";", "genReceive "););
- if (ic->argreg == 1) { /* first parameter */
- if (isOperandInFarSpace (IC_RESULT (ic)) &&
- (OP_SYMBOL (IC_RESULT (ic))->isspilt ||
- IS_TRUE_SYMOP (IC_RESULT (ic))))
- {
- offset = fReturnSizeDS390 - size;
- while (size--)
- {
- emitcode ("push", "%s", (strcmp (fReturn[fReturnSizeDS390 - offset - 1], "a") ?
- fReturn[fReturnSizeDS390 - offset - 1] : "acc"));
- offset++;
- }
- aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
- size = AOP_SIZE (IC_RESULT (ic));
- offset = 0;
- while (size--)
- {
- emitcode ("pop", "acc");
- aopPut (AOP (IC_RESULT (ic)), "a", offset++);
- }
-
- } else {
- _G.accInUse++;
- aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
- _G.accInUse--;
- assignResultValue (IC_RESULT (ic));
- }
- } else { /* second receive onwards */
- /* this gets a little tricky since unused recevies will be
+ if (ic->argreg == 1)
+ {
+ /* first parameter */
+ if (AOP_IS_STR(IC_RESULT(ic)))
+ {
+ /* Nothing to do: it's already in the proper place. */
+ return;
+ }
+ else
+ {
+ bool useDp2;
+
+ useDp2 = isOperandInFarSpace (IC_RESULT (ic)) &&
+ (OP_SYMBOL (IC_RESULT (ic))->isspilt ||
+ IS_TRUE_SYMOP (IC_RESULT (ic)));
+
+ _G.accInUse++;
+ aopOp (IC_RESULT (ic), ic, FALSE, useDp2);
+ _G.accInUse--;
+
+ /* Sanity checking... */
+ if (AOP_USESDPTR(IC_RESULT(ic)))
+ {
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ "genReceive got unexpected DPTR.");
+ }
+ assignResultValue (IC_RESULT (ic));
+ }
+ }
+ else
+ {
+ /* second receive onwards */
+ /* this gets a little tricky since unused recevies will be
eliminated, we have saved the reg in the type field . and
we use that to figure out which register to use */
- aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
- rb1off = ic->argreg;
- while (size--) {
- aopPut (AOP (IC_RESULT (ic)), rb1regs[rb1off++ -5], offset++);
- }
-
- }
- freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
+ aopOp (IC_RESULT (ic), ic, FALSE, FALSE);
+ rb1off = ic->argreg;
+ while (size--)
+ {
+ aopPut (AOP (IC_RESULT (ic)), rb1regs[rb1off++ -5], offset++);
+ }
+ }
+ freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
}
/*-----------------------------------------------------------------*/
if (rsym->liveFrom != rsym->liveTo) {
aopOp (IC_RESULT(ic),ic,FALSE,FALSE);
if (AOP_TYPE(IC_RESULT(ic)) != AOP_STR) {
+ _startLazyDPSEvaluation ();
+
aopPut(AOP(IC_RESULT(ic)),"dpl",0);
aopPut(AOP(IC_RESULT(ic)),"dph",1);
aopPut(AOP(IC_RESULT(ic)),"dpx",2);
+
+ _endLazyDPSEvaluation ();
+
}
}
}
}
#if 1
/* print the allocation information */
- if (allocInfo)
+ if (allocInfo && currFunc)
printAllocInfo (currFunc, codeOutFile);
#endif
/* if debug information required */
if (options.debug && currFunc)
{
- cdbSymbol (currFunc, cdbFile, FALSE, TRUE);
+ debugFile->writeFunction(currFunc);
_G.debugLine = 1;
if (IS_STATIC (currFunc->etype))
emitcode ("", "F%s$%s$0$0 ==.", moduleName, currFunc->name);
else addSet (&_G.sendSet, ic);
break;
+#if 0 // obsolete, and buggy for != xdata
case ARRAYINIT:
genArrayInit(ic);
break;
+#endif
default:
ic = ic;