Pristine Ack-5.5
[Ack-5.5.git] / mach / 6500 / 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:54:11 ceriel Exp $"
6
7 /*
8  * Mostek 6500 special routines.
9  */
10
11 branch(opc, exp)
12 register int    opc;
13 expr_t          exp;
14 {
15         register int    dist;
16
17         dist = exp.val - (DOTVAL + 2);
18         if (pass == PASS_2 && dist > 0 && !(exp.typ & S_DOT))
19                 dist -= DOTGAIN;
20         if (small(fitb(dist) && (exp.typ & ~S_DOT) == DOTTYP, 3)) {
21                 emit1(opc); emit1(dist);
22         } else {
23                 emit1(opc^0x20); emit1(0x03);   /* Skip over ... */
24                 emit1(0x4C);                    /* ... far jump. */
25 #ifdef RELOCATION
26                 newrelo(exp.typ, RELO2);
27 #endif
28                 emit2(exp.val);
29         }
30 }
31
32 code(exp, opc1, opc2)
33 expr_t          exp;
34 register int    opc1, opc2;
35 {
36         if (small((exp.typ & S_TYP) == S_ABS && fits_zeropage(exp.val), 1)) {
37                 emit1(opc1); emit1(exp.val);
38         } else {
39                 emit1(opc2);
40 #ifdef RELOCATION
41                 newrelo(exp.typ, RELO2);
42 #endif
43                 emit2(exp.val);
44         }
45 }