comparison src/insn_logicmem.c @ 80:8929e1ee99cf

Checkpointing deployment of non-constant expression handling
author lost
date Sat, 10 Jan 2009 07:18:59 +0000
parents 538e15927776
children
comparison
equal deleted inserted replaced
79:d0ce3f5f6797 80:8929e1ee99cf
29 #include "expr.h" 29 #include "expr.h"
30 30
31 extern void insn_gen_aux(asmstate_t *as, lwasm_line_t *l, char **optr, int opnum, int extra); 31 extern void insn_gen_aux(asmstate_t *as, lwasm_line_t *l, char **optr, int opnum, int extra);
32 32
33 // for aim, oim, eim, tim 33 // for aim, oim, eim, tim
34 // the immediate operand must be constant on pass 2
34 OPFUNC(insn_logicmem) 35 OPFUNC(insn_logicmem)
35 { 36 {
36 int rval, v1; 37 int rval, v1;
37 const char *p2; 38 const char *p2;
38 lwasm_expr_stack_t *s; 39 lwasm_expr_stack_t *s;
39 40
40 if (**p == '#') 41 if (**p == '#')
41 (*p)++; 42 (*p)++;
42 43
43 s = lwasm_evaluate_expr(as, l, *p, &p2); 44 rval = lwasm_expr_result2(as, l, p, 0, &v1, 1);
44 *p = (char *)p2; 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");
45 49
46 if (!s)
47 {
48 register_error(as, l, 1, "Bad expression");
49 return;
50 }
51
52 if (v1 < -128 || v1 > 255) 50 if (v1 < -128 || v1 > 255)
53 {
54 register_error(as, l, 2, "Byte overflow"); 51 register_error(as, l, 2, "Byte overflow");
55 v1 &= 0xff;
56 }
57 52
58 if (**p != ',' && **p != ';') 53 if (**p != ',' && **p != ';')
59 { 54 {
60 register_error(as, l, 1, "Bad operand"); 55 register_error(as, l, 1, "Bad operand");
61 return; 56 return;