+2003-08-20 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+ Changed the type of the result of the ! (NOT) operator to char;
+ previously it returned the same type as the source. This allows
+ us to eliminate all the genFloatNot functions (all of its target
+ implementations were very buggy) since !float can use the same
+ code as !long now.
+
+ * src/SDCCicode.c (ast2iCode): ! returns char
+ * src/mcs51/gen.c (genNot, genNotFloat),
+ * src/ds390/gen.c (genNot, genNotFloat),
+ * src/z80/gen.c (genNot, genNotFloat),
+ * src/pic/gen.c (genNot, genNotFloat),
+ * src/pic16/gen.c (genNot, genNotFloat): eliminated genNotFloat
+
2003-08-19 Bernhard Held <bernhard@bernhardheld.de>
pic patch provided by Slade Rich <slade_rich@yahoo.com>
2003-08-18 Erik Petrich <epetrich@ivorytower.norman.ok.us>
- * src/z80/gen.c (isUnsplitable, fetchPairLog): fixed bug #770454
+ * src/z80/gen.c (isUnsplitable, fetchPairLong): fixed bug #770454
2003-08-18 Erik Petrich <epetrich@ivorytower.norman.ok.us>
#endif
case '~':
- case '!':
case RRC:
case RLC:
return geniCodeUnary (geniCodeRValue (left, FALSE), tree->opval.op);
+ case '!':
case GETHBIT:
{
operand *op = geniCodeUnary (geniCodeRValue (left, FALSE), tree->opval.op);
emitcode("nop", "; workaround for DS80C390 div bug."); \
}
-/*-----------------------------------------------------------------*/
-/* genNotFloat - generates not for float operations */
-/*-----------------------------------------------------------------*/
-static void
-genNotFloat (operand * op, operand * res)
-{
- int size, offset;
- symbol *tlbl;
-
- D (emitcode (";", "genNotFloat "););
-
- /* we will put 127 in the first byte of
- the result */
- aopPut (AOP (res), "#127", 0);
- size = AOP_SIZE (op) - 1;
- offset = 1;
-
- _startLazyDPSEvaluation ();
- MOVA(aopGet(op->aop, offset++, FALSE, FALSE, NULL));
-
- while (size--)
- {
- emitcode ("orl", "a,%s",
- aopGet (op->aop,
- offset++, FALSE, FALSE,
- DP2_RESULT_REG));
- }
- _endLazyDPSEvaluation ();
-
- tlbl = newiTempLabel (NULL);
- aopPut (res->aop, one, 1);
- emitcode ("jz", "!tlabel", (tlbl->key + 100));
- aopPut (res->aop, zero, 1);
- emitcode ("", "!tlabeldef", (tlbl->key + 100));
-
- size = res->aop->size - 2;
- offset = 2;
- /* put zeros in the rest */
- while (size--)
- aopPut (res->aop, zero, offset++);
-}
/*-----------------------------------------------------------------*/
/* opIsGptr: returns non-zero if the passed operand is */
genNot (iCode * ic)
{
symbol *tlbl;
- sym_link *optype = operandType (IC_LEFT (ic));
D (emitcode (";", "genNot "););
goto release;
}
- /* if type float then do float */
- if (IS_FLOAT (optype))
- {
- genNotFloat (IC_LEFT (ic), IC_RESULT (ic));
- goto release;
- }
-
toBoolean (IC_LEFT (ic));
tlbl = newiTempLabel (NULL);
while (isspace (*lbp))
lbp++;
-
+// printf ("%s\n", lb); // EEP - debugging
+
if (lbp && *lbp)
lineCurr = (lineCurr ?
connectLine (lineCurr, newLineNode (lb)) :
(x->aopu.aop_reg[0] == mcs51_regWithIdx(R0_IDX) || \
x->aopu.aop_reg[0] == mcs51_regWithIdx(R1_IDX) )))
-/*-----------------------------------------------------------------*/
-/* genNotFloat - generates not for float operations */
-/*-----------------------------------------------------------------*/
-static void
-genNotFloat (operand * op, operand * res)
-{
- int size, offset;
- char *l;
- symbol *tlbl;
-
- D(emitcode ("; genNotFloat",""));
-
- /* we will put 127 in the first byte of
- the result */
- aopPut (AOP (res), "#127", 0, isOperandVolatile (op, FALSE));
- size = AOP_SIZE (op) - 1;
- offset = 1;
-
- l = aopGet (op->aop, offset++, FALSE, FALSE);
- MOVA (l);
-
- while (size--)
- {
- emitcode ("orl", "a,%s",
- aopGet (op->aop,
- offset++, FALSE, FALSE));
- }
-
- tlbl = newiTempLabel (NULL);
- aopPut (res->aop, one, 1, isOperandVolatile (op, FALSE));
- emitcode ("jz", "%05d$", (tlbl->key + 100));
- aopPut (res->aop, zero, 1, isOperandVolatile (op, FALSE));
- emitcode ("", "%05d$:", (tlbl->key + 100));
-
- size = res->aop->size - 2;
- offset = 2;
- /* put zeros in the rest */
- while (size--)
- aopPut (res->aop, zero, offset++, isOperandVolatile (op, FALSE));
-}
/*-----------------------------------------------------------------*/
/* opIsGptr: returns non-zero if the passed operand is */
genNot (iCode * ic)
{
symbol *tlbl;
- sym_link *optype = operandType (IC_LEFT (ic));
D(emitcode ("; genNot",""));
goto release;
}
- /* if type float then do float */
- if (IS_FLOAT (optype))
- {
- genNotFloat (IC_LEFT (ic), IC_RESULT (ic));
- goto release;
- }
-
toBoolean (IC_LEFT (ic));
tlbl = newiTempLabel (NULL);
}
-/*-----------------------------------------------------------------*/
-/* genNotFloat - generates not for float operations */
-/*-----------------------------------------------------------------*/
-static void genNotFloat (operand *op, operand *res)
-{
- int size, offset;
- char *l;
- symbol *tlbl ;
-
- DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- /* we will put 127 in the first byte of
- the result */
- aopPut(AOP(res),"#127",0);
- size = AOP_SIZE(op) - 1;
- offset = 1;
-
- l = aopGet(op->aop,offset++,FALSE,FALSE);
- MOVA(l);
-
- while(size--) {
- pic14_emitcode("orl","a,%s",
- aopGet(op->aop,
- offset++,FALSE,FALSE));
- }
- tlbl = newiTempLabel(NULL);
-
- tlbl = newiTempLabel(NULL);
- aopPut(res->aop,one,1);
- pic14_emitcode("jz","%05d_DS_",(tlbl->key+100));
- aopPut(res->aop,zero,1);
- pic14_emitcode("","%05d_DS_:",(tlbl->key+100));
-
- size = res->aop->size - 2;
- offset = 2;
- /* put zeros in the rest */
- while (size--)
- aopPut(res->aop,zero,offset++);
-}
#if 0
/*-----------------------------------------------------------------*/
static void genNot (iCode *ic)
{
symbol *tlbl;
- sym_link *optype = operandType(IC_LEFT(ic));
int size;
DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
goto release;
}
- /* if type float then do float */
- if (IS_FLOAT(optype)) {
- genNotFloat(IC_LEFT(ic),IC_RESULT(ic));
- goto release;
- }
-
- size = AOP_SIZE(IC_RESULT(ic));
+ size = AOP_SIZE(IC_LEFT(ic));
if(size == 1) {
emitpcode(POC_COMFW,popGet(AOP(IC_LEFT(ic)),0));
emitpcode(POC_ANDLW,popGetLit(1));
}
-/*-----------------------------------------------------------------*/
-/* genNotFloat - generates not for float operations */
-/*-----------------------------------------------------------------*/
-static void genNotFloat (operand *op, operand *res)
-{
- int size, offset;
- char *l;
- symbol *tlbl ;
-
- DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- /* we will put 127 in the first byte of
- the result */
- pic16_aopPut(AOP(res),"#127",0);
- size = AOP_SIZE(op) - 1;
- offset = 1;
-
- l = pic16_aopGet(op->aop,offset++,FALSE,FALSE);
- MOVA(l);
-
- while(size--) {
- pic16_emitcode("orl","a,%s",
- pic16_aopGet(op->aop,
- offset++,FALSE,FALSE));
- }
- tlbl = newiTempLabel(NULL);
-
- tlbl = newiTempLabel(NULL);
- pic16_aopPut(res->aop,one,1);
- pic16_emitcode("jz","%05d_DS_",(tlbl->key+100));
- pic16_aopPut(res->aop,zero,1);
- pic16_emitcode("","%05d_DS_:",(tlbl->key+100));
-
- size = res->aop->size - 2;
- offset = 2;
- /* put zeros in the rest */
- while (size--)
- pic16_aopPut(res->aop,zero,offset++);
-}
#if 0
/*-----------------------------------------------------------------*/
static void genNot (iCode *ic)
{
symbol *tlbl;
- sym_link *optype = operandType(IC_LEFT(ic));
int size;
DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
goto release;
}
- /* if type float then do float */
- if (IS_FLOAT(optype)) {
- genNotFloat(IC_LEFT(ic),IC_RESULT(ic));
- goto release;
- }
-
- size = AOP_SIZE(IC_RESULT(ic));
+ size = AOP_SIZE(IC_LEFT(ic));
if(size == 1) {
pic16_emitpcode(POC_COMFW,pic16_popGet(AOP(IC_LEFT(ic)),0));
pic16_emitpcode(POC_ANDLW,pic16_popGetLit(1));
}
}
-/*-----------------------------------------------------------------*/
-/* genNotFloat - generates not for float operations */
-/*-----------------------------------------------------------------*/
-static void
-genNotFloat (operand * op, operand * res)
-{
- int size, offset;
- symbol *tlbl;
-
- emitDebug ("; genNotFloat");
-
- /* we will put 127 in the first byte of
- the result */
- aopPut (AOP (res), "!immedbyte", 0x7F);
- size = AOP_SIZE (op) - 1;
- offset = 1;
-
- _moveA (aopGet (op->aop, offset++, FALSE));
-
- while (size--)
- {
- emit2 ("or a,%s", aopGet (op->aop, offset++, FALSE));
- }
-
- tlbl = newiTempLabel (NULL);
- aopPut (res->aop, "!one", 1);
- emit2 ("!shortjp z !tlabel", tlbl->key + 100);
- aopPut (res->aop, "!zero", 1);
-
- emitLabel(tlbl->key + 100);
-
- size = res->aop->size - 2;
- offset = 2;
- /* put zeros in the rest */
- while (size--)
- aopPut (res->aop, "!zero", offset++);
-}
/*-----------------------------------------------------------------*/
/* genNot - generate code for ! operation */
static void
genNot (iCode * ic)
{
- sym_link *optype = operandType (IC_LEFT (ic));
/* assign asmOps to operand & result */
aopOp (IC_LEFT (ic), ic, FALSE, TRUE);
wassertl (0, "Tried to negate a bit");
}
- /* if type float then do float */
- if (IS_FLOAT (optype))
- {
- genNotFloat (IC_LEFT (ic), IC_RESULT (ic));
- goto release;
- }
-
_toBoolean (IC_LEFT (ic));
/* Not of A:
emit2 ("sub a,!one");
outBitC (IC_RESULT (ic));
- release:
/* release the aops */
freeAsmop (IC_LEFT (ic), NULL, ic);
freeAsmop (IC_RESULT (ic), NULL, ic);