updateCFA();
break;
case HX_IDX:
- emitcode ("pulx", "");
+ emitcode ("pulh", "");
_G.stackPushes--;
updateCFA();
- emitcode ("pulh", "");
+ emitcode ("pulx", "");
_G.stackPushes--;
updateCFA();
break;
case XA_IDX:
- emitcode ("pula", "");
+ emitcode ("pulx", "");
_G.stackPushes--;
updateCFA();
- emitcode ("pulx", "");
+ emitcode ("pula", "");
_G.stackPushes--;
updateCFA();
break;
genJumpTab (iCode * ic)
{
symbol *jtab;
-// char *l;
-
+ symbol *jtablo = newiTempLabel (NULL);
+ symbol *jtabhi = newiTempLabel (NULL);
+
D(emitcode ("; genJumpTab",""));
aopOp (IC_JTCOND (ic), ic, FALSE);
- /* get the condition into accumulator */
- loadRegFromAop (hc08_reg_a, AOP (IC_JTCOND (ic)), 0);
- freeAsmop (IC_JTCOND (ic), NULL, ic, TRUE);
- /* multiply by three */
- pushReg (hc08_reg_a, FALSE);
- emitcode ("lsla", "");
- emitcode ("add","1,s");
- transferRegReg (hc08_reg_a, hc08_reg_x, TRUE);
- loadRegFromConst (hc08_reg_h, zero);
- pullReg (hc08_reg_a);
+
+ if (hc08_reg_x->isFree && hc08_reg_x->isFree)
+ {
+ /* get the condition into x */
+ loadRegFromAop (hc08_reg_x, AOP (IC_JTCOND (ic)), 0);
+ freeAsmop (IC_JTCOND (ic), NULL, ic, TRUE);
+ loadRegFromConst (hc08_reg_h, zero);
+
+ emitcode ("lda", "%05d$,x", jtabhi->key + 100);
+ emitcode ("ldx", "%05d$,x", jtablo->key + 100);
+ transferRegReg (hc08_reg_a, hc08_reg_h, TRUE);
+ emitcode ("jmp", ",x");
+
+ hc08_dirtyReg (hc08_reg_a, TRUE);
+ hc08_dirtyReg (hc08_reg_hx, TRUE);
+ }
+ else
+ {
+ adjustStack(-2);
+ pushReg(hc08_reg_hx, TRUE);
+
+ /* get the condition into x */
+ loadRegFromAop (hc08_reg_x, AOP (IC_JTCOND (ic)), 0);
+ freeAsmop (IC_JTCOND (ic), NULL, ic, TRUE);
+ loadRegFromConst (hc08_reg_h, zero);
+
+ emitcode ("lda", "%05d$,x", jtabhi->key + 100);
+ emitcode ("sta", "3,s");
+ emitcode ("lda", "%05d$,x", jtablo->key + 100);
+ emitcode ("sta", "4,s");
+
+ pullReg(hc08_reg_hx);
+ emitcode ("rts", "");
+ _G.stackPushes += 2;
+ updateCFA();
+ }
- jtab = newiTempLabel (NULL);
- emitcode ("jmp", "%05d$,x", jtab->key + 100);
- emitcode ("", "%05d$:", jtab->key + 100);
/* now generate the jump labels */
+ emitLabel (jtablo);
+ for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab;
+ jtab = setNextItem (IC_JTLABELS (ic)))
+ emitcode (".db", "%05d$", jtab->key + 100);
+ emitLabel (jtabhi);
for (jtab = setFirstItem (IC_JTLABELS (ic)); jtab;
jtab = setNextItem (IC_JTLABELS (ic)))
- emitcode ("jmp", "%05d$", jtab->key + 100);
+ emitcode (".db", ">%05d$", jtab->key + 100);
- hc08_dirtyReg (hc08_reg_a, TRUE);
- hc08_dirtyReg (hc08_reg_hx, TRUE);
}
/*-----------------------------------------------------------------*/
for (ic = ebp->sch; ic; ic = ic->next)
{
- /* Fix for bug #979599: */
- /* P0 &= ~1; */
-
- /* Look for two subsequent iCodes with */
- /* iTemp := _c; */
- /* _c = iTemp & op; */
- /* and replace them by */
- /* _c = _c & op; */
- if ((ic->op == BITWISEAND || ic->op == '|' || ic->op == '^') &&
- /* avoid trouble with unary '&' */
- IC_RIGHT (ic) &&
- ic->prev &&
- ic->prev->op == '=' &&
- IS_ITEMP (IC_LEFT (ic)) &&
- IC_LEFT (ic) == IC_RESULT (ic->prev) &&
- isOperandEqual (IC_RESULT(ic), IC_RIGHT(ic->prev)))
- {
- int key = ic->prev->key;
-
- bitVectUnSetBit (OP_SYMBOL (IC_RESULT (ic->prev))->defs, key);
- ReplaceOpWithCheaperOp (&IC_LEFT (ic), IC_RESULT (ic));
- if (/*IS_ITEMP (IC_RESULT (ic->prev)) && */
- OP_SYMBOL (IC_RESULT (ic->prev))->liveFrom > ic->seq)
- {
- OP_SYMBOL (IC_RESULT (ic->prev))->liveFrom = ic->seq;
- }
- // TODO: and the other way round?
-
- /* delete from liverange table also
- delete from all the points in between and the new one */
- bitVectUnSetBit (ic->prev->rlive, IC_RESULT (ic->prev)->key);
- bitVectSetBit (ic->prev->rlive, IC_RESULT (ic)->key);
- bitVectUnSetBit (ic->rlive, IC_RESULT (ic->prev)->key);
- bitVectSetBit (ic->rlive, IC_RESULT (ic)->key);
-
- remiCodeFromeBBlock (ebp, ic->prev);
- // bitVectUnSetBit (OP_SYMBOL (IC_RESULT (ic))->defs, ic->key);
- hTabDeleteItem (&iCodehTab, key, ic->prev, DELETE_ITEM, NULL);
- // OP_DEFS (IC_RESULT (ic->prev)) = bitVectSetBit (OP_DEFS (IC_RESULT (ic->prev)), ic->prev->key);
- }
/* if this is an itemp & result of an address of a true sym
then mark this as rematerialisable */