annotate src/pseudo.c @ 49:21ae0fab469b

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