* Fixed up multi bank support
[fw/sdcc] / src / z80 / mappings.i
1 static const ASM_MAPPING _asxxxx_gb_mapping[] = {
2     { "*hl", "(hl)" },
3     { "di", "di" },
4     { "ldahli", "ld a,(hl+)" },
5     { "ldahlsp", "lda hl,%d(sp)" },
6     { "ldaspsp", "lda sp,%d(sp)" },
7     { "*pair", "(%s)" },
8     { "shortjp", "jr" },
9     { "enter", "push bc" },
10     { "enterx", 
11       "push bc\n"
12       "\tlda sp,-%d(sp)" },
13     { "leave", 
14       "pop bc\n"
15       "\tret"
16     },
17     { "leavex", 
18       "lda sp,%d(sp)\n"
19       "\tpop bc\n"
20       "\tret"
21     },
22     { "pusha", 
23       "push af\n"
24       "\tpush bc\n"
25       "\tpush de\n"
26       "\tpush hl"
27     },
28     { "adjustsp", "lda sp,-%d(sp)" },
29     { NULL, NULL }
30 };
31
32 static const ASM_MAPPING _asxxxx_z80_mapping[] = {
33     { "*hl", "(hl)" },
34     { "di", "di" },
35     { "ldahli", "ld a,(hl+)" },
36     { "ldahlsp", "lda hl,%d(sp)" },
37     { "ldaspsp", "lda sp,%d(sp)" },
38     { "*pair", "(%s)" },
39     { "shortjp", "jr" },
40     { "enter", "push bc" },
41     { "enterx", 
42       "push bc\n"
43       "lda sp,-%d(sp)" },
44     { "leave", 
45       "pop bc\n"
46       "\tret"
47     },
48     { "leavex", 
49       "lda sp,%d(sp)\n"
50       "\tpop bc\n"
51       "\tret"
52     },
53     { "pusha", 
54       "push af\n"
55       "\tpush bc\n"
56       "\tpush de\n"
57       "\tpush hl"
58     },
59     { "adjustsp", "lda sp,-%d(sp)" },
60     { NULL, NULL }
61 };
62
63 static const ASM_MAPPING _rgbds_mapping[] = {
64     { "global", "GLOBAL %s" },
65     { "labeldef", "%s:" },
66     { "tlabeldef", ".l%05d:" },
67     { "tlabel", ".l%05d" },
68     { "fileprelude", 
69       "; Generated using the rgbds tokens.\n"
70       "\t; We have to define these here as sdcc dosnt make them global by default\n"
71       "\tGLOBAL __mulschar\n"
72       "\tGLOBAL __muluchar\n"
73       "\tGLOBAL __mulsint\n"
74       "\tGLOBAL __muluint\n"
75       "\tGLOBAL __divschar\n"
76       "\tGLOBAL __divuchar\n"
77       "\tGLOBAL __divsint\n"
78       "\tGLOBAL __divuint\n"
79       "\tGLOBAL __modschar\n"
80       "\tGLOBAL __moduchar\n"
81       "\tGLOBAL __modsint\n"
82       "\tGLOBAL __moduint"
83     },
84     { "functionheader", 
85       "; ---------------------------------\n"
86       "; Function %s\n"
87       "; ---------------------------------"
88     },
89     { "functionlabeldef", "%s:" },
90     { "zero", "$00" },
91     { "one", "$01" },
92     { "area", "SECTION \"%s\",CODE" },
93     { "areacode", "SECTION \"CODE\",CODE" },
94     { "areadata", "SECTION \"DATA\",BSS" },
95     { "ascii", "DB \"%s\"" },
96     { "ds", "DS %d" },
97     { "db", "DB %d" },
98     { "dbs", "DB %s" },
99     { "dw", "DW %d" },
100     { "dws", "DW %s" },
101     { "immed", "" },
102     { "constbyte", "$%02X" },
103     { "constword", "$%04X" },
104     { "immedword", "$%04X" },
105     { "immedbyte", "$%02X" },
106     { "hashedstr", "%s" },
107     { "lsbimmeds", "%s & $FF" },
108     { "msbimmeds", "%s >> 8" },
109     { "module", "; MODULE %s" },
110     { NULL, NULL }
111 };
112
113 static const ASM_MAPPING _rgbds_gb_mapping[] = {
114     { "pusha", 
115       "push af\n"
116       "\tpush bc\n"
117       "\tpush de\n"
118       "\tpush hl"
119     },
120     { "di", "di" },
121     { "adjustsp", "add sp,-%d" },
122     { "enter", "push bc" },
123     { "enterx", 
124       "push bc\n"
125       "\tadd sp,-%d"
126     },
127     { "leave", 
128       "pop bc\n"
129       "\tret"
130     },
131     { "leavex", 
132       "add sp,%d\n"
133       "\tpop bc\n"
134       "\tret"
135     },
136     { "ldahli", "ld a,[hl+]" },
137     { "*hl", "[hl]" },
138     { "ldahlsp", "ld hl,[sp+%d]" },
139     { "ldaspsp", "add sp,%d" },
140     { "*pair", "[%s]" },
141     { "shortjp", "jr" },
142     { NULL, NULL }
143 };
144
145 static const ASM_MAPPINGS _rgbds = {
146     NULL,
147     _rgbds_mapping
148 };
149
150 const ASM_MAPPINGS _rgbds_gb = {
151     &_rgbds,
152     _rgbds_gb_mapping
153 };
154
155 const ASM_MAPPINGS _asxxxx_gb = {
156     &asm_asxxxx_mapping,
157     _asxxxx_gb_mapping
158 };
159
160 const ASM_MAPPINGS _asxxxx_z80 = {
161     &asm_asxxxx_mapping,
162     _asxxxx_z80_mapping
163 };