annotate lwasm/pseudo.c @ 354:60568b123281

Added os9 opcodes and ERROR
author lost@starbug
date Tue, 30 Mar 2010 23:10:01 -0600
parents 4dba8c7e242c
children 7166254491ed
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 }
350
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
509
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
510 PARSEFUNC(pseudo_parse_org)
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
511 {
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
512 lw_expr_t e;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
513
351
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
514 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
515
350
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
516 e = lwasm_parse_expr(as, p);
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
517 if (!e)
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
518 {
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
519 lwasm_register_error(as, l, "Bad operand");
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
520 return;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
521 }
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
522
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
523 lw_expr_destroy(l -> addr);
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
524 l -> addr = e;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
525 l -> len = 0;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
526 }
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
527
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
528 PARSEFUNC(pseudo_parse_equ)
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
529 {
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
530 lw_expr_t e;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
531
351
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
532 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
533
350
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
534 if (!(l -> sym))
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
535 {
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
536 lwasm_register_error(as, l, "Missing symbol");
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
537 return;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
538 }
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
539
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
540 e = lwasm_parse_expr(as, p);
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
541 if (!e)
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
542 {
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
543 lwasm_register_error(as, l, "Bad operand");
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
544 return;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
545 }
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
546
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
547 register_symbol(as, l, l -> sym, e, symbol_flag_none);
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
548 l -> symset = 1;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
549 }
351
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
550
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
551 PARSEFUNC(pseudo_parse_set)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
552 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
553 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
554
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
555 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
556
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
557 if (!(l -> sym))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
558 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
559 lwasm_register_error(as, l, "Missing symbol");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
560 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
561 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
562
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
563 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
564 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
565 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
566 lwasm_register_error(as, l, "Bad operand");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
567 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
568 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
569
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
570 register_symbol(as, l, l -> sym, e, symbol_flag_set);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
571 l -> symset = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
572 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
573
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
574 PARSEFUNC(pseudo_parse_setdp)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
575 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
576 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
577
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
578 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
579
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
580 if (as -> output_format == OUTPUT_OBJ)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
581 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
582 lwasm_register_error(as, l, "SETDP not permitted for object target");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
583 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
584 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
585
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
586 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
587 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
588 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
589 lwasm_register_error(as, l, "Bad operand");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
590 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
591 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
592
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
593 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
594 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
595 lwasm_register_error(as, l, "SETDP must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
596 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
597 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
598 l -> dpval = lw_expr_intval(e) & 0xff;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
599 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
600
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
601 PARSEFUNC(pseudo_parse_ifp1)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
602 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
603 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
604
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
605 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
606 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
607 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
608 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
609 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
610 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
611
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
612 lwasm_register_warning(as, l, "IFP1 if is not supported; ignoring");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
613
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
614 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
615
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
616 PARSEFUNC(pseudo_parse_ifp2)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
617 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
618 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
619
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
620 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
621 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
622 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
623 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
624 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
625 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
626
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
627 lwasm_register_warning(as, l, "IFP2 if is not supported; ignoring");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
628 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
629
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
630 PARSEFUNC(pseudo_parse_ifeq)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
631 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
632 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
633
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
634 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
635
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
636 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
637 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
638 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
639 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
640 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
641 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
642
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
643 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
644 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
645 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
646 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
647 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
648 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
649 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
650 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
651 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
652 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
653 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
654 if (lw_expr_intval(e) != 0)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
655 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
656 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
657 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
658 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
659 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
660
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
661 PARSEFUNC(pseudo_parse_ifne)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
662 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
663 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
664
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
665 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
666
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
667 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
668 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
669 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
670 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
671 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
672 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
673
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
674 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
675 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
676 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
677 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
678 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
679 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
680 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
681 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
682 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
683 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
684 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
685 if (lw_expr_intval(e) == 0)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
686 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
687 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
688 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
689 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
690 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
691
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
692
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
693 PARSEFUNC(pseudo_parse_ifgt)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
694 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
695 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
696
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
697 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
698
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
699 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
700 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
701 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
702 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
703 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
704 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
705
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
706 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
707 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
708 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
709 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
710 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
711 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
712 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
713 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
714 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
715 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
716 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
717 if (lw_expr_intval(e) <= 0)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
718 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
719 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
720 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
721 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
722 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
723
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
724 PARSEFUNC(pseudo_parse_ifge)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
725 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
726 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
727
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
728 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
729
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
730 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
731 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
732 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
733 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
734 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
735 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
736
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
737 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
738 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
739 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
740 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
741 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
742 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
743 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
744 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
745 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
746 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
747 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
748 if (lw_expr_intval(e) < 0)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
749 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
750 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
751 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
752 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
753 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
754
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
755 PARSEFUNC(pseudo_parse_iflt)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
756 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
757 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
758
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
759 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
760
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
761 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
762 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
763 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
764 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
765 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
766 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
767
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
768 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
769 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
770 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
771 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
772 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
773 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
774 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
775 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
776 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
777 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
778 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
779 if (lw_expr_intval(e) >= 0)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
780 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
781 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
782 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
783 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
784 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
785
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
786 PARSEFUNC(pseudo_parse_ifle)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
787 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
788 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
789
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
790 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
791
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
792 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
793 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
794 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
795 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
796 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
797 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
798
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
799 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
800 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
801 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
802 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
803 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
804 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
805 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
806 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
807 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
808 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
809 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
810 if (lw_expr_intval(e) > 0)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
811 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
812 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
813 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
814 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
815 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
816
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
817 PARSEFUNC(pseudo_parse_endc)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
818 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
819 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
820 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
821 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
822 as -> skipcount--;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
823 if (as -> skipcount < 0)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
824 as -> skipcond = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
825 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
826 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
827
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
828 PARSEFUNC(pseudo_parse_else)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
829 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
830 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
831
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
832 if (as -> skipmacro)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
833 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
834
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
835 if (as -> skipcond)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
836 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
837 if (as -> skipcount == 1)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
838 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
839 as -> skipcount = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
840 as -> skipcond = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
841 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
842 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
843 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
844 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
845 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
846 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
847
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
848 PARSEFUNC(pseudo_parse_ifdef)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
849 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
850 char *sym;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
851 int i;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
852 struct symtabe *s;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
853
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
854 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
855
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
856 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
857 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
858 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
859 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
860 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
861 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
862
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
863 for (i = 0; (*p)[i] && !isspace((*p)[i]); i++)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
864 /* do nothing */ ;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
865
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
866 sym = lw_strndup(*p, i);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
867
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
868 s = lookup_symbol(as, l, sym, -1, -1);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
869
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
870 lw_free(sym);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
871
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
872 if (!s)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
873 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
874 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
875 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
876 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
877 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
878
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
879 PARSEFUNC(pseudo_parse_ifndef)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
880 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
881 char *sym;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
882 int i;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
883 struct symtabe *s;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
884
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
885 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
886
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
887 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
888 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
889 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
890 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
891 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
892 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
893
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
894 for (i = 0; (*p)[i] && !isspace((*p)[i]); i++)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
895 /* do nothing */ ;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
896
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
897 sym = lw_strndup(*p, i);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
898
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
899 s = lookup_symbol(as, l, sym, -1, -1);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
900
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
901 lw_free(sym);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
902
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
903 if (s)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
904 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
905 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
906 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
907 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
908 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
909
354
60568b123281 Added os9 opcodes and ERROR
lost@starbug
parents: 351
diff changeset
910 PARSEFUNC(pseudo_parse_error)
60568b123281 Added os9 opcodes and ERROR
lost@starbug
parents: 351
diff changeset
911 {
60568b123281 Added os9 opcodes and ERROR
lost@starbug
parents: 351
diff changeset
912 lwasm_register_error(as, l, "User error: %s", *p);
60568b123281 Added os9 opcodes and ERROR
lost@starbug
parents: 351
diff changeset
913 skip_operand(p);
60568b123281 Added os9 opcodes and ERROR
lost@starbug
parents: 351
diff changeset
914 }