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