(_print_format): fixed printing pointers
* src/mcs51/gen.c (emitLabel, movb): new, added,
(genAssign): small optimization,
(genDjnz): fixed stack overflow bug,
(throughout): replaced sprintf with SNPRINTF,
replaced mcs51_regWithIdx with REG_WITH_INDEX,
replaced emitcode("mov", "b,...") with MOVB(...),
replaced emitcode("", "%05d$:", lbl->key + 100) with emitLabel(lbl),
replaced D(emitcode("; genXXX", "")) with D(emitcode(";", "genXXX"))
* src/mcs51/peeph.def: added rules 140 and 264
* src/SDCCmem.c (allocLocal): store register declared locals in DSEG/OSEG
so they may get optimized into registers
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4202
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2006-05-31 Maarten Brock <sourceforge.brock AT dse.nl>
+
+ * device/lib/printf_large.c (output_digit, calculate_digit): optimized,
+ (_print_format): fixed printing pointers
+ * src/mcs51/peeph.def: added rule 140
+ * src/SDCCmem.c (allocLocal): store register declared locals in DSEG/OSEG
+ so they may get optimized into registers
+
2006-05-30 Maarten Brock <sourceforge.brock AT dse.nl>
* src/SDCCmain.c (optionsTable, parseCmdLine): handle --use-stdout
2006-05-30 Maarten Brock <sourceforge.brock AT dse.nl>
* src/SDCCmain.c (optionsTable, parseCmdLine): handle --use-stdout
what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
what you give them. Help stamp out software-hoarding!
-------------------------------------------------------------------------*/
+#if defined (SDCC_ds390)
#define USE_FLOATS 1
#endif
#define USE_FLOATS 1
#endif
static void output_digit( unsigned char n )
#endif
{
static void output_digit( unsigned char n )
#endif
{
- output_char( n <= 9 ? '0'+n :
- (lower_case ? n+(char)('a'-10) : n+(char)('A'-10)), p );
+ register unsigned char c;
+ if (n <= 9)
+ c = n + '0';
+ else if (lower_case)
+ c = n + (unsigned char)('a' - 10);
+ else
+ c = n + (unsigned char)('A' - 10);
+ output_char( c, p );
}
/*--------------------------------------------------------------------------*/
}
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
#if defined SDCC_STACK_AUTO
/*--------------------------------------------------------------------------*/
#if defined SDCC_STACK_AUTO
-static void calculate_digit( value_t* value, unsigned char radix )
+static void calculate_digit( value_t _AUTOMEM * value, unsigned char radix )
+ unsigned long ul = value->ul;
+ unsigned char _AUTOMEM * pb4 = &value->byte[4];
+ unsigned char i = 32;
- for( i = 32; i != 0; i-- )
- value->byte[4] = (value->byte[4] << 1) | ((value->ul >> 31) & 0x01);
- value->ul <<= 1;
+ *pb4 = (*pb4 << 1) | ((ul >> 31) & 0x01);
+ ul <<= 1;
- if (radix <= value->byte[4] )
- value->byte[4] -= radix;
- value->ul |= 1;
- }
+ *pb4 -= radix;
+ ul |= 1;
+ } while (--i);
+ value->ul = ul;
}
#else
static void calculate_digit( unsigned char radix )
{
}
#else
static void calculate_digit( unsigned char radix )
{
+ register unsigned long ul = value.ul;
+ register unsigned char b4 = value.byte[4];
+ register unsigned char i = 32;
- for( i = 32; i != 0; i-- )
- value.byte[4] = (value.byte[4] << 1) | ((value.ul >> 31) & 0x01);
- value.ul <<= 1;
+ b4 = (b4 << 1);
+ b4 |= (ul >> 31) & 0x01;
+ ul <<= 1;
- if (radix <= value.byte[4] )
- value.byte[4] -= radix;
- value.ul |= 1;
- }
+ b4 -= radix;
+ ul |= 1;
+ } while (--i);
+ value.ul = ul;
+ value.byte[4] = b4;
prefix_sign = 0;
prefix_space = 0;
signed_argument = 0;
prefix_sign = 0;
prefix_space = 0;
signed_argument = 0;
char_argument = 0;
long_argument = 0;
float_argument = 0;
char_argument = 0;
long_argument = 0;
float_argument = 0;
width = 0;
decimals = -1;
width = 0;
decimals = -1;
case 'P':
PTR = va_arg(ap,ptr_t);
case 'P':
PTR = va_arg(ap,ptr_t);
-#ifdef SDCC_ds390
- output_char(memory_id[(value.byte[3] > 3) ? 4 : value.byte[3]], p );
+#if defined (SDCC_ds390)
+ {
+ unsigned char memtype = value.byte[3];
+ if (memtype > 0x80)
+ c = 'C';
+ else if (memtype > 0x60)
+ c = 'P';
+ else if (memtype > 0x40)
+ c = 'I';
+ else
+ c = 'X';
+ }
+ output_char(c, p);
output_char(':', p);
output_char('0', p);
output_char('x', p);
output_char(':', p);
output_char('0', p);
output_char('x', p);
OUTPUT_2DIGITS( value.byte[1] );
OUTPUT_2DIGITS( value.byte[0] );
charsOutputted += 10;
OUTPUT_2DIGITS( value.byte[1] );
OUTPUT_2DIGITS( value.byte[0] );
charsOutputted += 10;
-#else
- output_char( memory_id[(value.byte[2] > 3) ? 4 : value.byte[2]], p );
+#elif defined (SDCC_mcs51)
+ {
+ unsigned char memtype = value.byte[2];
+ if (memtype > 0x80)
+ c = 'C';
+ else if (memtype > 0x60)
+ c = 'P';
+ else if (memtype > 0x40)
+ c = 'I';
+ else
+ c = 'X';
+ }
+ output_char(c, p);
output_char(':', p);
output_char('0', p);
output_char('x', p);
output_char(':', p);
output_char('0', p);
output_char('x', p);
- if ((value.byte[2] != 0x00 /* DSEG */) &&
- (value.byte[2] != 0x03 /* SSEG */))
+ if ((c != 'I' /* idata */) &&
+ (c != 'P' /* pdata */))
{
OUTPUT_2DIGITS( value.byte[1] );
charsOutputted += 2;
}
OUTPUT_2DIGITS( value.byte[0] );
charsOutputted += 6;
{
OUTPUT_2DIGITS( value.byte[1] );
charsOutputted += 2;
}
OUTPUT_2DIGITS( value.byte[0] );
charsOutputted += 6;
+#else
+ output_char('0', p);
+ output_char('x', p);
+ OUTPUT_2DIGITS( value.byte[1] );
+ OUTPUT_2DIGITS( value.byte[0] );
+ charsOutputted += 6;
for (lval = val; lval; lval = lval->next, pNum++)
{
for (lval = val; lval; lval = lval->next, pNum++)
{
/* check the declaration */
checkDecl (lval->sym, 0);
/* check the declaration */
checkDecl (lval->sym, 0);
lval->sym->ismyparm = 1;
lval->sym->localof = currFunc;
lval->sym->ismyparm = 1;
lval->sym->localof = currFunc;
/* if automatic variables r 2b stacked */
if (options.stackAuto || IFFUNC_ISREENT (currFunc->type))
{
/* if automatic variables r 2b stacked */
if (options.stackAuto || IFFUNC_ISREENT (currFunc->type))
{
if (lval->sym)
lval->sym->onStack = 1;
if (lval->sym)
lval->sym->onStack = 1;
- /* otherwise depending on the memory model */
- SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
+ /* otherwise depending on the memory model */
+ SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
port->mem.default_local_map;
port->mem.default_local_map;
- if (options.model == MODEL_SMALL)
- {
- /* note here that we put it into the overlay segment
- first, we will remove it from the overlay segment
- after the overlay determination has been done */
- if (!options.noOverlay)
- {
- SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
- overlay;
- }
- }
- else if (options.model == MODEL_MEDIUM)
- {
- SPEC_SCLS (lval->etype) = S_PDATA;
- }
- else
- {
- SPEC_SCLS (lval->etype) = S_XDATA;
- }
+ if (options.model == MODEL_SMALL)
+ {
+ /* note here that we put it into the overlay segment
+ first, we will remove it from the overlay segment
+ after the overlay determination has been done */
+ if (!options.noOverlay)
+ {
+ SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
+ overlay;
+ }
+ }
+ else if (options.model == MODEL_MEDIUM)
+ {
+ SPEC_SCLS (lval->etype) = S_PDATA;
+ }
+ else
+ {
+ SPEC_SCLS (lval->etype) = S_XDATA;
+ }
allocIntoSeg (lval->sym);
}
}
allocIntoSeg (lval->sym);
}
}
for (lval = val; lval; lval = lval->next)
{
for (lval = val; lval; lval = lval->next)
{
/* unmark is myparm */
lval->sym->ismyparm = 0;
/* unmark is myparm */
lval->sym->ismyparm = 0;
addSym (SymbolTab, lval->sym, lval->sym->name,
lval->sym->level, lval->sym->block, 1);
lval->sym->_isparm = 1;
addSym (SymbolTab, lval->sym, lval->sym->name,
lval->sym->level, lval->sym->block, 1);
lval->sym->_isparm = 1;
- if (!isinSet (operKeyReset, lval->sym)) {
- addSet(&operKeyReset, lval->sym);
- }
+ if (!isinSet (operKeyReset, lval->sym))
+ {
+ addSet(&operKeyReset, lval->sym);
+ }
void
allocLocal (symbol * sym)
{
void
allocLocal (symbol * sym)
{
/* generate an unique name */
SNPRINTF (sym->rname, sizeof(sym->rname),
"%s%s_%s_%d_%d",
/* generate an unique name */
SNPRINTF (sym->rname, sizeof(sym->rname),
"%s%s_%s_%d_%d",
- if (SPEC_SCLS (sym->etype) == S_DATA)
+ if ((SPEC_SCLS (sym->etype) == S_DATA) || (SPEC_SCLS (sym->etype) == S_REGISTER))
{
SPEC_OCLS (sym->etype) = (options.noOverlay ? data : overlay);
allocIntoSeg (sym);
{
SPEC_OCLS (sym->etype) = (options.noOverlay ? data : overlay);
allocIntoSeg (sym);
overlay analysis has been done */
if (options.model == MODEL_SMALL) {
SPEC_OCLS (sym->etype) =
overlay analysis has been done */
if (options.model == MODEL_SMALL) {
SPEC_OCLS (sym->etype) =
- (options.noOverlay ? port->mem.default_local_map
- : overlay);
+ (options.noOverlay ? port->mem.default_local_map : overlay);
} else {
SPEC_OCLS (sym->etype) = port->mem.default_local_map;
}
} else {
SPEC_OCLS (sym->etype) = port->mem.default_local_map;
}
/*-------------------------------------------------------------------------
/*-------------------------------------------------------------------------
- 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)
Written By - Sandeep Dutta . sandeep.dutta@usa.net (1998)
and - Jean-Louis VERN.jlvern@writeme.com (1999)
static unsigned short rbank = -1;
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
#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 && \
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")
#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 */
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")
#define CLRC emitcode("clr","c")
#define SETC emitcode("setb","c")
+static void
+emitLabel (symbol *tlbl)
+{
+ emitcode ("", "%05d$:", (tlbl->key +100));
+}
+
/*-----------------------------------------------------------------*/
/* mcs51_emitDebuggerSymbol - associate the current code location */
/* with a debugger symbol */
/*-----------------------------------------------------------------*/
/* mcs51_emitDebuggerSymbol - associate the current code location */
/* with a debugger symbol */
emitcode("mov", "a,%s", x);
}
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 */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* movc - moves specified value into the carry */
/*-----------------------------------------------------------------*/
static bool
pushReg (int index, bool bits_pushed)
{
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)
if (reg->type == REG_BIT)
{
if (!bits_pushed)
static bool
popReg (int index, bool bits_popped)
{
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)
if (reg->type == REG_BIT)
{
if (!bits_popped)
ic->rUsed = bitVectSetBit (ic->rUsed, R0_IDX);
(*aopp)->type = AOP_R0;
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 */
}
/* if no usage of r1 then return it */
ic->rUsed = bitVectSetBit (ic->rUsed, R1_IDX);
(*aopp)->type = AOP_R1;
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 */
}
/* now we know they both have usage */
/* push it if not already pushed */
if (ic->op == IPUSH)
{
/* 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",
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;
_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 */
}
/* if r1 not used then */
/* push it if not already pushed */
if (ic->op == IPUSH)
{
/* 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",
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;
_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 */
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 */
/* 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))
+ {
- 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))
+ {
- return mcs51_regWithIdx (R1_IDX);
- }
+ return REG_WITH_INDEX (R1_IDX);
}
/* now this is REALLY the end of the world */
}
/* now this is REALLY the end of the world */
for (i=0; i<freeRegs->size; i++)
{
if (bitVectBitValue(freeRegs,i))
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);
if (offset>=size)
{
freeBitVect(freeRegs);
SNPRINTF (buffer, sizeof(buffer), "@%s", aop->aopu.aop_ptr->name);
return Safe_strdup(buffer);
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);
case AOP_DPTR:
if (aop->code && aop->coff==0 && offset>=1) {
emitcode ("mov", "a,#0x%02x", offset);
else
{
SNPRINTF (buffer, sizeof(buffer),
else
{
SNPRINTF (buffer, sizeof(buffer),
- "#%s", aop->aopu.aop_immd.aop_immd1);
+ "#%s",
+ aop->aopu.aop_immd.aop_immd1);
}
return Safe_strdup(buffer);
}
return Safe_strdup(buffer);
else
{
SNPRINTF (buffer, sizeof(buffer),
else
{
SNPRINTF (buffer, sizeof(buffer),
- "%s", aop->aopu.aop_dir);
+ "%s",
+ aop->aopu.aop_dir);
}
return Safe_strdup(buffer);
}
return Safe_strdup(buffer);
else
{
SNPRINTF (buffer, sizeof(buffer),
else
{
SNPRINTF (buffer, sizeof(buffer),
- "%s", aop->aopu.aop_dir);
+ "%s",
+ aop->aopu.aop_dir);
}
if (strcmp (buffer, s) || bvolatile)
}
if (strcmp (buffer, s) || bvolatile)
- 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);
/* set C, if a == 0 */
tlbl = newiTempLabel (NULL);
emitcode ("cjne", "a,#0x01,%05d$", tlbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
outBitC (IC_RESULT (ic));
release:
outBitC (IC_RESULT (ic));
release:
MOVA (l);
emitcode ("cjne", "a,#0xFF,%05d$", tlbl->key + 100);
}
MOVA (l);
emitcode ("cjne", "a,#0xFF,%05d$", tlbl->key + 100);
}
- emitcode ("", "%05d$:", tlbl->key + 100);
outBitC (IC_RESULT(ic));
goto release;
}
outBitC (IC_RESULT(ic));
goto release;
}
- 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 (reg->type == REG_BIT)
{
emitcode ("mov", "a,%s", reg->base);
{
if (bitVectBitValue (rsave, R0_IDX))
{
{
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");
}
emitcode ("mov", "r0,%s", spname);
MOVA ("r0");
{
if (bitVectBitValue (rsave, i))
{
{
if (bitVectBitValue (rsave, i))
{
- regs * reg = mcs51_regWithIdx (i);
+ regs * reg = REG_WITH_INDEX (i);
if (i == R0_IDX)
{
emitcode ("pop", "acc");
if (i == R0_IDX)
{
emitcode ("pop", "acc");
}
if (bitVectBitValue (rsave, R0_IDX))
{
}
if (bitVectBitValue (rsave, R0_IDX))
{
- emitcode ("pop", "%s", mcs51_regWithIdx (R0_IDX)->dname);
+ emitcode ("pop", "%s", REG_WITH_INDEX (R0_IDX)->dname);
- 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");
emitcode ("mov", "r0,%s", spname);
emitcode ("dec", "r0");
emitcode ("movx", "a,@r0");
{
if (bitVectBitValue (rsave, i))
{
{
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)
emitcode ("dec", "r0");
emitcode ("movx", "a,@r0");
if (i == R0_IDX)
if (!ic)
{
/* Assume r0 is available for use. */
if (!ic)
{
/* Assume r0 is available for use. */
- r = mcs51_regWithIdx (R0_IDX);;
+ r = REG_WITH_INDEX (R0_IDX);;
if (!ic)
{
/* Assume r0 is available for use. */
if (!ic)
{
/* Assume r0 is available for use. */
- r = mcs51_regWithIdx (R0_IDX);;
+ r = REG_WITH_INDEX (R0_IDX);;
{
char *l = aopGet (IC_LEFT (sic), offset, FALSE, FALSE);
if (strcmp (l, fReturn[offset]))
{
char *l = aopGet (IC_LEFT (sic), offset, FALSE, FALSE);
if (strcmp (l, fReturn[offset]))
emitcode ("mov", "%s,%s", fReturn[offset], l);
emitcode ("mov", "%s,%s", fReturn[offset], l);
/* make the call */
emitcode ("ret", "");
/* make the call */
emitcode ("ret", "");
- emitcode ("", "%05d$:", (rlbl->key + 100));
else
for (i = 0; i < ic->parmBytes; i++)
emitcode ("dec", "%s", spname);
else
for (i = 0; i < ic->parmBytes; i++)
emitcode ("dec", "%s", spname);
}
// /* if register bank was saved then unsave them */
}
// /* 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)
{
/* 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,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 */
}
else
/* do it the hard way */
emitcode ("setb", "c");
emitcode ("jbc", "ea,%05d$", (tlbl->key + 100)); /* atomic test & clear */
emitcode ("clr", "c");
emitcode ("setb", "c");
emitcode ("jbc", "ea,%05d$", (tlbl->key + 100)); /* atomic test & clear */
emitcode ("clr", "c");
- emitcode ("", "%05d$:", (tlbl->key + 100));
emitcode ("push", "psw"); /* save old ea via c in psw */
}
}
emitcode ("push", "psw"); /* save old ea via c in psw */
}
}
{
if (bitVectBitValue (sym->regsUsed, i) ||
(mcs51_ptrRegReq && (i == R0_IDX || i == R1_IDX)))
{
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)
{
}
}
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))
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);
freeBitVect (regsUnneeded);
freeBitVect (regsUsed);
- emitcode ("", "%05d$:", tlbl->key + 100);
same */
if (sameRegs (AOP (IC_LEFT (ic)), AOP (IC_RESULT (ic))))
{
same */
if (sameRegs (AOP (IC_LEFT (ic)), AOP (IC_RESULT (ic))))
{
if (icount > 3)
{
MOVA (aopGet (IC_LEFT (ic), 0, FALSE, FALSE));
if (icount > 3)
{
MOVA (aopGet (IC_LEFT (ic), 0, FALSE, FALSE));
- emitcode ("inc", "%s", aopGet (IC_LEFT (ic), 0, FALSE, FALSE));
+ {
+ emitcode ("inc", "%s", aopGet (IC_LEFT (ic), 0, FALSE, FALSE));
+ }
{
emitcode ("jz", "%05d$", tlbl->key + 100);
emitcode ("mov", "a,%s", one);
{
emitcode ("jz", "%05d$", tlbl->key + 100);
emitcode ("mov", "a,%s", one);
- emitcode ("", "%05d$:", tlbl->key + 100);
static void
genPlusBits (iCode * ic)
{
static void
genPlusBits (iCode * ic)
{
- D(emitcode ("; genPlusBits",""));
+ D (emitcode (";", "genPlusBits"));
if (AOP_TYPE (IC_RESULT (ic)) == AOP_CRY)
{
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 ("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));
outBitC (IC_RESULT (ic));
}
else
outBitC (IC_RESULT (ic));
}
else
operand *leftOp, *rightOp;
operand * op;
operand *leftOp, *rightOp;
operand * op;
+ D (emitcode (";", "genPlus"));
- D(emitcode ("; genPlus",""));
aopOp (IC_LEFT (ic), ic, FALSE);
aopOp (IC_RIGHT (ic), ic, FALSE);
aopOp (IC_LEFT (ic), ic, FALSE);
aopOp (IC_RIGHT (ic), ic, FALSE);
- emitcode ("", "%05d$:", tlbl->key + 100);
- emitcode ("dec", "%s", l);
+ {
+ emitcode ("dec", "%s", l);
+ }
if (AOP_NEEDSACC (IC_RESULT (ic)))
aopPut (IC_RESULT (ic), "a", 0);
if (AOP_NEEDSACC (IC_RESULT (ic)))
aopPut (IC_RESULT (ic), "a", 0);
emitcode ("rlc", "a");
emitcode ("subb", "a,acc");
while (size--)
emitcode ("rlc", "a");
emitcode ("subb", "a,acc");
while (size--)
- aopPut (result, "a", offset++);
+ {
+ aopPut (result, "a", offset++);
+ }
- while (size--)
- aopPut (result, zero, offset++);
+ {
+ while (size--)
+ {
+ aopPut (result, zero, offset++);
+ }
+ }
{
symbol *lbl = newiTempLabel (NULL);
{
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");
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));
outBitC (IC_RESULT (ic));
}
else
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 ("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));
aopPut (IC_RESULT (ic), "a", 0);
addSign (IC_RESULT (ic), MSB16, SPEC_USIGN (getSpec (operandType (IC_RESULT (ic)))));
}
aopPut (IC_RESULT (ic), "a", 0);
addSign (IC_RESULT (ic), MSB16, SPEC_USIGN (getSpec (operandType (IC_RESULT (ic)))));
}
- D(emitcode ("; genMinus",""));
+ D (emitcode (";", "genMinus"));
aopOp (IC_LEFT (ic), ic, FALSE);
aopOp (IC_RIGHT (ic), ic, FALSE);
aopOp (IC_LEFT (ic), ic, FALSE);
aopOp (IC_RIGHT (ic), ic, FALSE);
operand * right,
operand * result)
{
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);
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;
bool runtimeSign, compiletimeSign;
bool lUnsigned, rUnsigned, pushedB;
- D(emitcode ("; genMultOneByte",""));
+ D (emitcode (";", "genMultOneByte"));
if (size < 1 || size > 2)
{
if (size < 1 || size > 2)
{
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
emitcode ("mov", "b,a");
}
}
emitcode ("mov", "b,a");
}
}
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
emitcode ("addc", "a,#0");
emitcode ("xch", "a,b");
}
emitcode ("addc", "a,#0");
emitcode ("xch", "a,b");
}
- emitcode ("", "%05d$:", (lbl->key + 100));
}
aopPut (result, "a", 0);
if (size == 2)
}
aopPut (result, "a", 0);
if (size == 2)
operand *right = IC_RIGHT (ic);
operand *result = IC_RESULT (ic);
operand *right = IC_RIGHT (ic);
operand *result = IC_RESULT (ic);
- D(emitcode ("; genMult",""));
+ D (emitcode (";", "genMult"));
/* assign the asmops */
aopOp (left, ic, FALSE);
/* assign the asmops */
aopOp (left, ic, FALSE);
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
emitcode ("mov", "b,a");
}
}
emitcode ("mov", "b,a");
}
}
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
emitcode ("cpl", "F0"); /* complement sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
emitcode ("jnb", "F0,%05d$", (lbl->key + 100));
emitcode ("cpl", "a"); /* lsb 2's complement */
emitcode ("inc", "a");
emitcode ("jnb", "F0,%05d$", (lbl->key + 100));
emitcode ("cpl", "a"); /* lsb 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
accuse = aopPut (result, "a", 0);
if (size > 0)
accuse = aopPut (result, "a", 0);
if (size > 0)
operand *right = IC_RIGHT (ic);
operand *result = IC_RESULT (ic);
operand *right = IC_RIGHT (ic);
operand *result = IC_RESULT (ic);
- D(emitcode ("; genDiv",""));
+ D (emitcode (";", "genDiv"));
/* assign the amsops */
aopOp (left, ic, FALSE);
/* assign the amsops */
aopOp (left, ic, FALSE);
lbl2 = newiTempLabel (NULL);
emitcode ("sjmp", "%05d$", (lbl2->key + 100));
}
lbl2 = newiTempLabel (NULL);
emitcode ("sjmp", "%05d$", (lbl2->key + 100));
}
- emitcode ("", "%05d$:", (lbl->key + 100));
aopPut (result, "a", 0);
while (size--)
aopPut (result, zero, offset++);
if (lbl2)
{
aopPut (result, "a", 0);
while (size--)
aopPut (result, zero, offset++);
if (lbl2)
{
- emitcode ("", "%05d$:", (lbl2->key + 100));
emitcode ("jnb", "acc.7,%05d$", (lbl->key + 100));
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
emitcode ("jnb", "acc.7,%05d$", (lbl->key + 100));
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
emitcode ("mov", "b,a");
}
}
emitcode ("mov", "b,a");
}
}
emitcode ("setb", "F0"); /* set sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
emitcode ("setb", "F0"); /* set sign flag */
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
emitcode ("jnb", "F0,%05d$", (lbl->key + 100));
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
emitcode ("jnb", "F0,%05d$", (lbl->key + 100));
emitcode ("cpl", "a"); /* 2's complement */
emitcode ("inc", "a");
- emitcode ("", "%05d$:", (lbl->key + 100));
aopPut (result, "a", 0);
if (size > 0)
aopPut (result, "a", 0);
if (size > 0)
operand *right = IC_RIGHT (ic);
operand *result = IC_RESULT (ic);
operand *right = IC_RIGHT (ic);
operand *result = IC_RESULT (ic);
- D(emitcode ("; genMod",""));
+ D (emitcode (";", "genMod"));
/* assign the asmops */
aopOp (left, ic, FALSE);
/* assign the asmops */
aopOp (left, ic, FALSE);
symbol *tlbl = newiTempLabel (NULL);
char *inst;
symbol *tlbl = newiTempLabel (NULL);
char *inst;
- D(emitcode ("; genIfxJump",""));
+ D (emitcode (";", "genIfxJump"));
/* if true label then we jump if condition
supplied is true */
/* if true label then we jump if condition
supplied is true */
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", jlbl->key + 100);
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", jlbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
/* mark the icode as generated */
ic->generated = 1;
/* mark the icode as generated */
ic->generated = 1;
unsigned long lit = 0L;
bool rightInB;
unsigned long lit = 0L;
bool rightInB;
- D(emitcode ("; genCmp",""));
+ D (emitcode (";", "genCmp"));
/* if left & right are bit variables */
if (AOP_TYPE (left) == AOP_CRY &&
/* 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);
aopGet (left, offset, FALSE, FALSE),
aopGet (right, offset, FALSE, FALSE),
lbl->key + 100);
- emitcode ("", "%05d$:", lbl->key + 100);
+ {
+ emitcode ("rlc", "a");
+ }
{
pushedB = pushB ();
rightInB++;
{
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");
}
emitcode ("xrl", "b,#0x80");
emitcode ("subb", "a,b");
ifx conditional branch then generate
code a little differently */
if (ifx)
ifx conditional branch then generate
code a little differently */
if (ifx)
- genIfxJump (ifx, "c", NULL, NULL, result);
+ {
+ genIfxJump (ifx, "c", NULL, NULL, result);
+ }
+ {
+ outBitC (result);
+ }
/* leave the result in acc */
}
}
/* leave the result in acc */
}
}
sym_link *letype, *retype;
int sign;
sym_link *letype, *retype;
int sign;
- D(emitcode ("; genCmpGt",""));
+ D (emitcode (";", "genCmpGt"));
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
sym_link *letype, *retype;
int sign;
sym_link *letype, *retype;
int sign;
- D(emitcode ("; genCmpLt",""));
+ D (emitcode (";", "genCmpLt"));
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
int offset = 0;
unsigned long lit = 0L;
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 */
/* 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--)
{
/* right is a pointer reg need both a & b */
while (size--)
{
//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");
//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++;
MOVA (aopGet (right, offset, FALSE, FALSE));
emitcode ("cjne", "a,b,%05d$", lbl->key + 100);
offset++;
{
symbol *tlbl = newiTempLabel (NULL);
{
symbol *tlbl = newiTempLabel (NULL);
+ D (emitcode (";", "gencjne"));
+
gencjneshort (left, right, lbl);
emitcode ("mov", "a,%s", one);
emitcode ("sjmp", "%05d$", tlbl->key + 100);
gencjneshort (left, right, lbl);
emitcode ("mov", "a,%s", one);
emitcode ("sjmp", "%05d$", tlbl->key + 100);
- emitcode ("", "%05d$:", lbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
}
/*-----------------------------------------------------------------*/
}
/*-----------------------------------------------------------------*/
bool swappedLR = FALSE;
operand *left, *right, *result;
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);
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 ("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));
}
/* if true label then we jump if condition
supplied is true */
}
/* if true label then we jump if condition
supplied is true */
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_FALSE (ifx)->key + 100);
}
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_FALSE (ifx)->key + 100);
}
- emitcode ("", "%05d$:", tlbl->key + 100);
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_TRUE (ifx)->key + 100);
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_TRUE (ifx)->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
}
else
{
symbol *lbl = newiTempLabel (NULL);
emitcode ("sjmp", "%05d$", lbl->key + 100);
}
else
{
symbol *lbl = newiTempLabel (NULL);
emitcode ("sjmp", "%05d$", lbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
freeForBranchAsmop (result);
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_FALSE (ifx)->key + 100);
freeForBranchAsmop (result);
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_FALSE (ifx)->key + 100);
- emitcode ("", "%05d$:", lbl->key + 100);
}
}
/* mark the icode as generated */
}
}
/* 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 ("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));
}
/* c = 1 if egal */
if (AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result))
}
/* 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 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);
{
sym_link *type = operandType(op);
sym_link *retype = getSpec (type);
operand *left, *right, *result;
symbol *tlbl;
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
/* 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);
toBoolean (left);
emitcode ("jz", "%05d$", tlbl->key + 100);
toBoolean (right);
- emitcode ("", "%05d$:", tlbl->key + 100);
operand *left, *right, *result;
symbol *tlbl;
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
/* 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);
toBoolean (left);
emitcode ("jnz", "%05d$", tlbl->key + 100);
toBoolean (right);
- emitcode ("", "%05d$:", tlbl->key + 100);
{
symbol *nlbl = newiTempLabel (NULL);
emitcode ("sjmp", "%05d$", nlbl->key + 100);
{
symbol *nlbl = newiTempLabel (NULL);
emitcode ("sjmp", "%05d$", nlbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
freeForBranchAsmop (result);
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_TRUE (ic)->key + 100);
freeForBranchAsmop (result);
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_TRUE (ic)->key + 100);
- emitcode ("", "%05d$:", nlbl->key + 100);
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_FALSE (ic)->key + 100);
freeForBranchAsmop (right);
freeForBranchAsmop (left);
emitcode ("ljmp", "%05d$", IC_FALSE (ic)->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
int bytelit = 0;
char buffer[10];
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);
aopOp ((left = IC_LEFT (ic)), ic, FALSE);
aopOp ((right = IC_RIGHT (ic)), ic, FALSE);
if (size)
{
emitcode ("clr", "c");
if (size)
{
emitcode ("clr", "c");
- emitcode ("", "%05d$:", tlbl->key + 100);
}
// if(left & literal)
else
}
// if(left & literal)
else
if (ifx)
jmpTrueOrFalse (ifx, tlbl, left, right, result);
else
if (ifx)
jmpTrueOrFalse (ifx, tlbl, left, right, result);
else
- emitcode ("", "%05d$:", tlbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
outBitC (result);
}
else if (ifx)
jmpTrueOrFalse (ifx, tlbl, left, right, result);
else
outBitC (result);
}
else if (ifx)
jmpTrueOrFalse (ifx, tlbl, left, right, result);
else
- emitcode ("", "%05d$:", tlbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
symbol *tlbl = newiTempLabel (NULL);
emitcode ("jnz", "%05d$", tlbl->key + 100);
CLRC;
symbol *tlbl = newiTempLabel (NULL);
emitcode ("jnz", "%05d$", tlbl->key + 100);
CLRC;
- emitcode ("", "%05d$:", tlbl->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
outBitC (result);
}
else if (ifx)
jmpTrueOrFalse (ifx, tlbl, left, right, result);
else
outBitC (result);
}
else if (ifx)
jmpTrueOrFalse (ifx, tlbl, left, right, result);
else
- emitcode ("", "%05d$:", tlbl->key + 100);
unsigned long lit = 0L;
int bytelit = 0;
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);
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 ("jnb", "%s,%05d$", AOP (left)->aopu.aop_dir, (tlbl->key + 100));
emitcode ("cpl", "c");
- emitcode ("", "%05d$:", (tlbl->key + 100));
// if(!size && ifx), conditional oper: if(left ^ right)
symbol *tlbl = newiTempLabel (NULL);
int sizer = max (AOP_SIZE (left), AOP_SIZE (right));
// 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)
emitcode ("setb", "c");
while (sizer--)
- emitcode ("", "%05d$:", tlbl->key + 100);
outBitC (result);
}
else if (ifx)
outBitC (result);
}
else if (ifx)
for (; (size--); offset++)
{
// normal case
for (; (size--); offset++)
{
// normal case
- // result = left & right
+ // result = left ^ right
if (AOP_TYPE (right) == AOP_LIT)
{
bytelit = (int) ((lit >> (offset * 8)) & 0x0FFL);
if (AOP_TYPE (right) == AOP_LIT)
{
bytelit = (int) ((lit >> (offset * 8)) & 0x0FFL);
genRRC (iCode * ic)
{
operand *left, *result;
genRRC (iCode * ic)
{
operand *left, *result;
- D(emitcode ("; genRRC",""));
+ D (emitcode (";", "genRRC"));
/* rotate right with carry */
left = IC_LEFT (ic);
/* rotate right with carry */
left = IC_LEFT (ic);
genRLC (iCode * ic)
{
operand *left, *result;
genRLC (iCode * ic)
{
operand *left, *result;
- D(emitcode ("; genRLC",""));
+ D (emitcode (";", "genRLC"));
/* rotate right with carry */
left = IC_LEFT (ic);
/* rotate right with carry */
left = IC_LEFT (ic);
}
emitcode("rlc","a"); /* bit0 will be written later */
if (AOP_SIZE (result) > 1)
}
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);
while (size--)
{
l = aopGet (left, offset, FALSE, FALSE);
{
operand *left, *result;
{
operand *left, *result;
- D(emitcode ("; genGetHbit",""));
+ D (emitcode (";", "genGetHbit"));
left = IC_LEFT (ic);
result = IC_RESULT (ic);
left = IC_LEFT (ic);
result = IC_RESULT (ic);
operand *left, *right, *result;
int shCount;
operand *left, *right, *result;
int shCount;
- D(emitcode ("; genGetAbit",""));
+ D (emitcode (";", "genGetAbit"));
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
operand *left, *right, *result;
int offset;
operand *left, *right, *result;
int offset;
- D(emitcode ("; genGetByte",""));
+ D (emitcode (";", "genGetByte"));
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
operand *left, *right, *result;
int offset;
operand *left, *right, *result;
int offset;
- D(emitcode ("; genGetWord",""));
+ D (emitcode (";", "genGetWord"));
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
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 ("jnb", "acc.%d,%05d$", 7 - shCount, tlbl->key + 100);
emitcode ("orl", "a,#0x%02x",
(unsigned char) ~SRMask[shCount]);
- emitcode ("", "%05d$:", tlbl->key + 100);
- aopPut (result, l, offr);
+ {
+ aopPut (result, l, offr);
+ }
else
{
/* MSB sign in acc.7 ! */
else
{
/* MSB sign in acc.7 ! */
emitcode ("orl", "a,#0x%02x",
(unsigned char) ~SRMask[shCount]); // 111AAAAA:BBBCCCCC
emitcode ("orl", "a,#0x%02x",
(unsigned char) ~SRMask[shCount]); // 111AAAAA:BBBCCCCC
- emitcode ("", "%05d$:", tlbl->key + 100);
break; // SSSSAAAA:BBBCCCCC
case 6: // AABBBBBB:CCDDDDDD
break; // SSSSAAAA:BBBCCCCC
case 6: // AABBBBBB:CCDDDDDD
emitcode ("orl", "a,#0x%02x",
(unsigned char) ~SRMask[shCount]); // 111111AA:BBBBBBCC
emitcode ("orl", "a,#0x%02x",
(unsigned char) ~SRMask[shCount]); // 111111AA:BBBBBBCC
- emitcode ("", "%05d$:", tlbl->key + 100);
break;
case 7: // ABBBBBBB:CDDDDDDD
break;
case 7: // ABBBBBBB:CDDDDDDD
emitcode ("orl", "a,#0x%02x",
(unsigned char) ~SRMask[shCount]); // 1111111A:BBBBBBBC
emitcode ("orl", "a,#0x%02x",
(unsigned char) ~SRMask[shCount]); // 1111111A:BBBBBBBC
- emitcode ("", "%05d$:", tlbl->key + 100);
static void
genlshOne (operand * result, operand * left, int shCount)
{
static void
genlshOne (operand * result, operand * left, int shCount)
{
- D(emitcode ("; genlshOne",""));
+ D (emitcode (";", "genlshOne"));
shiftL1Left2Result (left, LSB, result, LSB, shCount);
}
shiftL1Left2Result (left, LSB, result, LSB, shCount);
}
- D(emitcode ("; genlshTwo",""));
+ D (emitcode (";", "genlshTwo"));
size = getDataSize (result);
size = getDataSize (result);
- D(emitcode ("; genlshFour",""));
+ D (emitcode (";", "genlshFour"));
size = AOP_SIZE (result);
size = AOP_SIZE (result);
}
else if (shCount >= (size * 8))
}
else if (shCount >= (size * 8))
- while (size--)
- aopPut (result, zero, size);
+ {
+ while (size--)
+ {
+ aopPut (result, zero, size);
+ }
+ }
symbol *tlbl, *tlbl1;
bool pushedB;
symbol *tlbl, *tlbl1;
bool pushedB;
- D(emitcode ("; genLeftShift",""));
+ D (emitcode (";", "genLeftShift"));
right = IC_RIGHT (ic);
left = IC_LEFT (ic);
right = IC_RIGHT (ic);
left = IC_LEFT (ic);
largest size of an object can be only 32 bits ) */
pushedB = pushB ();
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);
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);
l = aopGet (left, 0, FALSE, FALSE);
MOVA (l);
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
emitcode ("add", "a,acc");
emitcode ("add", "a,acc");
- emitcode ("", "%05d$:", tlbl1->key + 100);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
aopPut (result, "a", 0);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
aopPut (result, "a", 0);
reAdjustPreg (AOP (result));
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
reAdjustPreg (AOP (result));
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
l = aopGet (result, offset, FALSE, FALSE);
MOVA (l);
emitcode ("add", "a,acc");
l = aopGet (result, offset, FALSE, FALSE);
MOVA (l);
emitcode ("add", "a,acc");
}
reAdjustPreg (AOP (result));
}
reAdjustPreg (AOP (result));
- emitcode ("", "%05d$:", tlbl1->key + 100);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
release:
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
release:
genrshOne (operand * result, operand * left,
int shCount, int sign)
{
genrshOne (operand * result, operand * left,
int shCount, int sign)
{
- D(emitcode ("; genrshOne",""));
+ D (emitcode (";", "genrshOne"));
shiftR1Left2Result (left, LSB, result, LSB, shCount, sign);
}
shiftR1Left2Result (left, LSB, result, LSB, shCount, sign);
}
genrshTwo (operand * result, operand * left,
int shCount, int 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)
/* 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);
else
movLeft2Result (left, MSB16, result, LSB, sign);
addSign (result, MSB16, sign);
genrshFour (operand * result, operand * left,
int shCount, int 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)
/* if shifting more that 3 bytes */
if (shCount >= 24)
{
shCount -= 8;
if (shCount == 1)
{
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);
else if (shCount == 0)
{
movLeft2Result (left, MSB16, result, LSB, 0);
symbol *tlbl, *tlbl1;
bool pushedB;
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 */
/* 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 ();
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);
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);
l = aopGet (left, 0, FALSE, FALSE);
MOVA (l);
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
emitcode ("mov", "c,ov");
emitcode ("rrc", "a");
emitcode ("mov", "c,ov");
emitcode ("rrc", "a");
- emitcode ("", "%05d$:", tlbl1->key + 100);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
aopPut (result, "a", 0);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
aopPut (result, "a", 0);
reAdjustPreg (AOP (result));
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
reAdjustPreg (AOP (result));
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
emitcode ("mov", "c,ov");
while (size--)
{
emitcode ("mov", "c,ov");
while (size--)
{
aopPut (result, "a", offset--);
}
reAdjustPreg (AOP (result));
aopPut (result, "a", offset--);
}
reAdjustPreg (AOP (result));
- emitcode ("", "%05d$:", tlbl1->key + 100);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
symbol *tlbl, *tlbl1;
bool 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 */
/* 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 ();
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);
emitcode ("inc", "b");
freeAsmop (right, NULL, ic, TRUE);
aopOp (left, ic, FALSE);
if (!sameRegs (AOP (left), AOP (result)) &&
AOP_SIZE (result) > 1)
{
if (!sameRegs (AOP (left), AOP (result)) &&
AOP_SIZE (result) > 1)
{
size = AOP_SIZE (result);
offset = 0;
while (size--)
size = AOP_SIZE (result);
offset = 0;
while (size--)
l = aopGet (left, 0, FALSE, FALSE);
MOVA (l);
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
l = aopGet (left, 0, FALSE, FALSE);
MOVA (l);
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
CLRC;
emitcode ("rrc", "a");
CLRC;
emitcode ("rrc", "a");
- emitcode ("", "%05d$:", tlbl1->key + 100);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
aopPut (result, "a", 0);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
aopPut (result, "a", 0);
reAdjustPreg (AOP (result));
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
reAdjustPreg (AOP (result));
emitcode ("sjmp", "%05d$", tlbl1->key + 100);
- emitcode ("", "%05d$:", tlbl->key + 100);
}
reAdjustPreg (AOP (result));
}
reAdjustPreg (AOP (result));
- emitcode ("", "%05d$:", tlbl1->key + 100);
emitcode ("djnz", "b,%05d$", tlbl->key + 100);
popB (pushedB);
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 ("jnb", "acc.%d,%05d$", blen - 1, tlbl->key + 100);
emitcode ("orl", "a,#0x%02x", (unsigned char) (0xff << blen));
- emitcode ("", "%05d$:", tlbl->key + 100);
}
aopPut (result, "a", offset++);
goto finish;
}
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 ("jnb", "acc.%d,%05d$", rlen - 1, tlbl->key + 100);
emitcode ("orl", "a,#0x%02x", (unsigned char) (0xff << rlen));
- emitcode ("", "%05d$:", tlbl->key + 100);
}
aopPut (result, "a", offset++);
}
}
aopPut (result, "a", offset++);
}
while (size--)
{
if (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++);
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,
/*-----------------------------------------------------------------*/
static void
genFarPointerGet (operand * left,
int size, offset;
sym_link *retype = getSpec (operandType (result));
int size, offset;
sym_link *retype = getSpec (operandType (result));
- D(emitcode ("; genGenPointerGet",""));
+ D (emitcode (";", "genGenPointerGet"));
aopOp (left, ic, FALSE);
loadDptrFromOperand (left, TRUE);
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))
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);
else
{
size = AOP_SIZE (result);
sym_link *type, *etype;
int p_type;
sym_link *type, *etype;
int p_type;
- D(emitcode ("; genPointerGet",""));
+ D (emitcode (";", "genPointerGet"));
left = IC_LEFT (ic);
result = IC_RESULT (ic);
left = IC_LEFT (ic);
result = IC_RESULT (ic);
/* special case when cast remat */
if (p_type == GPOINTER && OP_SYMBOL(left)->remat &&
/* 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)
/* now that we have the pointer type we assign
the pointer values */
switch (p_type)
genGenPointerGet (left, result, ic, pi, ifx);
break;
}
genGenPointerGet (left, result, ic, pi, ifx);
break;
}
/*-----------------------------------------------------------------*/
/* genPackBits - generates code for packed bit storage */
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
/* genPackBits - generates code for packed bit storage */
/*-----------------------------------------------------------------*/
}
emitPtrByteSet (rname, p_type, "a");
}
}
emitPtrByteSet (rname, p_type, "a");
}
int size, offset = 0;
char *l, buffer[256];
int size, offset = 0;
char *l, buffer[256];
- D(emitcode ("; genDataPointerSet",""));
+ D (emitcode (";", "genDataPointerSet"));
aopOp (right, ic, FALSE);
aopOp (right, ic, FALSE);
sym_link *retype, *letype;
sym_link *ptype = operandType (result);
sym_link *retype, *letype;
sym_link *ptype = operandType (result);
- D(emitcode ("; genNearPointerSet",""));
+ D (emitcode (";", "genNearPointerSet"));
retype = getSpec (operandType (right));
letype = getSpec (ptype);
retype = getSpec (operandType (right));
letype = getSpec (ptype);
aopOp (result, ic, FALSE);
/* if the result is rematerializable &
aopOp (result, ic, FALSE);
/* if the result is rematerializable &
genPackBits ((IS_BITFIELD (retype) ? retype : letype), right, rname, POINTER);
else
{
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);
int size = AOP_SIZE (right);
int offset = 0;
while (size--)
{
l = aopGet (right, offset, FALSE, TRUE);
+ if ((*l == '@') || (strcmp (l, "acc") == 0))
{
MOVA (l);
emitcode ("mov", "@%s,a", rname);
{
MOVA (l);
emitcode ("mov", "@%s,a", rname);
char *rname, *l;
sym_link *retype, *letype;
char *rname, *l;
sym_link *retype, *letype;
- D(emitcode ("; genPagedPointerSet",""));
+ D (emitcode (";", "genPagedPointerSet"));
retype = getSpec (operandType (right));
letype = getSpec (operandType (result));
retype = getSpec (operandType (right));
letype = getSpec (operandType (result));
while (size--)
{
l = aopGet (right, offset, FALSE, TRUE);
while (size--)
{
l = aopGet (right, offset, FALSE, TRUE);
MOVA (l);
emitcode ("movx", "@%s,a", rname);
MOVA (l);
emitcode ("movx", "@%s,a", rname);
/* if bit then unpack */
if (IS_BITFIELD (retype) || IS_BITFIELD (letype))
/* 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);
else
{
size = AOP_SIZE (right);
sym_link *type, *etype;
int p_type;
sym_link *type, *etype;
int p_type;
- D(emitcode ("; genPointerSet",""));
+ D (emitcode (";", "genPointerSet"));
right = IC_RIGHT (ic);
result = IC_RESULT (ic);
right = IC_RIGHT (ic);
result = IC_RESULT (ic);
type = operandType (result);
p_type = DCL_TYPE (type);
}
type = operandType (result);
p_type = DCL_TYPE (type);
}
/* now that we have the pointer type we assign
the pointer values */
switch (p_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");
}
werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
"genPointerSet: illegal pointer type");
}
}
/*-----------------------------------------------------------------*/
}
/*-----------------------------------------------------------------*/
int isbit = 0;
char *dup = NULL;
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)
aopOp (cond, ic, FALSE);
/* get the value into acc */
if (AOP_TYPE (cond) != AOP_CRY)
+ {
+ toBoolean (cond);
+ }
else
{
isbit = 1;
if (AOP(cond)->aopu.aop_dir)
dup = Safe_strdup(AOP(cond)->aopu.aop_dir);
}
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);
/* 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;
symbol *sym = OP_SYMBOL (IC_LEFT (ic));
int size, offset;
- D(emitcode ("; genAddrOf",""));
+ D (emitcode (";", "genAddrOf"));
aopOp (IC_RESULT (ic), ic, FALSE);
aopOp (IC_RESULT (ic), ic, FALSE);
variable */
if (sym->onStack)
{
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));
if (sym->stack)
{
emitcode ("mov", "a,%s", SYM_BP (sym));
{
aopPut (IC_RESULT (ic), zero, offset++);
}
{
aopPut (IC_RESULT (ic), zero, offset++);
}
int size, offset;
unsigned long lit = 0L;
int size, offset;
unsigned long lit = 0L;
- D(emitcode("; genAssign",""));
+ D (emitcode (";", "genAssign"));
result = IC_RESULT (ic);
right = IC_RIGHT (ic);
result = IC_RESULT (ic);
right = IC_RIGHT (ic);
IS_TRUE_SYMOP (result) &&
isOperandInFarSpace (result))
{
IS_TRUE_SYMOP (result) &&
isOperandInFarSpace (result))
{
genFarFarAssign (result, right, ic);
return;
}
genFarFarAssign (result, right, ic);
return;
}
/* if the result is a bit */
if (AOP_TYPE (result) == AOP_CRY)
{
/* 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)
/* 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);
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) &&
if ((size > 1) &&
(AOP_TYPE (result) != AOP_REG) &&
(AOP_TYPE (right) == AOP_LIT) &&
+ /* And now fill the rest with zeros. */
+ if (size)
+ {
+ emitcode ("clr", "a");
+ }
while (size--)
{
aopPut (result, "a", offset);
while (size--)
{
aopPut (result, "a", offset);
jtab = newiTempLabel (NULL);
emitcode ("mov", "dptr,#%05d$", jtab->key + 100);
emitcode ("jmp", "@a+dptr");
jtab = newiTempLabel (NULL);
emitcode ("mov", "dptr,#%05d$", jtab->key + 100);
emitcode ("jmp", "@a+dptr");
- emitcode ("", "%05d$:", jtab->key + 100);
/* now generate the jump labels */
for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab;
jtab = setNextItem (IC_JTLABELS (ic)))
/* 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 ("ret", "");
/* now generate jump table, LSB */
- emitcode ("", "%05d$:", jtablo->key + 100);
for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab;
jtab = setNextItem (IC_JTLABELS (ic)))
emitcode (".db", "%05d$", jtab->key + 100);
/* now generate jump table, MSB */
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);
for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab;
jtab = setNextItem (IC_JTLABELS (ic)))
emitcode (".db", "%05d$>>8", jtab->key + 100);
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;
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 they are equivalent then do nothing */
if (operandsEqu (IC_RESULT (ic), IC_RIGHT (ic)))
if (IS_GENPTR (ctype))
{
if (IS_PTR (type))
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) {
else
{
if (SPEC_SCLS(etype)==S_REGISTER) {
- D(emitcode ("; genDjnz",""));
-
/* if the if condition has a false label
then we cannot save */
if (IC_FALSE (ifx))
return 0;
/* 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;
if (!isOperandEqual (IC_RESULT (ic), IC_LEFT (ic)) ||
!IS_OP_LITERAL (IC_RIGHT (ic)))
return 0;
return 0;
/* otherwise we can save BIG */
return 0;
/* otherwise we can save BIG */
+
+ D (emitcode (";", "genDjnz"));
+
lbl = newiTempLabel (NULL);
lbl1 = newiTempLabel (NULL);
lbl = newiTempLabel (NULL);
lbl1 = newiTempLabel (NULL);
emitcode ("dec", "%s",
aopGet (IC_RESULT (ic), 0, FALSE, FALSE));
MOVA (aopGet (IC_RESULT (ic), 0, FALSE, FALSE));
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
emitcode ("jnz", "%05d$", lbl->key + 100);
}
else
lbl->key + 100);
}
emitcode ("sjmp", "%05d$", lbl1->key + 100);
lbl->key + 100);
}
emitcode ("sjmp", "%05d$", lbl1->key + 100);
- emitcode ("", "%05d$:", lbl->key + 100);
emitcode ("ljmp", "%05d$", IC_TRUE (ifx)->key + 100);
emitcode ("ljmp", "%05d$", IC_TRUE (ifx)->key + 100);
- emitcode ("", "%05d$:", lbl1->key + 100);
- freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
+ if (!ifx->generated)
+ freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
ifx->generated = 1;
return 1;
}
ifx->generated = 1;
return 1;
}
int size = getSize (operandType (IC_RESULT (ic)));
int offset = 0;
int size = getSize (operandType (IC_RESULT (ic)));
int offset = 0;
- D(emitcode ("; genReceive",""));
+ D (emitcode (";", "genReceive"));
if (ic->argreg == 1)
{ /* first parameter */
if (ic->argreg == 1)
{ /* first parameter */
operand *op;
int size, offset;
operand *op;
int size, offset;
- D(emitcode("; genDummyRead",""));
+ D (emitcode(";", "genDummyRead"));
op = IC_RIGHT (ic);
if (op && IS_SYMOP (op))
op = IC_RIGHT (ic);
if (op && IS_SYMOP (op))
{
symbol *tlbl = newiTempLabel (NULL);
{
symbol *tlbl = newiTempLabel (NULL);
- D(emitcode("; genCritical",""));
+ D (emitcode(";", "genCritical"));
aopPut (IC_RESULT (ic), one, 0);
emitcode ("jbc", "ea,%05d$", (tlbl->key + 100)); /* atomic test & clear */
aopPut (IC_RESULT (ic), zero, 0);
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));
freeAsmop (IC_RESULT (ic), NULL, ic, TRUE);
}
else
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 ("setb", "c");
emitcode ("jbc", "ea,%05d$", (tlbl->key + 100)); /* atomic test & clear */
emitcode ("clr", "c");
- emitcode ("", "%05d$:", (tlbl->key + 100));
emitcode ("push", "psw"); /* save old ea via c in psw on top of stack*/
}
}
emitcode ("push", "psw"); /* save old ea via c in psw on top of stack*/
}
}
+// applies to genlshOne
+replace {
+ mov ar%1,@%2
+ mov a,r%1
+ add a,acc
+ mov r%1,a
+} by {
+ ; Peephole 140 removed redundant mov
+ mov a,@%2
+ add a,@%2
+ mov r%1,a
+}
+
replace {
mov r%1,a
mov r%2,ar%1
replace {
mov r%1,a
mov r%2,ar%1
// rules 247.x apply to f.e. bitfields.c
replace {
mov r%5,#%1
// rules 247.x apply to f.e. bitfields.c
replace {
mov r%5,#%1
+
+replace {
+ clr a
+ cjne %1,%2,%3
+ inc a
+%3:
+ jz %4
+} by {
+ ; Peephole 264 jump optimization (acc not set)
+ cjne %1,%2,%4
+%3:
+} if labelRefCount(%3 1), labelRefCountChange(%3 -1)
+
// should be one of the last peepholes
replace{
%1:
// should be one of the last peepholes
replace{
%1: