Imported Upstream version 2.9.0
[debian/cc1111] / src / izt / i186.c
1 /** @file izt/i186.c
2         i186 specific general functions.
3 */
4 #include "izt.h"
5
6 static REG _i186_otherRegs[] = {
7         { 1, REG_ID_AL, "al", 0, { REG_ID_AX, REG_ID_NONE, REG_ID_NONE } },
8         { 1, REG_ID_AH, "ah", 0, { REG_ID_AX, REG_ID_NONE, REG_ID_NONE } },
9         { 2, REG_ID_AX, "ax", 0, { REG_ID_AL, REG_ID_AH, REG_ID_NONE } },
10         { 1, REG_ID_BL, "bl", 0, { REG_ID_BX, REG_ID_NONE, REG_ID_NONE } },
11         { 1, REG_ID_BH, "bh", 0, { REG_ID_BX, REG_ID_NONE, REG_ID_NONE } },
12         { 2, REG_ID_BX, "bx", 0, { REG_ID_BL, REG_ID_BH, REG_ID_NONE } },
13         { 2, REG_ID_BP, "bp", 0, { REG_ID_NONE, REG_ID_NONE, REG_ID_NONE } },
14         { 0, REG_ID_NONE,"??",  0, { REG_ID_NONE, REG_ID_NONE, REG_ID_NONE } }
15 };
16         
17 static REG _i186_regs[] = {
18         { 1, REG_ID_CL, "cl", 0, { REG_ID_CX, REG_ID_NONE, REG_ID_NONE } },
19         { 1, REG_ID_CH, "ch", 0, { REG_ID_CX, REG_ID_NONE, REG_ID_NONE } },
20         { 1, REG_ID_DL, "dl", 0, { REG_ID_DX, REG_ID_NONE, REG_ID_NONE } },
21         { 1, REG_ID_DH, "dh", 0, { REG_ID_DX, REG_ID_NONE, REG_ID_NONE } },
22         { 2, REG_ID_CX, "cx", 0, { REG_ID_CL, REG_ID_CH, REG_ID_NONE } },
23         { 2, REG_ID_DX, "dx", 0, { REG_ID_DL, REG_ID_DH, REG_ID_NONE } },
24         { 0, REG_ID_NONE,"??",  0, { REG_ID_NONE, REG_ID_NONE, REG_ID_NONE } }
25 };
26
27 static IZT_PORT _i186_port = {
28         _i186_regs,
29         { _i186_otherRegs + 0, _i186_otherRegs + 1, _i186_otherRegs + 2 },
30         _i186_otherRegs + 5,
31         _i186_otherRegs + 6
32 };
33
34 static char _defaultRules[] =
35 {
36         //#include "peeph.rul"
37     ""
38 };
39
40 /* list of key words used by i186 */
41 static char *_i186_keywords[] =
42 {
43   NULL
44 };
45
46 #include "i186_mappings.i"
47
48 static void
49 _i186_init (void)
50 {
51         asm_addTree(&_as86_i186_mappings);
52         izt_init(&_i186_port);
53 }
54
55 static void
56 _i186_reset_regparm ()
57 {
58 }
59
60 static int
61 _i186_regparm (sym_link * l)
62 {
63   // PENDING: No register parameters.
64   return 0;
65 }
66
67 static bool
68 _i186_parseOptions (int *pargc, char **argv, int *i)
69 {
70   /* TODO: allow port-specific command line options to specify
71    * segment names here.
72    */
73   return FALSE;
74 }
75
76 static void
77 _i186_finaliseOptions (void)
78 {
79   // No options
80 }
81
82 static void
83 _i186_setDefaultOptions (void)
84 {
85   // No options
86 }
87
88 static const char *
89 _i186_getRegName (struct regs *reg)
90 {
91   if (reg)
92         return reg->name;
93   wassert (0);
94   return "err";
95 }
96
97 static void
98 _i186_genAssemblerPreamble (FILE * of)
99 {
100   // PENDING
101 }
102
103 /* Generate interrupt vector table. */
104 static int
105 _i186_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
106 {
107   // PENDING
108   return 0;
109 }
110
111 /** $1 is always the basename.
112         $2 is always the output file.
113         $3 varies
114         $l is the list of extra options that should be there somewhere...
115         MUST be terminated with a NULL.
116 */
117 // PENDING
118 static const char *_linkCmd[] =
119 {
120   "aslink", "-nf", "$1", NULL
121 };
122
123 // PENDING
124 static const char *_asmCmd[] =
125 {
126   "gpasm", NULL, NULL, NULL
127 };
128
129 void
130 i186_assignRegisters (eBBlock ** ebbs, int count)
131 {
132 }
133
134 /* Globals */
135 PORT i186_port = {
136     TARGET_ID_I186,
137     "i186",
138     "Intel 80186",      /* Target name */
139     NULL,
140     {
141         glue,
142         FALSE,          /* Emit glue around main */
143         MODEL_SMALL,
144         MODEL_SMALL
145     },
146     {   
147         _asmCmd,
148         NULL,
149         NULL,
150         NULL,
151         0,
152         ".s",
153         NULL                    /* no do_assemble function */
154     },
155     {
156         _linkCmd,
157         NULL,
158         NULL,
159         ".o"
160     },
161     {
162         _defaultRules
163     },
164     {
165         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
166         1, 2, 2, 4, 2, 2, 2, 1, 4, 4
167     },
168     /* tags for generic pointers */
169     { 0x00, 0x40, 0x60, 0x80 },         /* far, near, xstack, code */
170
171     {
172         ".BSS",
173         ".BSS",
174         ".TEXT",
175         ".DATA",
176         ".DATA",
177         ".DATA",
178         ".DATA",
179         ".DATA",
180         ".TEXT",
181         ".DATA",
182         ".TEXT",
183         ".TEXT",
184         NULL, // xidata
185         NULL, // xinit
186         NULL,
187         NULL,
188         1
189     },
190     { 
191         +1, 1, 4, 1, 1, 0
192     },
193     /* i186 has an 16 bit mul */
194     {
195         2, 0
196     },
197     "_",
198     _i186_init,
199     _i186_parseOptions,
200     NULL,
201     _i186_finaliseOptions,
202     _i186_setDefaultOptions,
203     izt_assignRegisters,
204     _i186_getRegName ,
205     _i186_keywords,
206     _i186_genAssemblerPreamble,
207     NULL,                               /* no genAssemblerEnd */
208     _i186_genIVT ,
209     NULL, // _i186_genXINIT
210     _i186_reset_regparm,
211     _i186_regparm,
212     NULL,
213     NULL,
214     NULL,
215     FALSE,
216     TRUE,                               /* little endian */
217     0,  /* leave lt */
218     0,  /* leave gt */
219     1,  /* transform <= to ! > */
220     1,  /* transform >= to ! < */
221     1,  /* transform != to !(a == b) */
222     0,  /* leave == */
223     FALSE,                        /* No array initializer support. */
224     0,                            /* no CSE cost estimation yet */
225     NULL,                       /* no builtin functions */
226     GPOINTER,                   /* treat unqualified pointers as "generic" pointers */
227     1,                          /* reset labelKey to 1 */
228     1,                          /* globals & local static allowed */
229     PORT_MAGIC
230 };