* Added support for the gb.
[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         _asmCmd,
73         "-plosgff",             /* Options with debug */
74         "-plosgff",             /* Options without debug */
75     },
76     {
77         _linkCmd
78     },
79     {
80         _defaultRules
81     },
82     {
83         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
84         1, 1, 2, 4, 2, 2, 2, 1, 4, 4
85     },
86     {
87         "_XSEG",
88         "_STACK",
89         "_CODE",
90         "_DATA",
91         "_ISEG",
92         "_XSEG",
93         "_BSEG",
94         "_RSEG",
95         "_GSINIT",
96         "_OVERLAY"
97     },
98     { 
99         -1, 0, 0, 8, 0
100     },
101     /* Z80 has no native mul/div commands */
102     {  
103         0
104     },
105     _z80_init,
106     _z80_parseOptions,
107     _z80_finaliseOptions,
108     _z80_setDefaultOptions,
109     z80_assignRegisters,
110     _z80_getRegName,
111     _z80_keywords,
112     0,  /* no assembler preamble */
113     0,  /* no local IVT generation code */
114 };
115