annotate lwasm/pseudo.c @ 379:d791d47afc48

Add m80ext pragma for Macro-80C compatibility and ignore END in includes For compatibility with Macro-80C source, add pragma for it. Also implement ignoring END in include files rather than treating it as the total end of assembly. Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Mon, 13 Jul 2015 20:59:02 -0600
parents 8e25147c2aa8
children e3f4aaa2a4e8
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
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
22 #include "lwasm.h"
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
23
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
24 #include <stdio.h>
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
25 #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
26 #include <string.h>
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
27 #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
28 #include <time.h>
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
29
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
30 #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
31
2c24602be78f 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 "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
33 #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
34
2c24602be78f 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 #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
36
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
37 void register_struct_entry(asmstate_t *as, line_t *l, int size, structtab_t *ss);
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
38
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
39 // for "dts"
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
40 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
41 {
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
42 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
43 char *t;
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
44
135
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
45 skip_operand(p);
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
46 l -> len = 0;
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
47
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
48 tp = time(NULL);
281
cb24ffb23f7c Make DTS not have problems if used multiple times.
William Astle <lost@l-w.ca>
parents: 280
diff changeset
49 t = l ->lstr = lw_strdup(ctime(&tp));
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
50
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
51 while (*t)
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
52 {
233
7887a48b74df Remove stray \n from dts
William Astle <lost@l-w.ca>
parents: 225
diff changeset
53 if (*t == '\n')
7887a48b74df Remove stray \n from dts
William Astle <lost@l-w.ca>
parents: 225
diff changeset
54 break;
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
55 t++;
135
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
56 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
57 }
280
4370370f38d1 Correct CRC problems with DTS pseudo op
William Astle <lost@l-w.ca>
parents: 266
diff changeset
58
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
59 }
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
60
135
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
61 EMITFUNC(pseudo_emit_dts)
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
62 {
280
4370370f38d1 Correct CRC problems with DTS pseudo op
William Astle <lost@l-w.ca>
parents: 266
diff changeset
63 char *t;
4370370f38d1 Correct CRC problems with DTS pseudo op
William Astle <lost@l-w.ca>
parents: 266
diff changeset
64 int i;
4370370f38d1 Correct CRC problems with DTS pseudo op
William Astle <lost@l-w.ca>
parents: 266
diff changeset
65
4370370f38d1 Correct CRC problems with DTS pseudo op
William Astle <lost@l-w.ca>
parents: 266
diff changeset
66 for (t = l -> lstr, i = 0; i < l -> len; i++, t++)
4370370f38d1 Correct CRC problems with DTS pseudo op
William Astle <lost@l-w.ca>
parents: 266
diff changeset
67 lwasm_emit(l, *t);
135
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
68 }
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
69
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
70 // for "dtb"
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
71 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
72 {
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
73 skip_operand(p);
135
fe117454a1e7 Adjustments to dts/dtb
lost@l-w.ca
parents: 133
diff changeset
74 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
75 }
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 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
78 {
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
79 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
80 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
81
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
82 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
83 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
84
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
85 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
86 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
87 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
88 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
89 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
90 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
91 }
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
92
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
93 // 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
94 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
95 {
2c24602be78f 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 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
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 l -> len = 0;
379
d791d47afc48 Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents: 374
diff changeset
99
d791d47afc48 Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents: 374
diff changeset
100 if (CURPRAGMA(l, PRAGMA_M80EXT) && input_isinclude(as))
d791d47afc48 Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents: 374
diff changeset
101 return; /* ignore END inside includes */
d791d47afc48 Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents: 374
diff changeset
102
d791d47afc48 Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents: 374
diff changeset
103 as->endseen = 1;
d791d47afc48 Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents: 374
diff changeset
104
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
105 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
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 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
108 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
109 }
2c24602be78f 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
2c24602be78f 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 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
112 {
2c24602be78f 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 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
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 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
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 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
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 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
120 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
121 lwasm_register_error(as, as->cl, E_EXPRESSION_BAD);
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
122 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
123 }
2c24602be78f 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_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
125 }
2c24602be78f 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
2c24602be78f 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 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
128 {
2c24602be78f 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 lw_expr_t addr;
379
d791d47afc48 Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents: 374
diff changeset
130
d791d47afc48 Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents: 374
diff changeset
131 if (CURPRAGMA(l, PRAGMA_M80EXT) && input_isinclude(as))
d791d47afc48 Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents: 374
diff changeset
132 return; /* ignore END inside includes */
d791d47afc48 Add m80ext pragma for Macro-80C compatibility and ignore END in includes
William Astle <lost@l-w.ca>
parents: 374
diff changeset
133
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 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
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 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
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 if (!lw_expr_istype(addr, lw_expr_type_int))
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
139 lwasm_register_error(as, l, E_EXEC_ADDRESS);
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
140 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
141 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
142 }
2c24602be78f 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 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
144 }
2c24602be78f 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
2c24602be78f 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 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
147 {
2c24602be78f 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 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
149 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
150
2c24602be78f 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 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
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 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
154 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
155 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
156 lwasm_register_error2(as, l, E_EXPRESSION_BAD, "(#%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
157 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
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 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
160 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
161 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
162 (*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
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 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
166 }
2c24602be78f 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 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
169 {
2c24602be78f 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 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
171 lw_expr_t e;
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
172 // 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
173
2c24602be78f 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 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
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 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
177 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
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 }
2c24602be78f 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
2c24602be78f 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 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
182 {
2c24602be78f 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 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
184 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
185
2c24602be78f 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 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
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 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
189 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
190 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
191 lwasm_register_error2(as, l, E_EXPRESSION_BAD, "(#%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
192 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
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 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
195 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
196 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
197 (*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
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 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
201 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
202
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
203 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
204 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
205 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
206 lw_expr_t e;
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
207 // 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
208
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
209 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
210 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
211 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
212 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
213 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
214 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
215
218
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
216 PARSEFUNC(pseudo_parse_fdbs)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
217 {
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
218 int i = 0;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
219 lw_expr_t e;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
220
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
221 for (;;)
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 e = lwasm_parse_expr(as, p);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
224 if (!e)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
225 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
226 lwasm_register_error2(as, l, E_EXPRESSION_BAD, "(#%d)", i);
218
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
227 break;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
228 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
229 lwasm_save_expr(l, i++, e);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
230 if (**p != ',')
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
231 break;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
232 (*p)++;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
233 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
234
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
235 l -> len = i * 2;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
236 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
237
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
238 EMITFUNC(pseudo_emit_fdbs)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
239 {
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
240 int i;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
241 lw_expr_t e;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
242 lw_expr_t t;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
243 lw_expr_t t2;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
244 // int v;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
245
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
246 for (i = 0; i < (l -> len)/2; i++)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
247 {
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
248 e = lwasm_fetch_expr(l, i);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
249 t = lw_expr_build(lw_expr_type_int, 256);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
250 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
251 lwasm_reduce_expr(as, t2);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
252 lw_expr_destroy(t);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
253 lwasm_emitexpr(l, e, 1);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
254 lwasm_emitexpr(l, t2, 1);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
255 lw_expr_destroy(t2);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
256 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
257 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
258
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
259 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
260 {
2c24602be78f 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 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
262 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
263
2c24602be78f 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 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
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 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
267 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
268 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
269 lwasm_register_error2(as, l, E_EXPRESSION_BAD, "(#%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
270 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
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 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
273 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
274 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
275 (*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
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 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
279 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
280
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
281 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
282 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
283 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
284 lw_expr_t e;
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
285 // 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
286
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
287 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
288 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
289 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
290 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
291 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
292 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
293
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
294 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
295 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
296 int l = 0;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
297 char *str = NULL;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
298 int blen = 0;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
299 int bsize = 0;
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 if (!(as -> pragmas & PRAGMA_CESCAPES))
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 for (; **p && **p != delim; (*p)++)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
304 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
305 l++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
306 if (blen >= bsize)
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 str = lw_realloc(str, bsize + 32);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
309 bsize++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
310 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
311 str[blen++] = **p;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
312 }
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 else
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
315 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
316 while (**p && **p != delim)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
317 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
318 int wch = **p;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
319 if (**p == '\\')
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
320 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
321 /* escape sequence */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
322
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
323 (*p)++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
324 if (!**p)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
325 break;
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
326
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
327 switch (**p)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
328 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
329 /* octal sequence or NUL */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
330 /* skip the "0", then skip up to two more digits */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
331 case '0':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
332 case '1':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
333 case '2':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
334 case '3':
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
335 wch = **p;
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
336 wch -= 0x30;
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
337 if ((*p)[1] >= '0' && (*p)[1] < '8')
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
338 {
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
339 (*p)++;
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
340 wch *= 8;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
341 wch += **p - 0x30;
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
342 }
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
343 if ((*p)[1] >= '0' && (*p)[1] < '8')
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
344 {
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
345 (*p)++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
346 wch *= 8;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
347 wch += **p -0x30;
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 break;
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 /* hexadecimal value */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
352 case 'x':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
353 (*p)++; // ignore "x"
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
354 wch = 0;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
355 if (**p) // skip digit 1
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
356 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
357 wch = **p - 0x30;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
358 if (wch > 9)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
359 wch -= 7;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
360 if (wch > 9)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
361 wch -= 32;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
362 (*p)++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
363 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
364 if (**p)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
365 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
366 int i;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
367 i = **p - 0x30;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
368 if (i > 9)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
369 i -= 7;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
370 if (i > 9)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
371 i -= 32;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
372 wch = wch * 16 + i;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
373 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
374 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
375
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
376 case 'a':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
377 wch = 7;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
378 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
379
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
380 case 'b':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
381 wch = 8;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
382 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
383
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
384 case 't':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
385 wch = 9;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
386 break;
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 case 'n':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
389 wch = 10;
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 case 'v':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
393 wch = 11;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
394 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
395
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
396 case 'f':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
397 wch = 12;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
398 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
399
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
400 case 'r':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
401 wch = 13;
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 /* everything else represents itself */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
404 default:
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
405 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
406 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
407 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
408 /* now "wch" is the character to write out */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
409 l++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
410 (*p)++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
411 if (blen >= bsize)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
412 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
413 str = lw_realloc(str, bsize + 32);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
414 bsize += 32;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
415 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
416 str[blen++] = wch;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
417 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
418 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
419 /* do something with the string here */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
420 /* l is the string length, str is the string itself */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
421 ln -> lstr = str;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
422 return l;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
423 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
424
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
425 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
426 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
427 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
428 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
429
2c24602be78f 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 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
431 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
432 lwasm_register_error(as, l, E_OPERAND_BAD);
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 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
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 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
437 (*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
438
2c24602be78f 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
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
440 i = cstringlen(as, l, p, delim);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
441
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
442 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
443 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
444 lwasm_register_error(as, l, E_OPERAND_BAD);
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
445 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
446 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
447 (*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
448 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
449 }
2c24602be78f 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 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
452 {
2c24602be78f 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 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
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 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
456 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
457 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
458
2c24602be78f 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 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
460 {
2c24602be78f 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 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
462 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
463
2c24602be78f 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 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
465 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
466 lwasm_register_error(as, l, E_OPERAND_BAD);
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
467 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
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
2c24602be78f 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 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
471 (*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
472
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
473 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
474
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
475 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
476 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
477 lwasm_register_error(as, l, E_OPERAND_BAD);
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
478 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
479 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
480 (*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
481 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
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
2c24602be78f 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 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
485 {
2c24602be78f 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 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
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 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
489 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
490 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
491 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
492
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
493 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
494 {
2c24602be78f 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 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
496 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
497
2c24602be78f 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 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
499 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
500 lwasm_register_error(as, l, E_OPERAND_BAD);
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
501 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
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
2c24602be78f 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 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
505 (*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
506
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
507 i = cstringlen(as, l, p, delim);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
508
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
509 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
510 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
511 lwasm_register_error(as, l, E_OPERAND_BAD);
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
512 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
513 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
514 (*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
515 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
516 }
2c24602be78f 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
2c24602be78f 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 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
519 {
2c24602be78f 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 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
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 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
523 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
524 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
525 }
2c24602be78f 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
2c24602be78f 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 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
528 {
2c24602be78f 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 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
530
2c24602be78f 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 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
532 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
533 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
534 lwasm_register_error(as, l, E_EXPRESSION_BAD);
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
535 }
2c24602be78f 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
2c24602be78f 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 -> 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
538 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
539 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
540 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
541 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
542 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
543 lwasm_register_error(as, l, E_EXPRESSION_NOT_CONST);
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
544 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
545 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
546 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
547 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
548 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
549 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
550 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
551 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
552 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
553 }
2c24602be78f 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 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
555 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
556 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
557 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
558 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
559 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
560 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
561 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
562 }
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
563 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
564 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
565
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
566 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
567 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
568 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
569
2c24602be78f 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 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
571 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
572
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
573 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
574 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
575 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
576 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
577 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
578 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
579 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
580 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
581 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
582 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
583
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 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
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 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
587 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
588 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
589 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
590 lwasm_register_error2(as, l, E_NEGATIVE_RESERVATION, "(%d)", lw_expr_intval(expr));
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
591 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
592 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
593 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
594 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
595 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
596 l -> dlen = lw_expr_intval(expr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
597 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
598 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
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 }
2c24602be78f 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
2c24602be78f 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 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
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 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
605 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
606
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
607 if (l -> len < 0 || l -> dlen < 0)
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
608 lwasm_register_error2(as, l, E_EXPRESSION_NOT_CONST, "%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
609 }
2c24602be78f 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
2c24602be78f 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 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
612 {
2c24602be78f 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 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
614
2c24602be78f 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 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
616 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
617 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
618 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
619 lwasm_register_error(as, l, E_EXPRESSION_BAD);
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 }
2c24602be78f 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
2c24602be78f 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 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
623 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
624 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
625 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
626 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
627 lwasm_register_error(as, l, E_EXPRESSION_NOT_CONST);
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
628 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
629 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
630 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
631 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
632 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
633 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
634 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
635 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
636 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
637 }
2c24602be78f 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 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
639 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
640 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
641 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
642 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
643 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
644 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
645 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
646 }
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
647 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
648 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
649
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
650 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
651 {
2c24602be78f 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 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
653
2c24602be78f 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 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
655 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
656
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
657 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
658 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
659 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
660 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
661 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
662 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
663 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
664 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
665 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
666 }
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
667
2c24602be78f 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 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
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 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
671 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
672 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
673 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
674 lwasm_register_error2(as, l, E_NEGATIVE_RESERVATION, "(%d)", lw_expr_intval(expr));
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
675 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
676 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
677 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
678 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
679 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
680 l -> dlen = lw_expr_intval(expr) * 2;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
681 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
682 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
683 }
2c24602be78f 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
2c24602be78f 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 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
687 {
2c24602be78f 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 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
689 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
690
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
691 if (l -> len < 0 || l -> dlen < 0)
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
692 lwasm_register_error(as, l, E_EXPRESSION_NOT_CONST);
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
693 }
2c24602be78f 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
2c24602be78f 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 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
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 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
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 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
701 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
702 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
703 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
704 lwasm_register_error(as, l, E_EXPRESSION_BAD);
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
705 }
2c24602be78f 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 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
707 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
708 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
709 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
710 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
711 lwasm_register_error(as, l, E_EXPRESSION_NOT_CONST);
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
712 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
713 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
714 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
715 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
716 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
717 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
718 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
719 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
720 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
721 }
2c24602be78f 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 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
723 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
724 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
725 if (as -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
726 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
727 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
728 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
729 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
730 }
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
731 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
732 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
733
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
734 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
735 {
2c24602be78f 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 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
737
2c24602be78f 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 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
739 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
740
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
741 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
742 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
743 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
744 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
745 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
746 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
747 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
748 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
749 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
750 }
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
751
2c24602be78f 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 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
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 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
755 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
756 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
757 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
758 lwasm_register_error2(as, l, E_NEGATIVE_RESERVATION, "(%d)", lw_expr_intval(expr));
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
759 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
760 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
761 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
762 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
763 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
764 l -> dlen = lw_expr_intval(expr) * 4;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
765 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
766 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
767 }
2c24602be78f 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
2c24602be78f 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 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
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 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
773 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
774
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
775 if (l -> len < 0 || l -> dlen < 0)
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
776 lwasm_register_error(as, l, E_EXPRESSION_NOT_CONST);
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
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
2c24602be78f 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 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
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 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
783
2c24602be78f 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 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
785 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
786 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
787 lwasm_register_error(as, l, E_EXPRESSION_BAD);
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
788 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
789
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
790 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
791 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
792
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
793 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
794 {
2c24602be78f 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 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
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 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
798 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
799
2c24602be78f 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 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
801
2c24602be78f 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 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
803 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
804 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
805 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
806 lwasm_register_error2(as, l, E_NEGATIVE_BLOCKSIZE, "(%d)", lw_expr_intval(expr));
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
807 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
808 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
809 }
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
810 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
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 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
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 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
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 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
819 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
820 lwasm_register_error(as, l, E_EXPRESSION_NOT_CONST);
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
821 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
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 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
825 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
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
2c24602be78f 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 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
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 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
832
2c24602be78f 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 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
834 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
835 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
836 lwasm_register_error(as, l, E_EXPRESSION_BAD);
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
837 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
838
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
839 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
840 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
841
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
842 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
843 {
2c24602be78f 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 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
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 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
847 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
848
2c24602be78f 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 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
850
2c24602be78f 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 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
852 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
853 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
854 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
855 lwasm_register_error2(as, l, E_NEGATIVE_BLOCKSIZE, "(%d)", lw_expr_intval(expr));
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
856 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
857 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
858 }
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
859 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
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
2c24602be78f 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 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
864 {
2c24602be78f 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 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
866
2c24602be78f 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 (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
868 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
869 lwasm_register_error(as, l, E_EXPRESSION_NOT_CONST);
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
870 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
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
2c24602be78f 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 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
874 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
875 }
2c24602be78f 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 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
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 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
880
2c24602be78f 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 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
882 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
883 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
884 lwasm_register_error(as, l, E_EXPRESSION_BAD);
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
885 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
886
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
887 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
888 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
889
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
890 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
891 {
2c24602be78f 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 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
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 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
895 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
896
2c24602be78f 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 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
898
2c24602be78f 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 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
900 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
901 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
902 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
903 lwasm_register_error2(as, l, E_NEGATIVE_BLOCKSIZE, "(%d)", lw_expr_intval(expr));
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
904 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
905 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
906 }
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
907 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
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
2c24602be78f 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 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
912 {
2c24602be78f 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 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
914
2c24602be78f 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 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
916 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
917 lwasm_register_error(as, l, E_EXPRESSION_NOT_CONST);
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
918 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
919 }
2c24602be78f 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
2c24602be78f 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 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
922 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
923 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
924
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
925 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
926 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
927 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
928
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
929 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
930
2c24602be78f 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 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
932 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
933 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
934 lwasm_register_error(as, l, E_OPERAND_BAD);
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
935 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
936 }
2c24602be78f 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
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
938 lw_expr_destroy(l -> daddr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
939 l -> daddr = e;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
940
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
941 if (l -> inmod == 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
942 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
943 lw_expr_destroy(l -> addr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
944 l -> addr = e;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
945 }
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
946 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
947 }
2c24602be78f 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 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
950 {
2c24602be78f 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 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
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 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
954
2c24602be78f 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 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
956 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
957 lwasm_register_error(as, l, E_SYMBOL_MISSING);
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
958 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
959 }
2c24602be78f 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 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
962 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
963 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
964 lwasm_register_error(as, l, E_OPERAND_BAD);
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
965 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
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
2c24602be78f 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 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
969 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
970 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
971 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
972 }
2c24602be78f 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 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
975 {
2c24602be78f 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 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
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 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
979
2c24602be78f 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 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
981 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
982 lwasm_register_error(as, l, E_SYMBOL_MISSING);
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
983 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
984 }
2c24602be78f 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 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
987 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
988 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
989 lwasm_register_error(as, l, E_OPERAND_BAD);
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
990 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
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
2c24602be78f 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 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
994 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
995 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
996 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
997 }
2c24602be78f 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 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
1000 {
2c24602be78f 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 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
1002
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1003 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
1004
2c24602be78f 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 (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
1006 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1007 lwasm_register_error(as, l, E_SETDP_INVALID);
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
1008 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
1009 }
2c24602be78f 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 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
1012 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
1013 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1014 lwasm_register_error(as, l, E_OPERAND_BAD);
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
1015 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
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
38
7e92484cfbc3 Caused expressions used in setdp and conditionals to be reduced on pass 1
lost@l-w.ca
parents: 10
diff changeset
1018 // 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
1019 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
1020 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
1021 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1022 lwasm_register_error(as, l, E_SETDP_NOT_CONST);
88
1a1fdfe860d0 Fixed several memory leaks revealed by valgrind
lost@l-w.ca
parents: 84
diff changeset
1023 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
1024 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
1025 }
2c24602be78f 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 l -> dpval = lw_expr_intval(e) & 0xff;
88
1a1fdfe860d0 Fixed several memory leaks revealed by valgrind
lost@l-w.ca
parents: 84
diff changeset
1027 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
1028 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
1029 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
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_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
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;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1035 l -> hideline = 1;
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
1036
2c24602be78f 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 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
1038 {
2c24602be78f 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 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
1040 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
1041 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
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
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1044 lwasm_register_error2(as, l, W_NOT_SUPPORTED, "%s", "IFP1");
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
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
2c24602be78f 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 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
1048 {
2c24602be78f 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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1050 l -> hideline = 1;
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
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1059 lwasm_register_error2(as, l, W_NOT_SUPPORTED, "%s", "IFP2");
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
1060 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1061
2c24602be78f 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 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
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 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
1065
2c24602be78f 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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1067 l -> hideline = 1;
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
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 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
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 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
1072 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
1073 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
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
2c24602be78f 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 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
1077 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1078 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
1079 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
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 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
1082 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
1083 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1084 }
2c24602be78f 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
2c24602be78f 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 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
1087 {
2c24602be78f 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 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1091 l -> hideline = 1;
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
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 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
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 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
1096 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
1097 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
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
2c24602be78f 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 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
1101 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1102 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
1103 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
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 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
1106 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
1107 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1108 }
2c24602be78f 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
2c24602be78f 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 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
1112 {
2c24602be78f 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 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1116 l -> hideline = 1;
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
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 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
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 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
1121 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
1122 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
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
2c24602be78f 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 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
1126 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1127 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
1128 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
1129 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1130 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
1131 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
1132 }
2c24602be78f 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
2c24602be78f 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 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
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 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1140 l -> hideline = 1;
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
1141
2c24602be78f 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 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
1143 {
2c24602be78f 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 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
1145 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
1146 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
1147 }
2c24602be78f 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
2c24602be78f 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 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
1150 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1151 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
1152 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
1153 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1154 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
1155 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
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 }
2c24602be78f 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
2c24602be78f 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 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
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 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
1162
2c24602be78f 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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1164 l -> hideline = 1;
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
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 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
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 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
1169 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
1170 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
1171 }
2c24602be78f 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
2c24602be78f 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 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
1174 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1175 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
1176 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
1177 {
2c24602be78f 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 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
1179 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
1180 }
2c24602be78f 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 }
2c24602be78f 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 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
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 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
1186
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1187 l -> hideline = 1;
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
1188 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
1189
2c24602be78f 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 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
1191 {
2c24602be78f 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 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
1193 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
1194 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
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 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
1198 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1199 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
1200 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
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 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
1203 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
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 }
2c24602be78f 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 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
1208 {
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1209 l -> hideline = 1;
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 l -> len = 0;
145
d6e9cc4484f6 Fixed ENDC to work with comments after it
lost@l-w.ca
parents: 142
diff changeset
1211 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
1212 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
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 -> 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
1215 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
1216 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
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 }
2c24602be78f 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 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
1221 {
2c24602be78f 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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1223 l -> hideline = 1;
217
f87c86668d6b Fix handling of comments on ELSE lines
William Astle <lost@l-w.ca>
parents: 208
diff changeset
1224 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
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 -> 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 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
1228
2c24602be78f 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 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
1230 {
2c24602be78f 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 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
1232 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1233 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
1234 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
1235 }
2c24602be78f 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 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
1237 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1238 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
1239 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
1240 }
2c24602be78f 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 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
1243 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1244 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
1245 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
1246 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
1247
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1248 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1249 l -> hideline = 1;
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
1250
2c24602be78f 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 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
1252 {
2c24602be78f 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 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
1254 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
1255 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
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
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1258 again:
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1259 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
1260 /* 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
1261
2c24602be78f 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 sym = lw_strndup(*p, i);
84
16a72d9b6eb6 Make ifdef work correctly
lost@l-w.ca
parents: 76
diff changeset
1263 (*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
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 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
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 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
1268
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1269 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
1270 {
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1271 if (**p == '|')
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1272 {
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1273 (*p)++;
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1274 goto again;
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1275 }
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
1276 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
1277 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
1278 }
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1279 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
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
2c24602be78f 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 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
1283 {
2c24602be78f 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 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
1285 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
1286 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1289 l -> hideline = 1;
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
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 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
1292 {
2c24602be78f 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 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
1294 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
1295 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
1296 }
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1297 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
1298 /* 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
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 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
1301 (*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
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 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
1304
2c24602be78f 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 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
1306
2c24602be78f 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 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
1308 {
2c24602be78f 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 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
1310 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
1311 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
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
2c24602be78f 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 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
1316 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1317 lwasm_register_error2(as, l, E_USER_SPECIFIED, "%s", *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
1318 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
1319 }
2c24602be78f 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
2c24602be78f 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 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
1322 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1323 lwasm_register_error2(as, l, W_USER_SPECIFIED, "%s", *p);
225
823560a8c251 Prevent infinite loop due to warning directive
William Astle <lost@l-w.ca>
parents: 224
diff changeset
1324 l -> len = 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
1325 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
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
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1328 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
1329 {
2c24602be78f 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 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
1331 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
1332 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
1333 long flen;
224
3864d96ee8c7 Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents: 219
diff changeset
1334 char *rfn;
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
1335
2c24602be78f 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 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
1337 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1338 lwasm_register_error(as, l, E_FILENAME_MISSING);
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
1339 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
1340 }
2c24602be78f 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 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
1343 {
2c24602be78f 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 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
1345 (*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
1346
63
74b82202d355 Make for condition clearer
lost@l-w.ca
parents: 62
diff changeset
1347 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
1348 /* 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
1349 }
2c24602be78f 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 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
1351 {
2c24602be78f 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 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
1353 /* 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
1354 }
2c24602be78f 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 fn = lw_strndup(*p, p2 - *p);
62
5b10ff307463 Fixed problem with filename handling in includebin
lost@l-w.ca
parents: 58
diff changeset
1356 *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
1357 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
1358 (*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
1359
224
3864d96ee8c7 Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents: 219
diff changeset
1360 fp = input_open_standalone(as, fn, &rfn);
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
1361 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
1362 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1363 lwasm_register_error(as, l, E_FILE_OPEN);
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
1364 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
1365 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
1366 }
2c24602be78f 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
224
3864d96ee8c7 Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents: 219
diff changeset
1368 l -> lstr = rfn;
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
1369
2c24602be78f 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 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
1371 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
1372 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
1373
2c24602be78f 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 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
1375 }
2c24602be78f 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
2c24602be78f 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 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
1378 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1379 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
1380 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
1381
349
b62af915c2cc Fix includebin to use binary mode when emitting the contents of the file.
William Astle <lost@l-w.ca>
parents: 281
diff changeset
1382 fp = fopen(l -> lstr, "rb");
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
1383 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
1384 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1385 lwasm_register_error2(as, l, E_FILE_OPEN, "%s", "(emit)!");
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
1386 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
1387 }
2c24602be78f 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 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
1390 {
2c24602be78f 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 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
1392 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
1393 {
2c24602be78f 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 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
1395 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
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 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
1398 }
2c24602be78f 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
2c24602be78f 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 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
1402 {
2c24602be78f 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 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
1404 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
1405 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
1406 int len;
41
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1407 char buf[110];
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1408
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
1409 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
1410 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1411 lwasm_register_error(as, l, E_FILENAME_MISSING);
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 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
1413 }
2c24602be78f 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 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
1416 {
2c24602be78f 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 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
1418 (*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
1419
2c24602be78f 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 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
1421 /* 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
1422 }
2c24602be78f 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 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
1424 {
2c24602be78f 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 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
1426 /* 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
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 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
1429 (*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
1430 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
1431 (*p)++;
41
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1432
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1433 /* 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
1434 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
1435 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
1436
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
1437 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
1438 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
1439 sprintf(p3, "include:%s", fn);
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1440 as -> fileerr = 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
1441 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
1442 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
1443
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1444 if (as -> fileerr == 0)
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1445 l -> hideline = 1;
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 l -> len = 0;
93
5bf9edabd661 Squashed the remaining memory leaks revealed by valgrind
lost@l-w.ca
parents: 88
diff changeset
1447 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
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
2c24602be78f 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 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
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 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
1453 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
1454 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1455 lwasm_register_error(as, l, E_OPERAND_BAD);
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
1456 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
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
2c24602be78f 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 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
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 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
1462 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1463 lwasm_register_error(as, l, E_OPERAND_BAD);
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
1464 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
1465 }
2c24602be78f 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
2c24602be78f 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 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
1468
2c24602be78f 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 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
1470 {
114
707eda49ad60 Fix parsing padding argument for align pseudo op
lost@l-w.ca
parents: 93
diff changeset
1471 (*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
1472 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
1473 }
2c24602be78f 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 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
1475 {
2c24602be78f 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 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
1477 }
2c24602be78f 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 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
1479 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1480 lwasm_register_error(as, l, E_PADDING_BAD);
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
1481 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
1482 }
2c24602be78f 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
2c24602be78f 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 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
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 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
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;
264
346966cffeef Clean up various warnings when building under -Wall
William Astle <lost@l-w.ca>
parents: 251
diff changeset
1490 int align = 1;
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1491 lw_expr_t te;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1492 int a;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1493
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
1494 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
1495
2c24602be78f 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 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
1497 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1498 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
1499 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
1500 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1501 lwasm_register_error(as, l, E_ALIGNMENT_INVALID);
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
1502 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
1503 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1504 }
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1505 else
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
1506 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1507 return;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1508 }
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1509
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1510
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1511 te = lw_expr_copy(l -> addr);
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1512 as -> exportcheck = 1;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1513 lwasm_reduce_expr(as, te);
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1514 as -> exportcheck = 0;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1515
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1516 if (lw_expr_istype(te, lw_expr_type_int))
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1517 {
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1518 a = lw_expr_intval(te);
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1519 }
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1520 else
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1521 {
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1522 a = -1;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1523 }
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1524 lw_expr_destroy(te);
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1525
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1526 if (a >= 0)
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1527 {
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
1528 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
1529 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1530 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
1531 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
1532 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1533 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
1534 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
1535 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1536 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1537
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1538 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
1539 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1540 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
1541 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
1542
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1543 if (l -> csect && (l -> csect -> flags & (section_flag_bss | section_flag_constant)))
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1544 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
1545 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
1546 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
1547 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1548 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
1549 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1550 }
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1551
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1552 PARSEFUNC(pseudo_parse_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1553 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1554 lw_expr_t e, e1;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1555 if (!**p)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1556 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1557 lwasm_register_error(as, l, E_OPERAND_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1558 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1559 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1560
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1561 e1 = lwasm_parse_expr(as, p);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1562 if (**p != ',')
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1563 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1564 lwasm_register_error(as, l, E_OPERAND_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1565 return;
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 (*p)++;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1568 e = lwasm_parse_expr(as, p);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1569
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1570 if (!e)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1571 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1572 lwasm_register_error(as, l, E_OPERAND_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1573 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1574 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1575
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1576 lwasm_save_expr(l, 0, e);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1577 lwasm_save_expr(l, 1, e1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1578
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1579 if (!e1)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1580 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1581 lwasm_register_error(as, l, E_PADDING_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1582 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1583 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1584 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1585
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1586 RESOLVEFUNC(pseudo_resolve_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1587 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1588 lw_expr_t e, te;
264
346966cffeef Clean up various warnings when building under -Wall
William Astle <lost@l-w.ca>
parents: 251
diff changeset
1589 int align = 1;
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1590
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1591 e = lwasm_fetch_expr(l, 0);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1592
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1593 te = lw_expr_copy(e);
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1594 as -> exportcheck = 1;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1595 lwasm_reduce_expr(as, te);
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1596 as -> exportcheck = 0;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1597
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1598 if (lw_expr_istype(te, lw_expr_type_int))
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1599 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1600 align = lw_expr_intval(te);
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1601 if (align < 0)
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1602 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1603 lw_expr_destroy(te);
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1604 lwasm_register_error(as, l, E_FILL_INVALID);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1605 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1606 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1607 }
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1608 else
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1609 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1610 lw_expr_destroy(te);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1611 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1612 }
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1613 lw_expr_destroy(te);
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1614
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1615 l -> len = align;
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1616 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1617
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1618 EMITFUNC(pseudo_emit_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1619 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1620 lw_expr_t e;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1621 int i;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1622
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1623 /* don't emit anything in bss */
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1624 if (l -> csect && (l -> csect -> flags & (section_flag_bss | section_flag_constant)))
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1625 return;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1626
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1627 e = lwasm_fetch_expr(l, 1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1628 for (i = 0; i < l -> len; i++)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1629 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1630 lwasm_emitexpr(l, e, 1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1631 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1632 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1633
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1634 /* string conditional argument parser */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1635 /*
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1636 argument syntax:
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1637
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1638 a bare word ended by whitespace, comma, or NUL
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1639 a double quote delimited string containing arbitrary printable characters
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1640 a single quote delimited string containing arbitrary printable characters
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 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
1643 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
1644
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1645 */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1646 char *strcond_parsearg(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 *arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1649 char *tstr;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1650 int i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1651 tstr = *p;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1652
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1653 if (!**p || isspace(**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 return lw_strdup("");
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1656 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1657
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1658 if (*tstr == '"')
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1659 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1660 // double quote delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1661 tstr++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1662 for (i = 0; tstr[i] && tstr[i] != '"'; i++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1663 /* do nothing */ ;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1664
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1665 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1666 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1667 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1668
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1669 if (tstr[i])
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1670 i++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1671
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1672 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1673 return arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1674 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1675 else if (*tstr == '\'')
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 // single quote delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1678 tstr++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1679 for (i = 0; tstr[i] && tstr[i] != '\''; i++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1680 /* do nothing */ ;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1681
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1682 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1683 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1684 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1685
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1686 if (tstr[i])
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1687 i++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1688
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1689 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1690 return arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1691 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1692 else
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 // bare word - whitespace or comma delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1695 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
1696 /* do nothing */ ;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1697
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1698 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1699 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1700 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1701 if (tstr[i] == ',')
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1702 i++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1703
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1704 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1705 return arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1706 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1707 }
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 /* string conditional helpers */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1710 /* return "1" for true, "0" for false */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1711 int strcond_eq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1712 {
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 c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1716
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1717 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1718 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1719
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1720 if (strcmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1721 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1722 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1723 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1724 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1725 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1726
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1727 int strcond_ieq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1728 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1729 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1730 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1731 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1732
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1733 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1734 arg2 = strcond_parsearg(p);
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 if (strcasecmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1737 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1738 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1739 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1740 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1741 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1742
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1743 int strcond_ne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1744 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1745 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1746 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1747 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1748
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1749 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1750 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1751
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1752 if (strcmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1753 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1754 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1755 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1756 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1757 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1758
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1759 int strcond_ine(char **p)
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 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1762 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1763 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1764
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1765 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1766 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1767
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1768 if (strcasecmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1769 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1770 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1771 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1772 return c;
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
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1775 int strcond_peq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1776 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1777 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1778 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1779 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1780 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1781 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1782
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1783 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1784 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1785 arg2 = strcond_parsearg(p);
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 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1788 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1789 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1790 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1791 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1792
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1793 if (strcmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1794 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1795 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1796 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1797 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1798 return c;
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
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1801 int strcond_ipeq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1802 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1803 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1804 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1805 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1806 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1807 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1808
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1809 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1810 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1811 arg2 = strcond_parsearg(p);
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 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1814 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1815 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1816 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1817 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1818
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1819 if (strcasecmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1820 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1821 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1822 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1823 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1824 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1825 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1826
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1827 int strcond_pne(char **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 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1830 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1831 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1832 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1833 int c = 0;
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 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1836 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1837 arg2 = strcond_parsearg(p);
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 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1840 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1841 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1842 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1843 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1844
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1845 if (strcmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1846 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1847 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1848 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1849 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1850 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1851 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1852
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1853 int strcond_ipne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1854 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1855 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1856 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1857 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1858 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1859 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1860
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1861 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1862 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1863 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1864
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1865 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1866 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1867 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1868 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1869 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1870
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1871 if (strcasecmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1872 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1873 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1874 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1875 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1876 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1877 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1878
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1879 int strcond_seq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1880 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1881 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1882 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1883 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1884 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1885 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1886
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1887 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1888 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1889
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1890 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1891 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1892 arg2 = strcond_parsearg(p);
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 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1895 rarg2 = arg2;
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 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1898 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1899 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1900 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1901 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1902 if (strlen(arg2) > plen)
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 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1905 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1906 if (strcmp(rarg1, rarg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1907 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1908 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1909 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1910 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1911 return c;
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 int strcond_iseq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1915 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1916 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1917 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1918 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1919 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1920 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1921
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1922 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1923 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1924
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1925 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1926 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1927 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1928
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1929 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1930 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1931
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1932 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1933 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1934 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1935 rarg1 += strlen(arg1) - plen;
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 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1938 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1939 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1940 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1941
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1942 if (strcasecmp(rarg1, rarg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1943 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1944 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1945 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1946 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1947 return c;
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
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1951 int strcond_sne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1952 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1953 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1954 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1955 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1956 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1957 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1958
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1959 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1960 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1961
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1962 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1963 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1964 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1965
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1966 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1967 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1968
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1969 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1970 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1971 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1972 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1973 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1974 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1975 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1976 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1977 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1978
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1979 if (strcmp(rarg1, rarg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1980 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1981 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1982 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1983 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1984 return c;
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
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1987 int strcond_isne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1988 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1989 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1990 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1991 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1992 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1993 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1994
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1995 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1996 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1997
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1998 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1999 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2000 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2001
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2002 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2003 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2004
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2005 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2006 if (strlen(arg1) > plen)
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 rarg1 += strlen(arg1) - plen;
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 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2011 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2012 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2013 }
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 if (strcasecmp(rarg1, rarg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2016 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2017 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2018 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2019 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2020 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2021 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2022
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2023 /* string conditionals */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2024 PARSEFUNC(pseudo_parse_ifstr)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2025 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2026 static struct strconds
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2027 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2028 char *str;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2029 int (*fn)(char **ptr);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2030 } strops[] = {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2031 { "eq", strcond_eq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2032 { "ieq", strcond_ieq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2033 { "ne", strcond_ne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2034 { "ine", strcond_ine },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2035 { "peq", strcond_peq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2036 { "ipeq", strcond_ipeq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2037 { "pne", strcond_pne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2038 { "ipne", strcond_ipne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2039 { "seq", strcond_seq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2040 { "iseq", strcond_iseq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2041 { "sne", strcond_sne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2042 { "isne", strcond_isne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2043 { NULL, 0 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2044 };
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2045 int tv = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2046 char *tstr;
58
62372522ce9c Clean up warning about unused variable
lost@l-w.ca
parents: 55
diff changeset
2047 int strop;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2048
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2049 l -> len = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2050
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2051 if (as -> skipcond && !(as -> skipmacro))
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2052 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2053 as -> skipcount++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2054 skip_operand(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2055 return;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2056 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2057
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2058 tstr = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2059 if (!**p || isspace(**p))
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2060 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
2061 lwasm_register_error(as, l, E_STRING_BAD);
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2062 return;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2063 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2064
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2065 for (strop = 0; strops[strop].str != NULL; strop++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2066 if (strcasecmp(strops[strop].str, tstr) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2067 break;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2068
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2069 lw_free(tstr);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2070
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2071 if (strops[strop].str == NULL)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2072 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
2073 lwasm_register_error(as, l, E_STRING_BAD);
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2074 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2075
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2076 tv = (*(strops[strop].fn))(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2077
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2078 if (!tv)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2079 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2080 as -> skipcond = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2081 as -> skipcount = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2082 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2083 }