Mercurial > hg-old > index.cgi
annotate src/insn_gen.c @ 96:7fbccdd1defb
Added doc subdirectory to distribution
author | lost |
---|---|
date | Sat, 17 Jan 2009 07:09:02 +0000 |
parents | a338d496350e |
children | 81fc353d4d69 |
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 |
22 #include <ctype.h> | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
23 #include <stdlib.h> |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
24 |
0 | 25 #include "lwasm.h" |
26 #include "instab.h" | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
27 #include "expr.h" |
0 | 28 |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
29 extern void insn_indexed_aux(asmstate_t *as, lwasm_line_t *l, const char **p, int *b1, int *b2, int *b3); |
0 | 30 |
34 | 31 // "extra" is required due to the way OIM, EIM, TIM, and AIM work |
32 void insn_gen_aux(asmstate_t *as, lwasm_line_t *l, char **optr, int opnum, int extra) | |
0 | 33 { |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
34 int b1 = -1, b2 = -1, b3 = -1; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
35 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
36 const char *optr2; |
0 | 37 int v1, tv, rval; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
38 lwasm_expr_stack_t *s; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
39 int f8 = 0; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
40 int f16 = 0; |
65
31d8e85706e7
Implemented setdp and corrected handling of direct page detection in insn_gen_aux()
lost
parents:
62
diff
changeset
|
41 int isdp = 0; |
77 | 42 |
0 | 43 optr2 = *optr; |
44 while (*optr2 && !isspace(*optr2) && *optr2 != ',') optr2++ | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
45 /* do nothing */ ; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
46 |
0 | 47 if (*optr2 != ',' && **optr != '[') |
48 { | |
49 // not indexed | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
50 if (l -> fsize == 1) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
51 f8 = 1; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
52 else if (l -> fsize == 2) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
53 f16 = 1; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
54 |
0 | 55 if (**optr == '<') |
56 { | |
57 (*optr)++; | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
58 f8 = 1; |
0 | 59 } |
60 else if (**optr == '>') | |
61 { | |
62 (*optr)++; | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
63 f16 = 1; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
64 } |
77 | 65 rval = lwasm_expr_result2(as, l, optr, 0, &v1, 0); |
66 if (rval != 0) | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
67 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
68 f16 = 1; |
77 | 69 v1 = 0; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
70 l -> fsize = 2; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
71 } |
65
31d8e85706e7
Implemented setdp and corrected handling of direct page detection in insn_gen_aux()
lost
parents:
62
diff
changeset
|
72 |
31d8e85706e7
Implemented setdp and corrected handling of direct page detection in insn_gen_aux()
lost
parents:
62
diff
changeset
|
73 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
|
74 isdp = 1; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
75 |
77 | 76 // disallow non-explicit DP in obj target |
77 if (as -> outformat == OUTPUT_OBJ && !f8) | |
78 f16 = 1; | |
79 | |
65
31d8e85706e7
Implemented setdp and corrected handling of direct page detection in insn_gen_aux()
lost
parents:
62
diff
changeset
|
80 if (f8 || (!f16 && isdp)) |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
81 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
82 v1 = v1 & 0xffff; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
83 tv = v1 - ((as -> dpval) << 8); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
84 if (tv < 0 || tv > 0xff) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
85 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
86 register_error(as, l, 2, "Byte overflow"); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
87 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
88 v1 = v1 & 0xff; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
89 lwasm_emitop(as, l, instab[opnum].ops[0]); |
34 | 90 if (extra != -1) |
91 lwasm_emit(as, l, extra); | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
92 lwasm_emit(as, l, v1 & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
93 return; |
0 | 94 } |
95 else | |
96 { | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
97 // everything else is 16 bit.... |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
98 lwasm_emitop(as, l, instab[opnum].ops[2]); |
34 | 99 if (extra != -1) |
100 lwasm_emit(as, l, extra); | |
77 | 101 l -> relocoff = as -> addr - l -> codeaddr; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
102 lwasm_emit(as, l, v1 >> 8); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
103 lwasm_emit(as, l, v1 & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
104 return; |
0 | 105 } |
106 } | |
107 | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
108 lwasm_emitop(as, l, instab[opnum].ops[1]); |
34 | 109 if (extra != -1) |
110 lwasm_emit(as, l, extra); | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
111 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
|
112 if (b1 != -1) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
113 lwasm_emit(as, l, b1); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
114 if (b2 != -1) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
115 lwasm_emit(as, l, b2); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
116 if (b3 != -1) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
117 lwasm_emit(as, l, b3); |
0 | 118 return; |
119 } | |
120 | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
121 // 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
|
122 OPFUNC(insn_gen0) |
0 | 123 { |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
124 if (**p == '#') |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
125 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
126 register_error(as, l, 1, "Immediate mode not allowed"); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
127 return; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
128 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
129 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
130 // handle non-immediate |
34 | 131 insn_gen_aux(as, l, p, opnum, -1); |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
132 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
133 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
134 OPFUNC(insn_gen8) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
135 { |
0 | 136 int rval; |
77 | 137 int r; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
138 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
139 if (**p == '#') |
0 | 140 { |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
141 lwasm_emitop(as, l, instab[opnum].ops[3]); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
142 (*p)++; |
77 | 143 r = lwasm_expr_result2(as, l, p, EXPR_PASS2CONST | EXPR_BYTE, &rval, 0); |
144 if (r != 0) | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
145 rval = 0; |
77 | 146 if (r == 1 && as -> passnum == 2) |
147 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
|
148 lwasm_emit(as, l, rval & 0xff); |
0 | 149 return; |
150 } | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
151 |
34 | 152 insn_gen_aux(as, l, p, opnum, -1); |
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 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
155 OPFUNC(insn_gen16) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
156 { |
77 | 157 int rval, r; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
158 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
159 if (**p == '#') |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
160 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
161 lwasm_emitop(as, l, instab[opnum].ops[3]); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
162 (*p)++; |
77 | 163 |
164 r = lwasm_expr_result2(as, l, p, 0, &rval, 0); | |
165 if (r != 0) | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
166 rval = 0; |
77 | 167 if (r == 1 && as -> passnum == 2) |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
168 { |
77 | 169 l -> relocoff = as -> addr - l -> codeaddr; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
170 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
171 lwasm_emit(as, l, (rval >> 8) & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
172 lwasm_emit(as, l, rval & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
173 return; |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
174 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
175 |
34 | 176 insn_gen_aux(as, l, p, opnum, -1); |
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 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
179 OPFUNC(insn_gen32) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
180 { |
77 | 181 int r, rval; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
182 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
183 if (**p == '#') |
0 | 184 { |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
185 lwasm_emitop(as, l, instab[opnum].ops[3]); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
186 (*p)++; |
77 | 187 |
188 r = lwasm_expr_result2(as, l, p, 0, &rval, 0); | |
189 if (r != 0) | |
190 rval = 0; | |
191 if (r == 1 && as -> passnum == 2) | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
192 { |
77 | 193 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
|
194 } |
77 | 195 |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
196 lwasm_emit(as, l, (rval >> 24) & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
197 lwasm_emit(as, l, (rval >> 16) & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
198 lwasm_emit(as, l, (rval >> 8) & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
199 lwasm_emit(as, l, rval & 0xff); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
200 return; |
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 |
34 | 203 insn_gen_aux(as, l, p, opnum, -1); |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
204 } |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
205 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
206 OPFUNC(insn_imm8) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
207 { |
77 | 208 int r, rval; |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
209 |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
210 if (**p == '#') |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
211 { |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
212 lwasm_emitop(as, l, instab[opnum].ops[0]); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
213 (*p)++; |
77 | 214 |
215 r = lwasm_expr_result2(as, l, p, EXPR_PASS2CONST | EXPR_BYTE, &rval, 0); | |
216 if (r != 0) | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
217 rval = 0; |
77 | 218 if (r == 1 && as -> passnum == 2) |
219 register_error(as, l, 2, "Illegal external or intersegment reference"); | |
220 | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
221 if (rval < -128 || rval > 255) |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
222 register_error(as, l, 2, "Byte overflow"); |
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
223 lwasm_emit(as, l, rval & 0xff); |
0 | 224 return; |
225 } | |
226 | |
33
74a3fef7c8d0
Added general addressing modes (immediate, base page, extended, indexed)
lost
parents:
4
diff
changeset
|
227 register_error(as, l, 1, "Bad operand"); |
0 | 228 } |