annotate src/pseudo.c @ 63:d85ba47b1e8f

Moved symbol registration so symbols that are in skipped code do not get registered and so EQU/SET can do their own registration
author lost
date Mon, 05 Jan 2009 01:17:23 +0000
parents 035b95a3690f
children aaddd47219b4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
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
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
23
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
24 #include <stdlib.h>
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
25 #include <string.h>
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
26 #include "lwasm.h"
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
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
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
29 #include "util.h"
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
30
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
31 extern int lwasm_read_file(asmstate_t *as, const char *filename);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
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
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
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
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
37
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
38 if (as -> passnum != 1)
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
39 {
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
40 // org is not needed to be processed on pass 2
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
41 // this will prevent phasing errors for forward references that
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
42 // resolve on the second pass
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
43 // we saved the org address in l -> codeaddr on pass 1
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
44 as -> addr = l -> codeaddr;
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
45 return;
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
46 }
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
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
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
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
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
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
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
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
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
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
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
69 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
70
47
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
71 /*
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
72 The operand for include is a string optionally enclosed in "
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
73 */
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
74 OPFUNC(pseudo_include)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
75 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
76 int v1;
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
77 char *fn;
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
78
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
79 // only include files on pass 1
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
80 // but make sure local include context is right
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
81 // for the next line...
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
82 if (as -> passnum != 1)
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
83 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
84 as -> context = lwasm_next_context(as);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
85 return;
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
86 }
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
87
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
88 while (**p && isspace(**p))
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
89 (*p)++;
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
90
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
91 if (!**p)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
92 {
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
93 register_error(as, l, 1, "Bad file name");
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
94 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
95 }
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
96
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
97 if (**p == '"')
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
98 {
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
99 // search for ending "
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
100 (*p)++;
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
101 for (v1 = 0; *((*p)+v1) && *((*p)+v1) != '"'; v1++)
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
102 /* do nothing */ ;
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
103 if (*((*p)+v1) != '"')
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
104 {
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
105 register_error(as, l, 1, "Bad file name");
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
106 return;
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
107 }
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
108 }
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
109 else
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
110 {
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
111 // search for a space type character
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
112 for (v1 = 0; *((*p)+v1) && !isspace(*((*p)+v1)); v1++)
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
113 ;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
114 }
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
115
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
116 fn = lwasm_alloc(v1 + 1);
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
117 memcpy(fn, *p, v1);
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
118 fn[v1] = '\0';
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
119
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
120 // end local label context on include
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
121 as -> context = lwasm_next_context(as);
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
122 if (lwasm_read_file(as, fn) < 0)
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
123 {
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
124 register_error(as, l, 1, "File include error (%s)", fn);
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
125 }
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
126 lwasm_free(fn);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
127 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
128
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
129 OPFUNC(pseudo_rmb)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
130 {
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
131 int rval;
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
132 lwasm_expr_stack_t *s;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
133
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
134 s = lwasm_evaluate_expr(as, l, *p, NULL);
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
135 if (!s)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
136 {
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
137 register_error(as, l, 1, "Bad expression");
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
138 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
139 }
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
140 if (!lwasm_expr_is_constant(s))
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
141 {
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
142 register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
143 lwasm_expr_stack_free(s);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
144 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
145 }
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
146 rval = lwasm_expr_get_value(s);
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
147 lwasm_expr_stack_free(s);
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
148 l -> nocodelen = rval;
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
149 as -> addr += rval;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
150 }
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
151
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
152 OPFUNC(pseudo_rmd)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
153 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
154 int rval;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
155 lwasm_expr_stack_t *s;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
156
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
157 s = lwasm_evaluate_expr(as, l, *p, NULL);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
158 if (!s)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
159 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
160 register_error(as, l, 1, "Bad expression");
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
161 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
162 }
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
163 if (!lwasm_expr_is_constant(s))
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
164 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
165 register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
166 lwasm_expr_stack_free(s);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
167 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
168 }
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
169 rval = lwasm_expr_get_value(s) * 2;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
170 lwasm_expr_stack_free(s);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
171 l -> nocodelen = rval;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
172 as -> addr += rval;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
173 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
174
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
175 OPFUNC(pseudo_rmq)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
176 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
177 int rval;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
178 lwasm_expr_stack_t *s;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
179
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
180 s = lwasm_evaluate_expr(as, l, *p, NULL);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
181 if (!s)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
182 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
183 register_error(as, l, 1, "Bad expression");
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
184 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
185 }
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
186 if (!lwasm_expr_is_constant(s))
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
187 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
188 register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
189 lwasm_expr_stack_free(s);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
190 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
191 }
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
192 rval = lwasm_expr_get_value(s) * 4;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
193 lwasm_expr_stack_free(s);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
194 l -> nocodelen = rval;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
195 as -> addr += rval;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
196 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
197
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
198 OPFUNC(pseudo_zmb)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
199 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
200 int rval;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
201 lwasm_expr_stack_t *s;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
202
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
203 s = lwasm_evaluate_expr(as, l, *p, NULL);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
204 if (!s)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
205 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
206 register_error(as, l, 1, "Bad expression");
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
207 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
208 }
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
209 if (!lwasm_expr_is_constant(s))
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
210 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
211 register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
212 lwasm_expr_stack_free(s);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
213 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
214 }
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
215 rval = lwasm_expr_get_value(s);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
216 lwasm_expr_stack_free(s);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
217 while (rval-- > 0)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
218 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
219 lwasm_emit(as, l, 0);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
220 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
221 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
222
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
223 OPFUNC(pseudo_zmd)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
224 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
225 int rval;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
226 lwasm_expr_stack_t *s;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
227
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
228 s = lwasm_evaluate_expr(as, l, *p, NULL);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
229 if (!s)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
230 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
231 register_error(as, l, 1, "Bad expression");
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
232 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
233 }
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
234 if (!lwasm_expr_is_constant(s))
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
235 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
236 register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
237 lwasm_expr_stack_free(s);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
238 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
239 }
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
240 rval = lwasm_expr_get_value(s);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
241 lwasm_expr_stack_free(s);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
242 while (rval-- > 0)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
243 {
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
244 lwasm_emit(as, l, 0);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
245 lwasm_emit(as, l, 0);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
246 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
247 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
248
53
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
249 OPFUNC(pseudo_zmq)
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
250 {
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
251 int rval;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
252 lwasm_expr_stack_t *s;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
253
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
254 s = lwasm_evaluate_expr(as, l, *p, NULL);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
255 if (!s)
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
256 {
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
257 register_error(as, l, 1, "Bad expression");
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
258 return;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
259 }
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
260 if (!lwasm_expr_is_constant(s))
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
261 {
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
262 register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
263 lwasm_expr_stack_free(s);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
264 return;
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
265 }
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
266 rval = lwasm_expr_get_value(s);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
267 lwasm_expr_stack_free(s);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
268 while (rval-- > 0)
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
269 {
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
270 lwasm_emit(as, l, 0);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
271 lwasm_emit(as, l, 0);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
272 lwasm_emit(as, l, 0);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
273 lwasm_emit(as, l, 0);
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
274 }
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
275 }
493cb8ea50a0 Added rm[dq], zm[bdq]
lost
parents: 52
diff changeset
276
54
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
277 OPFUNC(pseudo_end)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
278 {
54
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
279 int rval;
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
280 lwasm_expr_stack_t *s;
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
281
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
282
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
283 as -> endseen = 1;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
284
54
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
285 // address only matters for DECB output
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
286 if (as -> outformat != OUTPUT_DECB)
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
287 return;
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
288
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
289 s = lwasm_evaluate_expr(as, l, *p, NULL);
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
290 if (!s)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
291 {
54
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
292 register_error(as, l, 1, "Bad expression");
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
293 return;
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
294 }
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
295 if (!lwasm_expr_is_constant(s))
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
296 {
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
297 register_error(as, l, 2, "Incomplete reference");
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
298 }
54
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
299 rval = lwasm_expr_get_value(s);
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
300 lwasm_expr_stack_free(s);
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
301
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
302 rval = rval & 0xffff;
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
303 if (as -> passnum == 2)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
304 {
54
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
305 as -> execaddr = rval;
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
306 l -> symaddr = rval;
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
307 l -> addrset = 2;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
308 }
54
360d53062bb9 Fixed typo in instruction table and added END directive
lost
parents: 53
diff changeset
309 }
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
310
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
311
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
312 OPFUNC(pseudo_align)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
313 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
314 int rval;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
315 lwasm_expr_stack_t *s;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
316 int cn;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
317
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
318 if (as -> passnum == 2)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
319 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
320 while (as -> addr < l -> symaddr)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
321 lwasm_emit(as, l, 0);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
322 return;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
323 }
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
324
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
325 s = lwasm_evaluate_expr(as, l, *p, NULL);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
326 if (!s)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
327 {
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
328 register_error(as, l, 1, "Bad expression");
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
329 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
330 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
331 if (!lwasm_expr_is_constant(s))
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
332 {
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
333 register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
334 }
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
335 rval = lwasm_expr_get_value(s);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
336 lwasm_expr_stack_free(s);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
337
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
338 if (rval < 1)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
339 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
340 register_error(as, l, 1, "Illegal alignment %d", rval);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
341 return;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
342 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
343
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
344 cn = l -> codeaddr % rval;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
345 if (cn)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
346 cn = rval - cn;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
347
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
348 while (cn--)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
349 {
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
350 lwasm_emit(as, l, 0);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
351 }
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
352 l -> symaddr = as -> addr;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
353 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
354
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
355 OPFUNC(pseudo_equ)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
356 {
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
357 int rval;
52
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
358
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
359 // equ is not needed to be processed on pass 2
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
360 if (as -> passnum != 1)
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
361 return;
b9856da2674a Added file inclusion
lost
parents: 50
diff changeset
362
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
363 if (l -> sym == NULL)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
364 {
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
365 register_error(as, l, 1, "No symbol specified");
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
366 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
367 }
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
368
63
d85ba47b1e8f Moved symbol registration so symbols that are in skipped code do not get registered and so EQU/SET can do their own registration
lost
parents: 57
diff changeset
369 if (lwasm_expr_result(as, l, p, EXPR_PASS1CONST, &rval) < 0)
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
370 rval = 0;
63
d85ba47b1e8f Moved symbol registration so symbols that are in skipped code do not get registered and so EQU/SET can do their own registration
lost
parents: 57
diff changeset
371
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
372 l -> symaddr = rval & 0xFFFF;
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
373 l -> addrset = 2;
63
d85ba47b1e8f Moved symbol registration so symbols that are in skipped code do not get registered and so EQU/SET can do their own registration
lost
parents: 57
diff changeset
374
d85ba47b1e8f Moved symbol registration so symbols that are in skipped code do not get registered and so EQU/SET can do their own registration
lost
parents: 57
diff changeset
375 lwasm_register_symbol(as, l, l -> sym, rval);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
376 }
63
d85ba47b1e8f Moved symbol registration so symbols that are in skipped code do not get registered and so EQU/SET can do their own registration
lost
parents: 57
diff changeset
377
d85ba47b1e8f Moved symbol registration so symbols that are in skipped code do not get registered and so EQU/SET can do their own registration
lost
parents: 57
diff changeset
378 OPFUNC(pseudo_set)
d85ba47b1e8f Moved symbol registration so symbols that are in skipped code do not get registered and so EQU/SET can do their own registration
lost
parents: 57
diff changeset
379 {
d85ba47b1e8f Moved symbol registration so symbols that are in skipped code do not get registered and so EQU/SET can do their own registration
lost
parents: 57
diff changeset
380 }
d85ba47b1e8f Moved symbol registration so symbols that are in skipped code do not get registered and so EQU/SET can do their own registration
lost
parents: 57
diff changeset
381
50
e672232caffe Added rmb pseudo op
lost
parents: 49
diff changeset
382 /*
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
383 void pseudo_set(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
384 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
385 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
386
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
387 if (cl -> hassym == 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
388 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
389 errorp1(ERR_NOSYM);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
390 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
391 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
392 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
393 // eval_expr returns -1 if there was a forward ref
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
394 // or -2 if the expr was invalid
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
395 if (rval == -2)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
396 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
397 // carp
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
398 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
399 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
400 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
401 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
402 // remove symbol ref
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
403 cl -> hassym = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
404 // mark as a "comment" so it isn't processed next time
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
405 cl -> opcode = -1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
406 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
407 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
408 cl -> code_symloc = v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
409 cl -> isset = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
410 cl -> isequ = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
411 cl -> symaddr = v1 & 0xFFFF;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
412 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
413
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
414 void pseudo_setdp(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
415 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
416 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
417
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
418 if (cl -> hassym)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
419 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
420 register_error(as, cl, ERR_SYM);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
421 cl -> hassym = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
422 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
423 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
424 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
425 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
426 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
427 if (rval == -1)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
428 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
429 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
430 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
431 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
432 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
433 cl -> opcode = -1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
434 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
435 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
436 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
437 // setdp needs to resolve properly on pass 2
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
438 if (v1 > 0xff || v1 < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
439 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
440 errorp1(ERR_OVERFLOW);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
441 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
442 as -> dpval = v1 & 0xff;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
443 cl -> dpval = v1 & 0xff;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
444 cl -> issetdp = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
445 cl -> numcodebytes = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
446 //printf("%s\n", "SETDP2");
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
447 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
448 */
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
449
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
450 OPFUNC(pseudo_fcc)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
451 {
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
452 int delim = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
453
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
454 delim = **p;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
455 if (!delim)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
456 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
457 register_error(as, l, 1, "Bad operand");
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
458 return;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
459 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
460 *p += 1;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
461 while (**p && **p != delim)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
462 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
463 lwasm_emit(as, l, **p);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
464 (*p)++;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
465 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
466 if (**p)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
467 (*p)++;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
468 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
469
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
470
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
471 OPFUNC(pseudo_fcs)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
472 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
473 int delim = 0;
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
474
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
475 delim = **p;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
476 if (!delim)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
477 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
478 register_error(as, l, 1, "Bad operand");
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
479 return;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
480 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
481 *p += 1;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
482 while (**p && **p != delim)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
483 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
484 if (!*((*p) + 1) || *((*p) + 1) == delim)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
485 lwasm_emit(as, l, **p | 0x80);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
486 else
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
487 lwasm_emit(as, l, **p);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
488 (*p)++;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
489 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
490 if (**p)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
491 (*p)++;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
492 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
493
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
494 OPFUNC(pseudo_fcn)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
495 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
496 int delim = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
497
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
498 delim = **p;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
499 if (!delim)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
500 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
501 register_error(as, l, 1, "Bad operand");
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
502 return;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
503 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
504 *p += 1;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
505 while (**p && **p != delim)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
506 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
507 lwasm_emit(as, l, **p);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
508 (*p)++;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
509 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
510 if (**p)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
511 (*p)++;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
512 lwasm_emit(as, l, 0);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
513 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
514
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
515 OPFUNC(pseudo_fcb)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
516 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
517 int v1;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
518
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
519 fcb_again:
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
520 if (lwasm_expr_result(as, l, p, EXPR_PASS2CONST | EXPR_BYTE, &v1) < 0)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
521 return;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
522
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
523 lwasm_emit(as, l, v1);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
524 if (**p == ',')
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
525 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
526 (*p)++;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
527 goto fcb_again;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
528 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
529 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
530
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
531 OPFUNC(pseudo_fdb)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
532 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
533 int v1;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
534
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
535 fdb_again:
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
536 if (lwasm_expr_result(as, l, p, EXPR_PASS2CONST, &v1) < 0)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
537 return;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
538
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
539 lwasm_emit(as, l, v1 >> 8);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
540 lwasm_emit(as, l, v1 & 0xff);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
541 if (**p == ',')
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
542 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
543 (*p)++;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
544 goto fdb_again;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
545 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
546 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
547
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
548 OPFUNC(pseudo_fqb)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
549 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
550 int v1;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
551
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
552 fqb_again:
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
553 if (lwasm_expr_result(as, l, p, EXPR_PASS2CONST, &v1) < 0)
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
554 return;
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
555
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
556 lwasm_emit(as, l, v1 >> 24);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
557 lwasm_emit(as, l, v1 >> 16);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
558 lwasm_emit(as, l, v1 >> 8);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
559 lwasm_emit(as, l, v1 & 0xff);
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
560 if (**p == ',')
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
561 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
562 (*p)++;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
563 goto fqb_again;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
564 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
565 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
566
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
567 // don't need to do anything if we are executing one of these
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
568 OPFUNC(pseudo_endc)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
569 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
570 if (as -> skipcond && !(as -> skipmacro))
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
571 {
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
572 as -> skipcount -= 1;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
573 if (as -> skipcount <= 0)
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
574 {
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
575 as -> skipcond = 0;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
576 }
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
577 }
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
578 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
579 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
580
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
581 // if "else" executes, we must be going into an "ignore" state
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
582 OPFUNC(pseudo_else)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
583 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
584 if (as -> skipmacro)
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
585 return;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
586
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
587 if (as -> skipcond)
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
588 {
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
589 if (as -> skipcount == 1)
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
590 {
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
591 as -> skipcount = 0;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
592 as -> skipcond = 0;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
593 }
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
594 return;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
595 }
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
596
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
597 as -> skipcond = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
598 as -> skipcount = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
599 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
600
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
601 OPFUNC(pseudo_ifne)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
602 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
603 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
604 int rval;
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
605
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
606 if (as -> skipcond && !(as -> skipmacro))
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
607 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
608 as -> skipcount++;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
609 return;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
610 }
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
611
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
612 rval = lwasm_expr_result(as, l, p, EXPR_PASS1CONST, &v1);
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
613 if (rval < 0)
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
614 return;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
615 if (!v1)
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
616 {
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
617 as -> skipcond = 1;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
618 as -> skipcount = 1;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
619 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
620 }
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
621
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
622 OPFUNC(pseudo_ifeq)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
623 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
624 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
625 int rval;
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
626
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
627 if (as -> skipcond && !(as -> skipmacro))
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
628 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
629 as -> skipcount++;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
630 return;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
631 }
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
632
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
633 rval = lwasm_expr_result(as, l, p, EXPR_PASS1CONST, &v1);
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
634 if (rval < 0)
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
635 return;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
636 if (v1)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
637 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
638 as -> skipcond = 1;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
639 as -> skipcount = 1;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
640 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
641 }
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
642
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
643 OPFUNC(pseudo_iflt)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
644 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
645 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
646 int rval;
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
647
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
648 if (as -> skipcond && !(as -> skipmacro))
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
649 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
650 as -> skipcount++;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
651 return;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
652 }
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
653
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
654 rval = lwasm_expr_result(as, l, p, EXPR_PASS1CONST, &v1);
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
655 if (rval < 0)
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
656 return;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
657 if (v1 >= 0)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
658 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
659 as -> skipcond = 1;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
660 as -> skipcount = 1;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
661 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
662 }
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
663
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
664 OPFUNC(pseudo_ifle)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
665 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
666 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
667 int rval;
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
668
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
669 if (as -> skipcond && !(as -> skipmacro))
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
670 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
671 as -> skipcount++;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
672 return;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
673 }
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
674
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
675 rval = lwasm_expr_result(as, l, p, EXPR_PASS1CONST, &v1);
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
676 if (rval < 0)
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
677 return;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
678 if (v1 > 0)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
679 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
680 as -> skipcond = 1;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
681 as -> skipcount = 1;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
682 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
683 }
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
684
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
685 OPFUNC(pseudo_ifgt)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
686 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
687 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
688 int rval;
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
689
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
690 if (as -> skipcond && !(as -> skipmacro))
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
691 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
692 as -> skipcount++;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
693 return;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
694 }
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
695
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
696 rval = lwasm_expr_result(as, l, p, EXPR_PASS1CONST, &v1);
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
697 if (rval < 0)
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
698 return;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
699 if (v1 <= 0)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
700 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
701 as -> skipcond = 1;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
702 as -> skipcount = 1;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
703 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
704 }
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
705
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
706 OPFUNC(pseudo_ifge)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
707 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
708 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
709 int rval;
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
710
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
711 if (as -> skipcond && !(as -> skipmacro))
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
712 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
713 as -> skipcount++;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
714 return;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
715 }
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
716
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
717 rval = lwasm_expr_result(as, l, p, EXPR_PASS1CONST, &v1);
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
718 if (rval < 0)
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
719 return;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
720 if (v1 < 0)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
721 {
57
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
722 as -> skipcond = 1;
035b95a3690f Added conditional assembly and macros
lost
parents: 56
diff changeset
723 as -> skipcount = 1;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
724 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
725 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
726
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
727 OPFUNC(pseudo_error)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
728 {
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
729 register_error(as, l, 1, "User error: %s", *p);
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
730 }
56
55260a178667 Added from f* pseudo ops
lost
parents: 54
diff changeset
731