c11a5b8aa366f1223d861295b70629ed5fd72840
[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_regs[] = {
7     { 1, REG_ID_CL, "cl", 0, { REG_ID_CX, REG_ID_NONE, REG_ID_NONE } },
8     { 1, REG_ID_CH, "ch", 0, { REG_ID_CX, REG_ID_NONE, REG_ID_NONE } },
9     { 1, REG_ID_DL, "dl", 0, { REG_ID_DX, REG_ID_NONE, REG_ID_NONE } },
10     { 1, REG_ID_DH, "dh", 0, { REG_ID_DX, REG_ID_NONE, REG_ID_NONE } },
11     { 2, REG_ID_CX, "cx", 0, { REG_ID_CL, REG_ID_CH, REG_ID_NONE } },
12     { 2, REG_ID_DX, "dx", 0, { REG_ID_DL, REG_ID_DH, REG_ID_NONE } },
13     { 0, REG_ID_NONE,"??",  0, { REG_ID_NONE, REG_ID_NONE, REG_ID_NONE } }
14 };
15
16 static char _defaultRules[] =
17 {
18     //#include "peeph.rul"
19 };
20
21 /* list of key words used by i186 */
22 static char *_i186_keywords[] =     {
23     NULL
24 };
25
26 static void _i186_init(void)
27 {
28     asm_addTree(&asm_asxxxx_mapping);
29     izt_init(_i186_regs);
30 }
31
32 static void _i186_reset_regparm()
33 {
34 }
35
36 static int _i186_regparm( sym_link *l)
37 {
38     // PENDING: No register parameters.
39     return 0;
40 }
41
42 static bool _i186_parseOptions(int *pargc, char **argv, int *i)
43 {
44     /* TODO: allow port-specific command line options to specify
45      * segment names here.
46      */
47     return FALSE;
48 }
49
50 static void _i186_finaliseOptions(void)
51 {
52     // No options
53 }
54
55 static void _i186_setDefaultOptions(void)
56 {
57     // No options
58 }
59
60 static const char *_i186_getRegName(struct regs *reg)
61 {
62     if (reg)
63         return reg->name;
64     wassert(0);
65     return "err";
66 }
67
68 static void _i186_genAssemblerPreamble(FILE *of)
69 {
70     // PENDING
71 }
72
73 /* Generate interrupt vector table. */
74 static int _i186_genIVT(FILE *of, symbol **interrupts, int maxInterrupts)
75 {
76     // PENDING
77     return 0;
78 }
79
80 /** $1 is always the basename.
81     $2 is always the output file.
82     $3 varies
83     $l is the list of extra options that should be there somewhere...
84     MUST be terminated with a NULL.
85 */
86 // PENDING
87 static const char *_linkCmd[] = {
88     "aslink", "-nf", "$1", NULL
89 };
90
91 // PENDING
92 static const char *_asmCmd[] = {
93  "gpasm", NULL, NULL, NULL
94 };
95
96 void i186_assignRegisters (eBBlock **ebbs, int count)
97 {
98 }
99
100 /* Globals */
101 PORT i186_port = {
102     "i186",
103     "Intel 8086/80186",         /* Target name */
104     {
105         FALSE,                  /* Emit glue around main */
106         MODEL_SMALL,
107         MODEL_SMALL
108     },
109     {   
110         _asmCmd,
111         NULL,
112         NULL,
113         0
114     },
115     {
116         _linkCmd,
117         NULL,
118         ".o"
119     },
120     {
121         _defaultRules
122     },
123     {
124         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
125         1, 2, 2, 4, 2, 2, 2, 1, 4, 4
126     },
127     {
128         "XSEG    (XDATA)",
129         "STACK   (DATA)",
130         "CSEG    (CODE)",
131         "DSEG    (DATA)",
132         "ISEG    (DATA)",
133         "XSEG    (XDATA)",
134         "BSEG    (BIT)",
135         "RSEG    (DATA)",
136         "GSINIT  (CODE)",
137         "OSEG    (OVR,DATA)",
138         "GSFINAL (CODE)",
139         "HOME    (CODE)",
140         NULL,
141         NULL,
142         1
143     },
144     { 
145         +1, 1, 4, 1, 1, 0
146     },
147     /* i186 has an 16 bit mul */
148     {
149         2, 0
150     },
151     "_",
152     _i186_init,
153     _i186_parseOptions,
154     _i186_finaliseOptions,
155     _i186_setDefaultOptions,
156     izt_assignRegisters,
157     _i186_getRegName ,
158     _i186_keywords,
159     _i186_genAssemblerPreamble,
160     _i186_genIVT ,
161     _i186_reset_regparm,
162     _i186_regparm,
163     NULL,
164     FALSE,
165     0,  /* leave lt */
166     0,  /* leave gt */
167     1,  /* transform <= to ! > */
168     1,  /* transform >= to ! < */
169     1,  /* transform != to !(a == b) */
170     0   /* leave == */
171 };