Mercurial > hg-old > index.cgi
annotate lwasm/insn_gen.c @ 276:23034db7dd8a 2.5
fixed expression 'slots' to not store null on a pass 1 store
author | lost |
---|---|
date | Mon, 31 Aug 2009 08:39:36 +0000 |
parents | 7803d2d09993 |
children |
rev | line source |
---|---|
0 | 1 /* |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
2 insn_gen.c, 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
|
3 |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
4 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
|
5 |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
6 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
|
7 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
|
8 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
|
9 version. |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
10 |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
11 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
|
12 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
|
13 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
|
14 more details. |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
15 |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
16 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
|
17 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
|
18 |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
19 Contains code for parsing general addressing modes (IMM+DIR+EXT+IND) |
34568fab6058
Fixed package to include all required files; also added copyright preamble to all source files
lost
parents:
0
diff
changeset
|
20 */ |
0 | 21 |
212 | 22 #include <config.h> |
23 | |
0 | 24 #include <ctype.h> |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
25 #include <stdlib.h> |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
26 |
0 | 27 #include "lwasm.h" |
28 #include "instab.h" | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
29 #include "expr.h" |
0 | 30 |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
31 extern void insn_indexed_aux(asmstate_t *as, lwasm_line_t *l, const char **p, int *b1, int *b2, int *b3); |
0 | 32 |
34 | 33 // "extra" is required due to the way OIM, EIM, TIM, and AIM work |
34 void insn_gen_aux(asmstate_t *as, lwasm_line_t *l, char **optr, int opnum, int extra) | |
0 | 35 { |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
36 int b1 = -1, b2 = -1, b3 = -1; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
37 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
38 const char *optr2; |
0 | 39 int v1, tv, rval; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
40 lwasm_expr_stack_t *s; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
41 int f8 = 0; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
42 int f16 = 0; |
65
31d8e85706e7
Implemented setdp and corrected handling of direct page detection in insn_gen_aux()
lost
parents:
62
diff
changeset
|
43 int isdp = 0; |
77 | 44 |
0 | 45 optr2 = *optr; |
46 while (*optr2 && !isspace(*optr2) && *optr2 != ',') optr2++ | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
47 /* do nothing */ ; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
48 |
0 | 49 if (*optr2 != ',' && **optr != '[') |
50 { | |
51 // not indexed | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
52 if (l -> fsize == 1) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
53 f8 = 1; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
54 else if (l -> fsize == 2) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
55 f16 = 1; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
56 |
0 | 57 if (**optr == '<') |
58 { | |
59 (*optr)++; | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
60 f8 = 1; |
0 | 61 } |
163 | 62 // for compatibility with asxxxx |
63 // * followed by a digit, alpha, or _, or ., or ?, or another * is "f8" | |
64 else if (**optr == '*') | |
65 { | |
66 tv = *(*optr + 1); | |
67 if (isdigit(tv) || isalpha(tv) || tv == '_' || tv == '.' || tv == '?' || tv == '@' || tv == '*' || tv == '+' || tv == '-') | |
68 { | |
69 f8 = 1; | |
70 (*optr)++; | |
71 } | |
72 } | |
0 | 73 else if (**optr == '>') |
74 { | |
75 (*optr)++; | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
76 f16 = 1; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
77 } |
77 | 78 rval = lwasm_expr_result2(as, l, optr, 0, &v1, 0); |
79 if (rval != 0) | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
80 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
81 f16 = 1; |
77 | 82 v1 = 0; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
83 l -> fsize = 2; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
84 } |
65
31d8e85706e7
Implemented setdp and corrected handling of direct page detection in insn_gen_aux()
lost
parents:
62
diff
changeset
|
85 |
31d8e85706e7
Implemented setdp and corrected handling of direct page detection in insn_gen_aux()
lost
parents:
62
diff
changeset
|
86 if (((v1 >> 8) & 0xff) == (as -> dpval & 0xff)) |
31d8e85706e7
Implemented setdp and corrected handling of direct page detection in insn_gen_aux()
lost
parents:
62
diff
changeset
|
87 isdp = 1; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
88 |
77 | 89 // disallow non-explicit DP in obj target |
90 if (as -> outformat == OUTPUT_OBJ && !f8) | |
91 f16 = 1; | |
92 | |
65
31d8e85706e7
Implemented setdp and corrected handling of direct page detection in insn_gen_aux()
lost
parents:
62
diff
changeset
|
93 if (f8 || (!f16 && isdp)) |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
94 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
95 v1 = v1 & 0xffff; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
96 tv = v1 - ((as -> dpval) << 8); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
97 if (tv < 0 || tv > 0xff) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
98 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
99 register_error(as, l, 2, "Byte overflow"); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
100 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
101 v1 = v1 & 0xff; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
102 lwasm_emitop(as, l, instab[opnum].ops[0]); |
34 | 103 if (extra != -1) |
104 lwasm_emit(as, l, extra); | |
204
048ebb85f6ef
Added 8 bit external references for base page addressing mode
lost
parents:
163
diff
changeset
|
105 l -> relocoff = as -> addr - l -> codeaddr; |
048ebb85f6ef
Added 8 bit external references for base page addressing mode
lost
parents:
163
diff
changeset
|
106 l -> reloc8bit = 1; |
220
2b254f02b252
Fixed off by one relocation offset for direct page external references
lost
parents:
212
diff
changeset
|
107 lwasm_emit(as, l, v1 & 0xff); |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
108 return; |
0 | 109 } |
110 else | |
111 { | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
112 // everything else is 16 bit.... |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
113 lwasm_emitop(as, l, instab[opnum].ops[2]); |
34 | 114 if (extra != -1) |
115 lwasm_emit(as, l, extra); | |
77 | 116 l -> relocoff = as -> addr - l -> codeaddr; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
117 lwasm_emit(as, l, v1 >> 8); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
118 lwasm_emit(as, l, v1 & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
119 return; |
0 | 120 } |
121 } | |
122 | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
123 lwasm_emitop(as, l, instab[opnum].ops[1]); |
34 | 124 if (extra != -1) |
125 lwasm_emit(as, l, extra); | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
126 insn_indexed_aux(as, l, (const char **)optr, &b1, &b2, &b3); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
127 if (b1 != -1) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
128 lwasm_emit(as, l, b1); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
129 if (b2 != -1) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
130 lwasm_emit(as, l, b2); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
131 if (b3 != -1) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
132 lwasm_emit(as, l, b3); |
0 | 133 return; |
134 } | |
135 | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
136 // the various insn_gen? functions have an immediate mode of ? bits |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
137 OPFUNC(insn_gen0) |
0 | 138 { |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
139 if (**p == '#') |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
140 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
141 register_error(as, l, 1, "Immediate mode not allowed"); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
142 return; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
143 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
144 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
145 // handle non-immediate |
34 | 146 insn_gen_aux(as, l, p, opnum, -1); |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
147 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
148 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
149 OPFUNC(insn_gen8) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
150 { |
0 | 151 int rval; |
77 | 152 int r; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
153 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
154 if (**p == '#') |
0 | 155 { |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
156 lwasm_emitop(as, l, instab[opnum].ops[3]); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
157 (*p)++; |
98
81fc353d4d69
Cleaned up old lwasm_expr_result() function and unused EXPR_* flags
lost
parents:
77
diff
changeset
|
158 r = lwasm_expr_result2(as, l, p, 0, &rval, 0); |
77 | 159 if (r != 0) |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
160 rval = 0; |
77 | 161 if (r == 1 && as -> passnum == 2) |
222
7803d2d09993
Allow 8 bit immediate operands to be external references
lost
parents:
220
diff
changeset
|
162 { |
7803d2d09993
Allow 8 bit immediate operands to be external references
lost
parents:
220
diff
changeset
|
163 l -> relocoff = as -> addr - l -> codeaddr; |
7803d2d09993
Allow 8 bit immediate operands to be external references
lost
parents:
220
diff
changeset
|
164 l -> reloc8bit = 1; |
7803d2d09993
Allow 8 bit immediate operands to be external references
lost
parents:
220
diff
changeset
|
165 } |
7803d2d09993
Allow 8 bit immediate operands to be external references
lost
parents:
220
diff
changeset
|
166 // register_error(as, l, 2, "Illegal external or intersegment reference"); |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
167 lwasm_emit(as, l, rval & 0xff); |
0 | 168 return; |
169 } | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
170 |
34 | 171 insn_gen_aux(as, l, p, opnum, -1); |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
172 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
173 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
174 OPFUNC(insn_gen16) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
175 { |
77 | 176 int rval, r; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
177 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
178 if (**p == '#') |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
179 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
180 lwasm_emitop(as, l, instab[opnum].ops[3]); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
181 (*p)++; |
77 | 182 |
183 r = lwasm_expr_result2(as, l, p, 0, &rval, 0); | |
184 if (r != 0) | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
185 rval = 0; |
77 | 186 if (r == 1 && as -> passnum == 2) |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
187 { |
77 | 188 l -> relocoff = as -> addr - l -> codeaddr; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
189 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
190 lwasm_emit(as, l, (rval >> 8) & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
191 lwasm_emit(as, l, rval & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
192 return; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
193 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
194 |
34 | 195 insn_gen_aux(as, l, p, opnum, -1); |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
196 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
197 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
198 OPFUNC(insn_gen32) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
199 { |
77 | 200 int r, rval; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
201 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
202 if (**p == '#') |
0 | 203 { |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
204 lwasm_emitop(as, l, instab[opnum].ops[3]); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
205 (*p)++; |
77 | 206 |
207 r = lwasm_expr_result2(as, l, p, 0, &rval, 0); | |
208 if (r != 0) | |
209 rval = 0; | |
210 if (r == 1 && as -> passnum == 2) | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
211 { |
77 | 212 register_error(as, l, 2, "Illegal external or intersegment reference"); |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
213 } |
77 | 214 |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
215 lwasm_emit(as, l, (rval >> 24) & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
216 lwasm_emit(as, l, (rval >> 16) & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
217 lwasm_emit(as, l, (rval >> 8) & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
218 lwasm_emit(as, l, rval & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
219 return; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
220 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
221 |
34 | 222 insn_gen_aux(as, l, p, opnum, -1); |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
223 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
224 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
225 OPFUNC(insn_imm8) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
226 { |
77 | 227 int r, rval; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
228 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
229 if (**p == '#') |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
230 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
231 lwasm_emitop(as, l, instab[opnum].ops[0]); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
232 (*p)++; |
77 | 233 |
98
81fc353d4d69
Cleaned up old lwasm_expr_result() function and unused EXPR_* flags
lost
parents:
77
diff
changeset
|
234 r = lwasm_expr_result2(as, l, p, 0, &rval, 0); |
77 | 235 if (r != 0) |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
236 rval = 0; |
77 | 237 if (r == 1 && as -> passnum == 2) |
238 register_error(as, l, 2, "Illegal external or intersegment reference"); | |
239 | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
240 if (rval < -128 || rval > 255) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
241 register_error(as, l, 2, "Byte overflow"); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
242 lwasm_emit(as, l, rval & 0xff); |
0 | 243 return; |
244 } | |
245 | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
246 register_error(as, l, 1, "Bad operand"); |
0 | 247 } |