Mercurial > hg-old > index.cgi
annotate src/pseudo.c @ 52:b9856da2674a
Added file inclusion
author | lost |
---|---|
date | Sun, 04 Jan 2009 20:16:38 +0000 |
parents | e672232caffe |
children | 493cb8ea50a0 |
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 } |
50 | 151 /* |
0 | 152 void pseudo_rmd(asmstate_t *as, sourceline_t *cl, char **optr) |
153 { | |
154 int rval, v1; | |
155 | |
156 rval = eval_expr(as, cl, optr, &v1); | |
157 if (rval < 0) | |
158 { | |
159 errorp1(ERR_FORWARD); | |
160 return; | |
161 } | |
162 if (v1 < 0) | |
163 { | |
164 errorp1(ERR_BADOPER); | |
165 return; | |
166 } | |
167 cl -> len = v1 * 2; | |
168 cl -> nocode = 1; | |
169 } | |
170 | |
171 void pseudo_rmq(asmstate_t *as, sourceline_t *cl, char **optr) | |
172 { | |
173 int rval, v1; | |
174 | |
175 rval = eval_expr(as, cl, optr, &v1); | |
176 if (rval < 0) | |
177 { | |
178 errorp1(ERR_FORWARD); | |
179 return; | |
180 } | |
181 if (v1 < 0) | |
182 { | |
183 errorp1(ERR_BADOPER); | |
184 return; | |
185 } | |
186 cl -> len = v1 * 4; | |
187 cl -> nocode = 1; | |
188 } | |
189 | |
190 void pseudo_zmb(asmstate_t *as, sourceline_t *cl, char **optr) | |
191 { | |
192 int rval, v1; | |
193 | |
194 rval = eval_expr(as, cl, optr, &v1); | |
195 if (rval < 0) | |
196 { | |
197 errorp1(ERR_FORWARD); | |
198 return; | |
199 } | |
200 if (v1 < 0) | |
201 { | |
202 errorp1(ERR_BADOPER); | |
203 return; | |
204 } | |
205 while (v1--) | |
206 emit(0); | |
207 } | |
208 | |
209 void pseudo_zmd(asmstate_t *as, sourceline_t *cl, char **optr) | |
210 { | |
211 int rval, v1; | |
212 | |
213 rval = eval_expr(as, cl, optr, &v1); | |
214 if (rval < 0) | |
215 { | |
216 errorp1(ERR_FORWARD); | |
217 return; | |
218 } | |
219 if (v1 < 0) | |
220 { | |
221 errorp1(ERR_BADOPER); | |
222 return; | |
223 } | |
224 while (v1--) | |
225 { | |
226 emit(0); | |
227 emit(0); | |
228 } | |
229 } | |
230 | |
231 void pseudo_zmq(asmstate_t *as, sourceline_t *cl, char **optr) | |
232 { | |
233 int rval, v1; | |
234 | |
235 rval = eval_expr(as, cl, optr, &v1); | |
236 if (rval < 0) | |
237 { | |
238 errorp1(ERR_FORWARD); | |
239 return; | |
240 } | |
241 if (v1 < 0) | |
242 { | |
243 errorp1(ERR_BADOPER); | |
244 return; | |
245 } | |
246 while (v1--) | |
247 { | |
248 emit(0); | |
249 emit(0); | |
250 emit(0); | |
251 emit(0); | |
252 } | |
253 } | |
254 | |
255 void pseudo_end(asmstate_t *as, sourceline_t *cl, char **optr) | |
256 { | |
257 int rval, v1; | |
258 | |
259 while (**optr && isspace(**optr)) | |
260 ; | |
261 if (**optr && **optr != '*' && **optr != ';') | |
262 { | |
263 rval = eval_expr(as, cl, optr, &v1); | |
264 if (rval < 0) | |
265 { | |
266 errorp1(ERR_FORWARD); | |
267 return; | |
268 } | |
269 } | |
270 else | |
271 { | |
272 v1 = 0; | |
273 } | |
274 if (as -> passnum == 2) | |
275 as -> execaddr = v1; | |
276 } | |
277 | |
278 void pseudo_align(asmstate_t *as, sourceline_t *cl, char **optr) | |
279 { | |
280 int rval, v1; | |
281 int cn; | |
282 | |
283 rval = eval_expr(as, cl, optr, &v1); | |
284 if (rval < 0) | |
285 { | |
286 errorp1(ERR_FORWARD); | |
287 return; | |
288 } | |
289 cn = cl -> addr % v1; | |
290 if (cn) | |
291 cn = v1 - cn; | |
292 | |
293 while (cn) | |
294 { | |
295 emit(0); | |
296 cn--; | |
297 } | |
298 } | |
50 | 299 */ |
300 OPFUNC(pseudo_equ) | |
0 | 301 { |
50 | 302 lwasm_expr_stack_t *s; |
303 int rval; | |
52 | 304 |
305 // equ is not needed to be processed on pass 2 | |
306 if (as -> passnum != 1) | |
307 return; | |
308 | |
50 | 309 if (l -> sym == NULL) |
0 | 310 { |
50 | 311 register_error(as, l, 1, "No symbol specified"); |
0 | 312 return; |
313 } | |
50 | 314 |
315 s = lwasm_evaluate_expr(as, l, *p, NULL); | |
316 | |
317 if (!s) | |
0 | 318 { |
50 | 319 register_error(as, l, 1, "Bad expression"); |
320 rval = 0; | |
0 | 321 } |
50 | 322 else |
0 | 323 { |
50 | 324 if (!lwasm_expr_is_constant(s)) |
325 register_error(as, l, 1, "Invalid incomplete reference (pass 1)"); | |
326 rval = lwasm_expr_get_value(s); | |
327 lwasm_expr_stack_free(s); | |
0 | 328 } |
50 | 329 l -> symaddr = rval & 0xFFFF; |
330 l -> addrset = 2; | |
331 if (strchr(l -> sym, '@') || strchr(l -> sym, '?')) | |
332 lwasm_set_symbol(as, l -> sym, as -> context, l -> symaddr); | |
333 else | |
334 lwasm_set_symbol(as, l -> sym, -1, l -> symaddr); | |
0 | 335 } |
50 | 336 /* |
0 | 337 void pseudo_set(asmstate_t *as, sourceline_t *cl, char **optr) |
338 { | |
339 int rval, v1; | |
340 | |
341 if (cl -> hassym == 0) | |
342 { | |
343 errorp1(ERR_NOSYM); | |
344 return; | |
345 } | |
346 rval = eval_expr(as, cl, optr, &v1); | |
347 // eval_expr returns -1 if there was a forward ref | |
348 // or -2 if the expr was invalid | |
349 if (rval == -2) | |
350 { | |
351 // carp | |
352 errorp1(ERR_FORWARD); | |
353 } | |
354 if (rval < 0) | |
355 { | |
356 // remove symbol ref | |
357 cl -> hassym = 0; | |
358 // mark as a "comment" so it isn't processed next time | |
359 cl -> opcode = -1; | |
360 return; | |
361 } | |
362 cl -> code_symloc = v1; | |
363 cl -> isset = 1; | |
364 cl -> isequ = 1; | |
365 cl -> symaddr = v1 & 0xFFFF; | |
366 } | |
367 | |
368 void pseudo_setdp(asmstate_t *as, sourceline_t *cl, char **optr) | |
369 { | |
370 int rval, v1; | |
371 | |
372 if (cl -> hassym) | |
373 { | |
374 register_error(as, cl, ERR_SYM); | |
375 cl -> hassym = 0; | |
376 return; | |
377 } | |
378 else | |
379 { | |
380 rval = eval_expr(as, cl, optr, &v1); | |
381 if (rval == -1) | |
382 { | |
383 errorp1(ERR_FORWARD); | |
384 } | |
385 if (rval < 0) | |
386 { | |
387 cl -> opcode = -1; | |
388 return; | |
389 } | |
390 } | |
391 // setdp needs to resolve properly on pass 2 | |
392 if (v1 > 0xff || v1 < 0) | |
393 { | |
394 errorp1(ERR_OVERFLOW); | |
395 } | |
396 as -> dpval = v1 & 0xff; | |
397 cl -> dpval = v1 & 0xff; | |
398 cl -> issetdp = 1; | |
399 cl -> numcodebytes = 0; | |
400 //printf("%s\n", "SETDP2"); | |
401 } | |
402 | |
403 void pseudo_fcc(asmstate_t *as, sourceline_t *cl, char **optr) | |
404 { | |
405 int cn = 0; | |
406 int delim = 0; | |
407 | |
408 delim = *(*optr)++; | |
409 if (!delim) | |
410 { | |
411 errorp1(ERR_BADOPER); | |
412 } | |
413 else | |
414 { | |
415 while (**optr && **optr != delim) | |
416 { | |
417 emit(**optr); | |
418 (*optr)++; | |
419 cn += 1; | |
420 } | |
421 } | |
422 cl -> len = cn; | |
423 } | |
424 | |
425 void pseudo_fcs(asmstate_t *as, sourceline_t *cl, char **optr) | |
426 { | |
427 int cn = 0; | |
428 int delim = 0; | |
429 | |
430 delim = *(*optr)++; | |
431 if (!delim) | |
432 { | |
433 errorp1(ERR_BADOPER); | |
434 } | |
435 else | |
436 { | |
437 while (**optr && **optr != delim) | |
438 { | |
439 if (!*((*optr) + 1) || *((*optr) + 1) == delim) | |
440 emit((**optr) | 0x80); | |
441 else | |
442 emit(**optr); | |
443 (*optr)++; | |
444 cn += 1; | |
445 } | |
446 } | |
447 cl -> len = cn; | |
448 } | |
449 | |
450 void pseudo_fcn(asmstate_t *as, sourceline_t *cl, char **optr) | |
451 { | |
452 int cn = 0; | |
453 int delim = 0; | |
454 | |
455 delim = *(*optr)++; | |
456 if (!delim) | |
457 { | |
458 errorp1(ERR_BADOPER); | |
459 } | |
460 else | |
461 { | |
462 while (**optr && **optr != delim) | |
463 { | |
464 emit(**optr); | |
465 (*optr)++; | |
466 cn += 1; | |
467 } | |
468 } | |
469 emit(0); | |
470 cl -> len = cn + 1; | |
471 } | |
472 | |
473 void pseudo_fcb(asmstate_t *as, sourceline_t *cl, char **optr) | |
474 { | |
475 int rval, v1; | |
476 | |
477 fcb_again: | |
478 rval = eval_expr(as, cl, optr, &v1); | |
479 if (v1 < -127 || v1 > 0xff) | |
480 errorp2(ERR_OVERFLOW); | |
481 emit(v1 & 0xff); | |
482 if (**optr == ',') | |
483 { | |
484 (*optr)++; | |
485 goto fcb_again; | |
486 } | |
487 } | |
488 | |
489 void pseudo_fdb(asmstate_t *as, sourceline_t *cl, char **optr) | |
490 { | |
491 int rval, v1; | |
492 | |
493 fdb_again: | |
494 rval = eval_expr(as, cl, optr, &v1); | |
495 emit((v1 >> 8) & 0xff); | |
496 emit(v1 & 0xff); | |
497 if (**optr == ',') | |
498 { | |
499 (*optr)++; | |
500 goto fdb_again; | |
501 } | |
502 } | |
503 | |
504 void pseudo_fqb(asmstate_t *as, sourceline_t *cl, char **optr) | |
505 { | |
506 int rval, v1; | |
507 | |
508 fqb_again: | |
509 rval = eval_expr(as, cl, optr, &v1); | |
510 emit((v1 >> 24) & 0xff); | |
511 emit((v1 >> 16) & 0xff); | |
512 emit((v1 >> 8) & 0xff); | |
513 emit(v1 & 0xff); | |
514 if (**optr == ',') | |
515 { | |
516 (*optr)++; | |
517 goto fqb_again; | |
518 } | |
519 } | |
520 | |
521 // don't need to do anything if we are executing one of these | |
522 void pseudo_endc(asmstate_t *as, sourceline_t *cl, char **optr) | |
523 { | |
524 return; | |
525 } | |
526 | |
527 // if "else" executes, we must be going into an "ignore" state | |
528 void pseudo_else(asmstate_t *as, sourceline_t *cl, char **optr) | |
529 { | |
530 as -> skipcond = 1; | |
531 as -> skipcount = 1; | |
532 } | |
533 | |
534 void pseudo_ifne(asmstate_t *as, sourceline_t *cl, char **optr) | |
535 { | |
536 int v1; | |
537 int rval; | |
538 // printf("ifne %s\n", *optr); | |
539 rval = eval_expr(as, cl, optr, &v1); | |
540 if (rval < 0) | |
541 { | |
542 errorp1(ERR_BADCOND); | |
543 } | |
544 else | |
545 { | |
546 // printf("Condition value: %d\n", v1); | |
547 if (!v1) | |
548 { | |
549 // printf("condition no match\n"); | |
550 as -> skipcond = 1; | |
551 as -> skipcount = 1; | |
552 } | |
553 } | |
554 } | |
555 void pseudo_ifeq(asmstate_t *as, sourceline_t *cl, char **optr) | |
556 { | |
557 int v1; | |
558 int rval; | |
559 | |
560 rval = eval_expr(as, cl, optr, &v1); | |
561 if (rval < 0) | |
562 { | |
563 errorp1(ERR_BADCOND); | |
564 } | |
565 else | |
566 { | |
567 if (v1) | |
568 { | |
569 as -> skipcond = 1; | |
570 as -> skipcount = 1; | |
571 } | |
572 } | |
573 } | |
574 void pseudo_iflt(asmstate_t *as, sourceline_t *cl, char **optr) | |
575 { | |
576 int v1; | |
577 int rval; | |
578 | |
579 rval = eval_expr(as, cl, optr, &v1); | |
580 if (rval < 0) | |
581 { | |
582 errorp1(ERR_BADCOND); | |
583 } | |
584 else | |
585 { | |
586 if (v1 >= 0) | |
587 { | |
588 as -> skipcond = 1; | |
589 as -> skipcount = 1; | |
590 } | |
591 } | |
592 } | |
593 void pseudo_ifle(asmstate_t *as, sourceline_t *cl, char **optr) | |
594 { | |
595 int v1; | |
596 int rval; | |
597 | |
598 rval = eval_expr(as, cl, optr, &v1); | |
599 if (rval < 0) | |
600 { | |
601 errorp1(ERR_BADCOND); | |
602 } | |
603 else | |
604 { | |
605 if (v1 > 0) | |
606 { | |
607 as -> skipcond = 1; | |
608 as -> skipcount = 1; | |
609 } | |
610 } | |
611 } | |
612 void pseudo_ifgt(asmstate_t *as, sourceline_t *cl, char **optr) | |
613 { | |
614 int v1; | |
615 int rval; | |
616 | |
617 rval = eval_expr(as, cl, optr, &v1); | |
618 if (rval < 0) | |
619 { | |
620 errorp1(ERR_BADCOND); | |
621 } | |
622 else | |
623 { | |
624 if (v1 <= 0) | |
625 { | |
626 as -> skipcond = 1; | |
627 as -> skipcount = 1; | |
628 } | |
629 } | |
630 } | |
631 void pseudo_ifge(asmstate_t *as, sourceline_t *cl, char **optr) | |
632 { | |
633 int v1; | |
634 int rval; | |
635 | |
636 rval = eval_expr(as, cl, optr, &v1); | |
637 if (rval < 0) | |
638 { | |
639 errorp1(ERR_BADCOND); | |
640 } | |
641 else | |
642 { | |
643 if (v1 < 0) | |
644 { | |
645 as -> skipcond = 1; | |
646 as -> skipcount = 1; | |
647 } | |
648 } | |
649 } | |
650 | |
651 void pseudo_error(asmstate_t *as, sourceline_t *cl, char **optr) | |
652 { | |
653 cl -> user_error = strdup(*optr); | |
654 errorp1(ERR_USER); | |
655 } | |
47
804d7465e0f9
Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents:
4
diff
changeset
|
656 */ |