Mercurial > hg-old > index.cgi
view src/insn_misc.c @ 32:9bd0fbfe7405
Added basic indexed mode handling
author | lost |
---|---|
date | Fri, 02 Jan 2009 04:22:39 +0000 |
parents | 7c6b8bdf8c5c |
children |
line wrap: on
line source
/* insn_misc.c Copyright © 2008 William Astle This file is part of LWASM. LWASM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Contains code for parsing miscelaneous addressing modes */ #include <ctype.h> #include <stdio.h> #include <string.h> #include "lwasm.h" #include "instab.h" extern void insn_gen_aux(asmstate_t *as, sourceline_t *cl, char **optr, int *b1, int *b2, int *b3, int *op); // for aim, oim, eim, tim void insn_logicmem(asmstate_t *as, sourceline_t *cl, char **optr) { int rval, v1; int b1, b2, b3, op; if (**optr == '#') (*optr)++; rval = eval_expr(as, cl, optr, &v1); if (rval < 0) return; if (v1 < -128 || v1 > 255) { errorp2(ERR_OVERFLOW); v1 = 0; } if (**optr != ',' && **optr != ';') { errorp1(ERR_BADOPER); return; } (*optr)++; // now we have a general addressing mode - call for it insn_gen_aux(as, cl, optr, &b1, &b2, &b3, &op); emitop(op); emit(v1 & 0xff); if (b1 != -1) { emit(b1); } if (b2 != -1) { emit(b2); } if (b3 != -1) { emit(b3); } }