Pristine Ack-5.5
[Ack-5.5.git] / mach / s2650 / 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 13:34:04 ceriel Exp $"
6
7 /*
8  * Signetics 2650 special routines
9  */
10
11 #define MASK    0x6000
12 #define MASK1   0x1FFF
13 #define MASK2   0x1FFE
14
15 page()
16         {
17         if(((DOTVAL - 1) & MASK1) == MASK1)
18                 serror("page violation");
19         }
20
21 pag2()
22         {
23         if(((DOTVAL - 1) & MASK1) >= MASK2)
24                 serror("page violation");
25         }
26
27 rela(exp,ind)
28 expr_t exp;
29 int   ind;
30         {
31         int c, d;
32         page();
33         if(pass == PASS_3){
34 #ifdef ASLD
35                 if((DOTVAL & MASK) != (exp.val & MASK))
36                         serror("relative address outside page");
37 #endif
38                 d = low13(DOTVAL);
39                 c = low13(exp.val);
40 #ifdef ASLD
41                 /*
42                  * I (Duk Bekema) think the next two if's are meant to
43                  * handle wrap around, but the original author didn't give
44                  * any comment here and I don't know anything about the
45                  * Signetics 2650.
46                  */
47                 if(c - d > 0x1F80)
48                         d |= 0x2000;
49                 if(d - c > 0x1F80)
50                         c |= 0x2000;
51 #endif
52                 c -= d + 1;
53                 fit(fit7(c));
54                 }
55 #ifdef RELOCATION
56         newrelo(exp.typ, RELPC | RELO1);
57 #endif
58         emit1(low7(c) | ind);
59 }
60
61 absoa(exp, ix, ind)
62 expr_t  exp;
63 int     ix;
64 unsigned ind;
65         {
66         pag2();
67 #ifdef ASLD
68         if(pass == PASS_3 && (exp.val & MASK) != (DOTVAL & MASK))
69                 serror("page violation");
70 #endif
71 #ifdef RELOCATION
72         newrelo(exp.typ, RELO2 | RELBR);
73 #endif
74         emit2(low13(exp.val) | ind | ix);
75 }
76
77 absob(exp, ind)
78 expr_t  exp;
79 unsigned ind;
80         {
81         pag2();
82 #ifdef ASLD
83         if (exp.val < 0)
84                 serror("branch to nonexistent memory");
85 #endif
86 #ifdef RELOCATION
87         newrelo(exp.typ, RELO2 | RELBR);
88 #endif
89         emit2(exp.val | ind);
90 }