3 static char _z80_defaultRules[] =
6 #include "peeph-z80.rul"
9 static char _gbz80_defaultRules[] =
12 #include "peeph-gbz80.rul"
21 static char *_keywords[] = {
27 extern PORT gbz80_port;
32 static void _z80_init(void)
34 z80_opts.sub = SUB_Z80;
35 asm_addTree(&_asxxxx_z80);
38 static void _gbz80_init(void)
40 z80_opts.sub = SUB_GBZ80;
43 static int regParmFlg = 0; /* determine if we can register a parameter */
45 static void _reset_regparm()
50 static int _reg_parm(link *l)
59 static bool _startsWith(const char *sz, const char *key)
61 return !strncmp(sz, key, strlen(key));
64 static void _chomp(char *sz)
67 while ((nl = strrchr(sz, '\n')))
71 static int _process_pragma(const char *sz)
73 if (_startsWith(sz, "bank=")) {
75 sprintf(buffer, "%s", sz+5);
77 gbz80_port.mem.code_name = gc_strdup(buffer);
78 code->sname = gbz80_port.mem.code_name;
84 static bool _parseOptions(int *pargc, char **argv, int *i)
86 if (argv[*i][0] == '-') {
87 if (argv[*i][1] == 'b' && IS_GB) {
88 int bank = atoi(argv[*i] + 3);
90 switch (argv[*i][2]) {
93 sprintf(buffer, "CODE_%u", bank);
94 gbz80_port.mem.code_name = gc_strdup(buffer);
98 sprintf(buffer, "DATA_%u", bank);
99 gbz80_port.mem.data_name = gc_strdup(buffer);
103 else if (!strncmp(argv[*i], "--asm=", 6)) {
104 if (!strcmp(argv[*i], "--asm=rgbds")) {
105 asm_addTree(&_rgbds_gb);
106 _G.fsetAsmType = TRUE;
109 else if (!strcmp(argv[*i], "--asm=asxxxx")) {
110 asm_addTree(&_asxxxx_gb);
111 _G.fsetAsmType = TRUE;
114 else if (!strcmp(argv[*i], "--asm=isas")) {
115 asm_addTree(&_isas_gb);
116 /* Munge the function prefix */
117 gbz80_port.fun_prefix = "";
118 _G.fsetAsmType = TRUE;
126 static void _finaliseOptions(void)
128 port->mem.default_local_map = data;
129 port->mem.default_globl_map = data;
130 if (!_G.fsetAsmType && IS_GB)
131 asm_addTree(&_asxxxx_gb);
134 static void _setDefaultOptions(void)
136 options.genericPtr = 1; /* default on */
138 options.stackAuto = 1;
139 options.mainreturn = 1;
140 options.noregparms = 1;
142 /* first the options part */
143 options.intlong_rent = 1;
145 optimize.global_cse = 1;
150 optimize.loopInvariant = 1;
151 optimize.loopInduction = 0;
154 static const char *_getRegName(struct regs *reg)
162 /** $1 is always the basename.
163 $2 is always the output file.
165 $l is the list of extra options that should be there somewhere...
166 MUST be terminated with a NULL.
168 static const char *_z80_linkCmd[] = {
169 "link-z80", "-nf", "$1", NULL
172 static const char *_z80_asmCmd[] = {
173 "as-z80", "-plosgff", "$1.o", "$1.asm", NULL
176 /** $1 is always the basename.
177 $2 is always the output file.
179 $l is the list of extra options that should be there somewhere...
180 MUST be terminated with a NULL.
182 static const char *_gbz80_linkCmd[] = {
183 "link-gbz80", "-nf", "$1", NULL
186 static const char *_gbz80_asmCmd[] = {
187 "as-gbz80", "-plosgff", "$1.o", "$1.asm", NULL
193 "Zilog Z80", /* Target name */
199 "-plosgff", /* Options with debug */
200 "-plosgff", /* Options without debug */
209 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
210 1, 1, 2, 4, 2, 2, 2, 1, 4, 4
231 /* Z80 has no native mul/div commands */
243 0, /* no assembler preamble */
244 0, /* no local IVT generation code */
254 "Gameboy Z80-like", /* Target name */
260 "-plosgff", /* Options with debug */
261 "-plosgff", /* Options without debug */
271 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
272 1, 1, 2, 4, 2, 2, 2, 1, 4, 4
293 /* gbZ80 has no native mul/div commands */
305 0, /* no assembler preamble */
306 0, /* no local IVT generation code */