comparison lwasm/insn_logicmem.c @ 151:427e268e876b

renamed src to lwasm to better reflect its purpose
author lost
date Fri, 30 Jan 2009 04:01:55 +0000
parents src/insn_logicmem.c@8929e1ee99cf
children bae1e3ecdce1
comparison
equal deleted inserted replaced
150:f0881c115010 151:427e268e876b
1 /*
2 insn_logicmem.c
3 Copyright © 2009 William Astle
4
5 This file is part of LWASM.
6
7 LWASM is free software: you can redistribute it and/or modify it under the
8 terms of the GNU General Public License as published by the Free Software
9 Foundation, either version 3 of the License, or (at your option) any later
10 version.
11
12 This program is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 more details.
16
17 You should have received a copy of the GNU General Public License along with
18 this program. If not, see <http://www.gnu.org/licenses/>.
19
20 Contains code for handling logic/mem instructions
21 */
22
23 #include <ctype.h>
24 #include <stdio.h>
25 #include <string.h>
26
27 #include "lwasm.h"
28 #include "instab.h"
29 #include "expr.h"
30
31 extern void insn_gen_aux(asmstate_t *as, lwasm_line_t *l, char **optr, int opnum, int extra);
32
33 // for aim, oim, eim, tim
34 // the immediate operand must be constant on pass 2
35 OPFUNC(insn_logicmem)
36 {
37 int rval, v1;
38 const char *p2;
39 lwasm_expr_stack_t *s;
40
41 if (**p == '#')
42 (*p)++;
43
44 rval = lwasm_expr_result2(as, l, p, 0, &v1, 1);
45 if (rval != 0)
46 v1 = 0;
47 if (rval == 1 && as -> passnum == 2)
48 register_error(as, l, 2, "Illegal external or intersegment reference");
49
50 if (v1 < -128 || v1 > 255)
51 register_error(as, l, 2, "Byte overflow");
52
53 if (**p != ',' && **p != ';')
54 {
55 register_error(as, l, 1, "Bad operand");
56 return;
57 }
58
59 (*p)++;
60
61 // now we have a general addressing mode - call for it
62 insn_gen_aux(as, l, p, opnum, v1 & 0xff);
63 }