]> git.gag.com Git - fw/sdcc/blob - src/z80/mappings.i
53c593385fbc7f578fb74f3d5f5766da2036b23b
[fw/sdcc] / 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     { "functionlabeldef", "%s:" },
7     { "*hl", "(hl)" },
8     { "di", "di" },
9     { "ldahli", "ld a,(hl+)" },
10     { "ldahlsp", "lda hl,%d(sp)" },
11     { "ldaspsp", "lda sp,%d(sp)" },
12     { "*pair", "(%s)" },
13     { "shortjp", "jr" },
14     { "enter", "push bc" },
15     { "enterx", 
16       "push bc\n"
17       "\tlda sp,-%d(sp)" },
18     { "leave", 
19       "pop bc\n"
20       "\tret"
21     },
22     { "leavex", 
23       "lda sp,%d(sp)\n"
24       "\tpop bc\n"
25       "\tret"
26     },
27     { "pusha", 
28       "push af\n"
29       "\tpush bc\n"
30       "\tpush de\n"
31       "\tpush hl"
32     },
33     { "adjustsp", "lda sp,-%d(sp)" },
34     { NULL, NULL }
35 };
36
37 static const ASM_MAPPING _asxxxx_z80_mapping[] = {
38     { "*ixx", "%d(ix)" },
39     { "*iyx", "%d(iy)" },
40     { "*hl", "(hl)" },
41     { "di", "di" },
42     { "ldahli", "ld a,(hl+)" },
43     { "ldahlsp", "lda hl,%d(sp)" },
44     { "ldaspsp", "lda sp,%d(sp)" },
45     { "*pair", "(%s)" },
46     { "shortjp", "jr" },
47     { "enter", "push bc" },
48     { "enterx", 
49       "push bc\n"
50       "lda sp,-%d(sp)" },
51     { "leave", 
52       "pop bc\n"
53       "\tret"
54     },
55     { "leavex", 
56       "lda sp,%d(sp)\n"
57       "\tpop bc\n"
58       "\tret"
59     },
60     { "pusha", 
61       "push af\n"
62       "\tpush bc\n"
63       "\tpush de\n"
64       "\tpush hl"
65     },
66     { "adjustsp", "lda sp,-%d(sp)" },
67     { NULL, NULL }
68 };
69
70 static const ASM_MAPPING _rgbds_mapping[] = {
71     { "global", "GLOBAL %s" },
72     { "slabeldef", "%s:" },
73     { "labeldef", "%s:" },
74     { "tlabeldef", ".l%05d:" },
75     { "tlabel", ".l%05d" },
76     { "fileprelude", 
77       "; Generated using the rgbds tokens.\n"
78       "\t; We have to define these here as sdcc dosnt make them global by default\n"
79       "\tGLOBAL __mulschar\n"
80       "\tGLOBAL __muluchar\n"
81       "\tGLOBAL __mulsint\n"
82       "\tGLOBAL __muluint\n"
83       "\tGLOBAL __divschar\n"
84       "\tGLOBAL __divuchar\n"
85       "\tGLOBAL __divsint\n"
86       "\tGLOBAL __divuint\n"
87       "\tGLOBAL __modschar\n"
88       "\tGLOBAL __moduchar\n"
89       "\tGLOBAL __modsint\n"
90       "\tGLOBAL __moduint"
91     },
92     { "functionheader", 
93       "; ---------------------------------\n"
94       "; Function %s\n"
95       "; ---------------------------------"
96     },
97     { "functionlabeldef", "%s:" },
98     { "zero", "$00" },
99     { "one", "$01" },
100     { "area", "SECTION \"%s\",%C" },
101     { "areacode", "SECTION \"CODE\",%C" },
102     { "areadata", "SECTION \"DATA\",BSS" },
103     { "ascii", "DB \"%s\"" },
104     { "ds", "DS %d" },
105     { "db", "DB %d" },
106     { "dbs", "DB %s" },
107     { "dw", "DW %d" },
108     { "dws", "DW %s" },
109     { "immed", "" },
110     { "constbyte", "$%02X" },
111     { "constword", "$%04X" },
112     { "immedword", "$%04X" },
113     { "immedbyte", "$%02X" },
114     { "hashedstr", "%s" },
115     { "lsbimmeds", "%s & $FF" },
116     { "msbimmeds", "%s >> 8" },
117     { "module", "; MODULE %s" },
118     { NULL, NULL }
119 };
120
121 static const ASM_MAPPING _rgbds_gb_mapping[] = {
122     { "pusha", 
123       "push af\n"
124       "\tpush bc\n"
125       "\tpush de\n"
126       "\tpush hl"
127     },
128     { "di", "di" },
129     { "adjustsp", "add sp,-%d" },
130     { "enter", "push bc" },
131     { "enterx", 
132       "push bc\n"
133       "\tadd sp,-%d"
134     },
135     { "leave", 
136       "pop bc\n"
137       "\tret"
138     },
139     { "leavex", 
140       "add sp,%d\n"
141       "\tpop bc\n"
142       "\tret"
143     },
144     { "ldahli", "ld a,[hl+]" },
145     { "*hl", "[hl]" },
146     { "ldahlsp", "ld hl,[sp+%d]" },
147     { "ldaspsp", "add sp,%d" },
148     { "*pair", "[%s]" },
149     { "shortjp", "jr" },
150     { NULL, NULL }
151 };
152
153 static const ASM_MAPPING _isas_mapping[] = {
154     { "global", "GLOBAL %s" },
155     { "slabeldef", "%s:" },
156     { "labeldef", "%s:" },
157     { "tlabeldef", "?l%05d:" },
158     { "tlabel", "?l%05d" },
159     { "fileprelude", 
160       ";Generated using the isas tokens.\n"
161       "\tLPREFIX '?'  ; Treat labels starting with ? as local.\n"
162       "\tONCNUM       ; Numbers are hex\n"
163       "\tCAPSOFF      ; Case sensitive\n"
164       "\tISDMG        ; Gameboy mode\n"
165       "_CODE\tGROUP\n"
166       "\t; We have to define these here as sdcc dosnt make them global by default\n"
167       "\tGLOBAL __mulschar\n"
168       "\tGLOBAL __muluchar\n"
169       "\tGLOBAL __mulsint\n"
170       "\tGLOBAL __muluint\n"
171       "\tGLOBAL __divschar\n"
172       "\tGLOBAL __divuchar\n"
173       "\tGLOBAL __divsint\n"
174       "\tGLOBAL __divuint\n"
175       "\tGLOBAL __modschar\n"
176       "\tGLOBAL __moduchar\n"
177       "\tGLOBAL __modsint\n"
178       "\tGLOBAL __moduint"
179     },
180     { "functionheader", 
181       "; ---------------------------------\n"
182       "; Function %s\n"
183       "; ---------------------------------"
184     },
185     { "functionlabeldef", "%s:" },
186     { "zero", "$00" },
187     { "one", "$01" },
188     { "area", "%s\tGROUP" },
189     { "areacode", "_CODE\tGROUP" },
190     { "areadata", "_DATA\tGROUP" },
191     { "ascii", "DB \"%s\"" },
192     { "ds", "DS %d" },
193     { "db", "DB %d" },
194     { "dbs", "DB %s" },
195     { "dw", "DW %d" },
196     { "dws", "DW %s" },
197     { "immed", "" },
198     { "constbyte", "0x%02X" },
199     { "constword", "0x%04X" },
200     { "immedword", "0x%04X" },
201     { "immedbyte", "0x%02X" },
202     { "hashedstr", "%s" },
203     { "lsbimmeds", "%s & 0xFF" },
204     { "msbimmeds", "%s >> 8" },
205     { "module", "; MODULE %s" },
206     { NULL, NULL }
207 };
208
209 static const ASM_MAPPING _isas_gb_mapping[] = {
210     { "pusha", 
211       "push af\n"
212       "\tpush bc\n"
213       "\tpush de\n"
214       "\tpush hl"
215     },
216     { "di", "di" },
217     { "adjustsp", "add sp,-%d" },
218     { "enter", "push bc" },
219     { "enterx", 
220       "push bc\n"
221       "\tadd sp,-%d"
222     },
223     { "leave", 
224       "pop bc\n"
225       "\tret"
226     },
227     { "leavex", 
228       "add sp,%d\n"
229       "\tpop bc\n"
230       "\tret"
231     },
232     { "ldahli", "ld a,(hli)" },
233     { "*hl", "(hl)" },
234     { "ldahlsp", "ldhl sp,%d" },
235     { "ldaspsp", "add sp,%d" },
236     { "*pair", "(%s)" },
237     { "shortjp", "jr" },
238     { NULL, NULL }
239 };
240
241 static const ASM_MAPPINGS _isas = {
242     NULL,
243     _isas_mapping
244 };
245
246 const ASM_MAPPINGS _isas_gb = {
247     &_isas,
248     _isas_gb_mapping
249 };
250
251 static const ASM_MAPPINGS _rgbds = {
252     NULL,
253     _rgbds_mapping
254 };
255
256 const ASM_MAPPINGS _rgbds_gb = {
257     &_rgbds,
258     _rgbds_gb_mapping
259 };
260
261 const ASM_MAPPINGS _asxxxx_gb = {
262     &asm_asxxxx_mapping,
263     _asxxxx_gb_mapping
264 };
265
266 const ASM_MAPPINGS _asxxxx_z80 = {
267     &asm_asxxxx_mapping,
268     _asxxxx_z80_mapping
269 };