annotate lwasm/pseudo.c @ 349:dcd2978a7d18

More pseudo ops
author lost@starbug
date Sat, 27 Mar 2010 22:44:46 -0600
parents 11a95c6414b4
children f5666775d76f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
1 /*
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
2 pseudo.c
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
3 Copyright © 2010 William Astle
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
4
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
5 This file is part of LWASM.
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
6
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
10 version.
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
11
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
15 more details.
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
16
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
19
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
20 */
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
21
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
22 #include <config.h>
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
23
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
24 #include "lwasm.h"
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
25 #include "instab.h"
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
26
349
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
27 #include "lw_string.h"
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
28
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
29 // for "end"
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
30 PARSEFUNC(pseudo_parse_end)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
31 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
32 lw_expr_t addr;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
33
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
34 as -> endseen = 1;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
35
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
36 if (as -> output_format != OUTPUT_DECB)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
37 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
38 skip_operand(p);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
39 return;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
40 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
41
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
42 addr = lwasm_parse_expr(as, p);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
43 if (!addr)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
44 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
45 lwasm_register_error(as, l, "Bad expression");
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
46 addr = lw_expr_build(lw_expr_type_int, 0);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
47 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
48 lwasm_save_expr(l, 0, addr);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
49 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
50
348
11a95c6414b4 Added third func to instab to split resolve and emit logic
lost@starbug
parents: 347
diff changeset
51 EMITFUNC(pseudo_emit_end)
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
52 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
53 lw_expr_t addr;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
54
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
55 addr = lwasm_fetch_expr(l, 0);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
56
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
57 if (addr)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
58 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
59 if (!lw_expr_istype(addr, lw_expr_type_int))
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
60 lwasm_register_error(as, l, "Exec address not constant!");
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
61 else
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
62 as -> execaddr = lw_expr_intval(addr);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
63 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
64 as -> endseen = 1;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
65 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
66
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
67 PARSEFUNC(pseudo_parse_fcb)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
68 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
69 int i = 0;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
70 lw_expr_t e;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
71
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
72 for (;;)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
73 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
74 e = lwasm_parse_expr(as, p);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
75 if (!e)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
76 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
77 lwasm_register_error(as, l, "Bad expression (#%s)", i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
78 break;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
79 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
80 lwasm_save_expr(l, i, e);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
81 i++;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
82 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
83
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
84 l -> len = i;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
85 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
86
348
11a95c6414b4 Added third func to instab to split resolve and emit logic
lost@starbug
parents: 347
diff changeset
87 EMITFUNC(pseudo_emit_fcb)
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
88 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
89 int i;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
90 lw_expr_t e;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
91 int v;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
92
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
93 for (i = 0; i < l -> len; i++)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
94 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
95 e = lwasm_fetch_expr(l, i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
96 lwasm_emitexpr(l, e, 1);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
97 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
98 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
99
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
100 PARSEFUNC(pseudo_parse_fdb)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
101 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
102 int i = 0;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
103 lw_expr_t e;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
104
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
105 for (;;)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
106 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
107 e = lwasm_parse_expr(as, p);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
108 if (!e)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
109 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
110 lwasm_register_error(as, l, "Bad expression (#%s)", i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
111 break;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
112 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
113 lwasm_save_expr(l, i, e);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
114 i++;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
115 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
116
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
117 l -> len = i * 2;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
118 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
119
348
11a95c6414b4 Added third func to instab to split resolve and emit logic
lost@starbug
parents: 347
diff changeset
120 EMITFUNC(pseudo_emit_fdb)
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
121 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
122 int i;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
123 lw_expr_t e;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
124 int v;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
125
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
126 for (i = 0; i < (l -> len)/2; i++)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
127 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
128 e = lwasm_fetch_expr(l, i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
129 lwasm_emitexpr(l, e, 2);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
130 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
131 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
132
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
133 PARSEFUNC(pseudo_parse_fqb)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
134 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
135 int i = 0;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
136 lw_expr_t e;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
137
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
138 for (;;)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
139 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
140 e = lwasm_parse_expr(as, p);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
141 if (!e)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
142 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
143 lwasm_register_error(as, l, "Bad expression (#%s)", i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
144 break;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
145 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
146 lwasm_save_expr(l, i, e);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
147 i++;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
148 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
149
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
150 l -> len = i * 4;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
151 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
152
348
11a95c6414b4 Added third func to instab to split resolve and emit logic
lost@starbug
parents: 347
diff changeset
153 EMITFUNC(pseudo_emit_fqb)
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
154 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
155 int i;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
156 lw_expr_t e;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
157 int v;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
158
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
159 for (i = 0; i < (l -> len)/4; i++)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
160 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
161 e = lwasm_fetch_expr(l, i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
162 lwasm_emitexpr(l, e, 4);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
163 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
164 }
349
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
165
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
166 PARSEFUNC(pseudo_parse_fcc)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
167 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
168 char delim;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
169 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
170
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
171 if (!**p)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
172 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
173 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
174 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
175 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
176
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
177 delim = **p;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
178 (*p)++;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
179
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
180 for (i = 0; (*p)[i] && (*p)[i] != delim; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
181 /* do nothing */ ;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
182
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
183 if ((*p)[i] != delim)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
184 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
185 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
186 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
187 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
188
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
189 l -> lstr = lw_strndup(*p, i);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
190 (*p) += i + 1;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
191
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
192 l -> len = i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
193 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
194
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
195 EMITFUNC(pseudo_emit_fcc)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
196 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
197 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
198
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
199 for (i = 0; i < l -> len; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
200 lwasm_emit(l, l -> lstr[i]);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
201 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
202
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
203 PARSEFUNC(pseudo_parse_fcs)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
204 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
205 char delim;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
206 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
207
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
208 if (!**p)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
209 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
210 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
211 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
212 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
213
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
214 delim = **p;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
215 (*p)++;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
216
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
217 for (i = 0; (*p)[i] && (*p)[i] != delim; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
218 /* do nothing */ ;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
219
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
220 if ((*p)[i] != delim)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
221 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
222 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
223 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
224 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
225
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
226 l -> lstr = lw_strndup(*p, i);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
227 (*p) += i + 1;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
228
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
229 l -> len = i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
230 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
231
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
232 EMITFUNC(pseudo_emit_fcs)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
233 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
234 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
235
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
236 for (i = 0; i < l -> len - 1; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
237 lwasm_emit(l, l -> lstr[i]);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
238 lwasm_emit(l, l -> lstr[i] | 0x80);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
239 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
240
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
241 PARSEFUNC(pseudo_parse_fcn)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
242 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
243 char delim;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
244 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
245
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
246 if (!**p)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
247 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
248 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
249 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
250 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
251
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
252 delim = **p;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
253 (*p)++;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
254
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
255 for (i = 0; (*p)[i] && (*p)[i] != delim; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
256 /* do nothing */ ;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
257
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
258 if ((*p)[i] != delim)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
259 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
260 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
261 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
262 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
263
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
264 l -> lstr = lw_strndup(*p, i);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
265 (*p) += i + 1;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
266
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
267 l -> len = i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
268 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
269
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
270 EMITFUNC(pseudo_emit_fcn)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
271 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
272 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
273
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
274 for (i = 0; i < l -> len; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
275 lwasm_emit(l, l -> lstr[i]);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
276 lwasm_emit(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
277 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
278
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
279 PARSEFUNC(pseudo_parse_rmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
280 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
281 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
282
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
283 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
284 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
285 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
286 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
287 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
288
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
289 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
290 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
291
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
292 RESOLVEFUNC(pseudo_resolve_rmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
293 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
294 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
295
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
296 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
297 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
298
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
299 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
300
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
301 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
302 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
303 l -> len = lw_expr_intval(expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
304 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
305 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
306
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
307 EMITFUNC(pseudo_emit_rmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
308 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
309 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
310 lwasm_register_error(as, l, "Expression not constant");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
311 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
312
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
313 PARSEFUNC(pseudo_parse_rmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
314 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
315 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
316
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
317 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
318 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
319 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
320 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
321 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
322
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
323 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
324 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
325
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
326 RESOLVEFUNC(pseudo_resolve_rmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
327 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
328 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
329
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
330 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
331 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
332
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
333 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
334
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
335 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
336 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
337 l -> len = lw_expr_intval(expr) * 2;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
338 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
339 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
340
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
341 EMITFUNC(pseudo_emit_rmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
342 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
343 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
344 lwasm_register_error(as, l, "Expression not constant");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
345 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
346
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
347
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
348 PARSEFUNC(pseudo_parse_rmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
349 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
350 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
351
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
352 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
353 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
354 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
355 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
356 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
357
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
358 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
359 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
360
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
361 RESOLVEFUNC(pseudo_resolve_rmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
362 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
363 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
364
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
365 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
366 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
367
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
368 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
369
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
370 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
371 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
372 l -> len = lw_expr_intval(expr) * 4;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
373 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
374 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
375
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
376 EMITFUNC(pseudo_emit_rmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
377 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
378 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
379 lwasm_register_error(as, l, "Expression not constant");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
380 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
381
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
382
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
383 PARSEFUNC(pseudo_parse_zmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
384 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
385 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
386
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
387 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
388 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
389 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
390 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
391 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
392
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
393 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
394 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
395
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
396 RESOLVEFUNC(pseudo_resolve_zmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
397 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
398 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
399
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
400 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
401 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
402
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
403 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
404
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
405 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
406 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
407 l -> len = lw_expr_intval(expr) * 4;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
408 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
409 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
410
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
411 EMITFUNC(pseudo_emit_zmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
412 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
413 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
414
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
415 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
416 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
417 lwasm_register_error(as, l, "Expression not constant");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
418 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
419 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
420
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
421 for (i = 0; i < l -> len; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
422 lwasm_emit(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
423 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
424
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
425
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
426 PARSEFUNC(pseudo_parse_zmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
427 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
428 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
429
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
430 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
431 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
432 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
433 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
434 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
435
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
436 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
437 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
438
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
439 RESOLVEFUNC(pseudo_resolve_zmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
440 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
441 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
442
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
443 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
444 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
445
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
446 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
447
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
448 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
449 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
450 l -> len = lw_expr_intval(expr) * 2;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
451 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
452 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
453
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
454 EMITFUNC(pseudo_emit_zmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
455 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
456 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
457
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
458 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
459 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
460 lwasm_register_error(as, l, "Expression not constant");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
461 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
462 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
463
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
464 for (i = 0; i < l -> len; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
465 lwasm_emit(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
466 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
467
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
468 PARSEFUNC(pseudo_parse_zmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
469 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
470 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
471
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
472 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
473 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
474 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
475 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
476 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
477
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
478 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
479 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
480
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
481 RESOLVEFUNC(pseudo_resolve_zmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
482 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
483 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
484
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
485 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
486 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
487
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
488 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
489
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
490 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
491 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
492 l -> len = lw_expr_intval(expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
493 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
494 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
495
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
496 EMITFUNC(pseudo_emit_zmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
497 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
498 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
499
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
500 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
501 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
502 lwasm_register_error(as, l, "Expression not constant");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
503 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
504 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
505
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
506 for (i = 0; i < l -> len; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
507 lwasm_emit(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
508 }