Mercurial > hg-old > index.cgi
comparison lwasm/insn_rlist.c @ 357:0cf4948d53b4
Checkpoint - adding actual cpu instructions
author | lost@starbug |
---|---|
date | Wed, 31 Mar 2010 20:12:20 -0600 |
parents | old-trunk/lwasm/old/insn_rlist.c@eb230fa7d28e |
children |
comparison
equal
deleted
inserted
replaced
356:7166254491ed | 357:0cf4948d53b4 |
---|---|
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 | |
29 PARSEFUNC(insn_parse_rlist) | |
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 { | |
40 lwasm_register_error(as, l, "Bad register '%s'", *p); | |
41 return; | |
42 } | |
43 if (**p && **p != ',' && !isspace(**p)) | |
44 { | |
45 lwasm_register_error(as, l, "Bad operand"); | |
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 } | |
57 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1; | |
58 l -> pb = rb; | |
59 } | |
60 | |
61 EMITFUNC(insn_emit_rlist) | |
62 { | |
63 lwasm_emitop(l, instab[l -> insn].ops[0]); | |
64 lwasm_emit(l, l -> pb); | |
65 } |