annotate lwasm/lwasm.h @ 374:8e25147c2aa8

Clean up various "externs" Apparently some compilers seriously choke on the "extern" keyword in some circumstances where GCC does not. Remove most instances of "extern" to guard against that. Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Mon, 13 Jul 2015 20:31:56 -0600
parents 8764142b3192
children 71f507f404f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1 /*
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
2 lwasm.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
3
2c24602be78f 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 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
5
2c24602be78f 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 This file is part of LWTOOLS.
2c24602be78f 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
2c24602be78f 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 LWTOOLS 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
9 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
10 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
11 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
12
2c24602be78f 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 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
14 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
15 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
16 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
17
2c24602be78f 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 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
19 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
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
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
22 #ifndef ___lwasm_h_seen___
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
23 #define ___lwasm_h_seen___
2c24602be78f 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
361
4130ffdeb5c8 Add contributed support for building with Microsoft's compiler
William Astle <lost@l-w.ca>
parents: 343
diff changeset
25 #ifdef _MSC_VER
4130ffdeb5c8 Add contributed support for building with Microsoft's compiler
William Astle <lost@l-w.ca>
parents: 343
diff changeset
26 #include "lw_win.h" // windows build
4130ffdeb5c8 Add contributed support for building with Microsoft's compiler
William Astle <lost@l-w.ca>
parents: 343
diff changeset
27 #endif
4130ffdeb5c8 Add contributed support for building with Microsoft's compiler
William Astle <lost@l-w.ca>
parents: 343
diff changeset
28
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
29 #include <lw_expr.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
30 #include <lw_stringlist.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
31 #include <lw_stack.h>
361
4130ffdeb5c8 Add contributed support for building with Microsoft's compiler
William Astle <lost@l-w.ca>
parents: 343
diff changeset
32 #include <lw_version.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
33
2c24602be78f 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 // these are allowed chars BELOW 0x80 for symbols
2c24602be78f 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 // first is symbol start chars, second is anywhere in symbol
2c24602be78f 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 #define SSYMCHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_@$"
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
37 #define SYMCHARS SSYMCHARS ".?0123456789"
2c24602be78f 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
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
39 typedef struct asmstate_s asmstate_t;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
40
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
41 enum
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
42 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
43 lwasm_expr_linelen = 1, // length of ref'd line
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
44 lwasm_expr_lineaddr = 2, // addr of ref'd line
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
45 lwasm_expr_nextbp = 3, // next branch point
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
46 lwasm_expr_prevbp = 4, // previous branch point
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
47 lwasm_expr_syment = 5, // symbol table entry
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
48 lwasm_expr_import = 6, // symbol import entry
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 115
diff changeset
49 lwasm_expr_secbase = 7, // section base address
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 115
diff changeset
50 lwasm_expr_linedaddr = 8, // data address of the line
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 115
diff changeset
51 lwasm_expr_linedlen = 9 // data length of the line
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
52 };
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
53
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
54 enum lwasm_output_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
55 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
56 OUTPUT_DECB = 0, // DECB multirecord format
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
57 OUTPUT_RAW, // raw sequence of bytes
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
58 OUTPUT_OBJ, // proprietary object file format
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
59 OUTPUT_RAWREL, // raw bytes where ORG causes a SEEK in the file
321
d4ac484d0ec6 Add support for Motorola SREC and Intel Hex output formats to lwasm.
Tom LeMense <tlemense@yahoo.com>
parents: 241
diff changeset
60 OUTPUT_OS9, // os9 module target
d4ac484d0ec6 Add support for Motorola SREC and Intel Hex output formats to lwasm.
Tom LeMense <tlemense@yahoo.com>
parents: 241
diff changeset
61 OUTPUT_SREC, // motorola SREC format
d4ac484d0ec6 Add support for Motorola SREC and Intel Hex output formats to lwasm.
Tom LeMense <tlemense@yahoo.com>
parents: 241
diff changeset
62 OUTPUT_IHEX, // intel hex format
d4ac484d0ec6 Add support for Motorola SREC and Intel Hex output formats to lwasm.
Tom LeMense <tlemense@yahoo.com>
parents: 241
diff changeset
63 OUTPUT_HEX // generic hexadecimal format
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
64 };
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
65
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
66 enum lwasm_flags_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
67 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
68 FLAG_LIST = 0x0001,
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
69 FLAG_DEPEND = 0x0002,
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
70 FLAG_SYMBOLS = 0x004,
73
1f77ae5c3590 Added --dependnoerr flag to list dependencies on non-existent files without bailing out; also suppress error reports during dependency generation
lost@l-w.ca
parents: 70
diff changeset
71 FLAG_DEPENDNOERR = 0x0008,
222
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents: 219
diff changeset
72 FLAG_UNICORNS = 0x0010,
365
3f8abaac214c Add map file output and option to suppress local symbols in listings
William Astle <lost@l-w.ca>
parents: 361
diff changeset
73 FLAG_MAP = 0x0020,
3f8abaac214c Add map file output and option to suppress local symbols in listings
William Astle <lost@l-w.ca>
parents: 361
diff changeset
74 FLAG_SYMBOLS_NOLOCALS = 0x0040,
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
75 FLAG_NONE = 0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
76 };
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
77
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
78 enum lwasm_pragmas_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
79 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
80 PRAGMA_NONE = 0, // no pragmas in effect
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
81 PRAGMA_DOLLARNOTLOCAL = 0x0001, // dollar sign does not make a symbol local
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
82 PRAGMA_NOINDEX0TONONE = 0x0002, // do not change implicit 0,R to ,R
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
83 PRAGMA_UNDEFEXTERN = 0x0004, // undefined symbols are considered to be external
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
84 PRAGMA_CESCAPES = 0x0008, // allow C style escapes in fcc, fcs, fcn, etc.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
85 PRAGMA_IMPORTUNDEFEXPORT = 0x0010, // imports symbol if undefined upon export
53
cb4efc47ce9d Allow macros to shadow/override builtin operations when the "shadow" pragma is active, which is NOT the default
lost@l-w.ca
parents: 49
diff changeset
86 PRAGMA_PCASPCR = 0x0020, // treats ,PC as ,PCR instead of constant offset
81
428068681cbf Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents: 73
diff changeset
87 PRAGMA_SHADOW = 0x0040, // allow macros to shadow builtin operations
115
344cfc25afec Added initial infrastructure for pragma autobranchlength (suggested by Ebonhand on irc)
lost@l-w.ca
parents: 101
diff changeset
88 PRAGMA_NOLIST = 0x0080, // don't show line in listing
206
080bb67d84f2 Add export pragma
William Astle <lost@l-w.ca>
parents: 195
diff changeset
89 PRAGMA_AUTOBRANCHLENGTH = 0x0100, // automatically select proper length for relative branches
207
07e1fac76321 Added pragma to allow non case sensitive symbols
William Astle <lost@l-w.ca>
parents: 206
diff changeset
90 PRAGMA_EXPORT = 0x0200, // export symbols by default, unless local
210
5d969517db74 Added condundefzero pragma
William Astle <lost@l-w.ca>
parents: 209
diff changeset
91 PRAGMA_SYMBOLNOCASE = 0x400, // symbols defined under this pragma are matched case insensitively
333
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 321
diff changeset
92 PRAGMA_CONDUNDEFZERO = 0x800, // treat undefined symbols as zero in conditionals during pass 1
343
98f3e016cfd8 Add pragma to turn off forward reference optimization
William Astle <lost@l-w.ca>
parents: 338
diff changeset
93 PRAGMA_6800COMPAT = 0x1000, // enable 6800 compatibility opcodes
367
c6d2a1f54e0c Change processor target variations to pragmas.
William Astle <lost@l-w.ca>
parents: 366
diff changeset
94 PRAGMA_FORWARDREFMAX = 0x2000, // force incomplete references on pass 1 to maximum mode
c6d2a1f54e0c Change processor target variations to pragmas.
William Astle <lost@l-w.ca>
parents: 366
diff changeset
95 PRAGMA_6809 = 0x4000 // 6809/6309 assembly mode
0
2c24602be78f 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 };
2c24602be78f 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 enum
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
99 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
100 section_flag_bss = 1, // BSS section
156
fc8386b13399 Added 'constant' sections to object file handling for lwasm and lwlink
lost@l-w.ca
parents: 142
diff changeset
101 section_flag_constant = 2, // constants - no base offset
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
102 section_flag_none = 0 // no flags
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
103 };
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
104
2c24602be78f 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 typedef struct reloctab_s reloctab_t;
2c24602be78f 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 struct reloctab_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
107 {
2c24602be78f 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 lw_expr_t offset; // offset of relocation
2c24602be78f 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 int size; // size of relocation
2c24602be78f 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 lw_expr_t expr; // relocation expression
2c24602be78f 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 reloctab_t *next;
2c24602be78f 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
2c24602be78f 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 typedef struct sectiontab_s sectiontab_t;
2c24602be78f 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 struct sectiontab_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
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 char *name; // section name
2c24602be78f 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 int flags; // section flags;
2c24602be78f 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 lw_expr_t offset; // offset for next instance
2c24602be78f 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 int oblen; // size of section output
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
121 int obsize; // size of output buffer
2c24602be78f 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 unsigned char *obytes; // output buffer
2c24602be78f 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 reloctab_t *reloctab; // table of relocations
2c24602be78f 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 sectiontab_t *next;
2c24602be78f 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
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
127 typedef enum
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
128 {
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
129 E_6309_INVALID,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
130 E_6809_INVALID,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
131 E_ALIGNMENT_INVALID,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
132 E_BITNUMBER_UNRESOLVED,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
133 E_BITNUMBER_INVALID,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
134 E_BYTE_OVERFLOW,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
135 E_CONDITION_P1,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
136 E_DIRECTIVE_OS9_ONLY,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
137 E_DIV0,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
138 E_EXEC_ADDRESS,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
139 E_FILL_INVALID,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
140 E_IMMEDIATE_INVALID,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
141 E_IMMEDIATE_UNRESOLVED,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
142 E_EXPRESSION_BAD,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
143 E_EXPRESSION_NOT_CONST,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
144 E_EXPRESSION_NOT_RESOLVED,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
145 E_FILE_OPEN,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
146 E_FILENAME_MISSING,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
147 E_INSTRUCTION_FAILED,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
148 E_INSTRUCTION_SECTION,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
149 E_LINE_ADDRESS,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
150 E_LINED_ADDRESS,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
151 E_MACRO_DUPE,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
152 E_MACRO_ENDM,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
153 E_MACRO_NONAME,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
154 E_MACRO_RECURSE,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
155 E_MODULE_IN,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
156 E_MODULE_NOTIN,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
157 E_NEGATIVE_BLOCKSIZE,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
158 E_NEGATIVE_RESERVATION,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
159 E_NW_8,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
160 E_OPCODE_BAD,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
161 E_OPERAND_BAD,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
162 E_OBJTARGET_ONLY,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
163 E_PADDING_BAD,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
164 E_PRAGMA_UNRECOGNIZED,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
165 E_REGISTER_BAD,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
166 E_SECTION_END,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
167 E_SECTION_EXTDEP,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
168 E_SECTION_FLAG,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
169 E_SECTION_NAME,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
170 E_SECTION_TARGET,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
171 E_SETDP_INVALID,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
172 E_SETDP_NOT_CONST,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
173 E_STRING_BAD,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
174 E_STRUCT_DUPE,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
175 E_STRUCT_NONAME,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
176 E_STRUCT_NOSYMBOL,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
177 E_STRUCT_RECURSE,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
178 E_SYMBOL_BAD,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
179 E_SYMBOL_DUPE,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
180 E_SYMBOL_MISSING,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
181 E_SYMBOL_UNDEFINED,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
182 E_SYMBOL_UNDEFINED_EXPORT,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
183 E_UNKNOWN_OPERATION,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
184 E_USER_SPECIFIED,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
185
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
186 /* warnings must be 1000 or greater */
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
187
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
188 W_DUPLICATE_SECTION = 1000,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
189 W_ENDSTRUCT_WITHOUT = 1001,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
190 W_NOT_SUPPORTED = 1002,
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
191 W_USER_SPECIFIED = 1003
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
192 } lwasm_errorcode_t;
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
193
0
2c24602be78f 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 typedef struct lwasm_error_s lwasm_error_t;
2c24602be78f 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 struct lwasm_error_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
196 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
197 lwasm_errorcode_t code; // error code
0
2c24602be78f 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 char *mess; // actual error message
226
7c2c2239ec9c Make unicorns grok errors and warnings.
William Astle <lost@l-w.ca>
parents: 223
diff changeset
199 int charpos; // character position on line where parsing stopped
0
2c24602be78f 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 lwasm_error_t *next; // ptr to next 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
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 struct line_expr_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
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 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
206 int id;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
207 struct line_expr_s *next;
2c24602be78f 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
2c24602be78f 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 typedef struct line_s line_t;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
211
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
212 typedef struct exportlist_s exportlist_t;
2c24602be78f 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 struct exportlist_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
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 char *symbol; // symbol to export
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
216 struct symtabe *se; // symbol table entry
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
217 line_t *line; // line the export is on
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
218 exportlist_t *next; // next in the export list
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
219 };
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
220
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
221 typedef struct importlist_s importlist_t;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
222 struct importlist_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
223 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
224 char *symbol; // symbol to import
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
225 importlist_t *next; // next in the import list
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
226 };
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
227
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
228 struct line_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
229 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
230 lw_expr_t addr; // assembly address of the line
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 115
diff changeset
231 lw_expr_t daddr; // data address of the line (os9 only)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
232 int len; // the "size" this line occupies (address space wise) (-1 if unknown)
142
697bc543368c Implement distinction between . and * for OS9 modules
lost@l-w.ca
parents: 115
diff changeset
233 int dlen; // the data "size" this line occupies (-1 if unknown)
241
d0e9dbe9afbe Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents: 226
diff changeset
234 int minlen; // minimum length
d0e9dbe9afbe Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents: 226
diff changeset
235 int maxlen; // maximum length
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
236 int insn; // number of insn in insn table
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
237 int symset; // set if the line symbol was consumed by the instruction
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
238 char *sym; // symbol, if any, on the line
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
239 unsigned char *output; // output bytes
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
240 int outputl; // size of output
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
241 int outputbl; // size of output buffer
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
242 int dpval; // direct page value
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
243 lwasm_error_t *err; // list of errors
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
244 lwasm_error_t *warn; // list of errors
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
245 line_t *prev; // previous line
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
246 line_t *next; // next line
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
247 int inmod; // inside a module?
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
248 sectiontab_t *csect; // which section are we in?
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
249 struct line_expr_s *exprs; // expressions used during parsing
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
250 char *lstr; // string passed forward
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
251 int pb; // pass forward post byte
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
252 int lint; // pass forward integer
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
253 int lint2; // another pass forward integer
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
254 asmstate_t *as; // assembler state data ptr
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
255 int pragmas; // pragmas in effect for the line
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
256 int context; // the symbol context number
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
257 char *ltext; // line number
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
258 char *linespec; // line spec
2c24602be78f 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 int lineno; // line number
2c24602be78f 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 int soff; // struct offset (for listings)
2c24602be78f 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 dshow; // data value to show (for listings)
2c24602be78f 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 int dsize; // set to 1 for 8 bit dshow value
2c24602be78f 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 int isbrpt; // set to 1 if this line is a branch point
2c24602be78f 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 struct symtabe *dptr; // symbol value to display
49
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 2
diff changeset
265
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 2
diff changeset
266 int noexpand_start; // start of a no-expand block
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 2
diff changeset
267 int noexpand_end; // end of a no-expand block
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 211
diff changeset
268 int hideline; // set if we're going to hide this line on output
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
269 };
2c24602be78f 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
2c24602be78f 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 enum
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
272 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
273 symbol_flag_set = 1, // symbol was used with "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
274 symbol_flag_nocheck = 2, // do not check symbol characters
81
428068681cbf Added nolist pragma to suppress listing output of non-code generating lines
Lost Wizard (lost@starbug3)
parents: 73
diff changeset
275 symbol_flag_nolist = 4, // no not show symbol in symbol table
207
07e1fac76321 Added pragma to allow non case sensitive symbols
William Astle <lost@l-w.ca>
parents: 206
diff changeset
276 symbol_flag_nocase = 8, // do not match case of symbol
0
2c24602be78f 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 symbol_flag_none = 0 // no flags
2c24602be78f 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 };
2c24602be78f 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 struct symtabe
2c24602be78f 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 {
2c24602be78f 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 char *symbol; // the name of the symbol
2c24602be78f 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 context; // symbol context (-1 for global)
2c24602be78f 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 int version; // version of the symbol (for "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
285 int flags; // flags for the symbol
2c24602be78f 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 sectiontab_t *section; // section the symbol is defined in
2c24602be78f 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 lw_expr_t value; // symbol value
195
17bd59f045af Changed symbol table to use a binary tree.
William Astle <lost@l-w.ca>
parents: 156
diff changeset
288 struct symtabe *left; // left subtree pointer
17bd59f045af Changed symbol table to use a binary tree.
William Astle <lost@l-w.ca>
parents: 156
diff changeset
289 struct symtabe *right; // right subtree pointer
17bd59f045af Changed symbol table to use a binary tree.
William Astle <lost@l-w.ca>
parents: 156
diff changeset
290 struct symtabe *nextver; // next lower version
0
2c24602be78f 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 typedef struct
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
294 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
295 struct symtabe *head; // start of symbol table
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
296 } symtab_t;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
297
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
298 typedef struct macrotab_s macrotab_t;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
299 struct macrotab_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
300 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
301 char *name; // name of macro
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
302 char **lines; // macro lines
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
303 int numlines; // number lines in macro
49
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 2
diff changeset
304 int flags; // flags for the macro
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
305 macrotab_t *next; // next macro in list
222
03f7192fcd20 Add --unicorns option for IDE integration
William Astle <lost@l-w.ca>
parents: 219
diff changeset
306 line_t *definedat; // the line where the macro definition starts
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
307 };
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
308
49
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 2
diff changeset
309 enum
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 2
diff changeset
310 {
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 2
diff changeset
311 macro_noexpand = 1 // set to not expland the macro by default in listing
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 2
diff changeset
312 };
bd8b3fbd1e28 Added ability to flag macros as "noexpand" so they are not expanded in the listing
lost@l-w.ca
parents: 2
diff changeset
313
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
314 typedef struct structtab_s structtab_t;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
315 typedef struct structtab_field_s structtab_field_t;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
316
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
317 struct structtab_field_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
318 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
319 char *name; // structure field name - NULL for anonymous
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
320 int size; // structure field size
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
321 structtab_t *substruct; // sub structure if there is one
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
322 structtab_field_t *next; // next field entry
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
323 };
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
324
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
325 struct structtab_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
326 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
327 char *name; // name of structure
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
328 int size; // number of bytes taken by struct
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
329 structtab_field_t *fields; // fields in the structure
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
330 structtab_t *next; // next structure
223
211fc8038b8d More unicorn stuff - structs and macros
William Astle <lost@l-w.ca>
parents: 222
diff changeset
331 line_t *definedat; // line where structure is defined
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
332 };
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
333
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
334 struct asmstate_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
335 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
336 int output_format; // output format
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
337 int debug_level; // level of debugging requested
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
338 FILE *debug_file; // FILE * to output debug messages to
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
339 int flags; // assembly flags
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
340 int pragmas; // pragmas currently in effect
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
341 int errorcount; // number of errors encountered
209
52d9dd71f555 Make warning actually work.
William Astle <lost@l-w.ca>
parents: 207
diff changeset
342 int warningcount; // number of warnings issued
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
343 int inmacro; // are we in a macro?
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
344 int instruct; // are w in a structure?
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
345 int skipcond; // skipping a condition?
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
346 int skipcount; // depth of "skipping"
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
347 int skipmacro; // are we skipping in a macro?
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
348 int endseen; // have we seen an "end" pseudo?
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
349 int execaddr; // address from "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
350 int inmod; // inside an os9 module?
210
5d969517db74 Added condundefzero pragma
William Astle <lost@l-w.ca>
parents: 209
diff changeset
351 int undefzero; // used for handling "condundefzero"
211
6f2e18f1fe67 Improve autobranchlength pragma
William Astle <lost@l-w.ca>
parents: 210
diff changeset
352 int pretendmax; // set if we need to pretend the instruction is max length
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
353 unsigned char crc[3]; // crc accumulator
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
354 int badsymerr; // throw error on undef sym if 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
355
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
356 line_t *line_head; // start of lines list
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
357 line_t *line_tail; // tail of lines list
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
358
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
359 line_t *cl; // current line pointer
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
360
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
361 sectiontab_t *csect; // current section
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
362
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
363 int context; // the current "context"
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
364 int nextcontext; // the next available context
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
365
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
366 symtab_t symtab; // meta data for the symbol table
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
367 macrotab_t *macros; // macro table
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
368 sectiontab_t *sections; // section table
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
369 exportlist_t *exportlist; // list of exported symbols
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
370 importlist_t *importlist; // list of imported symbols
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
371 char *list_file; // name of file to list to
365
3f8abaac214c Add map file output and option to suppress local symbols in listings
William Astle <lost@l-w.ca>
parents: 361
diff changeset
372 char *map_file; // name of map file
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
373 char *output_file; // output file name
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
374 lw_stringlist_t input_files; // files to assemble
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
375 void *input_data; // opaque data used by the input system
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
376 lw_stringlist_t include_list; // include paths
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
377 lw_stack_t file_dir; // stack of the "current file" dir
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
378 lw_stack_t includelist;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
379
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
380 structtab_t *structs; // defined structures
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
381 structtab_t *cstruct; // current structure
61
ccaecdff3fc2 Make structure definitions not affect current assembly address and fix up cosmetic offset display in listings
lost@l-w.ca
parents: 53
diff changeset
382 lw_expr_t savedaddr; // old address counter before struct started
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
383 int exportcheck; // set if we need to collapse out the section base to 0
70
ceab04fd2969 Fixed premature installation of external reference under UNDEFEXTERN pragma; should not resolve to external references until after the initial parsing pass
lost@l-w.ca
parents: 61
diff changeset
384 int passno; // set to the current pass number
219
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 211
diff changeset
385 int preprocess; // set if we are prepocessing
afd50d6b4113 Add --preprocess option
William Astle <lost@l-w.ca>
parents: 211
diff changeset
386 int fileerr; // flags error opening file
366
433dbc18fb41 Make byte overflow detection for 8 bit immediate not fail with COM operator
William Astle <lost@l-w.ca>
parents: 365
diff changeset
387 int exprwidth; // the bit width of the expression being evaluated
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
388 };
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
389
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
390 struct symtabe *register_symbol(asmstate_t *as, line_t *cl, char *sym, lw_expr_t value, int flags);
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
391 struct symtabe *lookup_symbol(asmstate_t *as, line_t *cl, char *sym);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
392
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
393 void lwasm_register_error(asmstate_t *as, line_t *cl, lwasm_errorcode_t err);
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
394 void lwasm_register_error2(asmstate_t *as, line_t *cl, lwasm_errorcode_t err, const char* fmt, ...);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
395
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
396 int lwasm_next_context(asmstate_t *as);
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
397 void lwasm_emit(line_t *cl, int byte);
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
398 void lwasm_emitop(line_t *cl, int opc);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
399
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
400 void lwasm_save_expr(line_t *cl, int id, lw_expr_t expr);
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
401 lw_expr_t lwasm_fetch_expr(line_t *cl, int id);
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
402 lw_expr_t lwasm_parse_expr(asmstate_t *as, char **p);
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
403 int lwasm_emitexpr(line_t *cl, lw_expr_t expr, int 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
404
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
405 void skip_operand(char **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
406
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
407 int lwasm_lookupreg2(const char *rlist, char **p);
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
408 int lwasm_lookupreg3(const char *rlist, char **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
409
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
410 void lwasm_show_errors(asmstate_t *as);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
411
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
412 int lwasm_reduce_expr(asmstate_t *as, lw_expr_t expr);
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
413
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
414 lw_expr_t lwasm_parse_cond(asmstate_t *as, char **p);
241
d0e9dbe9afbe Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents: 226
diff changeset
415
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
416 int lwasm_calculate_range(asmstate_t *as, lw_expr_t expr, int *min, int *max);
336
30b2bad9b5eb Factor some code for simplifying lines so it can be reused
William Astle <lost@l-w.ca>
parents: 333
diff changeset
417
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
418 void lwasm_reduce_line_exprs(line_t *cl);
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
419
338
5d401d1eb3e9 Allow disabling debugging messages.
William Astle <lost@l-w.ca>
parents: 336
diff changeset
420 #ifdef LWASM_NODEBUG
5d401d1eb3e9 Allow disabling debugging messages.
William Astle <lost@l-w.ca>
parents: 336
diff changeset
421 #define debug_message(...)
5d401d1eb3e9 Allow disabling debugging messages.
William Astle <lost@l-w.ca>
parents: 336
diff changeset
422 #define dump_state(...)
5d401d1eb3e9 Allow disabling debugging messages.
William Astle <lost@l-w.ca>
parents: 336
diff changeset
423 #else
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
424 void real_debug_message(asmstate_t *as, int level, const char *fmt, ...);
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 370
diff changeset
425 void dump_state(asmstate_t *as);
0
2c24602be78f 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
338
5d401d1eb3e9 Allow disabling debugging messages.
William Astle <lost@l-w.ca>
parents: 336
diff changeset
427 #define debug_message(as,level,...) do { asmstate_t *ras = (as); int rlevel = (level); if (ras->debug_level >= rlevel) { real_debug_message(ras, rlevel, __VA_ARGS__); } } while (0)
5d401d1eb3e9 Allow disabling debugging messages.
William Astle <lost@l-w.ca>
parents: 336
diff changeset
428 #endif
0
2c24602be78f 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 #define OPLEN(op) (((op)>0xFF)?2:1)
101
ed7f970f3688 Added --define= option to predfine a symbol for assembly
lost@l-w.ca
parents: 81
diff changeset
431 #define CURPRAGMA(l,p) (((l) && ((l)->pragmas & (p))) ? 1 : 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
432
2c24602be78f 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 #endif /* ___lwasm_h_seen___ */