Mercurial > hg > index.cgi
changeset 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 | fe117454a1e7 |
children | b62f5389b859 |
files | lwasm/insn_gen.c lwasm/insn_logicmem.c |
diffstat | 2 files changed, 17 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/lwasm/insn_gen.c Wed Aug 17 19:44:32 2011 -0600 +++ b/lwasm/insn_gen.c Wed Aug 17 21:04:33 2011 -0600 @@ -35,7 +35,7 @@ extern void insn_resolve_indexed_aux(asmstate_t *as, line_t *l, int force, int elen); // "extra" is required due to the way OIM, EIM, TIM, and AIM work -void insn_parse_gen_aux(asmstate_t *as, line_t *l, char **p) +void insn_parse_gen_aux(asmstate_t *as, line_t *l, char **p, int elen) { const char *optr2; int v1, tv; @@ -115,15 +115,15 @@ { if (l -> lint2 == 0) { - l -> len = OPLEN(instab[l -> insn].ops[0]) + 1; + l -> len = OPLEN(instab[l -> insn].ops[0]) + 1 + elen; } else if (l -> lint2 == 2) { - l -> len = OPLEN(instab[l -> insn].ops[2]) + 2; + l -> len = OPLEN(instab[l -> insn].ops[2]) + 2 + elen; } else if (l -> lint2 == 1 && l -> lint != -1) { - l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1; + l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1 + elen; } } } @@ -168,15 +168,15 @@ { if (l -> lint2 == 0) { - l -> len = OPLEN(instab[l -> insn].ops[0]) + 1; + l -> len = OPLEN(instab[l -> insn].ops[0]) + 1 + elen; } else if (l -> lint2 == 2) { - l -> len = OPLEN(instab[l -> insn].ops[2]) + 2; + l -> len = OPLEN(instab[l -> insn].ops[2]) + 2 + elen; } else if (l -> lint2 == 1 && l -> lint != -1) { - l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1; + l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1 + elen; } } } @@ -215,7 +215,7 @@ } // handle non-immediate - insn_parse_gen_aux(as, l, p); + insn_parse_gen_aux(as, l, p, 0); } RESOLVEFUNC(insn_resolve_gen0) @@ -252,7 +252,7 @@ } // handle non-immediate - insn_parse_gen_aux(as, l, p); + insn_parse_gen_aux(as, l, p, 0); if (l -> lint2 != -1) { if (l -> lint2 == 0) @@ -313,7 +313,7 @@ } // handle non-immediate - insn_parse_gen_aux(as, l, p); + insn_parse_gen_aux(as, l, p, 0); if (l -> lint2 != -1) { if (l -> lint2 == 0) @@ -374,7 +374,7 @@ } // handle non-immediate - insn_parse_gen_aux(as, l, p); + insn_parse_gen_aux(as, l, p, 0); if (l -> lint2 != -1) { if (l -> lint2 == 0)
--- a/lwasm/insn_logicmem.c Wed Aug 17 19:44:32 2011 -0600 +++ b/lwasm/insn_logicmem.c Wed Aug 17 21:04:33 2011 -0600 @@ -29,7 +29,7 @@ #include "lwasm.h" #include "instab.h" -extern void insn_parse_gen_aux(asmstate_t *as, line_t *l, char **optr); +extern void insn_parse_gen_aux(asmstate_t *as, line_t *l, char **optr, int elen); extern void insn_resolve_gen_aux(asmstate_t *as, line_t *l, int force, int elen); extern void insn_emit_gen_aux(asmstate_t *as, line_t *l, int extra); @@ -59,7 +59,7 @@ (*p)++; // now we have a general addressing mode - call for it - insn_parse_gen_aux(as, l, p); + insn_parse_gen_aux(as, l, p, 1); } RESOLVEFUNC(insn_resolve_logicmem) @@ -83,11 +83,12 @@ } v = lw_expr_intval(e); - if (v < -128 || v > 255) +/* if (v < -128 || v > 255) { + fprintf(stderr, "BYTE: %d\n", v); lwasm_register_error(as, l, "Byte overflow"); return; } - - insn_emit_gen_aux(as, l, v); +*/ + insn_emit_gen_aux(as, l, v & 0xff); }