/*-------------------------------------------------------------------------
- SDCCgen51.c - source file for code generation for 8051
+ gen.c - source file for code generation for 8051
Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998)
and - Jean-Louis VERN.jlvern@writeme.com (1999)
static unsigned short rbank = -1;
+#define REG_WITH_INDEX mcs51_regWithIdx
+
#define AOP(op) op->aop
#define AOP_TYPE(op) AOP(op)->type
#define AOP_SIZE(op) AOP(op)->size
AOP(x)->paged))
#define AOP_INPREG(x) (x && (x->type == AOP_REG && \
- (x->aopu.aop_reg[0] == mcs51_regWithIdx(R0_IDX) || \
- x->aopu.aop_reg[0] == mcs51_regWithIdx(R1_IDX) )))
+ (x->aopu.aop_reg[0] == REG_WITH_INDEX(R0_IDX) || \
+ x->aopu.aop_reg[0] == REG_WITH_INDEX(R1_IDX) )))
#define SYM_BP(sym) (SPEC_OCLS (sym->etype)->paged ? "_bpx" : "_bp")
IC_RESULT(x)->aop->type == AOP_STK )
#define MOVA(x) mova(x) /* use function to avoid multiple eval */
+#define MOVB(x) movb(x)
+
#define CLRC emitcode("clr","c")
#define SETC emitcode("setb","c")
va_end (ap);
}
+static void
+emitLabel (symbol *tlbl)
+{
+ emitcode ("", "%05d$:", (tlbl->key +100));
+}
+
/*-----------------------------------------------------------------*/
/* mcs51_emitDebuggerSymbol - associate the current code location */
/* with a debugger symbol */
emitcode("mov", "a,%s", x);
}
+/*-----------------------------------------------------------------*/
+/* movb - moves specified value into register b */
+/*-----------------------------------------------------------------*/
+static void
+movb (const char *x)
+{
+ /* do some early peephole optimization */
+ if (!strncmp(x, "b", 2))
+ return;
+
+ emitcode("mov","b,%s", x);
+}
+
/*-----------------------------------------------------------------*/
/* movc - moves specified value into the carry */
/*-----------------------------------------------------------------*/
static bool
pushReg (int index, bool bits_pushed)
{
- regs * reg = mcs51_regWithIdx (index);
+ regs * reg = REG_WITH_INDEX (index);
if (reg->type == REG_BIT)
{
if (!bits_pushed)
static bool
popReg (int index, bool bits_popped)
{
- regs * reg = mcs51_regWithIdx (index);
+ regs * reg = REG_WITH_INDEX (index);
if (reg->type == REG_BIT)
{
if (!bits_popped)
ic->rUsed = bitVectSetBit (ic->rUsed, R0_IDX);
(*aopp)->type = AOP_R0;
- return (*aopp)->aopu.aop_ptr = mcs51_regWithIdx (R0_IDX);
+ return (*aopp)->aopu.aop_ptr = REG_WITH_INDEX (R0_IDX);
}
/* if no usage of r1 then return it */
ic->rUsed = bitVectSetBit (ic->rUsed, R1_IDX);
(*aopp)->type = AOP_R1;
- return (*aopp)->aopu.aop_ptr = mcs51_regWithIdx (R1_IDX);
+ return (*aopp)->aopu.aop_ptr = REG_WITH_INDEX (R1_IDX);
}
/* now we know they both have usage */
/* push it if not already pushed */
if (ic->op == IPUSH)
{
- emitcode ("mov", "b,%s",
- mcs51_regWithIdx (R0_IDX)->dname);
+ MOVB (REG_WITH_INDEX (R0_IDX)->dname);
R0INB++;
}
else if (!_G.r0Pushed)
{
emitcode ("push", "%s",
- mcs51_regWithIdx (R0_IDX)->dname);
+ REG_WITH_INDEX (R0_IDX)->dname);
_G.r0Pushed++;
}
ic->rUsed = bitVectSetBit (ic->rUsed, R0_IDX);
(*aopp)->type = AOP_R0;
- return (*aopp)->aopu.aop_ptr = mcs51_regWithIdx (R0_IDX);
+ return (*aopp)->aopu.aop_ptr = REG_WITH_INDEX (R0_IDX);
}
/* if r1 not used then */
/* push it if not already pushed */
if (ic->op == IPUSH)
{
- emitcode ("mov", "b,%s",
- mcs51_regWithIdx (R1_IDX)->dname);
+ MOVB (REG_WITH_INDEX (R1_IDX)->dname);
R1INB++;
}
else if (!_G.r1Pushed)
{
emitcode ("push", "%s",
- mcs51_regWithIdx (R1_IDX)->dname);
+ REG_WITH_INDEX (R1_IDX)->dname);
_G.r1Pushed++;
}
ic->rUsed = bitVectSetBit (ic->rUsed, R1_IDX);
(*aopp)->type = AOP_R1;
- return mcs51_regWithIdx (R1_IDX);
+ return REG_WITH_INDEX (R1_IDX);
}
+
endOfWorld:
/* I said end of world, but not quite end of world yet */
- if (result) {
- /* we can push it on the stack */
- (*aopp)->type = AOP_STK;
- return NULL;
- } else {
+ /* if this is a result then we can push it on the stack */
+ if (result)
+ {
+ (*aopp)->type = AOP_STK;
+ return NULL;
+ }
/* in the case that result AND left AND right needs a pointer reg
we can safely use the result's */
- if (bitVectBitValue (mcs51_rUmaskForOp(IC_RESULT(ic)), R0_IDX)) {
+ if (bitVectBitValue (mcs51_rUmaskForOp(IC_RESULT(ic)), R0_IDX))
+ {
(*aopp)->type = AOP_R0;
- return mcs51_regWithIdx (R0_IDX);
+ return REG_WITH_INDEX (R0_IDX);
}
- if (bitVectBitValue (mcs51_rUmaskForOp(IC_RESULT(ic)), R1_IDX)) {
+ if (bitVectBitValue (mcs51_rUmaskForOp(IC_RESULT(ic)), R1_IDX))
+ {
(*aopp)->type = AOP_R1;
- return mcs51_regWithIdx (R1_IDX);
- }
+ return REG_WITH_INDEX (R1_IDX);
}
/* now this is REALLY the end of the world */
for (i=0; i<freeRegs->size; i++)
{
if (bitVectBitValue(freeRegs,i))
- tempRegs[offset++] = mcs51_regWithIdx(i);
+ tempRegs[offset++] = REG_WITH_INDEX(i);
if (offset>=size)
{
freeBitVect(freeRegs);
SNPRINTF (buffer, sizeof(buffer), "@%s", aop->aopu.aop_ptr->name);
return Safe_strdup(buffer);
-
case AOP_DPTR:
if (aop->code && aop->coff==0 && offset>=1) {
emitcode ("mov", "a,#0x%02x", offset);
else
{
SNPRINTF (buffer, sizeof(buffer),
- "#%s", aop->aopu.aop_immd.aop_immd1);
+ "#%s",
+ aop->aopu.aop_immd.aop_immd1);
}
return Safe_strdup(buffer);
else
{
SNPRINTF (buffer, sizeof(buffer),
- "%s", aop->aopu.aop_dir);
+ "%s",
+ aop->aopu.aop_dir);
}
return Safe_strdup(buffer);
else
{
SNPRINTF (buffer, sizeof(buffer),
- "%s", aop->aopu.aop_dir);
+ "%s",
+ aop->aopu.aop_dir);
}
if (strcmp (buffer, s) || bvolatile)
{
while (size--)
{
- emitcode ("orl", "a,%s", aopGet (oper, offset++, FALSE, FALSE));
+ emitcode ("orl", "a,%s",
+ aopGet (oper, offset++, FALSE, FALSE));
}
}
}
/* set C, if a == 0 */
tlbl = newiTempLabel (NULL);
emitcode ("cjne", "a,#0x01,%05d$", tlbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
outBitC (IC_RESULT (ic));
release:
MOVA (l);
emitcode ("cjne", "a,#0xFF,%05d$", tlbl->key + 100);
}
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
outBitC (IC_RESULT(ic));
goto release;
}
if (count == 1)
{
- regs * reg = mcs51_regWithIdx (bitVectFirstBit (rsave));
+ regs * reg = REG_WITH_INDEX (bitVectFirstBit (rsave));
if (reg->type == REG_BIT)
{
emitcode ("mov", "a,%s", reg->base);
{
if (bitVectBitValue (rsave, R0_IDX))
{
- emitcode ("push", "%s", mcs51_regWithIdx (R0_IDX)->dname);
+ emitcode ("push", "%s", REG_WITH_INDEX (R0_IDX)->dname);
}
emitcode ("mov", "r0,%s", spname);
MOVA ("r0");
{
if (bitVectBitValue (rsave, i))
{
- regs * reg = mcs51_regWithIdx (i);
+ regs * reg = REG_WITH_INDEX (i);
if (i == R0_IDX)
{
emitcode ("pop", "acc");
}
if (bitVectBitValue (rsave, R0_IDX))
{
- emitcode ("pop", "%s", mcs51_regWithIdx (R0_IDX)->dname);
+ emitcode ("pop", "%s", REG_WITH_INDEX (R0_IDX)->dname);
}
}
}
if (count == 1)
{
- regs * reg = mcs51_regWithIdx (bitVectFirstBit (rsave));
+ regs * reg = REG_WITH_INDEX (bitVectFirstBit (rsave));
emitcode ("mov", "r0,%s", spname);
emitcode ("dec", "r0");
emitcode ("movx", "a,@r0");
{
if (bitVectBitValue (rsave, i))
{
- regs * reg = mcs51_regWithIdx (i);
+ regs * reg = REG_WITH_INDEX (i);
emitcode ("dec", "r0");
emitcode ("movx", "a,@r0");
if (i == R0_IDX)
if (!ic)
{
/* Assume r0 is available for use. */
- r = mcs51_regWithIdx (R0_IDX);;
+ r = REG_WITH_INDEX (R0_IDX);;
}
else
{
if (!ic)
{
/* Assume r0 is available for use. */
- r = mcs51_regWithIdx (R0_IDX);;
+ r = REG_WITH_INDEX (R0_IDX);;
}
else
{
{
char *l = aopGet (IC_LEFT (sic), offset, FALSE, FALSE);
if (strcmp (l, fReturn[offset]))
+ {
emitcode ("mov", "%s,%s", fReturn[offset], l);
+ }
offset++;
}
}
/* make the call */
emitcode ("ret", "");
- emitcode ("", "%05d$:", (rlbl->key + 100));
+ emitLabel (rlbl);
}
}
if (swapBanks)
else
for (i = 0; i < ic->parmBytes; i++)
emitcode ("dec", "%s", spname);
-
}
// /* if register bank was saved then unsave them */
/* if it's a callee-saves function we need a saved register */
if (calleesaves_saved_register >= 0)
{
- emitcode ("mov", "%s,a", mcs51_regWithIdx (calleesaves_saved_register)->dname);
+ emitcode ("mov", "%s,a", REG_WITH_INDEX (calleesaves_saved_register)->dname);
emitcode ("mov", "a,sp");
emitcode ("add", "a,#0x%02x", ((char) sym->stack & 0xff));
emitcode ("mov", "sp,a");
- emitcode ("mov", "a,%s", mcs51_regWithIdx (calleesaves_saved_register)->dname);
+ emitcode ("mov", "a,%s", REG_WITH_INDEX (calleesaves_saved_register)->dname);
}
else
/* do it the hard way */
emitcode ("setb", "c");
emitcode ("jbc", "ea,%05d$", (tlbl->key + 100)); /* atomic test & clear */
emitcode ("clr", "c");
- emitcode ("", "%05d$:", (tlbl->key + 100));
+ emitLabel (tlbl);
emitcode ("push", "psw"); /* save old ea via c in psw */
}
}
{
if (bitVectBitValue (sym->regsUsed, i) ||
(mcs51_ptrRegReq && (i == R0_IDX || i == R1_IDX)))
- emitcode ("pop", "%s", mcs51_regWithIdx (i)->dname);
+ emitcode ("pop", "%s", REG_WITH_INDEX (i)->dname);
}
}
else if (mcs51_ptrRegReq)
{
- emitcode ("pop", "%s", mcs51_regWithIdx (R1_IDX)->dname);
- emitcode ("pop", "%s", mcs51_regWithIdx (R0_IDX)->dname);
+ emitcode ("pop", "%s", REG_WITH_INDEX (R1_IDX)->dname);
+ emitcode ("pop", "%s", REG_WITH_INDEX (R0_IDX)->dname);
}
}
for (idx = 0; idx < regsUnneeded->size; idx++)
if (bitVectBitValue (regsUnneeded, idx))
- emitcode ("", ";\teliminated unneeded push/pop %s", mcs51_regWithIdx (idx)->dname);
+ emitcode (";", "eliminated unneeded push/pop %s", REG_WITH_INDEX (idx)->dname);
freeBitVect (regsUnneeded);
freeBitVect (regsUsed);
if (emitTlbl)
{
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
return TRUE;
}
same */
if (sameRegs (AOP (IC_LEFT (ic)), AOP (IC_RESULT (ic))))
{
-
if (icount > 3)
{
MOVA (aopGet (IC_LEFT (ic), 0, FALSE, FALSE));
}
else
{
-
while (icount--)
- emitcode ("inc", "%s", aopGet (IC_LEFT (ic), 0, FALSE, FALSE));
+ {
+ emitcode ("inc", "%s", aopGet (IC_LEFT (ic), 0, FALSE, FALSE));
+ }
}
return TRUE;
{
emitcode ("jz", "%05d$", tlbl->key + 100);
emitcode ("mov", "a,%s", one);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
outAcc (result);
}
}
static void
genPlusBits (iCode * ic)
{
- D(emitcode ("; genPlusBits",""));
+ D (emitcode (";", "genPlusBits"));
if (AOP_TYPE (IC_RESULT (ic)) == AOP_CRY)
{
emitcode ("mov", "c,%s", AOP (IC_LEFT (ic))->aopu.aop_dir);
emitcode ("jnb", "%s,%05d$", AOP (IC_RIGHT (ic))->aopu.aop_dir, (lbl->key + 100));
emitcode ("cpl", "c");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
outBitC (IC_RESULT (ic));
}
else
operand *leftOp, *rightOp;
operand * op;
- /* special cases :- */
+ D (emitcode (";", "genPlus"));
- D(emitcode ("; genPlus",""));
+ /* special cases :- */
aopOp (IC_LEFT (ic), ic, FALSE);
aopOp (IC_RIGHT (ic), ic, FALSE);
}
if (emitTlbl)
{
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
return TRUE;
}
}
while (icount--)
- emitcode ("dec", "%s", l);
+ {
+ emitcode ("dec", "%s", l);
+ }
if (AOP_NEEDSACC (IC_RESULT (ic)))
aopPut (IC_RESULT (ic), "a", 0);
emitcode ("rlc", "a");
emitcode ("subb", "a,acc");
while (size--)
- aopPut (result, "a", offset++);
+ {
+ aopPut (result, "a", offset++);
+ }
}
else
- while (size--)
- aopPut (result, zero, offset++);
+ {
+ while (size--)
+ {
+ aopPut (result, zero, offset++);
+ }
+ }
}
}
{
symbol *lbl = newiTempLabel (NULL);
- D(emitcode ("; genMinusBits",""));
+ D (emitcode (";", "genMinusBits"));
if (AOP_TYPE (IC_RESULT (ic)) == AOP_CRY)
{
emitcode ("mov", "c,%s", AOP (IC_LEFT (ic))->aopu.aop_dir);
emitcode ("jnb", "%s,%05d$", AOP (IC_RIGHT (ic))->aopu.aop_dir, (lbl->key + 100));
emitcode ("cpl", "c");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
outBitC (IC_RESULT (ic));
}
else
emitcode ("subb", "a,acc");
emitcode ("jnb", "%s,%05d$", AOP (IC_LEFT (ic))->aopu.aop_dir, (lbl->key + 100));
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
aopPut (IC_RESULT (ic), "a", 0);
addSign (IC_RESULT (ic), MSB16, SPEC_USIGN (getSpec (operandType (IC_RESULT (ic)))));
}
{
int size, offset = 0;
- D(emitcode ("; genMinus",""));
+ D (emitcode (";", "genMinus"));
aopOp (IC_LEFT (ic), ic, FALSE);
aopOp (IC_RIGHT (ic), ic, FALSE);
operand * right,
operand * result)
{
- D(emitcode ("; genMultbits",""));
+ D (emitcode (";", "genMultbits"));
emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
emitcode ("anl", "c,%s", AOP (right)->aopu.aop_dir);
bool runtimeSign, compiletimeSign;
bool lUnsigned, rUnsigned, pushedB;
- D(emitcode ("; genMultOneByte",""));
+ D (emitcode (";", "genMultOneByte"));
if (size < 1 || size > 2)
{
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
emitcode ("mov", "b,a");
}
}
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
}
}
emitcode ("addc", "a,#0");
emitcode ("xch", "a,b");
}
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
}
aopPut (result, "a", 0);
if (size == 2)
operand *right = IC_RIGHT (ic);
operand *result = IC_RESULT (ic);
- D(emitcode ("; genMult",""));
+ D (emitcode (";", "genMult"));
/* assign the asmops */
aopOp (left, ic, FALSE);
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
emitcode ("mov", "b,a");
}
}
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
}
}
emitcode ("jnb", "F0,%05d$", (lbl->key + 100));
emitcode ("cpl", "a"); /* lsb 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
accuse = aopPut (result, "a", 0);
if (size > 0)
operand *right = IC_RIGHT (ic);
operand *result = IC_RESULT (ic);
- D(emitcode ("; genDiv",""));
+ D (emitcode (";", "genDiv"));
/* assign the amsops */
aopOp (left, ic, FALSE);
lbl2 = newiTempLabel (NULL);
emitcode ("sjmp", "%05d$", (lbl2->key + 100));
}
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
aopPut (result, "a", 0);
while (size--)
aopPut (result, zero, offset++);
if (lbl2)
{
- emitcode ("", "%05d$:", (lbl2->key + 100));
+ emitLabel (lbl2);
}
return;
emitcode ("jnb", "acc.7,%05d$", (lbl->key + 100));
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
emitcode ("mov", "b,a");
}
}
emitcode ("setb", "F0"); /* set sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
}
}
emitcode ("jnb", "F0,%05d$", (lbl->key + 100));
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
aopPut (result, "a", 0);
if (size > 0)
operand *right = IC_RIGHT (ic);
operand *result = IC_RESULT (ic);
- D(emitcode ("; genMod",""));
+ D (emitcode (";", "genMod"));
/* assign the asmops */
aopOp (left, ic, FALSE);
symbol *tlbl = newiTempLabel (NULL);
char *inst;
- D(emitcode ("; genIfxJump",""));
+ D (emitcode (";", "genIfxJump"));
/* if true label then we jump if condition
supplied is true */
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", jlbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
/* mark the icode as generated */
ic->generated = 1;
unsigned long lit = 0L;
bool rightInB;
- D(emitcode ("; genCmp",""));
+ D (emitcode (";", "genCmp"));
/* if left & right are bit variables */
if (AOP_TYPE (left) == AOP_CRY &&
aopGet (left, offset, FALSE, FALSE),
aopGet (right, offset, FALSE, FALSE),
lbl->key + 100);
- emitcode ("", "%05d$:", lbl->key + 100);
+ emitLabel (lbl);
}
else
{
return;
}
else
- emitcode ("rlc", "a");
+ {
+ emitcode ("rlc", "a");
+ }
}
goto release;
}
{
pushedB = pushB ();
rightInB++;
- emitcode ("mov", "b,%s", aopGet (right, offset, FALSE, FALSE));
+ MOVB (aopGet (right, offset, FALSE, FALSE));
}
emitcode ("xrl", "b,#0x80");
emitcode ("subb", "a,b");
ifx conditional branch then generate
code a little differently */
if (ifx)
- genIfxJump (ifx, "c", NULL, NULL, result);
+ {
+ genIfxJump (ifx, "c", NULL, NULL, result);
+ }
else
- outBitC (result);
+ {
+ outBitC (result);
+ }
/* leave the result in acc */
}
}
sym_link *letype, *retype;
int sign;
- D(emitcode ("; genCmpGt",""));
+ D (emitcode (";", "genCmpGt"));
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
sym_link *letype, *retype;
int sign;
- D(emitcode ("; genCmpLt",""));
+ D (emitcode (";", "genCmpLt"));
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
int offset = 0;
unsigned long lit = 0L;
+ D (emitcode (";", "gencjneshort"));
+
/* if the left side is a literal or
if the right is in a pointer register and left
is not */
/* right is a pointer reg need both a & b */
while (size--)
{
- char *l;
//if B in use: push B; mov B,left; mov A,right; clrc; subb A,B; pop B; jnz
wassertl(!BINUSE, "B was in use");
- l = aopGet (left, offset, FALSE, FALSE);
- if (strcmp (l, "b"))
- emitcode ("mov", "b,%s", l);
+ MOVB (aopGet (left, offset, FALSE, FALSE));
MOVA (aopGet (right, offset, FALSE, FALSE));
emitcode ("cjne", "a,b,%05d$", lbl->key + 100);
offset++;
{
symbol *tlbl = newiTempLabel (NULL);
+ D (emitcode (";", "gencjne"));
+
gencjneshort (left, right, lbl);
emitcode ("mov", "a,%s", one);
emitcode ("sjmp", "%05d$", tlbl->key + 100);
- emitcode ("", "%05d$:", lbl->key + 100);
+ emitLabel (lbl);
emitcode ("clr", "a");
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
/*-----------------------------------------------------------------*/
bool swappedLR = FALSE;
operand *left, *right, *result;
- D(emitcode ("; genCmpEq",""));
+ D (emitcode (";", "genCmpEq"));
aopOp ((left = IC_LEFT (ic)), ic, FALSE);
aopOp ((right = IC_RIGHT (ic)), ic, FALSE);
emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
emitcode ("jb", "%s,%05d$", AOP (right)->aopu.aop_dir, (lbl->key + 100));
emitcode ("cpl", "c");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
}
/* if true label then we jump if condition
supplied is true */
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_FALSE (ifx)->key + 100);
}
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
else
{
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_TRUE (ifx)->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
else
{
symbol *lbl = newiTempLabel (NULL);
emitcode ("sjmp", "%05d$", lbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
freeForBranchAsmop (result);
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_FALSE (ifx)->key + 100);
- emitcode ("", "%05d$:", lbl->key + 100);
+ emitLabel (lbl);
}
}
/* mark the icode as generated */
emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
emitcode ("jb", "%s,%05d$", AOP (right)->aopu.aop_dir, (lbl->key + 100));
emitcode ("cpl", "c");
- emitcode ("", "%05d$:", (lbl->key + 100));
+ emitLabel (lbl);
}
/* c = 1 if egal */
if (AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result))
/* hasInc - operand is incremented before any other use */
/*-----------------------------------------------------------------*/
static iCode *
-hasInc (operand *op, iCode *ic,int osize)
+hasInc (operand *op, iCode *ic, int osize)
{
sym_link *type = operandType(op);
sym_link *retype = getSpec (type);
operand *left, *right, *result;
symbol *tlbl;
- D(emitcode ("; genAndOp",""));
+ D (emitcode (";", "genAndOp"));
/* note here that && operations that are in an
if statement are taken away by backPatchLabels
toBoolean (left);
emitcode ("jz", "%05d$", tlbl->key + 100);
toBoolean (right);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
outBitAcc (result);
}
operand *left, *right, *result;
symbol *tlbl;
- D(emitcode ("; genOrOp",""));
+ D (emitcode (";", "genOrOp"));
/* note here that || operations that are in an
if statement are taken away by backPatchLabels
toBoolean (left);
emitcode ("jnz", "%05d$", tlbl->key + 100);
toBoolean (right);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
outBitAcc (result);
}
{
symbol *nlbl = newiTempLabel (NULL);
emitcode ("sjmp", "%05d$", nlbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
freeForBranchAsmop (result);
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_TRUE (ic)->key + 100);
- emitcode ("", "%05d$:", nlbl->key + 100);
+ emitLabel (nlbl);
}
else
{
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_FALSE (ic)->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
ic->generated = 1;
}
int bytelit = 0;
char buffer[10];
- D(emitcode ("; genAnd",""));
+ D (emitcode (";", "genAnd"));
aopOp ((left = IC_LEFT (ic)), ic, FALSE);
aopOp ((right = IC_RIGHT (ic)), ic, FALSE);
if (size)
{
emitcode ("clr", "c");
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
// if(left & literal)
else
if (ifx)
jmpTrueOrFalse (ifx, tlbl, left, right, result);
else
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
goto release;
}
}
if (size)
{
CLRC;
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
outBitC (result);
}
else if (ifx)
jmpTrueOrFalse (ifx, tlbl, left, right, result);
else
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
else
{
else
{
CLRC;
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
}
}
symbol *tlbl = newiTempLabel (NULL);
emitcode ("jnz", "%05d$", tlbl->key + 100);
CLRC;
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
else
{
if (size)
{
CLRC;
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
outBitC (result);
}
else if (ifx)
jmpTrueOrFalse (ifx, tlbl, left, right, result);
else
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
else
{
unsigned long lit = 0L;
int bytelit = 0;
- D(emitcode ("; genXor",""));
+ D (emitcode (";", "genXor"));
aopOp ((left = IC_LEFT (ic)), ic, FALSE);
aopOp ((right = IC_RIGHT (ic)), ic, FALSE);
}
emitcode ("jnb", "%s,%05d$", AOP (left)->aopu.aop_dir, (tlbl->key + 100));
emitcode ("cpl", "c");
- emitcode ("", "%05d$:", (tlbl->key + 100));
+ emitLabel (tlbl);
}
// bit = c
// val = c
// if(!size && ifx), conditional oper: if(left ^ right)
symbol *tlbl = newiTempLabel (NULL);
int sizer = max (AOP_SIZE (left), AOP_SIZE (right));
+
if (size)
emitcode ("setb", "c");
while (sizer--)
if (size)
{
CLRC;
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
outBitC (result);
}
else if (ifx)
for (; (size--); offset++)
{
// normal case
- // result = left & right
+ // result = left ^ right
if (AOP_TYPE (right) == AOP_LIT)
{
bytelit = (int) ((lit >> (offset * 8)) & 0x0FFL);
genRRC (iCode * ic)
{
operand *left, *result;
- int size, offset = 0;
+ int size, offset;
char *l;
- D(emitcode ("; genRRC",""));
+ D (emitcode (";", "genRRC"));
/* rotate right with carry */
left = IC_LEFT (ic);
genRLC (iCode * ic)
{
operand *left, *result;
- int size, offset = 0;
+ int size, offset;
char *l;
- D(emitcode ("; genRLC",""));
+ D (emitcode (";", "genRLC"));
/* rotate right with carry */
left = IC_LEFT (ic);
}
emitcode("rlc","a"); /* bit0 will be written later */
if (AOP_SIZE (result) > 1)
- aopPut (result, "a", offset++);
+ {
+ aopPut (result, "a", offset++);
+ }
+
while (size--)
{
l = aopGet (left, offset, FALSE, FALSE);
{
operand *left, *result;
- D(emitcode ("; genGetHbit",""));
+ D (emitcode (";", "genGetHbit"));
left = IC_LEFT (ic);
result = IC_RESULT (ic);
operand *left, *right, *result;
int shCount;
- D(emitcode ("; genGetAbit",""));
+ D (emitcode (";", "genGetAbit"));
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
operand *left, *right, *result;
int offset;
- D(emitcode ("; genGetByte",""));
+ D (emitcode (";", "genGetByte"));
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
operand *left, *right, *result;
int offset;
- D(emitcode ("; genGetWord",""));
+ D (emitcode (";", "genGetWord"));
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
emitcode ("jnb", "acc.%d,%05d$", 7 - shCount, tlbl->key + 100);
emitcode ("orl", "a,#0x%02x",
(unsigned char) ~SRMask[shCount]);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
}
}
else
{
if (!sign)
- aopPut (result, l, offr);
+ {
+ aopPut (result, l, offr);
+ }
else
{
/* MSB sign in acc.7 ! */
emitcode ("orl", "a,#0x%02x",
(unsigned char) ~SRMask[shCount]); // 111AAAAA:BBBCCCCC
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
break; // SSSSAAAA:BBBCCCCC
case 6: // AABBBBBB:CCDDDDDD
emitcode ("orl", "a,#0x%02x",
(unsigned char) ~SRMask[shCount]); // 111111AA:BBBBBBCC
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
break;
case 7: // ABBBBBBB:CDDDDDDD
emitcode ("orl", "a,#0x%02x",
(unsigned char) ~SRMask[shCount]); // 1111111A:BBBBBBBC
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
break;
default:
break;
static void
genlshOne (operand * result, operand * left, int shCount)
{
- D(emitcode ("; genlshOne",""));
+ D (emitcode (";", "genlshOne"));
shiftL1Left2Result (left, LSB, result, LSB, shCount);
}
{
int size;
- D(emitcode ("; genlshTwo",""));
+ D (emitcode (";", "genlshTwo"));
size = getDataSize (result);
{
int size;
- D(emitcode ("; genlshFour",""));
+ D (emitcode (";", "genlshFour"));
size = AOP_SIZE (result);
}
else if (shCount >= (size * 8))
- while (size--)
- aopPut (result, zero, size);
+ {
+ while (size--)
+ {
+ aopPut (result, zero, size);
+ }
+ }
else
{
switch (size)
symbol *tlbl, *tlbl1;
bool pushedB;
- D(emitcode ("; genLeftShift",""));
+ D (emitcode (";", "genLeftShift"));
right = IC_RIGHT (ic);
left = IC_LEFT (ic);
largest size of an object can be only 32 bits ) */
pushedB = pushB ();
- emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE));
+ MOVB (aopGet (right, 0, FALSE, FALSE));
emitcode ("inc", "b");
freeAsmop (right, NULL, ic, TRUE);
aopOp (left, ic, FALSE);
l = aopGet (left, 0, FALSE, FALSE);
MOVA (l);
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
emitcode ("add", "a,acc");
- emitcode ("", "%05d$:", tlbl1->key + 100);
+ emitLabel (tlbl1);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
aopPut (result, "a", 0);
reAdjustPreg (AOP (result));
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
l = aopGet (result, offset, FALSE, FALSE);
MOVA (l);
emitcode ("add", "a,acc");
}
reAdjustPreg (AOP (result));
- emitcode ("", "%05d$:", tlbl1->key + 100);
+ emitLabel (tlbl1);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
release:
genrshOne (operand * result, operand * left,
int shCount, int sign)
{
- D(emitcode ("; genrshOne",""));
+ D (emitcode (";", "genrshOne"));
shiftR1Left2Result (left, LSB, result, LSB, shCount, sign);
}
genrshTwo (operand * result, operand * left,
int shCount, int sign)
{
- D(emitcode ("; genrshTwo",""));
+ D (emitcode (";", "genrshTwo"));
/* if shCount >= 8 */
if (shCount >= 8)
{
shCount -= 8;
if (shCount)
- shiftR1Left2Result (left, MSB16, result, LSB,
- shCount, sign);
+ shiftR1Left2Result (left, MSB16, result, LSB, shCount, sign);
else
movLeft2Result (left, MSB16, result, LSB, sign);
addSign (result, MSB16, sign);
genrshFour (operand * result, operand * left,
int shCount, int sign)
{
- D(emitcode ("; genrshFour",""));
+ D (emitcode (";", "genrshFour"));
/* if shifting more that 3 bytes */
if (shCount >= 24)
{
shCount -= 8;
if (shCount == 1)
- shiftRLong (left, MSB16, result, sign);
+ {
+ shiftRLong (left, MSB16, result, sign);
+ }
else if (shCount == 0)
{
movLeft2Result (left, MSB16, result, LSB, 0);
symbol *tlbl, *tlbl1;
bool pushedB;
- D(emitcode ("; genSignedRightShift",""));
+ D (emitcode (";", "genSignedRightShift"));
/* we do it the hard way put the shift count in b
and loop thru preserving the sign */
largest size of an object can be only 32 bits ) */
pushedB = pushB ();
- emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE));
+ MOVB (aopGet (right, 0, FALSE, FALSE));
emitcode ("inc", "b");
freeAsmop (right, NULL, ic, TRUE);
aopOp (left, ic, FALSE);
l = aopGet (left, 0, FALSE, FALSE);
MOVA (l);
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
emitcode ("mov", "c,ov");
emitcode ("rrc", "a");
- emitcode ("", "%05d$:", tlbl1->key + 100);
+ emitLabel (tlbl1);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
aopPut (result, "a", 0);
reAdjustPreg (AOP (result));
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
emitcode ("mov", "c,ov");
while (size--)
{
aopPut (result, "a", offset--);
}
reAdjustPreg (AOP (result));
- emitcode ("", "%05d$:", tlbl1->key + 100);
+ emitLabel (tlbl1);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
symbol *tlbl, *tlbl1;
bool pushedB;
- D(emitcode ("; genRightShift",""));
+ D (emitcode (";", "genRightShift"));
/* if signed then we do it the hard way preserve the
sign bit moving it inwards */
largest size of an object can be only 32 bits ) */
pushedB = pushB ();
- emitcode ("mov", "b,%s", aopGet (right, 0, FALSE, FALSE));
+ MOVB (aopGet (right, 0, FALSE, FALSE));
emitcode ("inc", "b");
freeAsmop (right, NULL, ic, TRUE);
aopOp (left, ic, FALSE);
if (!sameRegs (AOP (left), AOP (result)) &&
AOP_SIZE (result) > 1)
{
-
size = AOP_SIZE (result);
offset = 0;
while (size--)
l = aopGet (left, 0, FALSE, FALSE);
MOVA (l);
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
CLRC;
emitcode ("rrc", "a");
- emitcode ("", "%05d$:", tlbl1->key + 100);
+ emitLabel (tlbl1);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
aopPut (result, "a", 0);
reAdjustPreg (AOP (result));
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
CLRC;
while (size--)
{
}
reAdjustPreg (AOP (result));
- emitcode ("", "%05d$:", tlbl1->key + 100);
+ emitLabel (tlbl1);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
emitcode ("jnb", "acc.%d,%05d$", blen - 1, tlbl->key + 100);
emitcode ("orl", "a,#0x%02x", (unsigned char) (0xff << blen));
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
aopPut (result, "a", offset++);
goto finish;
emitcode ("jnb", "acc.%d,%05d$", rlen - 1, tlbl->key + 100);
emitcode ("orl", "a,#0x%02x", (unsigned char) (0xff << rlen));
- emitcode ("", "%05d$:", tlbl->key + 100);
+ emitLabel (tlbl);
}
aopPut (result, "a", 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);
aopPut (result, buffer, offset++);
}
/*-----------------------------------------------------------------*/
-/* genFarPointerGet - gget value from far space */
+/* genFarPointerGet - get value from far space */
/*-----------------------------------------------------------------*/
static void
genFarPointerGet (operand * left,
int size, offset;
sym_link *retype = getSpec (operandType (result));
- D(emitcode ("; genGenPointerGet",""));
+ D (emitcode (";", "genGenPointerGet"));
aopOp (left, ic, FALSE);
loadDptrFromOperand (left, TRUE);
- /* so dptr know contains the address */
+ /* so dptr now contains the address */
aopOp (result, ic, FALSE);
/* if bit then unpack */
if (IS_BITFIELD (retype))
- genUnpackBits (result, "dptr", GPOINTER, ifx);
+ {
+ genUnpackBits (result, "dptr", GPOINTER, ifx);
+ }
else
{
size = AOP_SIZE (result);
sym_link *type, *etype;
int p_type;
- D(emitcode ("; genPointerGet",""));
+ D (emitcode (";", "genPointerGet"));
left = IC_LEFT (ic);
result = IC_RESULT (ic);
/* special case when cast remat */
if (p_type == GPOINTER && OP_SYMBOL(left)->remat &&
- IS_CAST_ICODE(OP_SYMBOL(left)->rematiCode)) {
- left = IC_RIGHT(OP_SYMBOL(left)->rematiCode);
- type = operandType (left);
- p_type = DCL_TYPE (type);
- }
+ IS_CAST_ICODE(OP_SYMBOL(left)->rematiCode))
+ {
+ left = IC_RIGHT(OP_SYMBOL(left)->rematiCode);
+ type = operandType (left);
+ p_type = DCL_TYPE (type);
+ }
/* now that we have the pointer type we assign
the pointer values */
switch (p_type)
genGenPointerGet (left, result, ic, pi, ifx);
break;
}
-
}
-
/*-----------------------------------------------------------------*/
/* genPackBits - generates code for packed bit storage */
/*-----------------------------------------------------------------*/
}
emitPtrByteSet (rname, p_type, "a");
}
-
}
int size, offset = 0;
char *l, buffer[256];
- D(emitcode ("; genDataPointerSet",""));
+ D (emitcode (";", "genDataPointerSet"));
aopOp (right, ic, FALSE);
sym_link *retype, *letype;
sym_link *ptype = operandType (result);
- D(emitcode ("; genNearPointerSet",""));
+ D (emitcode (";", "genNearPointerSet"));
retype = getSpec (operandType (right));
letype = getSpec (ptype);
+
aopOp (result, ic, FALSE);
/* if the result is rematerializable &
genPackBits ((IS_BITFIELD (retype) ? retype : letype), right, rname, POINTER);
else
{
- /* we have can just get the values */
+ /* we can just get the values */
int size = AOP_SIZE (right);
int offset = 0;
while (size--)
{
l = aopGet (right, offset, FALSE, TRUE);
- if (*l == '@')
+ if ((*l == '@') || (strcmp (l, "acc") == 0))
{
MOVA (l);
emitcode ("mov", "@%s,a", rname);
char *rname, *l;
sym_link *retype, *letype;
- D(emitcode ("; genPagedPointerSet",""));
+ D (emitcode (";", "genPagedPointerSet"));
retype = getSpec (operandType (right));
letype = getSpec (operandType (result));
while (size--)
{
l = aopGet (right, offset, FALSE, TRUE);
-
MOVA (l);
emitcode ("movx", "@%s,a", rname);
/* if bit then unpack */
if (IS_BITFIELD (retype) || IS_BITFIELD (letype))
- genPackBits ((IS_BITFIELD (retype) ? retype : letype), right, "dptr", GPOINTER);
+ {
+ genPackBits ((IS_BITFIELD (retype) ? retype : letype), right, "dptr", GPOINTER);
+ }
else
{
size = AOP_SIZE (right);
sym_link *type, *etype;
int p_type;
- D(emitcode ("; genPointerSet",""));
+ D (emitcode (";", "genPointerSet"));
right = IC_RIGHT (ic);
result = IC_RESULT (ic);
type = operandType (result);
p_type = DCL_TYPE (type);
}
+
/* now that we have the pointer type we assign
the pointer values */
switch (p_type)
werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
"genPointerSet: illegal pointer type");
}
-
}
/*-----------------------------------------------------------------*/
int isbit = 0;
char *dup = NULL;
- D(emitcode ("; genIfx",""));
+ D (emitcode (";", "genIfx"));
aopOp (cond, ic, FALSE);
/* get the value into acc */
if (AOP_TYPE (cond) != AOP_CRY)
- toBoolean (cond);
+ {
+ toBoolean (cond);
+ }
else
{
isbit = 1;
if (AOP(cond)->aopu.aop_dir)
dup = Safe_strdup(AOP(cond)->aopu.aop_dir);
}
+
/* the result is now in the accumulator or a directly addressable bit */
freeAsmop (cond, NULL, ic, TRUE);
symbol *sym = OP_SYMBOL (IC_LEFT (ic));
int size, offset;
- D(emitcode ("; genAddrOf",""));
+ D (emitcode (";", "genAddrOf"));
aopOp (IC_RESULT (ic), ic, FALSE);
variable */
if (sym->onStack)
{
- /* if it has an offset then we need to compute
- it */
+ /* if it has an offset then we need to compute it */
if (sym->stack)
{
emitcode ("mov", "a,%s", SYM_BP (sym));
{
aopPut (IC_RESULT (ic), zero, offset++);
}
-
goto release;
}
int size, offset;
unsigned long lit = 0L;
- D(emitcode("; genAssign",""));
+ D (emitcode (";", "genAssign"));
result = IC_RESULT (ic);
right = IC_RIGHT (ic);
IS_TRUE_SYMOP (result) &&
isOperandInFarSpace (result))
{
-
genFarFarAssign (result, right, ic);
return;
}
/* if the result is a bit */
if (AOP_TYPE (result) == AOP_CRY)
{
-
/* if the right size is a literal then
we know what the value is */
if (AOP_TYPE (right) == AOP_LIT)
offset = 0;
if (AOP_TYPE (right) == AOP_LIT)
lit = (unsigned long) floatFromVal (AOP (right)->aopu.aop_lit);
+
if ((size > 1) &&
(AOP_TYPE (result) != AOP_REG) &&
(AOP_TYPE (right) == AOP_LIT) &&
offset++;
size--;
}
- emitcode ("clr", "a");
+ /* And now fill the rest with zeros. */
+ if (size)
+ {
+ emitcode ("clr", "a");
+ }
while (size--)
{
aopPut (result, "a", offset);
jtab = newiTempLabel (NULL);
emitcode ("mov", "dptr,#%05d$", jtab->key + 100);
emitcode ("jmp", "@a+dptr");
- emitcode ("", "%05d$:", jtab->key + 100);
+ emitLabel (jtab);
/* now generate the jump labels */
for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab;
jtab = setNextItem (IC_JTLABELS (ic)))
emitcode ("ret", "");
/* now generate jump table, LSB */
- emitcode ("", "%05d$:", jtablo->key + 100);
+ emitLabel (jtablo);
for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab;
jtab = setNextItem (IC_JTLABELS (ic)))
emitcode (".db", "%05d$", jtab->key + 100);
/* now generate jump table, MSB */
- emitcode ("", "%05d$:", jtabhi->key + 100);
+ emitLabel (jtabhi);
for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab;
jtab = setNextItem (IC_JTLABELS (ic)))
emitcode (".db", "%05d$>>8", jtab->key + 100);
operand *right = IC_RIGHT (ic);
int size, offset;
- D(emitcode("; genCast",""));
+ D (emitcode (";", "genCast"));
/* if they are equivalent then do nothing */
if (operandsEqu (IC_RESULT (ic), IC_RIGHT (ic)))
if (IS_GENPTR (ctype))
{
if (IS_PTR (type))
- p_type = DCL_TYPE (type);
+ {
+ p_type = DCL_TYPE (type);
+ }
else
{
if (SPEC_SCLS(etype)==S_REGISTER) {
if (!ifx)
return 0;
- D(emitcode ("; genDjnz",""));
-
/* if the if condition has a false label
then we cannot save */
if (IC_FALSE (ifx))
return 0;
- /* if the minus is not of the form
- a = a - 1 */
+ /* if the minus is not of the form a = a - 1 */
if (!isOperandEqual (IC_RESULT (ic), IC_LEFT (ic)) ||
!IS_OP_LITERAL (IC_RIGHT (ic)))
return 0;
return 0;
/* otherwise we can save BIG */
+
+ D (emitcode (";", "genDjnz"));
+
lbl = newiTempLabel (NULL);
lbl1 = newiTempLabel (NULL);
emitcode ("dec", "%s",
aopGet (IC_RESULT (ic), 0, FALSE, FALSE));
MOVA (aopGet (IC_RESULT (ic), 0, FALSE, FALSE));
+ freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
+ ifx->generated = 1;
emitcode ("jnz", "%05d$", lbl->key + 100);
}
else
lbl->key + 100);
}
emitcode ("sjmp", "%05d$", lbl1->key + 100);
- emitcode ("", "%05d$:", lbl->key + 100);
+ emitLabel (lbl);
emitcode ("ljmp", "%05d$", IC_TRUE (ifx)->key + 100);
- emitcode ("", "%05d$:", lbl1->key + 100);
+ emitLabel (lbl1);
- freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
+ if (!ifx->generated)
+ freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
ifx->generated = 1;
return 1;
}
int size = getSize (operandType (IC_RESULT (ic)));
int offset = 0;
- D(emitcode ("; genReceive",""));
+ D (emitcode (";", "genReceive"));
if (ic->argreg == 1)
{ /* first parameter */
operand *op;
int size, offset;
- D(emitcode("; genDummyRead",""));
+ D (emitcode(";", "genDummyRead"));
op = IC_RIGHT (ic);
if (op && IS_SYMOP (op))
{
symbol *tlbl = newiTempLabel (NULL);
- D(emitcode("; genCritical",""));
+ D (emitcode(";", "genCritical"));
if (IC_RESULT (ic))
{
aopPut (IC_RESULT (ic), one, 0);
emitcode ("jbc", "ea,%05d$", (tlbl->key + 100)); /* atomic test & clear */
aopPut (IC_RESULT (ic), zero, 0);
- emitcode ("", "%05d$:", (tlbl->key + 100));
+ emitLabel (tlbl);
freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
}
else
emitcode ("setb", "c");
emitcode ("jbc", "ea,%05d$", (tlbl->key + 100)); /* atomic test & clear */
emitcode ("clr", "c");
- emitcode ("", "%05d$:", (tlbl->key + 100));
+ emitLabel (tlbl);
emitcode ("push", "psw"); /* save old ea via c in psw on top of stack*/
}
}