* .version: Updated to 2.3.1
[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
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     {
140         FALSE,          /* Emit glue around main */
141         MODEL_SMALL,
142         MODEL_SMALL
143     },
144     {   
145         _asmCmd,
146         NULL,
147         NULL,
148         NULL,
149         0,
150         ".s"
151     },
152     {
153         _linkCmd,
154         NULL,
155         NULL,
156         ".o"
157     },
158     {
159         _defaultRules
160     },
161     {
162         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
163         1, 2, 2, 4, 2, 2, 2, 1, 4, 4
164     },
165     {
166         ".BSS",
167         ".BSS",
168         ".TEXT",
169         ".DATA",
170         ".DATA",
171         ".DATA",
172         ".DATA",
173         ".DATA",
174         ".TEXT",
175         ".DATA",
176         ".TEXT",
177         ".TEXT",
178         NULL,
179         NULL,
180         1
181     },
182     { 
183         +1, 1, 4, 1, 1, 0
184     },
185     /* i186 has an 16 bit mul */
186     {
187         2, 0
188     },
189     "_",
190     _i186_init,
191     _i186_parseOptions,
192     _i186_finaliseOptions,
193     _i186_setDefaultOptions,
194     izt_assignRegisters,
195     _i186_getRegName ,
196     _i186_keywords,
197     _i186_genAssemblerPreamble,
198     _i186_genIVT ,
199     _i186_reset_regparm,
200     _i186_regparm,
201     NULL,
202     NULL,
203     FALSE,
204     0,  /* leave lt */
205     0,  /* leave gt */
206     1,  /* transform <= to ! > */
207     1,  /* transform >= to ! < */
208     1,  /* transform != to !(a == b) */
209     0,  /* leave == */
210     FALSE,                        /* No array initializer support. */
211     PORT_MAGIC
212 };