48a854f1a12dd0aeffff9098ab52ca5beda9626b
[fw/sdcc] / src / izt / tlcs900h.c
1 /** @file izt/tlcs900h.c
2     tlcs900h specific general functions.
3 */
4 #include "izt.h"
5
6 static REG _tlcs900h_regs[] =
7 {
8   {1, REG_ID_C, "c", 0,
9    {REG_ID_BC, REG_ID_NONE, REG_ID_NONE}},
10   {1, REG_ID_B, "b", 0,
11    {REG_ID_BC, REG_ID_NONE, REG_ID_NONE}},
12   {1, REG_ID_E, "e", 0,
13    {REG_ID_DE, REG_ID_NONE, REG_ID_NONE}},
14   {1, REG_ID_D, "d", 0,
15    {REG_ID_DE, REG_ID_NONE, REG_ID_NONE}},
16   {2, REG_ID_BC, "bc", 0,
17    {REG_ID_C, REG_ID_B, REG_ID_NONE}},
18   {2, REG_ID_DE, "de", 0,
19    {REG_ID_E, REG_ID_D, REG_ID_NONE}},
20   {4, REG_ID_XBC, "xbc", 0,
21    {REG_ID_C, REG_ID_B, REG_ID_BC}},
22   {4, REG_ID_XDE, "xde", 0,
23    {REG_ID_E, REG_ID_D, REG_ID_DE}},
24   {0, REG_ID_NONE, "??", 0,
25    {REG_ID_NONE, REG_ID_NONE, REG_ID_NONE}}
26 };
27
28 static IZT_PORT _tlcs900h_port =
29 {
30   _tlcs900h_regs
31 };
32
33 static char _defaultRules[] =
34 {
35     //#include "peeph.rul"
36     ""
37 };
38
39 static char *_tlcs900h_keywords[] =
40 {
41   NULL
42 };
43
44 void tlcs900h_assignRegisters (eBBlock ** ebbs, int count);
45
46 static void
47 _tlcs900h_init (void)
48 {
49   asm_addTree (&asm_asxxxx_mapping);
50   izt_init (&_tlcs900h_port);
51 }
52
53 static void
54 _tlcs900h_reset_regparm ()
55 {
56 }
57
58 static int
59 _tlcs900h_regparm (sym_link * l)
60 {
61   // PENDING: No register parameters.
62   return 0;
63 }
64
65 static bool
66 _tlcs900h_parseOptions (int *pargc, char **argv, int *i)
67 {
68   /* TODO: allow port-specific command line options to specify
69    * segment names here.
70    */
71   return FALSE;
72 }
73
74 static void
75 _tlcs900h_finaliseOptions (void)
76 {
77   // No options
78 }
79
80 static void
81 _tlcs900h_setDefaultOptions (void)
82 {
83   // No options
84 }
85
86 static const char *
87 _tlcs900h_getRegName (struct regs *reg)
88 {
89   if (reg)
90     return reg->name;
91   wassert (0);
92   return "err";
93 }
94
95 static void
96 _tlcs900h_genAssemblerPreamble (FILE * of)
97 {
98   // PENDING
99 }
100
101 /* Generate interrupt vector table. */
102 static int
103 _tlcs900h_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
104 {
105   // PENDING
106   return 0;
107 }
108
109 /** $1 is always the basename.
110     $2 is always the output file.
111     $3 varies
112     $l is the list of extra options that should be there somewhere...
113     MUST be terminated with a NULL.
114 */
115 // PENDING
116 static const char *_linkCmd[] =
117 {
118   "aslink", "-nf", "$1", NULL
119 };
120
121 // PENDING
122 static const char *_asmCmd[] =
123 {
124   "gpasm", NULL, NULL, NULL
125 };
126
127 void
128 tlcs900h_assignRegisters (eBBlock ** ebbs, int count)
129 {
130 }
131
132 /* Globals */
133 PORT tlcs900h_port =
134 {
135   TARGET_ID_TLCS900H,
136   "tlcs900h",
137   "Toshiba TLCS-900H",          /* Target name */
138   {
139     TRUE,                       /* Emit glue around main */
140     MODEL_SMALL,
141     MODEL_SMALL
142   },
143   {
144     _asmCmd,
145     NULL,
146     NULL,
147     NULL,
148     0,
149     NULL,
150     NULL                        /* no do_assemble function */
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     "XSEG    (XDATA)",
167     "STACK   (DATA)",
168     "CSEG    (CODE)",
169     "DSEG    (DATA)",
170     "ISEG    (DATA)",
171     "XSEG    (XDATA)",
172     "BSEG    (BIT)",
173     "RSEG    (DATA)",
174     "GSINIT  (CODE)",
175     "OSEG    (OVR,DATA)",
176     "GSFINAL (CODE)",
177     "HOME        (CODE)",
178     NULL, // xidata
179     NULL, // xinit
180     NULL,
181     NULL,
182     1
183   },
184   {
185     +1, 1, 4, 1, 1, 0
186   },
187     /* tlcs900h has an 16 bit mul */
188   {
189     2, -1
190   },
191   "_",
192   _tlcs900h_init,
193   _tlcs900h_parseOptions,
194   _tlcs900h_finaliseOptions,
195   _tlcs900h_setDefaultOptions,
196   tlcs900h_assignRegisters,
197   _tlcs900h_getRegName,
198   _tlcs900h_keywords,
199   _tlcs900h_genAssemblerPreamble,
200   NULL,                         /* no genAssemblerEnd */
201   _tlcs900h_genIVT,
202   0, // _tlcs900h_genXINIT
203   _tlcs900h_reset_regparm,
204   _tlcs900h_regparm,
205   NULL,
206   NULL,
207   NULL,
208   FALSE,
209   0,                            /* leave lt */
210   0,                            /* leave gt */
211   1,                            /* transform <= to ! > */
212   1,                            /* transform >= to ! < */
213   1,                            /* transform != to !(a == b) */
214   0,                            /* leave == */
215   FALSE,                        /* No array initializer support. */     
216   0,                            /* no CSE cost estimation yet */
217   NULL,                         /* no builtin functions */
218   GPOINTER,                     /* treat unqualified pointers as "generic" pointers */
219   1,                            /* reset labelKey to 1 */
220   1,                            /* globals & local static allowed */
221   PORT_MAGIC
222 };