#define AOP_TYPE(op) AOP(op)->type
#define AOP_SIZE(op) AOP(op)->size
#define IS_AOP_PREG(x) (AOP(x) && (AOP_TYPE(x) == AOP_R1 || \
- AOP_TYPE(x) == AOP_R0))
+ AOP_TYPE(x) == AOP_R0))
#define AOP_NEEDSACC(x) (AOP(x) && (AOP_TYPE(x) == AOP_CRY || \
- AOP_TYPE(x) == AOP_DPTR || \
- AOP(x)->paged))
+ AOP_TYPE(x) == AOP_DPTR || \
+ AOP(x)->paged))
#define AOP_INPREG(x) (x && (x->type == AOP_REG && \
(x->aopu.aop_reg[0] == REG_WITH_INDEX(R0_IDX) || \
/* set immd2 field if required */
if (aop->aopu.aop_immd.from_cast_remat)
{
- sprintf(buffer,"#0x%02x",ptr_type);
+ SNPRINTF (buffer, sizeof(buffer), "#0x%02x", ptr_type);
aop->aopu.aop_immd.aop_immd2 = Safe_strdup(buffer);
}
emitcode ("mov", "r1,b");
R1INB--;
}
- if (_G.r1Pushed)
+ else if (_G.r1Pushed)
{
if (pop)
{
emitcode ("pop", "ar1");
_G.r1Pushed--;
}
-
if (_G.r0Pushed)
{
emitcode ("pop", "ar0");
{
SNPRINTF (buffer, sizeof(buffer),
"(%s + %d)",
- aop->aopu.aop_dir,
- offset);
+ aop->aopu.aop_dir,
+ offset);
}
else
{
if (ic->regsSaved)
return;
if (IS_SYMOP(IC_LEFT(ic)) &&
- (IFFUNC_CALLEESAVES(OP_SYMBOL(IC_LEFT(ic))->type) ||
- IFFUNC_ISNAKED(OP_SYM_TYPE(IC_LEFT (ic)))))
+ (IFFUNC_CALLEESAVES (OP_SYMBOL (IC_LEFT (ic))->type) ||
+ IFFUNC_ISNAKED (OP_SYM_TYPE (IC_LEFT (ic)))))
return;
/* save the registers in use at this time but skip the
if (options.useXstack)
{
if (!ic)
- {
+ {
/* Assume r0 is available for use. */
r = REG_WITH_INDEX (R0_IDX);;
- }
+ }
else
- {
+ {
aop = newAsmop (0);
r = getFreePtr (ic, &aop, FALSE);
- }
+ }
// allocate space first
emitcode ("mov", "%s,%s", r->name, spname);
MOVA (r->name);
emitcode ("mov", "c,%s", AOP (IC_LEFT (ic))->aopu.aop_dir);
emitcode ("rlc", "a");
emitcode ("mov", "c,%s", AOP (IC_RIGHT (ic))->aopu.aop_dir);
- emitcode ("addc", "a,#0x00");
+ emitcode ("addc", "a,%s", zero);
outAcc (IC_RESULT (ic));
}
}
!sameRegs (AOP (IC_RESULT (ic)), AOP (IC_RIGHT (ic))))
{
char buffer[5];
- sprintf (buffer, "#%d", pointerTypeToGPByte (pointerCode (getSpec (operandType (IC_LEFT (ic)))), NULL, NULL));
+ SNPRINTF (buffer, sizeof(buffer),
+ "#%d", pointerTypeToGPByte (pointerCode (getSpec (operandType (IC_LEFT (ic)))), NULL, NULL));
aopPut (IC_RESULT (ic), buffer, GPTRSIZE - 1);
}
}
while (size--)
{
MOVA (aopGet (IC_RIGHT (ic), offset, FALSE, FALSE));
- emitcode ("addc", "a,#00");
+ emitcode ("addc", "a,%s", zero);
aopPut (IC_RESULT (ic), "a", offset++);
}
}
{
if (useCarry || ((lit >> (offset * 8)) & 0x0FFL))
{
- MOVA (aopGet (IC_LEFT (ic), offset, FALSE, FALSE));
+ MOVA (aopGet (IC_LEFT (ic), offset, FALSE, FALSE));
if (!offset && !size && lit== (unsigned long) -1)
{
emitcode ("dec", "a");
/* reverse subtraction with 2's complement */
if (offset == 0)
emitcode( "setb", "c");
- else
+ else
emitcode( "cpl", "c");
wassertl(!aopGetUsesAcc(leftOp, offset), "accumulator clash");
MOVA (aopGet(rightOp, offset, FALSE, TRUE));
}
goto release;
}
+ else
+ {//nonzero literal
+ int bytelit = ((lit >> (offset * 8)) & 0x0FFL);
+ while (size && (bytelit == 0))
+ {
+ offset++;
+ bytelit = ((lit >> (offset * 8)) & 0x0FFL);
+ size--;
+ }
+ CLRC;
+ while (size--)
+ {
+ MOVA (aopGet (left, offset, FALSE, FALSE));
+ if (sign && size == 0)
+ {
+ emitcode ("xrl", "a,#0x80");
+ emitcode ("subb", "a,#0x%02x",
+ 0x80 ^ (unsigned int) ((lit >> (offset * 8)) & 0x0FFL));
+ }
+ else
+ {
+ emitcode ("subb", "a,%s", aopGet (right, offset, FALSE, FALSE));
+ }
+ offset++;
+ }
+ goto release;
+ }
}
CLRC;
while (size--)
if (sign && size == 0)
{
emitcode ("xrl", "a,#0x80");
- if (AOP_TYPE (right) == AOP_LIT)
+ if (!rightInB)
{
- unsigned long lit = (unsigned long)
- floatFromVal (AOP (right)->aopu.aop_lit);
- emitcode ("subb", "a,#0x%02x",
- 0x80 ^ (unsigned int) ((lit >> (offset * 8)) & 0x0FFL));
- }
- else
- {
- if (!rightInB)
- {
- pushedB = pushB ();
- rightInB++;
- MOVB (aopGet (right, offset, FALSE, FALSE));
- }
- emitcode ("xrl", "b,#0x80");
- emitcode ("subb", "a,b");
+ pushedB = pushB ();
+ rightInB++;
+ MOVB (aopGet (right, offset, FALSE, FALSE));
}
+ emitcode ("xrl", "b,#0x80");
+ emitcode ("subb", "a,b");
}
else
{
}
else
{// what is this case? just found it in ds390/gen.c
- emitcode ("anl","a,#!constbyte",1 << (posbit & 0x07));
+ emitcode ("anl","a,#!constbyte",1 << (posbit & 0x07));
}
goto release;
}
"(%s + %d)", l + 1, offset);
}
else
- sprintf (buffer, "%s", l + 1);
+ {
+ SNPRINTF (buffer, sizeof(buffer),
+ "%s", l + 1);
+ }
aopPut (result, buffer, offset++);
}
}
else
{
- sprintf (buffer, "@%s", rname);
+ SNPRINTF (buffer, sizeof(buffer), "@%s", rname);
aopPut (result, buffer, offset);
}
offset++;
while (size--)
{
if (offset)
- sprintf (buffer, "(%s + %d)", l + 1, offset);
+ SNPRINTF (buffer, sizeof(buffer), "(%s + %d)", l + 1, offset);
else
- sprintf (buffer, "%s", l + 1);
+ SNPRINTF (buffer, sizeof(buffer), "%s", l + 1);
emitcode ("mov", "%s,%s", buffer,
aopGet (right, offset++, FALSE, FALSE));
}
sym->rname,
offset * 8);
else
- sprintf (s, "#%s", sym->rname);
+ SNPRINTF (s, sizeof(s), "#%s", sym->rname);
aopPut (IC_RESULT (ic), s, offset++);
}