static char *spname ;
char *fReturnAVR[] = {"r16","r17","r18","r19" };
-unsigned fReturnSize = 4; /* shared with ralloc.c */
-char **fReturn = fReturnAVR;
+unsigned fAVRReturnSize = 4; /* shared with ralloc.c */
+char **fAVRReturn = fReturnAVR;
static short rbank = -1;
IC_RESULT(x)->aop->type == AOP_STK )
#define MOVR0(x) if (strcmp(x,"r0")) emitcode("mov","r0,%s",x);
-#define CLRC emitcode("clc")
-#define SETC emitcode("stc")
-#define IS_REGIDX(a,r) (a->type == AOP_REG && aop->aopu.aop_reg[0]->rIdx == r)
+#define CLRC emitcode("clc","")
+#define SETC emitcode("stc","")
+#define MOVA(x)
+#define IS_REGIDX(a,r) (a->type == AOP_REG && a->aopu.aop_reg[0]->rIdx == r)
static lineNode *lineHead = NULL;
static lineNode *lineCurr = NULL;
aop->aopu.aop_ptr = getFreePtr(ic,&aop,result,aop->code);
aop->size = getSize(sym->type);
emitcode ("ldi","%s,lo8(%s)",aop->aopu.aop_ptr->name,sym->rname);
- emircode ("ldi","%s,hi8(%s)",aop->aop_ptr2);
+ emitcode ("ldi","%s,hi8(%s)",aop->aop_ptr2);
return aop;
}
/*-----------------------------------------------------------------*/
/* isRegPair - for size 2 if this operand has a register pair */
/*-----------------------------------------------------------------*/
-static int isRegPair (aop *aopp)
+static int isRegPair (asmop *aop)
{
if (!aop || aop->size != 2) return 0;
- if (aop->type == AOP_X || aop->type == AOP_Y) return 1;
+ if (aop->type == AOP_X || aop->type == AOP_Z) return 1;
if (aop->type != AOP_REG) return 0;
if ((aop->aopu.aop_reg[1]->rIdx -
aop->aopu.aop_reg[0]->rIdx) == 1) return 1;
int i;
aop = op->aop = sym->aop = newAsmop(AOP_STR);
aop->size = getSize(sym->type);
- for ( i = 0 ; i < fReturnSize ; i++ )
- aop->aopu.aop_str[i] = fReturn[i];
+ for ( i = 0 ; i < fAVRReturnSize ; i++ )
+ aop->aopu.aop_str[i] = fAVRReturn[i];
return;
}
static void aopPut (asmop *aop, char *s, int offset)
{
char *d = buffer ;
- symbol *lbl ;
if (aop->size && offset > ( aop->size - 1)) {
werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
MOVR0(l);
while(size--) {
- emitcode("or","R0,%s", aopGet(op->aop, offset++);
+ emitcode("or","R0,%s", aopGet(op->aop, offset++));
}
tlbl = newiTempLabel(NULL);
genNotFloat(IC_LEFT(ic),IC_RESULT(ic));
goto release;
}
- emitcode("clr","r24");
+ emitcode("clr","r0");
tlbl = newiTempLabel(NULL);
- toBoolean(IC_LEFT(ic),"r0",TRUE);
- emitcode("bne","L%05d",tlbl->key);
- emitcode("ldi","r24,1");
+ size = AOP_SIZE(IC_LEFT(ic));
+ offset = 0;
+ if (size == 1) {
+ emitcode("cpse","%s,r0",aopGet(AOP(IC_LEFT(ic)),0));
+ }
+ else {
+ while (size--) {
+ if (offset) emitcode("cpc","%s,r0",aopGet(AOP(IC_LEFT(ic)),offset));
+ else emitcode("cpi","%s,0",aopGet(AOP(IC_LEFT(ic)),offset));
+ offset++;
+ }
+ emitcode("bne","L%05d",tlbl->key);
+ }
+ emitcode("ldi","r0,1");
emitcode("","L%05d:",tlbl->key);
- aopPut(AOP(IC_RESULT(ic)),"r24",0);
+ aopPut(AOP(IC_RESULT(ic)),"r0",0);
size = AOP_SIZE(IC_RESULT(ic)) -1;
+ offset = 1;
while (size--) aopPut(AOP(IC_RESULT(ic)),zero,offset++);
/* assign asmOps to operand & result */
aopOp (IC_LEFT(ic),ic,FALSE);
aopOp (IC_RESULT(ic),ic,TRUE);
- samer = sameRegs(AOP(IC_LEFT(ic),AOP(IC_RESULT(ic))));
+ samer = sameRegs(AOP(IC_LEFT(ic)),AOP(IC_RESULT(ic)));
size = AOP_SIZE(IC_RESULT(ic));
while (size--) {
char *l = aopGet(AOP(IC_LEFT(ic)),offset);
}
-release:
/* release the aops */
freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1));
freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
aopPut(AOP(IC_RESULT(ic)),"r0",offset++);
} else {
char *s;
- emitcode("clr","%s",s=aopGet(IC_RESULT(ic),offset++));
+ emitcode("clr","%s",s=aopGet(AOP(IC_RESULT(ic)),offset++));
emitcode("sbc","%s,%s",s,l);
}
}
int offset = 0;
int size = AOP_SIZE(oper);
while (size--) {
- aopPut(AOP(oper),fReturn[offset],offset);
+ aopPut(AOP(oper),fAVRReturn[offset],offset);
offset++;
}
}
static void saveZreg (iCode *ic)
{
/* only if live accross this call */
- if (ic->regSaved == 0 &&
+ if (ic->regsSaved == 0 &&
(bitVectBitValue(ic->rMask,R30_IDX) ||
bitVectBitValue(ic->rMask,R31_IDX))) {
ic->regsSaved = 1;
/*-----------------------------------------------------------------*/
static void genCall (iCode *ic)
{
- link *detype;
/* if send set is not empty the assign */
if (_G.sendSet) {
size = AOP_SIZE(IC_LEFT(sic));
while (size--) {
char *l = aopGet(AOP(IC_LEFT(sic)),offset);
- if (strcmp(l,fReturn[offset]))
+ if (strcmp(l,fAVRReturn[offset]))
emitcode("mov","%s,%s",
- fReturn[offset],
+ fAVRReturn[offset],
l);
offset++;
}
/*-----------------------------------------------------------------*/
static void genPcall (iCode *ic)
{
- link *detype;
if (!ic->regsSaved) saveZreg(ic);
size = AOP_SIZE(IC_LEFT(sic));
while (size--) {
char *l = aopGet(AOP(IC_LEFT(sic)),offset);
- if (strcmp(l,fReturn[offset]))
+ if (strcmp(l,fAVRReturn[offset]))
emitcode("mov","%s,%s",
- fReturn[offset],
+ fAVRReturn[offset],
l);
offset++;
}
emitcode("sbci","r29,hi8(%d)",IC_LEFT(ic)->parmBytes);
}
}
- if (ic->regsSaved) popZregs(ic);
+ if (ic->regsSaved) popZreg(ic);
}
/*-----------------------------------------------------------------*/
/* if critical function then turn interrupts off */
if (SPEC_CRTCL(fetype))
- emitcode("cli");
+ emitcode("cli","");
if (IS_ISR(sym->etype)) {
}
static void genEndFunction (iCode *ic)
{
symbol *sym = OP_SYMBOL(IC_LEFT(ic));
+ int i;
/* restore stack pointer */
- if (sym->stack <= 63) {
- emitcode("adiw","r28,%d",sym->stack);
- } else {
- emitcode ("subi","r28,lo8(-%d)",sym->stack);
- emitcode ("sbci","r29,hi8(-%d)",sym->stack);
- }
- emitcode("out","__SP_L__,r28");
- emitcode("out","__SP_H__,r29");
-
- /* pop frame pointer */
- emitcode ("pop","r29");
- emitcode ("pop","r28");
+ if (sym->stack) {
+ if (sym->stack <= 63) {
+ emitcode("adiw","r28,%d",sym->stack);
+ } else {
+ emitcode ("subi","r28,lo8(-%d)",sym->stack);
+ emitcode ("sbci","r29,hi8(-%d)",sym->stack);
+ }
+ emitcode("out","__SP_L__,r28");
+ emitcode("out","__SP_H__,r29");
+ /* pop frame pointer */
+ emitcode ("pop","r29");
+ emitcode ("pop","r28");
+ }
/* restore preserved registers */
if (bitVectBitValue(sym->regsUsed,R31_IDX)) {
_G.nRegsSaved--;
}
}
+ if (SPEC_CRTCL(sym->etype))
+ emitcode("sti","");
+
if (IS_ISR(sym->etype)) {
+ emitcode("rti","");
+ } else {
+ emitcode("ret","");
}
- if (SPEC_CRTCL(fetype))
- emitcode("sti");
}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
static void genRet (iCode *ic)
{
- int size,offset = 0 , pushed = 0;
+ int size,offset = 0 ;
/* if we have no return value then
just generate the "ret" */
while (size--) {
char *l ;
l = aopGet(AOP(IC_LEFT(ic)),offset);
- if (strcmp(fReturn[offset],l))
- emitcode("mov","%s,%s",fReturn[offset++],l);
+ if (strcmp(fAVRReturn[offset],l))
+ emitcode("mov","%s,%s",fAVRReturn[offset++],l);
}
freeAsmop (IC_LEFT(ic),NULL,ic,TRUE);
then we cannot */
if (AOP_SIZE(IC_RESULT(ic)) > 2 ||
AOP_SIZE(IC_LEFT(ic)) > 2 ||
- !sameRegs(AOP(IC_LEFT(ic)),AOP(IC_RIGHT(ic))))
+ !sameRegs(AOP(IC_LEFT(ic)),AOP(IC_RESULT(ic))))
return FALSE ;
/* so we know LEFT & RESULT in the same registers and add
emitcode("inc","%s",aopGet(AOP(IC_LEFT(ic)),0));
return TRUE;
}
- emicode("subi","%s,lo8(%d)",aopGet(AOP(IC_LEFT(ic)),0),-icount);
+ emitcode("subi","%s,lo8(%d)",aopGet(AOP(IC_LEFT(ic)),0),-icount);
return TRUE;
}
* I'm pretty certain it's right, but not enough to toss the old
* code just yet...
*/
-static void adjustArithmeticResult(iCode *ic)
+static void adjustArithmeticResult (iCode *ic)
{
if (opIsGptr(IC_RESULT(ic)) &&
opIsGptr(IC_LEFT(ic)) &&
size = getDataSize(IC_RESULT(ic));
- while(size--){
+ while(size--) {
aopPut(AOP(IC_RESULT(ic)),aopGet(AOP(IC_RIGHT(ic)),offset),offset);
if(offset == 0)
emitcode("add","%s,%s",aopGet(AOP(IC_RESULT(ic)),offset),
else
emitcode("adc","%s,%s",aopGet(AOP(IC_RESULT(ic)),offset),
aopGet(AOP(IC_LEFT(ic)),offset));
- }
}
adjustArithmeticResult(ic);
emitcode("dec","%s",aopGet(AOP(IC_LEFT(ic)),0));
return TRUE;
}
- emicode("subi","%s,lo8(%d)",aopGet(AOP(IC_LEFT(ic)),0),icount);
+ emitcode("subi","%s,lo8(%d)",aopGet(AOP(IC_LEFT(ic)),0),icount);
return TRUE;
}
static void genMinus (iCode *ic)
{
int size, offset = 0;
- unsigned long lit = 0L;
aopOp (IC_LEFT(ic),ic,FALSE);
aopOp (IC_RIGHT(ic),ic,FALSE);
operand *result)
{
link *opetype = operandType(result);
- char *l ;
symbol *lbl ;
int size,offset;
size = AOP_SIZE(result);
if (SPEC_USIGN(opetype)) {
- emitcode("mul","%s,%s",
- aopGet(IC_LEFT(ic),0),
- aopGet(IC_RIGHT(ic),0));
+ emitcode("mul","%s,%s", aopGet(AOP(left),0),aopGet(AOP(right),0));
} else {
- emitcode("muls","%s,%s",
- aopGet(IC_LEFT(ic),0),
- aopGet(IC_RIGHT(ic),0));
+ emitcode("muls","%s,%s", aopGet(AOP(left),0),
+ aopGet(AOP(right),0));
}
- aopPut(AOP(IC_RESULT(ic)),"r0",0);
+ aopPut(AOP(result),"r0",0);
if (size > 1){
- aopPut(AOP(IC_RESULT(ic)),"r1",1);
+ aopPut(AOP(result),"r1",1);
offset = 2;
size -= 2;
if (SPEC_USIGN(opetype)) {
while(size--) {
- aopPut(AOP(IC_RESULT(ic)),zero,offset++);
+ aopPut(AOP(result),zero,offset++);
}
} else {
lbl = newiTempLabel(NULL);
emitcode("brcc","L%05d",lbl->key);
emitcode("ldi","r24,lo8(-1)");
emitcode("","L%05d:",lbl->key);
- while (size--) aopPut(AOP(IC_RESULT(ic)),"r24",offset++);
+ while (size--) aopPut(AOP(result),"r24",offset++);
}
}
return;
aopOp (left,ic,FALSE);
aopOp (right,ic,FALSE);
aopOp (result,ic,TRUE);
- size = AOP_SIZE(AOP(left));
+ size = AOP_SIZE(left);
if (ifx) {
if (size == 1) {
- if (AOP_TYPE(AOP(right)) == AOP_LIT) {
+ if (AOP_TYPE(right) == AOP_LIT) {
emitcode("cpi","%s,lo8(%d)",aopGet(AOP(left),0),
(int) floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit));
- genBranch(ifx,br_type);
+ genBranch(ifx,br_type,sign);
} else { /* right != literal */
emitcode("cp","%s,%s",aopGet(AOP(left),0),aopGet(AOP(right),0));
- genBranch(ifx,br_type);
+ genBranch(ifx,br_type,sign);
+ }
} else { /* size != 1 */
while (size--) {
- if (offset = 0)
+ if (offset == 0)
emitcode("cp","%s,%s",aopGet(AOP(left),0),aopGet(AOP(right),0));
else
emitcode("cpc","%s,%s",aopGet(AOP(left),offset),aopGet(AOP(right),offset));
offset++;
}
- genBranch(ifx,br_type);
+ genBranch(ifx,br_type,sign);
}
} else { /* no ifx */
- emitCode("clr","r0");
+ emitcode("clr","r0");
while (size--) {
- if (offset = 0)
+ if (offset == 0)
emitcode("cp","%s,%s",aopGet(AOP(left),0),aopGet(AOP(right),0));
else
emitcode("cpc","%s,%s",aopGet(AOP(left),offset),aopGet(AOP(right),offset));
emitcode("inc","r0");
emitcode("","L%05d:",lbl->key);
aopPut(AOP(result),"r0",0);
- size = AOP_SIZE(AOP(result)) - 1;
+ size = AOP_SIZE(result) - 1;
offset = 1;
while (size--) aopPut(AOP(result),zero,offset++);
}
IC_RIGHT(ic) = left;
IC_LEFT(ic) = right;
- gemCmp(ic,ifx,AVR_GE);
+ genCmp(ic,ifx,AVR_GE);
}
/*-----------------------------------------------------------------*/
aopOp((right=IC_RIGHT(ic)),ic,FALSE);
aopOp((result=IC_RESULT(ic)),ic,FALSE);
- tlbl = newitempLabel(NULL);
+ tlbl = newiTempLabel(NULL);
toBoolean(left,"r0",TRUE);
toBoolean(right,"r1",TRUE);
emitcode("and","r0,r1");
emitcode("ldi","r24,1");
emitcode("breq","L%05d",tlbl->key);
emitcode("dec","r24");
- emicode("","L%05d:",tlbl->key);
+ emitcode("","L%05d:",tlbl->key);
aopPut(AOP(result),"r24",0);
- size = AOP_SIZE(AOP(result)) -1;
+ size = AOP_SIZE(result) -1;
offset = 1;
while (size--) aopPut(AOP(result),zero,offset++);
aopOp((right=IC_RIGHT(ic)),ic,FALSE);
aopOp((result=IC_RESULT(ic)),ic,FALSE);
- tlbl = newitempLabel(NULL);
+ tlbl = newiTempLabel(NULL);
toBoolean(left,"r0",TRUE);
toBoolean(right,"r0",FALSE);
emitcode("ldi","r24,1");
emitcode("breq","L%05d",tlbl->key);
emitcode("dec","r24");
- emicode("","L%05d:",tlbl->key);
+ emitcode("","L%05d:",tlbl->key);
aopPut(AOP(result),"r24",0);
- size = AOP_SIZE(AOP(result)) -1;
+ size = AOP_SIZE(result) -1;
offset = 1;
while (size--) aopPut(AOP(result),zero,offset++);
operand *left, *right, *result;
int size, offset=0;
char *l;
- 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);
-
+
+ size = AOP_SIZE(left);
+ offset = 0;
if (ifx) { /* used only for jumps */
- if (AOP_TYPE(AOP(right)) == AOP_LIT) {
+ if (AOP_TYPE(right) == AOP_LIT) {
int p2 = powof2((int) floatFromVal (AOP(right)->aopu.aop_lit));
if (p2) { /* right side is a power of 2 */
l = aopGet(AOP(left),p2 / 8);
emitcode("rjmp","L%05d",IC_FALSE(ifx)->key);
}
} else { /* right not power of two */
- emitcode
+ while (size--) {
+ }
}
} else { /* right is not a literal */
}
aopOp((right= IC_RIGHT(ic)),ic,FALSE);
aopOp((result=IC_RESULT(ic)),ic,TRUE);
-#ifdef DEBUG_TYPE
- emitcode("","; Type res[%d] = l[%d]&r[%d]",
- AOP_TYPE(result),
- AOP_TYPE(left), AOP_TYPE(right));
- emitcode("","; Size res[%d] = l[%d]&r[%d]",
- AOP_SIZE(result),
- AOP_SIZE(left), AOP_SIZE(right));
-#endif
-
- /* if left is a literal & right is not then exchange them */
- if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) ||
- AOP_NEEDSACC(left)) {
- operand *tmp = right ;
- right = left;
- left = tmp;
- }
-
- /* if result = right then exchange them */
- if(sameRegs(AOP(result),AOP(right))){
- operand *tmp = right ;
- right = left;
- left = tmp;
- }
-
- /* if right is bit then exchange them */
- if (AOP_TYPE(right) == AOP_CRY &&
- AOP_TYPE(left) != AOP_CRY){
- operand *tmp = right ;
- right = left;
- left = tmp;
- }
- if(AOP_TYPE(right) == AOP_LIT)
- lit = (unsigned long)floatFromVal (AOP(right)->aopu.aop_lit);
-
- size = AOP_SIZE(result);
-
- // if(bit | yy)
- // xx = bit | yy;
- if (AOP_TYPE(left) == AOP_CRY){
- if(AOP_TYPE(right) == AOP_LIT){
- // c = bit & literal;
- if(lit){
- // lit != 0 => result = 1
- if(AOP_TYPE(result) == AOP_CRY){
- if(size)
- emitcode("setb","%s",AOP(result)->aopu.aop_dir);
- else if(ifx)
- continueIfTrue(ifx);
- goto release;
- }
- emitcode("setb","c");
- } else {
- // lit == 0 => result = left
- if(size && sameRegs(AOP(result),AOP(left)))
- goto release;
- emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
- }
- } else {
- if (AOP_TYPE(right) == AOP_CRY){
- // c = bit | bit;
- emitcode("mov","c,%s",AOP(right)->aopu.aop_dir);
- emitcode("orl","c,%s",AOP(left)->aopu.aop_dir);
- }
- else{
- // c = bit | val;
- symbol *tlbl = newiTempLabel(NULL);
- if(!((AOP_TYPE(result) == AOP_CRY) && ifx))
- emitcode("setb","c");
- emitcode("jb","%s,%05d$",
- AOP(left)->aopu.aop_dir,tlbl->key+100);
- toBoolean(right);
- emitcode("jnz","%05d$",tlbl->key+100);
- if((AOP_TYPE(result) == AOP_CRY) && ifx){
- jmpTrueOrFalse(ifx, tlbl);
- goto release;
- } else {
- CLRC;
- emitcode("","%05d$:",tlbl->key+100);
- }
- }
- }
- // bit = c
- // val = c
- if(size)
- outBitC(result);
- // if(bit | ...)
- else if((AOP_TYPE(result) == AOP_CRY) && ifx)
- genIfxJump(ifx, "c");
- goto release ;
- }
-
- // if(val | 0xZZ) - size = 0, ifx != FALSE -
- // bit = val | 0xZZ - size = 1, ifx = FALSE -
- if((AOP_TYPE(right) == AOP_LIT) &&
- (AOP_TYPE(result) == AOP_CRY) &&
- (AOP_TYPE(left) != AOP_CRY)){
- if(lit){
- // result = 1
- if(size)
- emitcode("setb","%s",AOP(result)->aopu.aop_dir);
- else
- continueIfTrue(ifx);
- goto release;
- } else {
- // lit = 0, result = boolean(left)
- if(size)
- emitcode("setb","c");
- toBoolean(right);
- if(size){
- symbol *tlbl = newiTempLabel(NULL);
- emitcode("jnz","%05d$",tlbl->key+100);
- CLRC;
- emitcode("","%05d$:",tlbl->key+100);
- } else {
- genIfxJump (ifx,"a");
- goto release;
- }
- }
- outBitC(result);
- goto release ;
- }
-
- /* if left is same as result */
- if(sameRegs(AOP(result),AOP(left))){
- for(;size--; offset++) {
- if(AOP_TYPE(right) == AOP_LIT){
- if(((lit >> (offset*8)) & 0x0FFL) == 0x00L)
- continue;
- else
- if (IS_AOP_PREG(left)) {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("orl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
- aopPut(AOP(result),"a",offset);
- } else
- emitcode("orl","%s,%s",
- aopGet(AOP(left),offset,FALSE,TRUE),
- aopGet(AOP(right),offset,FALSE,FALSE));
- } else {
- if (AOP_TYPE(left) == AOP_ACC)
- emitcode("orl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
- else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- if (IS_AOP_PREG(left)) {
- emitcode("orl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
- aopPut(AOP(result),"a",offset);
- } else
- emitcode("orl","%s,a",
- aopGet(AOP(left),offset,FALSE,TRUE));
- }
- }
- }
- } else {
- // left & result in different registers
- if(AOP_TYPE(result) == AOP_CRY){
- // result = bit
- // if(size), result in bit
- // 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--){
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("orl","a,%s",
- aopGet(AOP(left),offset,FALSE,FALSE));
- emitcode("jnz","%05d$",tlbl->key+100);
- offset++;
- }
- if(size){
- CLRC;
- emitcode("","%05d$:",tlbl->key+100);
- outBitC(result);
- } else if(ifx)
- jmpTrueOrFalse(ifx, tlbl);
- } else for(;(size--);offset++){
- // normal case
- // result = left & right
- if(AOP_TYPE(right) == AOP_LIT){
- if(((lit >> (offset*8)) & 0x0FFL) == 0x00L){
- aopPut(AOP(result),
- aopGet(AOP(left),offset,FALSE,FALSE),
- offset);
- continue;
- }
- }
- // faster than result <- left, anl result,right
- // and better if result is SFR
- if (AOP_TYPE(left) == AOP_ACC)
- emitcode("orl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
- else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("orl","a,%s",
- aopGet(AOP(left),offset,FALSE,FALSE));
- }
- aopPut(AOP(result),"a",offset);
- }
- }
release :
freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
aopOp((right= IC_RIGHT(ic)),ic,FALSE);
aopOp((result=IC_RESULT(ic)),ic,TRUE);
-#ifdef DEBUG_TYPE
- emitcode("","; Type res[%d] = l[%d]&r[%d]",
- AOP_TYPE(result),
- AOP_TYPE(left), AOP_TYPE(right));
- emitcode("","; Size res[%d] = l[%d]&r[%d]",
- AOP_SIZE(result),
- AOP_SIZE(left), AOP_SIZE(right));
-#endif
-
- /* if left is a literal & right is not ||
- if left needs acc & right does not */
- if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) ||
- (AOP_NEEDSACC(left) && !AOP_NEEDSACC(right))) {
- operand *tmp = right ;
- right = left;
- left = tmp;
- }
-
- /* if result = right then exchange them */
- if(sameRegs(AOP(result),AOP(right))){
- operand *tmp = right ;
- right = left;
- left = tmp;
- }
-
- /* if right is bit then exchange them */
- if (AOP_TYPE(right) == AOP_CRY &&
- AOP_TYPE(left) != AOP_CRY){
- operand *tmp = right ;
- right = left;
- left = tmp;
- }
- if(AOP_TYPE(right) == AOP_LIT)
- lit = (unsigned long)floatFromVal (AOP(right)->aopu.aop_lit);
-
- size = AOP_SIZE(result);
-
- // if(bit ^ yy)
- // xx = bit ^ yy;
- if (AOP_TYPE(left) == AOP_CRY){
- if(AOP_TYPE(right) == AOP_LIT){
- // c = bit & literal;
- if(lit>>1){
- // lit>>1 != 0 => result = 1
- if(AOP_TYPE(result) == AOP_CRY){
- if(size)
- emitcode("setb","%s",AOP(result)->aopu.aop_dir);
- else if(ifx)
- continueIfTrue(ifx);
- goto release;
- }
- emitcode("setb","c");
- } else{
- // lit == (0 or 1)
- if(lit == 0){
- // lit == 0, result = left
- if(size && sameRegs(AOP(result),AOP(left)))
- goto release;
- emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
- } else{
- // lit == 1, result = not(left)
- if(size && sameRegs(AOP(result),AOP(left))){
- emitcode("cpl","%s",AOP(result)->aopu.aop_dir);
- goto release;
- } else {
- emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
- emitcode("cpl","c");
- }
- }
- }
-
- } else {
- // right != literal
- symbol *tlbl = newiTempLabel(NULL);
- if (AOP_TYPE(right) == AOP_CRY){
- // c = bit ^ bit;
- emitcode("mov","c,%s",AOP(right)->aopu.aop_dir);
- }
- else{
- int sizer = AOP_SIZE(right);
- // c = bit ^ val
- // if val>>1 != 0, result = 1
- emitcode("setb","c");
- while(sizer){
- MOVA(aopGet(AOP(right),sizer-1,FALSE,FALSE));
- if(sizer == 1)
- // test the msb of the lsb
- emitcode("anl","a,#0xfe");
- emitcode("jnz","%05d$",tlbl->key+100);
- sizer--;
- }
- // val = (0,1)
- emitcode("rrc","a");
- }
- emitcode("jnb","%s,%05d$",AOP(left)->aopu.aop_dir,(tlbl->key+100));
- emitcode("cpl","c");
- emitcode("","%05d$:",(tlbl->key+100));
- }
- // bit = c
- // val = c
- if(size)
- outBitC(result);
- // if(bit | ...)
- else if((AOP_TYPE(result) == AOP_CRY) && ifx)
- genIfxJump(ifx, "c");
- goto release ;
- }
- if(sameRegs(AOP(result),AOP(left))){
- /* if left is same as result */
- for(;size--; offset++) {
- if(AOP_TYPE(right) == AOP_LIT){
- if(((lit >> (offset*8)) & 0x0FFL) == 0x00L)
- continue;
- else
- if (IS_AOP_PREG(left)) {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("xrl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
- aopPut(AOP(result),"a",offset);
- } else
- emitcode("xrl","%s,%s",
- aopGet(AOP(left),offset,FALSE,TRUE),
- aopGet(AOP(right),offset,FALSE,FALSE));
- } else {
- if (AOP_TYPE(left) == AOP_ACC)
- emitcode("xrl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
- else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- if (IS_AOP_PREG(left)) {
- emitcode("xrl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
- aopPut(AOP(result),"a",offset);
- } else
- emitcode("xrl","%s,a",
- aopGet(AOP(left),offset,FALSE,TRUE));
- }
- }
- }
- } else {
- // left & result in different registers
- if(AOP_TYPE(result) == AOP_CRY){
- // result = bit
- // if(size), result in bit
- // 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((AOP_TYPE(right) == AOP_LIT) &&
- (((lit >> (offset*8)) & 0x0FFL) == 0x00L)){
- MOVA(aopGet(AOP(left),offset,FALSE,FALSE));
- } else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("xrl","a,%s",
- aopGet(AOP(left),offset,FALSE,FALSE));
- }
- emitcode("jnz","%05d$",tlbl->key+100);
- offset++;
- }
- if(size){
- CLRC;
- emitcode("","%05d$:",tlbl->key+100);
- outBitC(result);
- } else if(ifx)
- jmpTrueOrFalse(ifx, tlbl);
- } else for(;(size--);offset++){
- // normal case
- // result = left & right
- if(AOP_TYPE(right) == AOP_LIT){
- if(((lit >> (offset*8)) & 0x0FFL) == 0x00L){
- aopPut(AOP(result),
- aopGet(AOP(left),offset,FALSE,FALSE),
- offset);
- continue;
- }
- }
- // faster than result <- left, anl result,right
- // and better if result is SFR
- if (AOP_TYPE(left) == AOP_ACC)
- emitcode("xrl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
- else {
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("xrl","a,%s",
- aopGet(AOP(left),offset,FALSE,TRUE));
- }
- aopPut(AOP(result),"a",offset);
- }
- }
release :
freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
/* move it to the result */
size = AOP_SIZE(result);
offset = size - 1 ;
- CLRC;
- while (size--) {
- l = aopGet(AOP(left),offset,FALSE,FALSE);
- MOVA(l);
- emitcode("rrc","a");
- if (AOP_SIZE(result) > 1)
- aopPut(AOP(result),"a",offset--);
- }
- /* now we need to put the carry into the
- highest order byte of the result */
- if (AOP_SIZE(result) > 1) {
- l = aopGet(AOP(result),AOP_SIZE(result)-1,FALSE,FALSE);
- MOVA(l);
- }
- emitcode("mov","acc.7,c");
- aopPut(AOP(result),"a",AOP_SIZE(result)-1);
+
+
freeAsmop(left,NULL,ic,TRUE);
freeAsmop(result,NULL,ic,TRUE);
}
aopOp (left,ic,FALSE);
aopOp (result,ic,FALSE);
- /* move it to the result */
- size = AOP_SIZE(result);
- offset = 0 ;
- if (size--) {
- l = aopGet(AOP(left),offset,FALSE,FALSE);
- MOVA(l);
- emitcode("add","a,acc");
- if (AOP_SIZE(result) > 1)
- aopPut(AOP(result),"a",offset++);
- while (size--) {
- l = aopGet(AOP(left),offset,FALSE,FALSE);
- MOVA(l);
- emitcode("rlc","a");
- if (AOP_SIZE(result) > 1)
- aopPut(AOP(result),"a",offset++);
- }
- }
- /* now we need to put the carry into the
- highest order byte of the result */
- if (AOP_SIZE(result) > 1) {
- l = aopGet(AOP(result),0,FALSE,FALSE);
- MOVA(l);
- }
- emitcode("mov","acc.0,c");
- aopPut(AOP(result),"a",0);
+
freeAsmop(left,NULL,ic,TRUE);
freeAsmop(result,NULL,ic,TRUE);
}
aopOp (left,ic,FALSE);
aopOp (result,ic,FALSE);
- /* get the highest order byte into a */
- MOVA(aopGet(AOP(left),AOP_SIZE(left) - 1,FALSE,FALSE));
- if(AOP_TYPE(result) == AOP_CRY){
- emitcode("rlc","a");
- outBitC(result);
- }
- else{
- emitcode("rl","a");
- emitcode("anl","a,#0x01");
- outAcc(result);
- }
-
freeAsmop(left,NULL,ic,TRUE);
freeAsmop(result,NULL,ic,TRUE);
operand *result, int offr, int shCount)
{
char *l;
- l = aopGet(AOP(left),offl,FALSE,FALSE);
+ l = aopGet(AOP(left),offl);
MOVA(l);
/* shift left accumulator */
AccLsh(shCount);
{
char *l;
if(!sameRegs(AOP(left),AOP(result)) || (offl != offr)){
- l = aopGet(AOP(left),offl,FALSE,FALSE);
+ l = aopGet(AOP(left),offl);
if (*l == '@' && (IS_AOP_PREG(result))) {
emitcode("mov","a,%s",l);
if(sameRegs(AOP(result), AOP(left)) &&
((offl + MSB16) == offr)){
/* don't crash result[offr] */
- MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
- emitcode("xch","a,%s", aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
+ // MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
+ emitcode("xch","a,%s", aopGet(AOP(left),offl+MSB16));
} else {
movLeft2Result(left,offl, result, offr, 0);
- MOVA(aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),offl+MSB16));
}
/* ax << shCount (x = lsb(result))*/
- AccAXLsh( aopGet(AOP(result),offr,FALSE,FALSE) , shCount);
+ AccAXLsh( aopGet(AOP(result),offr) , shCount);
aopPut(AOP(result),"a",offr+MSB16);
}
if(sameRegs(AOP(result), AOP(left)) &&
((offl + MSB16) == offr)){
/* don't crash result[offr] */
- MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
- emitcode("xch","a,%s", aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
+ // MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
+ emitcode("xch","a,%s", aopGet(AOP(left),offl+MSB16));
} else {
movLeft2Result(left,offl, result, offr, 0);
- MOVA(aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
+ // MOVA(aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
}
/* a:x >> shCount (x = lsb(result))*/
if(sign)
- AccAXRshS( aopGet(AOP(result),offr,FALSE,FALSE) , shCount);
+ AccAXRshS( aopGet(AOP(result),offr) , shCount);
else
- AccAXRsh( aopGet(AOP(result),offr,FALSE,FALSE) , shCount);
+ AccAXRsh( aopGet(AOP(result),offr) , shCount);
if(getDataSize(result) > 1)
aopPut(AOP(result),"a",offr+MSB16);
}
static void shiftLLeftOrResult (operand *left, int offl,
operand *result, int offr, int shCount)
{
- MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
+ // MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
/* shift left accumulator */
AccLsh(shCount);
/* or with result */
- emitcode("orl","a,%s", aopGet(AOP(result),offr,FALSE,FALSE));
+ emitcode("orl","a,%s", aopGet(AOP(result),offr));
/* back to result */
aopPut(AOP(result),"a",offr);
}
static void shiftRLeftOrResult (operand *left, int offl,
operand *result, int offr, int shCount)
{
- MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
+ // MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
/* shift right accumulator */
AccRsh(shCount);
/* or with result */
- emitcode("orl","a,%s", aopGet(AOP(result),offr,FALSE,FALSE));
+ emitcode("orl","a,%s", aopGet(AOP(result),offr));
/* back to result */
aopPut(AOP(result),"a",offr);
}
int size = AOP_SIZE(result);
if(size >= LSB+offr){
- l = aopGet(AOP(left),LSB,FALSE,FALSE);
+ l = aopGet(AOP(left),LSB);
MOVA(l);
emitcode("add","a,acc");
if (sameRegs(AOP(left),AOP(result)) &&
size >= MSB16+offr && offr != LSB )
emitcode("xch","a,%s",
- aopGet(AOP(left),LSB+offr,FALSE,FALSE));
+ aopGet(AOP(left),LSB+offr));
else
aopPut(AOP(result),"a",LSB+offr);
}
if(size >= MSB16+offr){
if (!(sameRegs(AOP(result),AOP(left)) && size >= MSB16+offr && offr != LSB) ) {
- l = aopGet(AOP(left),MSB16,FALSE,FALSE);
+ l = aopGet(AOP(left),MSB16);
MOVA(l);
}
emitcode("rlc","a");
if (sameRegs(AOP(left),AOP(result)) &&
size >= MSB24+offr && offr != LSB)
emitcode("xch","a,%s",
- aopGet(AOP(left),MSB16+offr,FALSE,FALSE));
+ aopGet(AOP(left),MSB16+offr));
else
aopPut(AOP(result),"a",MSB16+offr);
}
if(size >= MSB24+offr){
if (!(sameRegs(AOP(left),AOP(left)) && size >= MSB24+offr && offr != LSB)) {
- l = aopGet(AOP(left),MSB24,FALSE,FALSE);
- MOVA(l);
+ l = aopGet(AOP(left),MSB24);
+ // MOVA(l);
}
emitcode("rlc","a");
if (sameRegs(AOP(left),AOP(result)) &&
size >= MSB32+offr && offr != LSB )
emitcode("xch","a,%s",
- aopGet(AOP(left),MSB24+offr,FALSE,FALSE));
+ aopGet(AOP(left),MSB24+offr));
else
aopPut(AOP(result),"a",MSB24+offr);
}
if(size > MSB32+offr){
if (!(sameRegs(AOP(result),AOP(left)) && size >= MSB32+offr && offr != LSB)) {
- l = aopGet(AOP(left),MSB32,FALSE,FALSE);
+ l = aopGet(AOP(left),MSB32);
MOVA(l);
}
emitcode("rlc","a");
more that 32 bits make no sense anyway, ( the
largest size of an object can be only 32 bits ) */
- emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE));
+ emitcode("mov","b,%s",aopGet(AOP(right),0));
emitcode("inc","b");
freeAsmop (right,NULL,ic,TRUE);
aopOp(left,ic,FALSE);
size = AOP_SIZE(result);
offset=0;
while (size--) {
- l = aopGet(AOP(left),offset,FALSE,TRUE);
+ l = aopGet(AOP(left),offset);
if (*l == '@' && (IS_AOP_PREG(result))) {
emitcode("mov","a,%s",l);
if (size == 1) {
symbol *tlbl1 = newiTempLabel(NULL);
- l = aopGet(AOP(left),0,FALSE,FALSE);
+ l = aopGet(AOP(left),0);
MOVA(l);
emitcode("sjmp","%05d$",tlbl1->key+100);
emitcode("","%05d$:",tlbl->key+100);
emitcode("sjmp","%05d$",tlbl1->key+100);
emitcode("","%05d$:",tlbl->key+100);
- l = aopGet(AOP(result),offset,FALSE,FALSE);
+ l = aopGet(AOP(result),offset);
MOVA(l);
emitcode("add","a,acc");
aopPut(AOP(result),"a",offset++);
while (--size) {
- l = aopGet(AOP(result),offset,FALSE,FALSE);
+ l = aopGet(AOP(result),offset);
MOVA(l);
emitcode("rlc","a");
aopPut(AOP(result),"a",offset++);
{
if(!sign)
emitcode("clr","c");
- MOVA(aopGet(AOP(left),MSB32,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),MSB32));
if(sign)
emitcode("mov","c,acc.7");
emitcode("rrc","a");
/* add sign of "a" */
addSign(result, MSB32, sign);
- MOVA(aopGet(AOP(left),MSB24,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),MSB24));
emitcode("rrc","a");
aopPut(AOP(result),"a",MSB24-offl);
- MOVA(aopGet(AOP(left),MSB16,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),MSB16));
emitcode("rrc","a");
aopPut(AOP(result),"a",MSB16-offl);
if(offl == LSB){
- MOVA(aopGet(AOP(left),LSB,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),LSB));
emitcode("rrc","a");
aopPut(AOP(result),"a",LSB);
}
else if(shCount >= (size * 8)){
if(sign)
/* get sign in acc.7 */
- MOVA(aopGet(AOP(left),size-1,FALSE,FALSE));
+ MOVA(aopGet(AOP(left),size-1));
addSign(result, LSB, sign);
} else{
switch (size) {
more that 32 bits make no sense anyway, ( the
largest size of an object can be only 32 bits ) */
- emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE));
+ emitcode("mov","b,%s",aopGet(AOP(right),0));
emitcode("inc","b");
freeAsmop (right,NULL,ic,TRUE);
aopOp(left,ic,FALSE);
size = AOP_SIZE(result);
offset=0;
while (size--) {
- l = aopGet(AOP(left),offset,FALSE,TRUE);
+ l = aopGet(AOP(left),offset);
if (*l == '@' && IS_AOP_PREG(result)) {
emitcode("mov","a,%s",l);
size = AOP_SIZE(result);
offset = size - 1;
- emitcode("mov","a,%s",aopGet(AOP(left),offset,FALSE,FALSE));
+ emitcode("mov","a,%s",aopGet(AOP(left),offset));
emitcode("rlc","a");
emitcode("mov","ov,c");
/* if it is only one byte then */
if (size == 1) {
- l = aopGet(AOP(left),0,FALSE,FALSE);
+ l = aopGet(AOP(left),0);
MOVA(l);
emitcode("sjmp","%05d$",tlbl1->key+100);
emitcode("","%05d$:",tlbl->key+100);
emitcode("","%05d$:",tlbl->key+100);
emitcode("mov","c,ov");
while (size--) {
- l = aopGet(AOP(result),offset,FALSE,FALSE);
+ l = aopGet(AOP(result),offset);
MOVA(l);
emitcode("rrc","a");
aopPut(AOP(result),"a",offset--);
more that 32 bits make no sense anyway, ( the
largest size of an object can be only 32 bits ) */
- emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE));
+ emitcode("mov","b,%s",aopGet(AOP(right),0));
emitcode("inc","b");
freeAsmop (right,NULL,ic,TRUE);
aopOp(left,ic,FALSE);
size = AOP_SIZE(result);
offset=0;
while (size--) {
- l = aopGet(AOP(left),offset,FALSE,TRUE);
+ l = aopGet(AOP(left),offset);
if (*l == '@' && IS_AOP_PREG(result)) {
emitcode("mov","a,%s",l);
/* if it is only one byte then */
if (size == 1) {
- l = aopGet(AOP(left),0,FALSE,FALSE);
+ l = aopGet(AOP(left),0);
MOVA(l);
emitcode("sjmp","%05d$",tlbl1->key+100);
emitcode("","%05d$:",tlbl->key+100);
emitcode("","%05d$:",tlbl->key+100);
CLRC;
while (size--) {
- l = aopGet(AOP(result),offset,FALSE,FALSE);
+ l = aopGet(AOP(result),offset);
MOVA(l);
emitcode("rrc","a");
aopPut(AOP(result),"a",offset--);
aopOp(result,ic,TRUE);
/* get the string representation of the name */
- l = aopGet(AOP(left),0,FALSE,TRUE);
+ l = aopGet(AOP(left),0);
size = AOP_SIZE(result);
while (size--) {
if (offset)
if (!AOP_INPREG(AOP(left))) {
/* otherwise get a free pointer register */
aop = newAsmop(0);
- preg = getFreePtr(ic,&aop,FALSE);
+ preg = getFreePtr(ic,&aop,FALSE,0);
emitcode("mov","%s,%s",
preg->name,
- aopGet(AOP(left),0,FALSE,TRUE));
+ aopGet(AOP(left),0));
rname = preg->name ;
} else
- rname = aopGet(AOP(left),0,FALSE,FALSE);
+ rname = aopGet(AOP(left),0);
freeAsmop(left,NULL,ic,TRUE);
aopOp (result,ic,FALSE);
if (!AOP_INPREG(AOP(left))) {
/* otherwise get a free pointer register */
aop = newAsmop(0);
- preg = getFreePtr(ic,&aop,FALSE);
+ preg = getFreePtr(ic,&aop,FALSE,0);
emitcode("mov","%s,%s",
preg->name,
- aopGet(AOP(left),0,FALSE,TRUE));
+ aopGet(AOP(left),0));
rname = preg->name ;
} else
- rname = aopGet(AOP(left),0,FALSE,FALSE);
+ rname = aopGet(AOP(left),0);
freeAsmop(left,NULL,ic,TRUE);
aopOp (result,ic,FALSE);
if (AOP_TYPE(left) != AOP_STR) {
/* if this is remateriazable */
if (AOP_TYPE(left) == AOP_IMMD)
- emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE));
+ emitcode("mov","dptr,%s",aopGet(AOP(left),0));
else { /* we need to get it byte by byte */
- emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE));
- emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE));
+ emitcode("mov","dpl,%s",aopGet(AOP(left),0));
+ emitcode("mov","dph,%s",aopGet(AOP(left),1));
if (options.model == MODEL_FLAT24)
{
- emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE));
+ emitcode("mov", "dpx,%s",aopGet(AOP(left),2));
}
}
}
if (AOP_TYPE(left) != AOP_STR) {
/* if this is remateriazable */
if (AOP_TYPE(left) == AOP_IMMD)
- emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE));
+ emitcode("mov","dptr,%s",aopGet(AOP(left),0));
else { /* we need to get it byte by byte */
- emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE));
- emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE));
+ emitcode("mov","dpl,%s",aopGet(AOP(left),0));
+ emitcode("mov","dph,%s",aopGet(AOP(left),1));
if (options.model == MODEL_FLAT24)
{
- emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE));
+ emitcode("mov", "dpx,%s",aopGet(AOP(left),2));
}
}
}
if (AOP_TYPE(left) != AOP_STR) {
/* if this is remateriazable */
if (AOP_TYPE(left) == AOP_IMMD) {
- emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE));
+ emitcode("mov","dptr,%s",aopGet(AOP(left),0));
emitcode("mov","b,#%d",pointerCode(retype));
}
else { /* we need to get it byte by byte */
- emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE));
- emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE));
+ emitcode("mov","dpl,%s",aopGet(AOP(left),0));
+ emitcode("mov","dph,%s",aopGet(AOP(left),1));
if (options.model == MODEL_FLAT24)
{
- emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE));
- emitcode("mov","b,%s",aopGet(AOP(left),3,FALSE,FALSE));
+ emitcode("mov", "dpx,%s",aopGet(AOP(left),2));
+ emitcode("mov","b,%s",aopGet(AOP(left),3));
}
else
{
- emitcode("mov","b,%s",aopGet(AOP(left),2,FALSE,FALSE));
+ emitcode("mov","b,%s",aopGet(AOP(left),2));
}
}
}
blen = SPEC_BLEN(etype);
bstr = SPEC_BSTR(etype);
- l = aopGet(AOP(right),offset++,FALSE,FALSE);
+ l = aopGet(AOP(right),offset++);
MOVA(l);
/* if the bit lenth is less than or */
/* now generate for lengths greater than one byte */
while (1) {
- l = aopGet(AOP(right),offset++,FALSE,TRUE);
+ l = aopGet(AOP(right),offset++);
rLen -= 8 ;
if (rLen <= 0 )
aopOp(right,ic,FALSE);
- l = aopGet(AOP(result),0,FALSE,TRUE);
+ l = aopGet(AOP(result),0);
size = AOP_SIZE(right);
while (size--) {
if (offset)
else
sprintf(buffer,"%s",l+1);
emitcode("mov","%s,%s",buffer,
- aopGet(AOP(right),offset++,FALSE,FALSE));
+ aopGet(AOP(right),offset++));
}
freeAsmop(right,NULL,ic,TRUE);
if (!AOP_INPREG(AOP(result))) {
/* otherwise get a free pointer register */
aop = newAsmop(0);
- preg = getFreePtr(ic,&aop,FALSE);
+ preg = getFreePtr(ic,&aop,FALSE,0);
emitcode("mov","%s,%s",
preg->name,
- aopGet(AOP(result),0,FALSE,TRUE));
+ aopGet(AOP(result),0));
rname = preg->name ;
} else
- rname = aopGet(AOP(result),0,FALSE,FALSE);
+ rname = aopGet(AOP(result),0);
freeAsmop(result,NULL,ic,TRUE);
aopOp (right,ic,FALSE);
int offset = 0 ;
while (size--) {
- l = aopGet(AOP(right),offset,FALSE,TRUE);
+ l = aopGet(AOP(right),offset);
if (*l == '@' ) {
MOVA(l);
emitcode("mov","@%s,a",rname);
if (!AOP_INPREG(AOP(result))) {
/* otherwise get a free pointer register */
aop = newAsmop(0);
- preg = getFreePtr(ic,&aop,FALSE);
+ preg = getFreePtr(ic,&aop,FALSE,0);
emitcode("mov","%s,%s",
preg->name,
- aopGet(AOP(result),0,FALSE,TRUE));
+ aopGet(AOP(result),0));
rname = preg->name ;
} else
- rname = aopGet(AOP(result),0,FALSE,FALSE);
+ rname = aopGet(AOP(result),0);
freeAsmop(result,NULL,ic,TRUE);
aopOp (right,ic,FALSE);
int offset = 0 ;
while (size--) {
- l = aopGet(AOP(right),offset,FALSE,TRUE);
+ l = aopGet(AOP(right),offset);
MOVA(l);
emitcode("movx","@%s,a",rname);
if (AOP_TYPE(result) != AOP_STR) {
/* if this is remateriazable */
if (AOP_TYPE(result) == AOP_IMMD)
- emitcode("mov","dptr,%s",aopGet(AOP(result),0,TRUE,FALSE));
+ emitcode("mov","dptr,%s",aopGet(AOP(result),0));
else { /* we need to get it byte by byte */
- emitcode("mov","dpl,%s",aopGet(AOP(result),0,FALSE,FALSE));
- emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE));
+ emitcode("mov","dpl,%s",aopGet(AOP(result),0));
+ emitcode("mov","dph,%s",aopGet(AOP(result),1));
if (options.model == MODEL_FLAT24)
{
- emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE));
+ emitcode("mov", "dpx,%s",aopGet(AOP(result),2));
}
}
}
offset = 0 ;
while (size--) {
- char *l = aopGet(AOP(right),offset++,FALSE,FALSE);
+ char *l = aopGet(AOP(right),offset++);
MOVA(l);
emitcode("movx","@dptr,a");
if (size)
if (AOP_TYPE(result) != AOP_STR) {
/* if this is remateriazable */
if (AOP_TYPE(result) == AOP_IMMD) {
- emitcode("mov","dptr,%s",aopGet(AOP(result),0,TRUE,FALSE));
- emitcode("mov","b,%s + 1",aopGet(AOP(result),0,TRUE,FALSE));
+ emitcode("mov","dptr,%s",aopGet(AOP(result),0));
+ emitcode("mov","b,%s + 1",aopGet(AOP(result),0));
}
else { /* we need to get it byte by byte */
- emitcode("mov","dpl,%s",aopGet(AOP(result),0,FALSE,FALSE));
- emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE));
+ emitcode("mov","dpl,%s",aopGet(AOP(result),0));
+ emitcode("mov","dph,%s",aopGet(AOP(result),1));
if (options.model == MODEL_FLAT24)
{
- emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE));
- emitcode("mov","b,%s",aopGet(AOP(result),3,FALSE,FALSE));
+ emitcode("mov", "dpx,%s",aopGet(AOP(result),2));
+ emitcode("mov","b,%s",aopGet(AOP(result),3));
}
else
{
- emitcode("mov","b,%s",aopGet(AOP(result),2,FALSE,FALSE));
+ emitcode("mov","b,%s",aopGet(AOP(result),2));
}
}
}
offset = 0 ;
while (size--) {
- char *l = aopGet(AOP(right),offset++,FALSE,FALSE);
+ char *l = aopGet(AOP(right),offset++);
MOVA(l);
emitcode("lcall","__gptrput");
if (size)
/* get the value into acc */
if (AOP_TYPE(cond) != AOP_CRY)
- toBoolean(cond);
+ toBoolean(cond,"",0);
else
isbit = 1;
/* the result is now in the accumulator */
genIpop(popIc);
/* if the condition is a bit variable */
- if (isbit && IS_ITEMP(cond) &&
- SPIL_LOC(cond))
- genIfxJump(ic,SPIL_LOC(cond)->rname);
- else
- if (isbit && !IS_ITEMP(cond))
- genIfxJump(ic,OP_SYMBOL(cond)->rname);
- else
- genIfxJump(ic,"a");
+/* if (isbit && IS_ITEMP(cond) && SPIL_LOC(cond)) { */
+/* // genIfxJump(ic,SPIL_LOC(cond)->rname); */
+/* } */
+/* else */
+/* if (isbit && !IS_ITEMP(cond)) */
+/* // genIfxJump(ic,OP_SYMBOL(cond)->rname); */
+/* else */
+/* // genIfxJump(ic,"a"); */
ic->generated = 1;
}
char *l ;
/* first push the right side on to the stack */
while (size--) {
- l = aopGet(AOP(right),offset++,FALSE,FALSE);
+ l = aopGet(AOP(right),offset++);
MOVA(l);
emitcode ("push","acc");
}
aopOp(right,ic,FALSE);
/* special case both in far space */
- if ((AOP_TYPE(right) == AOP_DPTR ||
- AOP_TYPE(right) == AOP_DPTR2) &&
+ if (AOP_TYPE(right) == AOP_DPTR &&
IS_TRUE_SYMOP(result) &&
isOperandInFarSpace(result)) {
}
/* we need to or */
- toBoolean(right);
+ toBoolean(right,"",0);
aopPut(AOP(result),"a",0);
goto release ;
}
aopPut(AOP(result),"a",size);
else
aopPut(AOP(result),
- aopGet(AOP(right),size,FALSE,FALSE),
+ aopGet(AOP(right),size),
size);
}
} else {
while (size--) {
aopPut(AOP(result),
- aopGet(AOP(right),offset,FALSE,FALSE),
+ aopGet(AOP(right),offset),
offset);
offset++;
}
aopOp(IC_JTCOND(ic),ic,FALSE);
/* get the condition into accumulator */
- l = aopGet(AOP(IC_JTCOND(ic)),0,FALSE,FALSE);
+ l = aopGet(AOP(IC_JTCOND(ic)),0);
MOVA(l);
/* multiply by three */
emitcode("add","a,acc");
- emitcode("add","a,%s",aopGet(AOP(IC_JTCOND(ic)),0,FALSE,FALSE));
+ emitcode("add","a,%s",aopGet(AOP(IC_JTCOND(ic)),0));
freeAsmop(IC_JTCOND(ic),NULL,ic,TRUE);
jtab = newiTempLabel(NULL);
}
/* we need to or */
- toBoolean(right);
+ toBoolean(right,"",0);
aopPut(AOP(result),"a",0);
goto release ;
}
offset = 0 ;
while (size--) {
aopPut(AOP(result),
- aopGet(AOP(right),offset,FALSE,FALSE),
+ aopGet(AOP(right),offset),
offset);
offset++;
}
offset = 0 ;
while (size--) {
aopPut(AOP(result),
- aopGet(AOP(right),offset,FALSE,FALSE),
+ aopGet(AOP(right),offset),
offset);
offset++;
}
offset = 0 ;
while (size--) {
aopPut(AOP(result),
- aopGet(AOP(right),offset,FALSE,FALSE),
+ aopGet(AOP(right),offset),
offset);
offset++;
}
offset = 0 ;
while (size--) {
aopPut(AOP(result),
- aopGet(AOP(right),offset,FALSE,FALSE),
+ aopGet(AOP(right),offset),
offset);
offset++;
}
aopPut(AOP(result),zero,offset++);
} else {
/* we need to extend the sign :{ */
- char *l = aopGet(AOP(right),AOP_SIZE(right) - 1,
- FALSE,FALSE);
+ char *l = aopGet(AOP(right),AOP_SIZE(right) - 1);
MOVA(l);
emitcode("rlc","a");
emitcode("subb","a,acc");
if (IS_AOP_PREG(IC_RESULT(ic))) {
emitcode("dec","%s",
- aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
- emitcode("mov","a,%s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
+ aopGet(AOP(IC_RESULT(ic)),0));
+ emitcode("mov","a,%s",aopGet(AOP(IC_RESULT(ic)),0));
emitcode("jnz","%05d$",lbl->key+100);
} else {
- emitcode ("djnz","%s,%05d$",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE),
+ emitcode ("djnz","%s,%05d$",aopGet(AOP(IC_RESULT(ic)),0),
lbl->key+100);
}
emitcode ("sjmp","%05d$",lbl1->key+100);
IS_TRUE_SYMOP(IC_RESULT(ic))) ) {
int size = getSize(operandType(IC_RESULT(ic)));
- int offset = fReturnSize - size;
+ int offset = fAVRReturnSize - size;
while (size--) {
- emitcode ("push","%s", (strcmp(fReturn[fReturnSize - offset - 1],"a") ?
- fReturn[fReturnSize - offset - 1] : "acc"));
+ emitcode ("push","%s", (strcmp(fAVRReturn[fAVRReturnSize - offset - 1],"a") ?
+ fAVRReturn[fAVRReturnSize - offset - 1] : "acc"));
offset++;
}
aopOp(IC_RESULT(ic),ic,FALSE);
/*-----------------------------------------------------------------*/
/* gen51Code - generate code for 8051 based controllers */
/*-----------------------------------------------------------------*/
-void gen51Code (iCode *lic)
+void genAVRCode (iCode *lic)
{
iCode *ic;
int cln = 0;
case LE_OP:
genCmpLe (ic,ifxForOp(IC_RESULT(ic),ic));
- break
+ break;
case GE_OP:
genCmpGe (ic,ifxForOp(IC_RESULT(ic),ic));