Imported Upstream version 2.9.0
[debian/cc1111] / src / z80 / mappings.i
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     { "*hl", "(hl)" },
9     { "di", "di" },
10     { "ei", "ei" },
11     { "ldahli", "ld a,(hl+)" },
12     { "ldahlsp", "lda hl,%d(sp)" },
13     { "ldaspsp", "lda sp,%d(sp)" },
14     { "*pair", "(%s)" },
15     { "shortjp", "jr" },
16     { "enter", "" },
17     { "enterx", 
18       "lda sp,-%d(sp)" },
19     { "enterxl",
20                 "ld hl,#-%d\n"
21                 "\tadd\thl,sp\n"
22                 "\tld\tsp,hl"
23     },
24     { "leave", ""
25     },
26     { "leavex", "lda sp,%d(sp)"
27     },
28     { "leavexl",
29                 "ld hl,#%d\n"
30                 "\tadd\thl,sp\n"
31                 "\tld\tsp,hl"
32     },
33     { "pusha", 
34       "push af\n"
35       "\tpush bc\n"
36       "\tpush de\n"
37       "\tpush hl"
38     },
39     { "popa", 
40       "pop hl\n"
41       "\tpop de\n"
42       "\tpop bc\n"
43       "\tpop af"
44     },
45     { "adjustsp", "lda sp,-%d(sp)" },
46     { "fileprelude", "" },
47     { "profileenter",
48                 "ld a,#3\n"
49                 "\trst\t0x08"
50     },
51     { "profileexit",
52                 "ld a,#4\n"
53                 "\trst\t0x08"
54     },
55     { NULL, NULL }
56 };
57
58 static const ASM_MAPPING _asxxxx_z80_mapping[] = {
59     /* We want to prepend the _ */
60     { "area", ".area _%s" },
61     { "areacode", ".area _%s" },
62     { "areadata", ".area _%s" },
63     { "areahome", ".area _%s" },
64     { "*ixx", "%d (ix)" },
65     { "*iyx", "%d (iy)" },
66     { "*hl", "(hl)" },
67     { "di", "di" },
68     { "ei", "ei" },
69     { "ldahli", 
70                 "ld a,(hl)\n"
71                 "\tinc\thl" },
72     { "ldahlsp", 
73                 "ld hl,#%d\n"
74                 "\tadd\thl,sp" },
75     { "ldaspsp", 
76                 "ld hl,#%d\n"
77                 "\tadd\thl,sp\n"
78                 "\tld\tsp,hl" },
79     { "*pair", "(%s)" },
80     { "shortjp", "jp" },
81     { "enter", 
82                 "push\tix\n"
83                 "\tld\tix,#0\n"
84                 "\tadd\tix,sp" },
85     { "enterx", 
86                 "push\tix\n"
87                 "\tld\tix,#0\n"
88                 "\tadd\tix,sp\n"
89                 "\tld\thl,#-%d\n"
90                 "\tadd\thl,sp\n"
91                 "\tld\tsp,hl" 
92         },
93     { "leave", 
94                 "pop\tix"
95     },
96     { "leavex", 
97                 "ld sp,ix\n"
98                 "\tpop\tix"
99     },
100     { "pusha", 
101                 "push af\n"
102                 "\tpush\tbc\n"
103                 "\tpush\tde\n"
104                 "\tpush\thl\n"
105                 "\tpush\tiy"
106     },
107     { "popa",
108                 "pop iy\n"
109                 "\tpop\thl\n"
110                 "\tpop\tde\n"
111                 "\tpop\tbc\n"
112                 "\tpop\taf"
113     },
114     { "adjustsp", "lda sp,-%d(sp)" },
115     { "profileenter",
116                 "ld a,#3\n"
117                 "\trst\t0x08"
118     },
119     { "profileexit",
120                 "ld a,#4\n"
121                 "\trst\t0x08"
122     },
123     { NULL, NULL }
124 };
125
126 static const ASM_MAPPING _rgbds_mapping[] = {
127     { "global", "GLOBAL %s" },
128     { "extern", "GLOBAL %s" },
129     { "slabeldef", "%s:" },
130     { "labeldef", "%s:" },
131     { "tlabeldef", ".l%05d:" },
132     { "tlabel", ".l%05d" },
133     { "fileprelude", 
134       "; Generated using the rgbds tokens.\n"
135       "\t; We have to define these here as sdcc dosnt make them global by default\n"
136       "\tGLOBAL __mulschar\n"
137       "\tGLOBAL __muluchar\n"
138       "\tGLOBAL __mulint\n"
139       "\tGLOBAL __divschar\n"
140       "\tGLOBAL __divuchar\n"
141       "\tGLOBAL __divsint\n"
142       "\tGLOBAL __divuint\n"
143       "\tGLOBAL __modschar\n"
144       "\tGLOBAL __moduchar\n"
145       "\tGLOBAL __modsint\n"
146       "\tGLOBAL __moduint\n"
147       "\tGLOBAL __mullong\n"  
148       "\tGLOBAL __modslong\n"  
149       "\tGLOBAL __divslong\n"  
150       "\tGLOBAL banked_call\n"
151       "\tGLOBAL banked_ret\n"
152     },
153     { "functionheader", 
154       "; ---------------------------------\n"
155       "; Function %s\n"
156       "; ---------------------------------"
157     },
158     { "functionlabeldef", "%s:" },
159     { "zero", "$00" },
160     { "one", "$01" },
161     { "area", "SECTION \"%s\",CODE" },
162     { "areadata", "SECTION \"%F_%s\",BSS" },
163     { "areacode", "SECTION \"%F_CODE\",%s" }, 
164     { "areahome", "SECTION \"%F_HOME\",HOME" },
165     { "ascii", "DB \"%s\"" },
166     { "ds", "DS %d" },
167     { "db", "DB" },
168     { "dbs", "DB %s" },
169     { "dw", "DW" },
170     { "dws", "DW %s" },
171     { "immed", "" },
172     { "constbyte", "$%02X" },
173     { "constword", "$%04X" },
174     { "immedword", "$%04X" },
175     { "immedbyte", "$%02X" },
176     { "hashedstr", "%s" },
177     { "lsbimmeds", "%s & $FF" },
178     { "msbimmeds", "%s >> 8" },
179     { "bankimmeds", "BANK(%s)" },
180     { "module", "; MODULE %s" },
181     { NULL, NULL }
182 };
183
184 static const ASM_MAPPING _rgbds_gb_mapping[] = {
185     { "pusha", 
186       "push af\n"
187       "\tpush bc\n"
188       "\tpush de\n"
189       "\tpush hl"
190     },
191     { "popa", 
192       "pop hl\n"
193       "\tpop de\n"
194       "\tpop bc\n"
195       "\tpop af"
196     },
197     { "di", "di" },
198     { "ei", "ei" },
199     { "adjustsp", "add sp,-%d" },
200     { "enter", "" },
201     { "enterx", "add sp,-%d"
202     },
203     { "leave", ""
204     },
205     { "leavex", "add sp,%d"
206     },
207     { "ldahli", "ld a,[hl+]" },
208     { "*hl", "[hl]" },
209     { "ldahlsp", "ld hl,[sp+%d]" },
210     { "ldaspsp", "add sp,%d" },
211     { "*pair", "[%s]" },
212     { "shortjp", "jr" },
213     { NULL, NULL }
214 };
215
216 static const ASM_MAPPING _isas_mapping[] = {
217     { "global", "GLOBAL %s" },
218     { "extern", "GLOBAL %s" },
219     { "slabeldef", "%s:" },
220     { "labeldef", "%s:" },
221     { "tlabeldef", "?l%05d:" },
222     { "tlabel", "?l%05d" },
223     { "fileprelude", 
224       ";Generated using the isas tokens.\n"
225       "\tLPREFIX '?'  ; Treat labels starting with ? as local.\n"
226       "\tONCNUM       ; Numbers are hex\n"
227       "\tCAPSOFF      ; Case sensitive\n"
228       "\tISDMG        ; Gameboy mode\n"
229       "_CODE\tGROUP\n"
230       "\t; We have to define these here as sdcc doesnt make them global by default\n"
231       "\tGLOBAL __mulschar\n"
232       "\tGLOBAL __muluchar\n"
233       "\tGLOBAL __mulint\n"
234       "\tGLOBAL __divschar\n"
235       "\tGLOBAL __divuchar\n"
236       "\tGLOBAL __divsint\n"
237       "\tGLOBAL __divuint\n"
238       "\tGLOBAL __modschar\n"
239       "\tGLOBAL __moduchar\n"
240       "\tGLOBAL __modsint\n"
241       "\tGLOBAL __moduint\n"
242       "\tGLOBAL banked_call\n"
243       "\tGLOBAL banked_ret\n"
244     },
245     { "functionheader", 
246       "; ---------------------------------\n"
247       "; Function %s\n"
248       "; ---------------------------------"
249     },
250     { "functionlabeldef", "%s:" },
251     { "zero", "$00" },
252     { "one", "$01" },
253     { "area", "%s\tGROUP" },
254     { "areacode", "_CODE\tGROUP" },
255     { "areadata", "_DATA\tGROUP" },
256     { "areahome", "_CODE\tGROUP" },
257     { "ascii", "DB \"%s\"" },
258     { "ds", "DS %d" },
259     { "db", "DB" },
260     { "dbs", "DB %s" },
261     { "dw", "DW" },
262     { "dws", "DW %s" },
263     { "immed", "" },
264     { "constbyte", "0x%02X" },
265     { "constword", "0x%04X" },
266     { "immedword", "0x%04X" },
267     { "immedbyte", "0x%02X" },
268     { "hashedstr", "%s" },
269     { "lsbimmeds", "%s & 0xFF" },
270     { "msbimmeds", "%s >> 8" },
271     { "bankimmeds", "!%s" },
272     { "module", "; MODULE %s" },
273     { NULL, NULL }
274 };
275
276 static const ASM_MAPPING _isas_gb_mapping[] = {
277     { "pusha", 
278       "push af\n"
279       "\tpush bc\n"
280       "\tpush de\n"
281       "\tpush hl"
282     },
283     { "popa", 
284       "pop hl\n"
285       "\tpop de\n"
286       "\tpop bc\n"
287       "\tpop af"
288     },
289     { "di", "di" },
290     { "ei", "ei" },
291     { "adjustsp", "add sp,-%d" },
292     { "enter", "" },
293     { "enterx", "add sp,-%d"
294     },
295     { "leave", ""
296     },
297     { "leavex", "add sp,%d\n" },
298     { "ldahli", "ld a,(hli)" },
299     { "*hl", "(hl)" },
300     { "ldahlsp", "ldhl sp,%d" },
301     { "ldaspsp", "add sp,%d" },
302     { "*pair", "(%s)" },
303     { "shortjp", "jr" },
304     { NULL, NULL }
305 };
306
307 static const ASM_MAPPING _z80asm_mapping[] = {
308     { "global", "XDEF %s" },
309     { "extern", "XREF %s" },
310     { "slabeldef", "\n.%s" },
311     { "labeldef", "\n.%s" },
312     { "tlabeldef", "\n.l%N%05d" },
313     { "tlabel", "l%N%05d" },
314     { "fileprelude", 
315         "; Generated using the z80asm/z88 tokens.\n"
316         "\tXREF __muluchar_rrx_s\n"
317         "\tXREF __mulschar_rrx_s\n"
318         "\tXREF __mulint_rrx_s\n"
319         "\tXREF __mullong_rrx_s\n"
320         "\tXREF __divuchar_rrx_s\n"
321         "\tXREF __divschar_rrx_s\n"
322         "\tXREF __divsint_rrx_s\n"
323         "\tXREF __divuint_rrx_s\n"
324         "\tXREF __divulong_rrx_s\n"
325         "\tXREF __divslong_rrx_s\n"
326         "\tXREF __rrulong_rrx_s\n"
327         "\tXREF __rrslong_rrx_s\n"
328         "\tXREF __rlulong_rrx_s\n"
329         "\tXREF __rlslong_rrx_s\n"
330     },
331     { "functionheader", 
332       "; ---------------------------------\n"
333       "; Function %s\n"
334       "; ---------------------------------"
335     },
336     { "functionlabeldef", ".%s" },
337     { "zero", "$00" },
338     { "one", "$01" },
339     { "ascii", "DEFM \"%s\"" },
340     { "ds", "DEFS %d" },
341     { "db", "DEFB" },
342     { "dbs", "DEFB %s" },
343     { "dw", "DEFW" },
344     { "dws", "DEFB %s" },
345     { "immed", "" },
346     { "constbyte", "$%02X" },
347     { "constword", "$%04X" },
348     { "immedword", "$%04X" },
349     { "immedbyte", "$%02X" },
350     { "hashedstr", "%s" },
351     { "lsbimmeds", "%s & $FF" },
352     { "msbimmeds", "%s / 256" },
353
354     { "bankimmeds", "BANK(%s)" },
355     { "module", "MODULE %s" },
356     { "area", "; Area  %s" },
357     { "areadata", "; Aread BSS" },
358     { "areacode", "; Area CODE" }, 
359     { "areahome", "; Area HOME" },
360     { NULL, NULL }
361 };
362
363 static const ASM_MAPPING _z80asm_z80_mapping[] = {
364     { "*ixx", "(ix%+d)" },
365     { "*iyx", "(iy%+d)" },
366     { "*hl", "(hl)" },
367     { "di", "di" },
368     { "ei", "ei" },
369     { "ldahli", 
370                 "ld a,(hl)\n"
371                 "\tinc\thl" },
372     { "ldahlsp", 
373                 "ld hl,%d\n"
374                 "\tadd\thl,sp" },
375     { "ldaspsp", 
376                 "ld hl,%d\n"
377                 "\tadd\thl,sp\n"
378                 "\tld\tsp,hl" },
379     { "*pair", "(%s)" },
380     { "shortjp", "jp" },
381     { "enter", 
382                 "push\tix\n"
383                 "\tld\tix,0\n"
384                 "\tadd\tix,sp" },
385     { "enterx", 
386                 "push\tix\n"
387                 "\tld\tix,0\n"
388                 "\tadd\tix,sp\n"
389                 "\tld\thl,-%d\n"
390                 "\tadd\thl,sp\n"
391                 "\tld\tsp,hl" 
392         },
393     { "leave", 
394                 "pop\tix"
395     },
396     { "leavex", 
397                 "ld sp,ix\n"
398                 "\tpop\tix"
399     },
400     { "pusha", 
401                 "push af\n"
402                 "\tpush\tbc\n"
403                 "\tpush\tde\n"
404                 "\tpush\thl\n"
405                 "\tpush\tiy"
406     },
407     { "popa", 
408                 "pop\tiy\n"
409                 "\tpop\thl\n"
410                 "\tpop\tde\n"
411                 "\tpop\tbc\n"
412                 "\tpop\taf"
413     },
414     { "adjustsp", "lda sp,(sp%+d)" },
415     { "profileenter",
416                 "ld a,3\n"
417                 "\trst\t$08"
418     },
419     { "profileexit",
420                 "ld a,4\n"
421                 "\trst\t$08"
422     },
423     { NULL, NULL }
424 };
425
426 static const ASM_MAPPINGS _isas = {
427     NULL,
428     _isas_mapping
429 };
430
431 const ASM_MAPPINGS _isas_gb = {
432     &_isas,
433     _isas_gb_mapping
434 };
435
436 static const ASM_MAPPINGS _rgbds = {
437     NULL,
438     _rgbds_mapping
439 };
440
441 const ASM_MAPPINGS _rgbds_gb = {
442     &_rgbds,
443     _rgbds_gb_mapping
444 };
445
446 const ASM_MAPPINGS _asxxxx_gb = {
447     &asm_asxxxx_mapping,
448     _asxxxx_gb_mapping
449 };
450
451 const ASM_MAPPINGS _asxxxx_z80 = {
452     &asm_asxxxx_mapping,
453     _asxxxx_z80_mapping
454 };
455
456 static const ASM_MAPPINGS _z80asm = {
457     NULL,
458     _z80asm_mapping
459 };
460
461 const ASM_MAPPINGS _z80asm_z80 = {
462     &_z80asm,
463     _z80asm_z80_mapping
464 };