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