Mercurial > hg > index.cgi
comparison lwasm/insn_rlist.c @ 0:2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
author | lost@l-w.ca |
---|---|
date | Wed, 19 Jan 2011 22:27:17 -0700 |
parents | |
children | 7317fbe024af |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2c24602be78f |
---|---|
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 "lwasm.h" | |
26 #include "instab.h" | |
27 | |
28 PARSEFUNC(insn_parse_rlist) | |
29 { | |
30 int rb = 0; | |
31 int rn; | |
32 static const char *regs = "CCA B DPX Y U PCD S "; | |
33 | |
34 while (**p && !isspace(**p)) | |
35 { | |
36 rn = lwasm_lookupreg2(regs, p); | |
37 if (rn < 0) | |
38 { | |
39 lwasm_register_error(as, l, "Bad register '%s'", *p); | |
40 return; | |
41 } | |
42 if (**p && **p != ',' && !isspace(**p)) | |
43 { | |
44 lwasm_register_error(as, l, "Bad operand"); | |
45 } | |
46 if (**p == ',') | |
47 (*p)++; | |
48 if (rn == 8) | |
49 rn = 6; | |
50 else if (rn == 9) | |
51 rn = 0x40; | |
52 else | |
53 rn = 1 << rn; | |
54 rb |= rn; | |
55 } | |
56 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1; | |
57 l -> pb = rb; | |
58 } | |
59 | |
60 EMITFUNC(insn_emit_rlist) | |
61 { | |
62 lwasm_emitop(l, instab[l -> insn].ops[0]); | |
63 lwasm_emit(l, l -> pb); | |
64 } |