annotate lwasm/insn_rtor.c @ 200:3f9d299d2477

Fixed crash on unrecognized pragma
author lost
date Sun, 22 Mar 2009 19:26:26 +0000
parents 427e268e876b
children bae1e3ecdce1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
1 /*
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
2 insn_rtor.c
33
74a3fef7c8d0 Added general addressing modes (immediate, base page, extended, indexed)
lost
parents: 32
diff changeset
3 Copyright © 2009 William Astle
27
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
4
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
5 This file is part of LWASM.
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
6
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
10 version.
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
11
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
15 more details.
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
16
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
19 */
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
20
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
21 /*
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
22 for handling register to register mode instructions
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
23 */
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
24
32
9bd0fbfe7405 Added basic indexed mode handling
lost
parents: 27
diff changeset
25 #define __insn_rtor_c_seen__
27
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
26
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
27 #include "lwasm.h"
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
28 #include "instab.h"
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
29
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
30 OPFUNC(insn_rtor)
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
31 {
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
32 int r0, r1;
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
33 static const char *regs = "D X Y U S PCW V A B CCDP0 0 E F ";
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
34
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
35 lwasm_emitop(as, l, instab[opnum].ops[0]);
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
36 // register to register (r0,r1)
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
37 // registers are in order:
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
38 // D,X,Y,U,S,PC,W,V
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
39 // A,B,CC,DP,0,0,E,F
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
40 r0 = lwasm_lookupreg2(regs, p);
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
41 if (r0 < 0 || *(*p)++ != ',')
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
42 {
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
43 register_error(as, l, 1, "Bad operand");
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
44 r0 = r1 = 0;
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
45 }
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
46 else
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
47 {
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
48 r1 = lwasm_lookupreg2(regs, p);
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
49 if (r1 < 0)
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
50 {
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
51 register_error(as, l, 1, "Bad operand");
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
52 r0 = r1 = 0;
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
53 }
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
54 }
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
55 lwasm_emit(as, l, (r0 << 4) | r1);
f736579569b4 Added handlers for inherent and register to register instructions
lost
parents:
diff changeset
56 }