annotate lwasm/pseudo.c @ 218:b0c9df865b25

Add FDBS pseudo op. Add FDBS pseudo op which is just like FDB but it swaps the bytes of the operands. It is undocumented intentionally.
author William Astle <lost@l-w.ca>
date Sun, 10 Jun 2012 14:55:27 -0600
parents f87c86668d6b
children afd50d6b4113
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1 /*
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
2 pseudo.c
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
3 Copyright © 2010 William Astle
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
4
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
5 This file is part of LWASM.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
6
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
10 version.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
11
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
15 more details.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
16
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
19
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
20 */
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
21
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
22 #include <stdio.h>
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
23 #include <ctype.h>
10
127e5b1e01c0 Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents: 2
diff changeset
24 #include <string.h>
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
25 #include <stdlib.h>
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
26 #include <time.h>
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
27
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
28 #include <lw_alloc.h>
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
29
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
30 #include "lwasm.h"
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
31 #include "instab.h"
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
32 #include "input.h"
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
33
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
34 #include "lw_string.h"
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
35
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
36 extern void register_struct_entry(asmstate_t *as, line_t *l, int size, structtab_t *ss);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
37
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
38 // for "dts"
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
39 PARSEFUNC(pseudo_parse_dts)
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
40 {
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
41 time_t tp;
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
42 char *t;
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
43
135
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
44 skip_operand(p);
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
45 l -> len = 0;
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
46
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
47 tp = time(NULL);
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
48 t = ctime(&tp);
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
49
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
50 while (*t)
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
51 {
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
52 lwasm_emit(l, *t);
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
53 t++;
135
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
54 l -> len += 1;
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
55 }
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
56 }
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
57
135
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
58 EMITFUNC(pseudo_emit_dts)
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
59 {
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
60 }
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
61
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
62 // for "dtb"
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
63 PARSEFUNC(pseudo_parse_dtb)
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
64 {
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
65 skip_operand(p);
135
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
66 l -> len = 6;
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
67 }
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
68
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
69 EMITFUNC(pseudo_emit_dtb)
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
70 {
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
71 time_t tp;
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
72 struct tm *t;
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
73
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
74 tp = time(NULL);
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
75 t = localtime(&tp);
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
76
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
77 lwasm_emit(l, t -> tm_year);
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
78 lwasm_emit(l, t -> tm_mon + 1);
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
79 lwasm_emit(l, t -> tm_mday);
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
80 lwasm_emit(l, t -> tm_hour);
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
81 lwasm_emit(l, t -> tm_min);
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
82 lwasm_emit(l, t -> tm_sec);
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
83 }
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
84
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
85 // for "end"
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
86 PARSEFUNC(pseudo_parse_end)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
87 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
88 lw_expr_t addr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
89
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
90 as -> endseen = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
91 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
92
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
93 if (as -> output_format != OUTPUT_DECB)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
94 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
95 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
96 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
97 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
98
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
99 if (!**p)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
100 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
101 addr = lw_expr_build(lw_expr_type_int, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
102 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
103 else
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
104 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
105 addr = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
106 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
107 if (!addr)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
108 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
109 lwasm_register_error(as, l, "Bad expression");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
110 addr = lw_expr_build(lw_expr_type_int, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
111 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
112 lwasm_save_expr(l, 0, addr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
113 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
114
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
115 EMITFUNC(pseudo_emit_end)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
116 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
117 lw_expr_t addr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
118
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
119 addr = lwasm_fetch_expr(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
120
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
121 if (addr)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
122 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
123 if (!lw_expr_istype(addr, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
124 lwasm_register_error(as, l, "Exec address not constant!");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
125 else
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
126 as -> execaddr = lw_expr_intval(addr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
127 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
128 as -> endseen = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
129 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
130
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
131 PARSEFUNC(pseudo_parse_fcb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
132 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
133 int i = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
134 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
135
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
136 for (;;)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
137 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
138 e = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
139 if (!e)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
140 {
147
9cf1796259b2 Fixed segfault in fcb,fdb,fqb with empty operands
lost@l-w.ca
parents: 145
diff changeset
141 lwasm_register_error(as, l, "Bad expression (#%d)", i);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
142 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
143 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
144 lwasm_save_expr(l, i++, e);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
145 if (**p != ',')
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
146 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
147 (*p)++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
148 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
149
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
150 l -> len = i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
151 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
152
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
153 EMITFUNC(pseudo_emit_fcb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
154 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
155 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
156 lw_expr_t e;
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
157 // int v;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
158
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
159 for (i = 0; i < l -> len; i++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
160 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
161 e = lwasm_fetch_expr(l, i);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
162 lwasm_emitexpr(l, e, 1);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
163 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
164 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
165
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
166 PARSEFUNC(pseudo_parse_fdb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
167 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
168 int i = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
169 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
170
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
171 for (;;)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
172 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
173 e = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
174 if (!e)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
175 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
176 lwasm_register_error(as, l, "Bad expression (#%d)", i);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
177 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
178 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
179 lwasm_save_expr(l, i++, e);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
180 if (**p != ',')
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
181 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
182 (*p)++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
183 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
184
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
185 l -> len = i * 2;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
186 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
187
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
188 EMITFUNC(pseudo_emit_fdb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
189 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
190 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
191 lw_expr_t e;
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
192 // int v;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
193
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
194 for (i = 0; i < (l -> len)/2; i++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
195 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
196 e = lwasm_fetch_expr(l, i);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
197 lwasm_emitexpr(l, e, 2);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
198 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
199 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
200
218
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
201 PARSEFUNC(pseudo_parse_fdbs)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
202 {
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
203 int i = 0;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
204 lw_expr_t e;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
205
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
206 for (;;)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
207 {
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
208 e = lwasm_parse_expr(as, p);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
209 if (!e)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
210 {
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
211 lwasm_register_error(as, l, "Bad expression (#%d)", i);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
212 break;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
213 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
214 lwasm_save_expr(l, i++, e);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
215 if (**p != ',')
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
216 break;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
217 (*p)++;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
218 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
219
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
220 l -> len = i * 2;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
221 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
222
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
223 EMITFUNC(pseudo_emit_fdbs)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
224 {
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
225 int i;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
226 lw_expr_t e;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
227 lw_expr_t t;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
228 lw_expr_t t2;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
229 // int v;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
230
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
231 for (i = 0; i < (l -> len)/2; i++)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
232 {
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
233 e = lwasm_fetch_expr(l, i);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
234 t = lw_expr_build(lw_expr_type_int, 256);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
235 t2 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_divide, e, t);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
236 lwasm_reduce_expr(as, t2);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
237 lw_expr_destroy(t);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
238 lwasm_emitexpr(l, e, 1);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
239 lwasm_emitexpr(l, t2, 1);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
240 lw_expr_destroy(t2);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
241 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
242 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
243
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
244 PARSEFUNC(pseudo_parse_fqb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
245 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
246 int i = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
247 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
248
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
249 for (;;)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
250 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
251 e = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
252 if (!e)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
253 {
147
9cf1796259b2 Fixed segfault in fcb,fdb,fqb with empty operands
lost@l-w.ca
parents: 145
diff changeset
254 lwasm_register_error(as, l, "Bad expression (#%d)", i);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
255 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
256 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
257 lwasm_save_expr(l, i++, e);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
258 if (**p != ',')
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
259 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
260 (*p)++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
261 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
262
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
263 l -> len = i * 4;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
264 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
265
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
266 EMITFUNC(pseudo_emit_fqb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
267 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
268 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
269 lw_expr_t e;
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
270 // int v;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
271
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
272 for (i = 0; i < (l -> len)/4; i++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
273 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
274 e = lwasm_fetch_expr(l, i);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
275 lwasm_emitexpr(l, e, 4);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
276 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
277 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
278
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
279 static int cstringlen(asmstate_t *as, line_t *ln, char **p, char delim)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
280 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
281 int l = 0;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
282 char *str = NULL;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
283 int blen = 0;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
284 int bsize = 0;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
285
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
286 if (!(as -> pragmas & PRAGMA_CESCAPES))
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
287 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
288 for (; **p && **p != delim; (*p)++)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
289 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
290 l++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
291 if (blen >= bsize)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
292 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
293 str = lw_realloc(str, bsize + 32);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
294 bsize++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
295 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
296 str[blen++] = **p;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
297 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
298 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
299 else
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
300 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
301 while (**p && **p != delim)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
302 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
303 int wch = **p;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
304 if (**p == '\\')
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
305 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
306 /* escape sequence */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
307
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
308 (*p)++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
309 if (!**p)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
310 break;
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
311
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
312 switch (**p)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
313 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
314 /* octal sequence or NUL */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
315 /* skip the "0", then skip up to two more digits */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
316 case '0':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
317 case '1':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
318 case '2':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
319 case '3':
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
320 wch = **p;
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
321 wch -= 0x30;
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
322 if ((*p)[1] >= '0' && (*p)[1] < '8')
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
323 {
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
324 (*p)++;
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
325 wch *= 8;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
326 wch += **p - 0x30;
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
327 }
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
328 if ((*p)[1] >= '0' && (*p)[1] < '8')
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
329 {
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
330 (*p)++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
331 wch *= 8;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
332 wch += **p -0x30;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
333 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
334 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
335
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
336 /* hexadecimal value */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
337 case 'x':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
338 (*p)++; // ignore "x"
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
339 wch = 0;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
340 if (**p) // skip digit 1
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
341 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
342 wch = **p - 0x30;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
343 if (wch > 9)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
344 wch -= 7;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
345 if (wch > 9)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
346 wch -= 32;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
347 (*p)++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
348 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
349 if (**p)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
350 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
351 int i;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
352 i = **p - 0x30;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
353 if (i > 9)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
354 i -= 7;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
355 if (i > 9)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
356 i -= 32;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
357 wch = wch * 16 + i;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
358 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
359 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
360
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
361 case 'a':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
362 wch = 7;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
363 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
364
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
365 case 'b':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
366 wch = 8;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
367 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
368
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
369 case 't':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
370 wch = 9;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
371 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
372
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
373 case 'n':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
374 wch = 10;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
375 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
376
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
377 case 'v':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
378 wch = 11;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
379 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
380
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
381 case 'f':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
382 wch = 12;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
383 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
384
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
385 case 'r':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
386 wch = 13;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
387
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
388 /* everything else represents itself */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
389 default:
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
390 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
391 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
392 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
393 /* now "wch" is the character to write out */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
394 l++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
395 (*p)++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
396 if (blen >= bsize)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
397 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
398 str = lw_realloc(str, bsize + 32);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
399 bsize += 32;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
400 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
401 str[blen++] = wch;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
402 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
403 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
404 /* do something with the string here */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
405 /* l is the string length, str is the string itself */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
406 ln -> lstr = str;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
407 return l;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
408 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
409
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
410 PARSEFUNC(pseudo_parse_fcc)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
411 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
412 char delim;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
413 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
414
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
415 if (!**p)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
416 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
417 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
418 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
419 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
420
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
421 delim = **p;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
422 (*p)++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
423
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
424
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
425 i = cstringlen(as, l, p, delim);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
426
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
427 if (**p != delim)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
428 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
429 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
430 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
431 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
432 (*p)++;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
433 l -> len = i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
434 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
435
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
436 EMITFUNC(pseudo_emit_fcc)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
437 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
438 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
439
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
440 for (i = 0; i < l -> len; i++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
441 lwasm_emit(l, l -> lstr[i]);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
442 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
443
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
444 PARSEFUNC(pseudo_parse_fcs)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
445 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
446 char delim;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
447 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
448
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
449 if (!**p)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
450 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
451 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
452 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
453 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
454
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
455 delim = **p;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
456 (*p)++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
457
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
458 i = cstringlen(as, l, p, delim);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
459
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
460 if (**p != delim)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
461 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
462 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
463 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
464 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
465 (*p)++;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
466 l -> len = i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
467 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
468
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
469 EMITFUNC(pseudo_emit_fcs)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
470 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
471 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
472
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
473 for (i = 0; i < l -> len - 1; i++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
474 lwasm_emit(l, l -> lstr[i]);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
475 lwasm_emit(l, l -> lstr[i] | 0x80);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
476 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
477
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
478 PARSEFUNC(pseudo_parse_fcn)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
479 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
480 char delim;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
481 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
482
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
483 if (!**p)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
484 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
485 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
486 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
487 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
488
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
489 delim = **p;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
490 (*p)++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
491
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
492 i = cstringlen(as, l, p, delim);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
493
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
494 if (**p != delim)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
495 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
496 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
497 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
498 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
499 (*p)++;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
500 l -> len = i + 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
501 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
502
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
503 EMITFUNC(pseudo_emit_fcn)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
504 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
505 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
506
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
507 for (i = 0; i < (l -> len - 1); i++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
508 lwasm_emit(l, l -> lstr[i]);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
509 lwasm_emit(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
510 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
511
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
512 PARSEFUNC(pseudo_parse_rmb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
513 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
514 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
515
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
516 expr = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
517 if (!expr)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
518 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
519 lwasm_register_error(as, l, "Bad expression");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
520 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
521
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
522 l -> lint = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
523 if (as -> instruct)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
524 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
525 lwasm_reduce_expr(as, expr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
526 if (!lw_expr_istype(expr, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
527 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
528 lwasm_register_error(as, l, "Expression must be constant at parse time");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
529 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
530 else
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
531 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
532 int e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
533 e = lw_expr_intval(expr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
534 register_struct_entry(as, l, e, NULL);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
535 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
536 l -> lint = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
537 l -> symset = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
538 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
539 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
540 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
541 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
542 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
543 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
544 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
545 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
546 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
547 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
548 lwasm_save_expr(l, 0, expr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
549 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
550
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
551 RESOLVEFUNC(pseudo_resolve_rmb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
552 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
553 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
554
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
555 if (l -> lint)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
556 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
557
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
558 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
559 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
560 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
561 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
562 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
563 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
564 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
565 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
566 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
567 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
568
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
569 expr = lwasm_fetch_expr(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
570
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
571 if (lw_expr_istype(expr, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
572 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
573 if (lw_expr_intval(expr) < 0)
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
574 {
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
575 lwasm_register_error(as, l, "Negative reservation sizes make no sense!");
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
576 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
577 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
578 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
579 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
580 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
581 l -> dlen = lw_expr_intval(expr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
582 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
583 l -> len = lw_expr_intval(expr);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
584 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
585 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
586
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
587 EMITFUNC(pseudo_emit_rmb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
588 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
589 if (l -> lint)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
590 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
591
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
592 if (l -> len < 0 || l -> dlen < 0)
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
593 lwasm_register_error(as, l, "Expression not constant: %d %d", l -> len, l -> dlen);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
594 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
595
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
596 PARSEFUNC(pseudo_parse_rmd)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
597 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
598 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
599
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
600 l -> lint = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
601 expr = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
602 if (!expr)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
603 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
604 lwasm_register_error(as, l, "Bad expression");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
605 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
606
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
607 if (as -> instruct)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
608 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
609 lwasm_reduce_expr(as, expr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
610 if (!lw_expr_istype(expr, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
611 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
612 lwasm_register_error(as, l, "Expression must be constant at parse time");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
613 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
614 else
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
615 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
616 int e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
617 e = lw_expr_intval(expr) * 2;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
618 register_struct_entry(as, l, e, NULL);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
619 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
620 l -> symset = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
621 l -> lint = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
622 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
623 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
624 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
625 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
626 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
627 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
628 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
629 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
630 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
631 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
632 lwasm_save_expr(l, 0, expr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
633 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
634
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
635 RESOLVEFUNC(pseudo_resolve_rmd)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
636 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
637 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
638
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
639 if (l -> lint)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
640 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
641
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
642 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
643 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
644 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
645 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
646 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
647 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
648 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
649 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
650 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
651 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
652
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
653 expr = lwasm_fetch_expr(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
654
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
655 if (lw_expr_istype(expr, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
656 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
657 if (lw_expr_intval(expr) < 0)
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
658 {
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
659 lwasm_register_error(as, l, "Negative reservation sizes make no sense!");
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
660 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
661 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
662 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
663 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
664 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
665 l -> dlen = lw_expr_intval(expr) * 2;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
666 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
667 l -> len = lw_expr_intval(expr) * 2;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
668 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
669 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
670
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
671 EMITFUNC(pseudo_emit_rmd)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
672 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
673 if (l -> lint)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
674 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
675
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
676 if (l -> len < 0 || l -> dlen < 0)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
677 lwasm_register_error(as, l, "Expression not constant");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
678 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
679
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
680
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
681 PARSEFUNC(pseudo_parse_rmq)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
682 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
683 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
684
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
685 l -> lint = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
686 expr = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
687 if (!expr)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
688 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
689 lwasm_register_error(as, l, "Bad expression");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
690 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
691 if (as -> instruct)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
692 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
693 lwasm_reduce_expr(as, expr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
694 if (!lw_expr_istype(expr, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
695 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
696 lwasm_register_error(as, l, "Expression must be constant at parse time");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
697 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
698 else
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
699 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
700 int e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
701 e = lw_expr_intval(expr) * 4;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
702 register_struct_entry(as, l, e, NULL);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
703 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
704 l -> symset = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
705 l -> lint = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
706 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
707 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
708 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
709 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
710 if (as -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
711 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
712 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
713 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
714 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
715 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
716 lwasm_save_expr(l, 0, expr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
717 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
718
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
719 RESOLVEFUNC(pseudo_resolve_rmq)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
720 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
721 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
722
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
723 if (l -> lint)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
724 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
725
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
726 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
727 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
728 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
729 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
730 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
731 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
732 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
733 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
734 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
735 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
736
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
737 expr = lwasm_fetch_expr(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
738
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
739 if (lw_expr_istype(expr, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
740 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
741 if (lw_expr_intval(expr) < 0)
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
742 {
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
743 lwasm_register_error(as, l, "Negative reservation sizes make no sense!");
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
744 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
745 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
746 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
747 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
748 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
749 l -> dlen = lw_expr_intval(expr) * 4;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
750 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
751 l -> len = lw_expr_intval(expr) * 4;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
752 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
753 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
754
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
755 EMITFUNC(pseudo_emit_rmq)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
756 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
757 if (l -> lint)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
758 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
759
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
760 if (l -> len < 0 || l -> dlen < 0)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
761 lwasm_register_error(as, l, "Expression not constant");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
762 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
763
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
764
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
765 PARSEFUNC(pseudo_parse_zmq)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
766 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
767 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
768
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
769 expr = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
770 if (!expr)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
771 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
772 lwasm_register_error(as, l, "Bad expression");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
773 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
774
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
775 lwasm_save_expr(l, 0, expr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
776 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
777
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
778 RESOLVEFUNC(pseudo_resolve_zmq)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
779 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
780 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
781
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
782 if (l -> len >= 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
783 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
784
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
785 expr = lwasm_fetch_expr(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
786
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
787 if (lw_expr_istype(expr, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
788 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
789 if (lw_expr_intval(expr) < 0)
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
790 {
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
791 lwasm_register_error(as, l, "Negative block sizes make no sense!");
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
792 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
793 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
794 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
795 l -> len = lw_expr_intval(expr) * 4;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
796 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
797 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
798
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
799 EMITFUNC(pseudo_emit_zmq)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
800 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
801 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
802
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
803 if (l -> len < 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
804 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
805 lwasm_register_error(as, l, "Expression not constant");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
806 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
807 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
808
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
809 for (i = 0; i < l -> len; i++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
810 lwasm_emit(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
811 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
812
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
813
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
814 PARSEFUNC(pseudo_parse_zmd)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
815 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
816 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
817
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
818 expr = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
819 if (!expr)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
820 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
821 lwasm_register_error(as, l, "Bad expression");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
822 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
823
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
824 lwasm_save_expr(l, 0, expr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
825 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
826
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
827 RESOLVEFUNC(pseudo_resolve_zmd)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
828 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
829 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
830
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
831 if (l -> len >= 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
832 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
833
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
834 expr = lwasm_fetch_expr(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
835
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
836 if (lw_expr_istype(expr, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
837 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
838 if (lw_expr_intval(expr) < 0)
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
839 {
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
840 lwasm_register_error(as, l, "Negative block sizes make no sense!");
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
841 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
842 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
843 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
844 l -> len = lw_expr_intval(expr) * 2;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
845 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
846 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
847
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
848 EMITFUNC(pseudo_emit_zmd)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
849 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
850 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
851
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
852 if (l -> len < 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
853 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
854 lwasm_register_error(as, l, "Expression not constant");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
855 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
856 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
857
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
858 for (i = 0; i < l -> len; i++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
859 lwasm_emit(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
860 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
861
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
862 PARSEFUNC(pseudo_parse_zmb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
863 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
864 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
865
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
866 expr = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
867 if (!expr)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
868 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
869 lwasm_register_error(as, l, "Bad expression");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
870 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
871
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
872 lwasm_save_expr(l, 0, expr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
873 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
874
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
875 RESOLVEFUNC(pseudo_resolve_zmb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
876 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
877 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
878
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
879 if (l -> len >= 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
880 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
881
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
882 expr = lwasm_fetch_expr(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
883
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
884 if (lw_expr_istype(expr, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
885 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
886 if (lw_expr_intval(expr) < 0)
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
887 {
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
888 lwasm_register_error(as, l, "Negative block sizes make no sense!");
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
889 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
890 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
891 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
892 l -> len = lw_expr_intval(expr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
893 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
894 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
895
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
896 EMITFUNC(pseudo_emit_zmb)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
897 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
898 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
899
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
900 if (l -> len < 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
901 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
902 lwasm_register_error(as, l, "Expression not constant");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
903 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
904 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
905
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
906 for (i = 0; i < l -> len; i++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
907 lwasm_emit(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
908 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
909
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
910 PARSEFUNC(pseudo_parse_org)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
911 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
912 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
913
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
914 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
915
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
916 e = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
917 if (!e)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
918 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
919 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
920 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
921 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
922
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
923 lw_expr_destroy(l -> daddr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
924 l -> daddr = e;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
925
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
926 if (l -> inmod == 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
927 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
928 lw_expr_destroy(l -> addr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
929 l -> addr = e;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
930 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
931 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
932 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
933
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
934 PARSEFUNC(pseudo_parse_equ)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
935 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
936 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
937
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
938 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
939
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
940 if (!(l -> sym))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
941 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
942 lwasm_register_error(as, l, "Missing symbol");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
943 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
944 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
945
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
946 e = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
947 if (!e)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
948 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
949 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
950 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
951 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
952
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
953 register_symbol(as, l, l -> sym, e, symbol_flag_none);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
954 l -> symset = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
955 l -> dptr = lookup_symbol(as, l, l -> sym);
88
1a1fdfe860d0 Fixed several memory leaks revealed by valgrind
lost@l-w.ca
parents: 84
diff changeset
956 lw_expr_destroy(e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
957 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
958
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
959 PARSEFUNC(pseudo_parse_set)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
960 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
961 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
962
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
963 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
964
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
965 if (!(l -> sym))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
966 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
967 lwasm_register_error(as, l, "Missing symbol");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
968 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
969 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
970
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
971 e = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
972 if (!e)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
973 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
974 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
975 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
976 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
977
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
978 register_symbol(as, l, l -> sym, e, symbol_flag_set);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
979 l -> symset = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
980 l -> dptr = lookup_symbol(as, l, l -> sym);
88
1a1fdfe860d0 Fixed several memory leaks revealed by valgrind
lost@l-w.ca
parents: 84
diff changeset
981 lw_expr_destroy(e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
982 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
983
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
984 PARSEFUNC(pseudo_parse_setdp)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
985 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
986 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
987
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
988 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
989
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
990 if (as -> output_format == OUTPUT_OBJ)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
991 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
992 lwasm_register_error(as, l, "SETDP not permitted for object target");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
993 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
994 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
995
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
996 e = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
997 if (!e)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
998 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
999 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1000 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1001 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1002
38
7e92484cfbc3 Caused expressions used in setdp and conditionals to be reduced on pass 1
lost@l-w.ca
parents: 10
diff changeset
1003 // try simplifying the expression and see if it turns into an int
7e92484cfbc3 Caused expressions used in setdp and conditionals to be reduced on pass 1
lost@l-w.ca
parents: 10
diff changeset
1004 lwasm_reduce_expr(as, e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1005 if (!lw_expr_istype(e, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1006 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1007 lwasm_register_error(as, l, "SETDP must be constant on pass 1");
88
1a1fdfe860d0 Fixed several memory leaks revealed by valgrind
lost@l-w.ca
parents: 84
diff changeset
1008 lw_expr_destroy(e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1009 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1010 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1011 l -> dpval = lw_expr_intval(e) & 0xff;
88
1a1fdfe860d0 Fixed several memory leaks revealed by valgrind
lost@l-w.ca
parents: 84
diff changeset
1012 lw_expr_destroy(e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1013 l -> dshow = l -> dpval;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1014 l -> dsize = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1015 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1016
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1017 PARSEFUNC(pseudo_parse_ifp1)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1018 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1019 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1020
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1021 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1022 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1023 as -> skipcount++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1024 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1025 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1026 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1027
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1028 lwasm_register_warning(as, l, "IFP1 if is not supported; ignoring");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1029
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1030 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1031
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1032 PARSEFUNC(pseudo_parse_ifp2)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1033 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1034 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1035
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1036 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1037 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1038 as -> skipcount++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1039 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1040 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1041 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1042
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1043 lwasm_register_warning(as, l, "IFP2 if is not supported; ignoring");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1044 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1045
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1046 PARSEFUNC(pseudo_parse_ifeq)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1047 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1048 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1049
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1050 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1051
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1052 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1053 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1054 as -> skipcount++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1055 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1056 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1057 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1058
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1059 e = lwasm_parse_cond(as, p);
208
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1060 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1061 lwasm_reduce_expr(as, e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1062 if (e && lw_expr_intval(e) != 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1063 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1064 as -> skipcond = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1065 as -> skipcount = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1066 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1067 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1068
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1069 PARSEFUNC(pseudo_parse_ifne)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1070 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1071 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1072
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1073 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1074
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1075 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1076 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1077 as -> skipcount++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1078 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1079 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1080 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1081
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1082 e = lwasm_parse_cond(as, p);
208
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1083 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1084 lwasm_reduce_expr(as, e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1085 if (e && lw_expr_intval(e) == 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1086 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1087 as -> skipcond = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1088 as -> skipcount = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1089 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1090 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1091
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1092
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1093 PARSEFUNC(pseudo_parse_ifgt)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1094 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1095 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1096
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1097 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1098
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1099 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1100 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1101 as -> skipcount++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1102 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1103 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1104 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1105
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1106 e = lwasm_parse_cond(as, p);
208
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1107 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1108 lwasm_reduce_expr(as, e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1109 if (e && lw_expr_intval(e) <= 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1110 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1111 as -> skipcond = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1112 as -> skipcount = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1113 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1114 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1115
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1116 PARSEFUNC(pseudo_parse_ifge)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1117 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1118 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1119
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1120 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1121
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1122 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1123 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1124 as -> skipcount++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1125 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1126 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1127 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1128
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1129 e = lwasm_parse_cond(as, p);
208
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1130 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1131 lwasm_reduce_expr(as, e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1132 if (e && lw_expr_intval(e) < 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1133 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1134 as -> skipcond = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1135 as -> skipcount = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1136 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1137 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1138
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1139 PARSEFUNC(pseudo_parse_iflt)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1140 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1141 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1142
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1143 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1144
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1145 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1146 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1147 as -> skipcount++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1148 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1149 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1150 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1151
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1152 e = lwasm_parse_cond(as, p);
208
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1153 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1154 lwasm_reduce_expr(as, e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1155 if (e && lw_expr_intval(e) >= 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1156 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1157 as -> skipcond = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1158 as -> skipcount = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1159 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1160 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1161
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1162 PARSEFUNC(pseudo_parse_ifle)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1163 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1164 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1165
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1166 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1167
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1168 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1169 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1170 as -> skipcount++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1171 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1172 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1173 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1174
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1175 e = lwasm_parse_cond(as, p);
208
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1176 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1177 lwasm_reduce_expr(as, e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1178 if (e && lw_expr_intval(e) > 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1179 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1180 as -> skipcond = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1181 as -> skipcount = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1182 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1183 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1184
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1185 PARSEFUNC(pseudo_parse_endc)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1186 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1187 l -> len = 0;
145
d6e9cc4484f6 Fixed ENDC to work with comments after it
lost@l-w.ca
parents: 142
diff changeset
1188 skip_operand(p);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1189 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1190 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1191 as -> skipcount--;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1192 if (as -> skipcount <= 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1193 as -> skipcond = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1194 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1195 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1196
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1197 PARSEFUNC(pseudo_parse_else)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1198 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1199 l -> len = 0;
217
f87c86668d6b Fix handling of comments on ELSE lines
William Astle <lost@l-w.ca>
parents: 208
diff changeset
1200 skip_operand(p);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1201
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1202 if (as -> skipmacro)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1203 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1204
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1205 if (as -> skipcond)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1206 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1207 if (as -> skipcount == 1)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1208 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1209 as -> skipcount = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1210 as -> skipcond = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1211 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1212 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1213 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1214 as -> skipcond = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1215 as -> skipcount = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1216 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1217
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1218 PARSEFUNC(pseudo_parse_ifdef)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1219 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1220 char *sym;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1221 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1222 struct symtabe *s;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1223
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1224 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1225
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1226 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1227 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1228 as -> skipcount++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1229 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1230 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1231 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1232
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1233 again:
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1234 for (i = 0; (*p)[i] && !isspace((*p)[i]) && (*p)[i] != '|' && (*p)[i] != '&'; i++)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1235 /* do nothing */ ;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1236
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1237 sym = lw_strndup(*p, i);
84
16a72d9b6eb6 Make ifdef work correctly
lost@l-w.ca
parents: 76
diff changeset
1238 (*p) += i;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1239
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1240 s = lookup_symbol(as, l, sym);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1241
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1242 lw_free(sym);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1243
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1244 if (!s)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1245 {
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1246 if (**p == '|')
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1247 {
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1248 (*p)++;
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1249 goto again;
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1250 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1251 as -> skipcond = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1252 as -> skipcount = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1253 }
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1254 skip_operand(p);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1255 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1256
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1257 PARSEFUNC(pseudo_parse_ifndef)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1258 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1259 char *sym;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1260 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1261 struct symtabe *s;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1262
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1263 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1264
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1265 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1266 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1267 as -> skipcount++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1268 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1269 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1270 }
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1271 for (i = 0; (*p)[i] && !isspace((*p)[i]) && (*p)[i] != '&' && (*p)[i] != '|'; i++)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1272 /* do nothing */ ;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1273
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1274 sym = lw_strndup(*p, i);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1275 (*p) += i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1276
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1277 s = lookup_symbol(as, l, sym);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1278
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1279 lw_free(sym);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1280
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1281 if (s)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1282 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1283 as -> skipcond = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1284 as -> skipcount = 1;
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1285 return;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1286 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1287 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1288
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1289 PARSEFUNC(pseudo_parse_error)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1290 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1291 lwasm_register_error(as, l, "User error: %s", *p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1292 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1293 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1294
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1295 PARSEFUNC(pseudo_parse_warning)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1296 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1297 lwasm_register_warning(as, l, "User warning: %s", *p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1298 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1299 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1300
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1301 PARSEFUNC(pseudo_parse_includebin)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1302 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1303 char *fn, *p2;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1304 int delim = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1305 FILE *fp;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1306 long flen;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1307
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1308 if (!**p)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1309 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1310 lwasm_register_error(as, l, "Missing filename");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1311 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1312 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1313
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1314 if (**p == '"' || **p == '\'')
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1315 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1316 delim = **p;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1317 (*p)++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1318
63
74b82202d355 Make for condition clearer
lost@l-w.ca
parents: 62
diff changeset
1319 for (p2 = *p; *p2 && (*p2 != delim); p2++)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1320 /* do nothing */ ;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1321 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1322 else
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1323 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1324 for (p2 = *p; *p2 && !isspace(*p2); p2++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1325 /* do nothing */ ;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1326 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1327 fn = lw_strndup(*p, p2 - *p);
62
5b10ff307463 Fixed problem with filename handling in includebin
lost@l-w.ca
parents: 58
diff changeset
1328 *p = p2;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1329 if (delim && **p)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1330 (*p)++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1331
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1332 fp = input_open_standalone(as, fn);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1333 if (!fp)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1334 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1335 lwasm_register_error(as, l, "Cannot open file");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1336 lw_free(fn);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1337 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1338 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1339
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1340 l -> lstr = fn;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1341
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1342 fseek(fp, 0, SEEK_END);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1343 flen = ftell(fp);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1344 fclose(fp);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1345
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1346 l -> len = flen;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1347 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1348
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1349 EMITFUNC(pseudo_emit_includebin)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1350 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1351 FILE *fp;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1352 int c;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1353
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1354 fp = input_open_standalone(as, l -> lstr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1355 if (!fp)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1356 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1357 lwasm_register_error(as, l, "Cannot open file (emit)!");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1358 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1359 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1360
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1361 for (;;)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1362 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1363 c = fgetc(fp);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1364 if (c == EOF)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1365 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1366 fclose(fp);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1367 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1368 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1369 lwasm_emit(l, c);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1370 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1371 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1372
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1373 PARSEFUNC(pseudo_parse_include)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1374 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1375 char *fn, *p2;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1376 char *p3;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1377 int delim = 0;
10
127e5b1e01c0 Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents: 2
diff changeset
1378 int len;
41
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1379 char buf[110];
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1380
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1381 if (!**p)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1382 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1383 lwasm_register_error(as, l, "Missing filename");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1384 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1385 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1386
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1387 if (**p == '"' || **p == '\'')
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1388 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1389 delim = **p;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1390 (*p)++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1391
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1392 for (p2 = *p; *p2 && *p2 != delim; p2++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1393 /* do nothing */ ;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1394 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1395 else
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1396 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1397 for (p2 = *p; *p2 && !isspace(*p2); p2++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1398 /* do nothing */ ;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1399 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1400 fn = lw_strndup(*p, p2 - *p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1401 (*p) = p2;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1402 if (delim && **p)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1403 (*p)++;
41
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1404
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1405 /* add a book-keeping entry for line numbers */
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1406 snprintf(buf, 100, "\001\001SETLINENO %d\n", l -> lineno + 1);
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1407 input_openstring(as, "INTERNAL", buf);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1408
10
127e5b1e01c0 Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents: 2
diff changeset
1409 len = strlen(fn) + 8;
127e5b1e01c0 Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents: 2
diff changeset
1410 p3 = lw_alloc(len + 1);
127e5b1e01c0 Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents: 2
diff changeset
1411 sprintf(p3, "include:%s", fn);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1412 input_open(as, p3);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1413 lw_free(p3);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1414
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1415 l -> len = 0;
93
5bf9edabd661 Squashed the remaining memory leaks revealed by valgrind
lost@l-w.ca
parents: 88
diff changeset
1416 lw_free(fn);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1417 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1418
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1419 PARSEFUNC(pseudo_parse_align)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1420 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1421 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1422 if (!**p)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1423 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1424 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1425 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1426 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1427
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1428 e = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1429
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1430 if (!e)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1431 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1432 lwasm_register_error(as, l, "Bad operand");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1433 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1434 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1435
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1436 lwasm_save_expr(l, 0, e);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1437
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1438 if (**p == ',')
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1439 {
114
707eda49ad60 Fix parsing padding argument for align pseudo op
lost@l-w.ca
parents: 93
diff changeset
1440 (*p)++;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1441 e = lwasm_parse_expr(as, p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1442 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1443 else
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1444 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1445 e = lw_expr_build(lw_expr_type_int, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1446 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1447 if (!e)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1448 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1449 lwasm_register_error(as, l, "Bad padding");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1450 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1451 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1452
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1453 lwasm_save_expr(l, 1, e);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1454 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1455
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1456 RESOLVEFUNC(pseudo_resolve_align)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1457 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1458 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1459 int align;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1460
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1461 e = lwasm_fetch_expr(l, 0);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1462
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1463 if (lw_expr_istype(e, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1464 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1465 align = lw_expr_intval(e);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1466 if (align < 1)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1467 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1468 lwasm_register_error(as, l, "Invalid alignment");
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1469 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1470 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1471 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1472
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1473 if (lw_expr_istype(l -> addr, lw_expr_type_int))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1474 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1475 int a;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1476 a = lw_expr_intval(l -> addr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1477 if (a % align == 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1478 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1479 l -> len = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1480 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1481 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1482 l -> len = align - (a % align);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1483 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1484 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1485 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1486
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1487 EMITFUNC(pseudo_emit_align)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1488 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1489 lw_expr_t e;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1490 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1491
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1492 e = lwasm_fetch_expr(l, 1);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1493 for (i = 0; i < l -> len; i++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1494 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1495 lwasm_emitexpr(l, e, 1);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1496 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1497 }
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1498
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1499 PARSEFUNC(pseudo_parse_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1500 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1501 lw_expr_t e, e1;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1502 if (!**p)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1503 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1504 lwasm_register_error(as, l, "Bad operand");
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1505 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1506 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1507
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1508 e1 = lwasm_parse_expr(as, p);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1509 if (**p != ',')
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1510 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1511 lwasm_register_error(as, l, "Bad operand");
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1512 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1513 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1514 (*p)++;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1515 e = lwasm_parse_expr(as, p);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1516
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1517 if (!e)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1518 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1519 lwasm_register_error(as, l, "Bad operand");
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1520 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1521 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1522
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1523 lwasm_save_expr(l, 0, e);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1524 lwasm_save_expr(l, 1, e1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1525
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1526 if (!e1)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1527 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1528 lwasm_register_error(as, l, "Bad padding");
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1529 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1530 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1531 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1532
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1533 RESOLVEFUNC(pseudo_resolve_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1534 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1535 lw_expr_t e;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1536 int align;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1537
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1538 e = lwasm_fetch_expr(l, 0);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1539
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1540 if (lw_expr_istype(e, lw_expr_type_int))
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1541 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1542 align = lw_expr_intval(e);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1543 if (align < 1)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1544 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1545 lwasm_register_error(as, l, "Invalid fill length");
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1546 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1547 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1548 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1549
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1550 if (lw_expr_istype(l -> addr, lw_expr_type_int))
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1551 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1552 l -> len = align;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1553 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1554 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1555 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1556
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1557 EMITFUNC(pseudo_emit_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1558 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1559 lw_expr_t e;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1560 int i;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1561
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1562 e = lwasm_fetch_expr(l, 1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1563 for (i = 0; i < l -> len; i++)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1564 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1565 lwasm_emitexpr(l, e, 1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1566 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1567 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1568
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1569 /* string conditional argument parser */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1570 /*
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1571 argument syntax:
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1572
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1573 a bare word ended by whitespace, comma, or NUL
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1574 a double quote delimited string containing arbitrary printable characters
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1575 a single quote delimited string containing arbitrary printable characters
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1576
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1577 In a double quoted string, a double quote cannot be represented.
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1578 In a single quoted string, a single quote cannot be represented.
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1579
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1580 */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1581 char *strcond_parsearg(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1582 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1583 char *arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1584 char *tstr;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1585 int i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1586 tstr = *p;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1587
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1588 if (!**p || isspace(**p))
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1589 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1590 return lw_strdup("");
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1591 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1592
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1593 if (*tstr == '"')
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1594 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1595 // double quote delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1596 tstr++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1597 for (i = 0; tstr[i] && tstr[i] != '"'; i++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1598 /* do nothing */ ;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1599
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1600 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1601 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1602 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1603
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1604 if (tstr[i])
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1605 i++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1606
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1607 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1608 return arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1609 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1610 else if (*tstr == '\'')
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1611 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1612 // single quote delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1613 tstr++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1614 for (i = 0; tstr[i] && tstr[i] != '\''; i++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1615 /* do nothing */ ;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1616
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1617 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1618 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1619 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1620
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1621 if (tstr[i])
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1622 i++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1623
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1624 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1625 return arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1626 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1627 else
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1628 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1629 // bare word - whitespace or comma delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1630 for (i = 0; tstr[i] && !isspace(tstr[i]) && tstr[i] != ','; i++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1631 /* do nothing */ ;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1632
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1633 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1634 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1635 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1636 if (tstr[i] == ',')
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1637 i++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1638
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1639 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1640 return arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1641 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1642 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1643
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1644 /* string conditional helpers */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1645 /* return "1" for true, "0" for false */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1646 int strcond_eq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1647 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1648 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1649 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1650 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1651
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1652 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1653 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1654
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1655 if (strcmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1656 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1657 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1658 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1659 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1660 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1661
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1662 int strcond_ieq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1663 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1664 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1665 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1666 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1667
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1668 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1669 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1670
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1671 if (strcasecmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1672 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1673 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1674 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1675 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1676 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1677
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1678 int strcond_ne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1679 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1680 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1681 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1682 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1683
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1684 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1685 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1686
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1687 if (strcmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1688 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1689 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1690 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1691 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1692 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1693
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1694 int strcond_ine(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1695 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1696 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1697 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1698 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1699
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1700 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1701 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1702
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1703 if (strcasecmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1704 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1705 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1706 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1707 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1708 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1709
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1710 int strcond_peq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1711 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1712 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1713 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1714 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1715 int plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1716 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1717
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1718 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1719 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1720 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1721
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1722 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1723 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1724 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1725 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1726 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1727
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1728 if (strcmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1729 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1730 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1731 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1732 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1733 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1734 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1735
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1736 int strcond_ipeq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1737 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1738 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1739 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1740 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1741 int plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1742 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1743
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1744 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1745 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1746 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1747
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1748 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1749 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1750 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1751 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1752 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1753
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1754 if (strcasecmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1755 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1756 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1757 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1758 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1759 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1760 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1761
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1762 int strcond_pne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1763 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1764 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1765 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1766 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1767 int plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1768 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1769
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1770 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1771 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1772 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1773
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1774 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1775 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1776 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1777 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1778 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1779
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1780 if (strcmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1781 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1782 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1783 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1784 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1785 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1786 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1787
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1788 int strcond_ipne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1789 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1790 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1791 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1792 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1793 int plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1794 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1795
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1796 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1797 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1798 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1799
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1800 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1801 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1802 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1803 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1804 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1805
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1806 if (strcasecmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1807 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1808 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1809 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1810 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1811 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1812 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1813
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1814 int strcond_seq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1815 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1816 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1817 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1818 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1819 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1820 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1821
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1822 int plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1823 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1824
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1825 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1826 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1827 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1828
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1829 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1830 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1831
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1832 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1833 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1834 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1835 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1836 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1837 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1838 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1839 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1840 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1841 if (strcmp(rarg1, rarg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1842 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1843 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1844 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1845 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1846 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1847 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1848
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1849 int strcond_iseq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1850 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1851 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1852 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1853 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1854 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1855 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1856
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1857 int plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1858 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1859
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1860 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1861 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1862 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1863
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1864 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1865 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1866
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1867 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1868 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1869 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1870 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1871 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1872 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1873 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1874 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1875 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1876
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1877 if (strcasecmp(rarg1, rarg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1878 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1879 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1880 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1881 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1882 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1883 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1884
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1885
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1886 int strcond_sne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1887 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1888 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1889 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1890 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1891 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1892 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1893
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1894 int plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1895 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1896
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1897 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1898 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1899 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1900
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1901 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1902 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1903
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1904 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1905 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1906 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1907 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1908 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1909 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1910 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1911 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1912 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1913
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1914 if (strcmp(rarg1, rarg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1915 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1916 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1917 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1918 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1919 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1920 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1921
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1922 int strcond_isne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1923 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1924 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1925 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1926 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1927 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1928 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1929
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1930 int plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1931 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1932
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1933 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1934 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1935 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1936
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1937 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1938 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1939
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1940 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1941 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1942 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1943 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1944 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1945 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1946 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1947 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1948 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1949
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1950 if (strcasecmp(rarg1, rarg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1951 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1952 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1953 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1954 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1955 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1956 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1957
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1958 /* string conditionals */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1959 PARSEFUNC(pseudo_parse_ifstr)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1960 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1961 static struct strconds
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1962 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1963 char *str;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1964 int (*fn)(char **ptr);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1965 } strops[] = {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1966 { "eq", strcond_eq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1967 { "ieq", strcond_ieq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1968 { "ne", strcond_ne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1969 { "ine", strcond_ine },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1970 { "peq", strcond_peq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1971 { "ipeq", strcond_ipeq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1972 { "pne", strcond_pne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1973 { "ipne", strcond_ipne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1974 { "seq", strcond_seq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1975 { "iseq", strcond_iseq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1976 { "sne", strcond_sne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1977 { "isne", strcond_isne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1978 { NULL, 0 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1979 };
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1980 int tv = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1981 char *tstr;
58
62372522ce9c Clean up warning about unused variable
lost@l-w.ca
parents: 55
diff changeset
1982 int strop;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1983
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1984 l -> len = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1985
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1986 if (as -> skipcond && !(as -> skipmacro))
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1987 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1988 as -> skipcount++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1989 skip_operand(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1990 return;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1991 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1992
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1993 tstr = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1994 if (!**p || isspace(**p))
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1995 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1996 lwasm_register_error(as, l, "Bad string condition");
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1997 return;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1998 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1999
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2000 for (strop = 0; strops[strop].str != NULL; strop++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2001 if (strcasecmp(strops[strop].str, tstr) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2002 break;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2003
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2004 lw_free(tstr);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2005
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2006 if (strops[strop].str == NULL)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2007 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2008 lwasm_register_error(as, l, "Bad string condition");
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2009 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2010
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2011 tv = (*(strops[strop].fn))(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2012
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2013 if (!tv)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2014 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2015 as -> skipcond = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2016 as -> skipcount = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2017 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2018 }