static int
opIsGptr (operand * op)
{
- sym_link *type = operandType (op);
-
- if ((AOP_SIZE (op) == GPTRSIZE) && IS_GENPTR (type))
+ if (op && IS_GENPTR (operandType (op)) && (AOP_SIZE (op) == GPTRSIZE))
{
return 1;
}
static int
getDataSize (operand * op)
{
- int size;
- size = AOP_SIZE (op);
+ int size = AOP_SIZE (op);
+
if (size == GPTRSIZE)
{
sym_link *type = operandType (op);
/*-----------------------------------------------------------------*/
-/* pushSide - */
+/* pushSide - */
/*-----------------------------------------------------------------*/
static void
-pushSide (operand * oper, int size)
+pushSide (operand * oper, int size, iCode * ic)
{
int offset = 0;
+ 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;
+ }
+
_startLazyDPSEvaluation ();
while (size--)
{
}
}
_endLazyDPSEvaluation ();
+ freeAsmop (oper, NULL, ic, TRUE);
}
/*-----------------------------------------------------------------*/
emitcode ("push", "acc");
}
- /* now push the calling address */
- aopOp (IC_LEFT (ic), ic, FALSE, FALSE);
+ /* now push the function address */
+ pushSide (IC_LEFT (ic), FPTRSIZE, ic);
- pushSide (IC_LEFT (ic), FPTRSIZE);
-
- freeAsmop (IC_LEFT (ic), NULL, ic, TRUE);
-
- /* if send set is not empty the assign */
+ /* if send set is not empty then assign */
if (_G.sendSet)
{
genSend(reverseSet(_G.sendSet));
}
if (opIsGptr (IC_RESULT (ic)) &&
- AOP_SIZE (IC_LEFT (ic)) < GPTRSIZE &&
- AOP_SIZE (IC_RIGHT (ic)) < GPTRSIZE &&
+ IC_LEFT (ic) && AOP_SIZE (IC_LEFT (ic)) < GPTRSIZE &&
+ IC_RIGHT (ic) && AOP_SIZE (IC_RIGHT (ic)) < GPTRSIZE &&
!sameRegs (AOP (IC_RESULT (ic)), AOP (IC_LEFT (ic))) &&
!sameRegs (AOP (IC_RESULT (ic)), AOP (IC_RIGHT (ic))))
{
}
/* object not on stack then we need the name */
- size = AOP_SIZE (IC_RESULT (ic));
+ size = getDataSize (IC_RESULT (ic));
offset = 0;
while (size--)
{
char s[SDCC_NAME_MAX];
- if (offset) {
+ if (offset)
+ {
switch (offset) {
case 1:
tsprintf(s, sizeof(s), "#!his",sym->rname);
tsprintf(s, sizeof(s), "#!hihihis",sym->rname);
break;
default: /* should not need this (just in case) */
- SNPRINTF (s, sizeof(s), "#(%s >> %d)",
- sym->rname,
- offset * 8);
+ SNPRINTF (s, sizeof(s), "#(%s >> %d)", sym->rname, offset * 8);
}
}
else
aopPut (IC_RESULT (ic), s, offset++);
}
+ 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);
+ }
release:
freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
/* bit variables done */
/* general case */
- size = AOP_SIZE (result);
+ size = getDataSize (result);
offset = 0;
if (AOP_TYPE (right) == AOP_LIT)
lit = ulFromVal (AOP (right)->aopu.aop_lit);
}
_endLazyDPSEvaluation ();
}
+ adjustArithmeticResult (ic);
release:
freeAsmop (result, NULL, ic, TRUE);
cln = ic->lineno;
}
if (options.iCodeInAsm) {
- char *iLine = printILine(ic);
+ const char *iLine = printILine(ic);
emitcode(";", "ic:%d: %s", ic->key, iLine);
dbuf_free(iLine);
}
default:
/* This should never happen, right? */
- fprintf(stderr, "*** Probable error: unsupported op 0x%x (%c) in %s @ %d\n",
+ fprintf(stderr, "*** Probable error: unsupported op 0x%x (%c) in %s @ %d\n",
ic->op, ic->op, __FILE__, __LINE__);
ic = ic;
}