static char *accUse[] =
{"a", "b"};
-static short rbank = -1;
+static unsigned short rbank = -1;
static struct
{
/* emitcode - writes the code into a file : for now it is simple */
/*-----------------------------------------------------------------*/
static void
-emitcode (char *inst, char *fmt,...)
+emitcode (char *inst, const char *fmt,...)
{
va_list ap;
char lb[INITIAL_INLINEASM];
/* mova - moves specified value into accumulator */
/*-----------------------------------------------------------------*/
static void
-mova (char *x)
+mova (const char *x)
{
/* do some early peephole optimization */
if (!strcmp(x, "a") || !strcmp(x, "acc"))
/* aopPut - puts a string for a aop */
/*-----------------------------------------------------------------*/
static void
-aopPut (asmop * aop, char *s, int offset)
+aopPut (asmop * aop, const char *s, int offset, bool bvolatile)
{
char *d = buffer;
else
sprintf (d, "%s", aop->aopu.aop_dir);
- if (strcmp (d, s))
+ if (strcmp (d, s) ||
+ bvolatile)
emitcode ("mov", "%s,%s", d, s);
break;
if (aop->code)
{
werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
- "aopPut writting to code space");
+ "aopPut writing to code space");
exit (1);
}
case AOP_STR:
aop->coff = offset;
- if (strcmp (aop->aopu.aop_str[offset], s))
+ if (strcmp (aop->aopu.aop_str[offset], s) ||
+ bvolatile)
emitcode ("mov", "%s,%s", aop->aopu.aop_str[offset], s);
break;
case AOP_ACC:
aop->coff = offset;
- if (!offset && (strcmp (s, "acc") == 0))
+ if (!offset && (strcmp (s, "acc") == 0) &&
+ !bvolatile)
break;
- if (strcmp (aop->aopu.aop_str[offset], s))
+ if (strcmp (aop->aopu.aop_str[offset], s) &&
+ !bvolatile)
emitcode ("mov", "%s,%s", aop->aopu.aop_str[offset], s);
break;
/* we will put 127 in the first byte of
the result */
- aopPut (AOP (res), "#127", 0);
+ aopPut (AOP (res), "#127", 0, isOperandVolatile (op, FALSE));
size = AOP_SIZE (op) - 1;
offset = 1;
}
tlbl = newiTempLabel (NULL);
- aopPut (res->aop, one, 1);
+ aopPut (res->aop, one, 1, isOperandVolatile (op, FALSE));
emitcode ("jz", "%05d$", (tlbl->key + 100));
- aopPut (res->aop, zero, 1);
+ aopPut (res->aop, zero, 1, isOperandVolatile (op, FALSE));
emitcode ("", "%05d$:", (tlbl->key + 100));
size = res->aop->size - 2;
offset = 2;
/* put zeros in the rest */
while (size--)
- aopPut (res->aop, zero, offset++);
+ aopPut (res->aop, zero, offset++, isOperandVolatile (op, FALSE));
}
/*-----------------------------------------------------------------*/
size = getDataSize (result);
if (size)
{
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
size--;
offset = 1;
/* unsigned or positive */
while (size--)
{
- aopPut (AOP (result), zero, offset++);
+ aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE));
}
}
}
{
/* if the result is bit */
if (AOP_TYPE (result) == AOP_CRY)
- aopPut (AOP (result), "c", 0);
+ aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE));
else
{
emitcode ("clr", "a");
char *l = aopGet (AOP (IC_LEFT (ic)), offset, FALSE, FALSE);
MOVA (l);
emitcode ("cpl", "a");
- aopPut (AOP (IC_RESULT (ic)), "a", offset++);
+ aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE));
}
{
aopPut (AOP (result),
aopGet (AOP (op), offset, FALSE, FALSE),
- offset);
+ offset,
+ isOperandVolatile (result, FALSE));
offset++;
}
MOVA (l);
emitcode ("cpl", "acc.7");
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
/*-----------------------------------------------------------------*/
emitcode ("clr", "a");
emitcode ("subb", "a,%s", l);
}
- aopPut (AOP (IC_RESULT (ic)), "a", offset++);
+ aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE));
}
/* if any remaining bytes in the result */
emitcode ("rlc", "a");
emitcode ("subb", "a,acc");
while (size--)
- aopPut (AOP (IC_RESULT (ic)), "a", offset++);
+ aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE));
}
release:
int size = AOP_SIZE (oper);
while (size--)
{
- aopPut (AOP (oper), fReturn[offset], offset);
+ aopPut (AOP (oper), fReturn[offset], offset, isOperandVolatile (oper, FALSE));
offset++;
}
}
{
MOVA (aopGet (AOP (IC_LEFT (ic)), 0, FALSE, FALSE));
emitcode ("add", "a,#0x%02x", ((char) icount) & 0xff);
- aopPut (AOP (IC_RESULT (ic)), "a", 0);
+ aopPut (AOP (IC_RESULT (ic)), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE));
}
else
{
/* if the result is a bit */
if (AOP_TYPE (result) == AOP_CRY)
{
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
}
else
{
!sameRegs (AOP (IC_RESULT (ic)), AOP (IC_LEFT (ic))))
aopPut (AOP (IC_RESULT (ic)),
aopGet (AOP (IC_LEFT (ic)), 2, FALSE, FALSE),
- 2);
+ 2,
+ isOperandVolatile (IC_RESULT (ic), FALSE));
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);
+ 2,
+ isOperandVolatile (IC_RESULT (ic), FALSE));
if (AOP_SIZE (IC_RESULT (ic)) == 3 &&
AOP_SIZE (IC_LEFT (ic)) < 3 &&
{
char buffer[5];
sprintf (buffer, "#%d", pointerCode (getSpec (operandType (IC_LEFT (ic)))));
- aopPut (AOP (IC_RESULT (ic)), buffer, 2);
+ aopPut (AOP (IC_RESULT (ic)), buffer, 2, isOperandVolatile (IC_RESULT (ic), FALSE));
}
}
#else
{
aopPut (AOP (IC_RESULT (ic)),
aopGet (AOP (IC_LEFT (ic)), GPTRSIZE - 1, FALSE, FALSE),
- GPTRSIZE - 1);
+ GPTRSIZE - 1,
+ isOperandVolatile (IC_RESULT (ic), FALSE));
}
if (opIsGptr (IC_RESULT (ic)) &&
{
aopPut (AOP (IC_RESULT (ic)),
aopGet (AOP (IC_RIGHT (ic)), GPTRSIZE - 1, FALSE, FALSE),
- GPTRSIZE - 1);
+ GPTRSIZE - 1,
+ isOperandVolatile (IC_RESULT (ic), FALSE));
}
if (opIsGptr (IC_RESULT (ic)) &&
{
char buffer[5];
sprintf (buffer, "#%d", pointerCode (getSpec (operandType (IC_LEFT (ic)))));
- aopPut (AOP (IC_RESULT (ic)), buffer, GPTRSIZE - 1);
+ aopPut (AOP (IC_RESULT (ic)), buffer, GPTRSIZE - 1, isOperandVolatile (IC_RESULT (ic), FALSE));
}
}
#endif
{
MOVA (aopGet (AOP (IC_RIGHT (ic)), offset, FALSE, FALSE));
emitcode ("addc", "a,#00");
- aopPut (AOP (IC_RESULT (ic)), "a", offset++);
+ aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE));
}
}
goto release;
MOVA (aopGet (rightOp, offset, FALSE, TRUE));
emitcode (add, "a,%s", aopGet (leftOp, offset, FALSE, TRUE));
}
- aopPut (AOP (IC_RESULT (ic)), "a", offset++);
+ aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE));
add = "addc"; /* further adds must propagate carry */
}
emitcode ("rlc", "a");
emitcode ("subb", "a,acc");
while (size--)
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
}
else
while (size--)
- aopPut (AOP (result), zero, offset++);
+ aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE));
}
}
emitcode ("jnb", "%s,%05d$", AOP (IC_LEFT (ic))->aopu.aop_dir, (lbl->key + 100));
emitcode ("inc", "a");
emitcode ("", "%05d$:", (lbl->key + 100));
- aopPut (AOP (IC_RESULT (ic)), "a", 0);
+ aopPut (AOP (IC_RESULT (ic)), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE));
addSign (IC_RESULT (ic), MSB16, SPEC_USIGN (getSpec (operandType (IC_RESULT (ic)))));
}
}
MOVA (aopGet (AOP (IC_LEFT (ic)), offset, FALSE, FALSE));
/* first add without previous c */
if (!offset) {
- if (!size && lit==-1) {
+ if (!size && lit== (unsigned long) -1) {
emitcode ("dec", "a");
} else {
- emitcode ("add", "a,#0x%02x",
+ emitcode ("add", "a,#0x%02x",
(unsigned int) (lit & 0x0FFL));
}
} else {
emitcode ("addc", "a,#0x%02x",
(unsigned int) ((lit >> (offset * 8)) & 0x0FFL));
}
- aopPut (AOP (IC_RESULT (ic)), "a", offset++);
+ aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE));
}
}
else
aopGet(rightOp, offset, FALSE, TRUE));
}
- aopPut (AOP (IC_RESULT (ic)), "a", offset++);
+ aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE));
}
}
if (size<1 || size>2) {
// this should never happen
- fprintf (stderr, "size!=1||2 (%d) in %s at line:%d \n",
+ fprintf (stderr, "size!=1||2 (%d) in %s at line:%d \n",
AOP_SIZE(result), __FILE__, lineno);
exit (1);
}
emitcode ("mov", "b,%s", aopGet (AOP (right), 0, FALSE, FALSE));
MOVA (aopGet (AOP (left), 0, FALSE, FALSE));
emitcode ("mul", "ab");
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
if (size==2) {
- aopPut (AOP (result), "b", 1);
+ aopPut (AOP (result), "b", 1, isOperandVolatile (result, FALSE));
}
return;
}
}
emitcode ("", "%05d$:", lbl->key+100);
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
if (size==2) {
- aopPut (AOP (result), "b", 1);
+ aopPut (AOP (result), "b", 1, isOperandVolatile (result, FALSE));
}
}
emitcode ("div", "ab");
emitcode ("rrc", "a");
- aopPut (AOP (result), "c", 0);
+ aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE));
}
/*-----------------------------------------------------------------*/
l = aopGet (AOP (left), 0, FALSE, FALSE);
MOVA (l);
emitcode ("div", "ab");
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
while (size--)
- aopPut (AOP (result), zero, offset++);
+ aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE));
return;
}
emitcode ("", "%05d$:", (lbl->key + 100));
/* now we are done */
- aopPut (AOP (result), "b", 0);
+ aopPut (AOP (result), "b", 0, isOperandVolatile (result, FALSE));
if (size > 0)
{
emitcode ("mov", "c,b.7");
emitcode ("subb", "a,acc");
}
while (size--)
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
}
emitcode ("div", "ab");
emitcode ("mov", "a,b");
emitcode ("rrc", "a");
- aopPut (AOP (result), "c", 0);
+ aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE));
}
/*-----------------------------------------------------------------*/
l = aopGet (AOP (left), 0, FALSE, FALSE);
MOVA (l);
emitcode ("div", "ab");
- aopPut (AOP (result), "b", 0);
+ aopPut (AOP (result), "b", 0, isOperandVolatile (result, FALSE));
return;
}
emitcode ("", "%05d$:", (lbl->key + 100));
/* now we are done */
- aopPut (AOP (result), "b", 0);
+ aopPut (AOP (result), "b", 0, isOperandVolatile (result, FALSE));
}
gencjne (left, right, newiTempLabel (NULL));
if (AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result))
{
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
goto release;
}
if (ifx)
if ((bytelit = (int) ((lit >> (offset * 8)) & 0x0FFL)) == 0x0FF)
continue;
else if (bytelit == 0)
- aopPut (AOP (result), zero, offset);
+ {
+ aopPut (AOP (result), zero, offset, isOperandVolatile (result, FALSE));
+ }
else if (IS_AOP_PREG (result))
{
MOVA (aopGet (AOP (right), offset, FALSE, FALSE));
emitcode ("anl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE));
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
else
emitcode ("anl", "%s,%s",
if (IS_AOP_PREG (result))
{
emitcode ("anl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE));
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
else
{
aopPut (AOP (result),
aopGet (AOP (left), offset, FALSE, FALSE),
- offset);
+ offset,
+ isOperandVolatile (result, FALSE));
continue;
}
else if (bytelit == 0)
{
- aopPut (AOP (result), zero, offset);
+ /* dummy read of volatile operand */
+ if (isOperandVolatile (left, FALSE))
+ MOVA (aopGet (AOP (left), offset, FALSE, FALSE));
+ aopPut (AOP (result), zero, offset, isOperandVolatile (result, FALSE));
continue;
}
}
emitcode ("anl", "a,%s",
aopGet (AOP (left), offset, FALSE, FALSE));
}
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
}
}
if (AOP_TYPE (right) == AOP_LIT)
{
if (((lit >> (offset * 8)) & 0x0FFL) == 0x00L)
- continue;
+ {
+ /* dummy read of volatile operand */
+ if (isOperandVolatile (left, FALSE))
+ MOVA (aopGet (AOP (left), offset, FALSE, FALSE));
+ else
+ continue;
+ }
else if (IS_AOP_PREG (left))
{
MOVA (aopGet (AOP (right), offset, FALSE, FALSE));
emitcode ("orl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE));
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
else
emitcode ("orl", "%s,%s",
if (IS_AOP_PREG (left))
{
emitcode ("orl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE));
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
else
emitcode ("orl", "%s,a",
{
aopPut (AOP (result),
aopGet (AOP (left), offset, FALSE, FALSE),
- offset);
+ offset,
+ isOperandVolatile (result, FALSE));
continue;
}
}
emitcode ("orl", "a,%s",
aopGet (AOP (left), offset, FALSE, FALSE));
}
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
}
{
MOVA (aopGet (AOP (right), offset, FALSE, FALSE));
emitcode ("xrl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE));
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
else
emitcode ("xrl", "%s,%s",
if (IS_AOP_PREG (left))
{
emitcode ("xrl", "a,%s", aopGet (AOP (left), offset, FALSE, TRUE));
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
else
emitcode ("xrl", "%s,a",
{
aopPut (AOP (result),
aopGet (AOP (left), offset, FALSE, FALSE),
- offset);
+ offset,
+ isOperandVolatile (result, FALSE));
continue;
}
}
emitcode ("xrl", "a,%s",
aopGet (AOP (left), offset, FALSE, TRUE));
}
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
}
MOVA (l);
emitcode ("rrc", "a");
if (AOP_SIZE (result) > 1)
- aopPut (AOP (result), "a", offset--);
+ aopPut (AOP (result), "a", offset--, isOperandVolatile (result, FALSE));
}
/* now we need to put the carry into the
highest order byte of the result */
}
emitcode ("mov", "acc.7,c");
release:
- aopPut (AOP (result), "a", AOP_SIZE (result) - 1);
+ aopPut (AOP (result), "a", AOP_SIZE (result) - 1, isOperandVolatile (result, FALSE));
freeAsmop (left, NULL, ic, TRUE);
freeAsmop (result, NULL, ic, TRUE);
}
}
emitcode ("add", "a,acc");
if (AOP_SIZE (result) > 1)
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
while (size--)
{
l = aopGet (AOP (left), offset, FALSE, FALSE);
MOVA (l);
emitcode ("rlc", "a");
if (AOP_SIZE (result) > 1)
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
}
}
/* now we need to put the carry into the
}
emitcode ("mov", "acc.0,c");
release:
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
freeAsmop (left, NULL, ic, TRUE);
freeAsmop (result, NULL, ic, TRUE);
}
AccSRsh (shCount);
else
AccRsh (shCount);
- aopPut (AOP (result), "a", offr);
+ aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE));
}
/*-----------------------------------------------------------------*/
MOVA (l);
/* shift left accumulator */
AccLsh (shCount);
- aopPut (AOP (result), "a", offr);
+ aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE));
}
/*-----------------------------------------------------------------*/
if (*l == '@' && (IS_AOP_PREG (result)))
{
emitcode ("mov", "a,%s", l);
- aopPut (AOP (result), "a", offr);
+ aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE));
}
else
{
if (!sign)
- aopPut (AOP (result), l, offr);
+ aopPut (AOP (result), l, offr, isOperandVolatile (result, FALSE));
else
{
/* MSB sign in acc.7 ! */
if (getDataSize (left) == offl + 1)
{
emitcode ("mov", "a,%s", l);
- aopPut (AOP (result), "a", offr);
+ aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE));
}
}
}
}
/* ax << shCount (x = lsb(result)) */
AccAXLsh (aopGet (AOP (result), offr, FALSE, FALSE), shCount);
- aopPut (AOP (result), "a", offr + MSB16);
+ aopPut (AOP (result), "a", offr + MSB16, isOperandVolatile (result, FALSE));
}
else
AccAXRsh (aopGet (AOP (result), offr, FALSE, FALSE), shCount);
if (getDataSize (result) > 1)
- aopPut (AOP (result), "a", offr + MSB16);
+ aopPut (AOP (result), "a", offr + MSB16, isOperandVolatile (result, FALSE));
}
/*-----------------------------------------------------------------*/
/* or with result */
emitcode ("orl", "a,%s", aopGet (AOP (result), offr, FALSE, FALSE));
/* back to result */
- aopPut (AOP (result), "a", offr);
+ aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE));
}
/*-----------------------------------------------------------------*/
/* or with result */
emitcode ("orl", "a,%s", aopGet (AOP (result), offr, FALSE, FALSE));
/* back to result */
- aopPut (AOP (result), "a", offr);
+ aopPut (AOP (result), "a", offr, isOperandVolatile (result, FALSE));
}
/*-----------------------------------------------------------------*/
else
movLeft2Result (left, LSB, result, MSB16, 0);
}
- aopPut (AOP (result), zero, LSB);
+ aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE));
}
/* 1 <= shCount <= 7 */
emitcode ("xch", "a,%s",
aopGet (AOP (left), LSB + offr, FALSE, FALSE));
else
- aopPut (AOP (result), "a", LSB + offr);
+ aopPut (AOP (result), "a", LSB + offr, isOperandVolatile (result, FALSE));
}
if (size >= MSB16 + offr)
emitcode ("xch", "a,%s",
aopGet (AOP (left), MSB16 + offr, FALSE, FALSE));
else
- aopPut (AOP (result), "a", MSB16 + offr);
+ aopPut (AOP (result), "a", MSB16 + offr, isOperandVolatile (result, FALSE));
}
if (size >= MSB24 + offr)
emitcode ("xch", "a,%s",
aopGet (AOP (left), MSB24 + offr, FALSE, FALSE));
else
- aopPut (AOP (result), "a", MSB24 + offr);
+ aopPut (AOP (result), "a", MSB24 + offr, isOperandVolatile (result, FALSE));
}
if (size > MSB32 + offr)
MOVA (l);
}
emitcode ("rlc", "a");
- aopPut (AOP (result), "a", MSB32 + offr);
+ aopPut (AOP (result), "a", MSB32 + offr, isOperandVolatile (result, FALSE));
}
if (offr != LSB)
- aopPut (AOP (result), zero, LSB);
+ aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE));
}
/*-----------------------------------------------------------------*/
shiftL1Left2Result (left, LSB, result, MSB32, shCount);
else
movLeft2Result (left, LSB, result, MSB32, 0);
- aopPut (AOP (result), zero, LSB);
- aopPut (AOP (result), zero, MSB16);
- aopPut (AOP (result), zero, MSB24);
+ aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE));
+ aopPut (AOP (result), zero, MSB16, isOperandVolatile (result, FALSE));
+ aopPut (AOP (result), zero, MSB24, isOperandVolatile (result, FALSE));
return;
}
movLeft2Result (left, MSB16, result, MSB32, 0);
movLeft2Result (left, LSB, result, MSB24, 0);
}
- aopPut (AOP (result), zero, MSB16);
- aopPut (AOP (result), zero, LSB);
+ aopPut (AOP (result), zero, MSB16, isOperandVolatile (result, FALSE));
+ aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE));
return;
}
movLeft2Result (left, MSB24, result, MSB32, 0);
movLeft2Result (left, MSB16, result, MSB24, 0);
movLeft2Result (left, LSB, result, MSB16, 0);
- aopPut (AOP (result), zero, LSB);
+ aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE));
}
else if (shCount == 1)
shiftLLong (left, result, MSB16);
shiftL2Left2Result (left, MSB16, result, MSB24, shCount);
shiftL1Left2Result (left, LSB, result, MSB16, shCount);
shiftRLeftOrResult (left, LSB, result, MSB24, 8 - shCount);
- aopPut (AOP (result), zero, LSB);
+ aopPut (AOP (result), zero, LSB, isOperandVolatile (result, FALSE));
}
}
}
else if (shCount >= (size * 8))
while (size--)
- aopPut (AOP (result), zero, size);
+ aopPut (AOP (result), zero, size, isOperandVolatile (result, FALSE));
else
{
switch (size)
{
emitcode ("mov", "a,%s", l);
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
else
- aopPut (AOP (result), l, offset);
+ aopPut (AOP (result), l, offset, isOperandVolatile (result, FALSE));
offset++;
}
}
emitcode ("add", "a,acc");
emitcode ("", "%05d$:", tlbl1->key + 100);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
goto release;
}
l = aopGet (AOP (result), offset, FALSE, FALSE);
MOVA (l);
emitcode ("add", "a,acc");
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
while (--size)
{
l = aopGet (AOP (result), offset, FALSE, FALSE);
MOVA (l);
emitcode ("rlc", "a");
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
}
reAdjustPreg (AOP (result));
if (isSameRegs)
emitcode ("xch", "a,%s", aopGet(AOP(left), MSB32, FALSE, FALSE));
else {
- aopPut (AOP (result), "a", MSB32);
+ aopPut (AOP (result), "a", MSB32, isOperandVolatile (result, FALSE));
MOVA (aopGet (AOP (left), MSB32, FALSE, FALSE));
}
} else {
- aopPut (AOP(result), zero, MSB32);
+ aopPut (AOP(result), zero, MSB32, isOperandVolatile (result, FALSE));
}
}
if (isSameRegs && offl==MSB16) {
emitcode ("xch", "a,%s",aopGet (AOP (left), MSB24, FALSE, FALSE));
} else {
- aopPut (AOP (result), "a", MSB32-offl);
+ aopPut (AOP (result), "a", MSB32-offl, isOperandVolatile (result, FALSE));
MOVA (aopGet (AOP (left), MSB24, FALSE, FALSE));
}
if (isSameRegs && offl==1) {
emitcode ("xch", "a,%s",aopGet (AOP (left), MSB16, FALSE, FALSE));
} else {
- aopPut (AOP (result), "a", MSB24-offl);
+ aopPut (AOP (result), "a", MSB24-offl, isOperandVolatile (result, FALSE));
MOVA (aopGet (AOP (left), MSB16, FALSE, FALSE));
}
emitcode ("rrc", "a");
- aopPut (AOP (result), "a", MSB16 - offl);
+ aopPut (AOP (result), "a", MSB16 - offl, isOperandVolatile (result, FALSE));
if (offl == LSB)
{
MOVA (aopGet (AOP (left), LSB, FALSE, FALSE));
emitcode ("rrc", "a");
- aopPut (AOP (result), "a", LSB);
+ aopPut (AOP (result), "a", LSB, isOperandVolatile (result, FALSE));
}
}
{
emitcode ("mov", "a,%s", l);
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
else
- aopPut (AOP (result), l, offset);
+ aopPut (AOP (result), l, offset, isOperandVolatile (result, FALSE));
offset++;
}
}
emitcode ("rrc", "a");
emitcode ("", "%05d$:", tlbl1->key + 100);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
goto release;
}
l = aopGet (AOP (result), offset, FALSE, FALSE);
MOVA (l);
emitcode ("rrc", "a");
- aopPut (AOP (result), "a", offset--);
+ aopPut (AOP (result), "a", offset--, isOperandVolatile (result, FALSE));
}
reAdjustPreg (AOP (result));
emitcode ("", "%05d$:", tlbl1->key + 100);
{
emitcode ("mov", "a,%s", l);
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
else
- aopPut (AOP (result), l, offset);
+ aopPut (AOP (result), l, offset, isOperandVolatile (result, FALSE));
offset++;
}
}
emitcode ("rrc", "a");
emitcode ("", "%05d$:", tlbl1->key + 100);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
goto release;
}
l = aopGet (AOP (result), offset, FALSE, FALSE);
MOVA (l);
emitcode ("rrc", "a");
- aopPut (AOP (result), "a", offset--);
+ aopPut (AOP (result), "a", offset--, isOperandVolatile (result, FALSE));
}
reAdjustPreg (AOP (result));
emitcode ("anl", "a,#0x%02x",
((unsigned char) -1) >> (8 - SPEC_BLEN (etype)));
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
goto finish;
}
/* bit field did not fit in a byte */
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
while (1)
{
if (rlen < 8)
break;
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
}
{
// emitcode("anl","a,#0x%02x",((unsigned char)-1)>>(rlen));
AccLsh (8 - rlen);
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
}
finish:
{
rsize -= offset;
while (rsize--)
- aopPut (AOP (result), zero, offset++);
+ aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE));
}
return;
}
sprintf (buffer, "(%s + %d)", l + 1, offset);
else
sprintf (buffer, "%s", l + 1);
- aopPut (AOP (result), buffer, offset++);
+ aopPut (AOP (result), buffer, offset++, isOperandVolatile (result, FALSE));
}
freeAsmop (left, NULL, ic, TRUE);
{
emitcode ("mov", "a,@%s", rname);
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
}
else
{
sprintf (buffer, "@%s", rname);
- aopPut (AOP (result), buffer, offset);
+ aopPut (AOP (result), buffer, offset, isOperandVolatile (result, FALSE));
}
offset++;
if (size || pi)
if (aop) /* we had to allocate for this iCode */
{
if (pi) { /* post increment present */
- aopPut(AOP ( left ),rname,0);
+ aopPut(AOP ( left ),rname,0, isOperandVolatile (left, FALSE));
}
freeAsmop (NULL, aop, ic, TRUE);
}
{
emitcode ("movx", "a,@%s", rname);
- aopPut (AOP (result), "a", offset);
+ aopPut (AOP (result), "a", offset, isOperandVolatile (result, FALSE));
offset++;
/* now some housekeeping stuff */
if (aop) /* we had to allocate for this iCode */
{
- if (pi) aopPut ( AOP (left), rname, 0);
+ if (pi) aopPut ( AOP (left), rname, 0, isOperandVolatile (left, FALSE));
freeAsmop (NULL, aop, ic, TRUE);
}
else
while (size--)
{
emitcode ("movx", "a,@dptr");
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
if (size || pi)
emitcode ("inc", "dptr");
}
}
if (pi && AOP_TYPE (left) != AOP_IMMD && AOP_TYPE (left) != AOP_STR) {
- aopPut ( AOP (left), "dpl", 0);
- aopPut ( AOP (left), "dph", 1);
+ aopPut ( AOP (left), "dpl", 0, isOperandVolatile (left, FALSE));
+ aopPut ( AOP (left), "dph", 1, isOperandVolatile (left, FALSE));
pi->generated = 1;
}
freeAsmop (left, NULL, ic, TRUE);
{
emitcode ("clr", "a");
emitcode ("movc", "a,@a+dptr");
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
emitcode ("inc", "dptr");
}
else
{
emitcode ("mov", "a,#0x%02x", offset);
emitcode ("movc", "a,@a+dptr");
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
}
}
}
if (pi && AOP_TYPE (left) != AOP_IMMD && AOP_TYPE (left) != AOP_STR) {
- aopPut ( AOP (left), "dpl", 0);
- aopPut ( AOP (left), "dph", 1);
+ aopPut ( AOP (left), "dpl", 0, isOperandVolatile (left, FALSE));
+ aopPut ( AOP (left), "dph", 1, isOperandVolatile (left, FALSE));
pi->generated = 1;
}
freeAsmop (left, NULL, ic, TRUE);
while (size--)
{
emitcode ("lcall", "__gptrget");
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
if (size || pi)
emitcode ("inc", "dptr");
}
}
if (pi && AOP_TYPE (left) != AOP_IMMD && AOP_TYPE (left) != AOP_STR) {
- aopPut ( AOP (left), "dpl", 0);
- aopPut ( AOP (left), "dph", 1);
+ aopPut ( AOP (left), "dpl", 0, isOperandVolatile (left, FALSE));
+ aopPut ( AOP (left), "dph", 1, isOperandVolatile (left, FALSE));
+ aopPut ( AOP (left), "b", 2, isOperandVolatile (left, FALSE));
pi->generated = 1;
}
freeAsmop (left, NULL, ic, TRUE);
/* now some housekeeping stuff */
if (aop) /* we had to allocate for this iCode */
{
- if (pi) aopPut (AOP (result),rname,0);
+ if (pi)
+ aopPut (AOP (result), rname, 0, isOperandVolatile (result, FALSE));
freeAsmop (NULL, aop, ic, TRUE);
}
else
/* now some housekeeping stuff */
if (aop) /* we had to allocate for this iCode */
{
- if (pi) aopPut (AOP (result),rname,0);
+ if (pi)
+ aopPut (AOP (result), rname, 0, isOperandVolatile (result, FALSE));
freeAsmop (NULL, aop, ic, TRUE);
}
else
}
}
if (pi && AOP_TYPE (result) != AOP_STR && AOP_TYPE (result) != AOP_IMMD) {
- aopPut (AOP(result),"dpl",0);
- aopPut (AOP(result),"dph",1);
+ aopPut (AOP(result), "dpl", 0, isOperandVolatile (result, FALSE));
+ aopPut (AOP(result), "dph", 1, isOperandVolatile (result, FALSE));
pi->generated=1;
}
freeAsmop (result, NULL, ic, TRUE);
}
if (pi && AOP_TYPE (result) != AOP_STR && AOP_TYPE (result) != AOP_IMMD) {
- aopPut (AOP(result),"dpl",0);
- aopPut (AOP(result),"dph",1);
+ aopPut (AOP(result), "dpl", 0, isOperandVolatile (result, FALSE));
+ aopPut (AOP(result), "dph", 1, isOperandVolatile (result, FALSE));
+ aopPut (AOP(result), "b", 2, isOperandVolatile (result, FALSE));
pi->generated=1;
}
freeAsmop (result, NULL, ic, TRUE);
emitcode ("add", "a,#0x%02x", ((sym->stack < 0) ?
((char) (sym->stack - _G.nRegsSaved)) :
((char) sym->stack)) & 0xff);
- aopPut (AOP (IC_RESULT (ic)), "a", 0);
+ aopPut (AOP (IC_RESULT (ic)), "a", 0, isOperandVolatile (IC_RESULT (ic), FALSE));
}
else
{
/* we can just move _bp */
- aopPut (AOP (IC_RESULT (ic)), "_bp", 0);
+ aopPut (AOP (IC_RESULT (ic)), "_bp", 0, isOperandVolatile (IC_RESULT (ic), FALSE));
}
/* fill the result with zero */
size = AOP_SIZE (IC_RESULT (ic)) - 1;
offset = 1;
while (size--)
{
- aopPut (AOP (IC_RESULT (ic)), zero, offset++);
+ aopPut (AOP (IC_RESULT (ic)), zero, offset++, isOperandVolatile (IC_RESULT (ic), FALSE));
}
goto release;
offset * 8);
else
sprintf (s, "#%s", sym->rname);
- aopPut (AOP (IC_RESULT (ic)), s, offset++);
+ aopPut (AOP (IC_RESULT (ic)), s, offset++, isOperandVolatile (IC_RESULT (ic), FALSE));
}
release:
while (size--)
{
emitcode ("pop", "acc");
- aopPut (AOP (result), "a", --offset);
+ aopPut (AOP (result), "a", --offset, isOperandVolatile (result, FALSE));
}
freeAsmop (result, NULL, ic, FALSE);
right = IC_RIGHT (ic);
/* if they are the same */
- if (operandsEqu (result, right)) {
+ if (operandsEqu (result, right) &&
+ !isOperandVolatile (result, FALSE) &&
+ !isOperandVolatile (right, FALSE))
return;
- }
aopOp (right, ic, FALSE);
aopOp (result, ic, TRUE);
/* if they are the same registers */
- if (sameRegs (AOP (right), AOP (result)))
+ if (sameRegs (AOP (right), AOP (result)) &&
+ !isOperandVolatile (result, FALSE) &&
+ !isOperandVolatile (right, FALSE))
goto release;
/* if the result is a bit */
if (AOP_TYPE (right) == AOP_LIT)
{
if (((int) operandLitValue (right)))
- aopPut (AOP (result), one, 0);
+ aopPut (AOP (result), one, 0, isOperandVolatile (result, FALSE));
else
- aopPut (AOP (result), zero, 0);
+ aopPut (AOP (result), zero, 0, isOperandVolatile (result, FALSE));
goto release;
}
if (AOP_TYPE (right) == AOP_CRY)
{
emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir);
- aopPut (AOP (result), "c", 0);
+ aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE));
goto release;
}
/* we need to or */
toBoolean (right);
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
goto release;
}
while (size--)
{
if ((unsigned int) ((lit >> (size * 8)) & 0x0FFL) == 0)
- aopPut (AOP (result), "a", size);
+ aopPut (AOP (result), "a", size, isOperandVolatile (result, FALSE));
else
aopPut (AOP (result),
aopGet (AOP (right), size, FALSE, FALSE),
- size);
+ size,
+ isOperandVolatile (result, FALSE));
}
}
else
{
aopPut (AOP (result),
aopGet (AOP (right), offset, FALSE, FALSE),
- offset);
+ offset,
+ isOperandVolatile (result, FALSE));
offset++;
}
}
if (AOP_TYPE (right) == AOP_LIT)
{
if (((int) operandLitValue (right)))
- aopPut (AOP (result), one, 0);
+ aopPut (AOP (result), one, 0, isOperandVolatile (result, FALSE));
else
- aopPut (AOP (result), zero, 0);
+ aopPut (AOP (result), zero, 0, isOperandVolatile (result, FALSE));
goto release;
}
if (AOP_TYPE (right) == AOP_CRY)
{
emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir);
- aopPut (AOP (result), "c", 0);
+ aopPut (AOP (result), "c", 0, isOperandVolatile (result, FALSE));
goto release;
}
/* we need to or */
toBoolean (right);
- aopPut (AOP (result), "a", 0);
+ aopPut (AOP (result), "a", 0, isOperandVolatile (result, FALSE));
goto release;
}
{
aopPut (AOP (result),
aopGet (AOP (right), offset, FALSE, FALSE),
- offset);
+ offset,
+ isOperandVolatile (result, FALSE));
offset++;
}
goto release;
{
aopPut (AOP (result),
aopGet (AOP (right), offset, FALSE, FALSE),
- offset);
+ offset,
+ isOperandVolatile (result, FALSE));
offset++;
}
/* the last byte depending on type */
}
sprintf(gpValStr, "#0x%d", gpVal);
- aopPut (AOP (result), gpValStr, GPTRSIZE - 1);
+ aopPut (AOP (result), gpValStr, GPTRSIZE - 1, isOperandVolatile (result, FALSE));
}
goto release;
}
{
aopPut (AOP (result),
aopGet (AOP (right), offset, FALSE, FALSE),
- offset);
+ offset,
+ isOperandVolatile (result, FALSE));
offset++;
}
goto release;
{
aopPut (AOP (result),
aopGet (AOP (right), offset, FALSE, FALSE),
- offset);
+ offset,
+ isOperandVolatile (result, FALSE));
offset++;
}
if (!IS_SPEC (rtype) || SPEC_USIGN (rtype) || AOP_TYPE(right)==AOP_CRY)
{
while (size--)
- aopPut (AOP (result), zero, offset++);
+ aopPut (AOP (result), zero, offset++, isOperandVolatile (result, FALSE));
}
else
{
emitcode ("rlc", "a");
emitcode ("subb", "a,acc");
while (size--)
- aopPut (AOP (result), "a", offset++);
+ aopPut (AOP (result), "a", offset++, isOperandVolatile (result, FALSE));
}
/* we are done hurray !!!! */
return 0;
}
emitcode ("dec", "%s", rByte);
- aopPut(AOP(IC_RESULT(ic)), rByte, 0);
+ aopPut(AOP(IC_RESULT(ic)), rByte, 0, isOperandVolatile (IC_RESULT (ic), FALSE));
emitcode ("jnz", "%05d$", lbl->key + 100);
}
else if (IS_AOP_PREG (IC_RESULT (ic)))
if (isOperandInFarSpace (IC_RESULT (ic)) &&
(OP_SYMBOL (IC_RESULT (ic))->isspilt ||
IS_TRUE_SYMOP (IC_RESULT (ic)))) {
-
+
offset = fReturnSizeMCS51 - size;
while (size--) {
emitcode ("push", "%s", (strcmp (fReturn[fReturnSizeMCS51 - offset - 1], "a") ?
offset = 0;
while (size--) {
emitcode ("pop", "acc");
- aopPut (AOP (IC_RESULT (ic)), "a", offset++);
+ aopPut (AOP (IC_RESULT (ic)), "a", offset++, isOperandVolatile (IC_RESULT (ic), FALSE));
}
-
+
} else {
_G.accInUse++;
aopOp (IC_RESULT (ic), ic, FALSE);
aopOp (IC_RESULT (ic), ic, FALSE);
rb1off = ic->argreg;
while (size--) {
- aopPut (AOP (IC_RESULT (ic)), rb1regs[rb1off++ -5], offset++);
+ aopPut (AOP (IC_RESULT (ic)), rb1regs[rb1off++ -5], offset++, isOperandVolatile (IC_RESULT (ic), FALSE));
}
}
freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
}
+/*-----------------------------------------------------------------*/
+/* genDummyRead - generate code for dummy read of volatiles */
+/*-----------------------------------------------------------------*/
+static void
+genDummyRead (iCode * ic)
+{
+ operand *right;
+ int size, offset;
+
+ D(emitcode("; genDummyRead",""));
+
+ right = IC_RIGHT (ic);
+
+ aopOp (right, ic, FALSE);
+
+ /* if the result is a bit */
+ if (AOP_TYPE (right) == AOP_CRY)
+ {
+ emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir);
+ goto release;
+ }
+
+ /* bit variables done */
+ /* general case */
+ size = AOP_SIZE (right);
+ offset = 0;
+ while (size--)
+ {
+ emitcode ("mov", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE));
+ offset++;
+ }
+
+release:
+ freeAsmop (right, NULL, ic, TRUE);
+}
+
/*-----------------------------------------------------------------*/
/* gen51Code - generate code for 8051 based controllers */
/*-----------------------------------------------------------------*/
addSet (&_G.sendSet, ic);
break;
+ case DUMMY_READ_VOLATILE:
+ genDummyRead (ic);
+ break;
+
default:
ic = ic;
}