annotate lwasm/pseudo.c @ 519:724bcc4508bc

Add SETSTR/INCLUDESTR for some basic code building It seemed useful to have the ability to build up a variable containing arbitrary text and then to be able to include that in the assembly process like an include file. So add, undocumented for now, the following: SETTSTR varname="string" INCLUDESTSR "string" "string" must be enclosed in double quotes and may contain most of the usual escape sequences (\t, \r, etc.) as well as %(varname) to interpolate a variable value. To use it to create assembleable source code, you need to make sure it creates lines (ended by either \r or \n) with appropriate whitespace in appropriate places.
author William Astle <lost@l-w.ca>
date Sun, 19 Dec 2021 17:01:42 -0700
parents c33b4abff860
children 56c32bc798f8
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
443
999ae00d0919 Fix up execution address handling for ihex and srec output (lwasm)
William Astle <lost@l-w.ca>
parents: 432
diff changeset
105 if ((as -> output_format != OUTPUT_DECB) && (as -> output_format != OUTPUT_BASIC) && (as -> output_format != OUTPUT_LWMOD && (as -> output_format != OUTPUT_IHEX) && (as -> output_format != OUTPUT_SREC)))
0
2c24602be78f 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))
432
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
139 {
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
140 if (as -> output_format == OUTPUT_LWMOD)
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
141 {
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
142 as -> execaddr_expr = lw_expr_copy(addr);
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
143 }
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
144 else
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
145 {
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
146 lwasm_register_error(as, l, E_EXEC_ADDRESS);
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
147 }
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
148 }
0
2c24602be78f 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 else
432
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
150 {
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
151 as -> execaddr_expr = NULL;
0
2c24602be78f 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 as -> execaddr = lw_expr_intval(addr);
432
58cafa61ab40 Add support for undocumented custom module format (for LW)
William Astle <lost@l-w.ca>
parents: 406
diff changeset
153 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
154 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
155 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
156 }
2c24602be78f 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
2c24602be78f 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 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
159 {
2c24602be78f 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 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
161 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
162
2c24602be78f 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 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
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 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
166 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
167 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
168 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
169 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
170 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
171 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
172 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
173 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
174 (*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
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
2c24602be78f 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 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
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 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
181 {
2c24602be78f 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 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
183 lw_expr_t e;
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
184 // 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
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 (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
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_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
189 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
190 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
191 }
2c24602be78f 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
2c24602be78f 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 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
194 {
2c24602be78f 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 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
196 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
197
2c24602be78f 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 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
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 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
201 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
202 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
203 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
204 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
205 }
2c24602be78f 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 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
207 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
208 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
209 (*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
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
2c24602be78f 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 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
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 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
216 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
217 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
218 lw_expr_t e;
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
219 // 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
220
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
221 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
222 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
223 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
224 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
225 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
226 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
227
218
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
228 PARSEFUNC(pseudo_parse_fdbs)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
229 {
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
230 int i = 0;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
231 lw_expr_t e;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
232
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
233 for (;;)
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 e = lwasm_parse_expr(as, p);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
236 if (!e)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
237 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
238 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
239 break;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
240 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
241 lwasm_save_expr(l, i++, e);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
242 if (**p != ',')
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
243 break;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
244 (*p)++;
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
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
247 l -> len = i * 2;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
248 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
249
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
250 EMITFUNC(pseudo_emit_fdbs)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
251 {
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
252 int i;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
253 lw_expr_t e;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
254 lw_expr_t t;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
255 lw_expr_t t2;
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
256 // int v;
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 for (i = 0; i < (l -> len)/2; i++)
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
259 {
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
260 e = lwasm_fetch_expr(l, i);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
261 t = lw_expr_build(lw_expr_type_int, 256);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
262 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
263 lwasm_reduce_expr(as, t2);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
264 lw_expr_destroy(t);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
265 lwasm_emitexpr(l, e, 1);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
266 lwasm_emitexpr(l, t2, 1);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
267 lw_expr_destroy(t2);
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
268 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
269 }
b0c9df865b25 Add FDBS pseudo op.
William Astle <lost@l-w.ca>
parents: 217
diff changeset
270
0
2c24602be78f 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 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
272 {
2c24602be78f 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 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
274 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
275
2c24602be78f 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 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
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 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
279 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
280 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
281 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
282 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
283 }
2c24602be78f 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 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
285 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
286 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
287 (*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
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
2c24602be78f 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 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
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 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
294 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
295 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
296 lw_expr_t e;
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
297 // 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
298
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
299 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
300 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
301 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
302 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
303 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
304 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
305
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
306 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
307 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
308 int l = 0;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
309 char *str = NULL;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
310 int blen = 0;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
311 int bsize = 0;
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 if (!(as -> pragmas & PRAGMA_CESCAPES))
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
314 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
315 for (; **p && **p != delim; (*p)++)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
316 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
317 l++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
318 if (blen >= bsize)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
319 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
320 str = lw_realloc(str, bsize + 32);
393
f2decd9b276d Fix minor error in string parsing
William Astle <lost@l-w.ca>
parents: 384
diff changeset
321 bsize += 32;
75
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 str[blen++] = **p;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
324 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
325 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
326 else
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
327 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
328 while (**p && **p != delim)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
329 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
330 int wch = **p;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
331 if (**p == '\\')
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
332 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
333 /* escape sequence */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
334
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
335 (*p)++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
336 if (!**p)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
337 break;
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
338
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
339 switch (**p)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
340 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
341 /* octal sequence or NUL */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
342 /* skip the "0", then skip up to two more digits */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
343 case '0':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
344 case '1':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
345 case '2':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
346 case '3':
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
347 wch = **p;
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
348 wch -= 0x30;
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
349 if ((*p)[1] >= '0' && (*p)[1] < '8')
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
350 {
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
351 (*p)++;
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
352 wch *= 8;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
353 wch += **p - 0x30;
76
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
354 }
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
355 if ((*p)[1] >= '0' && (*p)[1] < '8')
da74ccf4278c Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents: 75
diff changeset
356 {
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
357 (*p)++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
358 wch *= 8;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
359 wch += **p -0x30;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
360 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
361 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
362
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
363 /* hexadecimal value */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
364 case 'x':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
365 (*p)++; // ignore "x"
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
366 wch = 0;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
367 if (**p) // skip digit 1
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
368 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
369 wch = **p - 0x30;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
370 if (wch > 9)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
371 wch -= 7;
516
c33b4abff860 Fix bug related to parsing \x sequences under pragma cstrings
William Astle <lost@l-w.ca>
parents: 474
diff changeset
372 if (wch > 15)
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
373 wch -= 32;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
374 (*p)++;
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 if (**p)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
377 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
378 int i;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
379 i = **p - 0x30;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
380 if (i > 9)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
381 i -= 7;
516
c33b4abff860 Fix bug related to parsing \x sequences under pragma cstrings
William Astle <lost@l-w.ca>
parents: 474
diff changeset
382 if (i > 15)
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
383 i -= 32;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
384 wch = wch * 16 + i;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
385 }
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 'a':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
389 wch = 7;
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 'b':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
393 wch = 8;
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 't':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
397 wch = 9;
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 'n':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
401 wch = 10;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
402 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
403
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
404 case 'v':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
405 wch = 11;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
406 break;
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 case 'f':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
409 wch = 12;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
410 break;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
411
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
412 case 'r':
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
413 wch = 13;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
414
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
415 /* everything else represents itself */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
416 default:
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
417 break;
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 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
420 /* now "wch" is the character to write out */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
421 l++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
422 (*p)++;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
423 if (blen >= bsize)
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
424 {
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
425 str = lw_realloc(str, bsize + 32);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
426 bsize += 32;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
427 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
428 str[blen++] = wch;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
429 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
430 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
431 /* do something with the string here */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
432 /* l is the string length, str is the string itself */
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
433 ln -> lstr = str;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
434 return l;
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
435 }
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
436
0
2c24602be78f 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 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
438 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
439 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
440 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
441
2c24602be78f 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 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
443 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
444 lwasm_register_error(as, l, E_OPERAND_BAD);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
445 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
446 }
2c24602be78f 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
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
448 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
449 (*p)++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
450
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
451 i = cstringlen(as, l, p, delim);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
452
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
453 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
454 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
455 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
456 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
457 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
458 (*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
459 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
460
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
461 /* 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
462 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
463 {
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
464 if (**p == ',')
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
465 {
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
466 (*p)++;
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
467 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
468 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
469 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
470 }
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
471 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
472 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
473
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
474 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
475 {
2c24602be78f 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 int i;
381
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
477 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
478
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
479 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
480 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
481
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
482 /* PRAGMA_M80EXT */
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
483 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
484 {
e3f4aaa2a4e8 Allow FCB-like syntax after constant in FCC under m80ext
William Astle <lost@l-w.ca>
parents: 379
diff changeset
485 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
486 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
487 }
0
2c24602be78f 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
2c24602be78f 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 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
491 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
492 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
493 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
494
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
495 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
496 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
497 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
498 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
499 }
2c24602be78f 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
2c24602be78f 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 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
502 (*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
503
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
504 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
505
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
506 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
507 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
508 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
509 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
510 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
511 (*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
512 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
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
2c24602be78f 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 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
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 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
518
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
519 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
520 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
521 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
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
2c24602be78f 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 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
525 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
526 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
527 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
528
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
529 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
530 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
531 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
532 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
533 }
2c24602be78f 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
2c24602be78f 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 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
536 (*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
537
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
538 i = cstringlen(as, l, p, delim);
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
539
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
540 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
541 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
542 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
543 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
544 }
75
3d50022e16e7 Restored pragma cescapes functionality
lost@l-w.ca
parents: 63
diff changeset
545 (*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
546 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
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
2c24602be78f 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 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
550 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
551 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
552
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
553 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
554 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
555 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
556 }
2c24602be78f 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
2c24602be78f 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 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
559 {
2c24602be78f 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 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
561
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
562 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
563 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
564 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
565 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
566 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
567
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
568 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
569 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
570 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
571 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
572 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
573 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
574 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
575 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
576 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
577 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
578 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
579 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
580 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
581 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
582 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
583 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
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 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
586 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
587 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
588 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
589 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
590 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
591 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
592 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
593 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
594 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
595 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
596
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
597 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
598 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
599 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
600
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
601 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
602 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
603
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
604 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
605 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
606 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
607 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
608 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
609 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
610 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
611 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
612 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
613 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
614
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
615 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
616
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
617 if (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
618 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
619 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
620 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
621 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
622 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
623 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
624 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
625 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
626 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
627 l -> dlen = lw_expr_intval(expr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
628 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
629 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
630 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
631 }
2c24602be78f 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
2c24602be78f 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 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
634 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
635 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
636 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
637
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
638 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
639 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
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
2c24602be78f 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 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
643 {
2c24602be78f 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 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
645
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
646 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
647 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
648 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
649 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
650 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
651 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
652
2c24602be78f 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 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
654 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
655 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
656 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
657 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
658 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
659 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
660 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
661 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
662 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
663 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
664 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
665 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
666 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
667 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
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 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
670 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
671 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
672 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
673 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
674 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
675 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
676 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
677 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
678 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
679 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
680
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
681 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
682 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
683 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
684
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
685 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
686 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
687
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
688 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
689 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
690 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
691 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
692 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
693 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
694 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
695 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
696 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
697 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
698
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
699 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
700
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
701 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
702 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
703 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
704 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
705 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
706 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
707 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
708 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
709 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
710 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
711 l -> dlen = lw_expr_intval(expr) * 2;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
712 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
713 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
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 }
2c24602be78f 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 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
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 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
720 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
721
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
722 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
723 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
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
2c24602be78f 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 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
728 {
2c24602be78f 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 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
730
2c24602be78f 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 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
732 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
733 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
734 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
735 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
736 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
737 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
738 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
739 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
740 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
741 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
742 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
743 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
744 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
745 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
746 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
747 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
748 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
749 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
750 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
751 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
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 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
754 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
755 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
756 if (as -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
757 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
758 l -> dlen = -1;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
759 l -> len = 0;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
760 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
761 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
762 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
763 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
764
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
765 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
766 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
767 lw_expr_t expr;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
768
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
769 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
770 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
771
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
772 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
773 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
774 if (l -> dlen >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
775 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
776 }
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
777 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
778 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
779 if (l -> len >= 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
780 return;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
781 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
782
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
783 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
784
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
785 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
786 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
787 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
788 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
789 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
790 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
791 l -> dlen = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
792 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
793 }
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
794 if (l -> inmod)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
795 l -> dlen = lw_expr_intval(expr) * 4;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
796 else
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
797 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
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 }
2c24602be78f 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 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
802 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
803 if (l -> 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
804 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
805
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
806 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
807 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
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
2c24602be78f 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 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
812 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
813 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
814
2c24602be78f 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 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
816 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
817 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
818 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
819 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
820
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
821 lwasm_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
822 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
823
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
824 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
825 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
826 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
827
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
828 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
829 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
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 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
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 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
834 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
835 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
836 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
837 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
838 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
839 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
840 }
0
2c24602be78f 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 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
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 }
2c24602be78f 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
2c24602be78f 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 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
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 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
848
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
849 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
850 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
851 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
852 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
853 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
854
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
855 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
856 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
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
2c24602be78f 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 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
861 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
862 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
863
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
864 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
865 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
866 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
867 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
868 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
869
2c24602be78f 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 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
871 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
872
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
873 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
874 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
875 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
876
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
877 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
878 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
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 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
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 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
883 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
884 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
885 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
886 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
887 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
888 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
889 }
0
2c24602be78f 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 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
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 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
893
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
894 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
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 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
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 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
899 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
900 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
901 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
902 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
903
2c24602be78f 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 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
905 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
906 }
2c24602be78f 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 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
909 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
910 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
911
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
912 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
913 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
914 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
915 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
916 }
2c24602be78f 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 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
919 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
920
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
921 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
922 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
923 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
924
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
925 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
926 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
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 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
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 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
931 {
159
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
932 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
933 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
934 lwasm_register_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
935 l -> len = 0;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
936 return;
8967eb907324 Trap negative sizes for [rz]m[bdq] and flag error
lost@l-w.ca
parents: 147
diff changeset
937 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
938 l -> len = 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
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 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
941
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
942 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
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 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
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 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
947 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
948 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
949 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
950 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
951
2c24602be78f 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 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
953 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
954 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
955
2c24602be78f 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 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
957 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
958 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
959
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
960 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
961
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
962 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
963 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
964 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
965 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
966 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
967 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
968
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
969 lw_expr_destroy(l -> daddr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
970 l -> daddr = e;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
971
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
972 if (l -> inmod == 0)
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
973 {
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
974 lw_expr_destroy(l -> addr);
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
975 l -> addr = e;
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 135
diff changeset
976 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
977 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
978 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
979
382
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
980 PARSEFUNC(pseudo_parse_reorg)
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
981 {
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
982 lw_expr_t e = NULL;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
983
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
984 l -> len = 0;
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 line_t *cl = l;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
987 for (cl = cl -> prev; cl; cl = cl -> prev)
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 (cl -> insn == -1) continue;
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 if (!strcmp("org", instab[cl -> insn].opcode))
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
992 {
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
993 if (cl -> prev)
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 e = lw_expr_copy(cl -> prev -> daddr);
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
996 break;
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 }
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
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1001 if (!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 lwasm_register_error(as, l, E_ORG_NOT_FOUND);
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1004 return;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1005 }
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1006
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1007 lw_expr_destroy(l -> daddr);
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1008 l -> daddr = e;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1009
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1010 if (l -> inmod == 0)
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1011 {
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1012 lw_expr_destroy(l -> addr);
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1013 l -> addr = e;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1014 }
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1015 l -> len = 0;
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1016 }
80d615a6642c Add REORG pseudo op
William Astle <lost@l-w.ca>
parents: 381
diff changeset
1017
0
2c24602be78f 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 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
1019 {
2c24602be78f 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 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
1021
2c24602be78f 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 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
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 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
1025 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1026 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
1027 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
1028 }
2c24602be78f 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 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
1031 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
1032 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1033 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
1034 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
1035 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1036
2c24602be78f 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 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
1038 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
1039 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
1040 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
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 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
1044 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1045 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
1046
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1047 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
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 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
1050 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1051 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
1052 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
1053 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1054
2c24602be78f 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 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
1056 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
1057 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1058 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
1059 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
1060 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1061
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1062 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
1063 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
1064 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
1065 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
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 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
1069 {
2c24602be78f 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 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
1071
2c24602be78f 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 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
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 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
1075 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1076 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
1077 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
1078 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1079
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1080 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
1081 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
1082 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1083 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
1084 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
1085 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1086
38
7e92484cfbc3 Caused expressions used in setdp and conditionals to be reduced on pass 1
lost@l-w.ca
parents: 10
diff changeset
1087 // 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
1088 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
1089 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
1090 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1091 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
1092 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
1093 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
1094 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1095 l -> dpval = lw_expr_intval(e) & 0xff;
88
1a1fdfe860d0 Fixed several memory leaks revealed by valgrind
lost@l-w.ca
parents: 84
diff changeset
1096 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
1097 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
1098 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
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
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1101 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1104 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1105 l -> hidecond = 1;
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1106
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1107 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
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 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
1110 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
1111 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
1112 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1113
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1114 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
1115 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1116
2c24602be78f 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 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1120 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1121 l -> hidecond = 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
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 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
1124 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1125 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
1126 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
1127 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
1128 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1129
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1130 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
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 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
1134 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1135 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
1136
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1137 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1138 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1139 l -> hidecond = 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
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 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
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 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
1144 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
1145 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
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
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1148 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
1149 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1150 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
1151 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
1152 {
2c24602be78f 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 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
1154 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
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
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1158 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
1159 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1160 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1163 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1164 l -> hidecond = 1;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1165
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1166 if (as -> skipcond && !(as -> skipmacro))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1167 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1168 as -> skipcount++;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1169 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1170 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1171 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1172
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1173 e = lwasm_parse_cond(as, p);
208
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1174 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1175 lwasm_reduce_expr(as, e);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1176 if (e && lw_expr_intval(e) == 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1177 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1178 as -> skipcond = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1179 as -> skipcount = 1;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1180 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1181 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1182
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1183
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1184 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
1185 {
2c24602be78f 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 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
1187
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1188 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1189 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1190 l -> hidecond = 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
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 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
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 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
1195 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
1196 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
1197 }
2c24602be78f 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 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
1200 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1201 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
1202 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
1203 {
2c24602be78f 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 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
1205 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
1206 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1207 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1208
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1209 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
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 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
1212
2c24602be78f 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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1214 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1215 l -> hidecond = 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
1216
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1217 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
1218 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1219 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
1220 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
1221 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
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
2c24602be78f 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 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
1225 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1226 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
1227 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
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 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
1230 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
1231 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1232 }
2c24602be78f 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
2c24602be78f 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 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
1235 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1236 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1239 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1240 l -> hidecond = 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
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 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
1243 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1244 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
1245 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
1246 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
1247 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1248
2c24602be78f 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 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
1250 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1251 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
1252 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
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 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
1255 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
1256 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1257 }
2c24602be78f 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 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
1260 {
2c24602be78f 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 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
1262
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1263 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1264 l -> hidecond = 1;
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1265
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1266 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
1267
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1268 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
1269 {
2c24602be78f 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 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
1271 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
1272 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
1273 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1274
2c24602be78f 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 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
1276 if (e)
fa835b780ffb Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents: 186
diff changeset
1277 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
1278 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
1279 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1280 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
1281 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
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 }
2c24602be78f 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
2c24602be78f 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 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
1286 {
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1287 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1288 l -> hidecond = 1;
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1289
0
2c24602be78f 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 l -> len = 0;
145
d6e9cc4484f6 Fixed ENDC to work with comments after it
lost@l-w.ca
parents: 142
diff changeset
1291 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
1292 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
1293 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1294 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
1295 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
1296 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
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
2c24602be78f 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 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
1301 {
2c24602be78f 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 l -> len = 0;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1303 l -> hidecond = 1;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1304 l -> hideline = 1;
217
f87c86668d6b Fix handling of comments on ELSE lines
William Astle <lost@l-w.ca>
parents: 208
diff changeset
1305 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
1306
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1307 if (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
1308 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
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 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
1311 {
2c24602be78f 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 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
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 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
1315 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
1316 }
2c24602be78f 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 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
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 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
1320 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
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
2c24602be78f 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 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
1324 {
2c24602be78f 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 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
1326 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
1327 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
1328
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1329 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1330 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1331 l -> hidecond = 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
1332
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1333 if (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
1334 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1335 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
1336 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
1337 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1338 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1339
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1340 again:
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1341 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
1342 /* 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
1343
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1344 sym = lw_strndup(*p, i);
84
16a72d9b6eb6 Make ifdef work correctly
lost@l-w.ca
parents: 76
diff changeset
1345 (*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
1346
2c24602be78f 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 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
1348
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1349 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
1350
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1351 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
1352 {
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1353 if (**p == '|')
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1354 {
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1355 (*p)++;
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1356 goto again;
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1357 }
0
2c24602be78f 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 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
1359 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
1360 }
133
3c1a80c2fb95 ifdef sym1|sym2 now works
lost@l-w.ca
parents: 132
diff changeset
1361 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
1362 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1363
2c24602be78f 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 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
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 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
1367 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
1368 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
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 l -> len = 0;
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1371 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1372 l -> hidecond = 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
1373
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1374 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
1375 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1376 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
1377 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
1378 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
1379 }
132
4cf44ff89b08 Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents: 114
diff changeset
1380 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
1381 /* 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
1382
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1383 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
1384 (*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
1385
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1386 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
1387
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1388 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
1389
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1390 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
1391 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1392 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
1393 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
1394 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
1395 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1396 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1397
384
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1398 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
1399 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1400 char *pstr;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1401 int i;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1402 int pragma;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1403 int compare;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1404
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1405 l -> len = 0;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1406 l -> hideline = 1;
474
74d0c394666e Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents: 443
diff changeset
1407 l -> hidecond = 1;
384
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1408
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1409 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
1410 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1411 as -> skipcount++;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1412 skip_operand(p);
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1413 return;
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
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1416 again:
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1417 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
1418 /* do nothing */;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1419
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1420 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
1421 (*p) += i;
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 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
1424 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
1425
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1426 lw_free(pstr);
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1427
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1428 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
1429 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1430 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
1431 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
1432 }
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1433 else
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1434 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1435 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
1436 }
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1437
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1438 if (!compare)
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1439 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1440 if (**p == '|')
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1441 {
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1442 (*p)++;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1443 goto again;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1444 }
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1445 as -> skipcond = 1;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1446 as -> skipcount = 1;
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1447 }
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1448 skip_operand(p);
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1449 }
6ee9c67a0f8d Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents: 382
diff changeset
1450
0
2c24602be78f 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 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
1452 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1453 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
1454 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
1455 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1456
2c24602be78f 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 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
1458 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1459 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
1460 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
1461 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
1462 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1463
2c24602be78f 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 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
1465 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1466 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
1467 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
1468 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
1469 long flen;
224
3864d96ee8c7 Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents: 219
diff changeset
1470 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
1471
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1472 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
1473 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1474 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
1475 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
1476 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1477
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1478 if (**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
1479 {
2c24602be78f 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 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
1481 (*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
1482
63
74b82202d355 Make for condition clearer
lost@l-w.ca
parents: 62
diff changeset
1483 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
1484 /* 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
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 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
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 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
1489 /* 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
1490 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1491 fn = lw_strndup(*p, p2 - *p);
62
5b10ff307463 Fixed problem with filename handling in includebin
lost@l-w.ca
parents: 58
diff changeset
1492 *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
1493 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
1494 (*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
1495
224
3864d96ee8c7 Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents: 219
diff changeset
1496 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
1497 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
1498 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1499 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
1500 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
1501 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
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
224
3864d96ee8c7 Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents: 219
diff changeset
1504 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
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 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
1507 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
1508 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
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 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
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
2c24602be78f 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 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
1514 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1515 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
1516 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
1517
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
1518 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
1519 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
1520 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1521 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
1522 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
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
2c24602be78f 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 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
1526 {
2c24602be78f 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 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
1528 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
1529 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1530 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
1531 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1532 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1533 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
1534 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1535 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1536
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1537 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
1538 {
2c24602be78f 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 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
1540 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
1541 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
1542 int len;
41
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1543 char buf[110];
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1544
0
2c24602be78f 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 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
1546 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1547 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
1548 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
1549 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1550
2c24602be78f 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 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
1552 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1553 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
1554 (*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
1555
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1556 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
1557 /* 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
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 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
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 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
1562 /* 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
1563 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1564 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
1565 (*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
1566 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
1567 (*p)++;
41
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1568
c6b8b455d67f Fix line number sequence after including a file
lost@l-w.ca
parents: 38
diff changeset
1569 /* 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
1570 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
1571 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
1572
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
1573 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
1574 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
1575 sprintf(p3, "include:%s", fn);
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1576 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
1577 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
1578 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
1579
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1580 if (as -> fileerr == 0)
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 218
diff changeset
1581 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
1582 l -> len = 0;
93
5bf9edabd661 Squashed the remaining memory leaks revealed by valgrind
lost@l-w.ca
parents: 88
diff changeset
1583 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
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
519
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1586 PARSEFUNC(pseudo_parse_includestr)
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1587 {
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1588 char *str;
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1589 char buf[110];
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1590
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1591 l -> len = 0;
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1592
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1593 if (!**p)
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1594 {
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1595 // no operand - include nothing
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1596 return;
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1597 }
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1598
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1599 str = lwasm_parse_general_string(l, p);
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1600 if (!str)
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1601 {
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1602 // string parsing failed
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1603 return;
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1604 }
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1605 if (*str == '\0')
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1606 {
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1607 // empty string; don't do anything
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1608 lw_free(str);
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1609 return;
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1610 }
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1611
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1612 /* add a book-keeping entry for line numbers */
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1613 snprintf(buf, 100, "\001\001SETLINENO %d\n", l -> lineno + 1);
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1614 input_openstring(as, "INTERNAL", buf);
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1615
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1616 /* add the constructed string to the input */
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1617 input_openstring(as, "INCLUDESTR", str);
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1618 lw_free(str);
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1619 }
724bcc4508bc Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents: 516
diff changeset
1620
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1621 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
1622 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1623 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
1624 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
1625 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1626 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
1627 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
1628 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1629
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1630 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
1631
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1632 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
1633 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1634 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
1635 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
1636 }
2c24602be78f 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
2c24602be78f 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 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
1639
2c24602be78f 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 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
1641 {
114
707eda49ad60 Fix parsing padding argument for align pseudo op
lost@l-w.ca
parents: 93
diff changeset
1642 (*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
1643 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
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 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
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 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
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 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
1650 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1651 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
1652 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
1653 }
2c24602be78f 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
2c24602be78f 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 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
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
2c24602be78f 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 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
1659 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1660 lw_expr_t e;
264
346966cffeef Clean up various warnings when building under -Wall
William Astle <lost@l-w.ca>
parents: 251
diff changeset
1661 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
1662 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
1663 int a;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1664
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1665 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
1666
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1667 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
1668 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1669 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
1670 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
1671 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1672 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
1673 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
1674 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1675 }
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1676 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
1677 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1678 return;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1679 }
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1680
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1681
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1682 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
1683 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
1684 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
1685 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
1686
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1687 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
1688 {
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1689 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
1690 }
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1691 else
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1692 {
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1693 a = -1;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1694 }
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1695 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
1696
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1697 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
1698 {
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1699 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
1700 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1701 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
1702 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
1703 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1704 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
1705 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
1706 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1707 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1708
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1709 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
1710 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1711 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
1712 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
1713
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1714 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
1715 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
1716 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
1717 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
1718 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1719 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
1720 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1721 }
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1722
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1723 PARSEFUNC(pseudo_parse_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1724 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1725 lw_expr_t e, e1;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1726 if (!**p)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1727 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1728 lwasm_register_error(as, l, E_OPERAND_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1729 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1730 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1731
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1732 e1 = lwasm_parse_expr(as, p);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1733 if (**p != ',')
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1734 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1735 lwasm_register_error(as, l, E_OPERAND_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1736 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1737 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1738 (*p)++;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1739 e = lwasm_parse_expr(as, p);
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 if (!e)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1742 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1743 lwasm_register_error(as, l, E_OPERAND_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1744 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1745 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1746
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1747 lwasm_save_expr(l, 0, e);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1748 lwasm_save_expr(l, 1, e1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1749
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1750 if (!e1)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1751 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
1752 lwasm_register_error(as, l, E_PADDING_BAD);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1753 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1754 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1755 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1756
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1757 RESOLVEFUNC(pseudo_resolve_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1758 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1759 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
1760 int align = 1;
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1761
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1762 e = lwasm_fetch_expr(l, 0);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1763
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1764 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
1765 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
1766 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
1767 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
1768
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1769 if (lw_expr_istype(te, lw_expr_type_int))
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1770 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1771 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
1772 if (align < 0)
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1773 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1774 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
1775 lwasm_register_error(as, l, E_FILL_INVALID);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1776 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1777 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1778 }
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1779 else
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1780 {
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1781 lw_expr_destroy(te);
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1782 return;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1783 }
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1784 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
1785
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1786 l -> len = align;
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1787 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1788
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1789 EMITFUNC(pseudo_emit_fill)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1790 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1791 lw_expr_t e;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1792 int i;
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1793
266
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1794 /* 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
1795 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
1796 return;
35c051bffbff Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents: 264
diff changeset
1797
186
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1798 e = lwasm_fetch_expr(l, 1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1799 for (i = 0; i < l -> len; i++)
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1800 {
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1801 lwasm_emitexpr(l, e, 1);
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1802 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1803 }
1824cabf25ce Various enhancements to lwasm
lost@l-w.ca
parents: 162
diff changeset
1804
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1805 /* string conditional argument parser */
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 argument syntax:
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1808
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1809 a bare word ended by whitespace, comma, or NUL
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1810 a double quote delimited string containing arbitrary printable characters
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1811 a single quote delimited string containing arbitrary printable characters
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 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
1814 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
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 char *strcond_parsearg(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1818 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1819 char *arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1820 char *tstr;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1821 int i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1822 tstr = *p;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1823
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1824 if (!**p || isspace(**p))
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 return lw_strdup("");
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1827 }
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 (*tstr == '"')
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1830 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1831 // double quote delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1832 tstr++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1833 for (i = 0; tstr[i] && tstr[i] != '"'; i++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1834 /* do nothing */ ;
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 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1837 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1838 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1839
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1840 if (tstr[i])
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1841 i++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1842
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1843 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1844 return arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1845 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1846 else if (*tstr == '\'')
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1847 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1848 // single quote delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1849 tstr++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1850 for (i = 0; tstr[i] && tstr[i] != '\''; i++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1851 /* do nothing */ ;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1852
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1853 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1854 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1855 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1856
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1857 if (tstr[i])
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1858 i++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1859
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1860 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1861 return arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1862 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1863 else
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1864 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1865 // bare word - whitespace or comma delim
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1866 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
1867 /* do nothing */ ;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1868
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1869 arg = lw_alloc(i + 1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1870 strncpy(arg, tstr, i);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1871 arg[i] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1872 if (tstr[i] == ',')
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1873 i++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1874
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1875 *p += i;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1876 return arg;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1877 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1878 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1879
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1880 /* string conditional helpers */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1881 /* return "1" for true, "0" for false */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1882 int strcond_eq(char **p)
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 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1885 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1886 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1887
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1888 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1889 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1890
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1891 if (strcmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1892 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1893 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1894 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1895 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1896 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1897
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1898 int strcond_ieq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1899 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1900 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1901 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1902 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1903
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1904 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1905 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1906
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1907 if (strcasecmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1908 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1909 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1910 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1911 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1912 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1913
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1914 int strcond_ne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1915 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1916 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1917 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1918 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1919
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1920 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1921 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1922
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1923 if (strcmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1924 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1925 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1926 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1927 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1928 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1929
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1930 int strcond_ine(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1931 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1932 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1933 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1934 int c = 0;
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 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1937 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1938
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1939 if (strcasecmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1940 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1941 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1942 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1943 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1944 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1945
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1946 int strcond_peq(char **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 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1949 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1950 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1951 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1952 int c = 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 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1955 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1956 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1957
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1958 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1959 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1960 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1961 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1962 arg2[plen] = 0;
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 if (strcmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1965 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1966 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1967 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1968 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1969 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1970 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1971
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1972 int strcond_ipeq(char **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 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1975 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1976 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
1977 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1978 int c = 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 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1981 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1982 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1983
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1984 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1985 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1986 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1987 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1988 arg2[plen] = 0;
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 if (strcasecmp(arg1, arg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1991 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1992 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1993 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1994 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1995 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1996 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1997
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1998 int strcond_pne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
1999 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2000 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2001 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2002 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
2003 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2004 int c = 0;
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 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2007 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2008 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2009
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2010 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2011 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2012 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2013 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2014 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2015
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2016 if (strcmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2017 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2018 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2019 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2020 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2021 return c;
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
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2024 int strcond_ipne(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2025 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2026 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2027 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2028 char *arg2;
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
2029 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2030 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2031
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2032 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2033 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2034 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2035
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2036 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2037 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2038 arg1[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2039 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2040 arg2[plen] = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2041
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2042 if (strcasecmp(arg1, arg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2043 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2044 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2045 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2046 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2047 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2048 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2049
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2050 int strcond_seq(char **p)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2051 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2052 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2053 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2054 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2055 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2056 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2057
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
2058 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2059 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2060
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2061 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2062 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2063 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2064
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2065 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2066 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2067
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2068 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2069 if (strlen(arg1) > plen)
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 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2072 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2073 if (strlen(arg2) > plen)
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 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2076 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2077 if (strcmp(rarg1, rarg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2078 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2079 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2080 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2081 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2082 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2083 }
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 int strcond_iseq(char **p)
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 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2088 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2089 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2090 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2091 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2092
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
2093 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2094 int c = 0;
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 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2097 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2098 arg2 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2099
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2100 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2101 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2102
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2103 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2104 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2105 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2106 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2107 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2108 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2109 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2110 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2111 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2112
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2113 if (strcasecmp(rarg1, rarg2) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2114 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2115 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2116 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2117 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2118 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2119 }
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
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2122 int strcond_sne(char **p)
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 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2125 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2126 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2127 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2128 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2129
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
2130 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2131 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2132
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2133 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2134 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2135 arg2 = strcond_parsearg(p);
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 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2138 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2139
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2140 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2141 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2142 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2143 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2144 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2145 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2146 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2147 rarg2 += strlen(arg2) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2148 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2149
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2150 if (strcmp(rarg1, rarg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2151 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2152 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2153 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2154 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2155 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2156 }
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 int strcond_isne(char **p)
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 char *arg0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2161 char *arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2162 char *arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2163 char *rarg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2164 char *rarg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2165
359
f318407d2469 Fix some signedness mismatches
William Astle <lost@l-w.ca>
parents: 349
diff changeset
2166 size_t plen;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2167 int c = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2168
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2169 arg0 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2170 arg1 = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2171 arg2 = strcond_parsearg(p);
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 rarg1 = arg1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2174 rarg2 = arg2;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2175
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2176 plen = strtol(arg0, NULL, 10);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2177 if (strlen(arg1) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2178 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2179 rarg1 += strlen(arg1) - plen;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2180 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2181 if (strlen(arg2) > plen)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2182 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2183 rarg2 += strlen(arg2) - plen;
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
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2186 if (strcasecmp(rarg1, rarg2) != 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2187 c = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2188 lw_free(arg0);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2189 lw_free(arg1);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2190 lw_free(arg2);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2191 return c;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2192 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2193
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2194 /* string conditionals */
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2195 PARSEFUNC(pseudo_parse_ifstr)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2196 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2197 static struct strconds
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2198 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2199 char *str;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2200 int (*fn)(char **ptr);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2201 } strops[] = {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2202 { "eq", strcond_eq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2203 { "ieq", strcond_ieq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2204 { "ne", strcond_ne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2205 { "ine", strcond_ine },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2206 { "peq", strcond_peq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2207 { "ipeq", strcond_ipeq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2208 { "pne", strcond_pne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2209 { "ipne", strcond_ipne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2210 { "seq", strcond_seq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2211 { "iseq", strcond_iseq },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2212 { "sne", strcond_sne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2213 { "isne", strcond_isne },
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2214 { NULL, 0 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2215 };
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2216 int tv = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2217 char *tstr;
58
62372522ce9c Clean up warning about unused variable
lost@l-w.ca
parents: 55
diff changeset
2218 int strop;
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2219
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2220 l -> len = 0;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2221
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2222 if (as -> skipcond && !(as -> skipmacro))
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2223 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2224 as -> skipcount++;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2225 skip_operand(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2226 return;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2227 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2228
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2229 tstr = strcond_parsearg(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2230 if (!**p || isspace(**p))
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2231 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
2232 lwasm_register_error(as, l, E_STRING_BAD);
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2233 return;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2234 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2235
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2236 for (strop = 0; strops[strop].str != NULL; strop++)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2237 if (strcasecmp(strops[strop].str, tstr) == 0)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2238 break;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2239
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2240 lw_free(tstr);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2241
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2242 if (strops[strop].str == NULL)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2243 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 359
diff changeset
2244 lwasm_register_error(as, l, E_STRING_BAD);
55
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2245 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2246
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2247 tv = (*(strops[strop].fn))(p);
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2248
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2249 if (!tv)
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2250 {
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2251 as -> skipcond = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2252 as -> skipcount = 1;
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2253 }
bad2ee25acdd Added string comparison pseudo ops
lost@l-w.ca
parents: 41
diff changeset
2254 }