Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / sdas / asstm8 / stm8pst.c
blob6ffec9b34ffb9285a61c5bc46489a7517823b8d7
1 /* stm8pst.c */
3 /*
4 * Copyright (C) 1010 Alan R. Baldwin
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Alan R. Baldwin
21 * 721 Berkeley St.
22 * Kent, Ohio 44240
26 #include "asxxxx.h"
27 #include "stm8.h"
29 #if 0
31 * Coding Banks
33 struct bank bank[2] = {
34 /* The '_CODE' area/bank has a NULL default file suffix. */
35 { NULL, "_CSEG", NULL, 0, 0, 0, 0, 0 },
36 { &bank[0], "_DSEG", "_DS", 1, 0, 0, 0, B_FSFX }
40 * Coding Areas
42 struct area area[2] = {
43 { NULL, &bank[0], "_CODE", 0, 0, 0, A_1BYTE|A_BNK|A_CSEG },
44 { &area[0], &bank[1], "_DATA", 1, 0, 0, A_1BYTE|A_BNK|A_DSEG }
46 #endif
49 * Basic Relocation Mode Definition
51 * #define R_NORM 0000 No Bit Positioning
53 char mode0[32] = { /* R_NORM */
54 '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
55 '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
56 '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
57 '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237'
61 * Additional Relocation Mode Definitions
65 * Bit Relocation Mode Definition
67 * #define R_BITS 0100 Bit Test Positioning
69 char mode1[32] = { /* R_BITS */
70 '\201', '\202', '\203', '\003', '\004', '\005', '\006', '\007',
71 '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
72 '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
73 '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037'
78 * *m_def is a pointer to the bit relocation definition.
79 * m_flag indicates that bit position swapping is required.
80 * m_dbits contains the active bit positions for the output.
81 * m_sbits contains the active bit positions for the input.
83 * struct mode
84 * {
85 * char * m_def; Bit Relocation Definition
86 * a_uint m_flag; Bit Swapping Flag
87 * a_uint m_dbits; Destination Bit Mask
88 * a_uint m_sbits; Source Bit Mask
89 * };
91 struct mode mode[2] = {
92 { &mode0[0], 0, 0x0000FFFF, 0x0000FFFF },
93 { &mode1[0], 1, 0x0000000E, 0x00000007 }
98 * Array of Pointers to mode Structures
100 struct mode *modep[16] = {
101 &mode[0], &mode[1], NULL, NULL,
102 NULL, NULL, NULL, NULL,
103 NULL, NULL, NULL, NULL,
104 NULL, NULL, NULL, NULL
108 * Mnemonic Structure
110 struct mne mne[] = {
112 /* machine */
114 //{ NULL, "CSEG", S_ATYP, 0, A_CSEG|A_1BYTE },
115 //{ NULL, "DSEG", S_ATYP, 0, A_DSEG|A_1BYTE },
117 /* system */
119 //{ NULL, "BANK", S_ATYP, 0, A_BNK },
120 { NULL, "CON", S_ATYP, 0, A_CON },
121 { NULL, "OVR", S_ATYP, 0, A_OVR },
122 { NULL, "REL", S_ATYP, 0, A_REL },
123 { NULL, "ABS", S_ATYP, 0, A_ABS },
124 { NULL, "NOPAG", S_ATYP, 0, A_NOPAG },
125 { NULL, "PAG", S_ATYP, 0, A_PAG },
127 #if 0 /* ljm -- figure out what S_BTYP (bank type?) is */
128 { NULL, "BASE", S_BTYP, 0, B_BASE },
129 { NULL, "SIZE", S_BTYP, 0, B_SIZE },
130 { NULL, "FSFX", S_BTYP, 0, B_FSFX },
131 { NULL, "MAP", S_BTYP, 0, B_MAP },
132 #endif
133 { NULL, "NOLOAD", S_ATYP, 0, A_NOLOAD},
134 { NULL, ".page", S_PAGE, 0, 0 },
135 { NULL, ".title", S_HEADER, 0, O_TITLE },
136 { NULL, ".sbttl", S_HEADER, 0, O_SBTTL },
137 { NULL, ".module", S_MODUL, 0, 0 },
138 { NULL, ".include", S_INCL, 0, I_CODE },
139 { NULL, ".incbin", S_INCL, 0, I_BNRY },
140 { NULL, ".area", S_AREA, 0, 0 },
141 //{ NULL, ".bank", S_BANK, 0, 0 },
142 { NULL, ".org", S_ORG, 0, 0 },
143 { NULL, ".radix", S_RADIX, 0, 0 },
144 { NULL, ".globl", S_GLOBL, 0, 0 },
145 { NULL, ".local", S_LOCAL, 0, 0 },
146 { NULL, ".if", S_CONDITIONAL, 0, O_IF },
147 { NULL, ".iff", S_CONDITIONAL, 0, O_IFF },
148 { NULL, ".ift", S_CONDITIONAL, 0, O_IFT },
149 { NULL, ".iftf", S_CONDITIONAL, 0, O_IFTF },
150 { NULL, ".ifdef", S_CONDITIONAL, 0, O_IFDEF },
151 { NULL, ".ifndef", S_CONDITIONAL, 0, O_IFNDEF},
152 { NULL, ".ifgt", S_CONDITIONAL, 0, O_IFGT },
153 { NULL, ".iflt", S_CONDITIONAL, 0, O_IFLT },
154 { NULL, ".ifge", S_CONDITIONAL, 0, O_IFGE },
155 { NULL, ".ifle", S_CONDITIONAL, 0, O_IFLE },
156 { NULL, ".ifeq", S_CONDITIONAL, 0, O_IFEQ },
157 { NULL, ".ifne", S_CONDITIONAL, 0, O_IFNE },
158 { NULL, ".ifb", S_CONDITIONAL, 0, O_IFB },
159 { NULL, ".ifnb", S_CONDITIONAL, 0, O_IFNB },
160 { NULL, ".ifidn", S_CONDITIONAL, 0, O_IFIDN },
161 { NULL, ".ifdif", S_CONDITIONAL, 0, O_IFDIF },
162 { NULL, ".iif", S_CONDITIONAL, 0, O_IIF },
163 { NULL, ".iiff", S_CONDITIONAL, 0, O_IIFF },
164 { NULL, ".iift", S_CONDITIONAL, 0, O_IIFT },
165 { NULL, ".iiftf", S_CONDITIONAL, 0, O_IIFTF },
166 { NULL, ".iifdef", S_CONDITIONAL, 0, O_IIFDEF},
167 { NULL, ".iifndef", S_CONDITIONAL, 0, O_IIFNDEF},
168 { NULL, ".iifgt", S_CONDITIONAL, 0, O_IIFGT },
169 { NULL, ".iiflt", S_CONDITIONAL, 0, O_IIFLT },
170 { NULL, ".iifge", S_CONDITIONAL, 0, O_IIFGE },
171 { NULL, ".iifle", S_CONDITIONAL, 0, O_IIFLE },
172 { NULL, ".iifeq", S_CONDITIONAL, 0, O_IIFEQ },
173 { NULL, ".iifne", S_CONDITIONAL, 0, O_IIFNE },
174 { NULL, ".iifb", S_CONDITIONAL, 0, O_IIFB },
175 { NULL, ".iifnb", S_CONDITIONAL, 0, O_IIFNB },
176 { NULL, ".iifidn", S_CONDITIONAL, 0, O_IIFIDN},
177 { NULL, ".iifdif", S_CONDITIONAL, 0, O_IIFDIF},
178 { NULL, ".else", S_CONDITIONAL, 0, O_ELSE },
179 { NULL, ".endif", S_CONDITIONAL, 0, O_ENDIF },
180 { NULL, ".list", S_LISTING, 0, O_LIST },
181 { NULL, ".nlist", S_LISTING, 0, O_NLIST },
182 { NULL, ".uleb128", S_ULEB128, 0, 0 },
183 { NULL, ".sleb128", S_SLEB128, 0, 0 },
184 { NULL, ".equ", S_EQU, 0, O_EQU },
185 { NULL, ".gblequ", S_EQU, 0, O_GBLEQU},
186 { NULL, ".lclequ", S_EQU, 0, O_LCLEQU},
187 { NULL, ".byte", S_DATA, 0, O_1BYTE },
188 { NULL, ".db", S_DATA, 0, O_1BYTE },
189 { NULL, ".fcb", S_DATA, 0, O_1BYTE },
190 { NULL, ".word", S_DATA, 0, O_2BYTE },
191 { NULL, ".dw", S_DATA, 0, O_2BYTE },
192 { NULL, ".fdb", S_DATA, 0, O_2BYTE },
193 { NULL, ".3byte", S_DATA, 0, O_3BYTE },
194 { NULL, ".triple", S_DATA, 0, O_3BYTE },
195 /* { NULL, ".4byte", S_DATA, 0, O_4BYTE }, */
196 /* { NULL, ".quad", S_DATA, 0, O_4BYTE }, */
197 { NULL, ".blkb", S_BLK, 0, O_1BYTE },
198 { NULL, ".ds", S_BLK, 0, O_1BYTE },
199 { NULL, ".rmb", S_BLK, 0, O_1BYTE },
200 { NULL, ".rs", S_BLK, 0, O_1BYTE },
201 { NULL, ".blkw", S_BLK, 0, O_2BYTE },
202 { NULL, ".blk3", S_BLK, 0, O_3BYTE },
203 /* { NULL, ".blk4", S_BLK, 0, O_4BYTE }, */
204 { NULL, ".ascii", S_ASCIX, 0, O_ASCII },
205 { NULL, ".ascis", S_ASCIX, 0, O_ASCIS },
206 { NULL, ".asciz", S_ASCIX, 0, O_ASCIZ },
207 { NULL, ".str", S_ASCIX, 0, O_ASCII },
208 { NULL, ".strs", S_ASCIX, 0, O_ASCIS },
209 { NULL, ".strz", S_ASCIX, 0, O_ASCIZ },
210 { NULL, ".fcc", S_ASCIX, 0, O_ASCII },
211 { NULL, ".define", S_DEFINE, 0, O_DEF },
212 { NULL, ".undefine", S_DEFINE, 0, O_UNDEF },
213 { NULL, ".even", S_BOUNDARY, 0, O_EVEN },
214 { NULL, ".odd", S_BOUNDARY, 0, O_ODD },
215 { NULL, ".bndry", S_BOUNDARY, 0, O_BNDRY },
216 { NULL, ".msg" , S_MSG, 0, 0 },
217 { NULL, ".assume", S_ERROR, 0, O_ASSUME},
218 { NULL, ".error", S_ERROR, 0, O_ERROR },
219 //{ NULL, ".msb", S_MSB, 0, 0 },
220 /* { NULL, ".lohi", S_MSB, 0, O_LOHI }, */
221 /* { NULL, ".hilo", S_MSB, 0, O_HILO }, */
222 /* { NULL, ".8bit", S_BITS, 0, O_1BYTE }, */
223 /* { NULL, ".16bit", S_BITS, 0, O_2BYTE }, */
224 /* { NULL, ".24bit", S_BITS, 0, O_3BYTE }, */
225 /* { NULL, ".32bit", S_BITS, 0, O_4BYTE }, */
226 { NULL, ".end", S_END, 0, 0 },
227 /* sdas specific */
228 { NULL, ".optsdcc", S_OPTSDCC, 0, 0 },
229 /* end sdas specific */
231 /* Macro Processor */
233 { NULL, ".macro", S_MACRO, 0, O_MACRO },
234 { NULL, ".endm", S_MACRO, 0, O_ENDM },
235 { NULL, ".mexit", S_MACRO, 0, O_MEXIT },
237 { NULL, ".narg", S_MACRO, 0, O_NARG },
238 { NULL, ".nchr", S_MACRO, 0, O_NCHR },
239 { NULL, ".ntyp", S_MACRO, 0, O_NTYP },
241 { NULL, ".irp", S_MACRO, 0, O_IRP },
242 { NULL, ".irpc", S_MACRO, 0, O_IRPC },
243 { NULL, ".rept", S_MACRO, 0, O_REPT },
245 { NULL, ".nval", S_MACRO, 0, O_NVAL },
247 { NULL, ".mdelete", S_MACRO, 0, O_MDEL },
249 /* stm8 Instructions */
251 { NULL, "jra", S_JR, 0, 0x20 },
252 { NULL, "jreq", S_JR, 0, 0x27 },
253 { NULL, "jrf", S_JR, 0, 0x21 },
254 { NULL, "jrc", S_JR, 0, 0x25 },
255 { NULL, "jrmi", S_JR, 0, 0x2B },
256 { NULL, "jrnc", S_JR, 0, 0x24 },
257 { NULL, "jrne", S_JR, 0, 0x26 },
258 { NULL, "jrnv", S_JR, 0, 0x28 },
259 { NULL, "jrpl", S_JR, 0, 0x2A },
260 { NULL, "jrsge", S_JR, 0, 0x2E },
261 { NULL, "jrsgt", S_JR, 0, 0x2C },
262 { NULL, "jrsle", S_JR, 0, 0x2D },
263 { NULL, "jrslt", S_JR, 0, 0x2F },
264 { NULL, "jrt", S_JR, 0, 0x20 },
265 { NULL, "jruge", S_JR, 0, 0x24 },
266 { NULL, "jrugt", S_JR, 0, 0x22 },
267 { NULL, "jrule", S_JR, 0, 0x23 },
268 { NULL, "jrult", S_JR, 0, 0x25 },
269 { NULL, "jrv", S_JR, 0, 0x29 },
271 { NULL, "jrnh", S_JRPG, 0, 0x28 },
272 { NULL, "jrh", S_JRPG, 0, 0x29 },
273 { NULL, "jrnm", S_JRPG, 0, 0x2C },
274 { NULL, "jrm", S_JRPG, 0, 0x2D },
275 { NULL, "jril", S_JRPG, 0, 0x2E },
276 { NULL, "jrih", S_JRPG, 0, 0x2F },
278 { NULL, "btjt", S_JRBT, 0, 0x00 },
279 { NULL, "btjf", S_JRBT, 0, 0x01 },
281 { NULL, "bccm", S_BT90, 0, 0x11 },
282 { NULL, "bcpl", S_BT90, 0, 0x10 },
283 { NULL, "bres", S_BT72, 0, 0x11 },
284 { NULL, "bset", S_BT72, 0, 0x10 },
286 { NULL, "ld", S_LD, 0, 0x06 },
287 { NULL, "ldf", S_LDF, 0, 0x0C },
288 { NULL, "ldw", S_LDW, 0, 0x0E },
290 { NULL, "mov", S_MOV, 0, 0x05 },
292 { NULL, "adc", S_AOP, 0, 0x09 },
293 { NULL, "add", S_AOP, 0, 0x0B },
294 { NULL, "and", S_AOP, 0, 0x04 },
295 { NULL, "bcp", S_AOP, 0, 0x05 },
296 { NULL, "cp", S_AOP, 0, 0x01 },
297 { NULL, "or", S_AOP, 0, 0x0A },
298 { NULL, "sub", S_AOP, 0, 0x00 },
299 { NULL, "sbc", S_AOP, 0, 0x02 },
300 { NULL, "xor", S_AOP, 0, 0x08 },
302 { NULL, "addw", S_ADDW, 0, 0x0C },
303 { NULL, "subw", S_SUBW, 0, 0x0D },
305 { NULL, "cpw", S_CPW, 0, 0x03 },
307 { NULL, "clr", S_BOP, 0, 0x0F },
308 { NULL, "cpl", S_BOP, 0, 0x03 },
309 { NULL, "dec", S_BOP, 0, 0x0A },
310 { NULL, "inc", S_BOP, 0, 0x0C },
311 { NULL, "neg", S_BOP, 0, 0x00 },
312 { NULL, "rlc", S_BOP, 0, 0x09 },
313 { NULL, "rrc", S_BOP, 0, 0x06 },
314 { NULL, "sla", S_BOP, 0, 0x08 },
315 { NULL, "sll", S_BOP, 0, 0x08 },
316 { NULL, "sra", S_BOP, 0, 0x07 },
317 { NULL, "srl", S_BOP, 0, 0x04 },
318 { NULL, "tnz", S_BOP, 0, 0x0D },
319 { NULL, "swap", S_BOP, 0, 0x0E },
321 { NULL, "clrw", S_WOP, 0, 0x5F },
322 { NULL, "cplw", S_WOP, 0, 0x53 },
323 { NULL, "decw", S_WOP, 0, 0x5A },
324 { NULL, "incw", S_WOP, 0, 0x5C },
325 { NULL, "negw", S_WOP, 0, 0x50 },
326 { NULL, "rlcw", S_WOP, 0, 0x59 },
327 { NULL, "rrcw", S_WOP, 0, 0x56 },
328 { NULL, "slaw", S_WOP, 0, 0x58 },
329 { NULL, "sllw", S_WOP, 0, 0x58 },
330 { NULL, "sraw", S_WOP, 0, 0x57 },
331 { NULL, "srlw", S_WOP, 0, 0x54 },
332 { NULL, "tnzw", S_WOP, 0, 0x5D },
333 { NULL, "swapw", S_WOP, 0, 0x5E },
335 { NULL, "mul", S_MLDV, 0, 0x42 },
336 { NULL, "div", S_MLDV, 0, 0x62 },
337 { NULL, "divw", S_DIVW, 0, 0x65 },
339 { NULL, "rlwa", S_RWA, 0, 0x02 },
340 { NULL, "rrwa", S_RWA, 0, 0x01 },
342 { NULL, "exg", S_EXG, 0, 0x01 },
343 { NULL, "exgw", S_EXGW, 0, 0x51 },
345 { NULL, "pop", S_POP, 0, 0x32 },
346 { NULL, "push", S_PUSH, 0, 0x3B },
348 { NULL, "popw", S_PW, 0, 0x85 },
349 { NULL, "pushw", S_PW, 0, 0x89 },
351 { NULL, "call", S_CLJP, 0, 0x0D },
352 { NULL, "callf", S_CLJPF, 0, 0x8D },
353 { NULL, "callr", S_CALLR, 0, 0xAD },
354 { NULL, "jp", S_CLJP, 0, 0x0C },
355 { NULL, "jpf", S_CLJPF, 0, 0xAC },
357 { NULL, "break", S_INH, 0, 0x8B },
358 { NULL, "ccf", S_INH, 0, 0x8C },
359 { NULL, "halt", S_INH, 0, 0x8E },
360 { NULL, "int", S_INT, 0, 0x0C },
361 { NULL, "iret", S_INH, 0, 0x80 },
362 { NULL, "nop", S_INH, 0, 0x9D },
363 { NULL, "rcf", S_INH, 0, 0x98 },
364 { NULL, "ret", S_INH, 0, 0x81 },
365 { NULL, "retf", S_INH, 0, 0x87 },
366 { NULL, "rim", S_INH, 0, 0x9A },
367 { NULL, "rvf", S_INH, 0, 0x9C },
368 { NULL, "scf", S_INH, 0, 0x99 },
369 { NULL, "sim", S_INH, 0, 0x9B },
370 { NULL, "trap", S_INH, 0, 0x83 },
371 { NULL, "wfi", S_INH, 0, 0x8F },
373 { NULL, "wfe", S_INH72, S_EOL, 0x8F }