annotate lwasm/pseudo.c @ 393:f2decd9b276d

Fix minor error in string parsing Growing a buffer by 32 bytes and then only saying the buffer grew by one byte is not exactly efficient. While not strictly broken, it's dumb. Fix it to actually count the 32 bytes.
author William Astle <lost@l-w.ca>
date Tue, 14 Jul 2015 23:12:24 -0600
parents 6ee9c67a0f8d
children 4411a6123716
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);
393
f2decd9b276d Fix minor error in string parsing
William Astle <lost@l-w.ca>
parents: 384
diff changeset
309 bsize += 32;
75
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
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
439 i = cstringlen(as, l, p, delim);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
440
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
441 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
442 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
443 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
444 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
445 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
446 (*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
447 l -> len = i;
381
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
448
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
449 /* handle additional expressions, like FCC "Hello",13,0 */
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
450 if (CURPRAGMA(l, PRAGMA_M80EXT))
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
451 {
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
452 if (**p == ',')
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
453 {
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
454 (*p)++;
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
455 pseudo_parse_fcb(as, l, p);
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
456 l -> fcc_extras = l -> len;
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
457 l -> len = i + l -> fcc_extras;
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
458 }
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
459 }
0
2c24602be78f 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
2c24602be78f 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 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
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 int i;
381
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
465 lw_expr_t e;
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
466
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
467 for (i = 0; i < l -> len - l -> fcc_extras; 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
468 lwasm_emit(l, l -> lstr[i]);
381
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
469
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
470 /* PRAGMA_M80EXT */
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
471 for (i = 0; i < l -> fcc_extras; i++)
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
472 {
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
473 e = lwasm_fetch_expr(l, i);
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
474 lwasm_emitexpr(l, e, 1);
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
475 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
476 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
477
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
478 PARSEFUNC(pseudo_parse_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
479 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
480 char delim;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
481 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
482
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
483 if (!**p)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
484 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
485 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
486 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
487 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
488
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
489 delim = **p;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
490 (*p)++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
491
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
492 i = cstringlen(as, l, p, delim);
0
2c24602be78f 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
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
494 if (**p != delim)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
495 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
496 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
497 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
498 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
499 (*p)++;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
500 l -> len = i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
501 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
502
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
503 EMITFUNC(pseudo_emit_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
504 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
505 int i;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
506
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
507 for (i = 0; i < l -> len - 1; i++)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
508 lwasm_emit(l, l -> lstr[i]);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
509 lwasm_emit(l, 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
510 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
511
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
512 PARSEFUNC(pseudo_parse_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
513 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
514 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
515 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
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 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
518 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
519 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
520 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
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
2c24602be78f 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 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
524 (*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
525
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
526 i = cstringlen(as, l, p, delim);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
527
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
528 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
529 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
530 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
531 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
532 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
533 (*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
534 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
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 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
538 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
539 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
540
2c24602be78f 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 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
542 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
543 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
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
2c24602be78f 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 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
547 {
2c24602be78f 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 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
549
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
550 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
551 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
552 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
553 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
554 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
555
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
556 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
557 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
558 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
559 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
560 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
561 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
562 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
563 }
2c24602be78f 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 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
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 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
567 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
568 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
569 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
570 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
571 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
572 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
573 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
574 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
575 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
576 if (l -> inmod)
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 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
579 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
580 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
581 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
582 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
583 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
584
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
585 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
586 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
587 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
588
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
589 if (l -> lint)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
590 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
591
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
592 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
593 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
594 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
595 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
596 }
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 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
599 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
600 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
601 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
602
0
2c24602be78f 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 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
604
2c24602be78f 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 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
606 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
607 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
608 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
609 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
610 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
611 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
612 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
613 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
614 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
615 l -> dlen = lw_expr_intval(expr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
616 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
617 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
618 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
619 }
2c24602be78f 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 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
622 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
623 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
624 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
625
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
626 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
627 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
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
2c24602be78f 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 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
631 {
2c24602be78f 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 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
633
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
634 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
635 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
636 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
637 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
638 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
639 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
640
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
641 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
642 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
643 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
644 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
645 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
646 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
647 }
2c24602be78f 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 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
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 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
651 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
652 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
653 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
654 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
655 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
656 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
657 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
658 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
659 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
660 if (l -> inmod)
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 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
663 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
664 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
665 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
666 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
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
2c24602be78f 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 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
670 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
671 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
672
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
673 if (l -> lint)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
674 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
675
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
676 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
677 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
678 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
679 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
680 }
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 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
683 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
684 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
685 }
0
2c24602be78f 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
2c24602be78f 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 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
688
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
689 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
690 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
691 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
692 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
693 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
694 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
695 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
696 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
697 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
698 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
699 l -> dlen = lw_expr_intval(expr) * 2;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
700 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
701 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
702 }
2c24602be78f 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 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
704
2c24602be78f 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 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
706 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
707 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
708 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
709
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
710 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
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
2c24602be78f 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 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
716 {
2c24602be78f 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 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
718
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
719 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
720 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
721 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
722 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
723 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
724 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
725 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
726 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
727 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
728 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
729 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
730 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
731 }
2c24602be78f 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 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
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 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
735 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
736 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
737 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
738 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
739 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
740 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
741 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
742 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
743 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
744 if (as -> inmod)
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 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
747 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
748 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
749 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
750 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
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
2c24602be78f 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 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
754 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
755 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
756
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
757 if (l -> lint)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
758 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
759
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
760 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
761 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
762 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
763 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
764 }
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 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
767 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
768 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
769 }
0
2c24602be78f 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
2c24602be78f 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 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
772
2c24602be78f 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 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
774 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
775 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
776 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
777 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
778 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
779 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
780 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
781 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
782 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
783 l -> dlen = lw_expr_intval(expr) * 4;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
784 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
785 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
786 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
787 }
2c24602be78f 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 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
790 {
2c24602be78f 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 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
792 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
793
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
794 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
795 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
796 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
797
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
798
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
799 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
800 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
801 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
802
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
803 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
804 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
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_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
807 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
808
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
809 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
810 }
2c24602be78f 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 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
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 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
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 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
817 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
818
2c24602be78f 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 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
820
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
821 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
822 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
823 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
824 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
825 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
826 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
827 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
828 }
0
2c24602be78f 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 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
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 }
2c24602be78f 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 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
834 {
2c24602be78f 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 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
836
2c24602be78f 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 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
838 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
839 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
840 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
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
2c24602be78f 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 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
844 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
845 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
846
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
847
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
848 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
849 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
850 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
851
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
852 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
853 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
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_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
856 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
857
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
858 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
859 }
2c24602be78f 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 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
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 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
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 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
866 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
867
2c24602be78f 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 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
869
2c24602be78f 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 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
871 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
872 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
873 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
874 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
875 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
876 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
877 }
0
2c24602be78f 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 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
879 }
2c24602be78f 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
2c24602be78f 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 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
883 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
884 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
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 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
887 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
888 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
889 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
890 }
2c24602be78f 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 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
893 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
894 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
895
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
896 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
897 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
898 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
899
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
900 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
901 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
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_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
904 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
905
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
906 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
907 }
2c24602be78f 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 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
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 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
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 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
914 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
915
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
916 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
917
2c24602be78f 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 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
919 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
920 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
921 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
922 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
923 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
924 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
925 }
0
2c24602be78f 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 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
927 }
2c24602be78f 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
2c24602be78f 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 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
931 {
2c24602be78f 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 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
933
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
934 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
935 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
936 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
937 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
938 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
939
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
940 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
941 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
942 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
943
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
944 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
945 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
946 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
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 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
949
2c24602be78f 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 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
951 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
952 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
953 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
954 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
955 }
2c24602be78f 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
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
957 lw_expr_destroy(l -> daddr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
958 l -> daddr = e;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
959
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
960 if (l -> inmod == 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
961 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
962 lw_expr_destroy(l -> addr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
963 l -> addr = e;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
964 }
0
2c24602be78f 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 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
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
382
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
968 PARSEFUNC(pseudo_parse_reorg)
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
969 {
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
970 lw_expr_t e = NULL;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
971
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
972 l -> len = 0;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
973
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
974 line_t *cl = l;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
975 for (cl = cl -> prev; cl; cl = cl -> prev)
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
976 {
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
977 if (cl -> insn == -1) continue;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
978
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
979 if (!strcmp("org", instab[cl -> insn].opcode))
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
980 {
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
981 if (cl -> prev)
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
982 {
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
983 e = lw_expr_copy(cl -> prev -> daddr);
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
984 break;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
985 }
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
986 }
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
987 }
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
988
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
989 if (!e)
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
990 {
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
991 lwasm_register_error(as, l, E_ORG_NOT_FOUND);
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
992 return;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
993 }
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
994
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
995 lw_expr_destroy(l -> daddr);
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
996 l -> daddr = e;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
997
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
998 if (l -> inmod == 0)
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
999 {
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1000 lw_expr_destroy(l -> addr);
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1001 l -> addr = e;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1002 }
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1003 l -> len = 0;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1004 }
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1005
0
2c24602be78f 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 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
1007 {
2c24602be78f 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 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
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 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
1011
2c24602be78f 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 (!(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
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_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
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
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1018 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
1019 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
1020 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1021 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
1022 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
1023 }
2c24602be78f 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
2c24602be78f 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 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
1026 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
1027 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
1028 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
1029 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1030
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1031 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
1032 {
2c24602be78f 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 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
1034
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1035 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
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 (!(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
1038 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1039 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
1040 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1041 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1042
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1043 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
1044 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
1045 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1046 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
1047 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
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
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1050 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
1051 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
1052 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
1053 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
1054 }
2c24602be78f 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
2c24602be78f 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 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
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 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
1059
2c24602be78f 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 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
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 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
1063 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1064 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
1065 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
1066 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1067
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1068 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
1069 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
1070 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1071 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
1072 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
1073 }
2c24602be78f 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
38
7e92484cfbc3 Caused expressions used in setdp and conditionals to be reduced on pass 1
lost@l-w.ca
parents: 10
diff changeset
1075 // 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
1076 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
1077 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
1078 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1079 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
1080 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
1081 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
1082 }
2c24602be78f 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 l -> dpval = lw_expr_intval(e) & 0xff;
88
1a1fdfe860d0 Fixed several memory leaks revealed by valgrind
lost@l-w.ca
parents: 84
diff changeset
1084 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
1085 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
1086 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
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
2c24602be78f 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 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
1090 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1091 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1092 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
1093
2c24602be78f 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 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
1095 {
2c24602be78f 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 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
1097 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
1098 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
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
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1101 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
1102 }
2c24602be78f 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
2c24602be78f 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 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
1105 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1106 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1107 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
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 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
1110 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1111 as -> 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
1112 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
1113 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
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
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1116 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
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
2c24602be78f 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 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
1120 {
2c24602be78f 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 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
1122
2c24602be78f 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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1124 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
1125
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1126 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
1127 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1128 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
1129 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
1130 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
1131 }
2c24602be78f 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 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
1134 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1135 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
1136 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
1137 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1138 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
1139 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
1140 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1141 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1142
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1143 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
1144 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1145 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
1146
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1147 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1148 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
1149
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1150 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
1151 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1152 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
1153 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
1154 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
1155 }
2c24602be78f 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 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
1158 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1159 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
1160 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
1161 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1162 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
1163 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
1164 }
2c24602be78f 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
2c24602be78f 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 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
1169 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1170 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1173 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
1174
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1175 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
1176 {
2c24602be78f 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 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
1178 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
1179 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
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 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
1183 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1184 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
1185 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
1186 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1187 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
1188 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
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 }
2c24602be78f 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 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
1193 {
2c24602be78f 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 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1197 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
1198
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1199 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
1200 {
2c24602be78f 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 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
1202 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
1203 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1204 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1205
2c24602be78f 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 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
1207 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1208 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
1209 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
1210 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1211 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
1212 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
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 }
2c24602be78f 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
2c24602be78f 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 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
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 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1221 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
1222
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1223 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
1224 {
2c24602be78f 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 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
1226 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
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
2c24602be78f 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 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
1231 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1232 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
1233 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
1234 {
2c24602be78f 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 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
1236 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
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 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1239
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1240 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
1241 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1242 lw_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
1243
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1244 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
1245 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
1246
2c24602be78f 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 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
1248 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1249 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
1250 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
1251 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
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
2c24602be78f 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 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
1255 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1256 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
1257 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
1258 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1259 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
1260 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
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 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1263
2c24602be78f 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 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
1265 {
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1266 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
1267 l -> len = 0;
145
d6e9cc4484f6 Fixed ENDC to work with comments after it
lost@l-w.ca
parents: 142
diff changeset
1268 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
1269 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
1270 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1271 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
1272 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
1273 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
1274 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1275 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1276
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1277 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
1278 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1279 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1280 l -> hideline = 1;
217
f87c86668d6b Fix handling of comments on ELSE lines
William Astle <lost@l-w.ca>
parents: 208
diff changeset
1281 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
1282
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1283 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
1284 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
1285
2c24602be78f 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 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
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 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
1289 {
2c24602be78f 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 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
1291 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
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 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
1294 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1295 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
1296 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
1297 }
2c24602be78f 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
2c24602be78f 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 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
1300 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1301 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
1302 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
1303 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1306 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
1307
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1308 if (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
1309 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1310 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
1311 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
1312 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
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
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1315 again:
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1316 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
1317 /* 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
1318
2c24602be78f 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 sym = lw_strndup(*p, i);
84
16a72d9b6eb6 Make ifdef work correctly
lost@l-w.ca
parents: 76
diff changeset
1320 (*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
1321
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1322 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
1323
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1324 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
1325
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1326 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
1327 {
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1328 if (**p == '|')
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1329 {
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1330 (*p)++;
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1331 goto again;
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1332 }
0
2c24602be78f 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 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
1334 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
1335 }
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1336 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
1337 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1338
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1339 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
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 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
1342 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
1343 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
1344
2c24602be78f 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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1346 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
1347
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1348 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
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 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
1351 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
1352 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
1353 }
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1354 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
1355 /* 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
1356
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1357 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
1358 (*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
1359
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1360 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
1361
2c24602be78f 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 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
1363
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1364 if (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
1365 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1366 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
1367 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
1368 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
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 }
2c24602be78f 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
384
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1372 PARSEFUNC(pseudo_parse_ifpragma)
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1373 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1374 char *pstr;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1375 int i;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1376 int pragma;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1377 int compare;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1378
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1379 l -> len = 0;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1380 l -> hideline = 1;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1381
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1382 if (as -> skipcond && !(as -> skipmacro))
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1383 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1384 as -> skipcount++;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1385 skip_operand(p);
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1386 return;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1387 }
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1388
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1389 again:
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1390 for (i = 0; (*p)[i] && !isspace((*p)[i]) && (*p)[i] != '|' && (*p)[i] != '&'; i++)
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1391 /* do nothing */;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1392
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1393 pstr = lw_strndup(*p, i);
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1394 (*p) += i;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1395
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1396 pragma = parse_pragma_helper(pstr);
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1397 if (!pragma) lwasm_register_error(as, l, E_PRAGMA_UNRECOGNIZED);
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1398
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1399 lw_free(pstr);
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1400
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1401 if (pragma & PRAGMA_CLEARBIT)
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1402 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1403 pragma &= ~PRAGMA_CLEARBIT; /* strip off flag bit */
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1404 compare = l -> pragmas & pragma ? 0 : 1;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1405 }
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1406 else
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1407 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1408 compare = l -> pragmas & pragma;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1409 }
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1410
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1411 if (!compare)
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1412 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1413 if (**p == '|')
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1414 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1415 (*p)++;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1416 goto again;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1417 }
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1418 as -> skipcond = 1;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1419 as -> skipcount = 1;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1420 }
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1421 skip_operand(p);
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1422 }
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1423
0
2c24602be78f 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 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
1425 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1426 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
1427 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
1428 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1429
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1430 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
1431 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1432 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
1433 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
1434 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
1435 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1436
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1437 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
1438 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1439 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
1440 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
1441 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
1442 long flen;
224
3864d96ee8c7 Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents: 219
diff changeset
1443 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
1444
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1445 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
1446 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1447 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
1448 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
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
2c24602be78f 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 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
1452 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1453 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
1454 (*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
1455
63
74b82202d355 Make for condition clearer
lost@l-w.ca
parents: 62
diff changeset
1456 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
1457 /* 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
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 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
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 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
1462 /* 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
1463 }
2c24602be78f 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 fn = lw_strndup(*p, p2 - *p);
62
5b10ff307463 Fixed problem with filename handling in includebin
lost@l-w.ca
parents: 58
diff changeset
1465 *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
1466 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
1467 (*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
1468
224
3864d96ee8c7 Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents: 219
diff changeset
1469 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
1470 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
1471 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1472 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
1473 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
1474 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
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
224
3864d96ee8c7 Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents: 219
diff changeset
1477 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
1478
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1479 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
1480 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
1481 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
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 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
1484 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1485
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1486 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
1487 {
2c24602be78f 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 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
1489 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
1490
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
1491 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
1492 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
1493 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1494 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
1495 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
1496 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1497
2c24602be78f 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 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
1499 {
2c24602be78f 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 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
1501 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
1502 {
2c24602be78f 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 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
1504 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
1505 }
2c24602be78f 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 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
1507 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1508 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1509
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1510 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
1511 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1512 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
1513 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
1514 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
1515 int len;
41
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1516 char buf[110];
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1517
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1518 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
1519 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1520 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
1521 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
1522 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1523
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1524 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
1525 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1526 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
1527 (*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
1528
2c24602be78f 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 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
1530 /* 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
1531 }
2c24602be78f 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 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
1533 {
2c24602be78f 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 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
1535 /* 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
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 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
1538 (*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
1539 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
1540 (*p)++;
41
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1541
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1542 /* 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
1543 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
1544 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
1545
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
1546 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
1547 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
1548 sprintf(p3, "include:%s", fn);
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1549 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
1550 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
1551 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
1552
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1553 if (as -> fileerr == 0)
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1554 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
1555 l -> len = 0;
93
5bf9edabd661 Squashed the remaining memory leaks revealed by valgrind
lost@l-w.ca
parents: 88
diff changeset
1556 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
1557 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1558
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1559 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
1560 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1561 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
1562 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
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);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1565 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
1566 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1567
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1568 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
1569
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1570 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
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);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1573 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
1574 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1575
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1576 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
1577
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1578 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
1579 {
114
707eda49ad60 Fix parsing padding argument for align pseudo op
lost@l-w.ca
parents: 93
diff changeset
1580 (*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
1581 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
1582 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1583 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
1584 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1585 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
1586 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1587 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
1588 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1589 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
1590 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
1591 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1592
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1593 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
1594 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1595
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1596 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
1597 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1598 lw_expr_t e;
264
346966cffeef Clean up various warnings when building under -Wall
William Astle <lost@l-w.ca>
parents: 251
diff changeset
1599 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
1600 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
1601 int a;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1602
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1603 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
1604
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1605 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
1606 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1607 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
1608 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
1609 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1610 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
1611 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
1612 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1613 }
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1614 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
1615 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1616 return;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1617 }
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1618
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1619
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1620 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
1621 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
1622 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
1623 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
1624
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1625 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
1626 {
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1627 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
1628 }
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1629 else
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1630 {
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1631 a = -1;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1632 }
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1633 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
1634
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1635 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
1636 {
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1637 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
1638 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1639 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
1640 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
1641 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1642 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
1643 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
1644 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1645 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1646
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1647 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
1648 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1649 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
1650 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
1651
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1652 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
1653 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
1654 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
1655 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
1656 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1657 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
1658 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1659 }
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1660
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1661 PARSEFUNC(pseudo_parse_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1662 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1663 lw_expr_t e, e1;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1664 if (!**p)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1665 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1666 lwasm_register_error(as, l, E_OPERAND_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1667 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1668 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1669
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1670 e1 = lwasm_parse_expr(as, p);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1671 if (**p != ',')
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1672 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1673 lwasm_register_error(as, l, E_OPERAND_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1674 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1675 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1676 (*p)++;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1677 e = lwasm_parse_expr(as, p);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1678
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1679 if (!e)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1680 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1681 lwasm_register_error(as, l, E_OPERAND_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1682 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1683 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1684
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1685 lwasm_save_expr(l, 0, e);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1686 lwasm_save_expr(l, 1, e1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1687
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1688 if (!e1)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1689 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1690 lwasm_register_error(as, l, E_PADDING_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1691 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1692 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1693 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1694
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1695 RESOLVEFUNC(pseudo_resolve_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1696 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1697 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
1698 int align = 1;
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1699
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1700 e = lwasm_fetch_expr(l, 0);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1701
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1702 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
1703 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
1704 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
1705 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
1706
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1707 if (lw_expr_istype(te, lw_expr_type_int))
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1708 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1709 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
1710 if (align < 0)
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1711 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1712 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
1713 lwasm_register_error(as, l, E_FILL_INVALID);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1714 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1715 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1716 }
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1717 else
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1718 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1719 lw_expr_destroy(te);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1720 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1721 }
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1722 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
1723
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1724 l -> len = align;
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1725 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1726
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1727 EMITFUNC(pseudo_emit_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1728 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1729 lw_expr_t e;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1730 int i;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1731
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1732 /* 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
1733 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
1734 return;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1735
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1736 e = lwasm_fetch_expr(l, 1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1737 for (i = 0; i < l -> len; i++)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1738 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1739 lwasm_emitexpr(l, e, 1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1740 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1741 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1742
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1743 /* string conditional argument parser */
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 argument syntax:
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1746
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1747 a bare word ended by whitespace, comma, or NUL
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1748 a double quote delimited string containing arbitrary printable characters
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1749 a single quote delimited string containing arbitrary printable characters
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1750
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1751 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
1752 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
1753
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1754 */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1755 char *strcond_parsearg(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1756 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1757 char *arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1758 char *tstr;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1759 int i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1760 tstr = *p;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1761
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1762 if (!**p || isspace(**p))
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1763 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1764 return lw_strdup("");
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1765 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1766
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1767 if (*tstr == '"')
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1768 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1769 // double quote delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1770 tstr++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1771 for (i = 0; tstr[i] && tstr[i] != '"'; i++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1772 /* do nothing */ ;
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 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1775 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1776 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1777
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1778 if (tstr[i])
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1779 i++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1780
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1781 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1782 return arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1783 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1784 else if (*tstr == '\'')
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1785 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1786 // single quote delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1787 tstr++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1788 for (i = 0; tstr[i] && tstr[i] != '\''; i++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1789 /* do nothing */ ;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1790
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1791 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1792 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1793 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1794
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1795 if (tstr[i])
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1796 i++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1797
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1798 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1799 return arg;
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 else
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 // bare word - whitespace or comma delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1804 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
1805 /* do nothing */ ;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1806
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1807 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1808 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1809 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1810 if (tstr[i] == ',')
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1811 i++;
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 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1814 return arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1815 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1816 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1817
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1818 /* string conditional helpers */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1819 /* return "1" for true, "0" for false */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1820 int strcond_eq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1821 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1822 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1823 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1824 int c = 0;
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 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1827 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1828
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1829 if (strcmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1830 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1831 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1832 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1833 return c;
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
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1836 int strcond_ieq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1837 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1838 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1839 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1840 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1841
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1842 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1843 arg2 = strcond_parsearg(p);
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 (strcasecmp(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(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1848 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1849 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1850 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1851
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1852 int strcond_ne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1853 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1854 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1855 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1856 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1857
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1858 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1859 arg2 = strcond_parsearg(p);
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 if (strcmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1862 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1863 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1864 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1865 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1866 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1867
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1868 int strcond_ine(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1869 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1870 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1871 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1872 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1873
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1874 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1875 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1876
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1877 if (strcasecmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1878 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1879 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1880 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1881 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1882 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1883
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1884 int strcond_peq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1885 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1886 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1887 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1888 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1889 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1890 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1891
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1892 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1893 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1894 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1895
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1896 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1897 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1898 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1899 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1900 arg2[plen] = 0;
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 (strcmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1903 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1904 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1905 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1906 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1907 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1908 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1909
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1910 int strcond_ipeq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1911 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1912 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1913 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1914 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1915 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1916 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1917
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1918 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1919 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1920 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1921
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1922 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1923 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1924 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1925 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1926 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1927
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1928 if (strcasecmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1929 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1930 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1931 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1932 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1933 return c;
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
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1936 int strcond_pne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1937 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1938 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1939 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1940 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1941 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1942 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1943
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1944 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1945 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1946 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1947
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1948 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1949 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1950 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1951 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1952 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1953
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1954 if (strcmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1955 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1956 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1957 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1958 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1959 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1960 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1961
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1962 int strcond_ipne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1963 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1964 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1965 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1966 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1967 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1968 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1969
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1970 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1971 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1972 arg2 = strcond_parsearg(p);
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 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1975 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1976 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1977 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1978 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1979
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1980 if (strcasecmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1981 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1982 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1983 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1984 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1985 return c;
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
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1988 int strcond_seq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1989 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1990 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1991 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1992 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1993 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1994 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1995
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1996 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1997 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1998
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1999 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2000 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2001 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2002
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2003 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2004 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2005
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2006 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2007 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2008 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2009 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2010 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2011 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2012 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2013 rarg2 += strlen(arg2) - plen;
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 (strcmp(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 int strcond_iseq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2024 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2025 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2026 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2027 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2028 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2029 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2030
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
2031 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2032 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2033
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2034 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2035 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2036 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2037
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2038 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2039 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2040
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2041 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2042 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2043 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2044 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2045 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2046 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2047 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2048 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2049 }
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 (strcasecmp(rarg1, rarg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2052 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2053 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2054 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2055 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2056 return c;
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
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2059
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2060 int strcond_sne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2061 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2062 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2063 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2064 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2065 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2066 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2067
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
2068 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2069 int c = 0;
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 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2072 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2073 arg2 = strcond_parsearg(p);
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 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2076 rarg2 = arg2;
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 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2079 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2080 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2081 rarg1 += strlen(arg1) - plen;
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 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2084 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2085 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2086 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2087
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2088 if (strcmp(rarg1, rarg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2089 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2090 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2091 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2092 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2093 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2094 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2095
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2096 int strcond_isne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2097 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2098 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2099 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2100 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2101 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2102 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2103
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
2104 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2105 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2106
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2107 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2108 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2109 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2110
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2111 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2112 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2113
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2114 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2115 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2116 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2117 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2118 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2119 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2120 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2121 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2122 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2123
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2124 if (strcasecmp(rarg1, rarg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2125 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2126 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2127 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2128 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2129 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2130 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2131
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2132 /* string conditionals */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2133 PARSEFUNC(pseudo_parse_ifstr)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2134 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2135 static struct strconds
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2136 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2137 char *str;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2138 int (*fn)(char **ptr);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2139 } strops[] = {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2140 { "eq", strcond_eq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2141 { "ieq", strcond_ieq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2142 { "ne", strcond_ne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2143 { "ine", strcond_ine },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2144 { "peq", strcond_peq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2145 { "ipeq", strcond_ipeq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2146 { "pne", strcond_pne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2147 { "ipne", strcond_ipne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2148 { "seq", strcond_seq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2149 { "iseq", strcond_iseq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2150 { "sne", strcond_sne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2151 { "isne", strcond_isne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2152 { NULL, 0 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2153 };
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2154 int tv = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2155 char *tstr;
58
62372522ce9c Clean up warning about unused variable
lost@l-w.ca
parents: 55
diff changeset
2156 int strop;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2157
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2158 l -> len = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2159
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2160 if (as -> skipcond && !(as -> skipmacro))
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2161 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2162 as -> skipcount++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2163 skip_operand(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2164 return;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2165 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2166
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2167 tstr = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2168 if (!**p || isspace(**p))
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2169 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
2170 lwasm_register_error(as, l, E_STRING_BAD);
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2171 return;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2172 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2173
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2174 for (strop = 0; strops[strop].str != NULL; strop++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2175 if (strcasecmp(strops[strop].str, tstr) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2176 break;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2177
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2178 lw_free(tstr);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2179
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2180 if (strops[strop].str == NULL)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2181 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
2182 lwasm_register_error(as, l, E_STRING_BAD);
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2183 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2184
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2185 tv = (*(strops[strop].fn))(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2186
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2187 if (!tv)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2188 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2189 as -> skipcond = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2190 as -> skipcount = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2191 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2192 }