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