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