Mercurial > hg > index.cgi
annotate lwasm/insn_indexed.c @ 569:37014b2935bf lwtools-4.22
Bump version in preparation for release
author | William Astle <lost@l-w.ca> |
---|---|
date | Fri, 22 Dec 2023 21:03:18 -0700 |
parents | 62720ac9e28d |
children |
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)++; |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
289 if (**p == '<') |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
290 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
291 l -> lint = 3; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
292 (*p)++; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
293 if (indir) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
294 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
295 lwasm_register_error(as, l, E_ILL5); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
296 return; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
297 } |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
298 } |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
299 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
300 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
|
301 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
302 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
|
303 (*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
|
304 } |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
305 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
|
306 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
|
307 { |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
308 tstr = *p + 1; |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
309 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
|
310 if (*tstr == ',') |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
311 { |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
312 f0 = 1; |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
313 } |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
314 } |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
315 |
0
2c24602be78f
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 // 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
|
317 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
|
318 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
|
319 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
367
diff
changeset
|
320 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
|
321 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
|
322 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
323 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
|
324 |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
325 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
|
326 { |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
327 /* 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
|
328 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
|
329 { |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
330 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
|
331 return; |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
332 } |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
333 (*p)++; |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
334 l -> lint = 2; |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
335 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
|
336 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
|
337 } |
402
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
338 (*p)++; |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
339 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
|
340 // 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
|
341 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
|
342 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
|
343 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
367
diff
changeset
|
344 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
|
345 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
|
346 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
347 |
2c24602be78f
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 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
|
349 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
350 if (**p != ']') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
351 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
367
diff
changeset
|
352 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
|
353 return; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
354 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
355 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
|
356 (*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
|
357 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
358 |
130
50d86baf4ea2
Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents:
129
diff
changeset
|
359 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
|
360 { |
50d86baf4ea2
Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents:
129
diff
changeset
|
361 // 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
|
362 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
|
363 { |
50d86baf4ea2
Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents:
129
diff
changeset
|
364 l -> pb = 0x88 | (rn << 5) | (indir ? 0x10 : 0); |
131 | 365 return; |
130
50d86baf4ea2
Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents:
129
diff
changeset
|
366 } |
50d86baf4ea2
Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents:
129
diff
changeset
|
367 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
|
368 { |
50d86baf4ea2
Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents:
129
diff
changeset
|
369 l -> pb = 0x89 | (rn << 5) | (indir ? 0x10 : 0); |
131 | 370 return; |
130
50d86baf4ea2
Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents:
129
diff
changeset
|
371 } |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
372 else if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
373 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
374 l -> pb = (rn << 5); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
375 } |
130
50d86baf4ea2
Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents:
129
diff
changeset
|
376 } |
50d86baf4ea2
Fixed code generation bug with forced-size offsets from X,Y,U,S
lost@l-w.ca
parents:
129
diff
changeset
|
377 |
0
2c24602be78f
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 // 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
|
379 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
|
380 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
381 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
|
382 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
367
diff
changeset
|
383 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
|
384 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
|
385 } |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
386 else if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
387 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
388 lwasm_register_error(as, l, E_ILL5); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
389 return; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
390 } |
0
2c24602be78f
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 |
2c24602be78f
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 (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
|
393 { |
138
57c0210d578c
Fix error with postbyte for constant offset from W modes
lost@l-w.ca
parents:
131
diff
changeset
|
394 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
|
395 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
|
396 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
|
397 } |
2c24602be78f
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 |
2c24602be78f
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 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
|
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 /* [,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
|
402 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
|
403 *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
|
404 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
|
405 *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
|
406 */ |
2c24602be78f
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 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
|
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 |
2c24602be78f
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 // 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
|
411 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
|
412 { |
2c24602be78f
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 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
|
414 // 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
|
415 // 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
|
416 // 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
|
417 // 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
|
418 // 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
|
419 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
420 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
|
421 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 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
|
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 ? 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
|
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 } |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
431 else if (l -> lint == 2) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
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 ? 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
|
434 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
|
435 } |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
436 else if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
437 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
438 lwasm_register_error(as, l, E_ILL5); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
439 return; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
440 } |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
441 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
442 |
2c24602be78f
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 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
|
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 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
|
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 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
|
448 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
|
449 } |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
450 else if (l -> lint == 2) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
451 { |
2c24602be78f
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 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
|
453 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
|
454 } |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
455 else if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
456 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
457 lwasm_register_error(as, l, E_ILL5); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
458 return; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
459 } |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
460 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
461 |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
462 if (l -> lint != 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
463 l -> pb = (indir * 0x80) | rn | (f0 * 0x40); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
464 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
465 |
2c24602be78f
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 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
|
467 { |
2c24602be78f
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 -> 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
|
469 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
|
470 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
471 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
|
472 { |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
473 if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
474 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
475 else |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
476 l -> len = OPLEN(instab[l -> insn].ops[0]) + l -> lint + 1; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
477 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
478 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
479 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
480 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
|
481 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
482 // 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
|
483 // 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
|
484 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
|
485 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
|
486 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
|
487 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
488 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
|
489 return; |
131 | 490 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
491 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
|
492 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
|
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 // 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
|
495 // 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
|
496 // 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
|
497 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
|
498 // 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
|
499 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
|
500 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
|
501 // 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
|
502 // 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
|
503 // 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
|
504 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
|
505 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
|
506 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
507 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
|
508 // 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
|
509 // the size of this instruction |
109 | 510 if (v == 0 && !CURPRAGMA(l, PRAGMA_NOINDEX0TONONE) && (l -> pb & 0x07) <= 4) |
511 { | |
512 if ((l -> pb & 0x07) < 4) | |
513 { | |
514 pb = 0x84 | ((l -> pb & 0x03) << 5) | ((l -> pb & 0x80) ? 0x10 : 0); | |
515 } | |
516 else | |
517 { | |
518 pb = (l -> pb & 0x80) ? 0x90 : 0x8F; | |
519 } | |
520 l -> pb = pb; | |
521 lw_expr_destroy(e2); | |
522 l -> lint = 0; | |
523 return; | |
524 } | |
525 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
|
526 { |
2c24602be78f
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 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
|
528 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
|
529 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
530 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
|
531 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
|
532 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
|
533 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
|
534 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
|
535 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
|
536 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
537 case 4: // W |
138
57c0210d578c
Fix error with postbyte for constant offset from W modes
lost@l-w.ca
parents:
131
diff
changeset
|
538 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
|
539 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
|
540 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
541 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
|
542 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
|
543 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
|
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 |
2c24602be78f
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 l -> pb = pb; |
91 | 548 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
|
549 // 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
|
550 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
|
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 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
|
553 { |
2c24602be78f
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 // 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
|
555 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
|
556 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
|
557 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
558 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
|
559 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
|
560 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
|
561 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
|
562 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
|
563 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
|
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 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
|
566 // 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
|
567 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
|
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 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
|
570 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
|
571 } |
2c24602be78f
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 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
|
573 { |
138
57c0210d578c
Fix error with postbyte for constant offset from W modes
lost@l-w.ca
parents:
131
diff
changeset
|
574 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
|
575 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
|
576 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
577 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
|
578 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
579 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
|
580 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
|
581 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
|
582 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
|
583 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
584 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
585 l -> pb = pb; |
91 | 586 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
|
587 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
|
588 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
589 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
|
590 { |
131 | 591 // 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
|
592 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
|
593 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
594 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
|
595 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
596 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
|
597 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
598 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
|
599 { |
131 | 600 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
|
601 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
602 l -> pb = pb; |
91 | 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 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
|
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 } |
464
9134f6426c57
Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents:
463
diff
changeset
|
607 else |
9134f6426c57
Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents:
463
diff
changeset
|
608 { |
9134f6426c57
Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents:
463
diff
changeset
|
609 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
|
610 { |
465
7370a67caf7e
Fix really dumb code generation error
William Astle <lost@l-w.ca>
parents:
464
diff
changeset
|
611 // 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
|
612 // 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
|
613 // 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
|
614 // 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
|
615 // 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
|
616 // 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
|
617 // 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
|
618 // 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
|
619 // 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
|
620 v = as -> pretendmax; |
9134f6426c57
Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents:
463
diff
changeset
|
621 as -> pretendmax = 1; |
9134f6426c57
Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents:
463
diff
changeset
|
622 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
|
623 as -> pretendmax = v; |
466
51bed8c8dc53
Actually check if we resolved a PCR reference before assuming 8 bits
William Astle <lost@l-w.ca>
parents:
465
diff
changeset
|
624 if (lw_expr_istype(e2, lw_expr_type_int)) |
464
9134f6426c57
Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents:
463
diff
changeset
|
625 { |
466
51bed8c8dc53
Actually check if we resolved a PCR reference before assuming 8 bits
William Astle <lost@l-w.ca>
parents:
465
diff
changeset
|
626 v = lw_expr_intval(e2); |
51bed8c8dc53
Actually check if we resolved a PCR reference before assuming 8 bits
William Astle <lost@l-w.ca>
parents:
465
diff
changeset
|
627 // Actual range is -128 <= offset <= 127; we're allowing a fudge |
51bed8c8dc53
Actually check if we resolved a PCR reference before assuming 8 bits
William Astle <lost@l-w.ca>
parents:
465
diff
changeset
|
628 // factor of 25 or so bytes so that we're less likely to accidentally |
51bed8c8dc53
Actually check if we resolved a PCR reference before assuming 8 bits
William Astle <lost@l-w.ca>
parents:
465
diff
changeset
|
629 // cross into the 16 bit boundary in weird corner cases. |
469 | 630 if (v >= -100 && v <= 100) |
466
51bed8c8dc53
Actually check if we resolved a PCR reference before assuming 8 bits
William Astle <lost@l-w.ca>
parents:
465
diff
changeset
|
631 { |
51bed8c8dc53
Actually check if we resolved a PCR reference before assuming 8 bits
William Astle <lost@l-w.ca>
parents:
465
diff
changeset
|
632 l -> lint = 1; |
51bed8c8dc53
Actually check if we resolved a PCR reference before assuming 8 bits
William Astle <lost@l-w.ca>
parents:
465
diff
changeset
|
633 l -> pb = (l -> pb & 0x80) ? 0x9C : 0x8C; |
51bed8c8dc53
Actually check if we resolved a PCR reference before assuming 8 bits
William Astle <lost@l-w.ca>
parents:
465
diff
changeset
|
634 return; |
51bed8c8dc53
Actually check if we resolved a PCR reference before assuming 8 bits
William Astle <lost@l-w.ca>
parents:
465
diff
changeset
|
635 } |
464
9134f6426c57
Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents:
463
diff
changeset
|
636 } |
9134f6426c57
Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents:
463
diff
changeset
|
637 } |
9134f6426c57
Fix think-o in PCR optimization fix from previous commit
William Astle <lost@l-w.ca>
parents:
463
diff
changeset
|
638 } |
91 | 639 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
|
640 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
641 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
642 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
|
643 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
644 // 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
|
645 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
|
646 |
b20f14edda5a
Completed initial conversion to new parser allowing spaces in operands
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
647 if (v == 0 && !CURPRAGMA(l, PRAGMA_NOINDEX0TONONE) && (l -> pb & 0x07) <= 4 && ((l -> pb & 0x40) == 0)) |
109 | 648 { |
649 if ((l -> pb & 0x07) < 4) | |
650 { | |
651 pb = 0x84 | ((l -> pb & 0x03) << 5) | ((l -> pb & 0x80) ? 0x10 : 0); | |
652 } | |
653 else | |
654 { | |
655 pb = (l -> pb & 0x80) ? 0x90 : 0x8F; | |
656 } | |
657 l -> pb = pb; | |
658 l -> lint = 0; | |
659 return; | |
660 } | |
661 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
|
662 { |
2c24602be78f
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 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
|
664 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
|
665 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
|
666 { |
2c24602be78f
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 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
|
668 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
|
669 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
|
670 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
|
671 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
|
672 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
|
673 |
2c24602be78f
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 case 4: // W |
138
57c0210d578c
Fix error with postbyte for constant offset from W modes
lost@l-w.ca
parents:
131
diff
changeset
|
675 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
|
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) ? 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
|
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 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
|
688 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
689 // if 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
|
690 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
|
691 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
|
692 { |
2c24602be78f
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 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
|
694 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
|
695 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
|
696 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
|
697 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
|
698 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
|
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 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
|
701 // 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
|
702 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
|
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 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
|
705 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
|
706 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
707 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
|
708 { |
138
57c0210d578c
Fix error with postbyte for constant offset from W modes
lost@l-w.ca
parents:
131
diff
changeset
|
709 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
|
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 } |
2c24602be78f
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 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
|
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 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
|
715 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
|
716 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
|
717 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
|
718 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
719 |
2c24602be78f
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 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
|
721 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
|
722 } |
2c24602be78f
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 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
|
724 { |
131 | 725 // 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
|
726 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
|
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 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
|
729 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
730 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
|
731 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
732 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
733 { |
131 | 734 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
|
735 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
736 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
|
737 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
|
738 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
739 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
740 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
|
741 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
742 // 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
|
743 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
|
744 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
|
745 // 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
|
746 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
|
747 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
|
748 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
749 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
750 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
751 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
|
752 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
753 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
|
754 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
|
755 |
2c24602be78f
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 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
|
757 { |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
758 if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
759 l -> len = OPLEN(instab[l -> insn].ops[0]) + 1; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
760 else |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
761 l -> len = OPLEN(instab[l -> insn].ops[0]) + l -> lint + 1; |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
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 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
764 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
765 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
|
766 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
767 lw_expr_t 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
|
768 |
283
210d261a614d
Make byte overflow detection for indexing work better
William Astle <lost@l-w.ca>
parents:
282
diff
changeset
|
769 if (l -> lint == 1) |
282
3c421f24c9b8
Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents:
243
diff
changeset
|
770 { |
3c421f24c9b8
Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents:
243
diff
changeset
|
771 int i; |
3c421f24c9b8
Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents:
243
diff
changeset
|
772 e = lwasm_fetch_expr(l, 0); |
3c421f24c9b8
Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents:
243
diff
changeset
|
773 i = lw_expr_intval(e); |
3c421f24c9b8
Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents:
243
diff
changeset
|
774 if (i < -128 || i > 127) |
3c421f24c9b8
Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents:
243
diff
changeset
|
775 { |
370
8764142b3192
Convert internal error/warning handling framework to a new unified system
William Astle <lost@l-w.ca>
parents:
367
diff
changeset
|
776 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
|
777 } |
3c421f24c9b8
Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents:
243
diff
changeset
|
778 } |
3c421f24c9b8
Make <...,PCR complain on byte overflows
William Astle <lost@l-w.ca>
parents:
243
diff
changeset
|
779 |
458
3948c874901b
Make offset,R operand size warning work properly
William Astle <lost@l-w.ca>
parents:
455
diff
changeset
|
780 // exclude expr,W since that can only be 16 bits |
470
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
781 if (l -> lint == 3) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
782 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
783 int offs; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
784 e = lwasm_fetch_expr(l, 0); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
785 if (lw_expr_istype(e, lw_expr_type_int)) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
786 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
787 offs = lw_expr_intval(e); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
788 if ((offs >= -16 && offs <= 15) || offs >= 0xFFF0) |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
789 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
790 l -> pb |= offs & 0x1f; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
791 l -> lint = 0; |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
792 } |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
793 else |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
794 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
795 lwasm_register_error(as, l, E_BYTE_OVERFLOW); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
796 } |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
797 } |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
798 else |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
799 { |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
800 lwasm_register_error(as, l, E_EXPRESSION_NOT_RESOLVED); |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
801 } |
2c1c5dd84024
Add << prefix to force 5 bit offsets in indexed modes
William Astle <lost@l-w.ca>
parents:
469
diff
changeset
|
802 } |
481
62720ac9e28d
Exclude extended indirect from operandsizewarning pragma
William Astle <lost@l-w.ca>
parents:
470
diff
changeset
|
803 // note that extended indirect (post byte 0x9f) can only be 16 bits |
62720ac9e28d
Exclude extended indirect from operandsizewarning pragma
William Astle <lost@l-w.ca>
parents:
470
diff
changeset
|
804 else if (l -> lint == 2 && CURPRAGMA(l, PRAGMA_OPERANDSIZE) && (l -> pb != 0xAF && l -> pb != 0xB0 && l -> pb != 0x9f)) |
455 | 805 { |
806 int offs; | |
807 e = lwasm_fetch_expr(l, 0); | |
808 if (lw_expr_istype(e, lw_expr_type_int)) | |
809 { | |
810 offs = lw_expr_intval(e); | |
811 if ((offs >= -128 && offs <= 127) || offs >= 0xFF80) | |
812 { | |
813 lwasm_register_error(as, l, W_OPERAND_SIZE); | |
814 } | |
815 } | |
816 } | |
817 | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
818 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
|
819 lwasm_emitop(l, l -> pb); |
376 | 820 |
821 l -> cycle_adj = lwasm_cycle_calc_ind(l); | |
822 | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
823 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
|
824 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
825 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
|
826 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
|
827 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
828 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
829 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
830 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
|
831 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
832 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
|
833 } |