1987-03-09 16:02:32 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1994-06-24 14:02:31 +00:00
|
|
|
#define RCSID5 "$Id$"
|
1985-06-10 14:52:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Motorola 6800 special routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
branch(opc,exp) register opc; expr_t exp; {
|
|
|
|
register sm, dist;
|
|
|
|
int saving;
|
|
|
|
|
|
|
|
dist = exp.val - (DOTVAL + 2);
|
|
|
|
if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
|
|
|
|
dist -= DOTGAIN;
|
|
|
|
sm = fitb(dist);
|
|
|
|
if ((exp.typ & ~S_DOT) != DOTTYP)
|
|
|
|
sm = 0;
|
|
|
|
if (opc == 0x8D || opc == 0x20)
|
|
|
|
saving = 1;
|
|
|
|
else
|
|
|
|
saving = 3;
|
|
|
|
if (small(sm,saving)) {
|
|
|
|
emit1(opc);
|
|
|
|
emit1(dist);
|
|
|
|
} else {
|
|
|
|
if (opc == 0x8D) /* bsr */
|
|
|
|
emit1(0xBD); /* jsr */
|
|
|
|
else {
|
|
|
|
if (opc != 0x20) { /* bra */
|
|
|
|
|
|
|
|
/* reverse condition : */
|
|
|
|
|
|
|
|
emit1(opc ^ 1);
|
|
|
|
emit1(3);
|
|
|
|
}
|
|
|
|
emit1(0x7E); /* jmp */
|
|
|
|
}
|
|
|
|
#ifdef RELOCATION
|
|
|
|
newrelo(exp.typ, RELO2 | RELBR);
|
|
|
|
#endif
|
|
|
|
emit2(exp.val);
|
|
|
|
}
|
|
|
|
}
|