stuff. This is what it is all about CODE GENERATION for a specific MCU.
Some of the routines may be reusable, will have to see */
+
static char *zero = "#0x00";
static char *one = "#0x01";
static char *spname ;
static int _lastStack = 0;
static int _pushed = 0;
static int _spoffset;
-static int _lastHLOff = 0;
-static asmop *_lastHL;
#define LSB 0
#define MSB16 1
static struct {
struct {
+ AOP_TYPE last_type;
const char *lit;
int offset;
} HL;
break;
}
}
- assert(0);
+ wassert(0);
return NULL;
}
if (sym->onStack || sym->iaccess) {
sym->aop = aop = newAsmop(AOP_STK);
aop->size = getSize(sym->type);
- _lastHL = NULL;
aop->aopu.aop_stk = sym->stack;
return aop;
}
/* in which case DPTR gets the address */
if (IS_GB) {
sym->aop = aop = newAsmop(AOP_HL);
- _lastHL = NULL;
}
else {
sym->aop = aop = newAsmop(AOP_IY);
aop->freed = 1;
- switch (aop->type) {
- case AOP_STK :
- break;
- }
-
dealloc:
/* all other cases just dealloc */
if (op ) {
char *s = buffer ;
char *rs;
- if (aop->size != 2)
+ if (aop->size != 2 && aop->type != AOP_HL)
return NULL;
- assert(offset == 0);
+ wassert(offset == 0);
/* depending on type */
switch (aop->type) {
+ case AOP_HL:
+ wassert(IS_GB);
+ /* Fall through */
case AOP_IMMD:
sprintf (s,"%s%s",with_hash ? "#" : "", aop->aopu.aop_immd);
ALLOC_ATOMIC(rs,strlen(s)+1);
strcpy(rs,s);
return rs;
-
case AOP_LIT: {
value * val = aop->aopu.aop_lit;
/* if it is a float then it gets tricky */
ALLOC_ATOMIC(rs,strlen(buffer)+1);
return strcpy (rs,buffer);
}
- assert(0);
+ wassert(0);
return NULL;
}
+ default:
+ return NULL;
}
- return NULL;
}
char *aopGetWord(asmop *aop, int offset)
static void adjustPair(const char *pair, int *pold, int new)
{
- assert(pair);
+ wassert(pair);
while (*pold < new) {
emitcode("inc", "%s", pair);
static void spillHL(void)
{
+ _G.HL.last_type = AOP_INVALID;
_G.HL.lit = NULL;
}
}
}
-static void fetchHL(asmop *aop)
-{
- spillHL();
- if (IS_GB && requiresHL(aop)) {
- aopGet(aop, 0, FALSE);
- emitcode("ld", "a,(hl+)");
- emitcode("ld", "h,(hl)");
- emitcode("ld", "l,a");
- }
- else {
- emitcode("ld", "l,%s", aopGet(aop, 0, FALSE));
- emitcode("ld", "h,%s", aopGet(aop, 1, FALSE));
- }
-}
-
static void fetchLitPair(int pairId, asmop *left, int offset)
{
const char *l;
const char *pair = _pairs[pairId].name;
l = aopGetLitWordLong(left, 0, FALSE);
- assert(l && pair);
+ wassert(l && pair);
if (isPtr(pair)) {
if (_G.HL.lit && !strcmp(_G.HL.lit, l) && abs(_G.HL.offset - offset) < 3) {
adjustPair(pair, &_G.HL.offset, offset);
}
else {
+ _G.HL.last_type = left->type;
_G.HL.lit = _strdup(l);
_G.HL.offset = offset;
- emitcode("ld", "%s,#%s + %d", pair, l, offset);
+ if (offset)
+ emitcode("ld", "%s,#%s + %d", pair, l, offset);
+ else
+ emitcode("ld", "%s,#%s", pair, l);
}
}
else {
/* Both a lit on the right and a true symbol on the left */
- emitcode("ld", "%s,#%s + %d", pair, l, offset);
+ if (offset)
+ emitcode("ld", "%s,#%s + %d", pair, l, offset);
+ else
+ emitcode("ld", "%s,#%s", pair, l);
}
}
-static void setupHL(asmop *aop, int offset)
+static void fetchPair(int pairId, asmop *aop)
{
- spillHL();
- if (_lastHL != aop) {
- switch (aop->type) {
- case AOP_HL:
- emitcode("", ";1");
- fetchLitPair(PAIR_HL, aop, offset);
- break;
- case AOP_STK:
- /* In some cases we can still inc or dec hl */
- emitcode("lda", "hl,%d+%d+%d(sp)", aop->aopu.aop_stk+offset, _pushed, _spoffset);
- break;
- default:
- assert(0);
+ /* if this is remateriazable */
+ if (isLitWord(aop)) {
+ fetchLitPair(pairId, aop, 0);
+ }
+ else { /* we need to get it byte by byte */
+ if (pairId == PAIR_HL && IS_GB && requiresHL(aop)) {
+ aopGet(aop, 0, FALSE);
+ emitcode("ld", "a,(hl+)");
+ emitcode("ld", "h,(hl)");
+ emitcode("ld", "l,a");
+ }
+ else {
+ emitcode("ld", "%s,%s", _pairs[pairId].l, aopGet(aop, 0, FALSE));
+ emitcode("ld", "%s,%s", _pairs[pairId].h, aopGet(aop, 1, FALSE));
}
- _lastHL = aop;
- _lastHLOff = offset;
+ /* PENDING: check? */
+ if (pairId == PAIR_HL)
+ spillHL();
}
- else {
- while (offset < _lastHLOff) {
- emitcode("dec", "hl");
- _lastHLOff--;
+}
+
+static void fetchHL(asmop *aop)
+{
+ fetchPair(PAIR_HL, aop);
+}
+
+static void setupHL(asmop *aop, int offset)
+{
+ switch (aop->type) {
+ case AOP_HL:
+ emitcode("", ";1");
+ fetchLitPair(PAIR_HL, aop, offset);
+ _G.HL.offset = offset;
+ break;
+ case AOP_STK: {
+ /* Doesnt include _pushed */
+ int abso = aop->aopu.aop_stk + offset + _spoffset;
+ /* In some cases we can still inc or dec hl */
+ if (_G.HL.last_type == AOP_STK && abs(_G.HL.offset - abso) < 3) {
+ adjustPair("hl", &_G.HL.offset, abso);
}
- while (offset > _lastHLOff) {
- emitcode("inc", "hl");
- _lastHLOff++;
+ else {
+ emitcode("lda", "hl,%d+%d+%d(sp)", aop->aopu.aop_stk+offset, _pushed, _spoffset);
}
+ _G.HL.offset = abso;
+ break;
}
+ default:
+ wassert(0);
+ }
+ _G.HL.last_type = aop->type;
+}
+
+static void emitLabel(int key)
+{
+ emitcode("", LABEL_STR ":", key);
+ spillHL();
}
/*-----------------------------------------------------------------*/
sprintf (s,"#%s ; 5",aop->aopu.aop_immd);
else
if (offset) {
- assert(offset == 1);
+ wassert(offset == 1);
sprintf(s,"#>%s",
aop->aopu.aop_immd);
}
return rs;
case AOP_DIR:
- assert(IS_GB);
+ wassert(IS_GB);
emitcode("ld", "a,(%s+%d) ; x", aop->aopu.aop_dir, offset);
sprintf(s, "a");
ALLOC_ATOMIC(rs,strlen(s)+1);
return aop->aopu.aop_reg[offset]->name;
case AOP_HL:
- assert(IS_GB);
+ wassert(IS_GB);
emitcode("", ";3");
setupHL(aop, offset);
sprintf(s, "(hl)");
return rs;
case AOP_CRY:
- assert(0);
+ wassert(0);
case AOP_ACC:
if (!offset) {
case AOP_STR:
aop->coff = offset;
return aop->aopu.aop_str[offset];
+ default:
+ break;
}
-
- fprintf(stderr, "Type %u\n", aop->type);
-
- werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
- "aopget got unsupported aop->type");
+ wassertl(0, "aopget got unsupported aop->type");
exit(0);
}
switch (aop->type) {
case AOP_DIR:
/* Direct. Hmmm. */
- assert(IS_GB);
+ wassert(IS_GB);
emitcode("ld", "a,%s", s);
emitcode("ld", "(%s+%d),a", aop->aopu.aop_dir, offset);
break;
break;
case AOP_IY:
- assert(!IS_GB);
+ wassert(!IS_GB);
if (!canAssignToPtr(s)) {
emitcode("ld", "a,%s", s);
emitcode("ld", "%d(iy),a", offset);
break;
case AOP_HL:
- assert(IS_GB);
+ wassert(IS_GB);
if (!strcmp(s, "(hl)")) {
emitcode("ld", "a,(hl)");
s = "a";
emitcode("rla", "");
} else {
/* In bit space but not in C - cant happen */
- assert(0);
+ wassert(0);
}
break;
size = AOP_SIZE(op);
if(size == 3) {
/* pointer */
- assert(0);
+ wassert(0);
}
return size;
}
aopPut(AOP(result),l,offr);
}
else {
- assert(0);
+ wassert(0);
}
}
}
/* if in bit space then a special case */
if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY) {
- assert(0);
+ wassert(0);
}
/* if type float then do float */
if (IS_FLOAT(optype)) {
- assert(0);
+ wassert(0);
}
toBoolean(IC_LEFT(ic));
a special case */
if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY &&
AOP_TYPE(IC_LEFT(ic)) == AOP_CRY ) {
- assert(0);
+ wassert(0);
}
size = AOP_SIZE(IC_RESULT(ic));
case */
if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY &&
AOP_TYPE(IC_LEFT(ic)) == AOP_CRY ) {
- assert(0);
+ wassert(0);
goto release;
}
/* if float then do float stuff */
if (IS_FLOAT(optype)) {
- assert(0);
+ wassert(0);
goto release;
}
int offset = 0;
int size = AOP_SIZE(oper);
- assert(size <= 2);
+ wassert(size <= 2);
while (size--) {
aopPut(AOP(oper),_fReturn[offset],offset);
}
else {
if (size == 2) {
- char *s = aopGetWord(AOP(IC_LEFT(ic)), 0);
- if (s) {
- emitcode("ld", "hl,%s", s);
- emitcode("push", "hl");
- _pushed+=2;
- }
- else {
- /* Optimise here - load into HL then push HL */
- fetchHL(AOP(IC_LEFT(ic)));
- emitcode("push", "hl");
- _pushed += 2;
- }
+ fetchHL(AOP(IC_LEFT(ic)));
+ emitcode("push", "hl ; 2");
+ spillHL();
+ _pushed += 2;
goto release;
}
offset = size;
while (size--) {
emitcode("dec", "sp");
emitcode("pop", "hl");
+ spillHL();
aopPut(AOP(IC_LEFT(ic)), "l", offset--);
}
}
}
if (ispcall) {
- symbol *rlbl = newiTempLabel(NULL);
-
- emitcode("ld", "hl,#" LABEL_STR, (rlbl->key+100));
- emitcode("push", "hl");
- _pushed += 2;
-
aopOp(IC_LEFT(ic),ic,FALSE);
- fetchHL(AOP(IC_LEFT(ic)));
+
+ if (isLitWord(AOP(IC_LEFT(ic)))) {
+ emitcode("", "; Special case where the pCall is to a constant");
+ emitcode("call", aopGetLitWordLong(AOP(IC_LEFT(ic)), 0, FALSE));
+ }
+ else {
+ symbol *rlbl = newiTempLabel(NULL);
+ spillHL();
+ emitcode("ld", "hl,#" LABEL_STR, (rlbl->key+100));
+ emitcode("push", "hl");
+ _pushed += 2;
+
+ fetchHL(AOP(IC_LEFT(ic)));
+ emitcode("jp", "(hl)");
+ emitcode("","%05d$:",(rlbl->key+100));
+ _pushed -= 2;
+ }
freeAsmop(IC_LEFT(ic),NULL,ic);
-
- emitcode("jp", "(hl)");
- emitcode("","%05d$:",(rlbl->key+100));
- _pushed -= 2;
}
else {
/* make the call */
OP_SYMBOL(IC_LEFT(ic))->name;
emitcode("call", "%s", name);
}
+ spillHL();
/* if we need assign a result value */
if ((IS_ITEMP(IC_RESULT(ic)) &&
emitcode("lda", "sp,%d(sp)", i);
}
else {
+ spillHL();
if (i>6) {
emitcode("ld", "hl,#%d", i);
emitcode("add", "hl,sp");
if (i)
emitcode("inc", "sp");
}
+ spillHL();
}
}
/*-----------------------------------------------------------------*/
static void genFunction (iCode *ic)
{
- symbol *sym;
+ symbol *sym = OP_SYMBOL(IC_LEFT(ic));
link *fetype;
nregssaved = 0;
/* create the function header */
emitcode(";","-----------------------------------------");
- emitcode(";"," function %s",(sym = OP_SYMBOL(IC_LEFT(ic)))->name);
+ emitcode(";"," function %s", sym->name);
emitcode(";","-----------------------------------------");
- emitcode("","%s:",sym->rname);
emitcode("", "__%s_start:", sym->rname);
+ emitcode("","%s:",sym->rname);
+
fetype = getSpec(operandType(IC_LEFT(ic)));
/* if critical function then turn interrupts off */
symbol *sym = OP_SYMBOL(IC_LEFT(ic));
if (IS_ISR(sym->etype)) {
- assert(0);
+ wassert(0);
}
else {
if (SPEC_CRTCL(sym->etype))
}
emitcode("pop", "bc");
emitcode("ret", "");
+ emitcode("; Useful for profiling and debugging", "");
+ emitcode(".dw", "%s", sym->rname);
emitcode("", "__%s_end:", sym->rname);
}
_pushed = 0;
if (IC_LABEL(ic) == entryLabel)
return ;
- emitcode("", LABEL_STR ":",(IC_LABEL(ic)->key+100));
+ emitLabel(IC_LABEL(ic)->key+100);
}
/*-----------------------------------------------------------------*/
emitcode("inc","%s",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE));
if(size == 4) {
- assert(0);
+ wassert(0);
}
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
return TRUE;
}
symbol *tlbl = newiTempLabel(NULL);
/* if the result is a bit */
if (AOP_TYPE(result) == AOP_CRY){
- assert(0);
+ wassert(0);
}
else {
emitcode(_shortJP,"z," LABEL_STR ,tlbl->key+100);
emitcode("ld","a,%s",one);
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
outAcc(result);
}
}
if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY &&
AOP_TYPE(IC_RIGHT(ic)) == AOP_CRY) {
/* Cant happen */
- assert(0);
+ wassert(0);
}
/* if left in bit space & right literal */
if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY &&
AOP_TYPE(IC_RIGHT(ic)) == AOP_LIT) {
/* Can happen I guess */
- assert(0);
+ wassert(0);
}
/* if I can do an increment instead
if (AOP_SIZE(IC_RESULT(ic)) == 3 &&
AOP_SIZE(IC_LEFT(ic)) == 3 &&
!sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))))
- assert(0);
+ wassert(0);
if (AOP_SIZE(IC_RESULT(ic)) == 3 &&
AOP_SIZE(IC_RIGHT(ic)) == 3 &&
!sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic))))
- assert(0);
+ wassert(0);
release:
emitcode("dec","%s",aopGet(AOP(IC_RESULT(ic)),MSB16,FALSE));
if(size == 4) {
- assert(0);
+ wassert(0);
}
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
return TRUE;
}
#endif
/* if both left & right are in bit space */
if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY &&
AOP_TYPE(IC_RIGHT(ic)) == AOP_CRY) {
- assert(0);
+ wassert(0);
goto release ;
}
if (AOP_SIZE(IC_RESULT(ic)) == 3 &&
AOP_SIZE(IC_LEFT(ic)) == 3 &&
!sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))))
- assert(0);
+ wassert(0);
release:
freeAsmop(IC_LEFT(ic),NULL,ic);
static void genMult (iCode *ic)
{
/* Shouldn't occur - all done through function calls */
- assert(0);
+ wassert(0);
}
/*-----------------------------------------------------------------*/
static void genDiv (iCode *ic)
{
/* Shouldn't occur - all done through function calls */
- assert(0);
+ wassert(0);
}
/*-----------------------------------------------------------------*/
static void genMod (iCode *ic)
{
/* Shouldn't occur - all done through function calls */
- assert(0);
+ wassert(0);
}
/*-----------------------------------------------------------------*/
if (AOP_TYPE(left) == AOP_CRY &&
AOP_TYPE(right) == AOP_CRY ) {
/* Cant happen on the Z80 */
- assert(0);
+ wassert(0);
} else {
/* subtract right from left if at the
end the carry flag is set then we know that
/* PENDING: ?? */
emitcode("ld","a,%s",one);
emitcode(_shortJP, LABEL_STR ,tlbl->key+100);
- emitcode("", LABEL_STR ":",lbl->key+100);
+ emitLabel(lbl->key+100);
emitcode("xor","a,a");
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
}
/*-----------------------------------------------------------------*/
/* if they are both bit variables */
if (AOP_TYPE(left) == AOP_CRY &&
((AOP_TYPE(right) == AOP_CRY) || (AOP_TYPE(right) == AOP_LIT))) {
- assert(0);
+ wassert(0);
} else {
tlbl = newiTempLabel(NULL);
gencjneshort(left, right, tlbl);
if ( IC_TRUE(ifx) ) {
emitcode("jp", LABEL_STR ,IC_TRUE(ifx)->key+100);
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
} else {
/* PENDING: do this better */
symbol *lbl = newiTempLabel(NULL);
emitcode(_shortJP, LABEL_STR ,lbl->key+100);
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
emitcode("jp", LABEL_STR ,IC_FALSE(ifx)->key+100);
- emitcode("", LABEL_STR ":",lbl->key+100);
+ emitLabel(lbl->key+100);
}
}
/* mark the icode as generated */
/* if they are both bit variables */
if (AOP_TYPE(left) == AOP_CRY &&
((AOP_TYPE(right) == AOP_CRY) || (AOP_TYPE(right) == AOP_LIT))) {
- assert(0);
+ wassert(0);
} else {
gencjne(left,right,newiTempLabel(NULL));
if (AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)) {
- assert(0);
+ wassert(0);
}
if (ifx) {
genIfxJump(ifx,"a");
/* if both are bit variables */
if (AOP_TYPE(left) == AOP_CRY &&
AOP_TYPE(right) == AOP_CRY ) {
- assert(0);
+ wassert(0);
} else {
tlbl = newiTempLabel(NULL);
toBoolean(left);
emitcode(_shortJP, "z," LABEL_STR ,tlbl->key+100);
toBoolean(right);
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
outBitAcc(result);
}
/* if both are bit variables */
if (AOP_TYPE(left) == AOP_CRY &&
AOP_TYPE(right) == AOP_CRY ) {
- assert(0);
+ wassert(0);
} else {
tlbl = newiTempLabel(NULL);
toBoolean(left);
emitcode(_shortJP, "nz," LABEL_STR,tlbl->key+100);
toBoolean(right);
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
outBitAcc(result);
}
if(IC_TRUE(ic)){
symbol *nlbl = newiTempLabel(NULL);
emitcode("jp", LABEL_STR, nlbl->key+100);
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
emitcode("jp",LABEL_STR,IC_TRUE(ic)->key+100);
- emitcode("", LABEL_STR ":",nlbl->key+100);
+ emitLabel(nlbl->key+100);
}
else{
emitcode("jp", LABEL_STR, IC_FALSE(ic)->key+100);
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
}
ic->generated = 1;
}
size = AOP_SIZE(result);
if (AOP_TYPE(left) == AOP_CRY){
- assert(0);
+ wassert(0);
goto release ;
}
MOVA(aopGet(AOP(left),posbit>>3,FALSE));
// bit = left & 2^n
if(size) {
- assert(0);
+ wassert(0);
emitcode("mov","c,acc.%d",posbit&0x07);
}
// if(left & 2^n)
genIfxJump(ifx, buffer);
}
else {
- assert(0);
+ wassert(0);
}
goto release;
}
symbol *tlbl = newiTempLabel(NULL);
int sizel = AOP_SIZE(left);
if(size) {
- assert(0);
+ wassert(0);
emitcode("setb","c");
}
while(sizel--){
MOVA( aopGet(AOP(left),offset,FALSE));
// byte == 2^n ?
if((posbit = isLiteralBit(bytelit)) != 0) {
- assert(0);
+ wassert(0);
emitcode("jb","acc.%d,%05d$",(posbit-1)&0x07,tlbl->key+100);
}
else{
} else {
if (AOP_TYPE(left) == AOP_ACC) {
- assert(0);
+ wassert(0);
}
else {
MOVA(aopGet(AOP(right),offset,FALSE));
} else {
// left & result in different registers
if(AOP_TYPE(result) == AOP_CRY){
- assert(0);
+ wassert(0);
} else {
for(;(size--);offset++) {
// normal case
size = AOP_SIZE(result);
if (AOP_TYPE(left) == AOP_CRY){
- assert(0);
+ wassert(0);
goto release ;
}
if((AOP_TYPE(right) == AOP_LIT) &&
(AOP_TYPE(result) == AOP_CRY) &&
(AOP_TYPE(left) != AOP_CRY)){
- assert(0);
+ wassert(0);
goto release ;
}
} else {
// left & result in different registers
if(AOP_TYPE(result) == AOP_CRY){
- assert(0);
+ wassert(0);
} else for(;(size--);offset++){
// normal case
// result = left & right
size = AOP_SIZE(result);
if (AOP_TYPE(left) == AOP_CRY){
- assert(0);
+ wassert(0);
goto release ;
}
if((AOP_TYPE(right) == AOP_LIT) &&
(AOP_TYPE(result) == AOP_CRY) &&
(AOP_TYPE(left) != AOP_CRY)){
- assert(0);
+ wassert(0);
goto release ;
}
} else {
// left & result in different registers
if(AOP_TYPE(result) == AOP_CRY){
- assert(0);
+ wassert(0);
} else for(;(size--);offset++){
// normal case
// result = left & right
/*-----------------------------------------------------------------*/
static void genRRC (iCode *ic)
{
- assert(0);
+ wassert(0);
}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/
static void genRLC (iCode *ic)
{
- assert(0);
+ wassert(0);
}
/*-----------------------------------------------------------------*/
{
if(sameRegs(AOP(result), AOP(left)) &&
((offl + MSB16) == offr)){
- assert(0);
+ wassert(0);
} else {
movLeft2Result(left, offl, result, offr, 0);
movLeft2Result(left, offl+1, result, offr+1, 0);
}
if (sign) {
- assert(0);
+ wassert(0);
}
else {
/* if (AOP(result)->type == AOP_REG) {*/
tlbl = newiTempLabel(NULL);
tlbl1 = newiTempLabel(NULL);
emitcode(_shortJP, LABEL_STR ,tlbl1->key+100);
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
}
emitcode("or", "a,a");
emitcode("rr","%s", l);
}
if (shCount>1) {
- emitcode("", LABEL_STR ":",tlbl1->key+100);
+ emitLabel(tlbl1->key+100);
emitcode("dec", "a");
emitcode(_shortJP,"nz," LABEL_STR ,tlbl->key+100);
}
{
if(sameRegs(AOP(result), AOP(left)) &&
((offl + MSB16) == offr)){
- assert(0);
+ wassert(0);
} else {
/* Copy left into result */
movLeft2Result(left, offl, result, offr, 0);
tlbl = newiTempLabel(NULL);
tlbl1 = newiTempLabel(NULL);
emitcode(_shortJP, LABEL_STR ,tlbl1->key+100);
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
}
emitcode("or", "a,a");
emitcode("rl","%s", l);
}
if (shCount>1) {
- emitcode("", LABEL_STR ":",tlbl1->key+100);
+ emitLabel(tlbl1->key+100);
emitcode("dec", "a");
emitcode(_shortJP,"nz," LABEL_STR ,tlbl->key+100);
}
{
int size = AOP_SIZE(result);
- assert(size==2);
+ wassert(size==2);
/* if shCount >= 8 */
if (shCount >= 8) {
/* 1 <= shCount <= 7 */
else {
if(size == 1) {
- assert(0);
+ wassert(0);
}
else {
shiftL2Left2Result(left, LSB, result, LSB, shCount);
/* I suppose that the left size >= result size */
if (shCount == 0) {
- assert(0);
+ wassert(0);
}
else if(shCount >= (size * 8))
genlshTwo (result,left,shCount);
break;
case 4:
- assert(0);
+ wassert(0);
break;
default:
- assert(0);
+ wassert(0);
}
}
freeAsmop(left,NULL,ic);
tlbl1 = newiTempLabel(NULL);
emitcode(_shortJP, LABEL_STR ,tlbl1->key+100);
- emitcode("", LABEL_STR ":",tlbl->key+100);
+ emitLabel(tlbl->key+100);
l = aopGet(AOP(result),offset,FALSE);
emitcode("or", "a,a");
while (size--) {
l = aopGet(AOP(result),offset++,FALSE);
emitcode("rl","%s", l);
}
- emitcode("", LABEL_STR ":",tlbl1->key+100);
+ emitLabel(tlbl1->key+100);
emitcode("dec", "a");
emitcode(_shortJP,"nz," LABEL_STR ,tlbl->key+100);
int size = AOP_SIZE(result);
char *l;
- assert(size==1);
- assert(shCount<8);
+ wassert(size==1);
+ wassert(shCount<8);
l = aopGet(AOP(left),0,FALSE);
if (AOP(result)->type == AOP_REG) {
{
MOVA(aopGet(AOP(left),offl,FALSE));
if (sign) {
- assert(0);
+ wassert(0);
}
else {
AccRsh(shCount);
if (shCount >= 8) {
shCount -= 8 ;
if (shCount) {
- assert(0);
+ wassert(0);
shiftR1Left2Result(left, MSB16, result, LSB,
shCount, sign);
}
/* I suppose that the left size >= result size */
if (shCount == 0) {
- assert(0);
+ wassert(0);
}
else if(shCount >= (size * 8))
genrshTwo(result, left, shCount, FALSE);
break;
case 4:
- assert(0);
+ wassert(0);
break;
default:
- assert(0);
+ wassert(0);
}
}
freeAsmop(left,NULL,ic);
return ;
}
else {
- assert(0);
+ wassert(0);
}
}
{
int size, offset ;
link *retype = getSpec(operandType(result));
- const char *ptr = "hl";
+ int pair = PAIR_HL;
if (IS_GB)
- ptr = "de";
+ pair = PAIR_DE;
aopOp(left,ic,FALSE);
aopOp(result,ic,FALSE);
/* For now we always load into IY */
/* if this is remateriazable */
- if (AOP_TYPE(left) == AOP_IMMD)
- emitcode("ld","%s,%s", ptr, aopGet(AOP(left),0,TRUE));
- else { /* we need to get it byte by byte */
- if (IS_GB) {
- emitcode("ld", "e,%s ; 1", aopGet(AOP(left), 0, FALSE));
- emitcode("ld", "d,%s ; 2", aopGet(AOP(left), 1, FALSE));
- }
- else
- fetchHL(AOP(left));
- }
+ fetchPair(pair, AOP(left));
+
/* so iy now contains the address */
freeAsmop(left,NULL,ic);
/* if bit then unpack */
if (IS_BITVAR(retype)) {
- assert(0);
+ wassert(0);
}
else {
size = AOP_SIZE(result);
aopPut(AOP(result),"(hl)",offset++);
}
else {
- emitcode("ld", "a,(%s)", ptr, offset);
+ emitcode("ld", "a,(%s)", _pairs[pair].name, offset);
aopPut(AOP(result),"a",offset++);
}
if (size) {
- emitcode("inc", "%s", ptr);
+ emitcode("inc", "%s", _pairs[pair].name);
}
}
}
return FALSE;
}
-static void fetchPair(int pairId, asmop *aop)
-{
- /* if this is remateriazable */
- if (aop->type == AOP_IMMD) {
- fetchLitPair(pairId, aop, 0);
- }
- else { /* we need to get it byte by byte */
- if (pairId == PAIR_HL) {
- fetchHL(aop);
- }
- else {
- emitcode("ld", "%s,%s", _pairs[pairId].l, 0, TRUE);
- emitcode("ld", "%s,%s", _pairs[pairId].h, 1, TRUE);
- }
- }
-}
-
/*-----------------------------------------------------------------*/
/* genGenPointerSet - stores the value into a pointer location */
/*-----------------------------------------------------------------*/
/* if bit then unpack */
if (IS_BITVAR(retype)) {
- assert(0);
+ wassert(0);
}
else {
size = AOP_SIZE(right);
variable */
if (IS_GB) {
if (sym->onStack) {
+ spillHL();
emitcode("lda", "hl,%d+%d+%d(sp)", sym->stack, _pushed, _spoffset);
emitcode("ld", "d,h");
emitcode("ld", "e,l");
aopPut(AOP(IC_RESULT(ic)), "d", 1);
}
else {
+ spillHL();
if (sym->onStack) {
/* if it has an offset then we need to compute it */
emitcode("push", "de");
/* if the result is a bit */
if (AOP_TYPE(result) == AOP_CRY) {
- assert(0);
+ wassert(0);
}
/* general case */
emitcode("ld", "e,%s", l);
emitcode("ld", "d,#0");
jtab = newiTempLabel(NULL);
+ spillHL();
emitcode("ld", "hl,#" LABEL_STR, jtab->key+100);
emitcode("add", "hl,de");
emitcode("add", "hl,de");
if (!IS_GB)
emitcode("pop", "de");
emitcode("jp", "(hl)");
- emitcode("","%05d$:",jtab->key+100);
+ emitLabel(jtab->key+100);
/* now generate the jump labels */
for (jtab = setFirstItem(IC_JTLABELS(ic)) ; jtab;
jtab = setNextItem(IC_JTLABELS(ic)))
/* if the result is a bit */
if (AOP_TYPE(result) == AOP_CRY) {
- assert(0);
+ wassert(0);
}
/* if they are the same size : or less */
#if 0
/* if the result is of type pointer */
if (IS_PTR(ctype)) {
- assert(0);
+ wassert(0);
}
#endif
if (isOperandInFarSpace(IC_RESULT(ic)) &&
( OP_SYMBOL(IC_RESULT(ic))->isspilt ||
IS_TRUE_SYMOP(IC_RESULT(ic))) ) {
- assert(0);
+ wassert(0);
} else {
accInUse++;
aopOp(IC_RESULT(ic),ic,FALSE);
case GETHBIT:
emitcode("", "; genHBIT");
- assert(0);
+ wassert(0);
case LEFT_OP:
emitcode("", "; genLeftShift");