annotate lwasm/pseudo.c @ 370:6b33faa21a0a

Debugging output and bugfixing pass 0
author lost@starbug
date Tue, 20 Apr 2010 21:59:58 -0600
parents d96c30e60ddf
children eacdae8a1575
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
356
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
24 #include <stdio.h>
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
25
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
26 #include "lwasm.h"
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
27 #include "instab.h"
356
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
28 #include "input.h"
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
29
349
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
30 #include "lw_string.h"
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
31
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
32 // for "end"
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
33 PARSEFUNC(pseudo_parse_end)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
34 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
35 lw_expr_t addr;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
36
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
37 as -> endseen = 1;
370
6b33faa21a0a Debugging output and bugfixing pass 0
lost@starbug
parents: 363
diff changeset
38 l -> len = 0;
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
39
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
40 if (as -> output_format != OUTPUT_DECB)
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 skip_operand(p);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
43 return;
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
370
6b33faa21a0a Debugging output and bugfixing pass 0
lost@starbug
parents: 363
diff changeset
46 if (!**p)
6b33faa21a0a Debugging output and bugfixing pass 0
lost@starbug
parents: 363
diff changeset
47 {
6b33faa21a0a Debugging output and bugfixing pass 0
lost@starbug
parents: 363
diff changeset
48 addr = lw_expr_build(lw_expr_type_int, 0);
6b33faa21a0a Debugging output and bugfixing pass 0
lost@starbug
parents: 363
diff changeset
49 }
6b33faa21a0a Debugging output and bugfixing pass 0
lost@starbug
parents: 363
diff changeset
50 else
6b33faa21a0a Debugging output and bugfixing pass 0
lost@starbug
parents: 363
diff changeset
51 {
6b33faa21a0a Debugging output and bugfixing pass 0
lost@starbug
parents: 363
diff changeset
52 addr = lwasm_parse_expr(as, p);
6b33faa21a0a Debugging output and bugfixing pass 0
lost@starbug
parents: 363
diff changeset
53 }
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
54 if (!addr)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
55 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
56 lwasm_register_error(as, l, "Bad expression");
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
57 addr = lw_expr_build(lw_expr_type_int, 0);
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 lwasm_save_expr(l, 0, addr);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
60 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
61
348
11a95c6414b4 Added third func to instab to split resolve and emit logic
lost@starbug
parents: 347
diff changeset
62 EMITFUNC(pseudo_emit_end)
347
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 lw_expr_t addr;
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 addr = lwasm_fetch_expr(l, 0);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
67
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
68 if (addr)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
69 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
70 if (!lw_expr_istype(addr, lw_expr_type_int))
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
71 lwasm_register_error(as, l, "Exec address not constant!");
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
72 else
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
73 as -> execaddr = lw_expr_intval(addr);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
74 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
75 as -> endseen = 1;
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
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
78 PARSEFUNC(pseudo_parse_fcb)
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 int i = 0;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
81 lw_expr_t e;
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 for (;;)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
84 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
85 e = lwasm_parse_expr(as, p);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
86 if (!e)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
87 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
88 lwasm_register_error(as, l, "Bad expression (#%s)", i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
89 break;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
90 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
91 lwasm_save_expr(l, i, e);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
92 i++;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
93 }
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 l -> len = i;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
96 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
97
348
11a95c6414b4 Added third func to instab to split resolve and emit logic
lost@starbug
parents: 347
diff changeset
98 EMITFUNC(pseudo_emit_fcb)
347
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 int i;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
101 lw_expr_t e;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
102 int v;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
103
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
104 for (i = 0; i < l -> len; i++)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
105 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
106 e = lwasm_fetch_expr(l, i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
107 lwasm_emitexpr(l, e, 1);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
108 }
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
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
111 PARSEFUNC(pseudo_parse_fdb)
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 int i = 0;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
114 lw_expr_t e;
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 for (;;)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
117 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
118 e = lwasm_parse_expr(as, p);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
119 if (!e)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
120 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
121 lwasm_register_error(as, l, "Bad expression (#%s)", i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
122 break;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
123 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
124 lwasm_save_expr(l, i, e);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
125 i++;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
126 }
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 l -> len = i * 2;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
129 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
130
348
11a95c6414b4 Added third func to instab to split resolve and emit logic
lost@starbug
parents: 347
diff changeset
131 EMITFUNC(pseudo_emit_fdb)
347
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 int i;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
134 lw_expr_t e;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
135 int v;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
136
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
137 for (i = 0; i < (l -> len)/2; i++)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
138 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
139 e = lwasm_fetch_expr(l, i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
140 lwasm_emitexpr(l, e, 2);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
141 }
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
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
144 PARSEFUNC(pseudo_parse_fqb)
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 int i = 0;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
147 lw_expr_t e;
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 for (;;)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
150 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
151 e = lwasm_parse_expr(as, p);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
152 if (!e)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
153 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
154 lwasm_register_error(as, l, "Bad expression (#%s)", i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
155 break;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
156 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
157 lwasm_save_expr(l, i, e);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
158 i++;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
159 }
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 l -> len = i * 4;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
162 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
163
348
11a95c6414b4 Added third func to instab to split resolve and emit logic
lost@starbug
parents: 347
diff changeset
164 EMITFUNC(pseudo_emit_fqb)
347
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
165 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
166 int i;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
167 lw_expr_t e;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
168 int v;
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
169
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
170 for (i = 0; i < (l -> len)/4; i++)
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
171 {
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
172 e = lwasm_fetch_expr(l, i);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
173 lwasm_emitexpr(l, e, 4);
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
174 }
1649bc7bda5a Some data oriented pseudo ops added
lost@starbug
parents:
diff changeset
175 }
349
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
176
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
177 PARSEFUNC(pseudo_parse_fcc)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
178 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
179 char delim;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
180 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
181
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
182 if (!**p)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
183 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
184 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
185 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
186 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
187
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
188 delim = **p;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
189 (*p)++;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
190
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
191 for (i = 0; (*p)[i] && (*p)[i] != delim; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
192 /* do nothing */ ;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
193
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
194 if ((*p)[i] != delim)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
195 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
196 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
197 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
198 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
199
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
200 l -> lstr = lw_strndup(*p, i);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
201 (*p) += i + 1;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
202
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
203 l -> len = i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
204 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
205
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
206 EMITFUNC(pseudo_emit_fcc)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
207 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
208 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
209
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
210 for (i = 0; i < l -> len; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
211 lwasm_emit(l, l -> lstr[i]);
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 PARSEFUNC(pseudo_parse_fcs)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
215 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
216 char delim;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
217 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
218
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
219 if (!**p)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
220 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
221 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
222 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
223 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
224
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
225 delim = **p;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
226 (*p)++;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
227
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
228 for (i = 0; (*p)[i] && (*p)[i] != delim; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
229 /* do nothing */ ;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
230
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
231 if ((*p)[i] != delim)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
232 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
233 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
234 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
235 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
236
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
237 l -> lstr = lw_strndup(*p, i);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
238 (*p) += i + 1;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
239
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
240 l -> len = i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
241 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
242
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
243 EMITFUNC(pseudo_emit_fcs)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
244 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
245 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
246
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
247 for (i = 0; i < l -> len - 1; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
248 lwasm_emit(l, l -> lstr[i]);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
249 lwasm_emit(l, l -> lstr[i] | 0x80);
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 PARSEFUNC(pseudo_parse_fcn)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
253 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
254 char delim;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
255 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
256
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
257 if (!**p)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
258 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
259 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
260 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
261 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
262
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
263 delim = **p;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
264 (*p)++;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
265
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
266 for (i = 0; (*p)[i] && (*p)[i] != delim; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
267 /* do nothing */ ;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
268
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
269 if ((*p)[i] != delim)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
270 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
271 lwasm_register_error(as, l, "Bad operand");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
272 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
273 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
274
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
275 l -> lstr = lw_strndup(*p, i);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
276 (*p) += i + 1;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
277
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
278 l -> len = i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
279 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
280
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
281 EMITFUNC(pseudo_emit_fcn)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
282 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
283 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
284
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
285 for (i = 0; i < l -> len; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
286 lwasm_emit(l, l -> lstr[i]);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
287 lwasm_emit(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
288 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
289
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
290 PARSEFUNC(pseudo_parse_rmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
291 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
292 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
293
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
294 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
295 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
296 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
297 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
298 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
299
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
300 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
301 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
302
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
303 RESOLVEFUNC(pseudo_resolve_rmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
304 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
305 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
306
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
307 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
308 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
309
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
310 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
311
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
312 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
313 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
314 l -> len = lw_expr_intval(expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
315 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
316 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
317
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
318 EMITFUNC(pseudo_emit_rmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
319 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
320 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
321 lwasm_register_error(as, l, "Expression not constant");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
322 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
323
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
324 PARSEFUNC(pseudo_parse_rmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
325 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
326 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
327
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
328 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
329 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
330 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
331 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
332 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
333
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
334 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
335 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
336
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
337 RESOLVEFUNC(pseudo_resolve_rmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
338 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
339 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
340
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
341 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
342 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
343
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
344 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
345
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
346 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
347 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
348 l -> len = lw_expr_intval(expr) * 2;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
349 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
350 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
351
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
352 EMITFUNC(pseudo_emit_rmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
353 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
354 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
355 lwasm_register_error(as, l, "Expression not constant");
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
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
359 PARSEFUNC(pseudo_parse_rmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
360 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
361 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
362
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
363 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
364 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
365 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
366 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
367 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
368
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
369 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
370 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
371
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
372 RESOLVEFUNC(pseudo_resolve_rmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
373 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
374 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
375
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
376 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
377 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
378
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
379 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
380
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
381 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
382 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
383 l -> len = lw_expr_intval(expr) * 4;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
384 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
385 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
386
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
387 EMITFUNC(pseudo_emit_rmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
388 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
389 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
390 lwasm_register_error(as, l, "Expression not constant");
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
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
394 PARSEFUNC(pseudo_parse_zmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
395 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
396 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
397
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
398 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
399 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
400 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
401 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
402 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
403
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
404 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
405 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
406
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
407 RESOLVEFUNC(pseudo_resolve_zmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
408 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
409 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
410
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
411 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
412 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
413
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
414 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
415
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
416 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
417 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
418 l -> len = lw_expr_intval(expr) * 4;
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
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
422 EMITFUNC(pseudo_emit_zmq)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
423 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
424 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
425
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
426 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
427 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
428 lwasm_register_error(as, l, "Expression not constant");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
429 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
430 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
431
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
432 for (i = 0; i < l -> len; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
433 lwasm_emit(l, 0);
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
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
437 PARSEFUNC(pseudo_parse_zmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
438 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
439 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
440
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
441 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
442 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
443 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
444 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
445 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
446
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
447 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
448 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
449
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
450 RESOLVEFUNC(pseudo_resolve_zmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
451 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
452 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
453
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
454 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
455 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
456
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
457 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
458
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
459 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
460 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
461 l -> len = lw_expr_intval(expr) * 2;
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
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
465 EMITFUNC(pseudo_emit_zmd)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
466 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
467 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
468
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
469 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
470 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
471 lwasm_register_error(as, l, "Expression not constant");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
472 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
473 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
474
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
475 for (i = 0; i < l -> len; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
476 lwasm_emit(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
477 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
478
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
479 PARSEFUNC(pseudo_parse_zmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
480 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
481 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
482
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
483 expr = lwasm_parse_expr(as, p);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
484 if (!expr)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
485 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
486 lwasm_register_error(as, l, "Bad expression");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
487 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
488
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
489 lwasm_save_expr(l, 0, expr);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
490 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
491
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
492 RESOLVEFUNC(pseudo_resolve_zmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
493 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
494 lw_expr_t expr;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
495
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
496 if (l -> len >= 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
497 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
498
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
499 expr = lwasm_fetch_expr(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
500
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
501 if (lw_expr_istype(expr, lw_expr_type_int))
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
502 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
503 l -> len = lw_expr_intval(expr);
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
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
507 EMITFUNC(pseudo_emit_zmb)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
508 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
509 int i;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
510
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
511 if (l -> len < 0)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
512 {
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
513 lwasm_register_error(as, l, "Expression not constant");
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
514 return;
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
515 }
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
516
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
517 for (i = 0; i < l -> len; i++)
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
518 lwasm_emit(l, 0);
dcd2978a7d18 More pseudo ops
lost@starbug
parents: 348
diff changeset
519 }
350
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
520
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
521 PARSEFUNC(pseudo_parse_org)
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_t e;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
524
351
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
525 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
526
350
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
527 e = lwasm_parse_expr(as, p);
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
528 if (!e)
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
529 {
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
530 lwasm_register_error(as, l, "Bad operand");
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
531 return;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
532 }
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
533
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
534 lw_expr_destroy(l -> addr);
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
535 l -> addr = e;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
536 l -> len = 0;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
537 }
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
538
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
539 PARSEFUNC(pseudo_parse_equ)
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
540 {
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
541 lw_expr_t e;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
542
351
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
543 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
544
350
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
545 if (!(l -> sym))
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
546 {
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
547 lwasm_register_error(as, l, "Missing symbol");
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
548 return;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
549 }
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
550
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
551 e = lwasm_parse_expr(as, p);
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
552 if (!e)
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
553 {
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
554 lwasm_register_error(as, l, "Bad operand");
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
555 return;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
556 }
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
557
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
558 register_symbol(as, l, l -> sym, e, symbol_flag_none);
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
559 l -> symset = 1;
f5666775d76f Even more pseudo ops
lost@starbug
parents: 349
diff changeset
560 }
351
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
561
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
562 PARSEFUNC(pseudo_parse_set)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
563 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
564 lw_expr_t 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 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
567
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
568 if (!(l -> sym))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
569 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
570 lwasm_register_error(as, l, "Missing symbol");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
571 return;
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 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
575 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
576 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
577 lwasm_register_error(as, l, "Bad operand");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
578 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
579 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
580
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
581 register_symbol(as, l, l -> sym, e, symbol_flag_set);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
582 l -> symset = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
583 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
584
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
585 PARSEFUNC(pseudo_parse_setdp)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
586 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
587 lw_expr_t 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 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
590
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
591 if (as -> output_format == OUTPUT_OBJ)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
592 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
593 lwasm_register_error(as, l, "SETDP not permitted for object target");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
594 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
595 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
596
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
597 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
598 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
599 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
600 lwasm_register_error(as, l, "Bad operand");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
601 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
602 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
603
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
604 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
605 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
606 lwasm_register_error(as, l, "SETDP must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
607 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
608 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
609 l -> dpval = lw_expr_intval(e) & 0xff;
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 PARSEFUNC(pseudo_parse_ifp1)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
613 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
614 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
615
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
616 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
617 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
618 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
619 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
620 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
621 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
622
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
623 lwasm_register_warning(as, l, "IFP1 if is not supported; ignoring");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
624
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 PARSEFUNC(pseudo_parse_ifp2)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
628 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
629 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
630
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
631 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
632 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
633 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
634 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
635 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
636 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
637
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
638 lwasm_register_warning(as, l, "IFP2 if is not supported; ignoring");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
639 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
640
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
641 PARSEFUNC(pseudo_parse_ifeq)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
642 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
643 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
644
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
645 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
646
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
647 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
648 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
649 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
650 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
651 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
652 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
653
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
654 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
655 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
656 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
657 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
658 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
659 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
660 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
661 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
662 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
663 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
664 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
665 if (lw_expr_intval(e) != 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 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
668 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
669 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
670 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
671
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
672 PARSEFUNC(pseudo_parse_ifne)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
673 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
674 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
675
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
676 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
677
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
678 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
679 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
680 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
681 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
682 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
683 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
684
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
685 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
686 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
687 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
688 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
689 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
690 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
691 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
692 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
693 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
694 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
695 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
696 if (lw_expr_intval(e) == 0)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
697 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
698 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
699 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
700 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
701 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
702
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
703
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
704 PARSEFUNC(pseudo_parse_ifgt)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
705 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
706 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
707
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
708 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
709
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
710 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
711 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
712 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
713 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
714 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
715 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
716
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
717 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
718 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
719 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
720 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
721 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
722 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
723 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
724 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
725 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
726 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
727 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
728 if (lw_expr_intval(e) <= 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 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
731 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
732 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
733 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
734
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
735 PARSEFUNC(pseudo_parse_ifge)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
736 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
737 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
738
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
739 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
740
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
741 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
742 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
743 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
744 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
745 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
746 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
747
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
748 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
749 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
750 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
751 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
752 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
753 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
754 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
755 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
756 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
757 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
758 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
759 if (lw_expr_intval(e) < 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 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
762 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
763 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
764 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
765
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
766 PARSEFUNC(pseudo_parse_iflt)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
767 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
768 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
769
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
770 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
771
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
772 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
773 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
774 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
775 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
776 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
777 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
778
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
779 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
780 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
781 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
782 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
783 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
784 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
785 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
786 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
787 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
788 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
789 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
790 if (lw_expr_intval(e) >= 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 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
793 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
794 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
795 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
796
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
797 PARSEFUNC(pseudo_parse_ifle)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
798 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
799 lw_expr_t e;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
800
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
801 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
802
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
803 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
804 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
805 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
806 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
807 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
808 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
809
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
810 e = lwasm_parse_expr(as, p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
811 if (!e)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
812 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
813 lwasm_register_error(as, l, "Bad expression");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
814 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
815 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
816 if (!lw_expr_istype(e, lw_expr_type_int))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
817 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
818 lwasm_register_error(as, l, "Conditions must be constant on pass 1");
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
819 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
820 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
821 if (lw_expr_intval(e) > 0)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
822 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
823 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
824 as -> skipcount = 1;
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_endc)
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 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
832 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
833 as -> skipcount--;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
834 if (as -> skipcount < 0)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
835 as -> skipcond = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
836 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
837 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
838
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
839 PARSEFUNC(pseudo_parse_else)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
840 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
841 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
842
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
843 if (as -> skipmacro)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
844 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
845
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
846 if (as -> skipcond)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
847 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
848 if (as -> skipcount == 1)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
849 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
850 as -> skipcount = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
851 as -> skipcond = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
852 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
853 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
854 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
855 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
856 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
857 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
858
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
859 PARSEFUNC(pseudo_parse_ifdef)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
860 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
861 char *sym;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
862 int i;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
863 struct symtabe *s;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
864
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
865 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
866
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
867 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
868 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
869 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
870 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
871 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
872 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
873
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
874 for (i = 0; (*p)[i] && !isspace((*p)[i]); i++)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
875 /* do nothing */ ;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
876
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
877 sym = lw_strndup(*p, i);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
878
363
d96c30e60ddf Added pass2 and various supporting logic including symbol lookups
lost@starbug
parents: 356
diff changeset
879 s = lookup_symbol(as, l, sym);
351
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
880
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
881 lw_free(sym);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
882
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
883 if (!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 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
886 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
887 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
888 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
889
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
890 PARSEFUNC(pseudo_parse_ifndef)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
891 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
892 char *sym;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
893 int i;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
894 struct symtabe *s;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
895
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
896 l -> len = 0;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
897
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
898 if (as -> skipcond && !(as -> skipmacro))
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
899 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
900 as -> skipcount++;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
901 skip_operand(p);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
902 return;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
903 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
904
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
905 for (i = 0; (*p)[i] && !isspace((*p)[i]); i++)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
906 /* do nothing */ ;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
907
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
908 sym = lw_strndup(*p, i);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
909
363
d96c30e60ddf Added pass2 and various supporting logic including symbol lookups
lost@starbug
parents: 356
diff changeset
910 s = lookup_symbol(as, l, sym);
351
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
911
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
912 lw_free(sym);
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
913
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
914 if (s)
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
915 {
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
916 as -> skipcond = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
917 as -> skipcount = 1;
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
918 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
919 }
4dba8c7e242c conditional pseudo ops added
lost@starbug
parents: 350
diff changeset
920
354
60568b123281 Added os9 opcodes and ERROR
lost@starbug
parents: 351
diff changeset
921 PARSEFUNC(pseudo_parse_error)
60568b123281 Added os9 opcodes and ERROR
lost@starbug
parents: 351
diff changeset
922 {
60568b123281 Added os9 opcodes and ERROR
lost@starbug
parents: 351
diff changeset
923 lwasm_register_error(as, l, "User error: %s", *p);
60568b123281 Added os9 opcodes and ERROR
lost@starbug
parents: 351
diff changeset
924 skip_operand(p);
60568b123281 Added os9 opcodes and ERROR
lost@starbug
parents: 351
diff changeset
925 }
356
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
926
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
927 PARSEFUNC(pseudo_parse_includebin)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
928 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
929 char *fn, *p2;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
930 int delim = 0;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
931 FILE *fp;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
932 long flen;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
933
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
934 if (!**p)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
935 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
936 lwasm_register_error(as, l, "Missing filename");
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
937 return;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
938 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
939
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
940 if (**p == '"' || **p == '\'')
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
941 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
942 delim = **p;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
943 (*p)++;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
944
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
945 for (p2 = *p; *p2 && *p2 != delim; p2++)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
946 /* do nothing */ ;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
947 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
948 else
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
949 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
950 for (p2 = *p; *p2 && !isspace(*p2); p2++)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
951 /* do nothing */ ;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
952 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
953 fn = lw_strndup(*p, p2 - *p);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
954
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
955 if (delim && **p)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
956 (*p)++;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
957
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
958 fp = input_open_standalone(as, fn);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
959 if (!fp)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
960 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
961 lwasm_register_error(as, l, "Cannot open file");
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
962 lw_free(fn);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
963 return;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
964 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
965
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
966 l -> lstr = fn;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
967
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
968 fseek(fp, 0, SEEK_END);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
969 flen = ftell(fp);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
970 fclose(fp);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
971
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
972 l -> len = flen;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
973 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
974
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
975 EMITFUNC(pseudo_emit_includebin)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
976 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
977 FILE *fp;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
978 int c;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
979
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
980 fp = input_open_standalone(as, l -> lstr);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
981 if (!fp)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
982 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
983 lwasm_register_error(as, l, "Cannot open file (emit)!");
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
984 return;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
985 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
986
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
987 for (;;)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
988 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
989 c = fgetc(fp);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
990 if (c == EOF)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
991 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
992 fclose(fp);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
993 return;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
994 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
995 lwasm_emit(l, c);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
996 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
997 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
998
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
999 PARSEFUNC(pseudo_parse_include)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1000 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1001 char *fn, *p2;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1002 int delim = 0;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1003
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1004 if (!**p)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1005 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1006 lwasm_register_error(as, l, "Missing filename");
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1007 return;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1008 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1009
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1010 if (**p == '"' || **p == '\'')
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1011 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1012 delim = **p;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1013 (*p)++;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1014
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1015 for (p2 = *p; *p2 && *p2 != delim; p2++)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1016 /* do nothing */ ;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1017 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1018 else
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1019 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1020 for (p2 = *p; *p2 && !isspace(*p2); p2++)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1021 /* do nothing */ ;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1022 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1023 fn = lw_strndup(*p, p2 - *p);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1024
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1025 if (delim && **p)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1026 (*p)++;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1027
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1028 input_open(as, fn);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1029
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1030 l -> len = 0;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1031 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1032
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1033 PARSEFUNC(pseudo_parse_align)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1034 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1035 lw_expr_t e;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1036
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1037 if (!**p)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1038 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1039 lwasm_register_error(as, l, "Bad operand");
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1040 return;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1041 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1042
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1043 e = lwasm_parse_expr(as, p);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1044 if (!e)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1045 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1046 lwasm_register_error(as, l, "Bad operand");
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1047 return;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1048 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1049
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1050 lwasm_save_expr(l, 0, e);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1051
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1052 if (**p == ',')
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1053 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1054 e = lwasm_parse_expr(as, p);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1055 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1056 else
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1057 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1058 e = lw_expr_build(lw_expr_type_int, 0);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1059 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1060 if (!e)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1061 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1062 lwasm_register_error(as, l, "Bad padding");
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1063 return;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1064 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1065
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1066 lwasm_save_expr(l, 1, e);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1067 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1068
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1069 RESOLVEFUNC(pseudo_resolve_align)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1070 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1071 lw_expr_t e;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1072 int align;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1073
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1074 e = lwasm_fetch_expr(l, 0);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1075
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1076 if (lw_expr_istype(e, lw_expr_type_int))
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1077 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1078 align = lw_expr_intval(e);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1079 if (align < 1)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1080 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1081 lwasm_register_error(as, l, "Invalid alignment");
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1082 return;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1083 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1084 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1085
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1086 if (lw_expr_istype(l -> addr, lw_expr_type_int))
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1087 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1088 int a;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1089 a = lw_expr_intval(l -> addr);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1090 if (a % align == 0)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1091 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1092 l -> len = 0;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1093 return;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1094 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1095 l -> len = align - (a % align);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1096 return;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1097 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1098 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1099
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1100 EMITFUNC(pseudo_emit_align)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1101 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1102 lw_expr_t e;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1103 int i;
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1104
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1105 e = lwasm_fetch_expr(l, 1);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1106 for (i = 0; i < l -> len; i++)
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1107 {
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1108 lwasm_emitexpr(l, e, 1);
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1109 }
7166254491ed Finished pseudo ops
lost@starbug
parents: 354
diff changeset
1110 }