Pristine Ack-5.5
[Ack-5.5.git] / mach / m68020 / as / mach1.c
1 /* $Id: mach1.c,v 1.12 1994/06/24 13:05:40 ceriel Exp $ */
2 /*
3  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4  * See the copyright notice in the ACK home directory, in the file "Copyright".
5  */
6 /*
7  * Motorola 68020 dependent C declarations
8  */
9
10 #define low3(z)         ((short)(z) & 07)
11 #define low4(z)         ((short)(z) & 017)
12 #define low5(z)         ((short)(z) & 037)
13 #define low6(z)         ((short)(z) & 077)
14 #define low7(z)         ((short)(z) & 0177)
15
16 #define fit3(z)         ((((z)-1) & ~((int)07)) == 0)
17 #define fit4(z)         (((z) & ~((int)017)) == 0)
18 #define fit5(z)         (((z) & ~((int)037)) == 0)
19 #define fit6(z)         (((z) & ~((int)077)) == 0)
20 #define fit7(z)         (((z) & ~((int)0177)) == 0)
21 #define sfit7(z)        (fit7((z)+64))
22 #define fit8(z)         (((z) & ~((int)0xFF)) == 0)
23 #define fit16(z)        (((z) & ~(0xFFFFL)) == 0)
24
25 #define SIZE_B          0000
26 #define SIZE_W          0100
27 #define SIZE_L          0200
28 #define SIZE_NON        0300
29 #define SIZE_DEF        SIZE_W
30
31 #define FSIZE_L         00
32 #define FSIZE_S         01
33 #define FSIZE_X         02
34 #define FSIZE_P         03
35 #define FSIZE_W         04
36 #define FSIZE_D         05
37 #define FSIZE_B         06
38
39 #define DEF_FP          01000   /* default floating point processor */
40 #define DEF_MM          00000   /* default memory management */
41 extern int      co_id;          /* coprocessor id */
42
43 extern int      mrg_1,mrg_2;    /* Mode and ReGister */
44 extern short    ffew_1, ffew_2; /* Full Format Extension Word */
45 extern expr_t   bd_1,bd_2,od_1,od_2; /* base and outer displacements */
46 #ifndef ASLD
47 extern valu_t   bd_rel1,bd_rel2,od_rel1,od_rel2;
48 #endif
49
50 #ifdef RELOCATION
51 #ifdef ASLD
52 #define T_EMIT2(a,b,c,d)        t_emit2(a,b,c,(valu_t)0)
53 #define T_EMIT4(a,b,c,d)        t_emit4(a,b,c,(valu_t)0)
54 #else  /* ALSD */
55 #define T_EMIT2(a,b,c,d)        t_emit2(a,b,c,(valu_t)d)
56 #define T_EMIT4(a,b,c,d)        t_emit4(a,b,c,(valu_t)d)
57 #endif /* ASLD */
58 #else
59 #define T_EMIT2(a,b,c,d)        t_emit2(a)
60 #define T_EMIT4(a,b,c,d)        t_emit4(a)
61 #endif
62
63 struct instr_t {
64         short   i_word;         /* word to be emitted */
65 #ifdef RELOCATION
66         short   i_relotype;
67         int     i_reloinfo;
68         valu_t  i_relonami;
69 #endif
70 };
71 typedef struct instr_t instr_t;
72 extern instr_t instr[30];       /* temporary area for instructions */
73 extern instr_t *instrp; /* index into instr[] */
74 extern int dot_offset;
75
76 /* flags used when reading effective addresses */
77 #define INDEX           0300
78 #define PRE_INDEX       0100
79 #define POST_INDEX      0200
80 #define DBL_INDEX       0300
81 #define PC_MODE         0400
82
83 /* addressing mode bits */
84 #define DTA             0x01
85 #define MEM             0x02
86 #define CTR             0x04
87 #define ALT             0x08
88 #define FITB            0x10
89 #define FITW            0x20
90 #define PUTW            0x40
91 #define PUTL            0x80
92
93 extern int      curr_instr;
94 extern int      curr_size;
95
96 #ifndef extern
97 extern short    eamode[];
98 #else
99 short   eamode[] = {
100 /* 00A */       DTA        |ALT,
101 /* 01A */                   ALT,
102 /* 02A */       DTA|MEM|CTR|ALT,
103 /* 03A */       DTA|MEM    |ALT,
104 /* 04A */       DTA|MEM    |ALT,
105 /* 05A */       DTA|MEM|CTR|ALT|FITW|PUTW, /* if relocation wanted, use 06A */
106 /* 06A */       DTA|MEM|CTR|ALT     |PUTW, /* relocation handled by ea_1() */
107 /* 07x */       0,
108 /* 070 */       DTA|MEM|CTR|ALT|FITW|PUTW | (RELO2)<<8,
109 /* 071 */       DTA|MEM|CTR|ALT     |PUTL | (RELO4)<<8,
110 /* 072 */       DTA|MEM|CTR    |FITW|PUTW, /* if relocation wanted, use 073 */
111 /* 073 */       DTA|MEM|CTR         |PUTW, /* relocation handled by ea_1() */
112 /* 074x */      0,
113 /* 074B */      DTA|MEM        |FITB|PUTW | (RELO1)<<8,
114 /* 074W */      DTA|MEM        |FITW|PUTW | (RELO2)<<8,
115 /* 074L */      DTA|MEM             |PUTL | (RELO4)<<8,
116 };
117                         /* RELO2 had to go with mode 070, because the assembly
118                          * language programmer can use addresses like
119                          * '(expression).w', which still have to be relocatable.
120                          */
121 #endif