Mercurial > hg > index.cgi
annotate lwasm/insn_gen.c @ 472:e97f9a302c6a
Add emuext pragma and associated instructions.
This provides two emulator specific instructions ("log" and "debug") enabled
by the "emuext" pragma.
This is from a patch provided by tim Lindner <tlindner@macmess.org>. From
Tim's submission:
----
I stole the whole patch from Erik Gavriluk. I hope he doesn't mind. :)
The two instructions are "debug" and "log". They are enabled with
pragmas. I also added them to the manual.
Hopefully all is well.
----
Said Erik Gavriluk <erik@bombfactory.com> in response:
...happy to see them picked up in mainline (if you choose to do so)....
author | William Astle <lost@l-w.ca> |
---|---|
date | Thu, 01 Nov 2018 23:00:00 -0600 |
parents | 2c1c5dd84024 |
children | eac8f5f0867d |
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 insn_gen.c, Copyright © 2009 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
|
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 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
|
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 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
|
7 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
|
8 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
|
9 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
|
10 |
2c24602be78f
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 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
|
12 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
|
13 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
|
14 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
|
15 |
2c24602be78f
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 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
|
17 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
|
18 |
2c24602be78f
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 Contains code for parsing general addressing modes (IMM+DIR+EXT+IND) |
2c24602be78f
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 #include <ctype.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
|
23 #include <stdlib.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
|
24 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
25 #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
|
26 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
27 #include "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
|
28 #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
|
29 |
374 | 30 void insn_indexed_parse_aux(asmstate_t *as, line_t *l, char **p); |
31 void insn_indexed_resolve_aux(asmstate_t *as, line_t *l, int force, int elen); | |
32 void insn_indexed_emit_aux(asmstate_t *as, line_t *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
|
33 |
374 | 34 void insn_parse_indexed_aux(asmstate_t *as, line_t *l, char **p); |
35 void insn_resolve_indexed_aux(asmstate_t *as, line_t *l, int force, int elen); | |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
36 |
0
2c24602be78f
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 // "extra" is required due to the way OIM, EIM, TIM, and AIM work |
136
b78b2f1e011e
Fixed additional instruction length problems with logic/memory operations
lost@l-w.ca
parents:
2
diff
changeset
|
38 void insn_parse_gen_aux(asmstate_t *as, line_t *l, char **p, int elen) |
0
2c24602be78f
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 { |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
40 char *optr2; |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
41 int v1, tv; |
0
2c24602be78f
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 lw_expr_t s; |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
43 |
255
67acad9db5b3
Fix crash when no operand is present
William Astle <lost@l-w.ca>
parents:
242
diff
changeset
|
44 if (!**p) |
67acad9db5b3
Fix crash when no operand is present
William Astle <lost@l-w.ca>
parents:
242
diff
changeset
|
45 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
366
diff
changeset
|
46 lwasm_register_error(as, l, E_OPERAND_BAD); |
255
67acad9db5b3
Fix crash when no operand is present
William Astle <lost@l-w.ca>
parents:
242
diff
changeset
|
47 return; |
67acad9db5b3
Fix crash when no operand is present
William Astle <lost@l-w.ca>
parents:
242
diff
changeset
|
48 } |
67acad9db5b3
Fix crash when no operand is present
William Astle <lost@l-w.ca>
parents:
242
diff
changeset
|
49 |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
50 /* this is the easy case - start it [ or , means indexed */ |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
51 if (**p == ',' || **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
|
52 { |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
53 indexed: |
0
2c24602be78f
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 l -> lint = -1; |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
55 l -> lint2 = 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
|
56 insn_parse_indexed_aux(as, l, p); |
241
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
57 l -> minlen = OPLEN(instab[l -> insn].ops[1]) + 1 + elen; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
58 l -> maxlen = OPLEN(instab[l -> insn].ops[1]) + 3 + elen; |
0
2c24602be78f
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 goto out; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
60 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
61 |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
62 /* we have to parse the first expression to find if we have a comma after it */ |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
63 optr2 = *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
|
64 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
|
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 (*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
|
67 l -> lint2 = 0; |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
68 if (**p == '<') |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
69 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
70 *p = optr2; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
71 goto indexed; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
72 } |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
73 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
74 // for compatibility with asxxxx |
2c24602be78f
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 // * followed by a digit, alpha, or _, or ., or ?, or another * is "f8" |
2c24602be78f
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 else 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
|
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 tv = *(*p + 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
|
79 if (isdigit(tv) || isalpha(tv) || tv == '_' || tv == '.' || tv == '?' || tv == '@' || tv == '*' || tv == '+' || tv == '-') |
2c24602be78f
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 { |
2c24602be78f
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 l -> lint2 = 0; |
2c24602be78f
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 (*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
|
83 } |
2c24602be78f
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 } |
2c24602be78f
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 else 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
|
86 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
87 (*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
|
88 l -> lint2 = 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
|
89 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
90 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
|
91 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
92 l -> lint2 = -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
|
93 } |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
94 lwasm_skip_to_next_token(l, p); |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
95 |
0
2c24602be78f
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 s = lwasm_parse_expr(as, p); |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
97 |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
98 if (**p == ',') |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
99 { |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
100 /* we have an indexed mode here - reset and transfer control to indexing mode */ |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
101 lw_expr_destroy(s); |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
102 *p = optr2; |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
103 goto indexed; |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
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 (!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
|
106 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
366
diff
changeset
|
107 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
|
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 lwasm_save_expr(l, 0, 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
|
112 |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
113 l -> minlen = OPLEN(instab[l -> insn].ops[0]) + 1 + elen; |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
389
diff
changeset
|
114 l -> maxlen = OPLEN(instab[l -> insn].ops[2]) + 2 + elen; |
0
2c24602be78f
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 if (as -> output_format == OUTPUT_OBJ && l -> lint2 == -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
|
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 l -> lint2 = 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
|
118 goto out; |
2c24602be78f
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 } |
2c24602be78f
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 |
2c24602be78f
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 if (l -> lint2 != -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
|
122 goto out; |
2c24602be78f
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 // if we have a constant now, figure out dp vs nondp |
2c24602be78f
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 if (lw_expr_istype(s, 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
|
126 { |
389
2d9b7ae6c329
Throw error if address overflows in extended mode
William Astle <lost@l-w.ca>
parents:
380
diff
changeset
|
127 if (s -> value > 0xffff) lwasm_register_error(as, l, E_BYTE_OVERFLOW); |
2d9b7ae6c329
Throw error if address overflows in extended mode
William Astle <lost@l-w.ca>
parents:
380
diff
changeset
|
128 |
0
2c24602be78f
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 v1 = lw_expr_intval(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
|
130 if (((v1 >> 8) & 0xff) == (l -> dpval & 0xff)) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
131 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
132 l -> lint2 = 0; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
133 goto out; |
2c24602be78f
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 } |
2c24602be78f
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 l -> lint2 = 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
|
136 } |
241
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
137 else |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
138 { |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
139 int min; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
140 int max; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
141 |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
142 if (lwasm_calculate_range(as, s, &min, &max) == 0) |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
143 { |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
144 // fprintf(stderr, "range (P) %d...%d for %s\n", min, max, lw_expr_print(s)); |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
145 if (min > max) |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
146 { |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
147 // we don't know what to do in this case so don't do anything |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
148 goto out; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
149 } |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
150 min = (min >> 8) & 0xff; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
151 max = (max >> 8) & 0xff; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
152 if ((l -> dpval & 0xff) < min || (l -> dpval & 0xff) > max) |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
153 { |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
154 l -> lint2 = 2; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
155 goto out; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
156 } |
242
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
157 if (min == max && (l -> dpval & 0xff) == min) |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
158 { |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
159 l -> lint2 = 0; |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
160 goto out; |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
161 } |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
162 // if here, we don't know if the value is in the DP or not |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
163 { |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
164 l -> lint2 = -1; |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
165 goto out; |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
166 } |
241
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
167 } |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
168 } |
0
2c24602be78f
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 out: |
2c24602be78f
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 if (l -> lint2 != -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
|
172 { |
2c24602be78f
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 if (l -> lint2 == 0) |
2c24602be78f
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 { |
136
b78b2f1e011e
Fixed additional instruction length problems with logic/memory operations
lost@l-w.ca
parents:
2
diff
changeset
|
175 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1 + elen; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
176 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
177 else if (l -> lint2 == 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
|
178 { |
136
b78b2f1e011e
Fixed additional instruction length problems with logic/memory operations
lost@l-w.ca
parents:
2
diff
changeset
|
179 l -> len = OPLEN(instab[l -> insn].ops[2]) + 2 + elen; |
0
2c24602be78f
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 else if (l -> lint2 == 1 && 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
|
182 { |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
183 if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
184 l -> len = OPLEN(instab[l -> insn].ops[1]) + 1 + elen; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
185 else |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
186 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1 + elen; |
0
2c24602be78f
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 } |
2c24602be78f
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 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
190 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
191 void insn_resolve_gen_aux(asmstate_t *as, line_t *l, int force, int elen) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
192 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
193 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
|
194 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
195 if (l -> lint2 == 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
|
196 { |
2c24602be78f
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 // indexed |
2c24602be78f
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 insn_resolve_indexed_aux(as, l, force, elen); |
2c24602be78f
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 goto out; |
2c24602be78f
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 } |
2c24602be78f
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 if (l -> lint2 != -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
|
203 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
|
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 e = lwasm_fetch_expr(l, 0); |
241
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
206 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
|
207 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
|
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 int v; |
2c24602be78f
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 v = 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
|
212 |
2c24602be78f
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 if (((v >> 8) & 0xff) == (l -> dpval & 0xff)) |
2c24602be78f
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 l -> lint2 = 0; |
2c24602be78f
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 goto out; |
2c24602be78f
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 } |
2c24602be78f
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 l -> lint2 = 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
|
219 goto out; |
2c24602be78f
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 } |
241
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
221 else |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
222 { |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
223 int min; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
224 int max; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
225 |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
226 if (lwasm_calculate_range(as, e, &min, &max) == 0) |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
227 { |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
228 // fprintf(stderr, "range (R) %d...%d for %s\n", min, max, lw_expr_print(e)); |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
229 if (min > max) |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
230 { |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
231 // we don't know what to do in this case so don't do anything |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
232 goto out; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
233 } |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
234 min = (min >> 8) & 0xff; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
235 max = (max >> 8) & 0xff; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
236 if ((l -> dpval & 0xff) < min || (l -> dpval & 0xff) > max) |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
237 { |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
238 l -> lint2 = 2; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
239 goto out; |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
240 } |
242
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
241 if (min == max && (l -> dpval & 0xff) == min) |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
242 { |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
243 l -> lint2 = 0; |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
244 goto out; |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
245 } |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
246 // if here, we don't know if the value is in the DP or not |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
247 { |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
248 l -> lint2 = -1; |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
249 goto out; |
ea092ebc5323
Fix thinko with algorithm improvement.
William Astle <lost@l-w.ca>
parents:
241
diff
changeset
|
250 } |
241
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
251 } |
d0e9dbe9afbe
Add new heuristic for resolving instruction sizes.
William Astle <lost@l-w.ca>
parents:
177
diff
changeset
|
252 } |
0
2c24602be78f
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 |
2c24602be78f
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 if (force) |
2c24602be78f
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 { |
2c24602be78f
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 l -> lint2 = 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
|
257 } |
2c24602be78f
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 |
2c24602be78f
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 out: |
2c24602be78f
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 if (l -> lint2 != -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
|
261 { |
2c24602be78f
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 if (l -> lint2 == 0) |
2c24602be78f
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 { |
136
b78b2f1e011e
Fixed additional instruction length problems with logic/memory operations
lost@l-w.ca
parents:
2
diff
changeset
|
264 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1 + elen; |
0
2c24602be78f
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 else if (l -> lint2 == 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
|
267 { |
136
b78b2f1e011e
Fixed additional instruction length problems with logic/memory operations
lost@l-w.ca
parents:
2
diff
changeset
|
268 l -> len = OPLEN(instab[l -> insn].ops[2]) + 2 + elen; |
0
2c24602be78f
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 else if (l -> lint2 == 1 && 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
|
271 { |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
272 if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
273 l -> len = OPLEN(instab[l -> insn].ops[1]) + 1 + elen; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
274 else |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
275 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 1 + elen; |
0
2c24602be78f
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 } |
2c24602be78f
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 void insn_emit_gen_aux(asmstate_t *as, line_t *l, int extra) |
2c24602be78f
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 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
|
283 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
284 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
|
285 lwasm_emitop(l, instab[l -> insn].ops[l -> lint2]); |
2c24602be78f
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 if (extra != -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
|
288 lwasm_emit(l, extra); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
289 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
290 if (l -> lint2 == 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
|
291 { |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
292 if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
293 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
294 int offs; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
295 if (lw_expr_istype(e, lw_expr_type_int)) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
296 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
297 offs = lw_expr_intval(e); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
298 if ((offs >= -16 && offs <= 15) || offs >= 0xFFF0) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
299 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
300 l -> pb |= offs & 0x1f; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
301 l -> lint = 0; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
302 } |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
303 else |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
304 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
305 lwasm_register_error(as, l, E_BYTE_OVERFLOW); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
306 } |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
307 } |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
308 else |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
309 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
310 lwasm_register_error(as, l, E_EXPRESSION_NOT_RESOLVED); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
311 } |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
312 } |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
313 lwasm_emit(l, l -> pb); |
2c24602be78f
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 if (l -> lint > 0) |
283
210d261a614d
Make byte overflow detection for indexing work better
William Astle <lost@l-w.ca>
parents:
255
diff
changeset
|
315 { |
210d261a614d
Make byte overflow detection for indexing work better
William Astle <lost@l-w.ca>
parents:
255
diff
changeset
|
316 int i; |
210d261a614d
Make byte overflow detection for indexing work better
William Astle <lost@l-w.ca>
parents:
255
diff
changeset
|
317 i = lw_expr_intval(e); |
210d261a614d
Make byte overflow detection for indexing work better
William Astle <lost@l-w.ca>
parents:
255
diff
changeset
|
318 if (l -> lint == 1) |
210d261a614d
Make byte overflow detection for indexing work better
William Astle <lost@l-w.ca>
parents:
255
diff
changeset
|
319 { |
210d261a614d
Make byte overflow detection for indexing work better
William Astle <lost@l-w.ca>
parents:
255
diff
changeset
|
320 if (i < -128 || i > 127) |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
366
diff
changeset
|
321 lwasm_register_error(as, l, E_BYTE_OVERFLOW); |
283
210d261a614d
Make byte overflow detection for indexing work better
William Astle <lost@l-w.ca>
parents:
255
diff
changeset
|
322 } |
458
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
402
diff
changeset
|
323 else if (l -> lint == 2 && lw_expr_istype(e, lw_expr_type_int) && CURPRAGMA(l, PRAGMA_OPERANDSIZE)) |
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
402
diff
changeset
|
324 { |
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
402
diff
changeset
|
325 if (l -> pb != 0xAF && l -> pb != 0xB0) |
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
402
diff
changeset
|
326 { |
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
402
diff
changeset
|
327 if ((i >= -128 && i <= 127) || i >= 0xFF80) |
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
402
diff
changeset
|
328 { |
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
402
diff
changeset
|
329 lwasm_register_error(as, l, W_OPERAND_SIZE); |
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
402
diff
changeset
|
330 |
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
402
diff
changeset
|
331 } |
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
402
diff
changeset
|
332 } |
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
402
diff
changeset
|
333 } |
0
2c24602be78f
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 lwasm_emitexpr(l, e, l -> lint); |
283
210d261a614d
Make byte overflow detection for indexing work better
William Astle <lost@l-w.ca>
parents:
255
diff
changeset
|
335 } |
376 | 336 |
337 l -> cycle_adj = lwasm_cycle_calc_ind(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
|
338 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
|
339 } |
2c24602be78f
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 |
2c24602be78f
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 if (l -> lint2 == 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
|
342 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
|
343 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
|
344 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
|
345 } |
2c24602be78f
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 |
2c24602be78f
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 // the various insn_gen? functions have an immediate mode of ? bits |
2c24602be78f
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 PARSEFUNC(insn_parse_gen0) |
2c24602be78f
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 { |
2c24602be78f
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 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
|
351 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
366
diff
changeset
|
352 lwasm_register_error(as, l, E_IMMEDIATE_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
|
353 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
|
354 } |
2c24602be78f
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 // handle non-immediate |
136
b78b2f1e011e
Fixed additional instruction length problems with logic/memory operations
lost@l-w.ca
parents:
2
diff
changeset
|
357 insn_parse_gen_aux(as, l, p, 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
|
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 |
2c24602be78f
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 RESOLVEFUNC(insn_resolve_gen0) |
2c24602be78f
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 { |
2c24602be78f
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 if (l -> len != -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
|
363 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
|
364 |
2c24602be78f
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 // handle non-immediate |
2c24602be78f
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 insn_resolve_gen_aux(as, l, force, 0); |
2c24602be78f
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 } |
2c24602be78f
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 |
2c24602be78f
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 EMITFUNC(insn_emit_gen0) |
2c24602be78f
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 { |
2c24602be78f
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 insn_emit_gen_aux(as, 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
|
372 } |
2c24602be78f
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 |
2c24602be78f
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 PARSEFUNC(insn_parse_gen8) |
2c24602be78f
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 { |
380
17fcd0c3ee45
Allow multibyte ascii constants in m80ext mode
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
376 l -> genmode = 8; |
0
2c24602be78f
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 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
|
378 { |
2c24602be78f
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 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
|
380 |
2c24602be78f
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 (*p)++; |
366
433dbc18fb41
Make byte overflow detection for 8 bit immediate not fail with COM operator
William Astle <lost@l-w.ca>
parents:
355
diff
changeset
|
382 as -> exprwidth = 8; |
0
2c24602be78f
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 e = lwasm_parse_expr(as, p); |
366
433dbc18fb41
Make byte overflow detection for 8 bit immediate not fail with COM operator
William Astle <lost@l-w.ca>
parents:
355
diff
changeset
|
384 as -> exprwidth = 16; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
385 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
|
386 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
366
diff
changeset
|
387 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
|
388 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
|
389 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
390 l -> len = OPLEN(instab[l -> insn].ops[3]) + 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
|
391 l -> lint2 = 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
|
392 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
|
393 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
|
394 } |
2c24602be78f
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 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
396 // handle non-immediate |
136
b78b2f1e011e
Fixed additional instruction length problems with logic/memory operations
lost@l-w.ca
parents:
2
diff
changeset
|
397 insn_parse_gen_aux(as, l, p, 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
|
398 if (l -> lint2 != -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
|
399 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
400 if (l -> lint2 == 0) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
401 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
402 l -> len = OPLEN(instab[l -> insn].ops[0]) + 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
|
403 } |
2c24602be78f
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 else if (l -> lint2 == 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
|
405 { |
2c24602be78f
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 l -> len = OPLEN(instab[l -> insn].ops[2]) + 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
|
407 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
408 else if (l -> lint2 == 1 && 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
|
409 { |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
410 if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
411 l -> len = OPLEN(instab[l -> insn].ops[1]) + 1; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
412 else |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
413 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 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
|
414 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
415 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
416 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
417 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
418 RESOLVEFUNC(insn_resolve_gen8) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
419 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
420 if (l -> len != -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
|
421 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
|
422 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
423 // handle non-immediate |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
424 insn_resolve_gen_aux(as, l, force, 0); |
2c24602be78f
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 } |
2c24602be78f
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 EMITFUNC(insn_emit_gen8) |
2c24602be78f
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 { |
2c24602be78f
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 if (l -> lint2 == 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
|
430 { |
2c24602be78f
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 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
|
432 e = lwasm_fetch_expr(l, 0); |
355
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
433 if (lw_expr_istype(e, lw_expr_type_int)) |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
434 { |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
435 int i; |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
436 i = lw_expr_intval(e); |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
437 if (i < -128 || i > 255) |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
438 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
366
diff
changeset
|
439 lwasm_register_error(as, l, E_BYTE_OVERFLOW); |
355
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
440 } |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
441 } |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
442 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
443 lwasm_emitop(l, instab[l -> insn].ops[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
|
444 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
|
445 return; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
446 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
447 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
448 insn_emit_gen_aux(as, 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
|
449 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
450 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
451 PARSEFUNC(insn_parse_gen16) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
452 { |
380
17fcd0c3ee45
Allow multibyte ascii constants in m80ext mode
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
453 l -> genmode = 16; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
454 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
|
455 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
456 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
|
457 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
458 (*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
|
459 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
|
460 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
|
461 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
366
diff
changeset
|
462 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
|
463 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
|
464 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
465 l -> len = OPLEN(instab[l -> insn].ops[3]) + 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
|
466 l -> lint2 = 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
|
467 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
|
468 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
|
469 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
470 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
471 // handle non-immediate |
136
b78b2f1e011e
Fixed additional instruction length problems with logic/memory operations
lost@l-w.ca
parents:
2
diff
changeset
|
472 insn_parse_gen_aux(as, l, p, 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
|
473 if (l -> lint2 != -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
|
474 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
475 if (l -> lint2 == 0) |
2c24602be78f
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 l -> len = OPLEN(instab[l -> insn].ops[0]) + 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
|
478 } |
2c24602be78f
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 else if (l -> lint2 == 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
|
480 { |
2c24602be78f
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 l -> len = OPLEN(instab[l -> insn].ops[2]) + 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
|
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 else if (l -> lint2 == 1 && 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
|
484 { |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
485 if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
486 l -> len = OPLEN(instab[l -> insn].ops[1]) + 1; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
487 else |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
488 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 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
|
489 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
490 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
491 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
492 |
2c24602be78f
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 RESOLVEFUNC(insn_resolve_gen16) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
494 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
495 if (l -> len != -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
|
496 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
|
497 |
2c24602be78f
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 // handle non-immediate |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
499 insn_resolve_gen_aux(as, l, force, 0); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
500 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
501 |
2c24602be78f
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 EMITFUNC(insn_emit_gen16) |
2c24602be78f
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 { |
2c24602be78f
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 if (l -> lint2 == 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
|
505 { |
2c24602be78f
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 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
|
507 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
|
508 lwasm_emitop(l, instab[l -> insn].ops[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
|
509 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
|
510 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
|
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 |
2c24602be78f
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 insn_emit_gen_aux(as, 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
|
514 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
515 |
2c24602be78f
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 PARSEFUNC(insn_parse_gen32) |
2c24602be78f
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 { |
380
17fcd0c3ee45
Allow multibyte ascii constants in m80ext mode
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
518 l -> genmode = 32; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
519 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
|
520 { |
2c24602be78f
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 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
|
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 (*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 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
|
525 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
|
526 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
366
diff
changeset
|
527 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
|
528 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
|
529 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
530 l -> len = OPLEN(instab[l -> insn].ops[3]) + 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
|
531 l -> lint2 = 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
|
532 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
|
533 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
|
534 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
535 |
2c24602be78f
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 // handle non-immediate |
136
b78b2f1e011e
Fixed additional instruction length problems with logic/memory operations
lost@l-w.ca
parents:
2
diff
changeset
|
537 insn_parse_gen_aux(as, l, p, 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
|
538 if (l -> lint2 != -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
|
539 { |
2c24602be78f
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 if (l -> lint2 == 0) |
2c24602be78f
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 { |
2c24602be78f
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 l -> len = OPLEN(instab[l -> insn].ops[0]) + 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
|
543 } |
2c24602be78f
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 else if (l -> lint2 == 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
|
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 l -> len = OPLEN(instab[l -> insn].ops[2]) + 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
|
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 else if (l -> lint2 == 1 && 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
|
549 { |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
550 if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
551 l -> len = OPLEN(instab[l -> insn].ops[1]) + 1; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
552 else |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
458
diff
changeset
|
553 l -> len = OPLEN(instab[l -> insn].ops[1]) + l -> lint + 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
|
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 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
557 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
558 RESOLVEFUNC(insn_resolve_gen32) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
559 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
560 if (l -> len != -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
|
561 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
|
562 |
2c24602be78f
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 // handle non-immediate |
2c24602be78f
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 insn_resolve_gen_aux(as, l, force, 0); |
2c24602be78f
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 |
2c24602be78f
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 EMITFUNC(insn_emit_gen32) |
2c24602be78f
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 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
569 if (l -> lint2 == 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
|
570 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
571 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
|
572 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
|
573 lwasm_emitop(l, instab[l -> insn].ops[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
|
574 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
|
575 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
|
576 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
577 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
578 insn_emit_gen_aux(as, 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
|
579 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
580 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
581 PARSEFUNC(insn_parse_imm8) |
2c24602be78f
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 { |
2c24602be78f
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 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
|
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 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
|
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 (*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
|
588 |
366
433dbc18fb41
Make byte overflow detection for 8 bit immediate not fail with COM operator
William Astle <lost@l-w.ca>
parents:
355
diff
changeset
|
589 as -> exprwidth = 8; |
0
2c24602be78f
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 e = lwasm_parse_expr(as, p); |
366
433dbc18fb41
Make byte overflow detection for 8 bit immediate not fail with COM operator
William Astle <lost@l-w.ca>
parents:
355
diff
changeset
|
591 as -> exprwidth = 16; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
592 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
|
593 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
366
diff
changeset
|
594 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
|
595 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
|
596 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
597 l -> len = OPLEN(instab[l -> insn].ops[0]) + 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
|
598 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
|
599 } |
177
f8b07153abc4
Make 'imm8' instructions actually complain about a bad operand if no # is present
lost@l-w.ca
parents:
136
diff
changeset
|
600 else |
f8b07153abc4
Make 'imm8' instructions actually complain about a bad operand if no # is present
lost@l-w.ca
parents:
136
diff
changeset
|
601 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
366
diff
changeset
|
602 lwasm_register_error(as, l, E_OPERAND_BAD); |
177
f8b07153abc4
Make 'imm8' instructions actually complain about a bad operand if no # is present
lost@l-w.ca
parents:
136
diff
changeset
|
603 } |
0
2c24602be78f
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 |
2c24602be78f
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 EMITFUNC(insn_emit_imm8) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
607 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
608 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
|
609 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
610 lwasm_emitop(l, instab[l -> insn].ops[0]); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
611 e = lwasm_fetch_expr(l, 0); |
355
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
612 if (lw_expr_istype(e, lw_expr_type_int)) |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
613 { |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
614 int i; |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
615 i = lw_expr_intval(e); |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
616 if (i < -128 || i > 255) |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
617 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
366
diff
changeset
|
618 lwasm_register_error(as, l, E_BYTE_OVERFLOW); |
355
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
619 } |
3afb809c7add
Make 8 bit immediate operands flag a byte overflow if not in 8 bit range.
William Astle <lost@l-w.ca>
parents:
283
diff
changeset
|
620 } |
0
2c24602be78f
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 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
|
622 } |