/*-----------------------------------------------------------------*/
/* aopForSym - for a true symbol */
/*-----------------------------------------------------------------*/
-static asmop *aopForSym (iCode *ic,symbol *sym,bool result)
+static asmop *aopForSym (iCode *ic,symbol *sym,bool result, bool requires_a)
{
asmop *aop;
memmap *space= SPEC_OCLS(sym->etype);
return aop;
}
-#if 0
if (IS_GB) {
/* if it is in direct space */
- if (IN_DIRSPACE(space)) {
- sym->aop = aop = newAsmop (AOP_DIR);
+ printf("sname %s: regsp %u\n", space->sname, space->regsp);
+ if (IN_REGSP(space) && !requires_a) {
+ sym->aop = aop = newAsmop (AOP_SFR);
aop->aopu.aop_dir = sym->rname ;
aop->size = getSize(sym->type);
- emitcode("", "; AOP_DIR for %s", sym->rname);
+ emitcode("", "; AOP_SFR for %s", sym->rname);
return aop;
}
}
-#endif
/* only remaining is far space */
/* in which case DPTR gets the address */
{
int i;
- if (aop1 == aop2)
- return TRUE ;
+ if (aop1->type == AOP_SFR ||
+ aop2->type == AOP_SFR)
+ return FALSE;
+
+ if (aop1 == aop2)
+ return TRUE;
if (aop1->type != AOP_REG ||
aop2->type != AOP_REG )
- return FALSE ;
+ return FALSE;
if (aop1->size != aop2->size)
return FALSE ;
/*-----------------------------------------------------------------*/
/* aopOp - allocates an asmop for an operand : */
/*-----------------------------------------------------------------*/
-static void aopOp (operand *op, iCode *ic, bool result)
+static void aopOp (operand *op, iCode *ic, bool result, bool requires_a)
{
asmop *aop;
symbol *sym;
/* if this is a true symbol */
if (IS_TRUE_SYMOP(op)) {
- op->aop = aopForSym(ic,OP_SYMBOL(op),result);
+ op->aop = aopForSym(ic,OP_SYMBOL(op),result, requires_a);
return ;
}
/* else spill location */
sym->aop = op->aop = aop =
- aopForSym(ic,sym->usl.spillLoc,result);
+ aopForSym(ic,sym->usl.spillLoc,result, requires_a);
aop->size = getSize(sym->type);
return;
}
_G.pairs[pairId].last_type = aop->type;
}
+static void emitIntLabel(int key)
+{
+ emit2("!tlabeldef", key);
+}
+
static void emitLabel(int key)
{
emit2("!tlabeldef", key);
case AOP_DIR:
wassert(IS_GB);
- /* PENDING: for re-target: currently unsupported. */
- wassert(0);
emitcode("ld", "a,(%s+%d) ; x", aop->aopu.aop_dir, offset);
sprintf(s, "a");
ALLOC_ATOMIC(rs,strlen(s)+1);
strcpy(rs,s);
return rs;
+ case AOP_SFR:
+ wassert(IS_GB);
+ emitcode("ldh", "a,(%s+%d) ; x", aop->aopu.aop_dir, offset);
+ sprintf(s, "a");
+ ALLOC_ATOMIC(rs,strlen(s)+1);
+ strcpy(rs,s);
+ return rs;
+
case AOP_REG:
return aop->aopu.aop_reg[offset]->name;
case AOP_DIR:
/* Direct. Hmmm. */
wassert(IS_GB);
- /* Currently unsupported */
- wassert(0);
- emitcode("ld", "a,%s", s);
+ if (strcmp(s, "a"))
+ emitcode("ld", "a,%s", s);
emitcode("ld", "(%s+%d),a", aop->aopu.aop_dir, offset);
break;
+ case AOP_SFR:
+ wassert(IS_GB);
+ if (strcmp(s, "a"))
+ emitcode("ld", "a,%s", s);
+ emitcode("ldh", "(%s+%d),a", aop->aopu.aop_dir, offset);
+ break;
+
case AOP_REG:
emitcode("ld","%s,%s",
aop->aopu.aop_reg[offset]->name,s);
link *optype = operandType(IC_LEFT(ic));
/* assign asmOps to operand & result */
- aopOp (IC_LEFT(ic),ic,FALSE);
- aopOp (IC_RESULT(ic),ic,TRUE);
+ aopOp (IC_LEFT(ic),ic,FALSE, TRUE);
+ aopOp (IC_RESULT(ic),ic,TRUE, FALSE);
/* if in bit space then a special case */
if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY) {
/* assign asmOps to operand & result */
- aopOp (IC_LEFT(ic),ic,FALSE);
- aopOp (IC_RESULT(ic),ic,TRUE);
+ aopOp (IC_LEFT(ic),ic,FALSE, FALSE);
+ aopOp (IC_RESULT(ic),ic,TRUE, FALSE);
/* if both are in bit space then
a special case */
link *optype, *rtype;
/* assign asmops */
- aopOp(IC_LEFT(ic),ic,FALSE);
- aopOp(IC_RESULT(ic),ic,TRUE);
+ aopOp(IC_LEFT(ic),ic,FALSE, FALSE);
+ aopOp(IC_RESULT(ic),ic,TRUE, FALSE);
/* if both in bit space then special
case */
if (OP_SYMBOL(IC_LEFT(ic))->isspilt)
return ;
- aopOp(IC_LEFT(ic),ic,FALSE);
+ aopOp(IC_LEFT(ic),ic,FALSE, FALSE);
size = AOP_SIZE(IC_LEFT(ic));
/* push it on the stack */
if (isPair(AOP(IC_LEFT(ic)))) {
at this point? */
/* then do the push */
- aopOp(IC_LEFT(ic),ic,FALSE);
+ aopOp(IC_LEFT(ic),ic,FALSE, FALSE);
size = AOP_SIZE(IC_LEFT(ic));
if (OP_SYMBOL(IC_LEFT(ic))->isspilt)
return ;
- aopOp(IC_LEFT(ic),ic,FALSE);
+ aopOp(IC_LEFT(ic),ic,FALSE, FALSE);
size = AOP_SIZE(IC_LEFT(ic));
offset = (size-1);
if (isPair(AOP(IC_LEFT(ic)))) {
for (sic = setFirstItem(sendSet) ; sic ;
sic = setNextItem(sendSet)) {
int size, offset = 0;
- aopOp(IC_LEFT(sic),sic,FALSE);
+ aopOp(IC_LEFT(sic),sic,FALSE, FALSE);
size = AOP_SIZE(IC_LEFT(sic));
while (size--) {
char *l = aopGet(AOP(IC_LEFT(sic)),offset,
}
if (ispcall) {
- aopOp(IC_LEFT(ic),ic,FALSE);
+ aopOp(IC_LEFT(ic),ic,FALSE, FALSE);
if (isLitWord(AOP(IC_LEFT(ic)))) {
emitcode("", "; Special case where the pCall is to a constant");
IS_TRUE_SYMOP(IC_RESULT(ic)) ) {
accInUse++;
- aopOp(IC_RESULT(ic),ic,FALSE);
+ aopOp(IC_RESULT(ic),ic,FALSE, FALSE);
accInUse--;
assignResultValue(IC_RESULT(ic));
/* we have something to return then
move the return value into place */
- aopOp(IC_LEFT(ic),ic,FALSE);
+ aopOp(IC_LEFT(ic),ic,FALSE, FALSE);
size = AOP_SIZE(IC_LEFT(ic));
if ((size == 2) && ((l = aopGetWord(AOP(IC_LEFT(ic)), 0)))) {
symbol *tlbl = NULL;
while (size--) {
if (offset) {
- emitLabel(tlbl->key+100);
+ emitIntLabel(tlbl->key+100);
}
emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)), offset++, FALSE));
if (size) {
if (sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
while (icount--)
emitcode ("inc","%s",aopGet(AOP(IC_LEFT(ic)),0, FALSE));
-
return TRUE ;
}
/* special cases :- */
- aopOp (IC_LEFT(ic),ic,FALSE);
- aopOp (IC_RIGHT(ic),ic,FALSE);
- aopOp (IC_RESULT(ic),ic,TRUE);
+ aopOp (IC_LEFT(ic),ic,FALSE, FALSE);
+ aopOp (IC_RIGHT(ic),ic,FALSE, FALSE);
+ aopOp (IC_RESULT(ic),ic,TRUE, FALSE);
/* Swap the left and right operands if:
emitcode("adc","a,%s",
aopGet(AOP(IC_RIGHT(ic)),offset,FALSE));
} else {
- MOVA(aopGet(AOP(IC_RIGHT(ic)),offset,FALSE));
+ MOVA(aopGet(AOP(IC_LEFT(ic)),offset,FALSE));
if(offset == 0)
emitcode("add","a,%s",
- aopGet(AOP(IC_LEFT(ic)),offset,FALSE));
+ aopGet(AOP(IC_RIGHT(ic)),offset,FALSE));
else
emitcode("adc","a,%s",
- aopGet(AOP(IC_LEFT(ic)),offset,FALSE));
+ aopGet(AOP(IC_RIGHT(ic)),offset,FALSE));
}
aopPut(AOP(IC_RESULT(ic)),"a",offset++);
}
int size, offset = 0;
unsigned long lit = 0L;
- aopOp (IC_LEFT(ic),ic,FALSE);
- aopOp (IC_RIGHT(ic),ic,FALSE);
- aopOp (IC_RESULT(ic),ic,TRUE);
+ aopOp (IC_LEFT(ic),ic,FALSE, FALSE);
+ aopOp (IC_RIGHT(ic),ic,FALSE, FALSE);
+ aopOp (IC_RESULT(ic),ic,TRUE, FALSE);
/* special cases :- */
/* if both left & right are in bit space */
retype =getSpec(operandType(right));
sign = !(SPEC_USIGN(letype) | SPEC_USIGN(retype));
/* assign the amsops */
- aopOp (left,ic,FALSE);
- aopOp (right,ic,FALSE);
- aopOp (result,ic,TRUE);
+ aopOp (left,ic,FALSE, FALSE);
+ aopOp (right,ic,FALSE, FALSE);
+ aopOp (result,ic,TRUE, FALSE);
genCmp(right, left, result, ifx, sign);
sign = !(SPEC_USIGN(letype) | SPEC_USIGN(retype));
/* assign the amsops */
- aopOp (left,ic,FALSE);
- aopOp (right,ic,FALSE);
- aopOp (result,ic,TRUE);
+ aopOp (left,ic,FALSE, FALSE);
+ aopOp (right,ic,FALSE, FALSE);
+ aopOp (result,ic,TRUE, FALSE);
genCmp(left, right, result, ifx, sign);
{
operand *left, *right, *result;
- aopOp((left=IC_LEFT(ic)),ic,FALSE);
- aopOp((right=IC_RIGHT(ic)),ic,FALSE);
- aopOp((result=IC_RESULT(ic)),ic,TRUE);
+ aopOp((left=IC_LEFT(ic)),ic,FALSE, FALSE);
+ aopOp((right=IC_RIGHT(ic)),ic,FALSE, FALSE);
+ aopOp((result=IC_RESULT(ic)),ic,TRUE, FALSE);
/* Swap operands if it makes the operation easier. ie if:
1. Left is a literal.
/* note here that && operations that are in an if statement are
taken away by backPatchLabels only those used in arthmetic
operations remain */
- aopOp((left=IC_LEFT(ic)),ic,FALSE);
- aopOp((right=IC_RIGHT(ic)),ic,FALSE);
- aopOp((result=IC_RESULT(ic)),ic,FALSE);
+ aopOp((left=IC_LEFT(ic)),ic,FALSE, TRUE);
+ aopOp((right=IC_RIGHT(ic)),ic,FALSE, TRUE);
+ aopOp((result=IC_RESULT(ic)),ic,FALSE, FALSE);
/* if both are bit variables */
if (AOP_TYPE(left) == AOP_CRY &&
/* note here that || operations that are in an
if statement are taken away by backPatchLabels
only those used in arthmetic operations remain */
- aopOp((left=IC_LEFT(ic)),ic,FALSE);
- aopOp((right=IC_RIGHT(ic)),ic,FALSE);
- aopOp((result=IC_RESULT(ic)),ic,FALSE);
+ aopOp((left=IC_LEFT(ic)),ic,FALSE, TRUE);
+ aopOp((right=IC_RIGHT(ic)),ic,FALSE, TRUE);
+ aopOp((result=IC_RESULT(ic)),ic,FALSE, FALSE);
/* if both are bit variables */
if (AOP_TYPE(left) == AOP_CRY &&
unsigned long lit = 0L;
int bytelit = 0;
- aopOp((left = IC_LEFT(ic)),ic,FALSE);
- aopOp((right= IC_RIGHT(ic)),ic,FALSE);
- aopOp((result=IC_RESULT(ic)),ic,TRUE);
+ aopOp((left = IC_LEFT(ic)),ic,FALSE, FALSE);
+ aopOp((right= IC_RIGHT(ic)),ic,FALSE, FALSE);
+ aopOp((result=IC_RESULT(ic)),ic,TRUE, FALSE);
#ifdef DEBUG_TYPE
emitcode("","; Type res[%d] = l[%d]&r[%d]",
MOVA(aopGet(AOP(left),offset,FALSE));
emitcode("and","a,%s",
aopGet(AOP(right),offset,FALSE));
- emitcode("ld", "%s,a", aopGet(AOP(left),offset,FALSE));
+ aopPut(AOP(left), "a", offset);
}
}
MOVA(aopGet(AOP(left),offset,FALSE));
emitcode("and","a,%s",
aopGet(AOP(right),offset,FALSE));
- emitcode("ld", "%s,a", aopGet(AOP(left),offset,FALSE));
+ aopPut(AOP(left), "a", offset);
}
}
}
int size, offset=0;
unsigned long lit = 0L;
- aopOp((left = IC_LEFT(ic)),ic,FALSE);
- aopOp((right= IC_RIGHT(ic)),ic,FALSE);
- aopOp((result=IC_RESULT(ic)),ic,TRUE);
+ aopOp((left = IC_LEFT(ic)),ic,FALSE, FALSE);
+ aopOp((right= IC_RIGHT(ic)),ic,FALSE, FALSE);
+ aopOp((result=IC_RESULT(ic)),ic,TRUE, FALSE);
#if 1
emitcode("","; Type res[%d] = l[%d]&r[%d]",
if(((lit >> (offset*8)) & 0x0FFL) == 0x00L)
continue;
else {
- MOVA(aopGet(AOP(right),offset,FALSE));
- emitcode("or","a,%s; 5",
- aopGet(AOP(left),offset,FALSE));
- aopPut(AOP(result),"a ; 8", offset);
+ MOVA(aopGet(AOP(left),offset,FALSE));
+ emitcode("or","a,%s",
+ aopGet(AOP(right),offset,FALSE));
+ aopPut(AOP(result),"a", offset);
}
} else {
if (AOP_TYPE(left) == AOP_ACC)
- emitcode("or","a,%s ; 6",aopGet(AOP(right),offset,FALSE));
+ emitcode("or","a,%s",aopGet(AOP(right),offset,FALSE));
else {
- MOVA(aopGet(AOP(right),offset,FALSE));
- emitcode("or","a,%s ; 7",
- aopGet(AOP(left),offset,FALSE));
- aopPut(AOP(result),"a ; 8", offset);
+ MOVA(aopGet(AOP(left),offset,FALSE));
+ emitcode("or","a,%s",
+ aopGet(AOP(right),offset,FALSE));
+ aopPut(AOP(result),"a", offset);
}
}
}
int size, offset=0;
unsigned long lit = 0L;
- aopOp((left = IC_LEFT(ic)),ic,FALSE);
- aopOp((right= IC_RIGHT(ic)),ic,FALSE);
- aopOp((result=IC_RESULT(ic)),ic,TRUE);
+ aopOp((left = IC_LEFT(ic)),ic,FALSE, FALSE);
+ aopOp((right= IC_RIGHT(ic)),ic,FALSE, FALSE);
+ aopOp((result=IC_RESULT(ic)),ic,TRUE, FALSE);
/* if left is a literal & right is not then exchange them */
if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) ||
freeAsmop(right,NULL,ic);
- aopOp(left,ic,FALSE);
- aopOp(result,ic,FALSE);
+ aopOp(left,ic,FALSE, FALSE);
+ aopOp(result,ic,FALSE, FALSE);
size = getSize(operandType(result));
left = IC_LEFT(ic);
result = IC_RESULT(ic);
- aopOp(right,ic,FALSE);
+ aopOp(right,ic,FALSE, FALSE);
/* if the shift count is known then do it
as efficiently as possible */
emitcode("ld","a,%s",aopGet(AOP(right),0,FALSE));
emitcode("inc","a");
freeAsmop (right,NULL,ic);
- aopOp(left,ic,FALSE);
- aopOp(result,ic,FALSE);
+ aopOp(left,ic,FALSE, FALSE);
+ aopOp(result,ic,FALSE, FALSE);
/* now move the left to the result if they are not the
same */
freeAsmop(right,NULL,ic);
- aopOp(left,ic,FALSE);
- aopOp(result,ic,FALSE);
+ aopOp(left,ic,FALSE, FALSE);
+ aopOp(result,ic,FALSE, FALSE);
size = getSize(operandType(result));
left = IC_LEFT(ic);
result = IC_RESULT(ic);
- aopOp(right,ic,FALSE);
+ aopOp(right,ic,FALSE, FALSE);
/* if the shift count is known then do it
as efficiently as possible */
return;
}
- aopOp(left,ic,FALSE);
- aopOp(result,ic,FALSE);
+ aopOp(left,ic,FALSE, FALSE);
+ aopOp(result,ic,FALSE, FALSE);
/* now move the left to the result if they are not the
same */
if (IS_GB)
pair = PAIR_DE;
- aopOp(left,ic,FALSE);
- aopOp(result,ic,FALSE);
+ aopOp(left,ic,FALSE, FALSE);
+ aopOp(result,ic,FALSE, FALSE);
if (isPair(AOP(left)) && AOP_SIZE(result)==1) {
/* Just do it */
link *retype = getSpec(operandType(right));
PAIR_ID pairId = PAIR_HL;
- aopOp(result,ic,FALSE);
- aopOp(right,ic,FALSE);
+ aopOp(result,ic,FALSE, FALSE);
+ aopOp(right,ic,FALSE, FALSE);
if (IS_GB)
pairId = PAIR_DE;
operand *cond = IC_COND(ic);
int isbit =0;
- aopOp(cond,ic,FALSE);
+ aopOp(cond,ic,FALSE, TRUE);
/* get the value into acc */
if (AOP_TYPE(cond) != AOP_CRY)
{
symbol *sym = OP_SYMBOL(IC_LEFT(ic));
- aopOp(IC_RESULT(ic),ic,FALSE);
+ aopOp(IC_RESULT(ic),ic,FALSE, FALSE);
/* if the operand is on the stack then we
need to get the stack offset of this
}
#endif
- aopOp(right,ic,FALSE);
- aopOp(result,ic,TRUE);
+ aopOp(right,ic,FALSE, FALSE);
+ aopOp(result,ic,TRUE, FALSE);
/* if they are the same registers */
if (sameRegs(AOP(right),AOP(result))) {
symbol *jtab;
char *l;
- aopOp(IC_JTCOND(ic),ic,FALSE);
+ aopOp(IC_JTCOND(ic),ic,FALSE, FALSE);
/* get the condition into accumulator */
l = aopGet(AOP(IC_JTCOND(ic)),0,FALSE);
if (!IS_GB)
if (operandsEqu(IC_RESULT(ic),IC_RIGHT(ic)))
return ;
- aopOp(right,ic,FALSE) ;
- aopOp(result,ic,FALSE);
+ aopOp(right,ic,FALSE, FALSE);
+ aopOp(result,ic,FALSE, FALSE);
/* if the result is a bit */
if (AOP_TYPE(result) == AOP_CRY) {
wassert(0);
} else {
accInUse++;
- aopOp(IC_RESULT(ic),ic,FALSE);
+ aopOp(IC_RESULT(ic),ic,FALSE, FALSE);
accInUse--;
assignResultValue(IC_RESULT(ic));
}