Mercurial > hg-old > index.cgi
annotate src/pseudo.c @ 53:493cb8ea50a0
Added rm[dq], zm[bdq]
author | lost |
---|---|
date | Sun, 04 Jan 2009 20:28:30 +0000 |
parents | b9856da2674a |
children | 360d53062bb9 |
rev | line source |
---|---|
0 | 1 /* |
4
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
2 pseudo.c |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
3 Copyright © 2009 William Astle |
4
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
4 |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
5 This file is part of LWASM. |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
6 |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
7 LWASM is free software: you can redistribute it and/or modify it under the |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
8 terms of the GNU General Public License as published by the Free Software |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
9 Foundation, either version 3 of the License, or (at your option) any later |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
10 version. |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
11 |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
12 This program is distributed in the hope that it will be useful, but WITHOUT |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
15 more details. |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
16 |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
17 You should have received a copy of the GNU General Public License along with |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
18 this program. If not, see <http://www.gnu.org/licenses/>. |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
19 |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
20 |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
21 This file implements the various pseudo operations. |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
22 */ |
0 | 23 |
24 #include <stdlib.h> | |
50 | 25 #include <string.h> |
0 | 26 #include "lwasm.h" |
27 #include "instab.h" | |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
28 #include "expr.h" |
52 | 29 #include "util.h" |
0 | 30 |
52 | 31 extern int lwasm_read_file(asmstate_t *as, const char *filename); |
0 | 32 |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
33 OPFUNC(pseudo_org) |
0 | 34 { |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
35 int rval; |
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
36 lwasm_expr_stack_t *s; |
52 | 37 |
38 if (as -> passnum != 1) | |
39 { | |
40 // org is not needed to be processed on pass 2 | |
41 // this will prevent phasing errors for forward references that | |
42 // resolve on the second pass | |
43 // we saved the org address in l -> codeaddr on pass 1 | |
44 as -> addr = l -> codeaddr; | |
45 return; | |
46 } | |
0 | 47 |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
48 if (l -> sym) |
0 | 49 { |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
50 register_error(as, l, 1, "No symbol allowed with ORG"); |
0 | 51 } |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
52 s = lwasm_evaluate_expr(as, l, *p, NULL); |
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
53 if (!s) |
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
54 { |
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
55 register_error(as, l, 1, "Bad expression"); |
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
56 return; |
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
57 } |
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
58 if (!lwasm_expr_is_constant(s)) |
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
59 { |
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
60 register_error(as, l, 1, "Illegal incomplete reference (pass 1)"); |
50 | 61 lwasm_expr_stack_free(s); |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
62 return; |
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
63 } |
49
21ae0fab469b
Added needed infra for useful listing of EQU and ORG type statements
lost
parents:
47
diff
changeset
|
64 rval = lwasm_expr_get_value(s) & 0xffff; |
50 | 65 lwasm_expr_stack_free(s); |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
66 l -> codeaddr = rval; |
49
21ae0fab469b
Added needed infra for useful listing of EQU and ORG type statements
lost
parents:
47
diff
changeset
|
67 l -> addrset = 1; |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
68 as -> addr = rval; |
0 | 69 } |
70 | |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
71 /* |
52 | 72 The operand for include is a string optionally enclosed in " |
73 */ | |
74 OPFUNC(pseudo_include) | |
0 | 75 { |
76 int v1; | |
52 | 77 char *fn; |
0 | 78 |
52 | 79 // only include files on pass 1 |
80 // but make sure local include context is right | |
81 // for the next line... | |
0 | 82 if (as -> passnum != 1) |
52 | 83 { |
84 as -> context += 1; | |
0 | 85 return; |
52 | 86 } |
87 | |
88 while (**p && isspace(**p)) | |
89 (*p)++; | |
90 | |
91 if (!**p) | |
0 | 92 { |
52 | 93 register_error(as, l, 1, "Bad file name"); |
0 | 94 return; |
95 } | |
52 | 96 |
97 if (**p == '"') | |
98 { | |
99 // search for ending " | |
100 (*p)++; | |
101 for (v1 = 0; *((*p)+v1) && *((*p)+v1) != '"'; v1++) | |
102 /* do nothing */ ; | |
103 if (*((*p)+v1) != '"') | |
104 { | |
105 register_error(as, l, 1, "Bad file name"); | |
106 return; | |
107 } | |
108 } | |
109 else | |
0 | 110 { |
52 | 111 // search for a space type character |
112 for (v1 = 0; *((*p)+v1) && !isspace(*((*p)+v1)); v1++) | |
113 ; | |
0 | 114 } |
52 | 115 |
116 fn = lwasm_alloc(v1 + 1); | |
117 memcpy(fn, *p, v1); | |
118 fn[v1] = '\0'; | |
119 | |
120 // end local label context on include | |
121 as -> context += 1; | |
122 if (lwasm_read_file(as, fn) < 0) | |
123 { | |
124 register_error(as, l, 1, "File include error (%s)", fn); | |
125 } | |
126 lwasm_free(fn); | |
0 | 127 } |
128 | |
50 | 129 OPFUNC(pseudo_rmb) |
0 | 130 { |
50 | 131 int rval; |
132 lwasm_expr_stack_t *s; | |
0 | 133 |
50 | 134 s = lwasm_evaluate_expr(as, l, *p, NULL); |
135 if (!s) | |
0 | 136 { |
50 | 137 register_error(as, l, 1, "Bad expression"); |
0 | 138 return; |
139 } | |
50 | 140 if (!lwasm_expr_is_constant(s)) |
0 | 141 { |
50 | 142 register_error(as, l, 1, "Illegal incomplete reference (pass 1)"); |
143 lwasm_expr_stack_free(s); | |
0 | 144 return; |
145 } | |
50 | 146 rval = lwasm_expr_get_value(s); |
147 lwasm_expr_stack_free(s); | |
148 l -> nocodelen = rval; | |
149 as -> addr += rval; | |
0 | 150 } |
53 | 151 |
152 OPFUNC(pseudo_rmd) | |
0 | 153 { |
53 | 154 int rval; |
155 lwasm_expr_stack_t *s; | |
0 | 156 |
53 | 157 s = lwasm_evaluate_expr(as, l, *p, NULL); |
158 if (!s) | |
0 | 159 { |
53 | 160 register_error(as, l, 1, "Bad expression"); |
0 | 161 return; |
162 } | |
53 | 163 if (!lwasm_expr_is_constant(s)) |
0 | 164 { |
53 | 165 register_error(as, l, 1, "Illegal incomplete reference (pass 1)"); |
166 lwasm_expr_stack_free(s); | |
0 | 167 return; |
168 } | |
53 | 169 rval = lwasm_expr_get_value(s) * 2; |
170 lwasm_expr_stack_free(s); | |
171 l -> nocodelen = rval; | |
172 as -> addr += rval; | |
0 | 173 } |
174 | |
53 | 175 OPFUNC(pseudo_rmq) |
0 | 176 { |
53 | 177 int rval; |
178 lwasm_expr_stack_t *s; | |
0 | 179 |
53 | 180 s = lwasm_evaluate_expr(as, l, *p, NULL); |
181 if (!s) | |
0 | 182 { |
53 | 183 register_error(as, l, 1, "Bad expression"); |
0 | 184 return; |
185 } | |
53 | 186 if (!lwasm_expr_is_constant(s)) |
0 | 187 { |
53 | 188 register_error(as, l, 1, "Illegal incomplete reference (pass 1)"); |
189 lwasm_expr_stack_free(s); | |
0 | 190 return; |
191 } | |
53 | 192 rval = lwasm_expr_get_value(s) * 4; |
193 lwasm_expr_stack_free(s); | |
194 l -> nocodelen = rval; | |
195 as -> addr += rval; | |
0 | 196 } |
197 | |
53 | 198 OPFUNC(pseudo_zmb) |
0 | 199 { |
53 | 200 int rval; |
201 lwasm_expr_stack_t *s; | |
0 | 202 |
53 | 203 s = lwasm_evaluate_expr(as, l, *p, NULL); |
204 if (!s) | |
0 | 205 { |
53 | 206 register_error(as, l, 1, "Bad expression"); |
0 | 207 return; |
208 } | |
53 | 209 if (!lwasm_expr_is_constant(s)) |
0 | 210 { |
53 | 211 register_error(as, l, 1, "Illegal incomplete reference (pass 1)"); |
212 lwasm_expr_stack_free(s); | |
0 | 213 return; |
214 } | |
53 | 215 rval = lwasm_expr_get_value(s); |
216 lwasm_expr_stack_free(s); | |
217 while (rval-- > 0) | |
0 | 218 { |
53 | 219 lwasm_emit(as, l, 0); |
0 | 220 } |
221 } | |
222 | |
53 | 223 OPFUNC(pseudo_zmd) |
0 | 224 { |
53 | 225 int rval; |
226 lwasm_expr_stack_t *s; | |
0 | 227 |
53 | 228 s = lwasm_evaluate_expr(as, l, *p, NULL); |
229 if (!s) | |
0 | 230 { |
53 | 231 register_error(as, l, 1, "Bad expression"); |
0 | 232 return; |
233 } | |
53 | 234 if (!lwasm_expr_is_constant(s)) |
0 | 235 { |
53 | 236 register_error(as, l, 1, "Illegal incomplete reference (pass 1)"); |
237 lwasm_expr_stack_free(s); | |
0 | 238 return; |
239 } | |
53 | 240 rval = lwasm_expr_get_value(s); |
241 lwasm_expr_stack_free(s); | |
242 while (rval-- > 0) | |
0 | 243 { |
53 | 244 lwasm_emit(as, l, 0); |
245 lwasm_emit(as, l, 0); | |
0 | 246 } |
247 } | |
248 | |
53 | 249 OPFUNC(pseudo_zmq) |
250 { | |
251 int rval; | |
252 lwasm_expr_stack_t *s; | |
253 | |
254 s = lwasm_evaluate_expr(as, l, *p, NULL); | |
255 if (!s) | |
256 { | |
257 register_error(as, l, 1, "Bad expression"); | |
258 return; | |
259 } | |
260 if (!lwasm_expr_is_constant(s)) | |
261 { | |
262 register_error(as, l, 1, "Illegal incomplete reference (pass 1)"); | |
263 lwasm_expr_stack_free(s); | |
264 return; | |
265 } | |
266 rval = lwasm_expr_get_value(s); | |
267 lwasm_expr_stack_free(s); | |
268 while (rval-- > 0) | |
269 { | |
270 lwasm_emit(as, l, 0); | |
271 lwasm_emit(as, l, 0); | |
272 lwasm_emit(as, l, 0); | |
273 lwasm_emit(as, l, 0); | |
274 } | |
275 } | |
276 | |
277 /* | |
0 | 278 void pseudo_end(asmstate_t *as, sourceline_t *cl, char **optr) |
279 { | |
280 int rval, v1; | |
281 | |
282 while (**optr && isspace(**optr)) | |
283 ; | |
284 if (**optr && **optr != '*' && **optr != ';') | |
285 { | |
286 rval = eval_expr(as, cl, optr, &v1); | |
287 if (rval < 0) | |
288 { | |
289 errorp1(ERR_FORWARD); | |
290 return; | |
291 } | |
292 } | |
293 else | |
294 { | |
295 v1 = 0; | |
296 } | |
297 if (as -> passnum == 2) | |
298 as -> execaddr = v1; | |
299 } | |
300 | |
301 void pseudo_align(asmstate_t *as, sourceline_t *cl, char **optr) | |
302 { | |
303 int rval, v1; | |
304 int cn; | |
305 | |
306 rval = eval_expr(as, cl, optr, &v1); | |
307 if (rval < 0) | |
308 { | |
309 errorp1(ERR_FORWARD); | |
310 return; | |
311 } | |
312 cn = cl -> addr % v1; | |
313 if (cn) | |
314 cn = v1 - cn; | |
315 | |
316 while (cn) | |
317 { | |
318 emit(0); | |
319 cn--; | |
320 } | |
321 } | |
50 | 322 */ |
323 OPFUNC(pseudo_equ) | |
0 | 324 { |
50 | 325 lwasm_expr_stack_t *s; |
326 int rval; | |
52 | 327 |
328 // equ is not needed to be processed on pass 2 | |
329 if (as -> passnum != 1) | |
330 return; | |
331 | |
50 | 332 if (l -> sym == NULL) |
0 | 333 { |
50 | 334 register_error(as, l, 1, "No symbol specified"); |
0 | 335 return; |
336 } | |
50 | 337 |
338 s = lwasm_evaluate_expr(as, l, *p, NULL); | |
339 | |
340 if (!s) | |
0 | 341 { |
50 | 342 register_error(as, l, 1, "Bad expression"); |
343 rval = 0; | |
0 | 344 } |
50 | 345 else |
0 | 346 { |
50 | 347 if (!lwasm_expr_is_constant(s)) |
348 register_error(as, l, 1, "Invalid incomplete reference (pass 1)"); | |
349 rval = lwasm_expr_get_value(s); | |
350 lwasm_expr_stack_free(s); | |
0 | 351 } |
50 | 352 l -> symaddr = rval & 0xFFFF; |
353 l -> addrset = 2; | |
354 if (strchr(l -> sym, '@') || strchr(l -> sym, '?')) | |
355 lwasm_set_symbol(as, l -> sym, as -> context, l -> symaddr); | |
356 else | |
357 lwasm_set_symbol(as, l -> sym, -1, l -> symaddr); | |
0 | 358 } |
50 | 359 /* |
0 | 360 void pseudo_set(asmstate_t *as, sourceline_t *cl, char **optr) |
361 { | |
362 int rval, v1; | |
363 | |
364 if (cl -> hassym == 0) | |
365 { | |
366 errorp1(ERR_NOSYM); | |
367 return; | |
368 } | |
369 rval = eval_expr(as, cl, optr, &v1); | |
370 // eval_expr returns -1 if there was a forward ref | |
371 // or -2 if the expr was invalid | |
372 if (rval == -2) | |
373 { | |
374 // carp | |
375 errorp1(ERR_FORWARD); | |
376 } | |
377 if (rval < 0) | |
378 { | |
379 // remove symbol ref | |
380 cl -> hassym = 0; | |
381 // mark as a "comment" so it isn't processed next time | |
382 cl -> opcode = -1; | |
383 return; | |
384 } | |
385 cl -> code_symloc = v1; | |
386 cl -> isset = 1; | |
387 cl -> isequ = 1; | |
388 cl -> symaddr = v1 & 0xFFFF; | |
389 } | |
390 | |
391 void pseudo_setdp(asmstate_t *as, sourceline_t *cl, char **optr) | |
392 { | |
393 int rval, v1; | |
394 | |
395 if (cl -> hassym) | |
396 { | |
397 register_error(as, cl, ERR_SYM); | |
398 cl -> hassym = 0; | |
399 return; | |
400 } | |
401 else | |
402 { | |
403 rval = eval_expr(as, cl, optr, &v1); | |
404 if (rval == -1) | |
405 { | |
406 errorp1(ERR_FORWARD); | |
407 } | |
408 if (rval < 0) | |
409 { | |
410 cl -> opcode = -1; | |
411 return; | |
412 } | |
413 } | |
414 // setdp needs to resolve properly on pass 2 | |
415 if (v1 > 0xff || v1 < 0) | |
416 { | |
417 errorp1(ERR_OVERFLOW); | |
418 } | |
419 as -> dpval = v1 & 0xff; | |
420 cl -> dpval = v1 & 0xff; | |
421 cl -> issetdp = 1; | |
422 cl -> numcodebytes = 0; | |
423 //printf("%s\n", "SETDP2"); | |
424 } | |
425 | |
426 void pseudo_fcc(asmstate_t *as, sourceline_t *cl, char **optr) | |
427 { | |
428 int cn = 0; | |
429 int delim = 0; | |
430 | |
431 delim = *(*optr)++; | |
432 if (!delim) | |
433 { | |
434 errorp1(ERR_BADOPER); | |
435 } | |
436 else | |
437 { | |
438 while (**optr && **optr != delim) | |
439 { | |
440 emit(**optr); | |
441 (*optr)++; | |
442 cn += 1; | |
443 } | |
444 } | |
445 cl -> len = cn; | |
446 } | |
447 | |
448 void pseudo_fcs(asmstate_t *as, sourceline_t *cl, char **optr) | |
449 { | |
450 int cn = 0; | |
451 int delim = 0; | |
452 | |
453 delim = *(*optr)++; | |
454 if (!delim) | |
455 { | |
456 errorp1(ERR_BADOPER); | |
457 } | |
458 else | |
459 { | |
460 while (**optr && **optr != delim) | |
461 { | |
462 if (!*((*optr) + 1) || *((*optr) + 1) == delim) | |
463 emit((**optr) | 0x80); | |
464 else | |
465 emit(**optr); | |
466 (*optr)++; | |
467 cn += 1; | |
468 } | |
469 } | |
470 cl -> len = cn; | |
471 } | |
472 | |
473 void pseudo_fcn(asmstate_t *as, sourceline_t *cl, char **optr) | |
474 { | |
475 int cn = 0; | |
476 int delim = 0; | |
477 | |
478 delim = *(*optr)++; | |
479 if (!delim) | |
480 { | |
481 errorp1(ERR_BADOPER); | |
482 } | |
483 else | |
484 { | |
485 while (**optr && **optr != delim) | |
486 { | |
487 emit(**optr); | |
488 (*optr)++; | |
489 cn += 1; | |
490 } | |
491 } | |
492 emit(0); | |
493 cl -> len = cn + 1; | |
494 } | |
495 | |
496 void pseudo_fcb(asmstate_t *as, sourceline_t *cl, char **optr) | |
497 { | |
498 int rval, v1; | |
499 | |
500 fcb_again: | |
501 rval = eval_expr(as, cl, optr, &v1); | |
502 if (v1 < -127 || v1 > 0xff) | |
503 errorp2(ERR_OVERFLOW); | |
504 emit(v1 & 0xff); | |
505 if (**optr == ',') | |
506 { | |
507 (*optr)++; | |
508 goto fcb_again; | |
509 } | |
510 } | |
511 | |
512 void pseudo_fdb(asmstate_t *as, sourceline_t *cl, char **optr) | |
513 { | |
514 int rval, v1; | |
515 | |
516 fdb_again: | |
517 rval = eval_expr(as, cl, optr, &v1); | |
518 emit((v1 >> 8) & 0xff); | |
519 emit(v1 & 0xff); | |
520 if (**optr == ',') | |
521 { | |
522 (*optr)++; | |
523 goto fdb_again; | |
524 } | |
525 } | |
526 | |
527 void pseudo_fqb(asmstate_t *as, sourceline_t *cl, char **optr) | |
528 { | |
529 int rval, v1; | |
530 | |
531 fqb_again: | |
532 rval = eval_expr(as, cl, optr, &v1); | |
533 emit((v1 >> 24) & 0xff); | |
534 emit((v1 >> 16) & 0xff); | |
535 emit((v1 >> 8) & 0xff); | |
536 emit(v1 & 0xff); | |
537 if (**optr == ',') | |
538 { | |
539 (*optr)++; | |
540 goto fqb_again; | |
541 } | |
542 } | |
543 | |
544 // don't need to do anything if we are executing one of these | |
545 void pseudo_endc(asmstate_t *as, sourceline_t *cl, char **optr) | |
546 { | |
547 return; | |
548 } | |
549 | |
550 // if "else" executes, we must be going into an "ignore" state | |
551 void pseudo_else(asmstate_t *as, sourceline_t *cl, char **optr) | |
552 { | |
553 as -> skipcond = 1; | |
554 as -> skipcount = 1; | |
555 } | |
556 | |
557 void pseudo_ifne(asmstate_t *as, sourceline_t *cl, char **optr) | |
558 { | |
559 int v1; | |
560 int rval; | |
561 // printf("ifne %s\n", *optr); | |
562 rval = eval_expr(as, cl, optr, &v1); | |
563 if (rval < 0) | |
564 { | |
565 errorp1(ERR_BADCOND); | |
566 } | |
567 else | |
568 { | |
569 // printf("Condition value: %d\n", v1); | |
570 if (!v1) | |
571 { | |
572 // printf("condition no match\n"); | |
573 as -> skipcond = 1; | |
574 as -> skipcount = 1; | |
575 } | |
576 } | |
577 } | |
578 void pseudo_ifeq(asmstate_t *as, sourceline_t *cl, char **optr) | |
579 { | |
580 int v1; | |
581 int rval; | |
582 | |
583 rval = eval_expr(as, cl, optr, &v1); | |
584 if (rval < 0) | |
585 { | |
586 errorp1(ERR_BADCOND); | |
587 } | |
588 else | |
589 { | |
590 if (v1) | |
591 { | |
592 as -> skipcond = 1; | |
593 as -> skipcount = 1; | |
594 } | |
595 } | |
596 } | |
597 void pseudo_iflt(asmstate_t *as, sourceline_t *cl, char **optr) | |
598 { | |
599 int v1; | |
600 int rval; | |
601 | |
602 rval = eval_expr(as, cl, optr, &v1); | |
603 if (rval < 0) | |
604 { | |
605 errorp1(ERR_BADCOND); | |
606 } | |
607 else | |
608 { | |
609 if (v1 >= 0) | |
610 { | |
611 as -> skipcond = 1; | |
612 as -> skipcount = 1; | |
613 } | |
614 } | |
615 } | |
616 void pseudo_ifle(asmstate_t *as, sourceline_t *cl, char **optr) | |
617 { | |
618 int v1; | |
619 int rval; | |
620 | |
621 rval = eval_expr(as, cl, optr, &v1); | |
622 if (rval < 0) | |
623 { | |
624 errorp1(ERR_BADCOND); | |
625 } | |
626 else | |
627 { | |
628 if (v1 > 0) | |
629 { | |
630 as -> skipcond = 1; | |
631 as -> skipcount = 1; | |
632 } | |
633 } | |
634 } | |
635 void pseudo_ifgt(asmstate_t *as, sourceline_t *cl, char **optr) | |
636 { | |
637 int v1; | |
638 int rval; | |
639 | |
640 rval = eval_expr(as, cl, optr, &v1); | |
641 if (rval < 0) | |
642 { | |
643 errorp1(ERR_BADCOND); | |
644 } | |
645 else | |
646 { | |
647 if (v1 <= 0) | |
648 { | |
649 as -> skipcond = 1; | |
650 as -> skipcount = 1; | |
651 } | |
652 } | |
653 } | |
654 void pseudo_ifge(asmstate_t *as, sourceline_t *cl, char **optr) | |
655 { | |
656 int v1; | |
657 int rval; | |
658 | |
659 rval = eval_expr(as, cl, optr, &v1); | |
660 if (rval < 0) | |
661 { | |
662 errorp1(ERR_BADCOND); | |
663 } | |
664 else | |
665 { | |
666 if (v1 < 0) | |
667 { | |
668 as -> skipcond = 1; | |
669 as -> skipcount = 1; | |
670 } | |
671 } | |
672 } | |
673 | |
674 void pseudo_error(asmstate_t *as, sourceline_t *cl, char **optr) | |
675 { | |
676 cl -> user_error = strdup(*optr); | |
677 errorp1(ERR_USER); | |
678 } | |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
679 */ |