28
|
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
|
32
|
25 #define __insn_rlist_c_seen__
|
28
|
26
|
|
27 #include "lwasm.h"
|
|
28 #include "instab.h"
|
|
29
|
|
30 OPFUNC(insn_rlist)
|
|
31 {
|
|
32 int rb = 0;
|
|
33 int rn;
|
|
34 static const char *regs = "CCA B DPX Y U PCD S ";
|
|
35
|
|
36 lwasm_emitop(as, l, instab[opnum].ops[0]);
|
|
37 while (**p && !isspace(**p))
|
|
38 {
|
|
39 rn = lwasm_lookupreg2(regs, p);
|
|
40 if (rn < 0)
|
|
41 {
|
|
42 register_error(as, l, 1, "Bad register '%s'", *p);
|
|
43 lwasm_emit(as, l, 0);
|
|
44 return;
|
|
45 }
|
|
46 if (**p && **p != ',' && !isspace(**p))
|
|
47 {
|
|
48 register_error(as, l, 1, "Bad operand");
|
|
49 lwasm_emit(as, l, 0);
|
|
50 }
|
|
51 if (**p == ',')
|
|
52 (*p)++;
|
|
53 if (rn == 8)
|
|
54 rn = 6;
|
|
55 else if (rn == 9)
|
|
56 rn = 0x40;
|
|
57 else
|
|
58 rn = 1 << rn;
|
|
59 rb |= rn;
|
|
60 }
|
|
61 lwasm_emit(as, l, rb);
|
|
62 }
|