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)
58 static bool _startsWith(const char *sz, const char *key)
60 return !strncmp(sz, key, strlen(key));
63 static void _chomp(char *sz)
66 while ((nl = strrchr(sz, '\n')))
70 static int _process_pragma(const char *sz)
72 if (_startsWith(sz, "bank=")) {
74 sprintf(buffer, "%s", sz+5);
76 gbz80_port.mem.code_name = gc_strdup(buffer);
77 code->sname = gbz80_port.mem.code_name;
83 static bool _parseOptions(int *pargc, char **argv, int *i)
85 if (argv[*i][0] == '-') {
86 if (argv[*i][1] == 'b' && IS_GB) {
87 int bank = atoi(argv[*i] + 3);
89 switch (argv[*i][2]) {
92 sprintf(buffer, "CODE_%u", bank);
93 gbz80_port.mem.code_name = gc_strdup(buffer);
97 sprintf(buffer, "DATA_%u", bank);
98 gbz80_port.mem.data_name = gc_strdup(buffer);
102 else if (!strncmp(argv[*i], "--asm=", 6)) {
103 if (!strcmp(argv[*i], "--asm=rgbds")) {
104 asm_addTree(&_rgbds_gb);
105 _G.fsetAsmType = TRUE;
108 else if (!strcmp(argv[*i], "--asm=asxxxx")) {
109 asm_addTree(&_asxxxx_gb);
110 _G.fsetAsmType = TRUE;
113 else if (!strcmp(argv[*i], "--asm=isas")) {
114 asm_addTree(&_isas_gb);
115 /* Munge the function prefix */
116 gbz80_port.fun_prefix = "";
117 _G.fsetAsmType = TRUE;
125 static void _finaliseOptions(void)
127 port->mem.default_local_map = data;
128 port->mem.default_globl_map = data;
129 if (!_G.fsetAsmType && IS_GB)
130 asm_addTree(&_asxxxx_gb);
133 static void _setDefaultOptions(void)
135 options.genericPtr = 1; /* default on */
137 options.stackAuto = 1;
138 options.mainreturn = 1;
139 options.noregparms = 1;
141 /* first the options part */
142 options.intlong_rent = 1;
144 optimize.global_cse = 1;
149 optimize.loopInvariant = 1;
150 optimize.loopInduction = 0;
153 static const char *_getRegName(struct regs *reg)
161 /** $1 is always the basename.
162 $2 is always the output file.
164 $l is the list of extra options that should be there somewhere...
165 MUST be terminated with a NULL.
167 static const char *_z80_linkCmd[] = {
168 "link-z80", "-nf", "$1", NULL
171 static const char *_z80_asmCmd[] = {
172 "as-z80", "-plosgff", "$1.o", "$1.asm", NULL
175 /** $1 is always the basename.
176 $2 is always the output file.
178 $l is the list of extra options that should be there somewhere...
179 MUST be terminated with a NULL.
181 static const char *_gbz80_linkCmd[] = {
182 "link-gbz80", "-nf", "$1", NULL
185 static const char *_gbz80_asmCmd[] = {
186 "as-gbz80", "-plosgff", "$1.o", "$1.asm", NULL
192 "Zilog Z80", /* Target name */
198 "-plosgff", /* Options with debug */
199 "-plosgff", /* Options without debug */
208 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
209 1, 1, 2, 4, 2, 2, 2, 1, 4, 4
230 /* Z80 has no native mul/div commands */
242 0, /* no assembler preamble */
243 0, /* no local IVT generation code */
253 "Gameboy Z80-like", /* Target name */
259 "-plosgff", /* Options with debug */
260 "-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 */