ack/mach/6805/as/mach5.c

52 lines
1,003 B
C
Raw Normal View History

1986-12-05 16:58:29 +00:00
#define RCSID5 "$Header$"
/*
* Motorola 6805 special routines
*/
/* VARARGS2 */
branch(opc,exp,cell) register opc; expr_t cell; expr_t exp; {
register sm, dist;
int saving;
dist = exp.val - (DOTVAL + 2);
if((opc & 0xf0) == 0) dist -= 1; /* bitbranch */
if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
dist -= DOTGAIN;
sm = fitj(dist);
if ((exp.typ & ~S_DOT) != DOTTYP)
sm = 0;
if (opc == 0x20 || opc == 0xAD)
saving = 1;
else
saving = 3;
if (small(sm,saving)) {
emit1(opc);
if((opc & 0xF0) == 0) /* bit branch */
emit1(cell.val);
#ifdef RELOCATION
newrelo(exp.typ, RELPC|RELO1);
#endif
emit1(dist);
} else {
if (opc == 0xAD) /* bsr */
emit1(0xBD); /* jsr */
else {
if (opc != 0x20) { /* bra */
/* reverse condition : */
emit1(opc ^ 1);
if((opc & 0xF0) == 0) /* bitbranch */
emit1(cell.val);
emit1(3);
}
emit1(0xCC); /* jmp */
}
#ifdef RELOCATION
newrelo(exp.typ, RELPC|RELO2|RELBR);
#endif
emit2(exp.val);
}
}