annotate src/pseudo.c @ 0:57495da01900

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