+2006-09-30 Maarten Brock <sourceforge.brock AT dse.nl>
+
+ * device/lib/libsdcc.lib: added module rand
+ * src/ds390/ralloc.c (rematStr),
+ * src/hc08/ralloc.c (rematStr),
+ * src/mcs51/ralloc.c (rematStr),
+ * src/z80/ralloc.c (rematStr): made output more consistent
+ * src/mcs51/gen.c: cosmetic changes
+
2006-09-30 Maarten Brock <sourceforge.brock AT dse.nl>
* src/port.h: added mem.cabs_name to PORT
_spx
abs
labs
+rand
_atoi
_atol
calloc
static char *
rematStr (symbol * sym)
{
- char *s = buffer;
iCode *ic = sym->rematiCode;
-
- *s = 0;
+ int offset = 0;
while (1)
{
+ /* if plus adjust offset to right hand side */
+ if (ic->op == '+')
+ {
+ offset += (int) operandLitValue (IC_RIGHT (ic));
+ ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
+ continue;
+ }
- /* if plus or minus print the right hand side */
- if (ic->op == '+' || ic->op == '-')
+ /* if minus adjust offset to right hand side */
+ if (ic->op == '-')
{
- SNPRINTF (s, sizeof(buffer) - strlen(buffer),
- "0x%04x %c ", (int) operandLitValue (IC_RIGHT (ic)),
- ic->op);
- s += strlen (s);
+ offset -= (int) operandLitValue (IC_RIGHT (ic));
ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
continue;
}
continue;
}
/* we reached the end */
- SNPRINTF (s, sizeof(buffer) - strlen(buffer),
- "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
break;
}
+ if (offset)
+ {
+ SNPRINTF (buffer, sizeof(buffer),
+ "(%s %c 0x%04x)",
+ OP_SYMBOL (IC_LEFT (ic))->rname,
+ offset >= 0 ? '+' : '-',
+ abs (offset) & 0xffff);
+ }
+ else
+ {
+ strncpyz (buffer, OP_SYMBOL (IC_LEFT (ic))->rname, sizeof(buffer));
+ }
return buffer;
}
static char *
rematStr (symbol * sym)
{
- char *s = buffer;
iCode *ic = sym->rematiCode;
-// int offset = 0;
+ int offset = 0;
while (1)
{
- /* if plus or minus print the right hand side */
- if (ic->op == '+' || ic->op == '-')
- {
- sprintf (s, "0x%04x %c ", (int) operandLitValue (IC_RIGHT (ic)),
- ic->op);
- s += strlen (s);
- ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
- continue;
- }
-
-/*
+ /* if plus adjust offset to right hand side */
if (ic->op == '+')
{
- offset += operandLitValue (IC_RIGHT (ic));
+ offset += (int) operandLitValue (IC_RIGHT (ic));
ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
continue;
}
+
+ /* if minus adjust offset to right hand side */
if (ic->op == '-')
{
- offset -= operandLitValue (IC_RIGHT (ic));
+ offset -= (int) operandLitValue (IC_RIGHT (ic));
ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
continue;
}
-*/
+
/* cast then continue */
if (IS_CAST_ICODE(ic)) {
ic = OP_SYMBOL (IC_RIGHT (ic))->rematiCode;
continue;
}
/* we reached the end */
- if (ic->op == ADDRESS_OF)
- sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
- else if (ic->op == '=')
- sprintf (s, "0x%04x", (int) operandLitValue (IC_RIGHT (ic)) );
break;
}
+ if (ic->op == ADDRESS_OF)
+ {
+ if (offset)
+ {
+ SNPRINTF (buffer, sizeof(buffer),
+ "(%s %c 0x%04x)",
+ OP_SYMBOL (IC_LEFT (ic))->rname,
+ offset >= 0 ? '+' : '-',
+ abs (offset) & 0xffff);
+ }
+ else
+ {
+ strncpyz (buffer, OP_SYMBOL (IC_LEFT (ic))->rname, sizeof(buffer));
+ }
+ }
+ else if (ic->op == '=')
+ {
+ offset += (int) operandLitValue (IC_RIGHT (ic));
+ SNPRINTF (buffer, sizeof(buffer),
+ "0x%04x",
+ offset & 0xffff);
+ }
return buffer;
}
/* rematerialize it NOW */
if (sym->remat)
{
- sym->aop = op->aop = aop =
- aopForRemat (sym);
+ sym->aop = op->aop = aop = aopForRemat (sym);
aop->size = getSize (sym->type);
return;
}
icount = (unsigned int) floatFromVal (AOP (IC_RIGHT (ic))->aopu.aop_lit);
- D(emitcode ("; genPlusIncr",""));
+ D(emitcode (";","genPlusIncr"));
/* if increment >=16 bits in register or direct space */
if (( AOP_TYPE(IC_LEFT(ic)) == AOP_REG ||
/* get the string representation of the name */
l = aopGet (left, 0, FALSE, TRUE);
+ l++; // remove #
size = AOP_SIZE (result);
while (size--)
{
if (offset)
{
- SNPRINTF (buffer, sizeof(buffer),
- "(%s + %d)", l + 1, offset);
+ SNPRINTF (buffer, sizeof(buffer), "(%s + %d)", l, offset);
}
else
{
- SNPRINTF (buffer, sizeof(buffer),
- "%s", l + 1);
+ SNPRINTF (buffer, sizeof(buffer), "%s", l);
}
aopPut (result, buffer, offset++);
}
aopOp (right, ic, FALSE);
l = aopGet (result, 0, FALSE, TRUE);
+ l++; //remove #
size = AOP_SIZE (right);
while (size--)
{
if (offset)
- SNPRINTF (buffer, sizeof(buffer), "(%s + %d)", l + 1, offset);
+ SNPRINTF (buffer, sizeof(buffer), "(%s + %d)", l, offset);
else
- SNPRINTF (buffer, sizeof(buffer), "%s", l + 1);
+ SNPRINTF (buffer, sizeof(buffer), "%s", l);
emitcode ("mov", "%s,%s", buffer,
aopGet (right, offset++, FALSE, FALSE));
}
static char *
rematStr (symbol * sym)
{
- char *s = buffer;
iCode *ic = sym->rematiCode;
-
- *s = 0;
+ int offset = 0;
while (1)
{
+ /* if plus adjust offset to right hand side */
+ if (ic->op == '+')
+ {
+ offset += (int) operandLitValue (IC_RIGHT (ic));
+ ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
+ continue;
+ }
- /* if plus or minus print the right hand side */
- if (ic->op == '+' || ic->op == '-')
+ /* if minus adjust offset to right hand side */
+ if (ic->op == '-')
{
- SNPRINTF (s, sizeof(buffer) - strlen(buffer),
- "0x%04x %c ", (int) operandLitValue (IC_RIGHT (ic)),
- ic->op);
- s += strlen (s);
+ offset -= (int) operandLitValue (IC_RIGHT (ic));
ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
continue;
}
continue;
}
/* we reached the end */
- SNPRINTF (s, sizeof(buffer) - strlen(buffer),
- "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
break;
}
+ if (offset)
+ {
+ SNPRINTF (buffer, sizeof(buffer),
+ "(%s %c 0x%04x)",
+ OP_SYMBOL (IC_LEFT (ic))->rname,
+ offset >= 0 ? '+' : '-',
+ abs (offset) & 0xffff);
+ }
+ else
+ {
+ strncpyz (buffer, OP_SYMBOL (IC_LEFT (ic))->rname, sizeof(buffer));
+ }
return buffer;
}
/** Returns the rematerialized string for a remat var.
*/
-char *
+static char *
rematStr (symbol * sym)
{
- char *s = buffer;
iCode *ic = sym->rematiCode;
+ int offset = 0;
while (1)
{
+ /* if plus adjust offset to right hand side */
+ if (ic->op == '+')
+ {
+ offset += (int) operandLitValue (IC_RIGHT (ic));
+ ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
+ continue;
+ }
- /* if plus or minus print the right hand side */
- if (ic->op == '+' || ic->op == '-')
+ /* if minus adjust offset to right hand side */
+ if (ic->op == '-')
{
- sprintf (s, "0x%04x %c ", (int) operandLitValue (IC_RIGHT (ic)),
- ic->op);
- s += strlen (s);
+ offset -= (int) operandLitValue (IC_RIGHT (ic));
ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
continue;
}
+
+ /* cast then continue */
+ if (IS_CAST_ICODE(ic)) {
+ ic = OP_SYMBOL (IC_RIGHT (ic))->rematiCode;
+ continue;
+ }
/* we reached the end */
- sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
break;
}
+ if (offset)
+ {
+ SNPRINTF (buffer, sizeof(buffer),
+ "(%s %c 0x%04x)",
+ OP_SYMBOL (IC_LEFT (ic))->rname,
+ offset >= 0 ? '+' : '-',
+ abs (offset) & 0xffff);
+ }
+ else
+ {
+ strncpyz (buffer, OP_SYMBOL (IC_LEFT (ic))->rname, sizeof(buffer));
+ }
return buffer;
}