comparison lwasm/insn_rtor.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 3a5f718b24c1
comparison
equal deleted inserted replaced
-1:000000000000 0:2c24602be78f
1 /*
2 insn_rtor.c
3 Copyright © 2010 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 #include "lwasm.h"
23 #include "instab.h"
24
25 PARSEFUNC(insn_parse_rtor)
26 {
27 int r0, r1;
28
29 static const char *regs = "D X Y U S PCW V A B CCDP0 0 E F ";
30 static const char *regs9 = "D X Y U S PC A B CCDP ";
31
32 // register to register (r0,r1)
33 // registers are in order:
34 // D,X,Y,U,S,PC,W,V
35 // A,B,CC,DP,0,0,E,F
36
37 r0 = lwasm_lookupreg2((as -> target == TARGET_6309) ? regs9 : regs, p);
38 if (r0 < 0 || *(*p)++ != ',')
39 {
40 lwasm_register_error(as, l, "Bad operand");
41 r0 = r1 = 0;
42 }
43 else
44 {
45 r1 = lwasm_lookupreg2((as -> target = TARGET_6309) ? regs9 : regs, p);
46 if (r1 < 0)
47 {
48 lwasm_register_error(as, l, "Bad operand");
49 r0 = r1 = 0;
50 }
51 }
52 l -> pb = (r0 << 4) | r1;
53 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;
54 }
55
56 EMITFUNC(insn_emit_rtor)
57 {
58 lwasm_emitop(l, instab[l -> insn].ops[0]);
59 lwasm_emit(l, l -> pb);
60 }