struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / src / z80 / mappings.i
blobf34801e12eb2b225c3bf0742c45b5d5ea794e151
1 static const ASM_MAPPING _asxxxx_gb_mapping[] = {
2 /* We want to prepend the _ */
3 { "area", ".area _%s" },
4 { "areacode", ".area _%s" },
5 { "areadata", ".area _%s" },
6 { "areahome", ".area _%s" },
7 { "functionlabeldef", "%s:" },
8 { "globalfunctionlabeldef", "%s::" },
9 { "*hl", "(hl)" },
10 { "jphl", "jp (hl)" },
11 { "di", "di" },
12 { "ei", "ei" },
13 { "ldahli", "ld\ta, (hl+)"},
14 { "ldahld", "ld\ta, (hl-)"},
15 { "lldahli", "ld\t(hl+), a"},
16 { "lldahld", "ld\t(hl-), a"},
17 { "rldh", "ldh a, (%s + %d)"},
18 { "lldh", "ldh (%s + %d), a"},
19 { "ldahlsp", "ldhl\tsp, #%d" },
20 { "ldaspsp", "add sp, #%d" },
21 { "mems", "(%s)" },
22 { "enter", "" },
23 { "enters", "" },
24 { "enterx",
25 "add sp, #-%d" },
26 { "pusha",
27 "push af\n"
28 "push bc\n"
29 "push de\n"
30 "push hl"
32 { "popa",
33 "pop hl\n"
34 "pop de\n"
35 "pop bc\n"
36 "pop af"
38 { "adjustsp", "add sp, #-%d" },
39 { "fileprelude", "" },
40 { "here", "." },
41 { "optsdcc", ".optsdcc" },
42 { NULL, NULL }
45 static const ASM_MAPPING _asxxxx_z80_mapping[] = {
46 /* We want to prepend the _ */
47 { "area", ".area _%s" },
48 { "areacode", ".area _%s" },
49 { "areadata", ".area _%s" },
50 { "areahome", ".area _%s" },
51 { "*ixx", "%d (ix)" },
52 { "*iyx", "%d (iy)" },
53 { "*hl", "(hl)" },
54 { "jphl", "jp (hl)" },
55 { "di", "di" },
56 { "ei", "ei" },
57 { "ldahli",
58 "ld a, (hl)\n"
59 "inc\thl" },
60 { "ldahld",
61 "ld a, (hl)\n"
62 "dec\thl" },
63 { "lldahli",
64 "ld (hl), a\n"
65 "inc\thl" },
66 { "lldahld",
67 "ld (hl), a\n"
68 "dec\thl" },
69 { "ldahlsp",
70 "ld hl, #%d\n"
71 "add\thl, sp" },
72 { "ldaspsp",
73 "ld iy,#%d\n"
74 "add\tiy,sp\n"
75 "ld\tsp,iy" },
76 { "mems", "(%s)" },
77 { "enter",
78 "push\tix\n"
79 "ld\tix,#0\n"
80 "add\tix,sp" },
81 { "enters",
82 "call\t___sdcc_enter_ix\n" },
83 { "pusha",
84 "push af\n"
85 "push\tbc\n"
86 "push\tde\n"
87 "push\thl\n"
88 "push\tiy"
90 { "popa",
91 "pop iy\n"
92 "pop\thl\n"
93 "pop\tde\n"
94 "pop\tbc\n"
95 "pop\taf"
97 { "adjustsp", "lda sp,-%d(sp)" },
98 { "here", "." },
99 { "optsdcc", ".optsdcc" },
100 { NULL, NULL }
103 static const ASM_MAPPING _asxxxx_r2k_mapping[] = {
104 /* We want to prepend the _ */
105 { "area", ".area _%s" },
106 { "areacode", ".area _%s" },
107 { "areadata", ".area _%s" },
108 { "areahome", ".area _%s" },
109 { "*ixx", "%d (ix)" },
110 { "*iyx", "%d (iy)" },
111 { "*hl", "(hl)" },
112 { "jphl", "jp (hl)" },
113 { "di", "ipset3" },
114 { "ei", "ipres" },
115 { "ldahli",
116 "ld a, (hl)\n"
117 "inc\thl" },
118 { "ldahld",
119 "ld a, (hl)\n"
120 "dec\thl" },
121 { "lldahli",
122 "ld (hl), a\n"
123 "inc\thl" },
124 { "lldahld",
125 "ld (hl), a\n"
126 "dec\thl" },
127 { "ldahlsp",
128 "ld hl, #%d\n"
129 "add\thl, sp" },
130 { "ldaspsp",
131 "ld iy,#%d\n"
132 "add\tiy,sp\n"
133 "ld\tsp,iy" },
134 { "mems", "(%s)" },
135 { "enter",
136 "push\tix\n"
137 "ld\tix,#0\n"
138 "add\tix,sp" },
139 { "enters",
140 "call\t___sdcc_enter_ix\n" },
141 { "pusha",
142 "push af\n"
143 "push\tbc\n"
144 "push\tde\n"
145 "push\thl\n"
146 "push\tiy"
148 { "popa",
149 "pop iy\n"
150 "pop\thl\n"
151 "pop\tde\n"
152 "pop\tbc\n"
153 "pop\taf"
155 { "adjustsp", "lda sp,-%d(sp)" },
156 { "optsdcc", ".optsdcc" },
157 { NULL, NULL }
160 static const ASM_MAPPING _rgbds_mapping[] = {
161 { "global", "EXPORT %s" },
162 { "extern", "" },
163 { "slabeldef", "%s:" },
164 { "labeldef", "%s:" },
165 { "tlabeldef", ".l%05d:" },
166 { "tlabel", ".l%05d" },
167 { "fileprelude",
168 "; Generated using the rgbds tokens.\n"
170 { "functionheader",
171 "; ---------------------------------\n"
172 "; Function %s\n"
173 "; ---------------------------------"
175 { "functionlabeldef", "%s:" },
176 { "globalfunctionlabeldef", "%s::" },
177 { "zero", "$00" },
178 { "one", "$01" },
179 { "area", "SECTION FRAGMENT \"_%s\",ROM0" },
180 { "areadata", "SECTION FRAGMENT \"%F_DATA\",%s" },
181 { "areacode", "SECTION FRAGMENT \"%F_CODE\",%s" },
182 { "areahome", "SECTION FRAGMENT \"%F_HOME\",ROM0" },
183 { "ascii", "DB \"%s\"" },
184 { "ds", "DS %d" },
185 { "db", "DB" },
186 { "dbs", "DB %s" },
187 { "dw", "DW" },
188 { "dws", "DW %s" },
189 { "immed", "" },
190 { "constbyte", "$%02X" },
191 { "constword", "$%04X" },
192 { "immedword", "$%04X" },
193 { "immedbyte", "$%02X" },
194 { "hashedstr", "%s" },
195 { "lsbimmeds", "LOW(%s)" },
196 { "msbimmeds", "HIGH(%s)" },
197 { "bankimmeds", "BANK(%s)" },
198 { "hashedbankimmeds", "BANK(%s)" },
199 { "module", "; MODULE %s" },
200 { "equ", "EQU" },
201 { "bequ", "\rb%s EQU %i" },
202 { "here", "@" },
203 { "optsdcc", "; optsdcc" },
204 { NULL, NULL }
207 static const ASM_MAPPING _rgbds_gb_mapping[] = {
208 { "pusha",
209 "push af\n"
210 "\tpush bc\n"
211 "\tpush de\n"
212 "\tpush hl"
214 { "popa",
215 "pop hl\n"
216 "\tpop de\n"
217 "\tpop bc\n"
218 "\tpop af"
220 { "di", "di" },
221 { "ei", "ei" },
222 { "adjustsp", "add sp, -%d" },
223 { "enter", "" },
224 { "enters", "" },
225 { "enterx",
226 "add sp, -%d" },
227 { "rldh", "ldh a, [%s + %d]"},
228 { "lldh", "ldh [%s + %d], a"},
229 { "ldahli", "ld a, [hl+]" },
230 { "ldahld", "ld a, [hl-]" },
231 { "lldahli", "ld [hl+], a" },
232 { "lldahld", "ld [hl-], a" },
233 { "*hl", "[hl]" },
234 { "jphl", "jp hl" },
235 { "ldahlsp", "ld hl, sp+%d" },
236 { "ldaspsp", "add sp, %d" },
237 { "mems", "[%s]" },
238 { "optsdcc", "; optsdcc" },
239 { NULL, NULL }
242 static const ASM_MAPPING _isas_mapping[] = {
243 { "global", "GLOBAL %s" },
244 { "extern", "GLOBAL %s" },
245 { "slabeldef", "%s:" },
246 { "labeldef", "%s:" },
247 { "tlabeldef", "?l%05d:" },
248 { "tlabel", "?l%05d" },
249 { "fileprelude",
250 ";Generated using the isas tokens.\n"
251 "\tLPREFIX '?' ; Treat labels starting with ? as local.\n"
252 "\tONCNUM ; Numbers are hex\n"
253 "\tCAPSOFF ; Case sensitive\n"
254 "\tISDMG ; Gameboy mode\n"
255 "_CODE\tGROUP\n"
256 "\t; We have to define these here as sdcc doesn't make them global by default\n"
257 "\tGLOBAL __mulschar\n"
258 "\tGLOBAL __muluchar\n"
259 "\tGLOBAL __mulint\n"
260 "\tGLOBAL __divschar\n"
261 "\tGLOBAL __divuchar\n"
262 "\tGLOBAL __divsint\n"
263 "\tGLOBAL __divuint\n"
264 "\tGLOBAL __modschar\n"
265 "\tGLOBAL __moduchar\n"
266 "\tGLOBAL __modsint\n"
267 "\tGLOBAL __moduint\n"
268 "\tGLOBAL banked_call\n"
269 "\tGLOBAL banked_ret\n"
271 { "functionheader",
272 "; ---------------------------------\n"
273 "; Function %s\n"
274 "; ---------------------------------"
276 { "functionlabeldef", "%s:" },
277 { "globalfunctionlabeldef", "%s::" },
278 { "zero", "$00" },
279 { "one", "$01" },
280 { "area", "%s\tGROUP" },
281 { "areacode", "_CODE\tGROUP" },
282 { "areadata", "_DATA\tGROUP" },
283 { "areahome", "_CODE\tGROUP" },
284 { "ascii", "DB \"%s\"" },
285 { "ds", "DS %d" },
286 { "db", "DB" },
287 { "dbs", "DB %s" },
288 { "dw", "DW" },
289 { "dws", "DW %s" },
290 { "immed", "" },
291 { "constbyte", "0x%02X" },
292 { "constword", "0x%04X" },
293 { "immedword", "0x%04X" },
294 { "immedbyte", "0x%02X" },
295 { "hashedstr", "%s" },
296 { "lsbimmeds", "%s & 0xFF" },
297 { "msbimmeds", "%s >> 8" },
298 { "bankimmeds", "!%s" },
299 { "hashedbankimmeds", "!%s" },
300 { "module", "; MODULE %s" },
301 { "optsdcc", "; optsdcc" },
302 { NULL, NULL }
305 static const ASM_MAPPING _isas_gb_mapping[] = {
306 { "pusha",
307 "push af\n"
308 "push bc\n"
309 "push de\n"
310 "push hl"
312 { "popa",
313 "pop hl\n"
314 "pop de\n"
315 "pop bc\n"
316 "pop af"
318 { "di", "di" },
319 { "ei", "ei" },
320 { "adjustsp", "add sp, -%d" },
321 { "enter", "" },
322 { "enters", "" },
323 { "ldahli", "ld a, (hli)" },
324 { "ldahld", "ld a, (hld)" },
325 { "lldahli", "ld (hli), a" },
326 { "lldahld", "ld (hld), a" },
327 { "*hl", "(hl)" },
328 { "jphl", "jp (hl)" },
329 { "ldahlsp", "ldhl sp, %d" },
330 { "ldaspsp", "add sp, %d" },
331 { "mems", "(%s)" },
332 { "optsdcc", "; optsdcc" },
333 { NULL, NULL }
336 static const ASM_MAPPING _z80asm_mapping[] = {
337 { "global", "XDEF %s" },
338 { "extern", "XREF %s" },
339 { "slabeldef", "\n.%s" },
340 { "labeldef", "\n.%s" },
341 { "tlabeldef", "\n.l%N%05d" },
342 { "tlabel", "l%N%05d" },
343 { "fileprelude",
344 "; Generated using the z80asm/z88 tokens.\n"
345 "\tXREF __muluchar_rrx_s\n"
346 "\tXREF __mulschar_rrx_s\n"
347 "\tXREF __mulint_rrx_s\n"
348 "\tXREF __mullong_rrx_s\n"
349 "\tXREF __divuchar_rrx_s\n"
350 "\tXREF __divschar_rrx_s\n"
351 "\tXREF __divsint_rrx_s\n"
352 "\tXREF __divuint_rrx_s\n"
353 "\tXREF __divulong_rrx_s\n"
354 "\tXREF __divslong_rrx_s\n"
355 "\tXREF __rrulong_rrx_s\n"
356 "\tXREF __rrslong_rrx_s\n"
357 "\tXREF __rlulong_rrx_s\n"
358 "\tXREF __rlslong_rrx_s\n"
360 { "functionheader",
361 "; ---------------------------------\n"
362 "; Function %s\n"
363 "; ---------------------------------"
365 { "functionlabeldef", ".%s" },
366 { "globalfunctionlabeldef", ".%s" },
367 { "zero", "$00" },
368 { "one", "$01" },
369 { "ascii", "DEFM \"%s\"" },
370 { "ds", "DEFS %d" },
371 { "db", "DEFB" },
372 { "dbs", "DEFB %s" },
373 { "dw", "DEFW" },
374 { "dws", "DEFB %s" },
375 { "immed", "" },
376 { "constbyte", "$%02X" },
377 { "constword", "$%04X" },
378 { "immedword", "$%04X" },
379 { "immedbyte", "$%02X" },
380 { "hashedstr", "%s" },
381 { "lsbimmeds", "%s ~ $FF" },
382 { "msbimmeds", "%s / 256" },
384 { "bankimmeds", "BANK(%s)" },
385 { "hashedbankimmeds", "BANK(%s)" },
386 { "module", "MODULE %s" },
387 { "area", "; Area %s" },
388 { "areadata", "; Aread BSS" },
389 { "areacode", "; Area CODE" },
390 { "areahome", "; Area HOME" },
391 { "optsdcc", "; optsdcc" },
392 { NULL, NULL }
395 static const ASM_MAPPING _z80asm_z80_mapping[] = {
396 { "*ixx", "(ix%+d)" },
397 { "*iyx", "(iy%+d)" },
398 { "*hl", "(hl)" },
399 { "jphl", "jp (hl)" },
400 { "di", "di" },
401 { "ei", "ei" },
402 { "ldahli",
403 "ld a, (hl)\n"
404 "inc\thl" },
405 { "ldahld",
406 "ld a, (hl)\n"
407 "dec\thl" },
408 { "ldahli",
409 "ld (hl), a\n"
410 "inc\thl" },
411 { "ldahld",
412 "ld (hl), a\n"
413 "dec\thl" },
414 { "ldahlsp",
415 "ld hl, %d\n"
416 "add\thl, sp" },
417 { "ldaspsp",
418 "ld iy, %d\n"
419 "add\tiy, sp\n"
420 "ld\tsp, iy" },
421 { "mems", "(%s)" },
422 { "enter",
423 "push\tix\n"
424 "ld\tix,0\n"
425 "add\tix,sp" },
426 { "enters",
427 "call\t___sdcc_enter_ix\n" },
428 { "pusha",
429 "push af\n"
430 "push\tbc\n"
431 "push\tde\n"
432 "push\thl\n"
433 "push\tiy"
435 { "popa",
436 "pop\tiy\n"
437 "pop\thl\n"
438 "pop\tde\n"
439 "pop\tbc\n"
440 "pop\taf"
442 { "adjustsp", "lda sp, (sp%+d)" },
443 { "optsdcc", "; optsdcc" },
444 { NULL, NULL }
446 static const ASM_MAPPING _gas_gb_mapping[] = {
447 { "immed", "#"},
448 { "zero", "#0x00"},
449 { "one", "#0x01"},
450 { "area", ".area\t%s" },
451 { "areacode", ".area\t%s"},
452 { "areadata", ".area\t%s"},
453 { "areahome", ".area\t%s"},
454 { "functionlabeldef", "%s:" },
455 { "globalfunctionlabeldef", "%s:" },
456 { "*hl", "(hl)" },
457 { "di", "di" },
458 { "ei", "ei" },
459 { "ldahli", "ldi\ta, (hl)" },
460 { "ldahld", "ldd\ta, (hl)" },
461 { "lldahli", "ldi\t(hl), a" },
462 { "lldahld", "ldd\t(hl), a" },
463 { "ldahlsp", "ldhl\tsp, #%d" },
464 { "ldaspsp", "add\tsp, #%d" },
465 { "mems", "(%s)" },
466 { "enter", "" },
467 { "enters", "" },
468 { "enterx", "add\tsp, #-%d" },
469 { "pusha",
470 "push\taf\n"
471 "push\tbc\n"
472 "push\tde\n"
473 "push\thl"
475 { "popa",
476 "pop\thl\n"
477 "pop\tde\n"
478 "pop\tbc\n"
479 "pop\taf"
481 { "adjustsp", "lda\tsp, -%d (sp)" },
482 { "fileprelude", "" },
483 { "optsdcc", "; optsdcc" },
484 { NULL, NULL }
487 static const ASM_MAPPING _gas_z80_mapping[] = {
488 {"immed", "#"},
489 {"zero", "#0x00"},
490 {"one", "#0x01"},
491 {"area", ".area\t%s"},
492 {"areacode", ".area\t%s"},
493 {"areadata", ".area\t%s"},
494 {"areahome", ".area\t%s"},
495 {"constbyte", "0x%02x"},
496 {"constword", "0x%04x"},
497 {"immedword", "#0x%04x"},
498 {"immedbyte", "#0x%02x"},
499 {"hashedstr", "#%s"},
500 {"bankimmeds", "%s >> 16"},
501 { "*ixx", "%d (ix)" },
502 { "*iyx", "%d (iy)" },
503 { "*hl", "(hl)" },
504 { "di", "di" },
505 { "ei", "ei" },
506 { "ldahli",
507 "ld\ta,(hl)\n"
508 "inc\thl" },
509 { "ldahld",
510 "ld\ta,(hl)\n"
511 "dec\thl" },
512 { "lldahli",
513 "ld\t(hl),a\n"
514 "inc\thl" },
515 { "lldahld",
516 "ld\t(hl),a\n"
517 "dec\thl" },
518 { "ldahlsp",
519 "ld\thl, #%d\n"
520 "add\thl, sp" },
521 { "ldaspsp",
522 "ld\tiy,#%d\n"
523 "add\tiy,sp\n"
524 "ld\tsp,iy" },
525 { "mems", "(%s)" },
526 { "enter",
527 "push\tix\n"
528 "ld\tix,#0\n"
529 "add\tix,sp" },
530 { "enters", "call\t___sdcc_enter_ix\n" },
531 { "pusha",
532 "push\taf\n"
533 "push\tbc\n"
534 "push\tde\n"
535 "push\thl\n"
536 "push\tiy"
538 { "popa",
539 "pop\tiy\n"
540 "pop\thl\n"
541 "pop\tde\n"
542 "pop\tbc\n"
543 "pop\taf"
545 { "adjustsp", "lda\tsp,-%d (sp)" },
546 { "optsdcc", "; optsdcc" },
547 { NULL, NULL }
550 static const ASM_MAPPINGS _isas = {
551 NULL,
552 _isas_mapping
555 const ASM_MAPPINGS _isas_gb = {
556 &_isas,
557 _isas_gb_mapping
560 static const ASM_MAPPINGS _rgbds = {
561 NULL,
562 _rgbds_mapping
565 const ASM_MAPPINGS _rgbds_gb = {
566 &_rgbds,
567 _rgbds_gb_mapping
570 const ASM_MAPPINGS _asxxxx_gb = {
571 &asm_asxxxx_mapping,
572 _asxxxx_gb_mapping
575 const ASM_MAPPINGS _asxxxx_z80 = {
576 &asm_asxxxx_mapping,
577 _asxxxx_z80_mapping
580 static const ASM_MAPPINGS _z80asm = {
581 NULL,
582 _z80asm_mapping
585 const ASM_MAPPINGS _z80asm_z80 = {
586 &_z80asm,
587 _z80asm_z80_mapping
590 const ASM_MAPPINGS _asxxxx_r2k = {
591 &asm_asxxxx_mapping,
592 _asxxxx_r2k_mapping
595 const ASM_MAPPINGS _gas_gb = {
596 &asm_gas_mapping,
597 _gas_gb_mapping
600 const ASM_MAPPINGS _gas_z80 = {
601 &asm_gas_mapping,
602 _gas_z80_mapping