3 static char _z80_defaultRules[] =
6 #include "peeph-z80.rul"
9 static char _gbz80_defaultRules[] =
12 #include "peeph-gbz80.rul"
21 static char *_keywords[] = {
26 extern PORT gbz80_port;
31 static void _z80_init(void)
33 z80_opts.sub = SUB_Z80;
34 asm_addTree(&_asxxxx_z80);
37 static void _gbz80_init(void)
39 z80_opts.sub = SUB_GBZ80;
42 static int regParmFlg = 0; /* determine if we can register a parameter */
44 static void _reset_regparm()
49 static int _reg_parm(link *l)
51 /* for this processor it is simple
52 can pass only the first parameter in a register */
61 static bool _startsWith(const char *sz, const char *key)
63 return !strncmp(sz, key, strlen(key));
66 static void _chomp(char *sz)
69 while ((nl = strrchr(sz, '\n')))
73 static int _process_pragma(const char *sz)
75 if (_startsWith(sz, "bank=")) {
77 sprintf(buffer, "%s", sz+5);
79 gbz80_port.mem.code_name = gc_strdup(buffer);
80 code->sname = gbz80_port.mem.code_name;
86 static bool _parseOptions(int *pargc, char **argv, int *i)
88 if (argv[*i][0] == '-') {
89 if (argv[*i][1] == 'b' && IS_GB) {
90 int bank = atoi(argv[*i] + 3);
92 switch (argv[*i][2]) {
95 sprintf(buffer, "_CODE_%u", bank);
96 gbz80_port.mem.code_name = gc_strdup(buffer);
100 sprintf(buffer, "_DATA_%u", bank);
101 gbz80_port.mem.data_name = gc_strdup(buffer);
105 else if (!strncmp(argv[*i], "--asm=", 6)) {
106 if (!strcmp(argv[*i], "--asm=rgbds")) {
107 asm_addTree(&_rgbds_gb);
108 _G.fsetAsmType = TRUE;
111 else if (!strcmp(argv[*i], "--asm=asxxxx")) {
112 asm_addTree(&_asxxxx_gb);
113 _G.fsetAsmType = TRUE;
116 else if (!strcmp(argv[*i], "--asm=isas")) {
117 asm_addTree(&_isas_gb);
118 /* Munge the function prefix */
119 gbz80_port.fun_prefix = "";
120 _G.fsetAsmType = TRUE;
128 static void _finaliseOptions(void)
130 port->mem.default_local_map = data;
131 port->mem.default_globl_map = data;
132 if (!_G.fsetAsmType && IS_GB)
133 asm_addTree(&_asxxxx_gb);
136 static void _setDefaultOptions(void)
138 options.genericPtr = 1; /* default on */
140 options.stackAuto = 1;
141 options.mainreturn = 1;
142 options.noregparms = 1;
144 /* first the options part */
145 options.intlong_rent = 1;
147 optimize.global_cse = 1;
152 optimize.loopInvariant = 1;
153 optimize.loopInduction = 0;
156 static const char *_getRegName(struct regs *reg)
164 /** $1 is always the basename.
165 $2 is always the output file.
167 $l is the list of extra options that should be there somewhere...
168 MUST be terminated with a NULL.
170 static const char *_z80_linkCmd[] = {
171 "link-z80", "-nf", "$1", NULL
174 static const char *_z80_asmCmd[] = {
175 "as-z80", "-plosgff", "$1.o", "$1.asm", NULL
178 /** $1 is always the basename.
179 $2 is always the output file.
181 $l is the list of extra options that should be there somewhere...
182 MUST be terminated with a NULL.
184 static const char *_gbz80_linkCmd[] = {
185 "link-gbz80", "-nf", "$1", NULL
188 static const char *_gbz80_asmCmd[] = {
189 "as-gbz80", "-plosgff", "$1.o", "$1.asm", NULL
195 "Zilog Z80", /* Target name */
201 "-plosgff", /* Options with debug */
202 "-plosgff", /* Options without debug */
211 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
212 1, 1, 2, 4, 2, 2, 2, 1, 4, 4
233 /* Z80 has no native mul/div commands */
245 0, /* no assembler preamble */
246 0, /* no local IVT generation code */
254 "Gameboy Z80-like", /* Target name */
260 "-plosgff", /* Options with debug */
261 "-plosgff", /* Options without debug */
270 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
271 1, 1, 2, 4, 2, 2, 2, 1, 4, 4
292 /* gbZ80 has no native mul/div commands */
304 0, /* no assembler preamble */
305 0, /* no local IVT generation code */