annotate lwasm/insn_indexed.c @ 465:7370a67caf7e

Fix really dumb code generation error The previous commit caused some unforuntate code generation errors. Fixed those. Also made the heuristic for guessing that 8 bit is okay for PCR allow a fudge factor so that some corner cases are much less likely to explode.
author William Astle <lost@l-w.ca>
date Wed, 28 Feb 2018 23:31:17 -0700
parents 9134f6426c57
children 51bed8c8dc53
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1 /*
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
2 insn_indexed.c
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
3 Copyright © 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
4
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
5 This file is part of LWASM.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
6
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
10 version.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
11
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
15 more details.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
16
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
19 */
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
20
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
21 /*
2c24602be78f 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 for handling indexed mode instructions
2c24602be78f 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 */
2c24602be78f 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 <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
26 #include <string.h>
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
27
2c24602be78f 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 <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
29
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
30 #include "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
31 #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
32
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
33 /*
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
34 l -> lint: size of operand (0, 1, 2, -1 if not determined)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
35 l -> pb: actual post byte (from "resolve" stage) or info passed
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
36 forward to the resolve stage (if l -> line is -1); 0x80 is indir
2c24602be78f 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 bits 0-2 are register number
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
38 */
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
39 void insn_parse_indexed_aux(asmstate_t *as, line_t *l, char **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
40 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
41 static const char *regs9 = "X Y U S PCRPC ";
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
42 static const char *regs = "X Y U S W PCRPC ";
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
43 int i, rn;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
44 int indir = 0;
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
45 int f0 = 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
46 const char *reglist;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
47 lw_expr_t e;
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
48 char *tstr;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
49
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
50
367
c6d2a1f54e0c Change processor target variations to pragmas.
William Astle <lost@l-w.ca>
parents: 334
diff changeset
51 if (CURPRAGMA(l, PRAGMA_6809))
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
52 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
53 reglist = regs9;
2c24602be78f 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 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
55 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
56 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
57 reglist = regs;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
58 }
2c24602be78f 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 // is it indirect?
2c24602be78f 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 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
61 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
62 indir = 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
63 (*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
64 }
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
65 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: 376
diff changeset
66 if (**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
67 {
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
68 int incdec = 0;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
69 /* we have a pre-dec, post-inc, or no offset mode here */
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
70 (*p)++;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
71 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: 376
diff changeset
72 if (**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
73 {
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
74 incdec = -1;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
75 (*p)++;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
76 if (**p == '-')
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
77 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
78 incdec = -2;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
79 (*p)++;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
80 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
81 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: 376
diff changeset
82 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
83 /* allowed registers: X, Y, U, S, or W (6309) */
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
84 switch (**p)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
85 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
86 case 'x':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
87 case 'X':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
88 rn = 0;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
89 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
90
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
91 case 'y':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
92 case 'Y':
0
2c24602be78f 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 rn = 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
94 break;
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
95
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
96 case 'u':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
97 case 'U':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
98 rn = 2;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
99 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
100
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
101 case 's':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
102 case 'S':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
103 rn = 3;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
104 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
105
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
106 case 'w':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
107 case 'W':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
108 if (CURPRAGMA(l, PRAGMA_6809))
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
109 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
110 lwasm_register_error(as, l, E_OPERAND_BAD);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
111 return;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
112 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
113 rn = 4;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
114 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
115
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
116 default:
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
117 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
118 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
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 (*p)++;
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
121 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: 376
diff changeset
122 if (**p == '+')
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
123 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
124 if (incdec != 0)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
125 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
126 lwasm_register_error(as, l, E_OPERAND_BAD);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
127 return;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
128 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
129 incdec = 1;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
130 (*p)++;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
131 if (**p == '+')
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
132 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
133 incdec = 2;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
134 (*p)++;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
135 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
136 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: 376
diff changeset
137 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
138 if (indir)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
139 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
140 if (**p != ']')
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
141 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
142 lwasm_register_error(as, l, E_OPERAND_BAD);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
143 return;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
144 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
145 (*p)++;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
146 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
147 if (indir || rn == 4)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
148 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
149 if (incdec == 1 || incdec == -1)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
150 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
151 lwasm_register_error(as, l, E_OPERAND_BAD);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
152 return;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
153 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
154 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
155 if (rn == 4)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
156 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
157 if (indir)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
158 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
159 if (incdec == 0)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
160 i = 0x90;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
161 else if (incdec == -2)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
162 i = 0xF0;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
163 else
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
164 i = 0xD0;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
165 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
166 else
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
167 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
168 if (incdec == 0)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
169 i = 0x8F;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
170 else if (incdec == -2)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
171 i = 0xEF;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
172 else
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
173 i = 0xCF;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
174 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
175 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
176 else
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
177 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
178 switch (incdec)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
179 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
180 case 0:
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
181 i = 0x84;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
182 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
183 case 1:
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
184 i = 0x80;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
185 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
186 case 2:
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
187 i = 0x81;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
188 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
189 case -1:
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
190 i = 0x82;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
191 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
192 case -2:
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
193 i = 0x83;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
194 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
195 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
196 i = (rn << 5) | i | (indir << 4);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
197 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
198 l -> pb = i;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
199 l -> lint = 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
200 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
201 }
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
202 i = toupper(**p);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
203 if (
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
204 (i == 'A' || i == 'B' || i == 'D') ||
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
205 (!CURPRAGMA(l, PRAGMA_6809) && (i == 'E' || i == 'F' || i == 'W'))
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
206 )
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
207 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
208 tstr = *p + 1;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
209 lwasm_skip_to_next_token(l, &tstr);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
210 if (*tstr == ',')
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
211 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
212 *p = tstr + 1;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
213 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: 376
diff changeset
214 switch (**p)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
215 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
216 case 'x':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
217 case 'X':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
218 rn = 0;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
219 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
220
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
221 case 'y':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
222 case 'Y':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
223 rn = 1;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
224 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
225
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
226 case 'u':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
227 case 'U':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
228 rn = 2;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
229 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
230
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
231 case 's':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
232 case 'S':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
233 rn = 3;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
234 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
235
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
236 default:
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
237 lwasm_register_error(as, l, E_OPERAND_BAD);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
238 return;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
239 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
240 (*p)++;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
241 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: 376
diff changeset
242 if (indir)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
243 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
244 if (**p != ']')
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
245 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
246 lwasm_register_error(as, l, E_OPERAND_BAD);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
247 return;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
248 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
249 (*p)++;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
250 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
251
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
252 switch (i)
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
253 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
254 case 'A':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
255 i = 0x86;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
256 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
257
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
258 case 'B':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
259 i = 0x85;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
260 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
261
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
262 case 'D':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
263 i = 0x8B;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
264 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
265
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
266 case 'E':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
267 i = 0x87;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
268 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
269
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
270 case 'F':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
271 i = 0x8A;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
272 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
273
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
274 case 'W':
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
275 i = 0x8E;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
276 break;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
277 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
278 l -> pb = i | (indir << 4) | (rn << 5);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
279 l -> lint = 0;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
280 return;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
281 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
282 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
283
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
284 /* we have the "expression" types now */
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
285 if (**p == '<')
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
286 {
2c24602be78f 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 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
288 (*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
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 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
291 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
292 l -> lint = 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
293 (*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
294 }
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
295 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: 376
diff changeset
296 if (**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
297 {
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
298 tstr = *p + 1;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
299 lwasm_skip_to_next_token(l, &tstr);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
300 if (*tstr == ',')
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
301 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
302 f0 = 1;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
303 }
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
304 }
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
305
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
306 // now we have to evaluate the expression
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
307 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
308 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
309 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
310 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
311 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
312 }
2c24602be78f 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_save_expr(l, 0, e);
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
314
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
315 if (**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
316 {
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
317 /* if no comma, we have extended indirect */
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
318 if (l -> lint == 1 || **p != ']')
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
319 {
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
320 lwasm_register_error(as, l, E_OPERAND_BAD);
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
321 return;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
322 }
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
323 (*p)++;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
324 l -> lint = 2;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
325 l -> pb = 0x9F;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
326 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
327 }
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
328 (*p)++;
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
329 lwasm_skip_to_next_token(l, 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
330 // now get the register
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
331 rn = lwasm_lookupreg3(reglist, 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
332 if (rn < 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
333 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
334 lwasm_register_error(as, l, E_REGISTER_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
335 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
336 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
337
2c24602be78f 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 if (indir)
2c24602be78f 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 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
341 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
342 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
343 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
344 }
2c24602be78f 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 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
346 (*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
347 }
2c24602be78f 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
130
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
349 if (rn <= 3)
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
350 {
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
351 // X,Y,U,S
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
352 if (l -> lint == 1)
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
353 {
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
354 l -> pb = 0x88 | (rn << 5) | (indir ? 0x10 : 0);
131
f2f3a4b0a25e Fix fix for forced index offset sizes
lost@l-w.ca
parents: 130
diff changeset
355 return;
130
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
356 }
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
357 else if (l -> lint == 2)
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
358 {
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
359 l -> pb = 0x89 | (rn << 5) | (indir ? 0x10 : 0);
131
f2f3a4b0a25e Fix fix for forced index offset sizes
lost@l-w.ca
parents: 130
diff changeset
360 return;
130
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
361 }
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
362 }
50d86baf4ea2 Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents: 129
diff changeset
363
0
2c24602be78f 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 // nnnn,W is only 16 bit (or 0 bit)
2c24602be78f 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 if (rn == 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
366 {
2c24602be78f 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 if (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
368 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
369 lwasm_register_error(as, l, E_NW_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
370 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
371 }
2c24602be78f 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 if (l -> lint == 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
374 {
138
57c0210d578c Fix error with postbyte for constant offset from W modes
lost@l-w.ca
parents: 131
diff changeset
375 l -> pb = indir ? 0xb0 : 0xaf;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
376 l -> lint = 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
377 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
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
2c24602be78f 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 l -> pb = (0x80 * indir) | rn;
2c24602be78f 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
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
382 /* [,w] and ,w
2c24602be78f 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 if (indir)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
384 *b1 = 0x90;
2c24602be78f 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 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
386 *b1 = 0x8f;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
387 */
2c24602be78f 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
2c24602be78f 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 // PCR? then we have PC relative addressing (like B??, LB??)
2c24602be78f 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 if (rn == 5 || (rn == 6 && CURPRAGMA(l, PRAGMA_PCASPCR)))
2c24602be78f 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 {
2c24602be78f 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 lw_expr_t e1, e2;
2c24602be78f 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 // external references are handled exactly the same as 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
396 // relative addressing modes
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
397 // on pass 1, adjust the expression for a subtraction of 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
398 // current address
2c24602be78f 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 // e - (addr + linelen) => e - addr - linelen
2c24602be78f 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
2c24602be78f 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 e2 = lw_expr_build(lw_expr_type_special, lwasm_expr_linelen, l);
2c24602be78f 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 e1 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_minus, e, e2);
2c24602be78f 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 lw_expr_destroy(e2);
2c24602be78f 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 e2 = lw_expr_build(lw_expr_type_oper, lw_expr_oper_minus, e1, l -> addr);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
405 lw_expr_destroy(e1);
2c24602be78f 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 lwasm_save_expr(l, 0, e2);
2c24602be78f 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 if (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
408 {
2c24602be78f 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 l -> pb = indir ? 0x9C : 0x8C;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
410 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
411 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
412 if (l -> lint == 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
413 {
2c24602be78f 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 l -> pb = indir ? 0x9D : 0x8D;
2c24602be78f 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 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
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
2c24602be78f 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 if (rn == 6)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
420 {
2c24602be78f 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 if (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
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 l -> pb = indir ? 0x9C : 0x8C;
2c24602be78f 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 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
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 if (l -> lint == 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
427 {
2c24602be78f 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 l -> pb = indir ? 0x9D : 0x8D;
2c24602be78f 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 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
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 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
432
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
433 l -> pb = (indir * 0x80) | rn | (f0 * 0x40);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
434 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
435
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
436 PARSEFUNC(insn_parse_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
437 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
438 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
439 insn_parse_indexed_aux(as, l, 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
440
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
441 if (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
442 {
2c24602be78f 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 l -> len = OPLEN(instab[l -> insn].ops[0]) + 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
444 }
2c24602be78f 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 }
2c24602be78f 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 void insn_resolve_indexed_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
448 {
2c24602be78f 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 // here, we have an expression which needs to be
2c24602be78f 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 // resolved; the post byte is determined here as well
2
7317fbe024af Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents: 0
diff changeset
451 lw_expr_t e, e2;
0
2c24602be78f 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 int pb = -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
453 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
454
2c24602be78f 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 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
456 return;
131
f2f3a4b0a25e Fix fix for forced index offset sizes
lost@l-w.ca
parents: 130
diff changeset
457
0
2c24602be78f 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 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
459 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
460 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
461 // temporarily set the instruction length to see if we get a
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
462 // constant for our expression; if so, we can select an instruction
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
463 // size
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
464 e2 = lw_expr_copy(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
465 // magic 2 for 8 bit (post byte + offset)
2c24602be78f 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 -> len = OPLEN(instab[l -> insn].ops[0]) + elen + 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
467 lwasm_reduce_expr(as, e2);
2c24602be78f 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 // 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
469 // e3 = lw_expr_copy(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
470 // lwasm_reduce_expr(as, e3);
2c24602be78f 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 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
472 if (lw_expr_istype(e2, 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
473 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
474 v = lw_expr_intval(e2);
2c24602be78f 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 // we have a reducible expression here which depends on
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
476 // the size of this instruction
109
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
477 if (v == 0 && !CURPRAGMA(l, PRAGMA_NOINDEX0TONONE) && (l -> pb & 0x07) <= 4)
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
478 {
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
479 if ((l -> pb & 0x07) < 4)
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
480 {
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
481 pb = 0x84 | ((l -> pb & 0x03) << 5) | ((l -> pb & 0x80) ? 0x10 : 0);
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
482 }
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
483 else
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
484 {
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
485 pb = (l -> pb & 0x80) ? 0x90 : 0x8F;
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
486 }
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
487 l -> pb = pb;
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
488 lw_expr_destroy(e2);
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
489 l -> lint = 0;
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
490 return;
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
491 }
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
492 else if (v < -128 || v > 127)
0
2c24602be78f 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 {
2c24602be78f 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 l -> lint = 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
495 switch (l -> pb & 0x07)
2c24602be78f 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 {
2c24602be78f 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 case 0:
2c24602be78f 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 case 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
499 case 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
500 case 3:
45
c42d6dc7df68 Fixed code generation error with indirect indexing using 8 or 16 bit offsets from X,Y,U,S
lost@l-w.ca
parents: 2
diff changeset
501 pb = 0x89 | ((l -> pb & 0x03) << 5) | ((l -> pb & 0x80) ? 0x10 : 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
502 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
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 case 4: // W
138
57c0210d578c Fix error with postbyte for constant offset from W modes
lost@l-w.ca
parents: 131
diff changeset
505 pb = (l -> pb & 0x80) ? 0xB0 : 0xAF;
0
2c24602be78f 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 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
507
2c24602be78f 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 case 5: // PCR
2c24602be78f 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 case 6: // PC
2c24602be78f 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 pb = (l -> pb & 0x80) ? 0x9D : 0x8D;
2c24602be78f 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 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
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
2c24602be78f 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 l -> pb = pb;
91
95181f1ad183 Really fix memory leaks
lost@l-w.ca
parents: 90
diff changeset
515 lw_expr_destroy(e2);
0
2c24602be78f 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 // lw_expr_destroy(e3);
2c24602be78f 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 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
518 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
519 else if ((l -> pb & 0x80) || ((l -> pb & 0x07) > 3) || v < -16 || v > 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
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 // if not a 5 bit value, is indirect, or is not X,Y,U,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
522 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
523 switch (l -> pb & 0x07)
2c24602be78f 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 {
2c24602be78f 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 case 0:
2c24602be78f 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 case 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
527 case 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
528 case 3:
45
c42d6dc7df68 Fixed code generation error with indirect indexing using 8 or 16 bit offsets from X,Y,U,S
lost@l-w.ca
parents: 2
diff changeset
529 pb = 0x88 | ((l -> pb & 0x03) << 5) | ((l -> pb & 0x80) ? 0x10 : 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
530 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
531
2c24602be78f 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 case 4: // W
2c24602be78f 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 // use 16 bit because W doesn't have 8 bit, unless 0
2c24602be78f 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 if (v == 0 && !(CURPRAGMA(l, PRAGMA_NOINDEX0TONONE) || l -> pb & 0x40))
2c24602be78f 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 pb = (l -> pb & 0x80) ? 0x90 : 0x8F;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
537 l -> lint = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
538 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
539 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
540 {
138
57c0210d578c Fix error with postbyte for constant offset from W modes
lost@l-w.ca
parents: 131
diff changeset
541 pb = (l -> pb & 0x80) ? 0xB0 : 0xAF;
0
2c24602be78f 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 -> lint = 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
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 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
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 case 5: // PCR
2c24602be78f 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 case 6: // PC
2c24602be78f 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 pb = (l -> pb & 0x80) ? 0x9C : 0x8C;
2c24602be78f 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 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
550 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
551
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
552 l -> pb = pb;
91
95181f1ad183 Really fix memory leaks
lost@l-w.ca
parents: 90
diff changeset
553 lw_expr_destroy(e2);
0
2c24602be78f 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 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
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 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
557 {
131
f2f3a4b0a25e Fix fix for forced index offset sizes
lost@l-w.ca
parents: 130
diff changeset
558 // we have X,Y,U,S and a possible 5 bit here
0
2c24602be78f 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 l -> lint = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
560
2c24602be78f 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 if (v == 0 && !(CURPRAGMA(l, PRAGMA_NOINDEX0TONONE) || l -> pb & 0x40))
2c24602be78f 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 pb = (l -> pb & 0x03) << 5 | 0x84;
2c24602be78f 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 }
2c24602be78f 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 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
566 {
131
f2f3a4b0a25e Fix fix for forced index offset sizes
lost@l-w.ca
parents: 130
diff changeset
567 pb = ((l -> pb & 0x03) << 5) | (v & 0x1F);
0
2c24602be78f 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 l -> pb = pb;
91
95181f1ad183 Really fix memory leaks
lost@l-w.ca
parents: 90
diff changeset
570 lw_expr_destroy(e2);
0
2c24602be78f 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 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
572 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
573 }
464
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
574 else
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
575 {
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
576 if ((l -> pb & 0x07) == 5 || (l -> pb & 0x07) == 6)
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
577 {
465
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
578 // NOTE: this will break in some particularly obscure corner cases
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
579 // which are not likely to show up in normal code. Notably, if, for
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
580 // some reason, the target gets *farther* away if shorter addressing
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
581 // modes are chosen, which should only happen if the symbol is before
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
582 // the instruction in the source file and there is some sort of ORG
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
583 // statement or similar in between which forces the address of this
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
584 // instruction, and the differences happen to cross the 8 bit boundary.
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
585 // For this reason, we use a heuristic and allow a margin on the 8
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
586 // bit boundary conditions.
464
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
587 v = as -> pretendmax;
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
588 as -> pretendmax = 1;
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
589 lwasm_reduce_expr(as, e2);
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
590 as -> pretendmax = v;
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
591 v = lw_expr_intval(e2);
465
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
592 // Actual range is -128 <= offset <= 127; we're allowing a fudge
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
593 // factor of 25 or so bytes so that we're less likely to accidentally
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
594 // cross into the 16 bit boundary in weird corner cases.
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
595 if (v >= -100 || v <= 100)
464
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
596 {
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
597 l -> lint = 1;
465
7370a67caf7e Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents: 464
diff changeset
598 l -> pb = (l -> pb & 0x80) ? 0x9C : 0x8C;
464
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
599 return;
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
600 }
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
601 }
9134f6426c57 Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents: 463
diff changeset
602 }
91
95181f1ad183 Really fix memory leaks
lost@l-w.ca
parents: 90
diff changeset
603 lw_expr_destroy(e2);
0
2c24602be78f 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 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
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 // we know how big it is
2c24602be78f 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 v = lw_expr_intval(e);
402
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
610
b20f14edda5a Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents: 376
diff changeset
611 if (v == 0 && !CURPRAGMA(l, PRAGMA_NOINDEX0TONONE) && (l -> pb & 0x07) <= 4 && ((l -> pb & 0x40) == 0))
109
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
612 {
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
613 if ((l -> pb & 0x07) < 4)
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
614 {
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
615 pb = 0x84 | ((l -> pb & 0x03) << 5) | ((l -> pb & 0x80) ? 0x10 : 0);
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
616 }
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
617 else
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
618 {
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
619 pb = (l -> pb & 0x80) ? 0x90 : 0x8F;
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
620 }
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
621 l -> pb = pb;
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
622 l -> lint = 0;
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
623 return;
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
624 }
6a919c3ca0e9 Fixed pragma noindex0tonone to work
lost@l-w.ca
parents: 91
diff changeset
625 else if (v < -128 || v > 127)
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
626 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
627 do16bit:
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
628 l -> lint = 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
629 switch (l -> pb & 0x07)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
630 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
631 case 0:
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
632 case 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
633 case 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
634 case 3:
45
c42d6dc7df68 Fixed code generation error with indirect indexing using 8 or 16 bit offsets from X,Y,U,S
lost@l-w.ca
parents: 2
diff changeset
635 pb = 0x89 | (l -> pb & 0x03) << 5 | ((l -> pb & 0x80) ? 0x10 : 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
636 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
637
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
638 case 4: // W
138
57c0210d578c Fix error with postbyte for constant offset from W modes
lost@l-w.ca
parents: 131
diff changeset
639 pb = (l -> pb & 0x80) ? 0xB0 : 0xAF;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
640 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
641
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
642 case 5: // PCR
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
643 case 6: // PC
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
644 pb = (l -> pb & 0x80) ? 0x9D : 0x8D;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
645 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
646 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
647
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
648 l -> pb = 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
649 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
650 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
651 else if ((l -> pb & 0x80) || ((l -> pb & 0x07) > 3) || v < -16 || v > 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
652 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
653 // if not a 5 bit value, is indirect, or is not X,Y,U,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
654 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
655 switch (l -> pb & 0x07)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
656 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
657 case 0:
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
658 case 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
659 case 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
660 case 3:
45
c42d6dc7df68 Fixed code generation error with indirect indexing using 8 or 16 bit offsets from X,Y,U,S
lost@l-w.ca
parents: 2
diff changeset
661 pb = 0x88 | (l -> pb & 0x03) << 5 | ((l -> pb & 0x80) ? 0x10 : 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
662 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
663
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
664 case 4: // W
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
665 // use 16 bit because W doesn't have 8 bit, unless 0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
666 if (v == 0 && !(CURPRAGMA(l, PRAGMA_NOINDEX0TONONE) || l -> pb & 0x40))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
667 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
668 pb = (l -> pb & 0x80) ? 0x90 : 0x8F;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
669 l -> lint = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
670 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
671 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
672 {
138
57c0210d578c Fix error with postbyte for constant offset from W modes
lost@l-w.ca
parents: 131
diff changeset
673 pb = (l -> pb & 0x80) ? 0xB0 : 0xAF;
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
674 l -> lint = 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
675 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
676 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
677
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
678 case 5: // PCR
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
679 case 6: // PC
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
680 pb = (l -> pb & 0x80) ? 0x9C : 0x8C;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
681 break;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
682 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
683
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
684 l -> pb = 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
685 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
686 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
687 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
688 {
131
f2f3a4b0a25e Fix fix for forced index offset sizes
lost@l-w.ca
parents: 130
diff changeset
689 // we have X,Y,U,S and a possible 5 bit here
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
690 l -> lint = 0;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
691
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
692 if (v == 0 && !(CURPRAGMA(l, PRAGMA_NOINDEX0TONONE) || l -> pb & 0x40))
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
693 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
694 pb = (l -> pb & 0x03) << 5 | 0x84;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
695 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
696 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
697 {
131
f2f3a4b0a25e Fix fix for forced index offset sizes
lost@l-w.ca
parents: 130
diff changeset
698 pb = ((l -> pb & 0x03) << 5) | (v & 0x1F);
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
699 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
700 l -> pb = 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
701 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
702 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
703 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
704 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
705 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
706 // we don't know how big it is
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
707 if (!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
708 return;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
709 // force 16 bit if we don't know
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
710 l -> lint = 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
711 goto do16bit;
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
712 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
713 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
714
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
715 RESOLVEFUNC(insn_resolve_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
716 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
717 if (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
718 insn_resolve_indexed_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
719
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
720 if (l -> lint != -1 && l -> pb != -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
721 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
722 l -> len = OPLEN(instab[l -> insn].ops[0]) + 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
723 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
724 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
725
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
726 void insn_emit_indexed_aux(asmstate_t *as, line_t *l)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
727 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
728 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
729
283
210d261a614d Make byte overflow detection for indexing work better
William Astle <lost@l-w.ca>
parents: 282
diff changeset
730 if (l -> lint == 1)
282
3c421f24c9b8 Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents: 243
diff changeset
731 {
3c421f24c9b8 Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents: 243
diff changeset
732 int i;
3c421f24c9b8 Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents: 243
diff changeset
733 e = lwasm_fetch_expr(l, 0);
3c421f24c9b8 Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents: 243
diff changeset
734 i = lw_expr_intval(e);
3c421f24c9b8 Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents: 243
diff changeset
735 if (i < -128 || i > 127)
3c421f24c9b8 Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents: 243
diff changeset
736 {
370
8764142b3192 Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents: 367
diff changeset
737 lwasm_register_error(as, l, E_BYTE_OVERFLOW);
282
3c421f24c9b8 Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents: 243
diff changeset
738 }
3c421f24c9b8 Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents: 243
diff changeset
739 }
3c421f24c9b8 Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents: 243
diff changeset
740
458
3948c874901b Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents: 455
diff changeset
741 // exclude expr,W since that can only be 16 bits
3948c874901b Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents: 455
diff changeset
742 if (l -> lint == 2 && CURPRAGMA(l, PRAGMA_OPERANDSIZE) && (l -> pb != 0xAF && l -> pb != 0xB0))
455
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
743 {
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
744 int offs;
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
745 e = lwasm_fetch_expr(l, 0);
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
746 if (lw_expr_istype(e, lw_expr_type_int))
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
747 {
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
748 offs = lw_expr_intval(e);
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
749 if ((offs >= -128 && offs <= 127) || offs >= 0xFF80)
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
750 {
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
751 lwasm_register_error(as, l, W_OPERAND_SIZE);
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
752 }
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
753 }
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
754 }
cad5937314cb Add operandsizewarning pragma
William Astle <lost@l-w.ca>
parents: 402
diff changeset
755
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
756 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
757 lwasm_emitop(l, l -> pb);
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 370
diff changeset
758
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 370
diff changeset
759 l -> cycle_adj = lwasm_cycle_calc_ind(l);
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 370
diff changeset
760
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
761 if (l -> lint > 0)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
762 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
763 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
764 lwasm_emitexpr(l, e, l -> lint);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
765 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
766 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
767
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
768 EMITFUNC(insn_emit_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
769 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
770 insn_emit_indexed_aux(as, l);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
771 }