if ( AOP_IS_STR(IC_LEFT(ic)) &&
isOperandLiteral(IC_RIGHT(ic)) && OP_SYMBOL(IC_RESULT(ic))->ruonly) {
aopOp (IC_RIGHT (ic), ic, TRUE, FALSE);
- size = floatFromVal (AOP (IC_RIGHT(ic))->aopu.aop_lit);
+ size = (int)floatFromVal (AOP (IC_RIGHT(ic))->aopu.aop_lit);
if (size <= 9) {
while (size--) emitcode ("inc","dptr");
} else {
/* if literal */
if (AOP_TYPE(right)==AOP_LIT) {
- signed char val=floatFromVal (AOP (right)->aopu.aop_lit);
+ signed char val=(signed char)floatFromVal (AOP (right)->aopu.aop_lit);
/* AND literal negative */
if ((int) val < 0) {
emitcode ("cpl", "F0"); // complement sign flag
if (!umult) {
emitcode("clr","F0");
if (AOP_TYPE(right) == AOP_LIT) {
- int val=floatFromVal (AOP (right)->aopu.aop_lit);
+ int val=(int)floatFromVal (AOP (right)->aopu.aop_lit);
if (val < 0) {
emitcode("setb","F0");
val = -val;
/* load up MB with right */
if (!umult) {
if (AOP_TYPE(right) == AOP_LIT) {
- int val=floatFromVal (AOP (right)->aopu.aop_lit);
+ int val=(int)floatFromVal (AOP (right)->aopu.aop_lit);
if (val < 0) {
lbl = newiTempLabel(NULL);
emitcode ("jbc","F0,!tlabel",lbl->key+100);
/* load up MB with right */
if (!umult) {
if (AOP_TYPE(right) == AOP_LIT) {
- int val=floatFromVal (AOP (right)->aopu.aop_lit);
+ int val=(int)floatFromVal (AOP (right)->aopu.aop_lit);
if (val < 0) {
val = -val;
}
genUnpackBits (operand * result, char *rname, int ptype)
{
int shCnt;
- int rlen;
+ int rlen = 0;
sym_link *etype;
int offset = 0;
+ int rsize;
D (emitcode (";", "genUnpackBits "););
etype = getSpec (operandType (result));
+ rsize = getSize (operandType (result));
/* read the first byte */
switch (ptype)
emitcode ("anl", "a,#!constbyte",
((unsigned char) -1) >> (8 - SPEC_BLEN (etype)));
- aopPut (AOP (result), "a", offset);
- return;
+ aopPut (AOP (result), "a", offset++);
+ goto finish;
}
/* bit field did not fit in a byte */
- rlen = SPEC_BLEN (etype) - 8;
+ rlen = SPEC_BLEN (etype);
aopPut (AOP (result), "a", offset++);
while (1)
if (rlen)
{
- emitcode ("anl", "a,#!constbyte", ((unsigned char) -1) >> (rlen));
- aopPut (AOP (result), "a", offset);
+ emitcode ("anl", "a,#!constbyte", ((unsigned char) -1) >> (8-rlen));
+ aopPut (AOP (result), "a", offset++);
}
- return;
+finish:
+ if (offset < rsize)
+ {
+ rsize -=offset;
+ while (rsize--)
+ aopPut (AOP (result), zero, offset++);
+ }
}
operand * right,
char *rname, int p_type)
{
+ int shCount = 0;
int offset = 0;
int rLen;
int blen, bstr;
/* it exactly fits a byte then */
if (SPEC_BLEN (etype) <= 8)
{
+ unsigned char mask = ((unsigned char) (0xFF << (blen + bstr)) |
+ (unsigned char) (0xFF >> (8 - bstr)));
+ shCount = SPEC_BSTR (etype);
+
/* shift left acc */
- AccLsh (SPEC_BSTR (etype));
+ AccLsh (shCount);
if (SPEC_BLEN (etype) < 8)
{ /* if smaller than a byte */
+ emitcode ("anl", "a,#0x%02x", (~mask) & 0xff);
switch (p_type)
{
break;
}
- emitcode ("anl", "a,#!constbyte", (unsigned char)
- ((unsigned char) (0xFF << (blen + bstr)) |
- (unsigned char) (0xFF >> (8 - bstr))));
+ emitcode ("anl", "a,#!constbyte", mask);
emitcode ("orl", "a,b");
if (p_type == GPOINTER)
emitcode ("pop", "b");
/* last last was not complete */
if (rLen)
{
+ emitcode ("anl", "a,#!constbyte",
+ (~(((unsigned char) -1 << rLen) & 0xff)) & 0xff);
+
/* save the byte & read byte */
switch (p_type)
{
break;
}
- emitcode ("anl", "a,#!constbyte", ((unsigned char) -1 << rLen));
+ emitcode ("anl", "a,#!constbyte", (((unsigned char) -1 << rLen) & 0xff));
emitcode ("orl", "a,b");
}
}
}
+/*-----------------------------------------------------------------*/
+/* genDummyRead - generate code for dummy read of volatiles */
+/*-----------------------------------------------------------------*/
+static void
+genDummyRead (iCode * ic)
+{
+ operand *right;
+ int size, offset;
+
+ D(emitcode("; genDummyRead",""));
+
+ right = IC_RIGHT (ic);
+
+ aopOp (right, ic, FALSE, FALSE);
+
+ /* if the result is a bit */
+ if (AOP_TYPE (right) == AOP_CRY)
+ {
+ emitcode ("mov", "c,%s", AOP (right)->aopu.aop_dir);
+ goto release;
+ }
+
+ /* bit variables done */
+ /* general case */
+ size = AOP_SIZE (right);
+ offset = 0;
+ while (size--)
+ {
+ emitcode ("mov", "a,%s", aopGet (AOP (right), offset, FALSE, FALSE, FALSE));
+ offset++;
+ }
+
+release:
+ freeAsmop (right, NULL, ic, TRUE);
+}
+
/*-----------------------------------------------------------------*/
/* genBuiltIn - calls the appropriate function to generating code */
/* for a built in function */
else addSet (&_G.sendSet, ic);
break;
+ case DUMMY_READ_VOLATILE:
+ genDummyRead (ic);
+ break;
+
#if 0 // obsolete, and buggy for != xdata
case ARRAYINIT:
genArrayInit(ic);