Update svn merge history.
[sdcc.git] / sdcc / sdas / as8051 / i51pst.c
blob1ea58c9f547748f9a9c09e9752c258b48ca41e1b
1 /* i51pst.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 * John L. Hartman (JLH)
26 * jhartman at compuserve dot com
27 * noice at noicedebugger dot com
31 #include "asxxxx.h"
32 #include "i8051.h"
35 * Mnemonic Structure
37 struct mne mne[] = {
39 /* machine */
41 /* system */
44 { NULL, "CON", S_ATYP, 0, A_CON },
45 { NULL, "OVR", S_ATYP, 0, A_OVR },
46 { NULL, "REL", S_ATYP, 0, A_REL },
47 { NULL, "ABS", S_ATYP, 0, A_ABS },
48 { NULL, "NOPAG", S_ATYP, 0, A_NOPAG },
49 { NULL, "PAG", S_ATYP, 0, A_PAG },
51 { NULL, "CODE", S_ATYP, 0, A_CODE },
52 { NULL, "DATA", S_ATYP, 0, A_DATA },
53 { NULL, "XDATA", S_ATYP, 0, A_XDATA },
54 { NULL, "BIT", S_ATYP, 0, A_BIT },
56 { NULL, ".page", S_PAGE, 0, 0 },
57 { NULL, ".title", S_HEADER, 0, O_TITLE },
58 { NULL, ".sbttl", S_HEADER, 0, O_SBTTL },
59 { NULL, ".module", S_MODUL, 0, 0 },
60 { NULL, ".include", S_INCL, 0, I_CODE },
61 { NULL, ".incbin", S_INCL, 0, I_BNRY },
62 { NULL, ".area", S_AREA, 0, 0 },
63 { NULL, ".org", S_ORG, 0, 0 },
64 { NULL, ".radix", S_RADIX, 0, 0 },
65 { NULL, ".globl", S_GLOBL, 0, 0 },
66 { NULL, ".local", S_LOCAL, 0, 0 },
67 { NULL, ".if", S_CONDITIONAL, 0, O_IF },
68 { NULL, ".iff", S_CONDITIONAL, 0, O_IFF },
69 { NULL, ".ift", S_CONDITIONAL, 0, O_IFT },
70 { NULL, ".iftf", S_CONDITIONAL, 0, O_IFTF },
71 { NULL, ".ifdef", S_CONDITIONAL, 0, O_IFDEF },
72 { NULL, ".ifndef", S_CONDITIONAL, 0, O_IFNDEF},
73 { NULL, ".ifgt", S_CONDITIONAL, 0, O_IFGT },
74 { NULL, ".iflt", S_CONDITIONAL, 0, O_IFLT },
75 { NULL, ".ifge", S_CONDITIONAL, 0, O_IFGE },
76 { NULL, ".ifle", S_CONDITIONAL, 0, O_IFLE },
77 { NULL, ".ifeq", S_CONDITIONAL, 0, O_IFEQ },
78 { NULL, ".ifne", S_CONDITIONAL, 0, O_IFNE },
79 { NULL, ".ifb", S_CONDITIONAL, 0, O_IFB },
80 { NULL, ".ifnb", S_CONDITIONAL, 0, O_IFNB },
81 { NULL, ".ifidn", S_CONDITIONAL, 0, O_IFIDN },
82 { NULL, ".ifdif", S_CONDITIONAL, 0, O_IFDIF },
83 { NULL, ".iif", S_CONDITIONAL, 0, O_IIF },
84 { NULL, ".iiff", S_CONDITIONAL, 0, O_IIFF },
85 { NULL, ".iift", S_CONDITIONAL, 0, O_IIFT },
86 { NULL, ".iiftf", S_CONDITIONAL, 0, O_IIFTF },
87 { NULL, ".iifdef", S_CONDITIONAL, 0, O_IIFDEF},
88 { NULL, ".iifndef", S_CONDITIONAL, 0, O_IIFNDEF},
89 { NULL, ".iifgt", S_CONDITIONAL, 0, O_IIFGT },
90 { NULL, ".iiflt", S_CONDITIONAL, 0, O_IIFLT },
91 { NULL, ".iifge", S_CONDITIONAL, 0, O_IIFGE },
92 { NULL, ".iifle", S_CONDITIONAL, 0, O_IIFLE },
93 { NULL, ".iifeq", S_CONDITIONAL, 0, O_IIFEQ },
94 { NULL, ".iifne", S_CONDITIONAL, 0, O_IIFNE },
95 { NULL, ".iifb", S_CONDITIONAL, 0, O_IIFB },
96 { NULL, ".iifnb", S_CONDITIONAL, 0, O_IIFNB },
97 { NULL, ".iifidn", S_CONDITIONAL, 0, O_IIFIDN},
98 { NULL, ".iifdif", S_CONDITIONAL, 0, O_IIFDIF},
99 { NULL, ".else", S_CONDITIONAL, 0, O_ELSE },
100 { NULL, ".endif", S_CONDITIONAL, 0, O_ENDIF },
101 { NULL, ".list", S_LISTING, 0, O_LIST },
102 { NULL, ".nlist", S_LISTING, 0, O_NLIST },
103 { NULL, ".equ", S_EQU, 0, O_EQU },
104 { NULL, ".gblequ", S_EQU, 0, O_GBLEQU},
105 { NULL, ".lclequ", S_EQU, 0, O_LCLEQU},
106 /* sdas specific */
107 { NULL, ".optsdcc", S_OPTSDCC, 0, 0 },
108 /* end sdas specific */
109 { NULL, ".byte", S_DATA, 0, O_1BYTE },
110 { NULL, ".db", S_DATA, 0, O_1BYTE },
111 { NULL, ".fcb", S_DATA, 0, O_1BYTE },
112 { NULL, ".word", S_DATA, 0, O_2BYTE },
113 { NULL, ".dw", S_DATA, 0, O_2BYTE },
114 { NULL, ".fdb", S_DATA, 0, O_2BYTE },
115 /* { NULL, ".3byte", S_DATA, 0, O_3BYTE }, */
116 /* { NULL, ".triple", S_DATA, 0, O_3BYTE }, */
117 /* { NULL, ".4byte", S_DATA, 0, O_4BYTE }, */
118 /* { NULL, ".quad", S_DATA, 0, O_4BYTE }, */
119 { NULL, ".blkb", S_BLK, 0, O_1BYTE },
120 { NULL, ".ds", S_BLK, 0, O_1BYTE },
121 { NULL, ".rmb", S_BLK, 0, O_1BYTE },
122 { NULL, ".rs", S_BLK, 0, O_1BYTE },
123 { NULL, ".blkw", S_BLK, 0, O_2BYTE },
124 /* { NULL, ".blk3", S_BLK, 0, O_3BYTE }, */
125 /* { NULL, ".blk4", S_BLK, 0, O_4BYTE }, */
126 { NULL, ".ascii", S_ASCIX, 0, O_ASCII },
127 { NULL, ".ascis", S_ASCIX, 0, O_ASCIS },
128 { NULL, ".asciz", S_ASCIX, 0, O_ASCIZ },
129 { NULL, ".str", S_ASCIX, 0, O_ASCII },
130 { NULL, ".strs", S_ASCIX, 0, O_ASCIS },
131 { NULL, ".strz", S_ASCIX, 0, O_ASCIZ },
132 { NULL, ".fcc", S_ASCIX, 0, O_ASCII },
133 { NULL, ".define", S_DEFINE, 0, O_DEF },
134 { NULL, ".undefine", S_DEFINE, 0, O_UNDEF },
135 { NULL, ".even", S_BOUNDARY, 0, O_EVEN },
136 { NULL, ".odd", S_BOUNDARY, 0, O_ODD },
137 { NULL, ".bndry", S_BOUNDARY, 0, O_BNDRY },
138 { NULL, ".msg" , S_MSG, 0, 0 },
139 { NULL, ".assume", S_ERROR, 0, O_ASSUME},
140 { NULL, ".error", S_ERROR, 0, O_ERROR },
142 /* Macro Processor */
144 { NULL, ".macro", S_MACRO, 0, O_MACRO },
145 { NULL, ".endm", S_MACRO, 0, O_ENDM },
146 { NULL, ".mexit", S_MACRO, 0, O_MEXIT },
148 { NULL, ".narg", S_MACRO, 0, O_NARG },
149 { NULL, ".nchr", S_MACRO, 0, O_NCHR },
150 { NULL, ".ntyp", S_MACRO, 0, O_NTYP },
152 { NULL, ".irp", S_MACRO, 0, O_IRP },
153 { NULL, ".irpc", S_MACRO, 0, O_IRPC },
154 { NULL, ".rept", S_MACRO, 0, O_REPT },
156 { NULL, ".nval", S_MACRO, 0, O_NVAL },
158 { NULL, ".mdelete", S_MACRO, 0, O_MDEL },
160 /* machine */
162 { NULL, "a", S_A, 0, A },
163 { NULL, "ab", S_AB, 0, 0 },
164 { NULL, "dptr", S_DPTR, 0, DPTR },
165 { NULL, "pc", S_PC, 0, PC },
166 { NULL, "r0", S_REG, 0, R0 },
167 { NULL, "r1", S_REG, 0, R1 },
168 { NULL, "r2", S_REG, 0, R2 },
169 { NULL, "r3", S_REG, 0, R3 },
170 { NULL, "r4", S_REG, 0, R4 },
171 { NULL, "r5", S_REG, 0, R5 },
172 { NULL, "r6", S_REG, 0, R6 },
173 { NULL, "r7", S_REG, 0, R7 },
175 { NULL, "nop", S_INH, 0, 0x00 },
176 { NULL, "ret", S_INH, 0, 0x22 },
177 { NULL, "reti", S_INH, 0, 0x32 },
179 { NULL, "ajmp", S_JMP11, 0, 0x01 },
180 { NULL, "acall", S_JMP11, 0, 0x11 },
181 { NULL, "ljmp", S_JMP16, 0, 0x02 },
182 { NULL, "lcall", S_JMP16, 0, 0x12 },
184 { NULL, "rr", S_ACC, 0, 0x03 },
185 { NULL, "rrc", S_ACC, 0, 0x13 },
186 { NULL, "rl", S_ACC, 0, 0x23 },
187 { NULL, "rlc", S_ACC, 0, 0x33 },
188 { NULL, "swap", S_ACC, 0, 0xC4 },
189 { NULL, "da", S_ACC, 0, 0xD4 },
191 { NULL, "inc", S_TYP1, 0, 0x00 },
192 { NULL, "dec", S_TYP1, 0, 0x10 },
194 { NULL, "add", S_TYP2, 0, 0x20 },
195 { NULL, "addc", S_TYP2, 0, 0x30 },
196 { NULL, "subb", S_TYP2, 0, 0x90 },
198 { NULL, "orl", S_TYP3, 0, 0x40 },
199 { NULL, "anl", S_TYP3, 0, 0x50 },
200 { NULL, "xrl", S_TYP3, 0, 0x60 },
202 { NULL, "xch", S_TYP4, 0, 0xC0 },
204 { NULL, "mov", S_MOV, 0, 0x00 },
206 { NULL, "jbc", S_BITBR, 0, 0x10 },
207 { NULL, "jb", S_BITBR, 0, 0x20 },
208 { NULL, "jnb", S_BITBR, 0, 0x30 },
210 { NULL, "jc", S_BR, 0, 0x40 },
211 { NULL, "jnc", S_BR, 0, 0x50 },
212 { NULL, "jz", S_BR, 0, 0x60 },
213 { NULL, "jnz", S_BR, 0, 0x70 },
214 { NULL, "sjmp", S_BR, 0, 0x80 },
216 { NULL, "cjne", S_CJNE, 0, 0xB0 },
217 { NULL, "djnz", S_DJNZ, 0, 0xD0 },
218 { NULL, "jmp", S_JMP, 0, 0x73 },
219 { NULL, "movc", S_MOVC, 0, 0x83 },
220 { NULL, "movx", S_MOVX, 0, 0x00 },
221 { NULL, "div", S_AB, 0, 0x84 },
222 { NULL, "mul", S_AB, 0, 0xA4 },
223 { NULL, "clr", S_ACBIT, 0, 0xC2 },
224 { NULL, "cpl", S_ACBIT, 0, 0xB2 },
225 { NULL, "setb", S_SETB, 0, 0xD2 },
226 { NULL, "push", S_DIRECT, 0, 0xC0 },
227 { NULL, "pop", S_DIRECT, 0, 0xD0 },
228 { NULL, "xchd", S_XCHD, S_EOL, 0xD6 }
231 struct PreDef preDef[] = {
232 { "AC", 0x00D6 },
233 { "ACC", 0x00E0 },
234 { "ACC.0", 0x00E0 },
235 { "ACC.1", 0x00E1 },
236 { "ACC.2", 0x00E2 },
237 { "ACC.3", 0x00E3 },
238 { "ACC.4", 0x00E4 },
239 { "ACC.5", 0x00E5 },
240 { "ACC.6", 0x00E6 },
241 { "ACC.7", 0x00E7 },
242 { "A", 0x00E0 },
243 { "A.0", 0x00E0 },
244 { "A.1", 0x00E1 },
245 { "A.2", 0x00E2 },
246 { "A.3", 0x00E3 },
247 { "A.4", 0x00E4 },
248 { "A.5", 0x00E5 },
249 { "A.6", 0x00E6 },
250 { "A.7", 0x00E7 },
251 { "B", 0x00F0 },
252 { "B.0", 0x00F0 },
253 { "B.1", 0x00F1 },
254 { "B.2", 0x00F2 },
255 { "B.3", 0x00F3 },
256 { "B.4", 0x00F4 },
257 { "B.5", 0x00F5 },
258 { "B.6", 0x00F6 },
259 { "B.7", 0x00F7 },
260 { "CPRL2", 0x00C8 },
261 { "CT2", 0x00C9 },
262 { "CY", 0x00D7 },
263 { "DPH", 0x0083 },
264 { "DPL", 0x0082 },
265 { "EA", 0x00AF },
266 { "ES", 0x00AC },
267 { "ET0", 0x00A9 },
268 { "ET1", 0x00AB },
269 { "ET2", 0x00AD },
270 { "EX0", 0x00A8 },
271 { "EX1", 0x00AA },
272 { "EXEN2", 0x00CB },
273 { "EXF2", 0x00CE },
274 { "F0", 0x00D5 },
275 { "IE", 0x00A8 },
276 { "IE.0", 0x00A8 },
277 { "IE.1", 0x00A9 },
278 { "IE.2", 0x00AA },
279 { "IE.3", 0x00AB },
280 { "IE.4", 0x00AC },
281 { "IE.5", 0x00AD },
282 { "IE.7", 0x00AF },
283 { "IE0", 0x0089 },
284 { "IE1", 0x008B },
285 { "INT0", 0x00B2 },
286 { "INT1", 0x00B3 },
287 { "IP", 0x00B8 },
288 { "IP.0", 0x00B8 },
289 { "IP.1", 0x00B9 },
290 { "IP.2", 0x00BA },
291 { "IP.3", 0x00BB },
292 { "IP.4", 0x00BC },
293 { "IP.5", 0x00BD },
294 { "IT0", 0x0088 },
295 { "IT1", 0x008A },
296 { "OV", 0x00D2 },
297 { "P", 0x00D0 },
298 { "P0", 0x0080 },
299 { "P0.0", 0x0080 },
300 { "P0.1", 0x0081 },
301 { "P0.2", 0x0082 },
302 { "P0.3", 0x0083 },
303 { "P0.4", 0x0084 },
304 { "P0.5", 0x0085 },
305 { "P0.6", 0x0086 },
306 { "P0.7", 0x0087 },
307 { "P1", 0x0090 },
308 { "P1.0", 0x0090 },
309 { "P1.1", 0x0091 },
310 { "P1.2", 0x0092 },
311 { "P1.3", 0x0093 },
312 { "P1.4", 0x0094 },
313 { "P1.5", 0x0095 },
314 { "P1.6", 0x0096 },
315 { "P1.7", 0x0097 },
316 { "P2", 0x00A0 },
317 { "P2.0", 0x00A0 },
318 { "P2.1", 0x00A1 },
319 { "P2.2", 0x00A2 },
320 { "P2.3", 0x00A3 },
321 { "P2.4", 0x00A4 },
322 { "P2.5", 0x00A5 },
323 { "P2.6", 0x00A6 },
324 { "P2.7", 0x00A7 },
325 { "P3", 0x00B0 },
326 { "P3.0", 0x00B0 },
327 { "P3.1", 0x00B1 },
328 { "P3.2", 0x00B2 },
329 { "P3.3", 0x00B3 },
330 { "P3.4", 0x00B4 },
331 { "P3.5", 0x00B5 },
332 { "P3.6", 0x00B6 },
333 { "P3.7", 0x00B7 },
334 { "PCON", 0x0087 },
335 { "PS", 0x00BC },
336 { "PSW", 0x00D0 },
337 { "PSW.0", 0x00D0 },
338 { "PSW.1", 0x00D1 },
339 { "PSW.2", 0x00D2 },
340 { "PSW.3", 0x00D3 },
341 { "PSW.4", 0x00D4 },
342 { "PSW.5", 0x00D5 },
343 { "PSW.6", 0x00D6 },
344 { "PSW.7", 0x00D7 },
345 { "PT0", 0x00B9 },
346 { "PT1", 0x00BB },
347 { "PT2", 0x00BD },
348 { "PX0", 0x00B8 },
349 { "PX1", 0x00BA },
350 { "RB8", 0x009A },
351 { "RCAP2H", 0x00CB },
352 { "RCAP2L", 0x00CA },
353 { "RCLK", 0x00CD },
354 { "REN", 0x009C },
355 { "RI", 0x0098 },
356 { "RS0", 0x00D3 },
357 { "RS1", 0x00D4 },
358 { "RXD", 0x00B0 },
359 { "SBUF", 0x0099 },
360 { "SCON", 0x0098 },
361 { "SCON.0", 0x0098 },
362 { "SCON.1", 0x0099 },
363 { "SCON.2", 0x009A },
364 { "SCON.3", 0x009B },
365 { "SCON.4", 0x009C },
366 { "SCON.5", 0x009D },
367 { "SCON.6", 0x009E },
368 { "SCON.7", 0x009F },
369 { "SM0", 0x009F },
370 { "SM1", 0x009E },
371 { "SM2", 0x009D },
372 { "SP", 0x0081 },
373 { "T2CON", 0x00C8 },
374 { "T2CON.0", 0x00C8 },
375 { "T2CON.1", 0x00C9 },
376 { "T2CON.2", 0x00CA },
377 { "T2CON.3", 0x00CB },
378 { "T2CON.4", 0x00CC },
379 { "T2CON.5", 0x00CD },
380 { "T2CON.6", 0x00CE },
381 { "T2CON.7", 0x00CF },
382 { "TB8", 0x009B },
383 { "TCLK", 0x00CC },
384 { "TCON", 0x0088 },
385 { "TCON.0", 0x0088 },
386 { "TCON.1", 0x0089 },
387 { "TCON.2", 0x008A },
388 { "TCON.3", 0x008B },
389 { "TCON.4", 0x008C },
390 { "TCON.5", 0x008D },
391 { "TCON.6", 0x008E },
392 { "TCON.7", 0x008F },
393 { "TF0", 0x008D },
394 { "TF1", 0x008F },
395 { "TF2", 0x00CF },
396 { "TH0", 0x008C },
397 { "TH1", 0x008D },
398 { "TH2", 0x00CD },
399 { "TI", 0x0099 },
400 { "TL0", 0x008A },
401 { "TL1", 0x008B },
402 { "TL2", 0x00CC },
403 { "TMOD", 0x0089 },
404 { "TR0", 0x008C },
405 { "TR1", 0x008E },
406 { "TR2", 0x00CA },
407 { "TXD", 0x00B1 },
408 { NULL, 0x0000 }