annotate src/pseudo.c @ 22:b704f7ffc8ba

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