annotate 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
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>
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
25 #include "lwasm.h"
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
26 #include "instab.h"
47
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
27 #include "expr.h"
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
28
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
29
47
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
30 OPFUNC(pseudo_org)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
31 {
47
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
32 int rval;
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
33 lwasm_expr_stack_t *s;
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 if (l -> sym)
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
36 {
47
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
37 register_error(as, l, 1, "No symbol allowed with ORG");
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
38 }
47
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
39 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
40 if (!s)
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
41 {
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
42 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
43 return;
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
44 }
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
45 if (!lwasm_expr_is_constant(s))
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
46 {
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
47 register_error(as, l, 1, "Illegal incomplete reference (pass 1)");
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
48 return;
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
49 }
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
50 rval = lwasm_expr_get_value(s);
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
51 l -> codeaddr = rval;
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
52 as -> addr = rval;
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
53 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
54
47
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
55 /*
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
56 void pseudo_include(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
57 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
58 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
59
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
60 if (as -> passnum != 1)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
61 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
62 while (**optr && isspace(**optr))
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
63 (*optr)++;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
64 if (!**optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
65 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
66 register_error(as, cl, ERR_BADFN);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
67 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
68 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
69 for (v1 = 0; *((*optr)+v1) && !isspace(*((*optr)+v1)); v1++)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
70 ;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
71 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
72 char *fn = malloc(v1 + 1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
73 strncpy(fn, *optr, v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
74 fn[v1] = '\0';
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
75 lwasm_read_file(as, fn);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
76 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
77 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
78
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
79
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
80 void pseudo_rmb(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
81 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
82 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
83
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
84 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
85 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
86 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
87 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
88 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
89 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
90 if (v1 < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
91 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
92 errorp1(ERR_BADOPER);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
93 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
94 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
95 cl -> len = v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
96 cl -> nocode = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
97 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
98
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
99 void pseudo_rmd(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
100 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
101 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
102
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
103 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
104 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
105 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
106 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
107 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
108 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
109 if (v1 < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
110 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
111 errorp1(ERR_BADOPER);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
112 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
113 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
114 cl -> len = v1 * 2;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
115 cl -> nocode = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
116 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
117
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
118 void pseudo_rmq(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
119 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
120 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
121
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
122 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
123 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
124 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
125 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
126 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
127 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
128 if (v1 < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
129 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
130 errorp1(ERR_BADOPER);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
131 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
132 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
133 cl -> len = v1 * 4;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
134 cl -> nocode = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
135 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
136
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
137 void pseudo_zmb(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
138 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
139 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
140
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
141 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
142 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
143 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
144 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
145 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
146 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
147 if (v1 < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
148 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
149 errorp1(ERR_BADOPER);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
150 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
151 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
152 while (v1--)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
153 emit(0);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
154 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
155
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
156 void pseudo_zmd(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
157 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
158 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
159
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
160 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
161 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
162 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
163 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
164 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
165 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
166 if (v1 < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
167 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
168 errorp1(ERR_BADOPER);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
169 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
170 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
171 while (v1--)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
172 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
173 emit(0);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
174 emit(0);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
175 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
176 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
177
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
178 void pseudo_zmq(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
179 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
180 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
181
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
182 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
183 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
184 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
185 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
186 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
187 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
188 if (v1 < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
189 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
190 errorp1(ERR_BADOPER);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
191 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
192 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
193 while (v1--)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
194 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
195 emit(0);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
196 emit(0);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
197 emit(0);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
198 emit(0);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
199 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
200 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
201
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
202 void pseudo_end(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
203 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
204 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
205
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
206 while (**optr && isspace(**optr))
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
207 ;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
208 if (**optr && **optr != '*' && **optr != ';')
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
209 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
210 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
211 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
212 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
213 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
214 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
215 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
216 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
217 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
218 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
219 v1 = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
220 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
221 if (as -> passnum == 2)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
222 as -> execaddr = v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
223 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
224
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
225 void pseudo_align(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
226 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
227 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
228 int cn;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
229
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
230 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
231 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
232 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
233 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
234 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
235 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
236 cn = cl -> addr % v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
237 if (cn)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
238 cn = v1 - cn;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
239
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
240 while (cn)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
241 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
242 emit(0);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
243 cn--;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
244 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
245 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
246
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
247 void pseudo_equ(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
248 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
249 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
250
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
251 if (cl -> hassym == 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
252 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
253 errorp1(ERR_NOSYM);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
254 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
255 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
256 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
257 // eval_expr returns -1 if there was a forward ref
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
258 // or -2 if the expr was invalid
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
259 if (rval == -2)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
260 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
261 // carp
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
262 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
263 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
264 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
265 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
266 // remove symbol ref
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
267 cl -> hassym = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
268 // mark as a "comment" so it isn't processed next time
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
269 cl -> opcode = -1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
270 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
271 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
272 cl -> code_symloc = v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
273 cl -> isequ = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
274 cl -> symaddr = v1 & 0xFFFF;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
275 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
276
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
277 void pseudo_set(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
278 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
279 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
280
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
281 if (cl -> hassym == 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
282 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
283 errorp1(ERR_NOSYM);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
284 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
285 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
286 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
287 // eval_expr returns -1 if there was a forward ref
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
288 // or -2 if the expr was invalid
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
289 if (rval == -2)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
290 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
291 // carp
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
292 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
293 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
294 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
295 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
296 // remove symbol ref
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
297 cl -> hassym = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
298 // mark as a "comment" so it isn't processed next time
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
299 cl -> opcode = -1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
300 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
301 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
302 cl -> code_symloc = v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
303 cl -> isset = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
304 cl -> isequ = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
305 cl -> symaddr = v1 & 0xFFFF;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
306 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
307
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
308 void pseudo_setdp(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
309 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
310 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
311
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
312 if (cl -> hassym)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
313 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
314 register_error(as, cl, ERR_SYM);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
315 cl -> hassym = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
316 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
317 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
318 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
319 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
320 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
321 if (rval == -1)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
322 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
323 errorp1(ERR_FORWARD);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
324 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
325 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
326 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
327 cl -> opcode = -1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
328 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
329 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
330 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
331 // setdp needs to resolve properly on pass 2
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
332 if (v1 > 0xff || v1 < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
333 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
334 errorp1(ERR_OVERFLOW);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
335 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
336 as -> dpval = v1 & 0xff;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
337 cl -> dpval = v1 & 0xff;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
338 cl -> issetdp = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
339 cl -> numcodebytes = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
340 //printf("%s\n", "SETDP2");
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
341 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
342
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
343 void pseudo_fcc(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
344 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
345 int cn = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
346 int delim = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
347
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
348 delim = *(*optr)++;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
349 if (!delim)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
350 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
351 errorp1(ERR_BADOPER);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
352 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
353 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
354 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
355 while (**optr && **optr != delim)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
356 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
357 emit(**optr);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
358 (*optr)++;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
359 cn += 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
360 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
361 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
362 cl -> len = cn;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
363 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
364
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
365 void pseudo_fcs(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
366 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
367 int cn = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
368 int delim = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
369
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
370 delim = *(*optr)++;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
371 if (!delim)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
372 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
373 errorp1(ERR_BADOPER);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
374 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
375 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
376 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
377 while (**optr && **optr != delim)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
378 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
379 if (!*((*optr) + 1) || *((*optr) + 1) == delim)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
380 emit((**optr) | 0x80);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
381 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
382 emit(**optr);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
383 (*optr)++;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
384 cn += 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
385 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
386 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
387 cl -> len = cn;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
388 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
389
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
390 void pseudo_fcn(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
391 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
392 int cn = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
393 int delim = 0;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
394
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
395 delim = *(*optr)++;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
396 if (!delim)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
397 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
398 errorp1(ERR_BADOPER);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
399 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
400 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
401 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
402 while (**optr && **optr != delim)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
403 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
404 emit(**optr);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
405 (*optr)++;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
406 cn += 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
407 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
408 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
409 emit(0);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
410 cl -> len = cn + 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
411 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
412
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
413 void pseudo_fcb(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
414 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
415 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
416
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
417 fcb_again:
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
418 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
419 if (v1 < -127 || v1 > 0xff)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
420 errorp2(ERR_OVERFLOW);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
421 emit(v1 & 0xff);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
422 if (**optr == ',')
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
423 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
424 (*optr)++;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
425 goto fcb_again;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
426 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
427 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
428
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
429 void pseudo_fdb(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
430 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
431 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
432
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
433 fdb_again:
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
434 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
435 emit((v1 >> 8) & 0xff);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
436 emit(v1 & 0xff);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
437 if (**optr == ',')
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
438 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
439 (*optr)++;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
440 goto fdb_again;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
441 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
442 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
443
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
444 void pseudo_fqb(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
445 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
446 int rval, v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
447
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
448 fqb_again:
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
449 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
450 emit((v1 >> 24) & 0xff);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
451 emit((v1 >> 16) & 0xff);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
452 emit((v1 >> 8) & 0xff);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
453 emit(v1 & 0xff);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
454 if (**optr == ',')
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
455 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
456 (*optr)++;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
457 goto fqb_again;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
458 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
459 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
460
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
461 // don't need to do anything if we are executing one of these
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
462 void pseudo_endc(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
463 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
464 return;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
465 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
466
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
467 // if "else" executes, we must be going into an "ignore" state
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
468 void pseudo_else(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
469 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
470 as -> skipcond = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
471 as -> skipcount = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
472 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
473
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
474 void pseudo_ifne(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
475 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
476 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
477 int rval;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
478 // printf("ifne %s\n", *optr);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
479 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
480 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
481 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
482 errorp1(ERR_BADCOND);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
483 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
484 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
485 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
486 // printf("Condition value: %d\n", v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
487 if (!v1)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
488 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
489 // printf("condition no match\n");
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
490 as -> skipcond = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
491 as -> skipcount = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
492 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
493 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
494 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
495 void pseudo_ifeq(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
496 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
497 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
498 int rval;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
499
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
500 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
501 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
502 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
503 errorp1(ERR_BADCOND);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
504 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
505 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
506 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
507 if (v1)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
508 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
509 as -> skipcond = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
510 as -> skipcount = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
511 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
512 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
513 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
514 void pseudo_iflt(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
515 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
516 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
517 int rval;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
518
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
519 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
520 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
521 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
522 errorp1(ERR_BADCOND);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
523 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
524 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
525 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
526 if (v1 >= 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
527 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
528 as -> skipcond = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
529 as -> skipcount = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
530 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
531 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
532 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
533 void pseudo_ifle(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
534 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
535 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
536 int rval;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
537
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
538 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
539 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
540 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
541 errorp1(ERR_BADCOND);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
542 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
543 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
544 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
545 if (v1 > 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
546 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
547 as -> skipcond = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
548 as -> skipcount = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
549 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
550 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
551 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
552 void pseudo_ifgt(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
553 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
554 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
555 int rval;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
556
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
557 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
558 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
559 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
560 errorp1(ERR_BADCOND);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
561 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
562 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
563 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
564 if (v1 <= 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
565 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
566 as -> skipcond = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
567 as -> skipcount = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
568 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
569 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
570 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
571 void pseudo_ifge(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
572 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
573 int v1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
574 int rval;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
575
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
576 rval = eval_expr(as, cl, optr, &v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
577 if (rval < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
578 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
579 errorp1(ERR_BADCOND);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
580 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
581 else
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
582 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
583 if (v1 < 0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
584 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
585 as -> skipcond = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
586 as -> skipcount = 1;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
587 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
588 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
589 }
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
590
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
591 void pseudo_error(asmstate_t *as, sourceline_t *cl, char **optr)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
592 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
593 cl -> user_error = strdup(*optr);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
594 errorp1(ERR_USER);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
595 }
47
804d7465e0f9 Implemented ORG and fixed problems with constants using $, &, or @ to specify base
lost
parents: 4
diff changeset
596 */