Pristine Ack-5.5
[Ack-5.5.git] / mach / i386 / as / mach1.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 RCSID1 "$Id: mach1.c,v 1.6 1994/06/24 07:25:17 ceriel Exp $"
6
7 /*
8  * INTEL 80386 C declarations
9  */
10
11 #define low6(z)         (z & 077)
12 #define fit6(z)         (low6(z) == z)
13 #define low3(z)         (z & 07)
14 #define fit3(z)         (low3(z) == z)
15
16 #define FESC    0xD8            /* escape for 80[23]87 processor */
17
18 #define ufitb(z)        ((unsigned)(z) <= 255)
19
20 #define IS_R8           0x100
21 #define IS_R32          0x200
22 #define IS_EXPR         0x400
23 #define IS_RSEG         0x800
24
25 #define is_expr(reg)    ((reg)&IS_EXPR)
26 #define is_segreg(reg)  ((reg)&IS_RSEG)
27 #define is_reg(reg)     (((reg)&(IS_R8|IS_R32)) != 0)
28 #define is_acc(reg)     (is_reg(reg) && ((reg & 07) == 0))
29
30 struct operand {
31         int     mod;
32         int     rm;
33         int     reg;
34         int     sib;            /* scale-index-base */
35         expr_t  exp;
36 };
37
38 extern struct operand   op_1, op_2;
39
40 #define mod_1   op_1.mod
41 #define mod_2   op_2.mod
42 #define rm_1    op_1.rm
43 #define rm_2    op_2.rm
44 #define reg_1   op_1.reg
45 #define reg_2   op_2.reg
46 #define sib_1   op_1.sib
47 #define sib_2   op_2.sib
48 #define exp_1   op_1.exp
49 #define exp_2   op_2.exp
50
51 #ifdef RELOCATION
52 extern int      rel_1, rel_2;
53 #endif
54
55 #ifndef extern
56 extern char     regindex_ind[8][8];
57 #else
58 /*      First index is base register; second index is index register;
59         sp cannot be an index register.
60         For base and index register indirect mode, bp cannot be the
61         base register, but this info is not included in this array.
62         This can always be handled by using the base and index register with
63         displacement mode.
64 */
65 char    regindex_ind[8][8] = {
66         000,    010,    020,    030,    -1,     050,    060,    070,
67         001,    011,    021,    031,    -1,     051,    061,    071,
68         002,    012,    022,    032,    -1,     052,    062,    072,
69         003,    013,    023,    033,    -1,     053,    063,    073,
70         004,    014,    024,    034,    -1,     054,    064,    074,
71         005,    015,    025,    035,    -1,     055,    065,    075,
72         006,    016,    026,    036,    -1,     056,    066,    076,
73         007,    017,    027,    037,    -1,     057,    067,    077,
74 };
75 #endif
76
77 extern int      address_long INIT(1), operand_long INIT(1);
78 extern int      use32 INIT(1);
79
80 /* For 16-bit addressing: copied from i86 assembler */
81 #ifndef extern
82 extern char     sr_m[8];
83 #else
84 char    sr_m[8] = {
85         -1,     -1,     -1,     7,      -1,     6,      4,      5
86 };
87 #endif
88
89 #ifndef extern
90 extern char     dr_m[8][8];
91 #else
92 char    dr_m[8][8] = {
93         -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
94         -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
95         -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
96         -1,     -1,     -1,     -1,     -1,     -1,     0,      1,
97         -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
98         -1,     -1,     -1,     -1,     -1,     -1,     2,      3,
99         -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1,
100         -1,     -1,     -1,     -1,     -1,     -1,     -1,     -1
101 };
102 #endif