comparison src/pseudo.c @ 47:804d7465e0f9

Implemented ORG and fixed problems with constants using $, &, or @ to specify base
author lost
date Sun, 04 Jan 2009 07:25:03 +0000
parents 34568fab6058
children 21ae0fab469b
comparison
equal deleted inserted replaced
46:b962cee20bf4 47:804d7465e0f9
1 /* 1 /*
2 pseudo.c 2 pseudo.c
3 Copyright © 2008 William Astle 3 Copyright © 2009 William Astle
4 4
5 This file is part of LWASM. 5 This file is part of LWASM.
6 6
7 LWASM is free software: you can redistribute it and/or modify it under the 7 LWASM is free software: you can redistribute it and/or modify it under the
8 terms of the GNU General Public License as published by the Free Software 8 terms of the GNU General Public License as published by the Free Software
19 19
20 20
21 This file implements the various pseudo operations. 21 This file implements the various pseudo operations.
22 */ 22 */
23 23
24 #include <ctype.h>
25 #include <stdlib.h> 24 #include <stdlib.h>
26 #include <string.h>
27 #include "lwasm.h" 25 #include "lwasm.h"
28 #include "instab.h" 26 #include "instab.h"
29 27 #include "expr.h"
30 #include <stdio.h> 28
31 29
32 void pseudo_org(asmstate_t *as, sourceline_t *cl, char **optr) 30 OPFUNC(pseudo_org)
33 { 31 {
34 int v1, rval; 32 int rval;
35 33 lwasm_expr_stack_t *s;
36 if (cl -> hassym) 34
37 { 35 if (l -> sym)
38 register_error(as, cl, ERR_SYM); 36 {
39 cl -> hassym = 0; 37 register_error(as, l, 1, "No symbol allowed with ORG");
40 } 38 }
41 rval = eval_expr(as, cl, optr, &v1); 39 s = lwasm_evaluate_expr(as, l, *p, NULL);
42 cl -> addr = v1; 40 if (!s)
43 cl -> addrset = 1; 41 {
44 as -> addr = v1; 42 register_error(as, l, 1, "Bad expression");
45 } 43 return;
46 44 }
45 if (!lwasm_expr_is_constant(s))
46 {
47 register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
48 return;
49 }
50 rval = lwasm_expr_get_value(s);
51 l -> codeaddr = rval;
52 as -> addr = rval;
53 }
54
55 /*
47 void pseudo_include(asmstate_t *as, sourceline_t *cl, char **optr) 56 void pseudo_include(asmstate_t *as, sourceline_t *cl, char **optr)
48 { 57 {
49 int v1; 58 int v1;
50 59
51 if (as -> passnum != 1) 60 if (as -> passnum != 1)
582 void pseudo_error(asmstate_t *as, sourceline_t *cl, char **optr) 591 void pseudo_error(asmstate_t *as, sourceline_t *cl, char **optr)
583 { 592 {
584 cl -> user_error = strdup(*optr); 593 cl -> user_error = strdup(*optr);
585 errorp1(ERR_USER); 594 errorp1(ERR_USER);
586 } 595 }
596 */