3 static char _z80_defaultRules[] =
6 #include "peeph-z80.rul"
9 static char _gbz80_defaultRules[] =
12 #include "peeph-gbz80.rul"
21 static char *_keywords[] = { NULL };
23 extern PORT gbz80_port;
28 static void _z80_init(void)
30 z80_opts.sub = SUB_Z80;
31 asm_addTree(&_asxxxx_z80);
34 static void _gbz80_init(void)
36 z80_opts.sub = SUB_GBZ80;
39 static int regParmFlg = 0; /* determine if we can register a parameter */
41 static void _reset_regparm()
46 static int _reg_parm(link *l)
48 /* for this processor it is simple
49 can pass only the first parameter in a register */
58 static int _process_pragma(const char *sz)
60 printf("Got pragma \"%s\"\n", sz);
64 static bool _parseOptions(int *pargc, char **argv, int *i)
66 if (argv[*i][0] == '-') {
67 if (argv[*i][1] == 'b' && IS_GB) {
68 int bank = atoi(argv[*i] + 3);
70 switch (argv[*i][2]) {
73 sprintf(buffer, "_CODE_%u", bank);
74 gbz80_port.mem.code_name = gc_strdup(buffer);
78 sprintf(buffer, "_DATA_%u", bank);
79 gbz80_port.mem.data_name = gc_strdup(buffer);
83 else if (!strncmp(argv[*i], "--asm=", 6)) {
84 if (!strcmp(argv[*i], "--asm=rgbds")) {
85 asm_addTree(&_rgbds_gb);
86 _G.fsetAsmType = TRUE;
89 else if (!strcmp(argv[*i], "--asm=asxxxx")) {
90 asm_addTree(&_asxxxx_gb);
91 _G.fsetAsmType = TRUE;
94 else if (!strcmp(argv[*i], "--asm=isas")) {
95 asm_addTree(&_isas_gb);
96 /* Munge the function prefix */
97 gbz80_port.fun_prefix = "";
98 _G.fsetAsmType = TRUE;
106 static void _finaliseOptions(void)
108 port->mem.default_local_map = data;
109 port->mem.default_globl_map = data;
110 if (!_G.fsetAsmType && IS_GB)
111 asm_addTree(&_asxxxx_gb);
114 static void _setDefaultOptions(void)
116 options.genericPtr = 1; /* default on */
118 options.stackAuto = 1;
119 options.mainreturn = 1;
120 options.noregparms = 1;
122 /* first the options part */
123 options.intlong_rent = 1;
125 optimize.global_cse = 1;
130 optimize.loopInvariant = 1;
131 optimize.loopInduction = 0;
134 static const char *_getRegName(struct regs *reg)
142 /** $1 is always the basename.
143 $2 is always the output file.
145 $l is the list of extra options that should be there somewhere...
146 MUST be terminated with a NULL.
148 static const char *_z80_linkCmd[] = {
149 "link-z80", "-nf", "$1", NULL
152 static const char *_z80_asmCmd[] = {
153 "as-z80", "-plosgff", "$1.o", "$1.asm", NULL
156 /** $1 is always the basename.
157 $2 is always the output file.
159 $l is the list of extra options that should be there somewhere...
160 MUST be terminated with a NULL.
162 static const char *_gbz80_linkCmd[] = {
163 "link-gbz80", "-nf", "$1", NULL
166 static const char *_gbz80_asmCmd[] = {
167 "as-gbz80", "-plosgff", "$1.o", "$1.asm", NULL
173 "Zilog Z80", /* Target name */
179 "-plosgff", /* Options with debug */
180 "-plosgff", /* Options without debug */
189 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
190 1, 1, 2, 4, 2, 2, 2, 1, 4, 4
211 /* Z80 has no native mul/div commands */
223 0, /* no assembler preamble */
224 0, /* no local IVT generation code */
232 "Gameboy Z80-like", /* Target name */
238 "-plosgff", /* Options with debug */
239 "-plosgff", /* Options without debug */
248 /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
249 1, 1, 2, 4, 2, 2, 2, 1, 4, 4
270 /* gbZ80 has no native mul/div commands */
282 0, /* no assembler preamble */
283 0, /* no local IVT generation code */