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