a12f962861d22e22c372d446da9caaba98607ba7
[fw/sdcc] / 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 /* list of key words used by i186 */
40 static char *_i186_keywords[] =
41 {
42   NULL
43 };
44
45 #include "i186_mappings.i"
46
47 static void
48 _i186_init (void)
49 {
50         asm_addTree(&_as86_i186_mappings);
51         izt_init(&_i186_port);
52 }
53
54 static void
55 _i186_reset_regparm ()
56 {
57 }
58
59 static int
60 _i186_regparm (sym_link * l)
61 {
62   // PENDING: No register parameters.
63   return 0;
64 }
65
66 static bool
67 _i186_parseOptions (int *pargc, char **argv, int *i)
68 {
69   /* TODO: allow port-specific command line options to specify
70    * segment names here.
71    */
72   return FALSE;
73 }
74
75 static void
76 _i186_finaliseOptions (void)
77 {
78   // No options
79 }
80
81 static void
82 _i186_setDefaultOptions (void)
83 {
84   // No options
85 }
86
87 static const char *
88 _i186_getRegName (struct regs *reg)
89 {
90   if (reg)
91         return reg->name;
92   wassert (0);
93   return "err";
94 }
95
96 static void
97 _i186_genAssemblerPreamble (FILE * of)
98 {
99   // PENDING
100 }
101
102 /* Generate interrupt vector table. */
103 static int
104 _i186_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
105 {
106   // PENDING
107   return 0;
108 }
109
110 /** $1 is always the basename.
111         $2 is always the output file.
112         $3 varies
113         $l is the list of extra options that should be there somewhere...
114         MUST be terminated with a NULL.
115 */
116 // PENDING
117 static const char *_linkCmd[] =
118 {
119   "aslink", "-nf", "$1", NULL
120 };
121
122 // PENDING
123 static const char *_asmCmd[] =
124 {
125   "gpasm", NULL, NULL, NULL
126 };
127
128 void
129 i186_assignRegisters (eBBlock ** ebbs, int count)
130 {
131 }
132
133 /* Globals */
134 PORT i186_port = {
135     TARGET_ID_I186,
136     "i186",
137     "Intel 80186",      /* Target name */
138     {
139         FALSE,          /* Emit glue around main */
140         MODEL_SMALL,
141         MODEL_SMALL
142     },
143     {   
144         _asmCmd,
145         NULL,
146         NULL,
147         0,
148         ".s"
149     },
150     {
151         _linkCmd,
152         NULL,
153         ".o"
154     },
155     {
156         _defaultRules
157     },
158     {
159         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
160         1, 2, 2, 4, 2, 2, 2, 1, 4, 4
161     },
162     {
163         ".BSS",
164         ".BSS",
165         ".TEXT",
166         ".DATA",
167         ".DATA",
168         ".DATA",
169         ".DATA",
170         ".DATA",
171         ".TEXT",
172         ".DATA",
173         ".TEXT",
174         ".TEXT",
175         NULL,
176         NULL,
177         1
178     },
179     { 
180         +1, 1, 4, 1, 1, 0
181     },
182     /* i186 has an 16 bit mul */
183     {
184         2, 0
185     },
186     "_",
187     _i186_init,
188     _i186_parseOptions,
189     _i186_finaliseOptions,
190     _i186_setDefaultOptions,
191     izt_assignRegisters,
192     _i186_getRegName ,
193     _i186_keywords,
194     _i186_genAssemblerPreamble,
195     _i186_genIVT ,
196     _i186_reset_regparm,
197     _i186_regparm,
198     NULL,
199     FALSE,
200     0,  /* leave lt */
201     0,  /* leave gt */
202     1,  /* transform <= to ! > */
203     1,  /* transform >= to ! < */
204     1,  /* transform != to !(a == b) */
205     0,  /* leave == */
206     PORT_MAGIC
207 };