Mercurial > hg-old > index.cgi
annotate src/insn_tfm.c @ 235:aa0056ca7319
Added a padding value for the ALIGN directive
author | lost |
---|---|
date | Fri, 12 Jun 2009 05:25:41 +0000 |
parents | 74a3fef7c8d0 |
children |
rev | line source |
---|---|
31 | 1 /* |
2 insn_tfm.c | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
32
diff
changeset
|
3 Copyright © 2009 William Astle |
31 | 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 inherent mode instructions | |
23 */ | |
24 | |
32 | 25 #define __insn_tfm_c_seen__ |
31 | 26 |
27 #include <ctype.h> | |
28 #include <string.h> | |
29 | |
30 #include "lwasm.h" | |
31 #include "instab.h" | |
32 | |
33 OPFUNC(insn_tfm) | |
34 { | |
35 static const char *reglist = "DXYUS AB 00EF"; | |
36 int r0, r1; | |
37 char *c; | |
38 int tfm = 0; | |
39 | |
40 c = strchr(reglist, toupper(*(*p)++)); | |
41 if (!c) | |
42 { | |
43 register_error(as, l, 1, "Unknown operation"); | |
44 return; | |
45 } | |
46 r0 = c - reglist; | |
47 if (**p == '+') | |
48 { | |
49 (*p)++; | |
50 tfm = 1; | |
51 } | |
52 else if (**p == '-') | |
53 { | |
54 (*p)++; | |
55 tfm = 2; | |
56 } | |
57 if (*(*p)++ != ',') | |
58 { | |
59 register_error(as, l, 1, "Unknown operation"); | |
60 return; | |
61 } | |
62 c = strchr(reglist, toupper(*(*p)++)); | |
63 if (!c) | |
64 { | |
65 register_error(as, l, 1, "Unknown operation"); | |
66 return; | |
67 } | |
68 r1 = c - reglist; | |
69 | |
70 if (**p == '+') | |
71 { | |
72 (*p)++; | |
73 tfm |= 4; | |
74 } | |
75 else if (**p == '-') | |
76 { | |
77 (*p)++; | |
78 tfm |= 8; | |
79 } | |
80 | |
81 if (**p && !isspace(**p)) | |
82 { | |
83 register_error(as, l, 1, "Bad operand"); | |
84 return; | |
85 } | |
86 | |
87 // valid values of tfm here are: | |
88 // 1: r0+,r1 (2) | |
89 // 4: r0,r1+ (3) | |
90 // 5: r0+,r1+ (0) | |
91 // 10: r0-,r1- (1) | |
92 switch (tfm) | |
93 { | |
94 case 5: //r0+,r1+ | |
95 lwasm_emitop(as, l, instab[opnum].ops[0]); | |
96 break; | |
97 case 10: //r0-,r1- | |
98 lwasm_emitop(as, l, instab[opnum].ops[1]); | |
99 break; | |
100 case 1: // r0+,r1 | |
101 lwasm_emitop(as, l, instab[opnum].ops[2]); | |
102 break; | |
103 case 4: // r0,r1+ | |
104 lwasm_emitop(as, l, instab[opnum].ops[3]); | |
105 break; | |
106 default: | |
107 register_error(as, l, 1, "Unknown operation"); | |
108 return; | |
109 } | |
110 lwasm_emit(as, l, (r0 << 4) | r1); | |
111 } |