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