{
dbuf_append_char (&dbuf, '\t');
dbuf_tvprintf (&dbuf, fmt, ap);
{
dbuf_append_char (&dbuf, '\t');
dbuf_tvprintf (&dbuf, fmt, ap);
- else if (IS_CAST_ICODE(ic)) {
- sym_link *from_type = operandType(IC_RIGHT(ic));
- aop->aopu.aop_immd.from_cast_remat = 1;
- ic = OP_SYMBOL (IC_RIGHT (ic))->rematiCode;
- ptr_type = pointerTypeToGPByte (DCL_TYPE(from_type), NULL, NULL);
- continue;
- } else break;
+ else if (IS_CAST_ICODE(ic))
+ {
+ sym_link *from_type = operandType(IC_RIGHT(ic));
+ aop->aopu.aop_immd.from_cast_remat = 1;
+ ic = OP_SYMBOL (IC_RIGHT (ic))->rematiCode;
+ ptr_type = pointerTypeToGPByte (DCL_TYPE(from_type), NULL, NULL);
+ continue;
+ }
+ else break;
SNPRINTF (buffer, sizeof(buffer),
"(%s %c 0x%06x)",
OP_SYMBOL (IC_LEFT (ic))->rname,
val >= 0 ? '+' : '-',
abs (val) & 0xffffff);
SNPRINTF (buffer, sizeof(buffer),
"(%s %c 0x%06x)",
OP_SYMBOL (IC_LEFT (ic))->rname,
val >= 0 ? '+' : '-',
abs (val) & 0xffffff);
SNPRINTF(buffer, sizeof(buffer),
"0x%x",(int) operandLitValue (IC_RIGHT (ic)));
SNPRINTF(buffer, sizeof(buffer),
"0x%x",(int) operandLitValue (IC_RIGHT (ic)));
tsprintf(buffer, sizeof(buffer), "#!constbyte",ptr_type);
aop->aopu.aop_immd.aop_immd2 = Safe_strdup(buffer);
tsprintf(buffer, sizeof(buffer), "#!constbyte",ptr_type);
aop->aopu.aop_immd.aop_immd2 = Safe_strdup(buffer);
+/*-----------------------------------------------------------------*/
+/* aopPutUsesAcc - indicates ahead of time whether aopPut() will */
+/* clobber the accumulator */
+/*-----------------------------------------------------------------*/
+static bool
+aopPutUsesAcc (operand * oper, const char *s, int offset)
+{
+ asmop * aop = AOP (oper);
+
+ if (offset > (aop->size - 1))
+ return FALSE;
+
+ switch (aop->type)
+ {
+ case AOP_DUMMY:
+ return TRUE;
+ case AOP_DIR:
+ return FALSE;
+ case AOP_REG:
+ wassert(strcmp(aop->aopu.aop_reg[offset]->name, "a"));
+ return FALSE;
+ case AOP_DPTRn:
+ return FALSE;
+ case AOP_DPTR:
+ case AOP_DPTR2:
+ return TRUE;
+ case AOP_R0:
+ case AOP_R1:
+ return ((aop->paged) || (*s == '@'));
+ case AOP_STK:
+ return (*s == '@');
+ case AOP_CRY:
+ return (!aop->aopu.aop_dir || strcmp(s, aop->aopu.aop_dir));
+ case AOP_STR:
+ return FALSE;
+ case AOP_IMMD:
+ return FALSE;
+ case AOP_ACC:
+ return FALSE;
+ default:
+ /* Error case --- will have been caught already */
+ wassert(0);
+ return FALSE;
+ }
+}
+
/*-----------------------------------------------------------------*/
/* aopPut - puts a string for a aop and indicates if acc is in use */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* aopPut - puts a string for a aop and indicates if acc is in use */
/*-----------------------------------------------------------------*/
emitcode ("mov", "%s,%s",
aop->aopu.aop_reg[offset]->dname, s);
}
emitcode ("mov", "%s,%s",
aop->aopu.aop_reg[offset]->dname, s);
}
{
emitcode ("mov", "%s,%s",
aop->aopu.aop_reg[offset]->name, s);
{
emitcode ("mov", "%s,%s",
aop->aopu.aop_reg[offset]->name, s);
emitcode ("mov", "@%s,%s",
aop->aopu.aop_ptr->name, buffer);
}
emitcode ("mov", "@%s,%s",
aop->aopu.aop_ptr->name, buffer);
}
+ }
+ else if (strcmp (s, "r0") == 0 ||
+ strcmp (s, "r1") == 0 ||
+ strcmp (s, "r2") == 0 ||
+ strcmp (s, "r3") == 0 ||
+ strcmp (s, "r4") == 0 ||
+ strcmp (s, "r5") == 0 ||
+ strcmp (s, "r6") == 0 ||
+ strcmp (s, "r7") == 0)
+ {
+ char buffer[10];
+ SNPRINTF (buffer, sizeof(buffer), "a%s", s);
+ emitcode ("push", buffer);
+ }
+ else
+ {
- /* if not bit variable */
- if (!aop->aopu.aop_dir)
+ // destination is carry for return-use-only
+ d = (IS_OP_RUONLY (result)) ? "c" : aop->aopu.aop_dir;
+
+ // source is no literal and not in carry
+ if ((s != zero) && (s != one) && strcmp (s, "c"))
- if (s == zero)
- emitcode ("clr", "%s", aop->aopu.aop_dir);
- else if (s == one)
- emitcode ("setb", "%s", aop->aopu.aop_dir);
- else if (!strcmp (s, "c"))
- emitcode ("mov", "%s,c", aop->aopu.aop_dir);
- else if (strcmp (s, aop->aopu.aop_dir))
+ if (!strcmp (s, "c"))
+ {
+ /* inefficient: move carry into A and use jz/jnz */
+ emitcode ("clr", "a");
+ emitcode ("rlc", "a");
+ accuse = TRUE;
+ }
+ else
+ else if (s == zero)
+ emitcode ("clr", "%s", d);
+ else if (s == one)
+ emitcode ("setb", "%s", d);
+ else if (strcmp (s, d))
+ emitcode ("mov", "%s,c", d);
+ int nPushed = _G.r0Pushed + _G.r1Pushed;
+
+ aopOp (oper, ic, FALSE, FALSE);
+
+ if (nPushed != _G.r0Pushed + _G.r1Pushed)
+ {
+ while (offset < size)
+ {
+ char *l = aopGet (oper, offset, FALSE, TRUE, NULL);
+ emitcode ("mov", "%s,%s", fReturn[offset++], l);
+ }
+ freeAsmop (oper, NULL, ic, TRUE);
+ offset = 0;
+ while (offset < size)
+ {
+ emitcode ("push", "%s", fReturn[offset++]);
+ }
+ return;
+ }
+
+/*-----------------------------------------------------------------*/
+/* popForBranch - recover the spilt registers for a branch */
+/*-----------------------------------------------------------------*/
+static void
+popForBranch (iCode * ic, bool markGenerated)
+{
+ while (ic && ic->op == IPOP)
+ {
+ genIpop (ic);
+ if (markGenerated)
+ ic->generated = 1; /* mark the icode as generated */
+ ic = ic->next;
+ }
+}
+
/*-----------------------------------------------------------------*/
/* saveRBank - saves an entire register bank on the stack */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* saveRBank - saves an entire register bank on the stack */
/*-----------------------------------------------------------------*/
- size = getSize (operandType (IC_LEFT (sic)));
- D (emitcode (";", "genSend argreg = %d, size = %d ",sic->argreg,size));
- if (sendCount == 0) { /* first parameter */
- // we know that dpl(hxb) is the result, so
- rb1_count = 0 ;
- _startLazyDPSEvaluation ();
- if (size>1) {
- aopOp (IC_LEFT (sic), sic, FALSE,
- (AOP_IS_STR(IC_LEFT(sic)) ? FALSE : TRUE));
- } else {
- aopOp (IC_LEFT (sic), sic, FALSE, FALSE);
+ size = getSize (operandType (IC_LEFT (sic)));
+ D (emitcode (";", "genSend argreg = %d, size = %d ",sic->argreg,size));
+ if (sendCount == 0)
+ { /* first parameter */
+ // we know that dpl(hxb) is the result, so
+ rb1_count = 0 ;
+ _startLazyDPSEvaluation ();
+ if (size>1)
+ {
+ aopOp (IC_LEFT (sic), sic, FALSE,
+ (AOP_IS_STR(IC_LEFT(sic)) ? FALSE : TRUE));
+ }
+ else
+ {
+ aopOp (IC_LEFT (sic), sic, FALSE, FALSE);
+ }
+ while (size--)
+ {
+ char *l = aopGet (IC_LEFT (sic), offset, FALSE, FALSE, NULL);
+ if (strcmp (l, fReturn[offset]))
+ {
+ emitcode ("mov", "%s,%s", fReturn[offset], l);
+ }
+ offset++;
+ }
+ _endLazyDPSEvaluation ();
+ freeAsmop (IC_LEFT (sic), NULL, sic, TRUE);
+ rb1_count =0;
- while (size--)
- {
- char *l = aopGet (IC_LEFT (sic), offset, FALSE, FALSE, NULL);
- if (strcmp (l, fReturn[offset]))
- {
- emitcode ("mov", "%s,%s", fReturn[offset], l);
- }
- offset++;
- }
- _endLazyDPSEvaluation ();
- freeAsmop (IC_LEFT (sic), NULL, sic, TRUE);
- rb1_count =0;
- } else { /* if more parameter in registers */
- aopOp (IC_LEFT (sic), sic, FALSE, TRUE);
- while (size--) {
- emitcode ("mov","b1_%d,%s",rb1_count++,aopGet (IC_LEFT (sic), offset++,
- FALSE, FALSE, NULL));
+ else
+ { /* if more parameter in registers */
+ aopOp (IC_LEFT (sic), sic, FALSE, TRUE);
+ while (size--)
+ {
+ emitcode ("mov","b1_%d,%s",rb1_count++,
+ aopGet (IC_LEFT (sic), offset, FALSE, FALSE, NULL));
+ offset++;
+ }
+ freeAsmop (IC_LEFT (sic), NULL, sic, TRUE);
- /* now push the calling address */
- aopOp (IC_LEFT (ic), ic, FALSE, FALSE);
-
- pushSide (IC_LEFT (ic), FPTRSIZE);
-
- freeAsmop (IC_LEFT (ic), NULL, ic, TRUE);
+ /* now push the function address */
+ pushSide (IC_LEFT (ic), FPTRSIZE, ic);
if (!inExcludeList ("acc"))
emitcode ("push", "acc");
if (!inExcludeList ("b"))
if (!inExcludeList ("acc"))
emitcode ("push", "acc");
if (!inExcludeList ("b"))
- emitcode ("cjne", "%s,%s,!tlabel", l, zero, tlbl->key + 100);
+ emitcode ("cjne", "%s,%s,!tlabel", l, zero, tlbl->key + 100);
- emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
+ emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
- emitcode ("cjne", "%s,%s,!tlabel", l, zero, tlbl->key + 100);
+ emitcode ("cjne", "%s,%s,!tlabel", l, zero, tlbl->key + 100);
- emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
+ emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
emitcode ("mov","dps,#!constbyte",AOP(IC_LEFT(ic))->aopu.dptr);
while (icount--)
emitcode ("inc", "dptr");
emitcode ("mov", "dps,#0");
return TRUE;
emitcode ("mov","dps,#!constbyte",AOP(IC_LEFT(ic))->aopu.dptr);
while (icount--)
emitcode ("inc", "dptr");
emitcode ("mov", "dps,#0");
return TRUE;
emitcode ("rlc", "a");
emitcode ("mov", "c,%s", AOP (IC_RIGHT (ic))->aopu.aop_dir);
emitcode ("addc", "a,%s", zero);
emitcode ("rlc", "a");
emitcode ("mov", "c,%s", AOP (IC_RIGHT (ic))->aopu.aop_dir);
emitcode ("addc", "a,%s", zero);
if ( AOP_IS_STR (IC_LEFT (ic)) &&
isOperandLiteral (IC_RIGHT (ic)) && OP_SYMBOL (IC_RESULT (ic))->ruonly) {
aopOp (IC_RIGHT (ic), ic, TRUE, FALSE);
if ( AOP_IS_STR (IC_LEFT (ic)) &&
isOperandLiteral (IC_RIGHT (ic)) && OP_SYMBOL (IC_RESULT (ic))->ruonly) {
aopOp (IC_RIGHT (ic), ic, TRUE, FALSE);
emitcode ("cjne", "%s,#!constbyte,!tlabel", l, 0xff, tlbl->key + 100);
emitcode ("cjne", "%s,#!constbyte,!tlabel", l, 0xff, tlbl->key + 100);
emitcode ("mov", "a,#!constbyte",0xff);
emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
emitcode ("mov", "a,#!constbyte",0xff);
emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
l = aopGet (IC_RESULT (ic), MSB16, FALSE, FALSE, NULL);
emitcode ("dec", "%s", l);
if (size > 2)
{
l = aopGet (IC_RESULT (ic), MSB16, FALSE, FALSE, NULL);
emitcode ("dec", "%s", l);
if (size > 2)
{
- emitcode ("cjne", "%s,#!constbyte,!tlabel", l, 0xff, tlbl->key + 100);
+ emitcode ("cjne", "%s,#!constbyte,!tlabel", l, 0xff, tlbl->key + 100);
- emitcode ("mov", "a,#!constbyte",0xff);
- emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
+ emitcode ("mov", "a,#!constbyte",0xff);
+ emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
- l = aopGet (IC_RESULT (ic), MSB24, FALSE, FALSE, NULL);
- emitcode ("dec", "%s", l);
+ l = aopGet (IC_RESULT (ic), MSB24, FALSE, FALSE, NULL);
+ emitcode ("dec", "%s", l);
- emitcode ("cjne", "%s,#!constbyte,!tlabel", l, 0xff, tlbl->key + 100);
+ emitcode ("cjne", "%s,#!constbyte,!tlabel", l, 0xff, tlbl->key + 100);
- emitcode ("mov", "a,#!constbyte",0xff);
- emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
+ emitcode ("mov", "a,#!constbyte",0xff);
+ emitcode ("cjne", "a,%s,!tlabel", l, tlbl->key + 100);
- l = aopGet (IC_RESULT (ic), MSB32, FALSE, FALSE, NULL);
- emitcode ("dec", "%s", l);
+ l = aopGet (IC_RESULT (ic), MSB32, FALSE, FALSE, NULL);
+ emitcode ("dec", "%s", l);
if (!rUnsigned && val < 0)
emitcode ("mov", "b,#!constbyte", -val);
if (!rUnsigned && val < 0)
emitcode ("mov", "b,#!constbyte", -val);
if (!lUnsigned && val < 0)
emitcode ("mov", "a,#!constbyte", -val);
if (!lUnsigned && val < 0)
emitcode ("mov", "a,#!constbyte", -val);
if (!rUnsigned && val < 0)
emitcode ("mov", "b,#0x%02x", -val);
if (!rUnsigned && val < 0)
emitcode ("mov", "b,#0x%02x", -val);
if (!lUnsigned && val < 0)
emitcode ("mov", "a,#0x%02x", -val);
if (!lUnsigned && val < 0)
emitcode ("mov", "a,#0x%02x", -val);
if (val < 0) {
lbl = newiTempLabel(NULL);
emitcode ("jbc","F0,!tlabel",lbl->key+100);
if (val < 0) {
lbl = newiTempLabel(NULL);
emitcode ("jbc","F0,!tlabel",lbl->key+100);
if (!rUnsigned && val < 0)
emitcode ("mov", "b,#0x%02x", -val);
if (!rUnsigned && val < 0)
emitcode ("mov", "b,#0x%02x", -val);
if (!(AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result)) && ifx)
{
freeAsmop (result, NULL, ic, TRUE);
if (!(AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result)) && ifx)
{
freeAsmop (result, NULL, ic, TRUE);
emitcode ("xrl", "a,#!constbyte",0x80);
if (AOP_TYPE (right) == AOP_LIT)
{
emitcode ("xrl", "a,#!constbyte",0x80);
if (AOP_TYPE (right) == AOP_LIT)
{
// emitcode (";", "genCmp #3.1");
emitcode ("subb", "a,#!constbyte",
0x80 ^ (unsigned int) ((lit >> (offset * 8)) & 0x0FFL));
// emitcode (";", "genCmp #3.1");
emitcode ("subb", "a,#!constbyte",
0x80 ^ (unsigned int) ((lit >> (offset * 8)) & 0x0FFL));
genCmpEq (iCode * ic, iCode * ifx)
{
operand *left, *right, *result;
genCmpEq (iCode * ic, iCode * ifx)
{
operand *left, *right, *result;
emitcode ("ljmp", "!tlabel", IC_TRUE (ifx)->key + 100);
}
else
{
emitcode ("jc", "!tlabel", tlbl->key + 100);
emitcode ("ljmp", "!tlabel", IC_TRUE (ifx)->key + 100);
}
else
{
emitcode ("jc", "!tlabel", tlbl->key + 100);
/* if operand of the form op = op + <sizeof *op> */
if (lic->op == '+' && isOperandEqual(IC_LEFT(lic),op) &&
isOperandEqual(IC_RESULT(lic),op) &&
isOperandLiteral(IC_RIGHT(lic)) &&
/* if operand of the form op = op + <sizeof *op> */
if (lic->op == '+' && isOperandEqual(IC_LEFT(lic),op) &&
isOperandEqual(IC_RESULT(lic),op) &&
isOperandLiteral(IC_RIGHT(lic)) &&
{
SNPRINTF (buffer, sizeof(buffer),
"acc.%d", posbit & 0x07);
{
SNPRINTF (buffer, sizeof(buffer),
"acc.%d", posbit & 0x07);
- for (; (size--); offset++)
- {
- // normal case
- // result = left ^ right
- if (AOP_TYPE (right) == AOP_LIT)
- {
- bytelit = (int) ((lit >> (offset * 8)) & 0x0FFL);
- if (bytelit == 0)
- {
- aopPut (result,
- aopGet (left, offset, FALSE, FALSE, NULL),
- offset);
- continue;
- }
- D (emitcode (";", "better literal XOR."));
- MOVA (aopGet (left, offset, FALSE, FALSE, NULL));
- emitcode ("xrl", "a, %s",
- aopGet (right, offset, FALSE, FALSE, DP2_RESULT_REG));
- }
- else
- {
- // faster than result <- left, anl result,right
- // and better if result is SFR
- if (AOP_TYPE (left) == AOP_ACC)
- {
- emitcode ("xrl", "a,%s",
- aopGet (right, offset,
- FALSE, FALSE, DP2_RESULT_REG));
- }
- else
- {
+ for (; (size--); offset++)
+ {
+ // normal case
+ // result = left ^ right
+ if (AOP_TYPE (right) == AOP_LIT)
+ {
+ bytelit = (int) ((lit >> (offset * 8)) & 0x0FFL);
+ if (bytelit == 0)
+ {
+ aopPut (result,
+ aopGet (left, offset, FALSE, FALSE, NULL),
+ offset);
+ continue;
+ }
+ D (emitcode (";", "better literal XOR."));
+ MOVA (aopGet (left, offset, FALSE, FALSE, NULL));
+ emitcode ("xrl", "a, %s",
+ aopGet (right, offset, FALSE, FALSE, DP2_RESULT_REG));
+ }
+ else
+ {
+ // faster than result <- left, anl result,right
+ // and better if result is SFR
+ if (AOP_TYPE (left) == AOP_ACC)
+ {
+ emitcode ("xrl", "a,%s",
+ aopGet (right, offset,
+ FALSE, FALSE, DP2_RESULT_REG));
+ }
+ else
+ {
char *rOp = aopGet (right, offset, FALSE, FALSE, NULL);
if (!strcmp(rOp, "a") || !strcmp(rOp, "acc"))
char *rOp = aopGet (right, offset, FALSE, FALSE, NULL);
if (!strcmp(rOp, "a") || !strcmp(rOp, "acc"))
MOVA (aopGet (left, offset, FALSE, FALSE, NULL));
emitcode ("xrl", "a,%s", rOp);
MOVA (aopGet (left, offset, FALSE, FALSE, NULL));
emitcode ("xrl", "a,%s", rOp);
l = aopGet (left, offl, FALSE, FALSE, NULL);
if (*l == '@' && (IS_AOP_PREG (result)))
l = aopGet (left, offl, FALSE, FALSE, NULL);
if (*l == '@' && (IS_AOP_PREG (result)))
emitcode ("mov", "a,%s", l);
aopPut (result, "a", offr);
emitcode ("mov", "a,%s", l);
aopPut (result, "a", offr);
- {
- _endLazyDPSEvaluation();
- shiftL1Left2Result (left, LSB, result, MSB16, shCount);
- aopPut (result, zero, LSB);
- }
+ {
+ _endLazyDPSEvaluation();
+ shiftL1Left2Result (left, LSB, result, MSB16, shCount);
+ aopPut (result, zero, LSB);
+ }
- {
- movLeft2Result (left, LSB, result, MSB16, 0);
- aopPut (result, zero, LSB);
- _endLazyDPSEvaluation();
- }
+ {
+ movLeft2Result (left, LSB, result, MSB16, 0);
+ aopPut (result, zero, LSB);
+ _endLazyDPSEvaluation();
+ }
* some small improvement.
*/
emitcode("mov", "b,#!constbyte",
* some small improvement.
*/
emitcode("mov", "b,#!constbyte",
size = getDataSize (result);
_startLazyDPSEvaluation();
while (size--)
movLeft2Result (left, size, result, size, 0);
_endLazyDPSEvaluation();
size = getDataSize (result);
_startLazyDPSEvaluation();
while (size--)
movLeft2Result (left, size, result, size, 0);
_endLazyDPSEvaluation();
* some small improvement.
*/
emitcode("mov", "b,#!constbyte",
* some small improvement.
*/
emitcode("mov", "b,#!constbyte",
* some small improvement.
*/
emitcode("mov", "b,#!constbyte",
* some small improvement.
*/
emitcode("mov", "b,#!constbyte",
- SNPRINTF (buffer, sizeof(buffer),
- "(%s + %d)", l + 1, offset);
+ SNPRINTF (buffer, sizeof(buffer), "(%s + %d)", l + 1, offset);
// with the implementation of __gptrgetWord
// in device/lib/_gptrget.c
emitcode ("lcall", "__gptrgetWord");
// with the implementation of __gptrgetWord
// in device/lib/_gptrget.c
emitcode ("lcall", "__gptrgetWord");
{
// Only one byte to get.
emitcode ("lcall", "__gptrget");
aopPut (result, "a", offset++);
}
{
// Only one byte to get.
emitcode ("lcall", "__gptrget");
aopPut (result, "a", offset++);
}
emitcode ("mov", "%s,%s", buffer,
aopGet (right, offset++, FALSE, FALSE, NULL));
}
emitcode ("mov", "%s,%s", buffer,
aopGet (right, offset++, FALSE, FALSE, NULL));
}
l = aopGet (right, offset, FALSE, TRUE, NULL);
MOVA (l);
emitcode ("movx", "@%s,a", rname);
l = aopGet (right, offset, FALSE, TRUE, NULL);
MOVA (l);
emitcode ("movx", "@%s,a", rname);
- // 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 (right, offset++, FALSE, FALSE, NULL));
- MOVA (aopGet (right, offset++, FALSE, FALSE, NULL));
-
- genSetDPTR (0);
- _flushLazyDPS ();
- emitcode ("lcall", "__gptrputWord");
- 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 (right, offset++, FALSE, FALSE, NULL));
+ MOVA (aopGet (right, offset++, FALSE, FALSE, NULL));
+
+ genSetDPTR (0);
+ _flushLazyDPS ();
+ emitcode ("lcall", "__gptrputWord");
+ size--;
- // Only one byte to put.
- MOVA (aopGet (right, offset++, FALSE, FALSE, NULL));
+ // Only one byte to put.
+ MOVA (aopGet (right, offset++, FALSE, FALSE, NULL));
/* the result is now in the accumulator or a directly addressable bit */
freeAsmop (cond, NULL, ic, TRUE);
/* the result is now in the accumulator or a directly addressable bit */
freeAsmop (cond, NULL, ic, TRUE);
aopPut (IC_RESULT (ic), "a", 1);
aopPut (IC_RESULT (ic), buff, 2);
} else {
aopPut (IC_RESULT (ic), "a", 1);
aopPut (IC_RESULT (ic), buff, 2);
} else {
tsprintf(s, sizeof(s), "#!hihihis",sym->rname);
break;
default: /* should not need this (just in case) */
tsprintf(s, sizeof(s), "#!hihihis",sym->rname);
break;
default: /* should not need this (just in case) */
+ if (opIsGptr (IC_RESULT (ic)))
+ {
+ char buffer[10];
+ SNPRINTF (buffer, sizeof(buffer), "#0x%02x",
+ pointerTypeToGPByte (pointerCode (getSpec (operandType (IC_LEFT (ic)))), NULL, NULL));
+ aopPut (IC_RESULT (ic), buffer, GPTRSIZE - 1);
+ }
emitcode ("mov", "b,%s",aopGet(count,0,FALSE,FALSE,NULL));
if (fromc) {
emitcode ("lcall","__bi_memcpyc2x_s");
emitcode ("mov", "b,%s",aopGet(count,0,FALSE,FALSE,NULL));
if (fromc) {
emitcode ("lcall","__bi_memcpyc2x_s");
emitcode ("mov", "b,%s",aopGet(count,0,FALSE,FALSE,NULL));
if (fromc)
emitcode("lcall","__bi_memcmpc2x_s");
emitcode ("mov", "b,%s",aopGet(count,0,FALSE,FALSE,NULL));
if (fromc)
emitcode("lcall","__bi_memcmpc2x_s");
emitcode (";","OH JOY auto increment with djnz (very fast)");
emitcode ("mov", "dps,#!constbyte",0x1); /* Select DPTR2 */
emitcode ("mov", "b,%s",aopGet(count,0,FALSE,FALSE,NULL));
emitcode (";","OH JOY auto increment with djnz (very fast)");
emitcode ("mov", "dps,#!constbyte",0x1); /* Select DPTR2 */
emitcode ("mov", "b,%s",aopGet(count,0,FALSE,FALSE,NULL));
emitcode (";","OH JOY auto increment with djnz (very fast)");
emitcode ("mov", "dps,#!constbyte",0x0); /* Select DPTR */
emitcode ("mov", "b,%s",aopGet(count,0,FALSE,FALSE,NULL));
emitcode (";","OH JOY auto increment with djnz (very fast)");
emitcode ("mov", "dps,#!constbyte",0x0); /* Select DPTR */
emitcode ("mov", "b,%s",aopGet(count,0,FALSE,FALSE,NULL));
l = aopGet(val, 0, FALSE, FALSE, NULL);
emitcode ("mov", "b,%s",aopGet(count,0,FALSE,FALSE,NULL));
MOVA(l);
l = aopGet(val, 0, FALSE, FALSE, NULL);
emitcode ("mov", "b,%s",aopGet(count,0,FALSE,FALSE,NULL));
MOVA(l);
- werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
- "genReceive got unexpected DPTR.");
+ werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ "genReceive got unexpected DPTR.");
- /* second receive onwards */
- /* this gets a little tricky since unused receives 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--)
+ /* second receive onwards */
+ /* this gets a little tricky since unused receives 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--)
- char *iLine = printILine(ic);
- emitcode("", ";ic:%d: %s", ic->key, iLine);
+ const char *iLine = printILine(ic);
+ emitcode(";", "ic:%d: %s", ic->key, iLine);
- /* IPOP happens only when trying to restore a
- spilt live range, if there is an ifx statement
- following this pop then the if statement might
- be using some of the registers being popped which
- would destory the contents of the register so
- we need to check for this condition and handle it */
- if (ic->next &&
- ic->next->op == IFX &&
- regsInCommon (IC_LEFT (ic), IC_COND (ic->next)))
- genIfx (ic->next, ic);
- else
- genIpop (ic);
+ {
+ iCode *ifxIc, *popIc;
+ bool CommonRegs = FALSE;
+
+ /* IPOP happens only when trying to restore a
+ spilt live range, if there is an ifx statement
+ following this pop (or several) then the if statement might
+ be using some of the registers being popped which
+ would destory the contents of the register so
+ we need to check for this condition and handle it */
+ for (ifxIc = ic->next; ifxIc && ifxIc->op == IPOP; ifxIc = ifxIc->next);
+ for (popIc = ic; popIc && popIc->op == IPOP; popIc = popIc->next)
+ CommonRegs |= (ifxIc && ifxIc->op == IFX && !ifxIc->generated &&
+ regsInCommon (IC_LEFT (popIc), IC_COND (ifxIc)));
+ if (CommonRegs)
+ genIfx (ifxIc, ic);
+ else
+ genIpop (ic);
+ }
- /* This should never happen, right? */
- fprintf(stderr, "*** Probable error: unsupported op 0x%x (%c) in %s @ %d\n",
- ic->op, ic->op, __FILE__, __LINE__);
- ic = ic;
- }
+ /* This should never happen, right? */
+ fprintf(stderr, "*** Probable error: unsupported op 0x%x (%c) in %s @ %d\n",
+ ic->op, ic->op, __FILE__, __LINE__);
+ ic = ic;
+ }