Pristine Ack-5.5
[Ack-5.5.git] / mach / 6800 / as / mach5.c
1 /*
2  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3  * See the copyright notice in the ACK home directory, in the file "Copyright".
4  */
5 #define RCSID5 "$Id: mach5.c,v 3.3 1994/06/24 12:55:23 ceriel Exp $"
6
7 /*
8  * Motorola 6800 special routines
9  */
10
11 branch(opc,exp) register opc; expr_t exp; {
12         register sm, dist;
13         int saving;
14
15         dist = exp.val - (DOTVAL + 2);
16         if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
17                 dist -= DOTGAIN;
18         sm = fitb(dist);
19         if ((exp.typ & ~S_DOT) != DOTTYP)
20                 sm = 0;
21         if (opc == 0x8D || opc == 0x20)
22                 saving = 1;
23         else
24                 saving = 3;
25         if (small(sm,saving)) {
26                 emit1(opc);
27                 emit1(dist);
28         } else {
29                 if (opc == 0x8D)                /* bsr */
30                         emit1(0xBD);            /* jsr */
31                 else {
32                         if (opc != 0x20) {      /* bra */
33
34                                         /* reverse condition : */
35
36                                 emit1(opc ^ 1);
37                                 emit1(3);
38                         }
39                         emit1(0x7E);            /* jmp */
40                 }
41 #ifdef RELOCATION
42                 newrelo(exp.typ, RELO2 | RELBR);
43 #endif
44                 emit2(exp.val);
45         }
46 }