struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / sdas / as8xcxxx / ds8pst.c
blobb32b11a05cd8bff74a7da3e770d2f837ab19296a
1 /* ds8pst.c */
3 /*
4 * Copyright (C) 1998-2009 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
24 * This Assembler Ported by
25 * jhartman at compuserve dot com
26 * noice at noicedebugger dot com
28 * Modified from i51pst.c
29 * Bill McKinnon
30 * w_mckinnon at conknet dot com
34 #include "asxxxx.h"
35 #include "ds8.h"
38 * Basic Relocation Mode Definition
40 * #define R_NORM 0000 No Bit Positioning
42 char mode0[32] = { /* R_NORM */
43 '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
44 '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
45 '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
46 '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237'
50 * Additional Relocation Mode Definitions
52 * Specification for the 11-bit addressing mode:
54 char mode1[32] = { /* R_J11 */
55 '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
56 '\215', '\216', '\217', '\013', '\014', '\015', '\016', '\017',
57 '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
58 '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037'
62 * Specification for the 19-bit addressing mode:
64 char mode2[32] = { /* R_J19 */
65 '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
66 '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
67 '\225', '\226', '\227', '\023', '\024', '\025', '\026', '\027',
68 '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037'
72 * *m_def is a pointer to the bit relocation definition.
73 * m_flag indicates that bit position swapping is required.
74 * m_dbits contains the active bit positions for the output.
75 * m_sbits contains the active bit positions for the input.
77 * struct mode
78 * {
79 * char * m_def; Bit Relocation Definition
80 * a_uint m_flag; Bit Swapping Flag
81 * a_uint m_dbits; Destination Bit Mask
82 * a_uint m_sbits; Source Bit Mask
83 * };
85 #ifdef LONGINT
86 struct mode mode[3] = {
87 { &mode0[0], 0, 0x0000FFFFl, 0x0000FFFFl },
88 { &mode1[0], 1, 0x0000E0FFl, 0x000007FFl },
89 { &mode2[0], 1, 0x00E0FFFFl, 0x0007FFFFl }
91 #else
92 struct mode mode[3] = {
93 { &mode0[0], 0, 0x0000FFFF, 0x0000FFFF },
94 { &mode1[0], 1, 0x0000E0FF, 0x000007FF },
95 { &mode2[0], 1, 0x00E0FFFF, 0x0007FFFF }
97 #endif
100 * Array of Pointers to mode Structures
102 struct mode *modep[16] = {
103 &mode[0], &mode[1], &mode[2], NULL,
104 NULL, NULL, NULL, NULL,
105 NULL, NULL, NULL, NULL,
106 NULL, NULL, NULL, NULL
110 * Mnemonic Structure
112 struct mne mne[] = {
114 /* machine */
116 { NULL, ".amode", S_AMODE, 0, 0 },
118 { NULL, ".cpu", S_CPU, 0, DS______ },
119 { NULL, ".DS8XCXXX", S_CPU, 0, DS8XCXXX },
120 { NULL, ".DS80C310", S_CPU, 0, DS80C310 },
121 { NULL, ".DS80C320", S_CPU, 0, DS80C320 },
122 { NULL, ".DS80C323", S_CPU, 0, DS80C323 },
123 { NULL, ".DS80C390", S_CPU, 0, DS80C390 },
124 { NULL, ".DS83C520", S_CPU, 0, DS83C520 },
125 { NULL, ".DS83C530", S_CPU, 0, DS83C530 },
126 { NULL, ".DS83C550", S_CPU, 0, DS83C550 },
127 { NULL, ".DS87C520", S_CPU, 0, DS87C520 },
128 { NULL, ".DS87C530", S_CPU, 0, DS87C530 },
129 { NULL, ".DS87C550", S_CPU, 0, DS87C550 },
131 /* system */
134 { NULL, "CON", S_ATYP, 0, A_CON },
135 { NULL, "OVR", S_ATYP, 0, A_OVR },
136 { NULL, "REL", S_ATYP, 0, A_REL },
137 { NULL, "ABS", S_ATYP, 0, A_ABS },
138 { NULL, "NOPAG", S_ATYP, 0, A_NOPAG },
139 { NULL, "PAG", S_ATYP, 0, A_PAG },
141 { NULL, "CODE", S_ATYP, 0, A_CODE },
142 { NULL, "DATA", S_ATYP, 0, A_DATA },
143 { NULL, "XDATA", S_ATYP, 0, A_XDATA },
144 { NULL, "BIT", S_ATYP, 0, A_BIT },
146 { NULL, ".page", S_PAGE, 0, 0 },
147 { NULL, ".title", S_HEADER, 0, O_TITLE },
148 { NULL, ".sbttl", S_HEADER, 0, O_SBTTL },
149 { NULL, ".module", S_MODUL, 0, 0 },
150 { NULL, ".include", S_INCL, 0, I_CODE },
151 { NULL, ".incbin", S_INCL, 0, I_BNRY },
152 { NULL, ".area", S_AREA, 0, 0 },
153 { NULL, ".org", S_ORG, 0, 0 },
154 { NULL, ".radix", S_RADIX, 0, 0 },
155 { NULL, ".globl", S_GLOBL, 0, 0 },
156 { NULL, ".local", S_LOCAL, 0, 0 },
157 { NULL, ".if", S_CONDITIONAL, 0, O_IF },
158 { NULL, ".iff", S_CONDITIONAL, 0, O_IFF },
159 { NULL, ".ift", S_CONDITIONAL, 0, O_IFT },
160 { NULL, ".iftf", S_CONDITIONAL, 0, O_IFTF },
161 { NULL, ".ifdef", S_CONDITIONAL, 0, O_IFDEF },
162 { NULL, ".ifndef", S_CONDITIONAL, 0, O_IFNDEF},
163 { NULL, ".ifgt", S_CONDITIONAL, 0, O_IFGT },
164 { NULL, ".iflt", S_CONDITIONAL, 0, O_IFLT },
165 { NULL, ".ifge", S_CONDITIONAL, 0, O_IFGE },
166 { NULL, ".ifle", S_CONDITIONAL, 0, O_IFLE },
167 { NULL, ".ifeq", S_CONDITIONAL, 0, O_IFEQ },
168 { NULL, ".ifne", S_CONDITIONAL, 0, O_IFNE },
169 { NULL, ".ifb", S_CONDITIONAL, 0, O_IFB },
170 { NULL, ".ifnb", S_CONDITIONAL, 0, O_IFNB },
171 { NULL, ".ifidn", S_CONDITIONAL, 0, O_IFIDN },
172 { NULL, ".ifdif", S_CONDITIONAL, 0, O_IFDIF },
173 { NULL, ".iif", S_CONDITIONAL, 0, O_IIF },
174 { NULL, ".iiff", S_CONDITIONAL, 0, O_IIFF },
175 { NULL, ".iift", S_CONDITIONAL, 0, O_IIFT },
176 { NULL, ".iiftf", S_CONDITIONAL, 0, O_IIFTF },
177 { NULL, ".iifdef", S_CONDITIONAL, 0, O_IIFDEF},
178 { NULL, ".iifndef", S_CONDITIONAL, 0, O_IIFNDEF},
179 { NULL, ".iifgt", S_CONDITIONAL, 0, O_IIFGT },
180 { NULL, ".iiflt", S_CONDITIONAL, 0, O_IIFLT },
181 { NULL, ".iifge", S_CONDITIONAL, 0, O_IIFGE },
182 { NULL, ".iifle", S_CONDITIONAL, 0, O_IIFLE },
183 { NULL, ".iifeq", S_CONDITIONAL, 0, O_IIFEQ },
184 { NULL, ".iifne", S_CONDITIONAL, 0, O_IIFNE },
185 { NULL, ".iifb", S_CONDITIONAL, 0, O_IIFB },
186 { NULL, ".iifnb", S_CONDITIONAL, 0, O_IIFNB },
187 { NULL, ".iifidn", S_CONDITIONAL, 0, O_IIFIDN},
188 { NULL, ".iifdif", S_CONDITIONAL, 0, O_IIFDIF},
189 { NULL, ".else", S_CONDITIONAL, 0, O_ELSE },
190 { NULL, ".endif", S_CONDITIONAL, 0, O_ENDIF },
191 { NULL, ".list", S_LISTING, 0, O_LIST },
192 { NULL, ".nlist", S_LISTING, 0, O_NLIST },
193 { NULL, ".equ", S_EQU, 0, O_EQU },
194 { NULL, ".gblequ", S_EQU, 0, O_GBLEQU},
195 { NULL, ".lclequ", S_EQU, 0, O_LCLEQU},
196 /* sdas specific */
197 { NULL, ".optsdcc", S_OPTSDCC, 0, 0 },
198 /* end sdas specific */
199 { NULL, ".byte", S_DATA, 0, O_1BYTE },
200 { NULL, ".db", S_DATA, 0, O_1BYTE },
201 { NULL, ".fcb", S_DATA, 0, O_1BYTE },
202 { NULL, ".word", S_DATA, 0, O_2BYTE },
203 { NULL, ".dw", S_DATA, 0, O_2BYTE },
204 { NULL, ".fdb", S_DATA, 0, O_2BYTE },
205 { NULL, ".3byte", S_DATA, 0, O_3BYTE },
206 { NULL, ".triple", S_DATA, 0, O_3BYTE },
207 /* { NULL, ".4byte", S_DATA, 0, O_4BYTE }, */
208 /* { NULL, ".quad", S_DATA, 0, O_4BYTE }, */
209 { NULL, ".blkb", S_BLK, 0, O_1BYTE },
210 { NULL, ".ds", S_BLK, 0, O_1BYTE },
211 { NULL, ".rmb", S_BLK, 0, O_1BYTE },
212 { NULL, ".rs", S_BLK, 0, O_1BYTE },
213 { NULL, ".blkw", S_BLK, 0, O_2BYTE },
214 { NULL, ".blk3", S_BLK, 0, O_3BYTE },
215 /* { NULL, ".blk4", S_BLK, 0, O_4BYTE }, */
216 { NULL, ".ascii", S_ASCIX, 0, O_ASCII },
217 { NULL, ".ascis", S_ASCIX, 0, O_ASCIS },
218 { NULL, ".asciz", S_ASCIX, 0, O_ASCIZ },
219 { NULL, ".str", S_ASCIX, 0, O_ASCII },
220 { NULL, ".strs", S_ASCIX, 0, O_ASCIS },
221 { NULL, ".strz", S_ASCIX, 0, O_ASCIZ },
222 { NULL, ".fcc", S_ASCIX, 0, O_ASCII },
223 { NULL, ".define", S_DEFINE, 0, O_DEF },
224 { NULL, ".undefine", S_DEFINE, 0, O_UNDEF },
225 { NULL, ".even", S_BOUNDARY, 0, O_EVEN },
226 { NULL, ".odd", S_BOUNDARY, 0, O_ODD },
227 { NULL, ".bndry", S_BOUNDARY, 0, O_BNDRY },
228 { NULL, ".msg" , S_MSG, 0, 0 },
229 { NULL, ".assume", S_ERROR, 0, O_ASSUME},
230 { NULL, ".error", S_ERROR, 0, O_ERROR },
231 { NULL, ".16bit", S_BITS, 0, O_2BYTE },
232 { NULL, ".24bit", S_BITS, 0, O_3BYTE },
234 /* Macro Processor */
236 { NULL, ".macro", S_MACRO, 0, O_MACRO },
237 { NULL, ".endm", S_MACRO, 0, O_ENDM },
238 { NULL, ".mexit", S_MACRO, 0, O_MEXIT },
240 { NULL, ".narg", S_MACRO, 0, O_NARG },
241 { NULL, ".nchr", S_MACRO, 0, O_NCHR },
242 { NULL, ".ntyp", S_MACRO, 0, O_NTYP },
244 { NULL, ".irp", S_MACRO, 0, O_IRP },
245 { NULL, ".irpc", S_MACRO, 0, O_IRPC },
246 { NULL, ".rept", S_MACRO, 0, O_REPT },
248 { NULL, ".nval", S_MACRO, 0, O_NVAL },
250 { NULL, ".mdelete", S_MACRO, 0, O_MDEL },
252 /* machine */
254 { NULL, "a", S_A, 0, A },
255 { NULL, "ab", S_AB, 0, 0 },
256 { NULL, "dptr", S_DPTR, 0, DPTR },
257 { NULL, "pc", S_PC, 0, PC },
258 { NULL, "r0", S_REG, 0, R0 },
259 { NULL, "r1", S_REG, 0, R1 },
260 { NULL, "r2", S_REG, 0, R2 },
261 { NULL, "r3", S_REG, 0, R3 },
262 { NULL, "r4", S_REG, 0, R4 },
263 { NULL, "r5", S_REG, 0, R5 },
264 { NULL, "r6", S_REG, 0, R6 },
265 { NULL, "r7", S_REG, 0, R7 },
267 { NULL, "nop", S_INH, 0, 0x00 },
268 { NULL, "ret", S_INH, 0, 0x22 },
269 { NULL, "reti", S_INH, 0, 0x32 },
271 { NULL, "ajmp", S_JMP11, 0, 0x01 },
272 { NULL, "acall", S_JMP11, 0, 0x11 },
273 { NULL, "ljmp", S_JMP16, 0, 0x02 },
274 { NULL, "lcall", S_JMP16, 0, 0x12 },
276 { NULL, "rr", S_ACC, 0, 0x03 },
277 { NULL, "rrc", S_ACC, 0, 0x13 },
278 { NULL, "rl", S_ACC, 0, 0x23 },
279 { NULL, "rlc", S_ACC, 0, 0x33 },
280 { NULL, "swap", S_ACC, 0, 0xC4 },
281 { NULL, "da", S_ACC, 0, 0xD4 },
283 { NULL, "inc", S_TYP1, 0, 0x00 },
284 { NULL, "dec", S_TYP1, 0, 0x10 },
286 { NULL, "add", S_TYP2, 0, 0x20 },
287 { NULL, "addc", S_TYP2, 0, 0x30 },
288 { NULL, "subb", S_TYP2, 0, 0x90 },
290 { NULL, "orl", S_TYP3, 0, 0x40 },
291 { NULL, "anl", S_TYP3, 0, 0x50 },
292 { NULL, "xrl", S_TYP3, 0, 0x60 },
294 { NULL, "xch", S_TYP4, 0, 0xC0 },
296 { NULL, "mov", S_MOV, 0, 0x00 },
298 { NULL, "jbc", S_BITBR, 0, 0x10 },
299 { NULL, "jb", S_BITBR, 0, 0x20 },
300 { NULL, "jnb", S_BITBR, 0, 0x30 },
302 { NULL, "jc", S_BR, 0, 0x40 },
303 { NULL, "jnc", S_BR, 0, 0x50 },
304 { NULL, "jz", S_BR, 0, 0x60 },
305 { NULL, "jnz", S_BR, 0, 0x70 },
306 { NULL, "sjmp", S_BR, 0, 0x80 },
308 { NULL, "cjne", S_CJNE, 0, 0xB0 },
309 { NULL, "djnz", S_DJNZ, 0, 0xD0 },
310 { NULL, "jmp", S_JMP, 0, 0x73 },
311 { NULL, "movc", S_MOVC, 0, 0x83 },
312 { NULL, "movx", S_MOVX, 0, 0x00 },
313 { NULL, "div", S_AB, 0, 0x84 },
314 { NULL, "mul", S_AB, 0, 0xA4 },
315 { NULL, "clr", S_ACBIT, 0, 0xC2 },
316 { NULL, "cpl", S_ACBIT, 0, 0xB2 },
317 { NULL, "setb", S_SETB, 0, 0xD2 },
318 { NULL, "push", S_DIRECT, 0, 0xC0 },
319 { NULL, "pop", S_DIRECT, 0, 0xD0 },
320 { NULL, "xchd", S_XCHD, S_EOL, 0xD6 }
323 struct PreDef preDef[] = {
324 { "AC", 0x00D6 },
325 { "ACC", 0x00E0 },
326 { "ACC.0", 0x00E0 },
327 { "ACC.1", 0x00E1 },
328 { "ACC.2", 0x00E2 },
329 { "ACC.3", 0x00E3 },
330 { "ACC.4", 0x00E4 },
331 { "ACC.5", 0x00E5 },
332 { "ACC.6", 0x00E6 },
333 { "ACC.7", 0x00E7 },
334 { "B", 0x00F0 },
335 { "B.0", 0x00F0 },
336 { "B.1", 0x00F1 },
337 { "B.2", 0x00F2 },
338 { "B.3", 0x00F3 },
339 { "B.4", 0x00F4 },
340 { "B.5", 0x00F5 },
341 { "B.6", 0x00F6 },
342 { "B.7", 0x00F7 },
343 { "CY", 0x00D7 },
344 { "DPH", 0x0083 },
345 { "DPL", 0x0082 },
346 { "EA", 0x00AF },
347 { "F0", 0x00D5 },
348 { "IE", 0x00A8 },
349 { "IP", 0x00B8 },
350 { "OV", 0x00D2 },
351 { "P", 0x00D0 },
352 { "PCON", 0x0087 },
353 { "PS", 0x00BC },
354 { "PSW", 0x00D0 },
355 { "RS0", 0x00D3 },
356 { "RS1", 0x00D4 },
357 { "SM0", 0x009F },
358 { "SM1", 0x009E },
359 { "SM2", 0x009D },
360 { "SP", 0x0081 },
361 { NULL, 0x0000 }