Merge of the izt changes.
[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     { 1, REG_ID_C,   "c",   0, { REG_ID_BC, REG_ID_NONE, REG_ID_NONE } },
8     { 1, REG_ID_B,   "b",   0, { REG_ID_BC, REG_ID_NONE, REG_ID_NONE } },
9     { 1, REG_ID_E,   "e",   0, { REG_ID_DE, REG_ID_NONE, REG_ID_NONE } },
10     { 1, REG_ID_D,   "d",   0, { REG_ID_DE, REG_ID_NONE, REG_ID_NONE } },
11     { 2, REG_ID_BC,  "bc",  0, { REG_ID_C, REG_ID_B, REG_ID_NONE } },
12     { 2, REG_ID_DE,  "de",  0, { REG_ID_E, REG_ID_D, REG_ID_NONE } },
13     { 4, REG_ID_XBC, "xbc", 0, { REG_ID_C, REG_ID_B, REG_ID_BC } },
14     { 4, REG_ID_XDE, "xde", 0, { REG_ID_E, REG_ID_D, REG_ID_DE } },
15     { 0, REG_ID_NONE,"??",  0, { REG_ID_NONE, REG_ID_NONE, REG_ID_NONE } }
16 };
17
18 static IZT_PORT _tlcs900h_port = {
19     _tlcs900h_regs
20 };
21
22 static char _defaultRules[] =
23 {
24     //#include "peeph.rul"
25 };
26
27 static char *_tlcs900h_keywords[] =     {
28     NULL
29 };
30
31 void tlcs900h_assignRegisters (eBBlock **ebbs, int count);
32
33 static void _tlcs900h_init(void)
34 {
35     asm_addTree(&asm_asxxxx_mapping);
36     izt_init(&_tlcs900h_port);
37 }
38
39 static void _tlcs900h_reset_regparm()
40 {
41 }
42
43 static int _tlcs900h_regparm( sym_link *l)
44 {
45     // PENDING: No register parameters.
46     return 0;
47 }
48
49 static bool _tlcs900h_parseOptions(int *pargc, char **argv, int *i)
50 {
51     /* TODO: allow port-specific command line options to specify
52      * segment names here.
53      */
54     return FALSE;
55 }
56
57 static void _tlcs900h_finaliseOptions(void)
58 {
59     // No options
60 }
61
62 static void _tlcs900h_setDefaultOptions(void)
63 {
64     // No options
65 }
66
67 static const char *_tlcs900h_getRegName(struct regs *reg)
68 {
69     if (reg)
70         return reg->name;
71     wassert(0);
72     return "err";
73 }
74
75 static void _tlcs900h_genAssemblerPreamble(FILE *of)
76 {
77     // PENDING
78 }
79
80 /* Generate interrupt vector table. */
81 static int _tlcs900h_genIVT(FILE *of, symbol **interrupts, int maxInterrupts)
82 {
83     // PENDING
84     return 0;
85 }
86
87 /** $1 is always the basename.
88     $2 is always the output file.
89     $3 varies
90     $l is the list of extra options that should be there somewhere...
91     MUST be terminated with a NULL.
92 */
93 // PENDING
94 static const char *_linkCmd[] = {
95     "aslink", "-nf", "$1", NULL
96 };
97
98 // PENDING
99 static const char *_asmCmd[] = {
100  "gpasm", NULL, NULL, NULL
101 };
102
103 void tlcs900h_assignRegisters (eBBlock **ebbs, int count)
104 {
105 }
106
107 /* Globals */
108 PORT tlcs900h_port = {
109     "tlcs900h",
110     "Toshiba TLCS-900H",        /* Target name */
111     {
112         TRUE,                   /* Emit glue around main */
113         MODEL_SMALL,
114         MODEL_SMALL
115     },
116     {   
117         _asmCmd,
118         NULL,
119         NULL,
120         0
121     },
122     {
123         _linkCmd,
124         NULL,
125         ".o"
126     },
127     {
128         _defaultRules
129     },
130     {
131         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
132         1, 2, 2, 4, 2, 2, 2, 1, 4, 4
133     },
134     {
135         "XSEG    (XDATA)",
136         "STACK   (DATA)",
137         "CSEG    (CODE)",
138         "DSEG    (DATA)",
139         "ISEG    (DATA)",
140         "XSEG    (XDATA)",
141         "BSEG    (BIT)",
142         "RSEG    (DATA)",
143         "GSINIT  (CODE)",
144         "OSEG    (OVR,DATA)",
145         "GSFINAL (CODE)",
146         "HOME    (CODE)",
147         NULL,
148         NULL,
149         1
150     },
151     { 
152         +1, 1, 4, 1, 1, 0
153     },
154     /* tlcs900h has an 16 bit mul */
155     {
156         2, 0
157     },
158     "_",
159     _tlcs900h_init,
160     _tlcs900h_parseOptions,
161     _tlcs900h_finaliseOptions,
162     _tlcs900h_setDefaultOptions,
163     tlcs900h_assignRegisters,
164     _tlcs900h_getRegName ,
165     _tlcs900h_keywords,
166     _tlcs900h_genAssemblerPreamble,
167     _tlcs900h_genIVT ,
168     _tlcs900h_reset_regparm,
169     _tlcs900h_regparm,
170     NULL,
171     FALSE,
172     0,  /* leave lt */
173     0,  /* leave gt */
174     1,  /* transform <= to ! > */
175     1,  /* transform >= to ! < */
176     1,  /* transform != to !(a == b) */
177     0,  /* leave == */
178     PORT_MAGIC
179 };