comparison old-trunk/lwasm/old/insn_logicmem.c @ 339:eb230fa7d28e

Prepare for migration to hg
author lost
date Fri, 19 Mar 2010 02:54:14 +0000
parents
children
comparison
equal deleted inserted replaced
338:e7885b3ee266 339:eb230fa7d28e
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 <config.h>
24 #include <ctype.h>
25 #include <stdio.h>
26 #include <string.h>
27
28 #include "lwasm.h"
29 #include "instab.h"
30 #include "expr.h"
31
32 extern void insn_gen_aux(asmstate_t *as, lwasm_line_t *l, char **optr, int opnum, int extra);
33
34 // for aim, oim, eim, tim
35 // the immediate operand must be constant on pass 2
36 OPFUNC(insn_logicmem)
37 {
38 int rval, v1;
39 const char *p2;
40 lwasm_expr_stack_t *s;
41
42 if (**p == '#')
43 (*p)++;
44
45 rval = lwasm_expr_result2(as, l, p, 0, &v1, 1);
46 if (rval != 0)
47 v1 = 0;
48 if (rval == 1 && as -> passnum == 2)
49 register_error(as, l, 2, "Illegal external or intersegment reference");
50
51 if (v1 < -128 || v1 > 255)
52 register_error(as, l, 2, "Byte overflow");
53
54 if (**p != ',' && **p != ';')
55 {
56 register_error(as, l, 1, "Bad operand");
57 return;
58 }
59
60 (*p)++;
61
62 // now we have a general addressing mode - call for it
63 insn_gen_aux(as, l, p, opnum, v1 & 0xff);
64 }