e9f852084f0def9f5d412340cc6b349f23416fe2
[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     0,
148     NULL
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     "XSEG    (XDATA)",
164     "STACK   (DATA)",
165     "CSEG    (CODE)",
166     "DSEG    (DATA)",
167     "ISEG    (DATA)",
168     "XSEG    (XDATA)",
169     "BSEG    (BIT)",
170     "RSEG    (DATA)",
171     "GSINIT  (CODE)",
172     "OSEG    (OVR,DATA)",
173     "GSFINAL (CODE)",
174     "HOME        (CODE)",
175     NULL,
176     NULL,
177     1
178   },
179   {
180     +1, 1, 4, 1, 1, 0
181   },
182     /* tlcs900h has an 16 bit mul */
183   {
184     2, -1
185   },
186   "_",
187   _tlcs900h_init,
188   _tlcs900h_parseOptions,
189   _tlcs900h_finaliseOptions,
190   _tlcs900h_setDefaultOptions,
191   tlcs900h_assignRegisters,
192   _tlcs900h_getRegName,
193   _tlcs900h_keywords,
194   _tlcs900h_genAssemblerPreamble,
195   _tlcs900h_genIVT,
196   _tlcs900h_reset_regparm,
197   _tlcs900h_regparm,
198   NULL,
199   NULL,
200   FALSE,
201   0,                            /* leave lt */
202   0,                            /* leave gt */
203   1,                            /* transform <= to ! > */
204   1,                            /* transform >= to ! < */
205   1,                            /* transform != to !(a == b) */
206   0,                            /* leave == */
207   FALSE,                        /* No array initializer support. */     
208   PORT_MAGIC
209 };