annotate lwasm/insn_gen.c @ 390:027d7fbcdcfc

Basic symbol table output; needs work for non-constant symbols
author lost@l-w.ca
date Wed, 14 Jul 2010 22:46:56 -0600
parents 848d3cca8078
children b8549694b4c9
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_gen.c, Copyright © 2009 William Astle
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
3
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
4 This file is part of LWASM.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
5
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
6 LWASM is free software: you can redistribute it and/or modify it under the
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
7 terms of the GNU General Public License as published by the Free Software
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
8 Foundation, either version 3 of the License, or (at your option) any later
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
9 version.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
10
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
11 This program is distributed in the hope that it will be useful, but WITHOUT
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
14 more details.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
15
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
16 You should have received a copy of the GNU General Public License along with
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
17 this program. If not, see <http://www.gnu.org/licenses/>.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
18
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
19 Contains code for parsing general addressing modes (IMM+DIR+EXT+IND)
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 #include <config.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
23
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
24 #include <ctype.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
25 #include <stdlib.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
26
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
27 #include <lw_expr.h>
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
28
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
29 #include "lwasm.h"
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
30 #include "instab.h"
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
31
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
32 extern void insn_indexed_parse_aux(asmstate_t *as, line_t *l, char **p);
382
eacdae8a1575 Various bugfixes
lost@starbug
parents: 362
diff changeset
33 extern void insn_indexed_resolve_aux(asmstate_t *as, line_t *l, int force, int elen);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
34 extern void insn_indexed_emit_aux(asmstate_t *as, line_t *l);
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
35
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
36 // "extra" is required due to the way OIM, EIM, TIM, and AIM work
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
37 void insn_parse_gen_aux(asmstate_t *as, line_t *l, char **p)
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
38 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
39 const char *optr2;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
40 int v1, tv, rval;
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
41 lw_expr_t *s;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
42
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
43 optr2 = *p;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
44 while (*optr2 && !isspace(*optr2) && *optr2 != ',') optr2++
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
45 /* do nothing */ ;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
46
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
47 if (*optr2 == ',' || **p == '[')
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
48 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
49 l -> lint = -1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
50 l -> lint2 = 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
51 insn_parse_indexed_aux(as, l, p);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
52 goto out;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
53 }
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
54
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
55 if (**p == '<')
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
56 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
57 (*p)++;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
58 l -> lint2 = 0;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
59 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
60
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
61 // for compatibility with asxxxx
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
62 // * followed by a digit, alpha, or _, or ., or ?, or another * is "f8"
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
63 else if (**p == '*')
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
64 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
65 tv = *(*p + 1);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
66 if (isdigit(tv) || isalpha(tv) || tv == '_' || tv == '.' || tv == '?' || tv == '@' || tv == '*' || tv == '+' || tv == '-')
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
67 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
68 l -> lint2 = 0;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
69 (*p)++;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
70 }
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
71 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
72 else if (**p == '>')
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
73 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
74 (*p)++;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
75 l -> lint2 = 2;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
76 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
77 else
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
78 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
79 l -> lint2 = -1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
80 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
81
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
82 s = lwasm_parse_expr(as, p);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
83 if (!s)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
84 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
85 lwasm_register_error(as, l, "Bad operand");
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
86 return;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
87 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
88
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
89 lwasm_save_expr(l, 0, s);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
90
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
91 if (as -> output_format == OUTPUT_OBJ && l -> lint2 == -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
92 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
93 l -> lint2 = 2;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
94 goto out;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
95 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
96
383
848d3cca8078 Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents: 382
diff changeset
97 if (l -> lint2 != -1)
848d3cca8078 Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents: 382
diff changeset
98 goto out;
848d3cca8078 Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents: 382
diff changeset
99
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
100 // if we have a constant now, figure out dp vs nondp
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
101 if (lw_expr_istype(s, lw_expr_type_int))
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
102 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
103 v1 = lw_expr_intval(s);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
104 if (((v1 >> 8) & 0xff) == (l -> dpval & 0xff))
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
105 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
106 l -> lint2 = 0;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
107 goto out;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
108 }
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
109 l -> lint2 = 2;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
110 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
111
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
112 out:
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
113 if (l -> lint2 != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
114 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
115 if (l -> lint2 == 0)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
116 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
117 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
118 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
119 else if (l -> lint2 == 2)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
120 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
121 l -> len = OPLEN(instab[l -> insn].ops[2]) + 2;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
122 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
123 else if (l -> lint2 == 1 && l -> lint != -1)
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
124 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
125 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
126 }
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
127 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
128 }
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
129
382
eacdae8a1575 Various bugfixes
lost@starbug
parents: 362
diff changeset
130 void insn_resolve_gen_aux(asmstate_t *as, line_t *l, int force, int elen)
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
131 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
132 lw_expr_t *e;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
133
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
134 if (l -> lint2 == 1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
135 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
136 // indexed
382
eacdae8a1575 Various bugfixes
lost@starbug
parents: 362
diff changeset
137 insn_resolve_indexed_aux(as, l, force, elen);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
138 goto out;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
139 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
140
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
141 if (l -> lint2 != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
142 return;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
143
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
144 e = lwasm_fetch_expr(l, 0);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
145 if (lw_expr_istype(e, lw_expr_type_int))
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
146 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
147 int v;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
148
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
149 v = lw_expr_intval(e);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
150
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
151 if (((v >> 8) & 0xff) == (l -> dpval & 0xff))
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
152 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
153 l -> lint2 = 0;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
154 goto out;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
155 }
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
156 l -> lint2 = 2;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
157 goto out;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
158 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
159
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
160 if (force)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
161 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
162 l -> lint2 = 2;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
163 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
164
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
165 out:
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
166 if (l -> lint2 != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
167 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
168 if (l -> lint2 == 0)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
169 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
170 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
171 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
172 else if (l -> lint2 == 2)
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
173 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
174 l -> len = OPLEN(instab[l -> insn].ops[2]) + 2;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
175 }
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
176 else if (l -> lint2 == 1 && l -> lint != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
177 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
178 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
179 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
180 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
181 }
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
182
362
4867f18c872f Added logic memory operands
lost@starbug
parents: 361
diff changeset
183 void insn_emit_gen_aux(asmstate_t *as, line_t *l, int extra)
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
184 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
185 lw_expr_t e;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
186
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
187 e = lwasm_fetch_expr(l, 0);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
188 lwasm_emitop(l, instab[l -> insn].ops[l -> lint2]);
362
4867f18c872f Added logic memory operands
lost@starbug
parents: 361
diff changeset
189
4867f18c872f Added logic memory operands
lost@starbug
parents: 361
diff changeset
190 if (extra != -1)
4867f18c872f Added logic memory operands
lost@starbug
parents: 361
diff changeset
191 lwasm_emit(l, extra);
4867f18c872f Added logic memory operands
lost@starbug
parents: 361
diff changeset
192
382
eacdae8a1575 Various bugfixes
lost@starbug
parents: 362
diff changeset
193 if (l -> lint2 == 1)
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
194 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
195 lwasm_emit(l, l -> pb);
382
eacdae8a1575 Various bugfixes
lost@starbug
parents: 362
diff changeset
196 if (l -> lint > 0)
eacdae8a1575 Various bugfixes
lost@starbug
parents: 362
diff changeset
197 lwasm_emitexpr(l, e, l -> lint);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
198 return;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
199 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
200
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
201 if (l -> lint2 == 2)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
202 lwasm_emitexpr(l, e, 2);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
203 else
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
204 lwasm_emitexpr(l, e, 1);
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
205 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
206
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
207 // the various insn_gen? functions have an immediate mode of ? bits
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
208 PARSEFUNC(insn_parse_gen0)
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
209 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
210 if (**p == '#')
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
211 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
212 lwasm_register_error(as, l, "Immediate mode not allowed");
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
213 return;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
214 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
215
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
216 // handle non-immediate
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
217 insn_parse_gen_aux(as, l, p);
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
218 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
219
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
220 RESOLVEFUNC(insn_resolve_gen0)
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
221 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
222 if (l -> len != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
223 return;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
224
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
225 // handle non-immediate
382
eacdae8a1575 Various bugfixes
lost@starbug
parents: 362
diff changeset
226 insn_resolve_gen_aux(as, l, force, 0);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
227 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
228
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
229 EMITFUNC(insn_emit_gen0)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
230 {
362
4867f18c872f Added logic memory operands
lost@starbug
parents: 361
diff changeset
231 insn_emit_gen_aux(as, l, -1);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
232 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
233
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
234 PARSEFUNC(insn_parse_gen8)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
235 {
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
236 if (**p == '#')
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
237 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
238 lw_expr_t e;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
239
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
240 (*p)++;
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
241 e = lwasm_parse_expr(as, p);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
242 if (!e)
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
243 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
244 lwasm_register_error(as, l, "Bad operand");
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
245 return;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
246 }
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
247 l -> len = OPLEN(instab[l -> insn].ops[3]) + 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
248 l -> lint2 = 3;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
249 lwasm_save_expr(l, 0, e);
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
250 return;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
251 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
252
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
253 // handle non-immediate
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
254 insn_parse_gen_aux(as, l, p);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
255 if (l -> lint2 != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
256 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
257 if (l -> lint2 == 0)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
258 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
259 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
260 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
261 else if (l -> lint2 == 2)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
262 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
263 l -> len = OPLEN(instab[l -> insn].ops[2]) + 2;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
264 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
265 else if (l -> lint2 == 1 && l -> lint != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
266 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
267 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
268 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
269 }
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
270 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
271
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
272 RESOLVEFUNC(insn_resolve_gen8)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
273 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
274 if (l -> len != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
275 return;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
276
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
277 // handle non-immediate
382
eacdae8a1575 Various bugfixes
lost@starbug
parents: 362
diff changeset
278 insn_resolve_gen_aux(as, l, force, 0);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
279 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
280
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
281 EMITFUNC(insn_emit_gen8)
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
282 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
283 if (l -> lint2 == 3)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
284 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
285 lw_expr_t e;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
286 e = lwasm_fetch_expr(l, 0);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
287 lwasm_emitop(l, instab[l -> insn].ops[3]);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
288 lwasm_emitexpr(l, e, 1);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
289 return;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
290 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
291
362
4867f18c872f Added logic memory operands
lost@starbug
parents: 361
diff changeset
292 insn_emit_gen_aux(as, l, -1);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
293 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
294
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
295 PARSEFUNC(insn_parse_gen16)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
296 {
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
297 if (**p == '#')
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
298 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
299 lw_expr_t e;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
300
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
301 (*p)++;
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
302 e = lwasm_parse_expr(as, p);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
303 if (!e)
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
304 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
305 lwasm_register_error(as, l, "Bad operand");
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
306 return;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
307 }
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
308 l -> len = OPLEN(instab[l -> insn].ops[3]) + 2;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
309 l -> lint2 = 3;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
310 lwasm_save_expr(l, 0, e);
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
311 return;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
312 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
313
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
314 // handle non-immediate
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
315 insn_parse_gen_aux(as, l, p);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
316 if (l -> lint2 != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
317 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
318 if (l -> lint2 == 0)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
319 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
320 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
321 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
322 else if (l -> lint2 == 2)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
323 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
324 l -> len = OPLEN(instab[l -> insn].ops[2]) + 2;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
325 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
326 else if (l -> lint2 == 1 && l -> lint != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
327 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
328 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
329 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
330 }
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
331 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
332
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
333 RESOLVEFUNC(insn_resolve_gen16)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
334 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
335 if (l -> len != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
336 return;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
337
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
338 // handle non-immediate
382
eacdae8a1575 Various bugfixes
lost@starbug
parents: 362
diff changeset
339 insn_resolve_gen_aux(as, l, force, 0);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
340 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
341
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
342 EMITFUNC(insn_emit_gen16)
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
343 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
344 if (l -> lint2 == 3)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
345 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
346 lw_expr_t e;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
347 e = lwasm_fetch_expr(l, 0);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
348 lwasm_emitop(l, instab[l -> insn].ops[3]);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
349 lwasm_emitexpr(l, e, 2);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
350 return;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
351 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
352
362
4867f18c872f Added logic memory operands
lost@starbug
parents: 361
diff changeset
353 insn_emit_gen_aux(as, l, -1);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
354 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
355
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
356 PARSEFUNC(insn_parse_gen32)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
357 {
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
358 if (**p == '#')
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
359 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
360 lw_expr_t e;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
361
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
362 (*p)++;
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
363 e = lwasm_parse_expr(as, p);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
364 if (!e)
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
365 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
366 lwasm_register_error(as, l, "Bad operand");
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
367 return;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
368 }
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
369 l -> len = OPLEN(instab[l -> insn].ops[3]) + 4;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
370 l -> lint2 = 3;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
371 lwasm_save_expr(l, 0, e);
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
372 return;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
373 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
374
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
375 // handle non-immediate
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
376 insn_parse_gen_aux(as, l, p);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
377 if (l -> lint2 != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
378 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
379 if (l -> lint2 == 0)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
380 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
381 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
382 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
383 else if (l -> lint2 == 2)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
384 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
385 l -> len = OPLEN(instab[l -> insn].ops[2]) + 2;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
386 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
387 else if (l -> lint2 == 1 && l -> lint != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
388 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
389 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
390 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
391 }
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
392 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
393
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
394 RESOLVEFUNC(insn_resolve_gen32)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
395 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
396 if (l -> len != -1)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
397 return;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
398
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
399 // handle non-immediate
382
eacdae8a1575 Various bugfixes
lost@starbug
parents: 362
diff changeset
400 insn_resolve_gen_aux(as, l, force, 0);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
401 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
402
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
403 EMITFUNC(insn_emit_gen32)
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
404 {
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
405 if (l -> lint2 == 3)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
406 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
407 lw_expr_t e;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
408 e = lwasm_fetch_expr(l, 0);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
409 lwasm_emitop(l, instab[l -> insn].ops[3]);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
410 lwasm_emitexpr(l, e, 4);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
411 return;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
412 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
413
362
4867f18c872f Added logic memory operands
lost@starbug
parents: 361
diff changeset
414 insn_emit_gen_aux(as, l, -1);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
415 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
416
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
417 PARSEFUNC(insn_parse_imm8)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
418 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
419 lw_expr_t e;
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
420
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
421 if (**p == '#')
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
422 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
423 (*p)++;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
424
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
425 e = lwasm_parse_expr(as, p);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
426 if (!e)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
427 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
428 lwasm_register_error(as, l, "Bad operand");
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
429 return;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
430 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
431 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
432 lwasm_save_expr(l, 0, e);
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
433 }
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
434 }
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
435
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
436 EMITFUNC(insn_emit_imm8)
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
437 {
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
438 lw_expr_t e;
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
439
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
440 lwasm_emitop(l, instab[l -> insn].ops[0]);
383
848d3cca8078 Fixed imm8 to actually use expression and also fixed gen mode to respect > and <
lost@starbug
parents: 382
diff changeset
441 e = lwasm_fetch_expr(l, 0);
361
105393e31f20 Generic memory mode insns
lost@starbug
parents: 339
diff changeset
442 lwasm_emitexpr(l, e, 1);
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
443 }