339
|
1 /*
|
|
2 insn_rlist.c
|
|
3 Copyright © 2009 William Astle
|
|
4
|
|
5 This file is part of LWASM.
|
|
6
|
|
7 LWASM is free software: you can redistribute it and/or modify it under the
|
|
8 terms of the GNU General Public License as published by the Free Software
|
|
9 Foundation, either version 3 of the License, or (at your option) any later
|
|
10 version.
|
|
11
|
|
12 This program is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
15 more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License along with
|
|
18 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19 */
|
|
20
|
|
21 /*
|
|
22 for handling inherent mode instructions
|
|
23 */
|
|
24
|
|
25 #include <config.h>
|
|
26 #include "lwasm.h"
|
|
27 #include "instab.h"
|
|
28
|
357
|
29 PARSEFUNC(insn_parse_rlist)
|
339
|
30 {
|
|
31 int rb = 0;
|
|
32 int rn;
|
|
33 static const char *regs = "CCA B DPX Y U PCD S ";
|
|
34
|
|
35 while (**p && !isspace(**p))
|
|
36 {
|
|
37 rn = lwasm_lookupreg2(regs, p);
|
|
38 if (rn < 0)
|
|
39 {
|
357
|
40 lwasm_register_error(as, l, "Bad register '%s'", *p);
|
339
|
41 return;
|
|
42 }
|
|
43 if (**p && **p != ',' && !isspace(**p))
|
|
44 {
|
357
|
45 lwasm_register_error(as, l, "Bad operand");
|
339
|
46 }
|
|
47 if (**p == ',')
|
|
48 (*p)++;
|
|
49 if (rn == 8)
|
|
50 rn = 6;
|
|
51 else if (rn == 9)
|
|
52 rn = 0x40;
|
|
53 else
|
|
54 rn = 1 << rn;
|
|
55 rb |= rn;
|
|
56 }
|
357
|
57 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;
|
|
58 l -> pb = rb;
|
339
|
59 }
|
357
|
60
|
|
61 EMITFUNC(insn_emit_rlist)
|
|
62 {
|
|
63 lwasm_emitop(l, instab[l -> insn].ops[0]);
|
|
64 lwasm_emit(l, l -> pb);
|
|
65 }
|