Lots.
[fw/sdcc] / src / z80 / main.c
1 #include "z80.h"
2
3 static char _defaultRules[] =
4 {
5 #include "peeph.rul"
6 };
7
8 Z80_OPTS z80_opts;
9
10 static char *_z80_keywords[] = { NULL };
11
12 static void _z80_init(void)
13 {
14     z80_opts.sub = SUB_Z80;
15 }
16
17 static bool _z80_parseOptions(int *pargc, char **argv, int *i)
18 {
19     return FALSE;
20 }
21
22 static void _z80_finaliseOptions(void)
23 {
24 }
25
26 static void _z80_setDefaultOptions(void)
27 {    
28     options.genericPtr = 1;   /* default on */
29     options.nopeep    = 0;
30     options.stackAuto = 1;
31     options.mainreturn = 1;
32     options.noregparms = 1;
33     /* first the options part */
34     options.intlong_rent = 1;
35
36     optimize.global_cse = 1;    
37     optimize.label1 = 1;
38     optimize.label2 = 1;
39     optimize.label3 = 1;
40     optimize.label4 = 1;    
41     optimize.loopInvariant = 1;
42     optimize.loopInduction = 0;
43 }
44
45 static const char *_z80_getRegName(struct regs *reg)
46 {
47     if (reg)
48         return reg->name;
49     assert(0);
50     return "err";
51 }
52
53 /** $1 is always the basename.
54     $2 is always the output file.
55     $3 varies
56     $l is the list of extra options that should be there somewhere...
57     MUST be terminated with a NULL.
58 */
59 static const char *_linkCmd[] = {
60     "link-z80", "-nf", "$1", NULL
61 };
62
63 static const char *_asmCmd[] = {
64     "as-z80", "-plosgff", "$1.o", "$1.asm", NULL
65 };
66
67 /* Globals */
68 PORT z80_port = {
69     "z80",
70     "Zilog Z80",                /* Target name */
71     {
72         FALSE,
73     },
74     {   
75         _asmCmd,
76         "-plosgff",             /* Options with debug */
77         "-plosgff",             /* Options without debug */
78     },
79     {
80         _linkCmd
81     },
82     {
83         _defaultRules
84     },
85     {
86         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
87         1, 1, 2, 4, 2, 2, 2, 1, 4, 4
88     },
89     {
90         "_XSEG",
91         "_STACK",
92         "_CODE",
93         "_DATA",
94         "_ISEG",
95         "_XSEG",
96         "_BSEG",
97         "_RSEG",
98         "_GSINIT",
99         "_OVERLAY"
100     },
101     { 
102         -1, 0, 0, 8, 0
103     },
104     /* Z80 has no native mul/div commands */
105     {  
106         0
107     },
108     _z80_init,
109     _z80_parseOptions,
110     _z80_finaliseOptions,
111     _z80_setDefaultOptions,
112     z80_assignRegisters,
113     _z80_getRegName,
114     _z80_keywords,
115     0,  /* no assembler preamble */
116     0,  /* no local IVT generation code */
117 };
118