comparison lwasm/pseudo.c @ 218:b0c9df865b25

Add FDBS pseudo op. Add FDBS pseudo op which is just like FDB but it swaps the bytes of the operands. It is undocumented intentionally.
author William Astle <lost@l-w.ca>
date Sun, 10 Jun 2012 14:55:27 -0600
parents f87c86668d6b
children afd50d6b4113
comparison
equal deleted inserted replaced
217:f87c86668d6b 218:b0c9df865b25
193 193
194 for (i = 0; i < (l -> len)/2; i++) 194 for (i = 0; i < (l -> len)/2; i++)
195 { 195 {
196 e = lwasm_fetch_expr(l, i); 196 e = lwasm_fetch_expr(l, i);
197 lwasm_emitexpr(l, e, 2); 197 lwasm_emitexpr(l, e, 2);
198 }
199 }
200
201 PARSEFUNC(pseudo_parse_fdbs)
202 {
203 int i = 0;
204 lw_expr_t e;
205
206 for (;;)
207 {
208 e = lwasm_parse_expr(as, p);
209 if (!e)
210 {
211 lwasm_register_error(as, l, "Bad expression (#%d)", i);
212 break;
213 }
214 lwasm_save_expr(l, i++, e);
215 if (**p != ',')
216 break;
217 (*p)++;
218 }
219
220 l -> len = i * 2;
221 }
222
223 EMITFUNC(pseudo_emit_fdbs)
224 {
225 int i;
226 lw_expr_t e;
227 lw_expr_t t;
228 lw_expr_t t2;
229 // int v;
230
231 for (i = 0; i < (l -> len)/2; i++)
232 {
233 e = lwasm_fetch_expr(l, i);
234 t = lw_expr_build(lw_expr_type_int, 256);
235 t2 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_divide, e, t);
236 lwasm_reduce_expr(as, t2);
237 lw_expr_destroy(t);
238 lwasm_emitexpr(l, e, 1);
239 lwasm_emitexpr(l, t2, 1);
240 lw_expr_destroy(t2);
198 } 241 }
199 } 242 }
200 243
201 PARSEFUNC(pseudo_parse_fqb) 244 PARSEFUNC(pseudo_parse_fqb)
202 { 245 {