annotate src/insn_rlist.c @ 245:eb499c146c0d 2.x

Fixed selection of objects for inclusion from within libraries to actually resolve references correctly
author lost
date Thu, 19 Nov 2009 00:51:31 +0000
parents 9bd0fbfe7405
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
1 /*
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
2 insn_rlist.c
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
3 Copyright © 2009 William Astle
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
4
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
5 This file is part of LWASM.
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
6
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
10 version.
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
11
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
15 more details.
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
16
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
19 */
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
20
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
21 /*
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
22 for handling inherent mode instructions
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
23 */
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
24
32
9bd0fbfe7405 Added basic indexed mode handling
lost
parents: 28
diff changeset
25 #define __insn_rlist_c_seen__
28
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
26
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
27 #include "lwasm.h"
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
28 #include "instab.h"
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
29
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
30 OPFUNC(insn_rlist)
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
31 {
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
32 int rb = 0;
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
33 int rn;
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
34 static const char *regs = "CCA B DPX Y U PCD S ";
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
35
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
36 lwasm_emitop(as, l, instab[opnum].ops[0]);
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
37 while (**p && !isspace(**p))
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
38 {
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
39 rn = lwasm_lookupreg2(regs, p);
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
40 if (rn < 0)
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
41 {
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
42 register_error(as, l, 1, "Bad register '%s'", *p);
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
43 lwasm_emit(as, l, 0);
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
44 return;
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
45 }
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
46 if (**p && **p != ',' && !isspace(**p))
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
47 {
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
48 register_error(as, l, 1, "Bad operand");
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
49 lwasm_emit(as, l, 0);
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
50 }
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
51 if (**p == ',')
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
52 (*p)++;
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
53 if (rn == 8)
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
54 rn = 6;
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
55 else if (rn == 9)
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
56 rn = 0x40;
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
57 else
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
58 rn = 1 << rn;
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
59 rb |= rn;
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
60 }
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
61 lwasm_emit(as, l, rb);
c0ff62e5ad39 Added register list mode handler
lost
parents:
diff changeset
62 }