comparison src/insn_rtor.c @ 27:f736579569b4

Added handlers for inherent and register to register instructions
author lost
date Fri, 02 Jan 2009 02:56:04 +0000
parents
children 9bd0fbfe7405
comparison
equal deleted inserted replaced
26:d2e86babd958 27:f736579569b4
1 /*
2 insn_rtor.c
3 Copyright © 2008 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 register to register mode instructions
23 */
24
25 #define __insn_inh_c_seen__
26
27 #include "lwasm.h"
28 #include "instab.h"
29
30 OPFUNC(insn_rtor)
31 {
32 int r0, r1;
33 static const char *regs = "D X Y U S PCW V A B CCDP0 0 E F ";
34
35 lwasm_emitop(as, l, instab[opnum].ops[0]);
36 // register to register (r0,r1)
37 // registers are in order:
38 // D,X,Y,U,S,PC,W,V
39 // A,B,CC,DP,0,0,E,F
40 r0 = lwasm_lookupreg2(regs, p);
41 if (r0 < 0 || *(*p)++ != ',')
42 {
43 register_error(as, l, 1, "Bad operand");
44 r0 = r1 = 0;
45 }
46 else
47 {
48 r1 = lwasm_lookupreg2(regs, p);
49 if (r1 < 0)
50 {
51 register_error(as, l, 1, "Bad operand");
52 r0 = r1 = 0;
53 }
54 }
55 lwasm_emit(as, l, (r0 << 4) | r1);
56 }