Mercurial > hg > index.cgi
annotate lwasm/pseudo.c @ 559:ddc7b05a5675
Add --no-warn=ifp1 flag to suppress warnings about ifp1 and ipf2
author | William Astle <lost@l-w.ca> |
---|---|
date | Thu, 21 Sep 2023 13:13:23 -0600 |
parents | e10618b48e68 |
children | a6a9d46f071f |
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 | 22 #include "lwasm.h" |
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 | 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 | 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 | 45 skip_operand(p); |
46 l -> len = 0; | |
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 | 53 if (*t == '\n') |
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 | 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 | 61 EMITFUNC(pseudo_emit_dts) |
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 | 68 } |
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 | 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 |
543
e10618b48e68
Implement support for dragon format binaries
William Astle <lost@l-w.ca>
parents:
521
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) && (as -> output_format != OUTPUT_DRAGON) && (as -> output_format != OUTPUT_ABS)) |
0
2c24602be78f
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 | 228 PARSEFUNC(pseudo_parse_fdbs) |
229 { | |
230 int i = 0; | |
231 lw_expr_t e; | |
232 | |
233 for (;;) | |
234 { | |
235 e = lwasm_parse_expr(as, p); | |
236 if (!e) | |
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 | 239 break; |
240 } | |
241 lwasm_save_expr(l, i++, e); | |
242 if (**p != ',') | |
243 break; | |
244 (*p)++; | |
245 } | |
246 | |
247 l -> len = i * 2; | |
248 } | |
249 | |
250 EMITFUNC(pseudo_emit_fdbs) | |
251 { | |
252 int i; | |
253 lw_expr_t e; | |
254 lw_expr_t t; | |
255 lw_expr_t t2; | |
256 // int v; | |
257 | |
258 for (i = 0; i < (l -> len)/2; i++) | |
259 { | |
260 e = lwasm_fetch_expr(l, i); | |
261 t = lw_expr_build(lw_expr_type_int, 256); | |
262 t2 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_divide, e, t); | |
263 lwasm_reduce_expr(as, t2); | |
264 lw_expr_destroy(t); | |
265 lwasm_emitexpr(l, e, 1); | |
266 lwasm_emitexpr(l, t2, 1); | |
267 lw_expr_destroy(t2); | |
268 } | |
269 } | |
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 | 306 static int cstringlen(asmstate_t *as, line_t *ln, char **p, char delim) |
307 { | |
308 int l = 0; | |
309 char *str = NULL; | |
310 int blen = 0; | |
311 int bsize = 0; | |
312 | |
313 if (!(as -> pragmas & PRAGMA_CESCAPES)) | |
314 { | |
315 for (; **p && **p != delim; (*p)++) | |
316 { | |
317 l++; | |
318 if (blen >= bsize) | |
319 { | |
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 | 322 } |
323 str[blen++] = **p; | |
324 } | |
325 } | |
326 else | |
327 { | |
328 while (**p && **p != delim) | |
329 { | |
330 int wch = **p; | |
331 if (**p == '\\') | |
332 { | |
333 /* escape sequence */ | |
334 | |
335 (*p)++; | |
336 if (!**p) | |
337 break; | |
76
da74ccf4278c
Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents:
75
diff
changeset
|
338 |
75 | 339 switch (**p) |
340 { | |
341 /* octal sequence or NUL */ | |
342 /* skip the "0", then skip up to two more digits */ | |
343 case '0': | |
344 case '1': | |
345 case '2': | |
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 | 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 | 350 { |
76
da74ccf4278c
Fixed bug parsing octal constants under cescapes pragma
lost@l-w.ca
parents:
75
diff
changeset
|
351 (*p)++; |
75 | 352 wch *= 8; |
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 | 357 (*p)++; |
358 wch *= 8; | |
359 wch += **p -0x30; | |
360 } | |
361 break; | |
362 | |
363 /* hexadecimal value */ | |
364 case 'x': | |
365 (*p)++; // ignore "x" | |
366 wch = 0; | |
367 if (**p) // skip digit 1 | |
368 { | |
369 wch = **p - 0x30; | |
370 if (wch > 9) | |
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 | 373 wch -= 32; |
374 (*p)++; | |
375 } | |
376 if (**p) | |
377 { | |
378 int i; | |
379 i = **p - 0x30; | |
380 if (i > 9) | |
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 | 383 i -= 32; |
384 wch = wch * 16 + i; | |
385 } | |
386 break; | |
387 | |
388 case 'a': | |
389 wch = 7; | |
390 break; | |
391 | |
392 case 'b': | |
393 wch = 8; | |
394 break; | |
395 | |
396 case 't': | |
397 wch = 9; | |
398 break; | |
399 | |
400 case 'n': | |
401 wch = 10; | |
402 break; | |
403 | |
404 case 'v': | |
405 wch = 11; | |
406 break; | |
407 | |
408 case 'f': | |
409 wch = 12; | |
410 break; | |
411 | |
412 case 'r': | |
413 wch = 13; | |
414 | |
415 /* everything else represents itself */ | |
416 default: | |
417 break; | |
418 } | |
419 } | |
420 /* now "wch" is the character to write out */ | |
421 l++; | |
422 (*p)++; | |
423 if (blen >= bsize) | |
424 { | |
425 str = lw_realloc(str, bsize + 32); | |
426 bsize += 32; | |
427 } | |
428 str[blen++] = wch; | |
429 } | |
430 } | |
431 /* do something with the string here */ | |
432 /* l is the string length, str is the string itself */ | |
433 ln -> lstr = str; | |
434 return l; | |
435 } | |
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 | 451 i = cstringlen(as, l, p, delim); |
452 | |
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 | 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 | 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 | 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 | 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 | 538 i = cstringlen(as, l, p, delim); |
539 | |
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 | 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 | 980 PARSEFUNC(pseudo_parse_reorg) |
981 { | |
982 lw_expr_t e = NULL; | |
983 | |
984 l -> len = 0; | |
985 | |
986 line_t *cl = l; | |
987 for (cl = cl -> prev; cl; cl = cl -> prev) | |
988 { | |
989 if (cl -> insn == -1) continue; | |
990 | |
991 if (!strcmp("org", instab[cl -> insn].opcode)) | |
992 { | |
993 if (cl -> prev) | |
994 { | |
995 e = lw_expr_copy(cl -> prev -> daddr); | |
996 break; | |
997 } | |
998 } | |
999 } | |
1000 | |
1001 if (!e) | |
1002 { | |
1003 lwasm_register_error(as, l, E_ORG_NOT_FOUND); | |
1004 return; | |
1005 } | |
1006 | |
1007 lw_expr_destroy(l -> daddr); | |
1008 l -> daddr = e; | |
1009 | |
1010 if (l -> inmod == 0) | |
1011 { | |
1012 lw_expr_destroy(l -> addr); | |
1013 l -> addr = e; | |
1014 } | |
1015 l -> len = 0; | |
1016 } | |
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 | 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 | 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 | 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 | 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 | 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 |
559
ddc7b05a5675
Add --no-warn=ifp1 flag to suppress warnings about ifp1 and ipf2
William Astle <lost@l-w.ca>
parents:
543
diff
changeset
|
1114 if ((as -> nowarn_flags & NOWARN_IFP1) == 0) |
ddc7b05a5675
Add --no-warn=ifp1 flag to suppress warnings about ifp1 and ipf2
William Astle <lost@l-w.ca>
parents:
543
diff
changeset
|
1115 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
|
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 |
2c24602be78f
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 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
|
1119 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1120 l -> len = 0; |
219 | 1121 l -> hideline = 1; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1122 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
|
1123 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1124 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
|
1125 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1126 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
|
1127 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
|
1128 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
|
1129 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1130 |
559
ddc7b05a5675
Add --no-warn=ifp1 flag to suppress warnings about ifp1 and ipf2
William Astle <lost@l-w.ca>
parents:
543
diff
changeset
|
1131 if ((as -> nowarn_flags & NOWARN_IFP1) == 0) |
ddc7b05a5675
Add --no-warn=ifp1 flag to suppress warnings about ifp1 and ipf2
William Astle <lost@l-w.ca>
parents:
543
diff
changeset
|
1132 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
|
1133 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1134 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1135 PARSEFUNC(pseudo_parse_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
|
1136 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1137 lw_expr_t e; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1138 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1139 l -> len = 0; |
219 | 1140 l -> hideline = 1; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1141 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
|
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 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
|
1144 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1145 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
|
1146 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
|
1147 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
|
1148 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1149 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1150 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
|
1151 if (e) |
fa835b780ffb
Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents:
186
diff
changeset
|
1152 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
|
1153 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
|
1154 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1155 as -> 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
|
1156 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
|
1157 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1158 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1159 |
2c24602be78f
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 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
|
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 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
|
1163 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1164 l -> len = 0; |
219 | 1165 l -> hideline = 1; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1166 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
|
1167 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1168 if (as -> skipcond && !(as -> skipmacro)) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1169 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1170 as -> skipcount++; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1171 skip_operand(p); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1172 return; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1173 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1174 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1175 e = lwasm_parse_cond(as, p); |
208
fa835b780ffb
Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents:
186
diff
changeset
|
1176 if (e) |
fa835b780ffb
Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents:
186
diff
changeset
|
1177 lwasm_reduce_expr(as, e); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1178 if (e && lw_expr_intval(e) == 0) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1179 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1180 as -> skipcond = 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1181 as -> skipcount = 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1182 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1183 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1184 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1185 |
2c24602be78f
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 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
|
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 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
|
1189 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1190 l -> len = 0; |
219 | 1191 l -> hideline = 1; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1192 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
|
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 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
|
1195 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1196 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
|
1197 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
|
1198 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
|
1199 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1200 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1201 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
|
1202 if (e) |
fa835b780ffb
Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents:
186
diff
changeset
|
1203 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
|
1204 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
|
1205 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1206 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
|
1207 as -> skipcount = 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1208 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1209 } |
2c24602be78f
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 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
|
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 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
|
1214 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1215 l -> len = 0; |
219 | 1216 l -> hideline = 1; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1217 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
|
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 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
|
1220 { |
2c24602be78f
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 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
|
1222 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
|
1223 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
|
1224 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1225 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1226 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
|
1227 if (e) |
fa835b780ffb
Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents:
186
diff
changeset
|
1228 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
|
1229 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
|
1230 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1231 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
|
1232 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
|
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 } |
2c24602be78f
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 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
|
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 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
|
1239 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1240 l -> len = 0; |
219 | 1241 l -> hideline = 1; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1242 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
|
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 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
|
1245 { |
2c24602be78f
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 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
|
1247 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
|
1248 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
|
1249 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1250 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1251 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
|
1252 if (e) |
fa835b780ffb
Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents:
186
diff
changeset
|
1253 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
|
1254 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
|
1255 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1256 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
|
1257 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
|
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 } |
2c24602be78f
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 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
|
1262 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1263 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
|
1264 |
219 | 1265 l -> hideline = 1; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1266 l -> hidecond = 1; |
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1267 |
0
2c24602be78f
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 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
|
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 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
|
1271 { |
2c24602be78f
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 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
|
1273 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
|
1274 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
|
1275 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1276 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1277 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
|
1278 if (e) |
fa835b780ffb
Fix crash on conditionals with undefined symbols
William Astle <lost@l-w.ca>
parents:
186
diff
changeset
|
1279 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
|
1280 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
|
1281 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1282 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
|
1283 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
|
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 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1286 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1287 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
|
1288 { |
219 | 1289 l -> hideline = 1; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1290 l -> hidecond = 1; |
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1291 |
0
2c24602be78f
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 l -> len = 0; |
145 | 1293 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
|
1294 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
|
1295 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1296 as -> skipcount--; |
2c24602be78f
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 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
|
1298 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
|
1299 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1300 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1301 |
2c24602be78f
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 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
|
1303 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1304 l -> len = 0; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1305 l -> hidecond = 1; |
219 | 1306 l -> hideline = 1; |
217
f87c86668d6b
Fix handling of comments on ELSE lines
William Astle <lost@l-w.ca>
parents:
208
diff
changeset
|
1307 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
|
1308 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1309 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
|
1310 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
|
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 -> 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
|
1313 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1314 if (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
|
1315 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1316 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
|
1317 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
|
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 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
|
1320 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1321 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
|
1322 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
|
1323 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1324 |
2c24602be78f
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 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
|
1326 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1327 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
|
1328 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
|
1329 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
|
1330 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1331 l -> len = 0; |
219 | 1332 l -> hideline = 1; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1333 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
|
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 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
|
1336 { |
2c24602be78f
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 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
|
1338 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
|
1339 return; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1340 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1341 |
132
4cf44ff89b08
Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents:
114
diff
changeset
|
1342 again: |
4cf44ff89b08
Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents:
114
diff
changeset
|
1343 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
|
1344 /* 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
|
1345 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1346 sym = lw_strndup(*p, i); |
84 | 1347 (*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
|
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 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
|
1350 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1351 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
|
1352 |
133 | 1353 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
|
1354 { |
133 | 1355 if (**p == '|') |
1356 { | |
1357 (*p)++; | |
1358 goto again; | |
1359 } | |
0
2c24602be78f
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 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
|
1361 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
|
1362 } |
133 | 1363 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
|
1364 } |
2c24602be78f
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 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
|
1367 { |
2c24602be78f
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 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
|
1369 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
|
1370 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
|
1371 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1372 l -> len = 0; |
219 | 1373 l -> hideline = 1; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1374 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
|
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 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
|
1377 { |
2c24602be78f
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 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
|
1379 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
|
1380 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
|
1381 } |
132
4cf44ff89b08
Added DTS and DTB pseudo ops; initial attempt to allow ifdef SYM1|SYM2
lost@l-w.ca
parents:
114
diff
changeset
|
1382 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
|
1383 /* 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
|
1384 |
2c24602be78f
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 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
|
1386 (*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
|
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 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
|
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 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
|
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 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
|
1393 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1394 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
|
1395 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
|
1396 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
|
1397 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1398 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1399 |
384
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1400 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
|
1401 { |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1402 char *pstr; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1403 int i; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1404 int pragma; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1405 int compare; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1406 |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1407 l -> len = 0; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1408 l -> hideline = 1; |
474
74d0c394666e
Add "noexpandcond" pragma (cleans up listings)
William Astle <lost@l-w.ca>
parents:
443
diff
changeset
|
1409 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
|
1410 |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1411 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
|
1412 { |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1413 as -> skipcount++; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1414 skip_operand(p); |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1415 return; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1416 } |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1417 |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1418 again: |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1419 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
|
1420 /* do nothing */; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1421 |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1422 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
|
1423 (*p) += i; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1424 |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1425 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
|
1426 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
|
1427 |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1428 lw_free(pstr); |
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 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
|
1431 { |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1432 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
|
1433 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
|
1434 } |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1435 else |
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 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
|
1438 } |
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 (!compare) |
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 if (**p == '|') |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1443 { |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1444 (*p)++; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1445 goto again; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1446 } |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1447 as -> skipcond = 1; |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1448 as -> skipcount = 1; |
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 skip_operand(p); |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1451 } |
6ee9c67a0f8d
Add conditional for testing if a pragma is in effect
William Astle <lost@l-w.ca>
parents:
382
diff
changeset
|
1452 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1453 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
|
1454 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1455 lwasm_register_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
|
1456 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
|
1457 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1458 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1459 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
|
1460 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1461 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
|
1462 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
|
1463 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
|
1464 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1465 |
2c24602be78f
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 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
|
1467 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1468 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
|
1469 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
|
1470 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
|
1471 long flen; |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
1472 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
|
1473 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1474 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
|
1475 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1476 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
|
1477 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
|
1478 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1479 |
2c24602be78f
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 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
|
1481 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1482 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
|
1483 (*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
|
1484 |
63 | 1485 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
|
1486 /* 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
|
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 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
|
1489 { |
2c24602be78f
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 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
|
1491 /* 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
|
1492 } |
2c24602be78f
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 fn = lw_strndup(*p, p2 - *p); |
62
5b10ff307463
Fixed problem with filename handling in includebin
lost@l-w.ca
parents:
58
diff
changeset
|
1494 *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
|
1495 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
|
1496 (*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
|
1497 |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
1498 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
|
1499 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
|
1500 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1501 lwasm_register_error(as, l, E_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
|
1502 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
|
1503 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
|
1504 } |
2c24602be78f
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 |
224
3864d96ee8c7
Make unicorns notice referenced files better
William Astle <lost@l-w.ca>
parents:
219
diff
changeset
|
1506 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
|
1507 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1508 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
|
1509 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
|
1510 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
|
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 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
|
1513 } |
2c24602be78f
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 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
|
1516 { |
2c24602be78f
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 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
|
1518 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
|
1519 |
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
|
1520 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
|
1521 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
|
1522 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1523 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
|
1524 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
|
1525 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1526 |
2c24602be78f
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 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
|
1528 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1529 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
|
1530 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
|
1531 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1532 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
|
1533 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
|
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 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
|
1536 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1537 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1538 |
2c24602be78f
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 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
|
1540 { |
2c24602be78f
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 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
|
1542 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
|
1543 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
|
1544 int len; |
41 | 1545 char buf[110]; |
1546 | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1547 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
|
1548 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1549 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
|
1550 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
|
1551 } |
2c24602be78f
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 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
|
1554 { |
2c24602be78f
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 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
|
1556 (*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
|
1557 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1558 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
|
1559 /* 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
|
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 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
|
1562 { |
2c24602be78f
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 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
|
1564 /* 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
|
1565 } |
2c24602be78f
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 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
|
1567 (*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
|
1568 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
|
1569 (*p)++; |
41 | 1570 |
1571 /* add a book-keeping entry for line numbers */ | |
1572 snprintf(buf, 100, "\001\001SETLINENO %d\n", l -> lineno + 1); | |
1573 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
|
1574 |
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
|
1575 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
|
1576 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
|
1577 sprintf(p3, "include:%s", fn); |
219 | 1578 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
|
1579 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
|
1580 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
|
1581 |
219 | 1582 if (as -> fileerr == 0) |
1583 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
|
1584 l -> len = 0; |
93
5bf9edabd661
Squashed the remaining memory leaks revealed by valgrind
lost@l-w.ca
parents:
88
diff
changeset
|
1585 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
|
1586 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1587 |
519
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1588 PARSEFUNC(pseudo_parse_includestr) |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1589 { |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1590 char *str; |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1591 char buf[110]; |
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 l -> len = 0; |
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 if (!**p) |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1596 { |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1597 // no operand - include nothing |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1598 return; |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1599 } |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1600 |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1601 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
|
1602 if (!str) |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1603 { |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1604 // string parsing failed |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1605 return; |
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 if (*str == '\0') |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1608 { |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1609 // 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
|
1610 lw_free(str); |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1611 return; |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1612 } |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1613 |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1614 /* 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
|
1615 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
|
1616 input_openstring(as, "INTERNAL", buf); |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1617 |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1618 /* 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
|
1619 input_openstring(as, "INCLUDESTR", str); |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1620 lw_free(str); |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1621 } |
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
516
diff
changeset
|
1622 |
0
2c24602be78f
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 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
|
1624 { |
2c24602be78f
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 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
|
1626 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
|
1627 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1628 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
|
1629 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
|
1630 } |
2c24602be78f
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 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
|
1633 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1634 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
|
1635 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1636 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
|
1637 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
|
1638 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1639 |
2c24602be78f
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 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
|
1641 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1642 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
|
1643 { |
114
707eda49ad60
Fix parsing padding argument for align pseudo op
lost@l-w.ca
parents:
93
diff
changeset
|
1644 (*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
|
1645 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
|
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 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
|
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 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
|
1650 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1651 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
|
1652 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1653 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
|
1654 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
|
1655 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1656 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1657 lwasm_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
|
1658 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1659 |
2c24602be78f
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 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
|
1661 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1662 lw_expr_t e; |
264
346966cffeef
Clean up various warnings when building under -Wall
William Astle <lost@l-w.ca>
parents:
251
diff
changeset
|
1663 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
|
1664 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
|
1665 int a; |
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1666 |
0
2c24602be78f
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 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
|
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 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
|
1670 { |
2c24602be78f
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 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
|
1672 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
|
1673 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1674 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
|
1675 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
|
1676 } |
2c24602be78f
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 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
|
1679 { |
266
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1680 return; |
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 |
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1683 |
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1684 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
|
1685 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
|
1686 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
|
1687 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
|
1688 |
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1689 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
|
1690 { |
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1691 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
|
1692 } |
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1693 else |
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 a = -1; |
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 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
|
1698 |
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1699 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
|
1700 { |
0
2c24602be78f
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 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
|
1702 { |
2c24602be78f
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 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
|
1704 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
|
1705 } |
2c24602be78f
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 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
|
1707 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
|
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 } |
2c24602be78f
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 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
|
1712 { |
2c24602be78f
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 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
|
1714 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
|
1715 |
266
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1716 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
|
1717 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
|
1718 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
|
1719 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
|
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 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
|
1722 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1723 } |
55 | 1724 |
186 | 1725 PARSEFUNC(pseudo_parse_fill) |
1726 { | |
1727 lw_expr_t e, e1; | |
1728 if (!**p) | |
1729 { | |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1730 lwasm_register_error(as, l, E_OPERAND_BAD); |
186 | 1731 return; |
1732 } | |
1733 | |
1734 e1 = lwasm_parse_expr(as, p); | |
1735 if (**p != ',') | |
1736 { | |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1737 lwasm_register_error(as, l, E_OPERAND_BAD); |
186 | 1738 return; |
1739 } | |
1740 (*p)++; | |
1741 e = lwasm_parse_expr(as, p); | |
1742 | |
1743 if (!e) | |
1744 { | |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1745 lwasm_register_error(as, l, E_OPERAND_BAD); |
186 | 1746 return; |
1747 } | |
1748 | |
1749 lwasm_save_expr(l, 0, e); | |
1750 lwasm_save_expr(l, 1, e1); | |
1751 | |
1752 if (!e1) | |
1753 { | |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
1754 lwasm_register_error(as, l, E_PADDING_BAD); |
186 | 1755 return; |
1756 } | |
1757 } | |
1758 | |
1759 RESOLVEFUNC(pseudo_resolve_fill) | |
1760 { | |
266
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1761 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
|
1762 int align = 1; |
186 | 1763 |
1764 e = lwasm_fetch_expr(l, 0); | |
1765 | |
266
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1766 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
|
1767 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
|
1768 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
|
1769 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
|
1770 |
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1771 if (lw_expr_istype(te, lw_expr_type_int)) |
186 | 1772 { |
266
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1773 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
|
1774 if (align < 0) |
186 | 1775 { |
266
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1776 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
|
1777 lwasm_register_error(as, l, E_FILL_INVALID); |
186 | 1778 return; |
1779 } | |
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 else |
186 | 1782 { |
266
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1783 lw_expr_destroy(te); |
186 | 1784 return; |
1785 } | |
266
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1786 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
|
1787 |
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1788 l -> len = align; |
186 | 1789 } |
1790 | |
1791 EMITFUNC(pseudo_emit_fill) | |
1792 { | |
1793 lw_expr_t e; | |
1794 int i; | |
1795 | |
266
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1796 /* 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
|
1797 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
|
1798 return; |
35c051bffbff
Make fill and align do something useful in the object target
William Astle <lost@l-w.ca>
parents:
264
diff
changeset
|
1799 |
186 | 1800 e = lwasm_fetch_expr(l, 1); |
1801 for (i = 0; i < l -> len; i++) | |
1802 { | |
1803 lwasm_emitexpr(l, e, 1); | |
1804 } | |
1805 } | |
1806 | |
55 | 1807 /* string conditional argument parser */ |
1808 /* | |
1809 argument syntax: | |
1810 | |
1811 a bare word ended by whitespace, comma, or NUL | |
1812 a double quote delimited string containing arbitrary printable characters | |
1813 a single quote delimited string containing arbitrary printable characters | |
1814 | |
1815 In a double quoted string, a double quote cannot be represented. | |
1816 In a single quoted string, a single quote cannot be represented. | |
1817 | |
1818 */ | |
1819 char *strcond_parsearg(char **p) | |
1820 { | |
1821 char *arg; | |
1822 char *tstr; | |
1823 int i; | |
1824 tstr = *p; | |
1825 | |
1826 if (!**p || isspace(**p)) | |
1827 { | |
1828 return lw_strdup(""); | |
1829 } | |
1830 | |
1831 if (*tstr == '"') | |
1832 { | |
1833 // double quote delim | |
1834 tstr++; | |
1835 for (i = 0; tstr[i] && tstr[i] != '"'; i++) | |
1836 /* do nothing */ ; | |
1837 | |
1838 arg = lw_alloc(i + 1); | |
1839 strncpy(arg, tstr, i); | |
1840 arg[i] = 0; | |
1841 | |
1842 if (tstr[i]) | |
1843 i++; | |
521
56c32bc798f8
Fix argument parsing problems with IFSTR
William Astle <lost@l-w.ca>
parents:
519
diff
changeset
|
1844 if (tstr[i] == ',') |
56c32bc798f8
Fix argument parsing problems with IFSTR
William Astle <lost@l-w.ca>
parents:
519
diff
changeset
|
1845 i++; |
55 | 1846 |
521
56c32bc798f8
Fix argument parsing problems with IFSTR
William Astle <lost@l-w.ca>
parents:
519
diff
changeset
|
1847 *p += i + 1; |
55 | 1848 return arg; |
1849 } | |
1850 else if (*tstr == '\'') | |
1851 { | |
1852 // single quote delim | |
1853 tstr++; | |
1854 for (i = 0; tstr[i] && tstr[i] != '\''; i++) | |
1855 /* do nothing */ ; | |
1856 | |
1857 arg = lw_alloc(i + 1); | |
1858 strncpy(arg, tstr, i); | |
1859 arg[i] = 0; | |
1860 | |
1861 if (tstr[i]) | |
1862 i++; | |
521
56c32bc798f8
Fix argument parsing problems with IFSTR
William Astle <lost@l-w.ca>
parents:
519
diff
changeset
|
1863 if (tstr[i] == ',') |
56c32bc798f8
Fix argument parsing problems with IFSTR
William Astle <lost@l-w.ca>
parents:
519
diff
changeset
|
1864 i++; |
56c32bc798f8
Fix argument parsing problems with IFSTR
William Astle <lost@l-w.ca>
parents:
519
diff
changeset
|
1865 *p += i + 1; |
55 | 1866 return arg; |
1867 } | |
1868 else | |
1869 { | |
1870 // bare word - whitespace or comma delim | |
1871 for (i = 0; tstr[i] && !isspace(tstr[i]) && tstr[i] != ','; i++) | |
1872 /* do nothing */ ; | |
1873 | |
1874 arg = lw_alloc(i + 1); | |
1875 strncpy(arg, tstr, i); | |
1876 arg[i] = 0; | |
1877 if (tstr[i] == ',') | |
1878 i++; | |
1879 | |
1880 *p += i; | |
1881 return arg; | |
1882 } | |
1883 } | |
1884 | |
1885 /* string conditional helpers */ | |
1886 /* return "1" for true, "0" for false */ | |
1887 int strcond_eq(char **p) | |
1888 { | |
1889 char *arg1; | |
1890 char *arg2; | |
1891 int c = 0; | |
1892 | |
1893 arg1 = strcond_parsearg(p); | |
1894 arg2 = strcond_parsearg(p); | |
521
56c32bc798f8
Fix argument parsing problems with IFSTR
William Astle <lost@l-w.ca>
parents:
519
diff
changeset
|
1895 |
55 | 1896 if (strcmp(arg1, arg2) == 0) |
1897 c = 1; | |
1898 lw_free(arg1); | |
1899 lw_free(arg2); | |
1900 return c; | |
1901 } | |
1902 | |
1903 int strcond_ieq(char **p) | |
1904 { | |
1905 char *arg1; | |
1906 char *arg2; | |
1907 int c = 0; | |
1908 | |
1909 arg1 = strcond_parsearg(p); | |
1910 arg2 = strcond_parsearg(p); | |
1911 | |
1912 if (strcasecmp(arg1, arg2) == 0) | |
1913 c = 1; | |
1914 lw_free(arg1); | |
1915 lw_free(arg2); | |
1916 return c; | |
1917 } | |
1918 | |
1919 int strcond_ne(char **p) | |
1920 { | |
1921 char *arg1; | |
1922 char *arg2; | |
1923 int c = 0; | |
1924 | |
1925 arg1 = strcond_parsearg(p); | |
1926 arg2 = strcond_parsearg(p); | |
1927 | |
1928 if (strcmp(arg1, arg2) != 0) | |
1929 c = 1; | |
1930 lw_free(arg1); | |
1931 lw_free(arg2); | |
1932 return c; | |
1933 } | |
1934 | |
1935 int strcond_ine(char **p) | |
1936 { | |
1937 char *arg1; | |
1938 char *arg2; | |
1939 int c = 0; | |
1940 | |
1941 arg1 = strcond_parsearg(p); | |
1942 arg2 = strcond_parsearg(p); | |
1943 | |
1944 if (strcasecmp(arg1, arg2) != 0) | |
1945 c = 1; | |
1946 lw_free(arg1); | |
1947 lw_free(arg2); | |
1948 return c; | |
1949 } | |
1950 | |
1951 int strcond_peq(char **p) | |
1952 { | |
1953 char *arg0; | |
1954 char *arg1; | |
1955 char *arg2; | |
359 | 1956 size_t plen; |
55 | 1957 int c = 0; |
1958 | |
1959 arg0 = strcond_parsearg(p); | |
1960 arg1 = strcond_parsearg(p); | |
1961 arg2 = strcond_parsearg(p); | |
1962 | |
1963 plen = strtol(arg0, NULL, 10); | |
1964 if (strlen(arg1) > plen) | |
1965 arg1[plen] = 0; | |
1966 if (strlen(arg2) > plen) | |
1967 arg2[plen] = 0; | |
1968 | |
1969 if (strcmp(arg1, arg2) == 0) | |
1970 c = 1; | |
1971 lw_free(arg0); | |
1972 lw_free(arg1); | |
1973 lw_free(arg2); | |
1974 return c; | |
1975 } | |
1976 | |
1977 int strcond_ipeq(char **p) | |
1978 { | |
1979 char *arg0; | |
1980 char *arg1; | |
1981 char *arg2; | |
359 | 1982 size_t plen; |
55 | 1983 int c = 0; |
1984 | |
1985 arg0 = strcond_parsearg(p); | |
1986 arg1 = strcond_parsearg(p); | |
1987 arg2 = strcond_parsearg(p); | |
1988 | |
1989 plen = strtol(arg0, NULL, 10); | |
1990 if (strlen(arg1) > plen) | |
1991 arg1[plen] = 0; | |
1992 if (strlen(arg2) > plen) | |
1993 arg2[plen] = 0; | |
1994 | |
1995 if (strcasecmp(arg1, arg2) == 0) | |
1996 c = 1; | |
1997 lw_free(arg0); | |
1998 lw_free(arg1); | |
1999 lw_free(arg2); | |
2000 return c; | |
2001 } | |
2002 | |
2003 int strcond_pne(char **p) | |
2004 { | |
2005 char *arg0; | |
2006 char *arg1; | |
2007 char *arg2; | |
359 | 2008 size_t plen; |
55 | 2009 int c = 0; |
2010 | |
2011 arg0 = strcond_parsearg(p); | |
2012 arg1 = strcond_parsearg(p); | |
2013 arg2 = strcond_parsearg(p); | |
2014 | |
2015 plen = strtol(arg0, NULL, 10); | |
2016 if (strlen(arg1) > plen) | |
2017 arg1[plen] = 0; | |
2018 if (strlen(arg2) > plen) | |
2019 arg2[plen] = 0; | |
2020 | |
2021 if (strcmp(arg1, arg2) != 0) | |
2022 c = 1; | |
2023 lw_free(arg0); | |
2024 lw_free(arg1); | |
2025 lw_free(arg2); | |
2026 return c; | |
2027 } | |
2028 | |
2029 int strcond_ipne(char **p) | |
2030 { | |
2031 char *arg0; | |
2032 char *arg1; | |
2033 char *arg2; | |
359 | 2034 size_t plen; |
55 | 2035 int c = 0; |
2036 | |
2037 arg0 = strcond_parsearg(p); | |
2038 arg1 = strcond_parsearg(p); | |
2039 arg2 = strcond_parsearg(p); | |
2040 | |
2041 plen = strtol(arg0, NULL, 10); | |
2042 if (strlen(arg1) > plen) | |
2043 arg1[plen] = 0; | |
2044 if (strlen(arg2) > plen) | |
2045 arg2[plen] = 0; | |
2046 | |
2047 if (strcasecmp(arg1, arg2) != 0) | |
2048 c = 1; | |
2049 lw_free(arg0); | |
2050 lw_free(arg1); | |
2051 lw_free(arg2); | |
2052 return c; | |
2053 } | |
2054 | |
2055 int strcond_seq(char **p) | |
2056 { | |
2057 char *arg0; | |
2058 char *arg1; | |
2059 char *arg2; | |
2060 char *rarg1; | |
2061 char *rarg2; | |
2062 | |
359 | 2063 size_t plen; |
55 | 2064 int c = 0; |
2065 | |
2066 arg0 = strcond_parsearg(p); | |
2067 arg1 = strcond_parsearg(p); | |
2068 arg2 = strcond_parsearg(p); | |
2069 | |
2070 rarg1 = arg1; | |
2071 rarg2 = arg2; | |
2072 | |
2073 plen = strtol(arg0, NULL, 10); | |
2074 if (strlen(arg1) > plen) | |
2075 { | |
2076 rarg1 += strlen(arg1) - plen; | |
2077 } | |
2078 if (strlen(arg2) > plen) | |
2079 { | |
2080 rarg2 += strlen(arg2) - plen; | |
2081 } | |
2082 if (strcmp(rarg1, rarg2) == 0) | |
2083 c = 1; | |
2084 lw_free(arg0); | |
2085 lw_free(arg1); | |
2086 lw_free(arg2); | |
2087 return c; | |
2088 } | |
2089 | |
2090 int strcond_iseq(char **p) | |
2091 { | |
2092 char *arg0; | |
2093 char *arg1; | |
2094 char *arg2; | |
2095 char *rarg1; | |
2096 char *rarg2; | |
2097 | |
359 | 2098 size_t plen; |
55 | 2099 int c = 0; |
2100 | |
2101 arg0 = strcond_parsearg(p); | |
2102 arg1 = strcond_parsearg(p); | |
2103 arg2 = strcond_parsearg(p); | |
2104 | |
2105 rarg1 = arg1; | |
2106 rarg2 = arg2; | |
2107 | |
2108 plen = strtol(arg0, NULL, 10); | |
2109 if (strlen(arg1) > plen) | |
2110 { | |
2111 rarg1 += strlen(arg1) - plen; | |
2112 } | |
2113 if (strlen(arg2) > plen) | |
2114 { | |
2115 rarg2 += strlen(arg2) - plen; | |
2116 } | |
2117 | |
2118 if (strcasecmp(rarg1, rarg2) == 0) | |
2119 c = 1; | |
2120 lw_free(arg0); | |
2121 lw_free(arg1); | |
2122 lw_free(arg2); | |
2123 return c; | |
2124 } | |
2125 | |
2126 | |
2127 int strcond_sne(char **p) | |
2128 { | |
2129 char *arg0; | |
2130 char *arg1; | |
2131 char *arg2; | |
2132 char *rarg1; | |
2133 char *rarg2; | |
2134 | |
359 | 2135 size_t plen; |
55 | 2136 int c = 0; |
2137 | |
2138 arg0 = strcond_parsearg(p); | |
2139 arg1 = strcond_parsearg(p); | |
2140 arg2 = strcond_parsearg(p); | |
2141 | |
2142 rarg1 = arg1; | |
2143 rarg2 = arg2; | |
2144 | |
2145 plen = strtol(arg0, NULL, 10); | |
2146 if (strlen(arg1) > plen) | |
2147 { | |
2148 rarg1 += strlen(arg1) - plen; | |
2149 } | |
2150 if (strlen(arg2) > plen) | |
2151 { | |
2152 rarg2 += strlen(arg2) - plen; | |
2153 } | |
2154 | |
2155 if (strcmp(rarg1, rarg2) != 0) | |
2156 c = 1; | |
2157 lw_free(arg0); | |
2158 lw_free(arg1); | |
2159 lw_free(arg2); | |
2160 return c; | |
2161 } | |
2162 | |
2163 int strcond_isne(char **p) | |
2164 { | |
2165 char *arg0; | |
2166 char *arg1; | |
2167 char *arg2; | |
2168 char *rarg1; | |
2169 char *rarg2; | |
2170 | |
359 | 2171 size_t plen; |
55 | 2172 int c = 0; |
2173 | |
2174 arg0 = strcond_parsearg(p); | |
2175 arg1 = strcond_parsearg(p); | |
2176 arg2 = strcond_parsearg(p); | |
2177 | |
2178 rarg1 = arg1; | |
2179 rarg2 = arg2; | |
2180 | |
2181 plen = strtol(arg0, NULL, 10); | |
2182 if (strlen(arg1) > plen) | |
2183 { | |
2184 rarg1 += strlen(arg1) - plen; | |
2185 } | |
2186 if (strlen(arg2) > plen) | |
2187 { | |
2188 rarg2 += strlen(arg2) - plen; | |
2189 } | |
2190 | |
2191 if (strcasecmp(rarg1, rarg2) != 0) | |
2192 c = 1; | |
2193 lw_free(arg0); | |
2194 lw_free(arg1); | |
2195 lw_free(arg2); | |
2196 return c; | |
2197 } | |
2198 | |
2199 /* string conditionals */ | |
2200 PARSEFUNC(pseudo_parse_ifstr) | |
2201 { | |
2202 static struct strconds | |
2203 { | |
2204 char *str; | |
2205 int (*fn)(char **ptr); | |
2206 } strops[] = { | |
2207 { "eq", strcond_eq }, | |
2208 { "ieq", strcond_ieq }, | |
2209 { "ne", strcond_ne }, | |
2210 { "ine", strcond_ine }, | |
2211 { "peq", strcond_peq }, | |
2212 { "ipeq", strcond_ipeq }, | |
2213 { "pne", strcond_pne }, | |
2214 { "ipne", strcond_ipne }, | |
2215 { "seq", strcond_seq }, | |
2216 { "iseq", strcond_iseq }, | |
2217 { "sne", strcond_sne }, | |
2218 { "isne", strcond_isne }, | |
2219 { NULL, 0 } | |
2220 }; | |
2221 int tv = 0; | |
2222 char *tstr; | |
58 | 2223 int strop; |
55 | 2224 |
2225 l -> len = 0; | |
2226 | |
2227 if (as -> skipcond && !(as -> skipmacro)) | |
2228 { | |
2229 as -> skipcount++; | |
2230 skip_operand(p); | |
2231 return; | |
2232 } | |
2233 | |
2234 tstr = strcond_parsearg(p); | |
2235 if (!**p || isspace(**p)) | |
2236 { | |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
2237 lwasm_register_error(as, l, E_STRING_BAD); |
55 | 2238 return; |
2239 } | |
2240 | |
2241 for (strop = 0; strops[strop].str != NULL; strop++) | |
2242 if (strcasecmp(strops[strop].str, tstr) == 0) | |
2243 break; | |
2244 | |
2245 lw_free(tstr); | |
2246 | |
2247 if (strops[strop].str == NULL) | |
2248 { | |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
359
diff
changeset
|
2249 lwasm_register_error(as, l, E_STRING_BAD); |
55 | 2250 } |
2251 | |
2252 tv = (*(strops[strop].fn))(p); | |
2253 | |
2254 if (!tv) | |
2255 { | |
2256 as -> skipcond = 1; | |
2257 as -> skipcount = 1; | |
2258 } | |
2259 } |