annotate lwasm/insn_rlist.c @ 407:b2e007c28b8f

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