annotate lwasm/pseudo.c @ 384:38b50ce6967a

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