comparison lwasm/insn_gen.c @ 136:b78b2f1e011e

Fixed additional instruction length problems with logic/memory operations
author lost@l-w.ca
date Wed, 17 Aug 2011 21:04:33 -0600
parents 7317fbe024af
children f8b07153abc4
comparison
equal deleted inserted replaced
135:fe117454a1e7 136:b78b2f1e011e
33 33
34 extern void insn_parse_indexed_aux(asmstate_t *as, line_t *l, char **p); 34 extern void insn_parse_indexed_aux(asmstate_t *as, line_t *l, char **p);
35 extern void insn_resolve_indexed_aux(asmstate_t *as, line_t *l, int force, int elen); 35 extern void insn_resolve_indexed_aux(asmstate_t *as, line_t *l, int force, int elen);
36 36
37 // "extra" is required due to the way OIM, EIM, TIM, and AIM work 37 // "extra" is required due to the way OIM, EIM, TIM, and AIM work
38 void insn_parse_gen_aux(asmstate_t *as, line_t *l, char **p) 38 void insn_parse_gen_aux(asmstate_t *as, line_t *l, char **p, int elen)
39 { 39 {
40 const char *optr2; 40 const char *optr2;
41 int v1, tv; 41 int v1, tv;
42 lw_expr_t s; 42 lw_expr_t s;
43 43
113 out: 113 out:
114 if (l -> lint2 != -1) 114 if (l -> lint2 != -1)
115 { 115 {
116 if (l -> lint2 == 0) 116 if (l -> lint2 == 0)
117 { 117 {
118 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1; 118 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1 + elen;
119 } 119 }
120 else if (l -> lint2 == 2) 120 else if (l -> lint2 == 2)
121 { 121 {
122 l -> len = OPLEN(instab[l -> insn].ops[2]) + 2; 122 l -> len = OPLEN(instab[l -> insn].ops[2]) + 2 + elen;
123 } 123 }
124 else if (l -> lint2 == 1 && l -> lint != -1) 124 else if (l -> lint2 == 1 && l -> lint != -1)
125 { 125 {
126 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1; 126 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1 + elen;
127 } 127 }
128 } 128 }
129 } 129 }
130 130
131 void insn_resolve_gen_aux(asmstate_t *as, line_t *l, int force, int elen) 131 void insn_resolve_gen_aux(asmstate_t *as, line_t *l, int force, int elen)
166 out: 166 out:
167 if (l -> lint2 != -1) 167 if (l -> lint2 != -1)
168 { 168 {
169 if (l -> lint2 == 0) 169 if (l -> lint2 == 0)
170 { 170 {
171 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1; 171 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1 + elen;
172 } 172 }
173 else if (l -> lint2 == 2) 173 else if (l -> lint2 == 2)
174 { 174 {
175 l -> len = OPLEN(instab[l -> insn].ops[2]) + 2; 175 l -> len = OPLEN(instab[l -> insn].ops[2]) + 2 + elen;
176 } 176 }
177 else if (l -> lint2 == 1 && l -> lint != -1) 177 else if (l -> lint2 == 1 && l -> lint != -1)
178 { 178 {
179 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1; 179 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1 + elen;
180 } 180 }
181 } 181 }
182 } 182 }
183 183
184 void insn_emit_gen_aux(asmstate_t *as, line_t *l, int extra) 184 void insn_emit_gen_aux(asmstate_t *as, line_t *l, int extra)
213 lwasm_register_error(as, l, "Immediate mode not allowed"); 213 lwasm_register_error(as, l, "Immediate mode not allowed");
214 return; 214 return;
215 } 215 }
216 216
217 // handle non-immediate 217 // handle non-immediate
218 insn_parse_gen_aux(as, l, p); 218 insn_parse_gen_aux(as, l, p, 0);
219 } 219 }
220 220
221 RESOLVEFUNC(insn_resolve_gen0) 221 RESOLVEFUNC(insn_resolve_gen0)
222 { 222 {
223 if (l -> len != -1) 223 if (l -> len != -1)
250 lwasm_save_expr(l, 0, e); 250 lwasm_save_expr(l, 0, e);
251 return; 251 return;
252 } 252 }
253 253
254 // handle non-immediate 254 // handle non-immediate
255 insn_parse_gen_aux(as, l, p); 255 insn_parse_gen_aux(as, l, p, 0);
256 if (l -> lint2 != -1) 256 if (l -> lint2 != -1)
257 { 257 {
258 if (l -> lint2 == 0) 258 if (l -> lint2 == 0)
259 { 259 {
260 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1; 260 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;
311 lwasm_save_expr(l, 0, e); 311 lwasm_save_expr(l, 0, e);
312 return; 312 return;
313 } 313 }
314 314
315 // handle non-immediate 315 // handle non-immediate
316 insn_parse_gen_aux(as, l, p); 316 insn_parse_gen_aux(as, l, p, 0);
317 if (l -> lint2 != -1) 317 if (l -> lint2 != -1)
318 { 318 {
319 if (l -> lint2 == 0) 319 if (l -> lint2 == 0)
320 { 320 {
321 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1; 321 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;
372 lwasm_save_expr(l, 0, e); 372 lwasm_save_expr(l, 0, e);
373 return; 373 return;
374 } 374 }
375 375
376 // handle non-immediate 376 // handle non-immediate
377 insn_parse_gen_aux(as, l, p); 377 insn_parse_gen_aux(as, l, p, 0);
378 if (l -> lint2 != -1) 378 if (l -> lint2 != -1)
379 { 379 {
380 if (l -> lint2 == 0) 380 if (l -> lint2 == 0)
381 { 381 {
382 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1; 382 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1;