Commit | Line | Data |
---|---|---|
49f58d10 | 1 | ; Renesas M32C CPU description. -*- Scheme -*- |
0a665bfd JB |
2 | ; |
3 | ; Copyright 2005 Free Software Foundation, Inc. | |
4 | ; | |
5 | ; Contributed by Red Hat Inc; developed under contract from Renesas. | |
6 | ; | |
7 | ; This file is part of the GNU Binutils. | |
8 | ; | |
9 | ; This program is free software; you can redistribute it and/or modify | |
10 | ; it under the terms of the GNU General Public License as published by | |
11 | ; the Free Software Foundation; either version 2 of the License, or | |
12 | ; (at your option) any later version. | |
13 | ; | |
14 | ; This program is distributed in the hope that it will be useful, | |
15 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | ; GNU General Public License for more details. | |
18 | ; | |
19 | ; You should have received a copy of the GNU General Public License | |
20 | ; along with this program; if not, write to the Free Software | |
21 | ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. | |
49f58d10 JB |
22 | |
23 | (include "simplify.inc") | |
24 | ||
25 | (define-arch | |
26 | (name m32c) | |
27 | (comment "Renesas M32C") | |
28 | (default-alignment forced) | |
29 | (insn-lsb0? #f) | |
30 | (machs m16c m32c) | |
31 | (isas m16c m32c) | |
32 | ) | |
33 | ||
34 | (define-isa | |
35 | (name m16c) | |
36 | ||
37 | (default-insn-bitsize 32) | |
38 | ||
39 | ; Number of bytes of insn we can initially fetch. | |
40 | (base-insn-bitsize 32) | |
41 | ||
42 | ; Used in computing bit numbers. | |
43 | (default-insn-word-bitsize 32) | |
44 | ||
45 | (decode-assist (0 1 2 3 4 5 6 7)) ; Initial bitnumbers to decode insns by. | |
46 | ||
47 | ; fetches 1 insn at a time. | |
48 | (liw-insns 1) | |
49 | ||
50 | ; executes 1 insn at a time. | |
51 | (parallel-insns 1) | |
52 | ) | |
53 | ||
54 | (define-isa | |
55 | (name m32c) | |
56 | ||
57 | (default-insn-bitsize 32) | |
58 | ||
59 | ; Number of bytes of insn we can initially fetch. | |
60 | (base-insn-bitsize 32) | |
61 | ||
62 | ; Used in computing bit numbers. | |
63 | (default-insn-word-bitsize 32) | |
64 | ||
65 | (decode-assist (0 1 2 3 4 5 6 7)) ; Initial bitnumbers to decode insns by. | |
66 | ||
67 | ; fetches 1 insn at a time. | |
68 | (liw-insns 1) | |
69 | ||
70 | ; executes 1 insn at a time. | |
71 | (parallel-insns 1) | |
72 | ) | |
73 | ||
74 | (define-cpu | |
75 | ; cpu names must be distinct from the architecture name and machine names. | |
76 | ; The "b" suffix stands for "base" and is the convention. | |
77 | ; The "f" suffix stands for "family" and is the convention. | |
78 | (name m16cbf) | |
79 | (comment "Renesas M16C base family") | |
80 | (insn-endian big) | |
81 | (data-endian little) | |
82 | (word-bitsize 16) | |
83 | ) | |
84 | ||
85 | (define-cpu | |
86 | ; cpu names must be distinct from the architecture name and machine names. | |
87 | ; The "b" suffix stands for "base" and is the convention. | |
88 | ; The "f" suffix stands for "family" and is the convention. | |
89 | (name m32cbf) | |
90 | (comment "Renesas M32C base family") | |
91 | (insn-endian big) | |
92 | (data-endian little) | |
93 | (word-bitsize 16) | |
94 | ) | |
95 | ||
96 | (define-mach | |
97 | (name m16c) | |
98 | (comment "Generic M16C cpu") | |
99 | (cpu m32cbf) | |
100 | ) | |
101 | ||
102 | (define-mach | |
103 | (name m32c) | |
104 | (comment "Generic M32C cpu") | |
105 | (cpu m32cbf) | |
106 | ) | |
107 | ||
108 | ; Model descriptions. | |
109 | ||
110 | (define-model | |
111 | (name m16c) | |
112 | (comment "m16c") (attrs) | |
113 | (mach m16c) | |
114 | ||
115 | ; `state' is a list of variables for recording model state | |
116 | ; (state) | |
117 | (unit u-exec "Execution Unit" () | |
118 | 1 1 ; issue done | |
119 | () ; state | |
120 | () ; inputs | |
121 | () ; outputs | |
122 | () ; profile action (default) | |
123 | ) | |
124 | ) | |
125 | ||
126 | (define-model | |
127 | (name m32c) | |
128 | (comment "m32c") (attrs) | |
129 | (mach m32c) | |
130 | ||
131 | ; `state' is a list of variables for recording model state | |
132 | ; (state) | |
133 | (unit u-exec "Execution Unit" () | |
134 | 1 1 ; issue done | |
135 | () ; state | |
136 | () ; inputs | |
137 | () ; outputs | |
138 | () ; profile action (default) | |
139 | ) | |
140 | ) | |
141 | ||
142 | ; Macros to simplify MACH attribute specification. | |
143 | ||
144 | (define-pmacro all-isas () (ISA m16c,m32c)) | |
145 | (define-pmacro m16c-isa () (ISA m16c)) | |
146 | (define-pmacro m32c-isa () (ISA m32c)) | |
147 | ||
148 | (define-pmacro MACH16 (MACH m16c)) | |
149 | (define-pmacro MACH32 (MACH m32c)) | |
150 | ||
151 | (define-pmacro (machine size) | |
152 | (MACH (.sym m size c)) (ISA (.sym m size c))) | |
153 | \f | |
154 | ;============================================================= | |
155 | ; Fields | |
156 | ;------------------------------------------------------------- | |
157 | ; Main opcodes | |
158 | ; | |
159 | (dnf f-0-1 "opcode" (all-isas) 0 1) | |
160 | (dnf f-0-2 "opcode" (all-isas) 0 2) | |
161 | (dnf f-0-3 "opcode" (all-isas) 0 3) | |
162 | (dnf f-0-4 "opcode" (all-isas) 0 4) | |
163 | (dnf f-1-3 "opcode" (all-isas) 1 3) | |
164 | (dnf f-2-2 "opcode" (all-isas) 2 2) | |
165 | (dnf f-3-4 "opcode" (all-isas) 3 4) | |
166 | (dnf f-3-1 "opcode" (all-isas) 3 1) | |
167 | (dnf f-4-1 "opcode" (all-isas) 4 1) | |
168 | (dnf f-4-3 "opcode" (all-isas) 4 3) | |
169 | (dnf f-4-4 "opcode" (all-isas) 4 4) | |
170 | (dnf f-4-6 "opcode" (all-isas) 4 6) | |
171 | (dnf f-5-1 "opcode" (all-isas) 5 1) | |
172 | (dnf f-5-3 "opcode" (all-isas) 5 3) | |
173 | (dnf f-6-2 "opcode" (all-isas) 6 2) | |
174 | (dnf f-7-1 "opcode" (all-isas) 7 1) | |
175 | (dnf f-8-1 "opcode" (all-isas) 8 1) | |
176 | (dnf f-8-2 "opcode" (all-isas) 8 2) | |
177 | (dnf f-8-3 "opcode" (all-isas) 8 3) | |
178 | (dnf f-8-4 "opcode" (all-isas) 8 4) | |
179 | (dnf f-8-8 "opcode" (all-isas) 8 8) | |
180 | (dnf f-9-3 "opcode" (all-isas) 9 3) | |
181 | (dnf f-9-1 "opcode" (all-isas) 9 1) | |
182 | (dnf f-10-1 "opcode" (all-isas) 10 1) | |
183 | (dnf f-10-2 "opcode" (all-isas) 10 2) | |
184 | (dnf f-10-3 "opcode" (all-isas) 10 3) | |
185 | (dnf f-11-1 "opcode" (all-isas) 11 1) | |
186 | (dnf f-12-1 "opcode" (all-isas) 12 1) | |
187 | (dnf f-12-2 "opcode" (all-isas) 12 2) | |
188 | (dnf f-12-3 "opcode" (all-isas) 12 3) | |
189 | (dnf f-12-4 "opcode" (all-isas) 12 4) | |
190 | (dnf f-12-6 "opcode" (all-isas) 12 6) | |
191 | (dnf f-13-3 "opcode" (all-isas) 13 3) | |
192 | (dnf f-14-1 "opcode" (all-isas) 14 1) | |
193 | (dnf f-14-2 "opcode" (all-isas) 14 2) | |
194 | (dnf f-15-1 "opcode" (all-isas) 15 1) | |
195 | (dnf f-16-1 "opcode" (all-isas) 16 1) | |
196 | (dnf f-16-2 "opcode" (all-isas) 16 2) | |
197 | (dnf f-16-4 "opcode" (all-isas) 16 4) | |
e729279b | 198 | (dnf f-16-8 "opcode" (all-isas) 16 8) |
49f58d10 JB |
199 | (dnf f-18-1 "opcode" (all-isas) 18 1) |
200 | (dnf f-18-2 "opcode" (all-isas) 18 2) | |
201 | (dnf f-18-3 "opcode" (all-isas) 18 3) | |
202 | (dnf f-20-1 "opcode" (all-isas) 20 1) | |
203 | (dnf f-20-3 "opcode" (all-isas) 20 3) | |
204 | (dnf f-20-2 "opcode" (all-isas) 20 2) | |
205 | (dnf f-20-4 "opcode" (all-isas) 20 4) | |
206 | (dnf f-21-3 "opcode" (all-isas) 21 3) | |
207 | (dnf f-24-2 "opcode" (all-isas) 24 2) | |
e729279b NC |
208 | (dnf f-24-8 "opcode" (all-isas) 24 8) |
209 | (dnf f-32-16 "opcode" (all-isas) 32 16) | |
49f58d10 JB |
210 | |
211 | ;------------------------------------------------------------- | |
212 | ; Registers | |
213 | ;------------------------------------------------------------- | |
214 | ||
215 | (dnf f-src16-rn "source Rn for m16c" (MACH16 m16c-isa) 10 2) | |
216 | (dnf f-src16-an "source An for m16c" (MACH16 m16c-isa) 11 1) | |
217 | ||
218 | (dnf f-src32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 11 1) | |
219 | (dnf f-src32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 19 1) | |
220 | ||
221 | ; QI mode gr encoding for m32c is different than for m16c. The hardware | |
222 | ; is indexed using the m16c encoding, so perform the transformation here. | |
223 | ; register m16c m32c | |
224 | ; ---------------------- | |
225 | ; r0l 00'b 10'b | |
226 | ; r0h 01'b 00'b | |
227 | ; r1l 10'b 11'b | |
228 | ; r1h 11'b 01'b | |
229 | (df f-src32-rn-unprefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 10 2 UINT | |
230 | ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert | |
231 | ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract | |
232 | ) | |
233 | ; QI mode gr encoding for m32c is different than for m16c. The hardware | |
234 | ; is indexed using the m16c encoding, so perform the transformation here. | |
235 | ; register m16c m32c | |
236 | ; ---------------------- | |
237 | ; r0l 00'b 10'b | |
238 | ; r0h 01'b 00'b | |
239 | ; r1l 10'b 11'b | |
240 | ; r1h 11'b 01'b | |
241 | (df f-src32-rn-prefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 18 2 UINT | |
242 | ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert | |
243 | ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract | |
244 | ) | |
245 | ; HI mode gr encoding for m32c is different than for m16c. The hardware | |
246 | ; is indexed using the m16c encoding, so perform the transformation here. | |
247 | ; register m16c m32c | |
248 | ; ---------------------- | |
249 | ; r0 00'b 10'b | |
250 | ; r1 01'b 11'b | |
251 | ; r2 10'b 00'b | |
252 | ; r3 11'b 01'b | |
253 | (df f-src32-rn-unprefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 10 2 UINT | |
254 | ((value pc) (mod USI (add value 2) 4)) ; insert | |
255 | ((value pc) (mod USI (add value 2) 4)) ; extract | |
256 | ) | |
257 | ||
258 | ; HI mode gr encoding for m32c is different than for m16c. The hardware | |
259 | ; is indexed using the m16c encoding, so perform the transformation here. | |
260 | ; register m16c m32c | |
261 | ; ---------------------- | |
262 | ; r0 00'b 10'b | |
263 | ; r1 01'b 11'b | |
264 | ; r2 10'b 00'b | |
265 | ; r3 11'b 01'b | |
266 | (df f-src32-rn-prefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 18 2 UINT | |
267 | ((value pc) (mod USI (add value 2) 4)) ; insert | |
268 | ((value pc) (mod USI (add value 2) 4)) ; extract | |
269 | ) | |
270 | ||
271 | ; SI mode gr encoding for m32c is as follows: | |
272 | ; register encoding index | |
273 | ; ------------------------- | |
274 | ; r2r0 10'b 0 | |
275 | ; r3r1 11'b 1 | |
276 | (df f-src32-rn-unprefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 10 2 UINT | |
277 | ((value pc) (add USI value 2)) ; insert | |
278 | ((value pc) (sub USI value 2)) ; extract | |
279 | ) | |
280 | (df f-src32-rn-prefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 18 2 UINT | |
281 | ((value pc) (add USI value 2)) ; insert | |
282 | ((value pc) (sub USI value 2)) ; extract | |
283 | ) | |
284 | ||
285 | (dnf f-dst32-rn-ext-unprefixed "destination Rn for m32c" (MACH32 m32c-isa) 9 1) | |
286 | ||
287 | (dnf f-dst16-rn "destination Rn for m16c" (MACH16 m16c-isa) 14 2) | |
288 | (dnf f-dst16-rn-ext "destination Rn for m16c" (MACH16 m16c-isa) 14 1) | |
289 | (dnf f-dst16-rn-QI-s "destination Rn for m16c" (MACH16 m16c-isa) 5 1) | |
290 | ||
291 | (dnf f-dst16-an "destination An for m16c" (MACH16 m16c-isa) 15 1) | |
292 | (dnf f-dst16-an-s "destination An for m16c" (MACH16 m16c-isa) 4 1) | |
293 | ||
294 | (dnf f-dst32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 9 1) | |
295 | (dnf f-dst32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 17 1) | |
296 | ||
297 | ; QI mode gr encoding for m32c is different than for m16c. The hardware | |
298 | ; is indexed using the m16c encoding, so perform the transformation here. | |
299 | ; register m16c m32c | |
300 | ; ---------------------- | |
301 | ; r0l 00'b 10'b | |
302 | ; r0h 01'b 00'b | |
303 | ; r1l 10'b 11'b | |
304 | ; r1h 11'b 01'b | |
305 | (df f-dst32-rn-unprefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 8 2 UINT | |
306 | ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert | |
307 | ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract | |
308 | ) | |
309 | (df f-dst32-rn-prefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 16 2 UINT | |
310 | ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert | |
311 | ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract | |
312 | ) | |
313 | ; HI mode gr encoding for m32c is different than for m16c. The hardware | |
314 | ; is indexed using the m16c encoding, so perform the transformation here. | |
315 | ; register m16c m32c | |
316 | ; ---------------------- | |
317 | ; r0 00'b 10'b | |
318 | ; r1 01'b 11'b | |
319 | ; r2 10'b 00'b | |
320 | ; r3 11'b 01'b | |
321 | (df f-dst32-rn-unprefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 8 2 UINT | |
322 | ((value pc) (mod USI (add value 2) 4)) ; insert | |
323 | ((value pc) (mod USI (add value 2) 4)) ; extract | |
324 | ) | |
325 | (df f-dst32-rn-prefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 16 2 UINT | |
326 | ((value pc) (mod USI (add value 2) 4)) ; insert | |
327 | ((value pc) (mod USI (add value 2) 4)) ; extract | |
328 | ) | |
329 | ; SI mode gr encoding for m32c is as follows: | |
330 | ; register encoding index | |
331 | ; ------------------------- | |
332 | ; r2r0 10'b 0 | |
333 | ; r3r1 11'b 1 | |
334 | (df f-dst32-rn-unprefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 8 2 UINT | |
335 | ((value pc) (add USI value 2)) ; insert | |
336 | ((value pc) (sub USI value 2)) ; extract | |
337 | ) | |
338 | (df f-dst32-rn-prefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 16 2 UINT | |
339 | ((value pc) (add USI value 2)) ; insert | |
340 | ((value pc) (sub USI value 2)) ; extract | |
341 | ) | |
342 | ||
343 | (dnf f-dst16-1-S "destination R0[hl] for m16c" (MACH16 m16c-isa) 5 1) | |
344 | ||
345 | ;------------------------------------------------------------- | |
346 | ; Immediates embedded in the base insn | |
347 | ;------------------------------------------------------------- | |
348 | ||
349 | (df f-imm-8-s4 "4 bit signed" (all-isas) 8 4 INT #f #f) | |
350 | (df f-imm-12-s4 "4 bit signed" (all-isas) 12 4 INT #f #f) | |
351 | (df f-imm-13-u3 "3 bit unsigned" (all-isas) 13 3 UINT #f #f) | |
352 | (df f-imm-20-s4 "4 bit signed" (all-isas) 20 4 INT #f #f) | |
353 | ||
354 | (df f-imm1-S "1 bit immediate for short format binary insns" (MACH32 m32c-isa) 2 1 UINT | |
355 | ((value pc) (sub USI value 1)) ; insert | |
356 | ((value pc) (add USI value 1)) ; extract | |
357 | ) | |
358 | ||
359 | (dnmf f-imm3-S "3 bit unsigned for short format insns" (all-isas) UINT | |
360 | (f-2-2 f-7-1) | |
361 | (sequence () ; insert | |
362 | (set (ifield f-7-1) (and (sub (ifield f-imm3-S) 1) 1)) | |
363 | (set (ifield f-2-2) (and (srl (sub (ifield f-imm3-S) 1) 1) #x3)) | |
364 | ) | |
365 | (sequence () ; extract | |
366 | (set (ifield f-imm3-S) (add (or (sll (ifield f-2-2) 1) | |
367 | (ifield f-7-1)) | |
368 | 1)) | |
369 | ) | |
370 | ) | |
371 | ||
372 | ;------------------------------------------------------------- | |
373 | ; Immediates and displacements beyond the base insn | |
374 | ;------------------------------------------------------------- | |
375 | ||
376 | (df f-dsp-8-u6 "6 bit unsigned" (all-isas) 8 6 UINT #f #f) | |
377 | (df f-dsp-8-u8 "8 bit unsigned" (all-isas) 8 8 UINT #f #f) | |
378 | (df f-dsp-8-s8 "8 bit signed" (all-isas) 8 8 INT #f #f) | |
379 | (df f-dsp-10-u6 "6 bit unsigned" (all-isas) 10 6 UINT #f #f) | |
380 | (df f-dsp-16-u8 "8 bit unsigned" (all-isas) 16 8 UINT #f #f) | |
381 | (df f-dsp-16-s8 "8 bit signed" (all-isas) 16 8 INT #f #f) | |
382 | (df f-dsp-24-u8 "8 bit unsigned" (all-isas) 24 8 UINT #f #f) | |
383 | (df f-dsp-24-s8 "8 bit signed" (all-isas) 24 8 INT #f #f) | |
384 | (df f-dsp-32-u8 "8 bit unsigned" (all-isas) 32 8 UINT #f #f) | |
385 | (df f-dsp-32-s8 "8 bit signed" (all-isas) 32 8 INT #f #f) | |
386 | (df f-dsp-40-u8 "8 bit unsigned" (all-isas) 40 8 UINT #f #f) | |
387 | (df f-dsp-40-s8 "8 bit signed" (all-isas) 40 8 INT #f #f) | |
388 | (df f-dsp-48-u8 "8 bit unsigned" (all-isas) 48 8 UINT #f #f) | |
389 | (df f-dsp-48-s8 "8 bit signed" (all-isas) 48 8 INT #f #f) | |
390 | (df f-dsp-56-u8 "8 bit unsigned" (all-isas) 56 8 UINT #f #f) | |
391 | (df f-dsp-56-s8 "8 bit signed" (all-isas) 56 8 INT #f #f) | |
392 | (df f-dsp-64-u8 "8 bit unsigned" (all-isas) 64 8 UINT #f #f) | |
393 | (df f-dsp-64-s8 "8 bit signed" (all-isas) 64 8 INT #f #f) | |
394 | ||
395 | ; Insn opcode endianness is big, but the immediate fields are stored | |
396 | ; in little endian. Handle this here at the field level for all immediate | |
397 | ; fields longer that 1 byte. | |
398 | ; | |
399 | ; CGEN can't handle a field which spans a 32 bit word boundary, so | |
400 | ; handle those as multi ifields. | |
401 | ; | |
402 | ; Take care in expressions using 'srl' or 'sll' as part of some larger | |
403 | ; expression meant to yield sign-extended values. CGEN translates | |
404 | ; uses of those operators into C expressions whose type is 'unsigned | |
405 | ; int', which tends to make the whole expression 'unsigned int'. | |
406 | ; Expressions like (set (ifield foo) X), however, just take X and | |
407 | ; store it in some member of 'struct cgen_fields', all of whose | |
408 | ; members are 'long'. On machines where 'long' is larger than | |
409 | ; 'unsigned int', assigning a "sign-extended" unsigned int to a long | |
410 | ; just produces a very large positive value. insert_normal will | |
411 | ; range-check the field's value and produce odd error messages like | |
412 | ; this: | |
413 | ; | |
414 | ; Error: operand out of range (4160684031 not between -2147483648 and 2147483647) `add.l #-265,-270[fb]' | |
415 | ; | |
416 | ; Annoyingly, the code will work fine on machines where 'long' and | |
417 | ; 'unsigned int' are the same size: the assignment will produce a | |
418 | ; negative number. | |
419 | ; | |
420 | ; Just tell yourself over and over: overflow detection is expensive, | |
421 | ; and you're glad C doesn't do it, because it never happens in real | |
422 | ; life. | |
423 | ||
424 | (df f-dsp-8-u16 "16 bit unsigned" (all-isas) 8 16 UINT | |
425 | ((value pc) (or UHI | |
426 | (and (srl value 8) #x00ff) | |
427 | (and (sll value 8) #xff00))) ; insert | |
428 | ((value pc) (or UHI | |
429 | (and UHI (srl UHI value 8) #x00ff) | |
430 | (and UHI (sll UHI value 8) #xff00))) ; extract | |
431 | ) | |
432 | ||
433 | (df f-dsp-8-s16 "8 bit signed" (all-isas) 8 16 INT | |
434 | ((value pc) (ext INT | |
435 | (trunc HI | |
436 | (or (and (srl value 8) #x00ff) | |
437 | (and (sll value 8) #xff00))))) ; insert | |
438 | ((value pc) (ext INT | |
439 | (trunc HI | |
440 | (or (and (srl value 8) #x00ff) | |
441 | (and (sll value 8) #xff00))))) ; extract | |
442 | ) | |
443 | ||
444 | (df f-dsp-16-u16 "16 bit unsigned" (all-isas) 16 16 UINT | |
445 | ((value pc) (or UHI | |
446 | (and (srl value 8) #x00ff) | |
447 | (and (sll value 8) #xff00))) ; insert | |
448 | ((value pc) (or UHI | |
449 | (and UHI (srl UHI value 8) #x00ff) | |
450 | (and UHI (sll UHI value 8) #xff00))) ; extract | |
451 | ) | |
452 | ||
453 | (df f-dsp-16-s16 "16 bit signed" (all-isas) 16 16 INT | |
454 | ((value pc) (ext INT | |
455 | (trunc HI | |
456 | (or (and (srl value 8) #x00ff) | |
457 | (and (sll value 8) #xff00))))) ; insert | |
458 | ((value pc) (ext INT | |
459 | (trunc HI | |
460 | (or (and (srl value 8) #x00ff) | |
461 | (and (sll value 8) #xff00))))) ; extract | |
462 | ) | |
463 | ||
464 | (dnmf f-dsp-24-u16 "16 bit unsigned" (all-isas) UINT | |
465 | (f-dsp-24-u8 f-dsp-32-u8) | |
466 | (sequence () ; insert | |
467 | (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u16) #xff)) | |
468 | (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-24-u16) 8) #xff)) | |
469 | ) | |
470 | (sequence () ; extract | |
471 | (set (ifield f-dsp-24-u16) (or (sll (ifield f-dsp-32-u8) 8) | |
472 | (ifield f-dsp-24-u8))) | |
473 | ) | |
474 | ) | |
475 | ||
476 | (dnmf f-dsp-24-s16 "16 bit signed" (all-isas) INT | |
477 | (f-dsp-24-u8 f-dsp-32-u8) | |
478 | (sequence () ; insert | |
479 | (set (ifield f-dsp-24-u8) | |
480 | (and (ifield f-dsp-24-s16) #xff)) | |
481 | (set (ifield f-dsp-32-u8) | |
482 | (and (srl (ifield f-dsp-24-s16) 8) #xff)) | |
483 | ) | |
484 | (sequence () ; extract | |
485 | (set (ifield f-dsp-24-s16) | |
486 | (ext INT | |
487 | (trunc HI (or (sll (ifield f-dsp-32-u8) 8) | |
488 | (ifield f-dsp-24-u8))))) | |
489 | ) | |
490 | ) | |
491 | ||
492 | (df f-dsp-32-u16 "16 bit unsigned" (all-isas) 32 16 UINT | |
493 | ((value pc) (or UHI | |
494 | (and (srl value 8) #x00ff) | |
495 | (and (sll value 8) #xff00))) ; insert | |
496 | ((value pc) (or UHI | |
497 | (and UHI (srl UHI value 8) #x00ff) | |
498 | (and UHI (sll UHI value 8) #xff00))) ; extract | |
499 | ) | |
500 | ||
501 | (df f-dsp-32-s16 "16 bit signed" (all-isas) 32 16 INT | |
502 | ((value pc) (ext INT | |
503 | (trunc HI | |
504 | (or (and (srl value 8) #x00ff) | |
505 | (and (sll value 8) #xff00))))) ; insert | |
506 | ((value pc) (ext INT | |
507 | (trunc HI | |
508 | (or (and (srl value 8) #x00ff) | |
509 | (and (sll value 8) #xff00))))) ; extract | |
510 | ) | |
511 | ||
512 | (df f-dsp-40-u16 "16 bit unsigned" (all-isas) 40 16 UINT | |
513 | ((value pc) (or UHI | |
514 | (and (srl value 8) #x00ff) | |
515 | (and (sll value 8) #xff00))) ; insert | |
516 | ((value pc) (or UHI | |
517 | (and UHI (srl UHI value 8) #x00ff) | |
518 | (and UHI (sll UHI value 8) #xff00))) ; extract | |
519 | ) | |
520 | ||
521 | (df f-dsp-40-s16 "16 bit signed" (all-isas) 40 16 INT | |
522 | ((value pc) (ext INT | |
523 | (trunc HI | |
524 | (or (and (srl value 8) #x00ff) | |
525 | (and (sll value 8) #xff00))))) ; insert | |
526 | ((value pc) (ext INT | |
527 | (trunc HI | |
528 | (or (and (srl value 8) #x00ff) | |
529 | (and (sll value 8) #xff00))))) ; extract | |
530 | ) | |
531 | ||
532 | (df f-dsp-48-u16 "16 bit unsigned" (all-isas) 48 16 UINT | |
533 | ((value pc) (or UHI | |
534 | (and (srl value 8) #x00ff) | |
535 | (and (sll value 8) #xff00))) ; insert | |
536 | ((value pc) (or UHI | |
537 | (and UHI (srl UHI value 8) #x00ff) | |
538 | (and UHI (sll UHI value 8) #xff00))) ; extract | |
539 | ) | |
540 | ||
541 | (df f-dsp-48-s16 "16 bit signed" (all-isas) 48 16 INT | |
542 | ((value pc) (ext INT | |
543 | (trunc HI | |
544 | (or (and (srl value 8) #x00ff) | |
545 | (and (sll value 8) #xff00))))) ; insert | |
546 | ((value pc) (ext INT | |
547 | (trunc HI | |
548 | (or (and (srl value 8) #x00ff) | |
549 | (and (sll value 8) #xff00))))) ; extract | |
550 | ) | |
551 | ||
552 | (df f-dsp-64-u16 "16 bit unsigned" (all-isas) 64 16 UINT | |
553 | ((value pc) (or UHI | |
554 | (and (srl value 8) #x00ff) | |
555 | (and (sll value 8) #xff00))) ; insert | |
556 | ((value pc) (or UHI | |
557 | (and UHI (srl UHI value 8) #x00ff) | |
558 | (and UHI (sll UHI value 8) #xff00))) ; extract | |
559 | ) | |
f75eb1c0 DD |
560 | (df f-dsp-8-s24 "24 bit signed" (all-isas) 8 24 INT |
561 | ((value pc) (or SI | |
562 | (or (srl value 16) (and value #xff00)) | |
563 | (sll (ext INT (trunc QI (and value #xff))) 16))) | |
564 | ((value pc) (or SI | |
565 | (or (srl value 16) (and value #xff00)) | |
566 | (sll (ext INT (trunc QI (and value #xff))) 16))) | |
567 | ) | |
568 | ||
e729279b NC |
569 | (df f-dsp-8-u24 "24 bit unsigned" (all-isas) 8 24 UINT |
570 | ((value pc) (or SI | |
571 | (or (srl value 16) (and value #xff00)) | |
572 | (sll (and value #xff) 16))) | |
573 | ((value pc) (or SI | |
574 | (or (srl value 16) (and value #xff00)) | |
575 | (sll (and value #xff) 16))) | |
576 | ) | |
49f58d10 JB |
577 | |
578 | (dnmf f-dsp-16-u24 "24 bit unsigned" (all-isas) UINT | |
579 | (f-dsp-16-u16 f-dsp-32-u8) | |
580 | (sequence () ; insert | |
581 | (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-u24) #xffff)) | |
582 | (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-16-u24) 16) #xff)) | |
583 | ) | |
584 | (sequence () ; extract | |
585 | (set (ifield f-dsp-16-u24) (or (sll (ifield f-dsp-32-u8) 16) | |
586 | (ifield f-dsp-16-u16))) | |
587 | ) | |
588 | ) | |
589 | ||
590 | (dnmf f-dsp-24-u24 "24 bit unsigned" (all-isas) UINT | |
591 | (f-dsp-24-u8 f-dsp-32-u16) | |
592 | (sequence () ; insert | |
593 | (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u24) #xff)) | |
594 | (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-24-u24) 8) #xffff)) | |
595 | ) | |
596 | (sequence () ; extract | |
597 | (set (ifield f-dsp-24-u24) (or (sll (ifield f-dsp-32-u16) 8) | |
598 | (ifield f-dsp-24-u8))) | |
599 | ) | |
600 | ) | |
601 | ||
602 | (df f-dsp-32-u24 "24 bit unsigned" (all-isas) 32 24 UINT | |
603 | ((value pc) (or USI | |
604 | (or USI | |
605 | (and (srl value 16) #x0000ff) | |
606 | (and value #x00ff00)) | |
607 | (and (sll value 16) #xff0000))) ; insert | |
608 | ((value pc) (or USI | |
609 | (or USI | |
610 | (and USI (srl UHI value 16) #x0000ff) | |
611 | (and USI value #x00ff00)) | |
612 | (and USI (sll UHI value 16) #xff0000))) ; extract | |
613 | ) | |
614 | ||
615 | (df f-dsp-40-u24 "24 bit unsigned" (all-isas) 40 24 UINT | |
616 | ((value pc) (or USI | |
617 | (or USI | |
618 | (and (srl value 16) #x0000ff) | |
619 | (and value #x00ff00)) | |
620 | (and (sll value 16) #xff0000))) ; insert | |
621 | ((value pc) (or USI | |
622 | (or USI | |
623 | (and USI (srl UHI value 16) #x0000ff) | |
624 | (and USI value #x00ff00)) | |
625 | (and USI (sll UHI value 16) #xff0000))) ; extract | |
626 | ) | |
627 | ||
628 | (dnmf f-dsp-40-s32 "32 bit signed" (all-isas) INT | |
629 | (f-dsp-40-u24 f-dsp-64-u8) | |
630 | (sequence () ; insert | |
631 | (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-40-s32) 24) #xff)) | |
632 | (set (ifield f-dsp-40-u24) (and (ifield f-dsp-40-s32) #xffffff)) | |
633 | ) | |
634 | (sequence () ; extract | |
635 | (set (ifield f-dsp-40-s32) (or (and (ifield f-dsp-40-u24) #xffffff) | |
636 | (and (sll (ifield f-dsp-64-u8) 24) #xff000000))) | |
637 | ) | |
638 | ) | |
639 | ||
640 | (dnmf f-dsp-48-u24 "24 bit unsigned" (all-isas) UINT | |
641 | (f-dsp-48-u16 f-dsp-64-u8) | |
642 | (sequence () ; insert | |
643 | (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-48-u24) 16) #xff)) | |
644 | (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u24) #xffff)) | |
645 | ) | |
646 | (sequence () ; extract | |
647 | (set (ifield f-dsp-48-u24) (or (and (ifield f-dsp-48-u16) #xffff) | |
648 | (and (sll (ifield f-dsp-64-u8) 16) #xff0000))) | |
649 | ) | |
650 | ) | |
651 | ||
652 | (dnmf f-dsp-16-s32 "32 bit signed" (all-isas) INT | |
653 | (f-dsp-16-u16 f-dsp-32-u16) | |
654 | (sequence () ; insert | |
655 | (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-16-s32) 16) #xffff)) | |
656 | (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-s32) #xffff)) | |
657 | ) | |
658 | (sequence () ; extract | |
659 | (set (ifield f-dsp-16-s32) (or (and (ifield f-dsp-16-u16) #xffff) | |
660 | (and (sll (ifield f-dsp-32-u16) 16) #xffff0000))) | |
661 | ) | |
662 | ) | |
663 | ||
664 | (dnmf f-dsp-24-s32 "32 bit signed" (all-isas) INT | |
665 | (f-dsp-24-u8 f-dsp-32-u24) | |
666 | (sequence () ; insert | |
667 | (set (ifield f-dsp-32-u24) (and (srl (ifield f-dsp-24-s32) 8) #xffffff)) | |
668 | (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-s32) #xff)) | |
669 | ) | |
670 | (sequence () ; extract | |
671 | (set (ifield f-dsp-24-s32) (or (and (ifield f-dsp-24-u8) #xff) | |
672 | (and (sll (ifield f-dsp-32-u24) 8) #xffffff00))) | |
673 | ) | |
674 | ) | |
675 | ||
676 | (df f-dsp-32-s32 "32 bit signed" (all-isas) 32 32 INT | |
677 | ((value pc) | |
678 | ||
679 | ;; insert | |
680 | (ext INT | |
681 | (or SI | |
682 | (or SI | |
683 | (and (srl value 24) #x000000ff) | |
684 | (and (srl value 8) #x0000ff00)) | |
685 | (or SI | |
686 | (and (sll value 8) #x00ff0000) | |
687 | (and (sll value 24) #xff000000))))) | |
688 | ||
689 | ;; extract | |
690 | ((value pc) | |
691 | (ext INT | |
692 | (or SI | |
693 | (or SI | |
694 | (and (srl value 24) #x000000ff) | |
695 | (and (srl value 8) #x0000ff00)) | |
696 | (or SI | |
697 | (and (sll value 8) #x00ff0000) | |
698 | (and (sll value 24) #xff000000))))) | |
699 | ) | |
700 | ||
701 | (dnmf f-dsp-48-u32 "32 bit unsigned" (all-isas) UINT | |
702 | (f-dsp-48-u16 f-dsp-64-u16) | |
703 | (sequence () ; insert | |
704 | (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-u32) 16) #xffff)) | |
705 | (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u32) #xffff)) | |
706 | ) | |
707 | (sequence () ; extract | |
708 | (set (ifield f-dsp-48-u32) (or (and (ifield f-dsp-48-u16) #xffff) | |
709 | (and (sll (ifield f-dsp-64-u16) 16) #xffff0000))) | |
710 | ) | |
711 | ) | |
712 | ||
713 | (dnmf f-dsp-48-s32 "32 bit signed" (all-isas) INT | |
714 | (f-dsp-48-u16 f-dsp-64-u16) | |
715 | (sequence () ; insert | |
716 | (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-s32) 16) #xffff)) | |
717 | (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-s32) #xffff)) | |
718 | ) | |
719 | (sequence () ; extract | |
720 | (set (ifield f-dsp-48-s32) (or (and (ifield f-dsp-48-u16) #xffff) | |
721 | (and (sll (ifield f-dsp-64-u16) 16) #xffff0000))) | |
722 | ) | |
723 | ) | |
724 | ||
725 | (dnmf f-dsp-56-s16 "16 bit signed" (all-isas) INT | |
726 | (f-dsp-56-u8 f-dsp-64-u8) | |
727 | (sequence () ; insert | |
728 | (set (ifield f-dsp-56-u8) | |
729 | (and (ifield f-dsp-56-s16) #xff)) | |
730 | (set (ifield f-dsp-64-u8) | |
731 | (and (srl (ifield f-dsp-56-s16) 8) #xff)) | |
732 | ) | |
733 | (sequence () ; extract | |
734 | (set (ifield f-dsp-56-s16) | |
735 | (ext INT | |
736 | (trunc HI (or (sll (ifield f-dsp-64-u8) 8) | |
737 | (ifield f-dsp-56-u8))))) | |
738 | ) | |
739 | ) | |
740 | ||
741 | (df f-dsp-64-s16 " 16 bit signed" (all-isas) 64 16 INT | |
742 | ((value pc) (ext INT | |
743 | (trunc HI | |
744 | (or (and (srl value 8) #x00ff) | |
745 | (and (sll value 8) #xff00))))) ; insert | |
746 | ((value pc) (ext INT | |
747 | (trunc HI | |
748 | (or (and (srl value 8) #x00ff) | |
749 | (and (sll value 8) #xff00))))) ; extract | |
750 | ) | |
751 | ||
752 | ;------------------------------------------------------------- | |
753 | ; Bit indices | |
754 | ;------------------------------------------------------------- | |
755 | ||
756 | (dnf f-bitno16-S "bit index for m16c" (all-isas) 5 3) | |
757 | (dnf f-bitno32-prefixed "bit index for m32c" (all-isas) 21 3) | |
758 | (dnf f-bitno32-unprefixed "bit index for m32c" (all-isas) 13 3) | |
759 | ||
760 | (dnmf f-bitbase16-u11-S "unsigned bit,base:11" (all-isas) UINT | |
761 | (f-bitno16-S f-dsp-8-u8) | |
762 | (sequence () ; insert | |
763 | (set (ifield f-bitno16-S) (and f-bitbase16-u11-S #x7)) | |
764 | (set (ifield f-dsp-8-u8) (and (srl (ifield f-bitbase16-u11-S) 3) #xff)) | |
765 | ) | |
766 | (sequence () ; extract | |
767 | (set (ifield f-bitbase16-u11-S) (or (sll (ifield f-dsp-8-u8) 3) | |
768 | (ifield f-bitno16-S))) | |
769 | ) | |
770 | ) | |
771 | ||
772 | (dnmf f-bitbase32-16-u11-unprefixed "unsigned bit,base:11" (all-isas) UINT | |
773 | (f-bitno32-unprefixed f-dsp-16-u8) | |
774 | (sequence () ; insert | |
775 | (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u11-unprefixed #x7)) | |
776 | (set (ifield f-dsp-16-u8) (and (srl (ifield f-bitbase32-16-u11-unprefixed) 3) #xff)) | |
777 | ) | |
778 | (sequence () ; extract | |
779 | (set (ifield f-bitbase32-16-u11-unprefixed) (or (sll (ifield f-dsp-16-u8) 3) | |
780 | (ifield f-bitno32-unprefixed))) | |
781 | ) | |
782 | ) | |
783 | (dnmf f-bitbase32-16-s11-unprefixed "signed bit,base:11" (all-isas) INT | |
784 | (f-bitno32-unprefixed f-dsp-16-s8) | |
785 | (sequence () ; insert | |
786 | (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s11-unprefixed #x7)) | |
787 | (set (ifield f-dsp-16-s8) (sra INT (ifield f-bitbase32-16-s11-unprefixed) 3)) | |
788 | ) | |
789 | (sequence () ; extract | |
790 | (set (ifield f-bitbase32-16-s11-unprefixed) (or (sll (ifield f-dsp-16-s8) 3) | |
791 | (ifield f-bitno32-unprefixed))) | |
792 | ) | |
793 | ) | |
794 | (dnmf f-bitbase32-16-u19-unprefixed "unsigned bit,base:19" (all-isas) UINT | |
795 | (f-bitno32-unprefixed f-dsp-16-u16) | |
796 | (sequence () ; insert | |
797 | (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u19-unprefixed #x7)) | |
798 | (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u19-unprefixed) 3) #xffff)) | |
799 | ) | |
800 | (sequence () ; extract | |
801 | (set (ifield f-bitbase32-16-u19-unprefixed) (or (sll (ifield f-dsp-16-u16) 3) | |
802 | (ifield f-bitno32-unprefixed))) | |
803 | ) | |
804 | ) | |
805 | (dnmf f-bitbase32-16-s19-unprefixed "signed bit,base:11" (all-isas) INT | |
806 | (f-bitno32-unprefixed f-dsp-16-s16) | |
807 | (sequence () ; insert | |
808 | (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s19-unprefixed #x7)) | |
809 | (set (ifield f-dsp-16-s16) (sra INT (ifield f-bitbase32-16-s19-unprefixed) 3)) | |
810 | ) | |
811 | (sequence () ; extract | |
812 | (set (ifield f-bitbase32-16-s19-unprefixed) (or (sll (ifield f-dsp-16-s16) 3) | |
813 | (ifield f-bitno32-unprefixed))) | |
814 | ) | |
815 | ) | |
816 | ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-( | |
817 | (dnmf f-bitbase32-16-u27-unprefixed "unsigned bit,base:27" (all-isas) UINT | |
818 | (f-bitno32-unprefixed f-dsp-16-u16 f-dsp-32-u8) | |
819 | (sequence () ; insert | |
820 | (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u27-unprefixed #x7)) | |
821 | (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 3) #xffff)) | |
822 | (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 19) #xff)) | |
823 | ) | |
824 | (sequence () ; extract | |
825 | (set (ifield f-bitbase32-16-u27-unprefixed) (or (sll (ifield f-dsp-16-u16) 3) | |
826 | (or (sll (ifield f-dsp-32-u8) 19) | |
827 | (ifield f-bitno32-unprefixed)))) | |
828 | ) | |
829 | ) | |
830 | (dnmf f-bitbase32-24-u11-prefixed "unsigned bit,base:11" (all-isas) UINT | |
831 | (f-bitno32-prefixed f-dsp-24-u8) | |
832 | (sequence () ; insert | |
833 | (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u11-prefixed #x7)) | |
834 | (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u11-prefixed) 3) #xff)) | |
835 | ) | |
836 | (sequence () ; extract | |
837 | (set (ifield f-bitbase32-24-u11-prefixed) (or (sll (ifield f-dsp-24-u8) 3) | |
838 | (ifield f-bitno32-prefixed))) | |
839 | ) | |
840 | ) | |
841 | (dnmf f-bitbase32-24-s11-prefixed "signed bit,base:11" (all-isas) INT | |
842 | (f-bitno32-prefixed f-dsp-24-s8) | |
843 | (sequence () ; insert | |
844 | (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s11-prefixed #x7)) | |
845 | (set (ifield f-dsp-24-s8) (sra INT (ifield f-bitbase32-24-s11-prefixed) 3)) | |
846 | ) | |
847 | (sequence () ; extract | |
848 | (set (ifield f-bitbase32-24-s11-prefixed) (or (sll (ifield f-dsp-24-s8) 3) | |
849 | (ifield f-bitno32-prefixed))) | |
850 | ) | |
851 | ) | |
852 | ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-( | |
853 | (dnmf f-bitbase32-24-u19-prefixed "unsigned bit,base:19" (all-isas) UINT | |
854 | (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u8) | |
855 | (sequence () ; insert | |
856 | (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u19-prefixed #x7)) | |
857 | (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 3) #xff)) | |
858 | (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 11) #xff)) | |
859 | ) | |
860 | (sequence () ; extract | |
861 | (set (ifield f-bitbase32-24-u19-prefixed) (or (sll (ifield f-dsp-24-u8) 3) | |
862 | (or (sll (ifield f-dsp-32-u8) 11) | |
863 | (ifield f-bitno32-prefixed)))) | |
864 | ) | |
865 | ) | |
866 | ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-( | |
867 | (dnmf f-bitbase32-24-s19-prefixed "signed bit,base:11" (all-isas) INT | |
868 | (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-s8) | |
869 | (sequence () ; insert | |
870 | (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s19-prefixed #x7)) | |
871 | (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-s19-prefixed) 3) #xff)) | |
872 | (set (ifield f-dsp-32-s8) (sra INT (ifield f-bitbase32-24-s19-prefixed) 11)) | |
873 | ) | |
874 | (sequence () ; extract | |
875 | (set (ifield f-bitbase32-24-s19-prefixed) (or (sll (ifield f-dsp-24-u8) 3) | |
876 | (or (sll (ifield f-dsp-32-s8) 11) | |
877 | (ifield f-bitno32-prefixed)))) | |
878 | ) | |
879 | ) | |
880 | ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-( | |
881 | (dnmf f-bitbase32-24-u27-prefixed "unsigned bit,base:27" (all-isas) UINT | |
882 | (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u16) | |
883 | (sequence () ; insert | |
884 | (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u27-prefixed #x7)) | |
885 | (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u27-prefixed) 3) #xff)) | |
886 | (set (ifield f-dsp-32-u16) (and (srl (ifield f-bitbase32-24-u27-prefixed) 11) #xffff)) | |
887 | ) | |
888 | (sequence () ; extract | |
889 | (set (ifield f-bitbase32-24-u27-prefixed) (or (sll (ifield f-dsp-24-u8) 3) | |
890 | (or (sll (ifield f-dsp-32-u16) 11) | |
891 | (ifield f-bitno32-prefixed)))) | |
892 | ) | |
893 | ) | |
894 | ||
895 | ;------------------------------------------------------------- | |
896 | ; Labels | |
897 | ;------------------------------------------------------------- | |
898 | ||
e729279b | 899 | (df f-lab-5-3 "3 bit pc relative unsigned offset" (PCREL-ADDR all-isas) 5 3 UINT |
49f58d10 JB |
900 | ((value pc) (sub SI value (add SI pc 2))) ; insert |
901 | ((value pc) (add SI value (add SI pc 2))) ; extract | |
902 | ) | |
903 | (dnmf f-lab32-jmp-s "unsigned 3 bit pc relative offset" (PCREL-ADDR all-isas) UINT | |
904 | (f-2-2 f-7-1) | |
e729279b NC |
905 | (sequence ((SI val)) ; insert |
906 | (set val (sub (sub (ifield f-lab32-jmp-s) pc) 2)) | |
907 | (set (ifield f-7-1) (and val #x1)) | |
908 | (set (ifield f-2-2) (srl val 1)) | |
49f58d10 JB |
909 | ) |
910 | (sequence () ; extract | |
911 | (set (ifield f-lab32-jmp-s) (add pc (add (or (sll (ifield f-2-2) 1) | |
912 | (ifield f-7-1)) | |
913 | 2))) | |
914 | ) | |
915 | ) | |
916 | (df f-lab-8-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 8 8 INT | |
917 | ((value pc) (sub SI value (add SI pc 1))) ; insert | |
918 | ((value pc) (add SI value (add SI pc 1))) ; extract | |
919 | ) | |
920 | (df f-lab-8-16 "16 bit pc relative signed offset" (PCREL-ADDR SIGN-OPT all-isas) 8 16 UINT | |
921 | ((value pc) (or SI (sll (and (sub value (add pc 1)) #xff) 8) | |
922 | (srl (and (sub value (add pc 1)) #xffff) 8))) | |
923 | ((value pc) (add SI (or (srl (and value #xffff) 8) | |
924 | (sra (sll (and value #xff) 24) 16)) (add pc 1))) | |
925 | ) | |
926 | (df f-lab-8-24 "24 bit absolute" (all-isas ABS-ADDR) 8 24 UINT | |
927 | ((value pc) (or SI | |
928 | (or (srl value 16) (and value #xff00)) | |
929 | (sll (and value #xff) 16))) | |
930 | ((value pc) (or SI | |
931 | (or (srl value 16) (and value #xff00)) | |
932 | (sll (and value #xff) 16))) | |
933 | ) | |
934 | (df f-lab-16-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 16 8 INT | |
935 | ((value pc) (sub SI value (add SI pc 2))) ; insert | |
936 | ((value pc) (add SI value (add SI pc 2))) ; extract | |
937 | ) | |
938 | (df f-lab-24-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 24 8 INT | |
939 | ((value pc) (sub SI value (add SI pc 2))) ; insert | |
940 | ((value pc) (add SI value (add SI pc 2))) ; extract | |
941 | ) | |
942 | (df f-lab-32-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 32 8 INT | |
943 | ((value pc) (sub SI value (add SI pc 2))) ; insert | |
944 | ((value pc) (add SI value (add SI pc 2))) ; extract | |
945 | ) | |
946 | (df f-lab-40-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 40 8 INT | |
947 | ((value pc) (sub SI value (add SI pc 2))) ; insert | |
948 | ((value pc) (add SI value (add SI pc 2))) ; extract | |
949 | ) | |
950 | ||
951 | ;------------------------------------------------------------- | |
952 | ; Condition codes | |
953 | ;------------------------------------------------------------- | |
954 | ||
955 | (dnf f-cond16 "condition code" (all-isas) 12 4) | |
956 | (dnf f-cond16j-5 "condition code" (all-isas) 5 3) | |
957 | ||
958 | (dnmf f-cond32 "condition code" (all-isas) UINT | |
959 | (f-9-1 f-13-3) | |
960 | (sequence () ; insert | |
961 | (set (ifield f-9-1) (and (srl (ifield f-cond32) 3) 1)) | |
962 | (set (ifield f-13-3) (and (ifield f-cond32) #x7)) | |
963 | ) | |
964 | (sequence () ; extract | |
965 | (set (ifield f-cond32) (or (sll (ifield f-9-1) 3) | |
966 | (ifield f-13-3))) | |
967 | ) | |
968 | ) | |
969 | ||
970 | (dnmf f-cond32j "condition code" (all-isas) UINT | |
971 | (f-1-3 f-7-1) | |
972 | (sequence () ; insert | |
973 | (set (ifield f-1-3) (and (srl (ifield f-cond32j) 1) #x7)) | |
974 | (set (ifield f-7-1) (and (ifield f-cond32j) #x1)) | |
975 | ) | |
976 | (sequence () ; extract | |
977 | (set (ifield f-cond32j) (or (sll (ifield f-1-3) 1) | |
978 | (ifield f-7-1))) | |
979 | ) | |
980 | ) | |
981 | \f | |
982 | ;============================================================= | |
983 | ; Hardware | |
984 | ; | |
985 | (dnh h-pc "program counter" (PC all-isas) (pc USI) () () ()) | |
986 | ||
987 | ;------------------------------------------------------------- | |
988 | ; General registers | |
989 | ; The actual registers are 16 bits | |
990 | ;------------------------------------------------------------- | |
991 | ||
992 | (define-hardware | |
993 | (name h-gr) | |
994 | (comment "general 16 bit registers") | |
995 | (attrs all-isas CACHE-ADDR) | |
996 | (type register HI (4)) | |
997 | (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3)))) | |
998 | ||
999 | ; Define different views of the grs as VIRTUAL with getter/setter specs | |
1000 | ; | |
1001 | (define-hardware | |
1002 | (name h-gr-QI) | |
1003 | (comment "general 8 bit registers") | |
1004 | (attrs all-isas VIRTUAL) | |
1005 | (type register QI (4)) | |
1006 | (indices keyword "" (("r0l" 0) ("r0h" 1) ("r1l" 2) ("r1h" 3))) | |
1007 | (get (index) (and (if SI (mod index 2) | |
1008 | (srl (reg h-gr (div index 2)) 8) | |
1009 | (reg h-gr (div index 2))) | |
1010 | #xff)) | |
1011 | (set (index newval) (set (reg h-gr (div index 2)) | |
1012 | (if SI (mod index 2) | |
1013 | (or (and (reg h-gr (div index 2)) #xff) | |
1014 | (sll (and newval #xff) 8)) | |
1015 | (or (and (reg h-gr (div index 2)) #xff00) | |
1016 | (and newval #xff)))))) | |
1017 | ||
1018 | (define-hardware | |
1019 | (name h-gr-HI) | |
1020 | (comment "general 16 bit registers") | |
1021 | (attrs all-isas VIRTUAL) | |
1022 | (type register HI (4)) | |
1023 | (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3))) | |
1024 | (get (index) (reg h-gr index)) | |
1025 | (set (index newval) (set (reg h-gr index) newval))) | |
1026 | ||
1027 | (define-hardware | |
1028 | (name h-gr-SI) | |
1029 | (comment "general 32 bit registers") | |
1030 | (attrs all-isas VIRTUAL) | |
1031 | (type register SI (2)) | |
1032 | (indices keyword "" (("r2r0" 0) ("r3r1" 1))) | |
1033 | (get (index) (or SI | |
1034 | (and (reg h-gr index) #xffff) | |
1035 | (and (sll (reg h-gr (add index 2)) 16) #xffff0000))) | |
1036 | (set (index newval) (sequence () | |
1037 | (set (reg h-gr index) (and newval #xffff)) | |
1038 | (set (reg h-gr (add index 2)) (srl newval 16))))) | |
1039 | ||
1040 | (define-hardware | |
1041 | (name h-gr-ext-QI) | |
1042 | (comment "general 16 bit registers") | |
1043 | (attrs all-isas VIRTUAL) | |
1044 | (type register HI (2)) | |
1045 | (indices keyword "" (("r0l" 0) ("r1l" 1))) | |
1046 | (get (index) (reg h-gr-QI (mul index 2))) | |
1047 | (set (index newval) (set (reg h-gr (mul index 2)) newval))) | |
1048 | ||
1049 | (define-hardware | |
1050 | (name h-gr-ext-HI) | |
1051 | (comment "general 16 bit registers") | |
1052 | (attrs all-isas VIRTUAL) | |
1053 | (type register SI (2)) | |
1054 | (indices keyword "" (("r0" 0) ("r1" 1))) | |
1055 | (get (index) (reg h-gr (mul index 2))) | |
1056 | (set (index newval) (set (reg h-gr-SI index) newval))) | |
1057 | ||
1058 | (define-hardware | |
1059 | (name h-r0l) | |
1060 | (comment "r0l register") | |
1061 | (attrs all-isas VIRTUAL) | |
1062 | (type register QI) | |
1063 | (indices keyword "" (("r0l" 0))) | |
1064 | (get () (reg h-gr-QI 0)) | |
1065 | (set (newval) (set (reg h-gr-QI 0) newval))) | |
1066 | ||
1067 | (define-hardware | |
1068 | (name h-r0h) | |
1069 | (comment "r0h register") | |
1070 | (attrs all-isas VIRTUAL) | |
1071 | (type register QI) | |
1072 | (indices keyword "" (("r0h" 0))) | |
1073 | (get () (reg h-gr-QI 1)) | |
1074 | (set (newval) (set (reg h-gr-QI 1) newval))) | |
1075 | ||
1076 | (define-hardware | |
1077 | (name h-r1l) | |
1078 | (comment "r1l register") | |
1079 | (attrs all-isas VIRTUAL) | |
1080 | (type register QI) | |
1081 | (indices keyword "" (("r1l" 0))) | |
1082 | (get () (reg h-gr-QI 2)) | |
1083 | (set (newval) (set (reg h-gr-QI 2) newval))) | |
1084 | ||
1085 | (define-hardware | |
1086 | (name h-r1h) | |
1087 | (comment "r1h register") | |
1088 | (attrs all-isas VIRTUAL) | |
1089 | (type register QI) | |
1090 | (indices keyword "" (("r1h" 0))) | |
1091 | (get () (reg h-gr-QI 3)) | |
1092 | (set (newval) (set (reg h-gr-QI 3) newval))) | |
1093 | ||
1094 | (define-hardware | |
1095 | (name h-r0) | |
1096 | (comment "r0 register") | |
1097 | (attrs all-isas VIRTUAL) | |
1098 | (type register HI) | |
1099 | (indices keyword "" (("r0" 0))) | |
1100 | (get () (reg h-gr 0)) | |
1101 | (set (newval) (set (reg h-gr 0) newval))) | |
1102 | ||
1103 | (define-hardware | |
1104 | (name h-r1) | |
1105 | (comment "r1 register") | |
1106 | (attrs all-isas VIRTUAL) | |
1107 | (type register HI) | |
1108 | (indices keyword "" (("r1" 0))) | |
1109 | (get () (reg h-gr 1)) | |
1110 | (set (newval) (set (reg h-gr 1) newval))) | |
1111 | ||
1112 | (define-hardware | |
1113 | (name h-r2) | |
1114 | (comment "r2 register") | |
1115 | (attrs all-isas VIRTUAL) | |
1116 | (type register HI) | |
1117 | (indices keyword "" (("r2" 0))) | |
1118 | (get () (reg h-gr 2)) | |
1119 | (set (newval) (set (reg h-gr 2) newval))) | |
1120 | ||
1121 | (define-hardware | |
1122 | (name h-r3) | |
1123 | (comment "r3 register") | |
1124 | (attrs all-isas VIRTUAL) | |
1125 | (type register HI) | |
1126 | (indices keyword "" (("r3" 0))) | |
1127 | (get () (reg h-gr 3)) | |
1128 | (set (newval) (set (reg h-gr 3) newval))) | |
1129 | ||
1130 | (define-hardware | |
1131 | (name h-r0l-r0h) | |
1132 | (comment "r0l or r0h") | |
1133 | (attrs all-isas VIRTUAL) | |
1134 | (type register QI (2)) | |
1135 | (indices keyword "" (("r0l" 0) ("r0h" 1))) | |
1136 | (get (index) (reg h-gr-QI index)) | |
1137 | (set (index newval) (set (reg h-gr-QI index) newval))) | |
1138 | ||
1139 | (define-hardware | |
1140 | (name h-r2r0) | |
1141 | (comment "r2r0 register") | |
1142 | (attrs all-isas VIRTUAL) | |
1143 | (type register SI) | |
1144 | (indices keyword "" (("r2r0" 0))) | |
1145 | (get () (or (sll (reg h-gr 2) 16) (reg h-gr 0))) | |
1146 | (set (newval) | |
1147 | (sequence () | |
1148 | (set (reg h-gr 0) newval) | |
1149 | (set (reg h-gr 2) (sra newval 16))))) | |
1150 | ||
1151 | (define-hardware | |
1152 | (name h-r3r1) | |
1153 | (comment "r3r1 register") | |
1154 | (attrs all-isas VIRTUAL) | |
1155 | (type register SI) | |
1156 | (indices keyword "" (("r3r1" 0))) | |
1157 | (get () (or (sll (reg h-gr 3) 16) (reg h-gr 1))) | |
1158 | (set (newval) | |
1159 | (sequence () | |
1160 | (set (reg h-gr 1) newval) | |
1161 | (set (reg h-gr 3) (sra newval 16))))) | |
1162 | ||
1163 | (define-hardware | |
1164 | (name h-r1r2r0) | |
1165 | (comment "r1r2r0 register") | |
1166 | (attrs all-isas VIRTUAL) | |
1167 | (type register DI) | |
1168 | (indices keyword "" (("r1r2r0" 0))) | |
1169 | (get () (or DI (sll DI (reg h-gr 1) 32) (or (sll (reg h-gr 2) 16) (reg h-gr 0)))) | |
1170 | (set (newval) | |
1171 | (sequence () | |
1172 | (set (reg h-gr 0) newval) | |
1173 | (set (reg h-gr 2) (sra newval 16)) | |
1174 | (set (reg h-gr 1) (sra newval 32))))) | |
1175 | ||
1176 | ;------------------------------------------------------------- | |
1177 | ; Address registers | |
1178 | ;------------------------------------------------------------- | |
1179 | ||
1180 | (define-hardware | |
1181 | (name h-ar) | |
1182 | (comment "address registers") | |
1183 | (attrs all-isas) | |
1184 | (type register USI (2)) | |
1185 | (indices keyword "" (("a0" 0) ("a1" 1))) | |
1186 | (get (index) (c-call USI "h_ar_get_handler" index)) | |
1187 | (set (index newval) (c-call VOID "h_ar_set_handler" index newval))) | |
1188 | ||
1189 | ; Define different views of the ars as VIRTUAL with getter/setter specs | |
1190 | (define-hardware | |
1191 | (name h-ar-QI) | |
1192 | (comment "8 bit view of address register") | |
1193 | (attrs all-isas VIRTUAL) | |
1194 | (type register QI (2)) | |
1195 | (indices keyword "" (("a0" 0) ("a1" 1))) | |
1196 | (get (index) (reg h-ar index)) | |
1197 | (set (index newval) (set (reg h-ar index) newval))) | |
1198 | ||
1199 | (define-hardware | |
1200 | (name h-ar-HI) | |
1201 | (comment "16 bit view of address register") | |
1202 | (attrs all-isas VIRTUAL) | |
1203 | (type register HI (2)) | |
1204 | (indices keyword "" (("a0" 0) ("a1" 1))) | |
1205 | (get (index) (reg h-ar index)) | |
1206 | (set (index newval) (set (reg h-ar index) newval))) | |
1207 | ||
1208 | (define-hardware | |
1209 | (name h-ar-SI) | |
1210 | (comment "32 bit view of address register") | |
1211 | (attrs all-isas VIRTUAL) | |
1212 | (type register SI) | |
1213 | (indices keyword "" (("a1a0" 0))) | |
1214 | (get () (or SI (sll SI (ext SI (reg h-ar 1)) 16) (ext SI (reg h-ar 0)))) | |
1215 | (set (newval) (sequence () | |
1216 | (set (reg h-ar 0) (and newval #xffff)) | |
1217 | (set (reg h-ar 1) (and (srl newval 16) #xffff))))) | |
1218 | ||
1219 | (define-hardware | |
1220 | (name h-a0) | |
1221 | (comment "16 bit view of address register") | |
1222 | (attrs all-isas VIRTUAL) | |
1223 | (type register HI) | |
1224 | (indices keyword "" (("a0" 0))) | |
1225 | (get () (reg h-ar 0)) | |
1226 | (set (newval) (set (reg h-ar 0) newval))) | |
1227 | ||
1228 | (define-hardware | |
1229 | (name h-a1) | |
1230 | (comment "16 bit view of address register") | |
1231 | (attrs all-isas VIRTUAL) | |
1232 | (type register HI) | |
1233 | (indices keyword "" (("a1" 1))) | |
1234 | (get () (reg h-ar 1)) | |
1235 | (set (newval) (set (reg h-ar 1) newval))) | |
1236 | ||
1237 | ; SB Register | |
1238 | (define-hardware | |
1239 | (name h-sb) | |
1240 | (comment "SB register") | |
1241 | (attrs all-isas) | |
1242 | (type register USI) | |
1243 | (get () (c-call USI "h_sb_get_handler")) | |
1244 | (set (newval) (c-call VOID "h_sb_set_handler" newval)) | |
1245 | ) | |
1246 | ||
1247 | ; FB Register | |
1248 | (define-hardware | |
1249 | (name h-fb) | |
1250 | (comment "FB register") | |
1251 | (attrs all-isas) | |
1252 | (type register USI) | |
1253 | (get () (c-call USI "h_fb_get_handler")) | |
1254 | (set (newval) (c-call VOID "h_fb_set_handler" newval)) | |
1255 | ) | |
1256 | ||
1257 | ; SP Register | |
1258 | (define-hardware | |
1259 | (name h-sp) | |
1260 | (comment "SP register") | |
1261 | (attrs all-isas) | |
1262 | (type register USI) | |
1263 | (get () (c-call USI "h_sp_get_handler")) | |
1264 | (set (newval) (c-call VOID "h_sp_set_handler" newval)) | |
1265 | ) | |
1266 | ||
1267 | ;------------------------------------------------------------- | |
1268 | ; condition-code bits | |
1269 | ;------------------------------------------------------------- | |
1270 | ||
1271 | (define-hardware | |
1272 | (name h-sbit) | |
1273 | (comment "sign bit") | |
1274 | (attrs all-isas) | |
1275 | (type register BI) | |
1276 | ) | |
1277 | ||
1278 | (define-hardware | |
1279 | (name h-zbit) | |
1280 | (comment "zero bit") | |
1281 | (attrs all-isas) | |
1282 | (type register BI) | |
1283 | ) | |
1284 | ||
1285 | (define-hardware | |
1286 | (name h-obit) | |
1287 | (comment "overflow bit") | |
1288 | (attrs all-isas) | |
1289 | (type register BI) | |
1290 | ) | |
1291 | ||
1292 | (define-hardware | |
1293 | (name h-cbit) | |
1294 | (comment "carry bit") | |
1295 | (attrs all-isas) | |
1296 | (type register BI) | |
1297 | ) | |
1298 | ||
1299 | (define-hardware | |
1300 | (name h-ubit) | |
1301 | (comment "stack pointer select bit") | |
1302 | (attrs all-isas) | |
1303 | (type register BI) | |
1304 | ) | |
1305 | ||
1306 | (define-hardware | |
1307 | (name h-ibit) | |
1308 | (comment "interrupt enable bit") | |
1309 | (attrs all-isas) | |
1310 | (type register BI) | |
1311 | ) | |
1312 | ||
1313 | (define-hardware | |
1314 | (name h-bbit) | |
1315 | (comment "register bank select bit") | |
1316 | (attrs all-isas) | |
1317 | (type register BI) | |
1318 | ) | |
1319 | ||
1320 | (define-hardware | |
1321 | (name h-dbit) | |
1322 | (comment "debug bit") | |
1323 | (attrs all-isas) | |
1324 | (type register BI) | |
1325 | ) | |
1326 | ||
1327 | (define-hardware | |
1328 | (name h-dct0) | |
1329 | (comment "dma transfer count 000") | |
1330 | (attrs all-isas) | |
1331 | (type register UHI) | |
1332 | ) | |
1333 | (define-hardware | |
1334 | (name h-dct1) | |
1335 | (comment "dma transfer count 001") | |
1336 | (attrs all-isas) | |
1337 | (type register UHI) | |
1338 | ) | |
1339 | (define-hardware | |
1340 | (name h-svf) | |
1341 | (comment "save flag 011") | |
1342 | (attrs all-isas) | |
1343 | (type register UHI) | |
1344 | ) | |
1345 | (define-hardware | |
1346 | (name h-drc0) | |
1347 | (comment "dma transfer count reload 100") | |
1348 | (attrs all-isas) | |
1349 | (type register UHI) | |
1350 | ) | |
1351 | (define-hardware | |
1352 | (name h-drc1) | |
1353 | (comment "dma transfer count reload 101") | |
1354 | (attrs all-isas) | |
1355 | (type register UHI) | |
1356 | ) | |
1357 | (define-hardware | |
1358 | (name h-dmd0) | |
1359 | (comment "dma mode 110") | |
1360 | (attrs all-isas) | |
1361 | (type register UQI) | |
1362 | ) | |
1363 | (define-hardware | |
1364 | (name h-dmd1) | |
1365 | (comment "dma mode 111") | |
1366 | (attrs all-isas) | |
1367 | (type register UQI) | |
1368 | ) | |
1369 | (define-hardware | |
1370 | (name h-intb) | |
1371 | (comment "interrupt table 000") | |
1372 | (attrs all-isas) | |
1373 | (type register USI) | |
1374 | ) | |
1375 | (define-hardware | |
1376 | (name h-svp) | |
1377 | (comment "save pc 100") | |
1378 | (attrs all-isas) | |
1379 | (type register UHI) | |
1380 | ) | |
1381 | (define-hardware | |
1382 | (name h-vct) | |
1383 | (comment "vector 101") | |
1384 | (attrs all-isas) | |
1385 | (type register USI) | |
1386 | ) | |
1387 | (define-hardware | |
1388 | (name h-isp) | |
1389 | (comment "interrupt stack ptr 111") | |
1390 | (attrs all-isas) | |
1391 | (type register USI) | |
1392 | ) | |
1393 | (define-hardware | |
1394 | (name h-dma0) | |
1395 | (comment "dma mem addr 010") | |
1396 | (attrs all-isas) | |
1397 | (type register USI) | |
1398 | ) | |
1399 | (define-hardware | |
1400 | (name h-dma1) | |
1401 | (comment "dma mem addr 011") | |
1402 | (attrs all-isas) | |
1403 | (type register USI) | |
1404 | ) | |
1405 | (define-hardware | |
1406 | (name h-dra0) | |
1407 | (comment "dma mem addr reload 100") | |
1408 | (attrs all-isas) | |
1409 | (type register USI) | |
1410 | ) | |
1411 | (define-hardware | |
1412 | (name h-dra1) | |
1413 | (comment "dma mem addr reload 101") | |
1414 | (attrs all-isas) | |
1415 | (type register USI) | |
1416 | ) | |
1417 | (define-hardware | |
1418 | (name h-dsa0) | |
1419 | (comment "dma sfr addr 110") | |
1420 | (attrs all-isas) | |
1421 | (type register USI) | |
1422 | ) | |
1423 | (define-hardware | |
1424 | (name h-dsa1) | |
1425 | (comment "dma sfr addr 111") | |
1426 | (attrs all-isas) | |
1427 | (type register USI) | |
1428 | ) | |
1429 | ||
1430 | ;------------------------------------------------------------- | |
1431 | ; Condition code operand hardware | |
1432 | ;------------------------------------------------------------- | |
1433 | ||
1434 | (define-hardware | |
1435 | (name h-cond16) | |
1436 | (comment "condition code hardware for m16c") | |
1437 | (attrs m16c-isa MACH16) | |
1438 | (type immediate UQI) | |
1439 | (values keyword "" | |
1440 | (("geu" #x00) ("c" #x00) | |
1441 | ("gtu" #x01) | |
1442 | ("eq" #x02) ("z" #x02) | |
1443 | ("n" #x03) | |
1444 | ("le" #x04) | |
1445 | ("o" #x05) | |
1446 | ("ge" #x06) | |
1447 | ("ltu" #xf8) ("nc" #xf8) | |
1448 | ("leu" #xf9) | |
1449 | ("ne" #xfa) ("nz" #xfa) | |
1450 | ("pz" #xfb) | |
1451 | ("gt" #xfc) | |
1452 | ("no" #xfd) | |
1453 | ("lt" #xfe) | |
1454 | ) | |
1455 | ) | |
1456 | ) | |
1457 | (define-hardware | |
1458 | (name h-cond16c) | |
1459 | (comment "condition code hardware for m16c") | |
1460 | (attrs m16c-isa MACH16) | |
1461 | (type immediate UQI) | |
1462 | (values keyword "" | |
1463 | (("geu" #x00) ("c" #x00) | |
1464 | ("gtu" #x01) | |
1465 | ("eq" #x02) ("z" #x02) | |
1466 | ("n" #x03) | |
1467 | ("ltu" #x04) ("nc" #x04) | |
1468 | ("leu" #x05) | |
1469 | ("ne" #x06) ("nz" #x06) | |
1470 | ("pz" #x07) | |
1471 | ("le" #x08) | |
1472 | ("o" #x09) | |
1473 | ("ge" #x0a) | |
1474 | ("gt" #x0c) | |
1475 | ("no" #x0d) | |
1476 | ("lt" #x0e) | |
1477 | ) | |
1478 | ) | |
1479 | ) | |
1480 | (define-hardware | |
1481 | (name h-cond16j) | |
1482 | (comment "condition code hardware for m16c") | |
1483 | (attrs m16c-isa MACH16) | |
1484 | (type immediate UQI) | |
1485 | (values keyword "" | |
1486 | (("le" #x08) | |
1487 | ("o" #x09) | |
1488 | ("ge" #x0a) | |
1489 | ("gt" #x0c) | |
1490 | ("no" #x0d) | |
1491 | ("lt" #x0e) | |
1492 | ) | |
1493 | ) | |
1494 | ) | |
1495 | (define-hardware | |
1496 | (name h-cond16j-5) | |
1497 | (comment "condition code hardware for m16c") | |
1498 | (attrs m16c-isa MACH16) | |
1499 | (type immediate UQI) | |
1500 | (values keyword "" | |
1501 | (("geu" #x00) ("c" #x00) | |
1502 | ("gtu" #x01) | |
1503 | ("eq" #x02) ("z" #x02) | |
1504 | ("n" #x03) | |
1505 | ("ltu" #x04) ("nc" #x04) | |
1506 | ("leu" #x05) | |
1507 | ("ne" #x06) ("nz" #x06) | |
1508 | ("pz" #x07) | |
1509 | ) | |
1510 | ) | |
1511 | ) | |
1512 | ||
1513 | (define-hardware | |
1514 | (name h-cond32) | |
1515 | (comment "condition code hardware for m32c") | |
1516 | (attrs m32c-isa MACH32) | |
1517 | (type immediate UQI) | |
1518 | (values keyword "" | |
1519 | (("ltu" #x00) ("nc" #x00) | |
1520 | ("leu" #x01) | |
1521 | ("ne" #x02) ("nz" #x02) | |
1522 | ("pz" #x03) | |
1523 | ("no" #x04) | |
1524 | ("gt" #x05) | |
1525 | ("ge" #x06) | |
1526 | ("geu" #x08) ("c" #x08) | |
1527 | ("gtu" #x09) | |
1528 | ("eq" #x0a) ("z" #x0a) | |
1529 | ("n" #x0b) | |
1530 | ("o" #x0c) | |
1531 | ("le" #x0d) | |
1532 | ("lt" #x0e) | |
1533 | ) | |
1534 | ) | |
1535 | ) | |
1536 | ||
1537 | (define-hardware | |
1538 | (name h-cr1-32) | |
1539 | (comment "control registers") | |
1540 | (attrs m32c-isa MACH32) | |
1541 | (type immediate UQI) | |
1542 | (values keyword "" (("dct0" 0) ("dct1" 1) ("flg" 2) ("svf" 3) ("drc0" 4) | |
1543 | ("drc1" 5) ("dmd0" 6) ("dmd1" 7)))) | |
1544 | (define-hardware | |
1545 | (name h-cr2-32) | |
1546 | (comment "control registers") | |
1547 | (attrs m32c-isa MACH32) | |
1548 | (type immediate UQI) | |
1549 | (values keyword "" (("intb" 0) ("sp" 1) ("sb" 2) ("fb" 3) ("svp" 4) | |
1550 | ("vct" 5) ("isp" 7)))) | |
1551 | ||
1552 | (define-hardware | |
1553 | (name h-cr3-32) | |
1554 | (comment "control registers") | |
1555 | (attrs m32c-isa MACH32) | |
1556 | (type immediate UQI) | |
1557 | (values keyword "" (("dma0" 2) ("dma1" 3) ("dra0" 4) | |
1558 | ("dra1" 5) ("dsa0" 6) ("dsa1" 7)))) | |
1559 | (define-hardware | |
1560 | (name h-cr-16) | |
1561 | (comment "control registers") | |
1562 | (attrs m16c-isa MACH16) | |
1563 | (type immediate UQI) | |
1564 | (values keyword "" (("intbl" 1) ("intbh" 2) ("flg" 3) ("isp" 4) | |
1565 | ("sp" 5) ("sb" 6) ("fb" 7)))) | |
1566 | ||
1567 | (define-hardware | |
1568 | (name h-flags) | |
1569 | (comment "flag hardware for m32c") | |
1570 | (attrs all-isas) | |
1571 | (type immediate UQI) | |
1572 | (values keyword "" | |
1573 | (("c" #x0) | |
1574 | ("d" #x1) | |
1575 | ("z" #x2) | |
1576 | ("s" #x3) | |
1577 | ("b" #x4) | |
1578 | ("o" #x5) | |
1579 | ("i" #x6) | |
1580 | ("u" #x7) | |
1581 | ) | |
1582 | ) | |
1583 | ) | |
1584 | ||
1585 | ;------------------------------------------------------------- | |
1586 | ; Misc helper hardware | |
1587 | ;------------------------------------------------------------- | |
1588 | ||
1589 | (define-hardware | |
1590 | (name h-shimm) | |
1591 | (comment "shift immediate") | |
1592 | (attrs all-isas) | |
1593 | (type immediate (INT 4)) | |
1594 | (values keyword "" (("1" 0) ("2" 1) ("3" 2) ("4" 3) ("5" 4) ("6" 5) ("7" 6) | |
1595 | ("8" 7) ("-1" -8) ("-2" -7) ("-3" -6) ("-4" -5) ("-5" -4) | |
1596 | ("-6" -3) ("-7" -2) ("-8" -1) | |
1597 | ))) | |
1598 | (define-hardware | |
1599 | (name h-bit-index) | |
1600 | (comment "bit index for the next insn") | |
1601 | (attrs m32c-isa MACH32) | |
1602 | (type register UHI) | |
1603 | ) | |
1604 | (define-hardware | |
1605 | (name h-src-index) | |
1606 | (comment "source index for the next insn") | |
1607 | (attrs m32c-isa MACH32) | |
1608 | (type register UHI) | |
1609 | ) | |
1610 | (define-hardware | |
1611 | (name h-dst-index) | |
1612 | (comment "destination index for the next insn") | |
1613 | (attrs m32c-isa MACH32) | |
1614 | (type register UHI) | |
1615 | ) | |
1616 | (define-hardware | |
1617 | (name h-src-indirect) | |
1618 | (comment "indirect src for the next insn") | |
1619 | (attrs all-isas) | |
1620 | (type register UHI) | |
1621 | ) | |
1622 | (define-hardware | |
1623 | (name h-dst-indirect) | |
1624 | (comment "indirect dst for the next insn") | |
1625 | (attrs all-isas) | |
1626 | (type register UHI) | |
1627 | ) | |
1628 | (define-hardware | |
1629 | (name h-none) | |
1630 | (comment "for storing unused values") | |
1631 | (attrs m32c-isa MACH32) | |
1632 | (type register SI) | |
1633 | ) | |
1634 | \f | |
1635 | ;============================================================= | |
1636 | ; Operands | |
1637 | ;------------------------------------------------------------- | |
1638 | ; Source Registers | |
1639 | ;------------------------------------------------------------- | |
1640 | ||
1641 | (dnop Src16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-src16-rn) | |
1642 | (dnop Src16RnHI "general register QH view" (MACH16 m16c-isa) h-gr-HI f-src16-rn) | |
1643 | ||
1644 | (dnop Src32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-unprefixed-QI) | |
1645 | (dnop Src32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-unprefixed-HI) | |
1646 | (dnop Src32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-unprefixed-SI) | |
1647 | ||
1648 | (dnop Src32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-prefixed-QI) | |
1649 | (dnop Src32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-prefixed-HI) | |
1650 | (dnop Src32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-prefixed-SI) | |
1651 | ||
1652 | (dnop Src16An "address register" (MACH16 m16c-isa) h-ar f-src16-an) | |
1653 | (dnop Src16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-src16-an) | |
1654 | (dnop Src16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-src16-an) | |
1655 | ||
1656 | (dnop Src32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed) | |
1657 | (dnop Src32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-unprefixed) | |
1658 | (dnop Src32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-unprefixed) | |
1659 | (dnop Src32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed) | |
1660 | ||
1661 | (dnop Src32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-prefixed) | |
1662 | (dnop Src32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-prefixed) | |
1663 | (dnop Src32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-prefixed) | |
1664 | (dnop Src32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-prefixed) | |
1665 | ||
1666 | ; Destination Registers | |
1667 | ; | |
1668 | (dnop Dst16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-dst16-rn) | |
1669 | (dnop Dst16RnHI "general register HI view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn) | |
1670 | (dnop Dst16RnSI "general register SI view" (MACH16 m16c-isa) h-gr-SI f-dst16-rn) | |
1671 | (dnop Dst16RnExtQI "general register QI/HI view for 'ext' insns" (MACH16 m16c-isa) h-gr-ext-QI f-dst16-rn-ext) | |
1672 | ||
1673 | (dnop Dst32R0QI-S "general register QI view" (MACH32 m32c-isa) h-r0l f-nil) | |
1674 | (dnop Dst32R0HI-S "general register HI view" (MACH32 m32c-isa) h-r0 f-nil) | |
1675 | ||
1676 | (dnop Dst32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI) | |
1677 | (dnop Dst32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-unprefixed-HI) | |
1678 | (dnop Dst32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-unprefixed-SI) | |
1679 | (dnop Dst32RnExtUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-ext-QI f-dst32-rn-ext-unprefixed) | |
1680 | (dnop Dst32RnExtUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-ext-HI f-dst32-rn-ext-unprefixed) | |
1681 | ||
1682 | (dnop Dst32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI) | |
1683 | (dnop Dst32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-prefixed-HI) | |
1684 | (dnop Dst32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-prefixed-SI) | |
1685 | ||
1686 | (dnop Dst16RnQI-S "general register QI view" (MACH16 m16c-isa) h-r0l-r0h f-dst16-rn-QI-s) | |
1687 | ||
1688 | (dnop Dst16AnQI-S "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-rn-QI-s) | |
1689 | ||
1690 | (dnop Bit16Rn "general register bit view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn) | |
1691 | ||
1692 | (dnop Bit32RnPrefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI) | |
1693 | (dnop Bit32RnUnprefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI) | |
1694 | ||
1695 | (dnop R0 "r0" (all-isas) h-r0 f-nil) | |
1696 | (dnop R1 "r1" (all-isas) h-r1 f-nil) | |
1697 | (dnop R2 "r2" (all-isas) h-r2 f-nil) | |
1698 | (dnop R3 "r3" (all-isas) h-r3 f-nil) | |
1699 | (dnop R0l "r0l" (all-isas) h-r0l f-nil) | |
1700 | (dnop R0h "r0h" (all-isas) h-r0h f-nil) | |
1701 | (dnop R2R0 "r2r0" (all-isas) h-r2r0 f-nil) | |
1702 | (dnop R3R1 "r3r1" (all-isas) h-r3r1 f-nil) | |
1703 | (dnop R1R2R0 "r1r2r0" (all-isas) h-r1r2r0 f-nil) | |
1704 | ||
1705 | (dnop Dst16An "address register" (MACH16 m16c-isa) h-ar f-dst16-an) | |
1706 | (dnop Dst16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-an) | |
1707 | (dnop Dst16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an) | |
1708 | (dnop Dst16AnSI "address register SI view" (MACH16 m16c-isa) h-ar-SI f-dst16-an) | |
1709 | (dnop Dst16An-S "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an-s) | |
1710 | ||
1711 | (dnop Dst32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed) | |
1712 | (dnop Dst32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-unprefixed) | |
1713 | (dnop Dst32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-unprefixed) | |
1714 | (dnop Dst32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed) | |
1715 | ||
1716 | (dnop Dst32AnExtUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed) | |
1717 | ||
1718 | (dnop Dst32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed) | |
1719 | (dnop Dst32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-prefixed) | |
1720 | (dnop Dst32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-prefixed) | |
1721 | (dnop Dst32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed) | |
1722 | ||
1723 | (dnop Bit16An "address register bit view" (MACH16 m16c-isa) h-ar f-dst16-an) | |
1724 | ||
1725 | (dnop Bit32AnPrefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed) | |
1726 | (dnop Bit32AnUnprefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed) | |
1727 | ||
1728 | (dnop A0 "a0" (all-isas) h-a0 f-nil) | |
1729 | (dnop A1 "a1" (all-isas) h-a1 f-nil) | |
1730 | ||
1731 | (dnop sb "SB register" (all-isas SEM-ONLY) h-sb f-nil) | |
1732 | (dnop fb "FB register" (all-isas SEM-ONLY) h-fb f-nil) | |
1733 | (dnop sp "SP register" (all-isas SEM-ONLY) h-sp f-nil) | |
1734 | ||
1735 | (define-full-operand SrcDst16-r0l-r0h-S-normal "r0l/r0h pair" (MACH16 m16c-isa) | |
1736 | h-sint DFLT f-5-1 | |
1737 | ((parse "r0l_r0h") (print "r0l_r0h")) () () | |
1738 | ) | |
1739 | ||
1740 | (define-full-operand Regsetpop "popm regset" (all-isas) h-uint | |
1741 | DFLT f-8-8 ((parse "pop_regset") (print "pop_regset")) () ()) | |
1742 | (define-full-operand Regsetpush "pushm regset" (all-isas) h-uint | |
1743 | DFLT f-8-8 ((parse "push_regset") (print "push_regset")) () ()) | |
1744 | ||
1745 | (dnop Rn16-push-S "r0[lh]" (MACH16 m16c-isa) h-gr-QI f-4-1) | |
1746 | (dnop An16-push-S "a[01]" (MACH16 m16c-isa) h-ar-HI f-4-1) | |
1747 | ||
1748 | ;------------------------------------------------------------- | |
1749 | ; Offsets and absolutes | |
1750 | ;------------------------------------------------------------- | |
1751 | ||
1752 | (define-full-operand Dsp-8-u6 "unsigned 6 bit displacement at offset 8 bits" (all-isas) | |
1753 | h-uint DFLT f-dsp-8-u6 | |
1754 | ((parse "unsigned6")) () () | |
1755 | ) | |
1756 | (define-full-operand Dsp-8-u8 "unsigned 8 bit displacement at offset 8 bits" (all-isas) | |
1757 | h-uint DFLT f-dsp-8-u8 | |
1758 | ((parse "unsigned8")) () () | |
1759 | ) | |
1760 | (define-full-operand Dsp-8-u16 "unsigned 16 bit displacement at offset 8 bits" (all-isas) | |
1761 | h-uint DFLT f-dsp-8-u16 | |
1762 | ((parse "unsigned16")) () () | |
1763 | ) | |
1764 | (define-full-operand Dsp-8-s8 "signed 8 bit displacement at offset 8 bits" (all-isas) | |
1765 | h-sint DFLT f-dsp-8-s8 | |
1766 | ((parse "signed8")) () () | |
1767 | ) | |
f75eb1c0 DD |
1768 | (define-full-operand Dsp-8-s24 "signed 24 bit displacement at offset 8 bits" (all-isas) |
1769 | h-sint DFLT f-dsp-8-s24 | |
1770 | ((parse "signed24")) () () | |
1771 | ) | |
e729279b NC |
1772 | (define-full-operand Dsp-8-u24 "unsigned 24 bit displacement at offset 8 bits" (all-isas) |
1773 | h-uint DFLT f-dsp-8-u24 | |
1774 | ((parse "unsigned24")) () () | |
1775 | ) | |
49f58d10 JB |
1776 | (define-full-operand Dsp-10-u6 "unsigned 6 bit displacement at offset 10 bits" (all-isas) |
1777 | h-uint DFLT f-dsp-10-u6 | |
1778 | ((parse "unsigned6")) () () | |
1779 | ) | |
1780 | (define-full-operand Dsp-16-u8 "unsigned 8 bit displacement at offset 16 bits" (all-isas) | |
1781 | h-uint DFLT f-dsp-16-u8 | |
1782 | ((parse "unsigned8")) () () | |
1783 | ) | |
1784 | (define-full-operand Dsp-16-u16 "unsigned 16 bit displacement at offset 16 bits" (all-isas) | |
1785 | h-uint DFLT f-dsp-16-u16 | |
1786 | ((parse "unsigned16")) () () | |
1787 | ) | |
1788 | (define-full-operand Dsp-16-u20 "unsigned 20 bit displacement at offset 16 bits" (all-isas) | |
1789 | h-uint DFLT f-dsp-16-u24 | |
1790 | ((parse "unsigned20")) () () | |
1791 | ) | |
1792 | (define-full-operand Dsp-16-u24 "unsigned 24 bit displacement at offset 16 bits" (all-isas) | |
1793 | h-uint DFLT f-dsp-16-u24 | |
1794 | ((parse "unsigned24")) () () | |
1795 | ) | |
1796 | (define-full-operand Dsp-16-s8 "signed 8 bit displacement at offset 16 bits" (all-isas) | |
1797 | h-sint DFLT f-dsp-16-s8 | |
1798 | ((parse "signed8")) () () | |
1799 | ) | |
1800 | (define-full-operand Dsp-16-s16 "signed 16 bit displacement at offset 16 bits" (all-isas) | |
1801 | h-sint DFLT f-dsp-16-s16 | |
1802 | ((parse "signed16")) () () | |
1803 | ) | |
1804 | (define-full-operand Dsp-24-u8 "unsigned 8 bit displacement at offset 24 bits" (all-isas) | |
1805 | h-uint DFLT f-dsp-24-u8 | |
1806 | ((parse "unsigned8")) () () | |
1807 | ) | |
1808 | (define-full-operand Dsp-24-u16 "unsigned 16 bit displacement at offset 24 bits" (all-isas) | |
1809 | h-uint DFLT f-dsp-24-u16 | |
1810 | ((parse "unsigned16")) () () | |
1811 | ) | |
1812 | (define-full-operand Dsp-24-u20 "unsigned 20 bit displacement at offset 24 bits" (all-isas) | |
1813 | h-uint DFLT f-dsp-24-u24 | |
1814 | ((parse "unsigned20")) () () | |
1815 | ) | |
1816 | (define-full-operand Dsp-24-u24 "unsigned 24 bit displacement at offset 24 bits" (all-isas) | |
1817 | h-uint DFLT f-dsp-24-u24 | |
1818 | ((parse "unsigned24")) () () | |
1819 | ) | |
1820 | (define-full-operand Dsp-24-s8 "signed 8 bit displacement at offset 24 bits" (all-isas) | |
1821 | h-sint DFLT f-dsp-24-s8 | |
1822 | ((parse "signed8")) () () | |
1823 | ) | |
1824 | (define-full-operand Dsp-24-s16 "signed 16 bit displacement at offset 24 bits" (all-isas) | |
1825 | h-sint DFLT f-dsp-24-s16 | |
1826 | ((parse "signed16")) () () | |
1827 | ) | |
1828 | (define-full-operand Dsp-32-u8 "unsigned 8 bit displacement at offset 32 bits" (all-isas) | |
1829 | h-uint DFLT f-dsp-32-u8 | |
1830 | ((parse "unsigned8")) () () | |
1831 | ) | |
1832 | (define-full-operand Dsp-32-u16 "unsigned 16 bit displacement at offset 32 bits" (all-isas) | |
1833 | h-uint DFLT f-dsp-32-u16 | |
1834 | ((parse "unsigned16")) () () | |
1835 | ) | |
1836 | (define-full-operand Dsp-32-u24 "unsigned 24 bit displacement at offset 32 bits" (all-isas) | |
1837 | h-uint DFLT f-dsp-32-u24 | |
1838 | ((parse "unsigned24")) () () | |
1839 | ) | |
1840 | (define-full-operand Dsp-32-u20 "unsigned 20 bit displacement at offset 32 bits" (all-isas) | |
1841 | h-uint DFLT f-dsp-32-u24 | |
1842 | ((parse "unsigned20")) () () | |
1843 | ) | |
1844 | (define-full-operand Dsp-32-s8 "signed 8 bit displacement at offset 32 bits" (all-isas) | |
1845 | h-sint DFLT f-dsp-32-s8 | |
1846 | ((parse "signed8")) () () | |
1847 | ) | |
1848 | (define-full-operand Dsp-32-s16 "signed 16 bit displacement at offset 32 bits" (all-isas) | |
1849 | h-sint DFLT f-dsp-32-s16 | |
1850 | ((parse "signed16")) () () | |
1851 | ) | |
1852 | (define-full-operand Dsp-40-u8 "unsigned 8 bit displacement at offset 40 bits" (all-isas) | |
1853 | h-uint DFLT f-dsp-40-u8 | |
1854 | ((parse "unsigned8")) () () | |
1855 | ) | |
1856 | (define-full-operand Dsp-40-s8 "signed 8 bit displacement at offset 40 bits" (all-isas) | |
e729279b | 1857 | h-sint DFLT f-dsp-40-s8 |
49f58d10 JB |
1858 | ((parse "signed8")) () () |
1859 | ) | |
1860 | (define-full-operand Dsp-40-u16 "unsigned 16 bit displacement at offset 40 bits" (all-isas) | |
1861 | h-uint DFLT f-dsp-40-u16 | |
1862 | ((parse "unsigned16")) () () | |
1863 | ) | |
1864 | (define-full-operand Dsp-40-s16 "signed 16 bit displacement at offset 40 bits" (all-isas) | |
e729279b | 1865 | h-sint DFLT f-dsp-40-s16 |
49f58d10 JB |
1866 | ((parse "signed16")) () () |
1867 | ) | |
1868 | (define-full-operand Dsp-40-u24 "unsigned 24 bit displacement at offset 40 bits" (all-isas) | |
1869 | h-uint DFLT f-dsp-40-u24 | |
1870 | ((parse "unsigned24")) () () | |
1871 | ) | |
1872 | (define-full-operand Dsp-48-u8 "unsigned 8 bit displacement at offset 48 bits" (all-isas) | |
1873 | h-uint DFLT f-dsp-48-u8 | |
1874 | ((parse "unsigned8")) () () | |
1875 | ) | |
1876 | (define-full-operand Dsp-48-s8 "signed 8 bit displacement at offset 48 bits" (all-isas) | |
e729279b | 1877 | h-sint DFLT f-dsp-48-s8 |
49f58d10 JB |
1878 | ((parse "signed8")) () () |
1879 | ) | |
1880 | (define-full-operand Dsp-48-u16 "unsigned 16 bit displacement at offset 48 bits" (all-isas) | |
1881 | h-uint DFLT f-dsp-48-u16 | |
1882 | ((parse "unsigned16")) () () | |
1883 | ) | |
1884 | (define-full-operand Dsp-48-s16 "signed 16 bit displacement at offset 48 bits" (all-isas) | |
e729279b | 1885 | h-sint DFLT f-dsp-48-s16 |
49f58d10 JB |
1886 | ((parse "signed16")) () () |
1887 | ) | |
1888 | (define-full-operand Dsp-48-u24 "unsigned 24 bit displacement at offset 48 bits" (all-isas) | |
1889 | h-uint DFLT f-dsp-48-u24 | |
1890 | ((parse "unsigned24")) () () | |
1891 | ) | |
1892 | ||
1893 | (define-full-operand Imm-8-s4 "signed 4 bit immediate at offset 8 bits" (all-isas) | |
1894 | h-sint DFLT f-imm-8-s4 | |
1895 | ((parse "signed4")) () () | |
1896 | ) | |
c6552317 DD |
1897 | (define-full-operand Imm-8-s4n "negated 4 bit immediate at offset 8 bits" (all-isas) |
1898 | h-sint DFLT f-imm-8-s4 | |
1899 | ((parse "signed4n")) () () | |
1900 | ) | |
49f58d10 JB |
1901 | (define-full-operand Imm-sh-8-s4 "signed 4 bit shift immediate at offset 8 bits" (all-isas) |
1902 | h-shimm DFLT f-imm-8-s4 | |
1903 | () () () | |
1904 | ) | |
1905 | (define-full-operand Imm-8-QI "signed 8 bit immediate at offset 8 bits" (all-isas) | |
1906 | h-sint DFLT f-dsp-8-s8 | |
1907 | ((parse "signed8")) () () | |
1908 | ) | |
1909 | (define-full-operand Imm-8-HI "signed 16 bit immediate at offset 8 bits" (all-isas) | |
1910 | h-sint DFLT f-dsp-8-s16 | |
1911 | ((parse "signed16")) () () | |
1912 | ) | |
1913 | (define-full-operand Imm-12-s4 "signed 4 bit immediate at offset 12 bits" (all-isas) | |
1914 | h-sint DFLT f-imm-12-s4 | |
1915 | ((parse "signed4")) () () | |
1916 | ) | |
c6552317 DD |
1917 | (define-full-operand Imm-12-s4n "negated 4 bit immediate at offset 12 bits" (all-isas) |
1918 | h-sint DFLT f-imm-12-s4 | |
1919 | ((parse "signed4n") (print "signed4n")) () () | |
1920 | ) | |
49f58d10 JB |
1921 | (define-full-operand Imm-sh-12-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas) |
1922 | h-shimm DFLT f-imm-12-s4 | |
1923 | () () () | |
1924 | ) | |
1925 | (define-full-operand Imm-13-u3 "signed 3 bit immediate at offset 13 bits" (all-isas) | |
e729279b | 1926 | h-sint DFLT f-imm-13-u3 |
49f58d10 JB |
1927 | ((parse "signed4")) () () |
1928 | ) | |
1929 | (define-full-operand Imm-20-s4 "signed 4 bit immediate at offset 20 bits" (all-isas) | |
1930 | h-sint DFLT f-imm-20-s4 | |
1931 | ((parse "signed4")) () () | |
1932 | ) | |
1933 | (define-full-operand Imm-sh-20-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas) | |
1934 | h-shimm DFLT f-imm-20-s4 | |
1935 | () () () | |
1936 | ) | |
1937 | (define-full-operand Imm-16-QI "signed 8 bit immediate at offset 16 bits" (all-isas) | |
1938 | h-sint DFLT f-dsp-16-s8 | |
1939 | ((parse "signed8")) () () | |
1940 | ) | |
1941 | (define-full-operand Imm-16-HI "signed 16 bit immediate at offset 16 bits" (all-isas) | |
1942 | h-sint DFLT f-dsp-16-s16 | |
1943 | ((parse "signed16")) () () | |
1944 | ) | |
1945 | (define-full-operand Imm-16-SI "signed 32 bit immediate at offset 16 bits" (all-isas) | |
1946 | h-sint DFLT f-dsp-16-s32 | |
1947 | ((parse "signed32")) () () | |
1948 | ) | |
1949 | (define-full-operand Imm-24-QI "signed 8 bit immediate at offset 24 bits" (all-isas) | |
1950 | h-sint DFLT f-dsp-24-s8 | |
1951 | ((parse "signed8")) () () | |
1952 | ) | |
1953 | (define-full-operand Imm-24-HI "signed 16 bit immediate at offset 24 bits" (all-isas) | |
1954 | h-sint DFLT f-dsp-24-s16 | |
1955 | ((parse "signed16")) () () | |
1956 | ) | |
1957 | (define-full-operand Imm-24-SI "signed 32 bit immediate at offset 24 bits" (all-isas) | |
1958 | h-sint DFLT f-dsp-24-s32 | |
1959 | ((parse "signed32")) () () | |
1960 | ) | |
1961 | (define-full-operand Imm-32-QI "signed 8 bit immediate at offset 32 bits" (all-isas) | |
1962 | h-sint DFLT f-dsp-32-s8 | |
1963 | ((parse "signed8")) () () | |
1964 | ) | |
1965 | (define-full-operand Imm-32-SI "signed 32 bit immediate at offset 32 bits" (all-isas) | |
1966 | h-sint DFLT f-dsp-32-s32 | |
1967 | ((parse "signed32")) () () | |
1968 | ) | |
1969 | (define-full-operand Imm-32-HI "signed 16 bit immediate at offset 32 bits" (all-isas) | |
1970 | h-sint DFLT f-dsp-32-s16 | |
1971 | ((parse "signed16")) () () | |
1972 | ) | |
1973 | (define-full-operand Imm-40-QI "signed 8 bit immediate at offset 40 bits" (all-isas) | |
1974 | h-sint DFLT f-dsp-40-s8 | |
1975 | ((parse "signed8")) () () | |
1976 | ) | |
1977 | (define-full-operand Imm-40-HI "signed 16 bit immediate at offset 40 bits" (all-isas) | |
1978 | h-sint DFLT f-dsp-40-s16 | |
1979 | ((parse "signed16")) () () | |
1980 | ) | |
1981 | (define-full-operand Imm-40-SI "signed 32 bit immediate at offset 40 bits" (all-isas) | |
1982 | h-sint DFLT f-dsp-40-s32 | |
1983 | ((parse "signed32")) () () | |
1984 | ) | |
1985 | (define-full-operand Imm-48-QI "signed 8 bit immediate at offset 48 bits" (all-isas) | |
1986 | h-sint DFLT f-dsp-48-s8 | |
1987 | ((parse "signed8")) () () | |
1988 | ) | |
1989 | (define-full-operand Imm-48-HI "signed 16 bit immediate at offset 48 bits" (all-isas) | |
1990 | h-sint DFLT f-dsp-48-s16 | |
1991 | ((parse "signed16")) () () | |
1992 | ) | |
1993 | (define-full-operand Imm-48-SI "signed 32 bit immediate at offset 48 bits" (all-isas) | |
1994 | h-sint DFLT f-dsp-48-s32 | |
1995 | ((parse "signed32")) () () | |
1996 | ) | |
1997 | (define-full-operand Imm-56-QI "signed 8 bit immediate at offset 56 bits" (all-isas) | |
1998 | h-sint DFLT f-dsp-56-s8 | |
1999 | ((parse "signed8")) () () | |
2000 | ) | |
2001 | (define-full-operand Imm-56-HI "signed 16 bit immediate at offset 56 bits" (all-isas) | |
2002 | h-sint DFLT f-dsp-56-s16 | |
2003 | ((parse "signed16")) () () | |
2004 | ) | |
2005 | (define-full-operand Imm-64-HI "signed 16 bit immediate at offset 64 bits" (all-isas) | |
2006 | h-sint DFLT f-dsp-64-s16 | |
2007 | ((parse "signed16")) () () | |
2008 | ) | |
2009 | (define-full-operand Imm1-S "signed 1 bit immediate for short format binary insns" (m32c-isa) | |
2010 | h-sint DFLT f-imm1-S | |
2011 | ((parse "imm1_S")) () () | |
2012 | ) | |
2013 | (define-full-operand Imm3-S "signed 3 bit immediate for short format binary insns" (m32c-isa) | |
2014 | h-sint DFLT f-imm3-S | |
2015 | ((parse "imm3_S")) () () | |
2016 | ) | |
2017 | ||
2018 | ;------------------------------------------------------------- | |
2019 | ; Bit numbers | |
2020 | ;------------------------------------------------------------- | |
2021 | ||
2022 | (define-full-operand Bitno16R "bit number for indexing registers" (m16c-isa) | |
2023 | h-uint DFLT f-dsp-16-u8 | |
2024 | ((parse "Bitno16R")) () () | |
2025 | ) | |
2026 | (dnop Bitno32Prefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-prefixed) | |
2027 | (dnop Bitno32Unprefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-unprefixed) | |
2028 | ||
2029 | (define-full-operand BitBase16-16-u8 "unsigned bit,base:8 at offset 16for m16c" (m16c-isa) | |
2030 | h-uint DFLT f-dsp-16-u8 | |
2031 | ((parse "unsigned_bitbase8") (print "unsigned_bitbase")) () () | |
2032 | ) | |
2033 | (define-full-operand BitBase16-16-s8 "signed bit,base:8 at offset 16for m16c" (m16c-isa) | |
e729279b | 2034 | h-sint DFLT f-dsp-16-s8 |
49f58d10 JB |
2035 | ((parse "signed_bitbase8") (print "signed_bitbase")) () () |
2036 | ) | |
2037 | (define-full-operand BitBase16-16-u16 "unsigned bit,base:16 at offset 16 for m16c" (m16c-isa) | |
2038 | h-uint DFLT f-dsp-16-u16 | |
2039 | ((parse "unsigned_bitbase16") (print "unsigned_bitbase")) () () | |
2040 | ) | |
2041 | (define-full-operand BitBase16-8-u11-S "signed bit,base:11 at offset 16 for m16c" (m16c-isa) | |
e729279b | 2042 | h-uint DFLT f-bitbase16-u11-S |
49f58d10 JB |
2043 | ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () () |
2044 | ) | |
2045 | ||
2046 | (define-full-operand BitBase32-16-u11-Unprefixed "unsigned bit,base:11 at offset 16 for m32c" (m32c-isa) | |
2047 | h-uint DFLT f-bitbase32-16-u11-unprefixed | |
2048 | ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () () | |
2049 | ) | |
2050 | (define-full-operand BitBase32-16-s11-Unprefixed "signed bit,base:11 at offset 16 for m32c" (m32c-isa) | |
2051 | h-sint DFLT f-bitbase32-16-s11-unprefixed | |
2052 | ((parse "signed_bitbase11") (print "signed_bitbase")) () () | |
2053 | ) | |
2054 | (define-full-operand BitBase32-16-u19-Unprefixed "unsigned bit,base:19 at offset 16 for m32c" (m32c-isa) | |
2055 | h-uint DFLT f-bitbase32-16-u19-unprefixed | |
2056 | ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () () | |
2057 | ) | |
2058 | (define-full-operand BitBase32-16-s19-Unprefixed "signed bit,base:19 at offset 16 for m32c" (m32c-isa) | |
2059 | h-sint DFLT f-bitbase32-16-s19-unprefixed | |
2060 | ((parse "signed_bitbase19") (print "signed_bitbase")) () () | |
2061 | ) | |
2062 | (define-full-operand BitBase32-16-u27-Unprefixed "unsigned bit,base:27 at offset 16 for m32c" (m32c-isa) | |
2063 | h-uint DFLT f-bitbase32-16-u27-unprefixed | |
2064 | ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () () | |
2065 | ) | |
2066 | (define-full-operand BitBase32-24-u11-Prefixed "unsigned bit,base:11 at offset 24 for m32c" (m32c-isa) | |
2067 | h-uint DFLT f-bitbase32-24-u11-prefixed | |
2068 | ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () () | |
2069 | ) | |
2070 | (define-full-operand BitBase32-24-s11-Prefixed "signed bit,base:11 at offset 24 for m32c" (m32c-isa) | |
2071 | h-sint DFLT f-bitbase32-24-s11-prefixed | |
2072 | ((parse "signed_bitbase11") (print "signed_bitbase")) () () | |
2073 | ) | |
2074 | (define-full-operand BitBase32-24-u19-Prefixed "unsigned bit,base:19 at offset 24 for m32c" (m32c-isa) | |
2075 | h-uint DFLT f-bitbase32-24-u19-prefixed | |
2076 | ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () () | |
2077 | ) | |
2078 | (define-full-operand BitBase32-24-s19-Prefixed "signed bit,base:19 at offset 24 for m32c" (m32c-isa) | |
2079 | h-sint DFLT f-bitbase32-24-s19-prefixed | |
2080 | ((parse "signed_bitbase19") (print "signed_bitbase")) () () | |
2081 | ) | |
2082 | (define-full-operand BitBase32-24-u27-Prefixed "unsigned bit,base:27 at offset 24 for m32c" (m32c-isa) | |
2083 | h-uint DFLT f-bitbase32-24-u27-prefixed | |
2084 | ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () () | |
2085 | ) | |
2086 | ;------------------------------------------------------------- | |
2087 | ; Labels | |
2088 | ;------------------------------------------------------------- | |
2089 | ||
e729279b NC |
2090 | (define-full-operand Lab-5-3 "3 bit label" (all-isas RELAX) |
2091 | h-iaddr DFLT f-lab-5-3 | |
2092 | ((parse "lab_5_3")) () () ) | |
2093 | ||
2094 | (define-full-operand Lab32-jmp-s "3 bit label" (all-isas RELAX) | |
2095 | h-iaddr DFLT f-lab32-jmp-s | |
2096 | ((parse "lab_5_3")) () () ) | |
2097 | ||
2098 | (dnop Lab-8-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-8-8) | |
2099 | (dnop Lab-8-16 "16 bit label" (all-isas RELAX) h-iaddr f-lab-8-16) | |
49f58d10 | 2100 | (dnop Lab-8-24 "24 bit label" (all-isas) h-iaddr f-lab-8-24) |
e729279b | 2101 | (dnop Lab-16-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-16-8) |
49f58d10 JB |
2102 | (dnop Lab-24-8 "8 bit label" (all-isas) h-iaddr f-lab-24-8) |
2103 | (dnop Lab-32-8 "8 bit label" (all-isas) h-iaddr f-lab-32-8) | |
2104 | (dnop Lab-40-8 "8 bit label" (all-isas) h-iaddr f-lab-40-8) | |
2105 | ||
2106 | ;------------------------------------------------------------- | |
2107 | ; Condition code bits | |
2108 | ;------------------------------------------------------------- | |
2109 | ||
2110 | (dnop sbit "negative bit" (SEM-ONLY all-isas) h-sbit f-nil) | |
2111 | (dnop obit "overflow bit" (SEM-ONLY all-isas) h-obit f-nil) | |
2112 | (dnop zbit "zero bit" (SEM-ONLY all-isas) h-zbit f-nil) | |
2113 | (dnop cbit "carry bit" (SEM-ONLY all-isas) h-cbit f-nil) | |
2114 | (dnop ubit "stack ptr select bit" (SEM-ONLY all-isas) h-ubit f-nil) | |
2115 | (dnop ibit "interrupt enable bit" (SEM-ONLY all-isas) h-ibit f-nil) | |
2116 | (dnop bbit "reg bank select bit" (SEM-ONLY all-isas) h-bbit f-nil) | |
2117 | (dnop dbit "debug bit" (SEM-ONLY all-isas) h-dbit f-nil) | |
2118 | ||
2119 | ;------------------------------------------------------------- | |
2120 | ; Condition operands | |
2121 | ;------------------------------------------------------------- | |
2122 | ||
2123 | (define-pmacro (cond-operand mach offset) | |
2124 | (dnop (.sym cond mach - offset) "condition" ((.sym m mach c-isa)) (.sym h-cond mach) (.sym f-dsp- offset -u8)) | |
2125 | ) | |
2126 | ||
2127 | (cond-operand 16 16) | |
2128 | (cond-operand 16 24) | |
2129 | (cond-operand 16 32) | |
2130 | (cond-operand 32 16) | |
2131 | (cond-operand 32 24) | |
2132 | (cond-operand 32 32) | |
2133 | (cond-operand 32 40) | |
2134 | ||
2135 | (dnop cond16c "condition" (m16c-isa) h-cond16c f-cond16) | |
2136 | (dnop cond16j "condition" (m16c-isa) h-cond16j f-cond16) | |
2137 | (dnop cond16j5 "condition" (m16c-isa) h-cond16j-5 f-cond16j-5) | |
2138 | (dnop cond32 "condition" (m32c-isa) h-cond32 f-cond32) | |
2139 | (dnop cond32j "condition" (m32c-isa) h-cond32 f-cond32j) | |
2140 | (dnop sccond32 "scCND condition" (m32c-isa) h-cond32 f-cond16) | |
2141 | (dnop flags16 "flags" (m16c-isa) h-flags f-9-3) | |
2142 | (dnop flags32 "flags" (m32c-isa) h-flags f-13-3) | |
2143 | (dnop cr16 "control" (m16c-isa) h-cr-16 f-9-3) | |
2144 | (dnop cr1-Unprefixed-32 "control" (m32c-isa) h-cr1-32 f-13-3) | |
2145 | (dnop cr1-Prefixed-32 "control" (m32c-isa) h-cr1-32 f-21-3) | |
2146 | (dnop cr2-32 "control" (m32c-isa) h-cr2-32 f-13-3) | |
2147 | (dnop cr3-Unprefixed-32 "control" (m32c-isa) h-cr3-32 f-13-3) | |
2148 | (dnop cr3-Prefixed-32 "control" (m32c-isa) h-cr3-32 f-21-3) | |
2149 | ||
2150 | ;------------------------------------------------------------- | |
2151 | ; Suffixes | |
2152 | ;------------------------------------------------------------- | |
2153 | ||
2154 | (define-full-operand Z "Suffix for zero format insns" (all-isas) | |
2155 | h-sint DFLT f-nil | |
2156 | ((parse "Z") (print "Z")) () () | |
2157 | ) | |
2158 | (define-full-operand S "Suffix for short format insns" (all-isas) | |
2159 | h-sint DFLT f-nil | |
2160 | ((parse "S") (print "S")) () () | |
2161 | ) | |
2162 | (define-full-operand Q "Suffix for quick format insns" (all-isas) | |
2163 | h-sint DFLT f-nil | |
2164 | ((parse "Q") (print "Q")) () () | |
2165 | ) | |
2166 | (define-full-operand G "Suffix for general format insns" (all-isas) | |
2167 | h-sint DFLT f-nil | |
2168 | ((parse "G") (print "G")) () () | |
2169 | ) | |
2170 | (define-full-operand X "Empty suffix" (all-isas) | |
2171 | h-sint DFLT f-nil | |
2172 | ((parse "X") (print "X")) () () | |
2173 | ) | |
2174 | (define-full-operand size "any size specifier" (all-isas) | |
2175 | h-sint DFLT f-nil | |
2176 | ((parse "size") (print "size")) () () | |
2177 | ) | |
2178 | ;------------------------------------------------------------- | |
2179 | ; Misc | |
2180 | ;------------------------------------------------------------- | |
2181 | ||
2182 | (dnop BitIndex "Bit Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-bit-index f-nil) | |
2183 | (dnop SrcIndex "Source Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-src-index f-nil) | |
2184 | (dnop DstIndex "Destination Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-dst-index f-nil) | |
2185 | (dnop NoRemainder "Place holder for when the remainder is not kept" (SEM-ONLY MACH32 m32c-isa) h-none f-nil) | |
2186 | \f | |
2187 | ;============================================================= | |
2188 | ; Derived Operands | |
2189 | ||
2190 | ; Memory reference macros that clip addresses appropriately. Refer to | |
2191 | ; memory at ADDRESS in MODE, clipped appropriately for either the m16c | |
2192 | ; or m32c. | |
2193 | (define-pmacro (mem16 mode address) | |
2194 | (mem mode (and #xffff address))) | |
2195 | ||
2196 | (define-pmacro (mem32 mode address) | |
2197 | (mem mode (and #xffffff address))) | |
2198 | ||
2199 | ; Like mem16 and mem32, but takes MACH as a parameter. MACH must be | |
2200 | ; either 16 or 32. | |
2201 | (define-pmacro (mem-mach mach mode address) | |
2202 | ((.sym mem mach) mode address)) | |
2203 | ||
2204 | ;------------------------------------------------------------- | |
2205 | ; Source | |
2206 | ;------------------------------------------------------------- | |
2207 | ; Rn direct | |
2208 | ;------------------------------------------------------------- | |
2209 | ||
2210 | (define-pmacro (src16-Rn-direct-operand xmode) | |
2211 | (begin | |
2212 | (define-derived-operand | |
2213 | (name (.sym src16-Rn-direct- xmode)) | |
2214 | (comment (.str "m16c Rn direct source " xmode)) | |
2215 | (attrs (machine 16)) | |
2216 | (mode xmode) | |
2217 | (args ((.sym Src16Rn xmode))) | |
2218 | (syntax (.str "$Src16Rn" xmode)) | |
2219 | (base-ifield f-8-4) | |
2220 | (encoding (+ (f-8-2 0) (.sym Src16Rn xmode))) | |
2221 | (ifield-assertion (eq f-8-2 0)) | |
2222 | (getter (trunc xmode (.sym Src16Rn xmode))) | |
2223 | (setter (set (.sym Src16Rn xmode) newval)) | |
2224 | ) | |
2225 | ) | |
2226 | ) | |
2227 | (src16-Rn-direct-operand QI) | |
2228 | (src16-Rn-direct-operand HI) | |
2229 | ||
2230 | (define-pmacro (src32-Rn-direct-operand group base xmode) | |
2231 | (begin | |
2232 | (define-derived-operand | |
2233 | (name (.sym src32-Rn-direct- group - xmode)) | |
2234 | (comment (.str "m32c Rn direct source " xmode)) | |
2235 | (attrs (machine 32)) | |
2236 | (mode xmode) | |
2237 | (args ((.sym Src32Rn group xmode))) | |
2238 | (syntax (.str "$Src32Rn" group xmode)) | |
2239 | (base-ifield (.sym f- base -11)) | |
2240 | (encoding (+ ((.sym f- base -3) 4) (.sym Src32Rn group xmode))) | |
2241 | (ifield-assertion (eq (.sym f- base -3) 4)) | |
2242 | (getter (trunc xmode (.sym Src32Rn group xmode))) | |
2243 | (setter (set (.sym Src32Rn group xmode) newval)) | |
2244 | ) | |
2245 | ) | |
2246 | ) | |
2247 | ||
2248 | (src32-Rn-direct-operand Unprefixed 1 QI) | |
2249 | (src32-Rn-direct-operand Prefixed 9 QI) | |
2250 | (src32-Rn-direct-operand Unprefixed 1 HI) | |
2251 | (src32-Rn-direct-operand Prefixed 9 HI) | |
2252 | (src32-Rn-direct-operand Unprefixed 1 SI) | |
2253 | (src32-Rn-direct-operand Prefixed 9 SI) | |
2254 | ||
2255 | ;------------------------------------------------------------- | |
2256 | ; An direct | |
2257 | ;------------------------------------------------------------- | |
2258 | ||
2259 | (define-pmacro (src16-An-direct-operand xmode) | |
2260 | (begin | |
2261 | (define-derived-operand | |
2262 | (name (.sym src16-An-direct- xmode)) | |
2263 | (comment (.str "m16c An direct destination " xmode)) | |
2264 | (attrs (machine 16)) | |
2265 | (mode xmode) | |
2266 | (args ((.sym Src16An xmode))) | |
2267 | (syntax (.str "$Src16An" xmode)) | |
2268 | (base-ifield f-8-4) | |
2269 | (encoding (+ (f-8-2 1) (f-10-1 0) (.sym Src16An xmode))) | |
2270 | (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 0))) | |
2271 | (getter (trunc xmode (.sym Src16An xmode))) | |
2272 | (setter (set (.sym Src16An xmode) newval)) | |
2273 | ) | |
2274 | ) | |
2275 | ) | |
2276 | (src16-An-direct-operand QI) | |
2277 | (src16-An-direct-operand HI) | |
2278 | ||
2279 | (define-pmacro (src32-An-direct-operand group base1 base2 xmode) | |
2280 | (begin | |
2281 | (define-derived-operand | |
2282 | (name (.sym src32-An-direct- group - xmode)) | |
2283 | (comment (.str "m32c An direct destination " xmode)) | |
2284 | (attrs (machine 32)) | |
2285 | (mode xmode) | |
2286 | (args ((.sym Src32An group xmode))) | |
2287 | (syntax (.str "$Src32An" group xmode)) | |
2288 | (base-ifield (.sym f- base1 -11)) | |
2289 | (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Src32An group xmode))) | |
2290 | (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1))) | |
2291 | (getter (trunc xmode (.sym Src32An group xmode))) | |
2292 | (setter (set (.sym Src32An group xmode) newval)) | |
2293 | ) | |
2294 | ) | |
2295 | ) | |
2296 | ||
2297 | (src32-An-direct-operand Unprefixed 1 10 QI) | |
2298 | (src32-An-direct-operand Unprefixed 1 10 HI) | |
2299 | (src32-An-direct-operand Unprefixed 1 10 SI) | |
2300 | (src32-An-direct-operand Prefixed 9 18 QI) | |
2301 | (src32-An-direct-operand Prefixed 9 18 HI) | |
2302 | (src32-An-direct-operand Prefixed 9 18 SI) | |
2303 | ||
2304 | ;------------------------------------------------------------- | |
2305 | ; An indirect | |
2306 | ;------------------------------------------------------------- | |
2307 | ||
2308 | (define-pmacro (src16-An-indirect-operand xmode) | |
2309 | (begin | |
2310 | (define-derived-operand | |
2311 | (name (.sym src16-An-indirect- xmode)) | |
2312 | (comment (.str "m16c An indirect destination " xmode)) | |
2313 | (attrs (machine 16)) | |
2314 | (mode xmode) | |
2315 | (args (Src16An)) | |
2316 | (syntax "[$Src16An]") | |
2317 | (base-ifield f-8-4) | |
2318 | (encoding (+ (f-8-2 1) (f-10-1 1) Src16An)) | |
2319 | (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 1))) | |
2320 | (getter (mem16 xmode Src16An)) | |
2321 | (setter (set (mem16 xmode Src16An) newval)) | |
2322 | ) | |
2323 | ) | |
2324 | ) | |
2325 | (src16-An-indirect-operand QI) | |
2326 | (src16-An-indirect-operand HI) | |
2327 | ||
2328 | (define-pmacro (src32-An-indirect-operand group base1 base2 xmode) | |
2329 | (begin | |
2330 | (define-derived-operand | |
2331 | (name (.sym src32-An-indirect- group - xmode)) | |
2332 | (comment (.str "m32c An indirect destination " xmode)) | |
2333 | (attrs (machine 32)) | |
2334 | (mode xmode) | |
2335 | (args ((.sym Src32An group))) | |
2336 | (syntax (.str "[$Src32An" group "]")) | |
2337 | (base-ifield (.sym f- base1 -11)) | |
2338 | (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Src32An group))) | |
2339 | (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0))) | |
2340 | (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) | |
2341 | (const 0))) | |
2342 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval | |
2343 | (.sym Src32An group) (const 0))) | |
2344 | ; (getter (mem32 xmode (.sym Src32An group))) | |
2345 | ; (setter (set (mem32 xmode (.sym Src32An group)) newval)) | |
2346 | ) | |
2347 | ) | |
2348 | ) | |
2349 | ||
2350 | (src32-An-indirect-operand Unprefixed 1 10 QI) | |
2351 | (src32-An-indirect-operand Unprefixed 1 10 HI) | |
2352 | (src32-An-indirect-operand Unprefixed 1 10 SI) | |
2353 | (src32-An-indirect-operand Prefixed 9 18 QI) | |
2354 | (src32-An-indirect-operand Prefixed 9 18 HI) | |
2355 | (src32-An-indirect-operand Prefixed 9 18 SI) | |
2356 | ||
2357 | ;------------------------------------------------------------- | |
2358 | ; dsp:d[r] relative | |
2359 | ;------------------------------------------------------------- | |
2360 | ||
2361 | (define-pmacro (src16-relative-operand xmode) | |
2362 | (begin | |
2363 | (define-derived-operand | |
2364 | (name (.sym src16-16-8-SB-relative- xmode)) | |
2365 | (comment (.str "m16c dsp:8[sb] relative destination " xmode)) | |
2366 | (attrs (machine 16)) | |
2367 | (mode xmode) | |
2368 | (args (Dsp-16-u8)) | |
2369 | (syntax "${Dsp-16-u8}[sb]") | |
2370 | (base-ifield f-8-4) | |
2371 | (encoding (+ (f-8-4 #xA) Dsp-16-u8)) | |
2372 | (ifield-assertion (eq f-8-4 #xA)) | |
2373 | (getter (mem16 xmode (add Dsp-16-u8 (reg h-sb)))) | |
2374 | (setter (set (mem16 xmode (add Dsp-16-u8 (reg h-sb))) newval)) | |
2375 | ) | |
2376 | (define-derived-operand | |
2377 | (name (.sym src16-16-16-SB-relative- xmode)) | |
2378 | (comment (.str "m16c dsp:16[sb] relative destination " xmode)) | |
2379 | (attrs (machine 16)) | |
2380 | (mode xmode) | |
2381 | (args (Dsp-16-u16)) | |
2382 | (syntax "${Dsp-16-u16}[sb]") | |
2383 | (base-ifield f-8-4) | |
2384 | (encoding (+ (f-8-4 #xE) Dsp-16-u16)) | |
2385 | (ifield-assertion (eq f-8-4 #xE)) | |
2386 | (getter (mem16 xmode (add Dsp-16-u16 (reg h-sb)))) | |
2387 | (setter (set (mem16 xmode (add Dsp-16-u16 (reg h-sb))) newval)) | |
2388 | ) | |
2389 | (define-derived-operand | |
2390 | (name (.sym src16-16-8-FB-relative- xmode)) | |
2391 | (comment (.str "m16c dsp:8[fb] relative destination " xmode)) | |
2392 | (attrs (machine 16)) | |
2393 | (mode xmode) | |
2394 | (args (Dsp-16-s8)) | |
2395 | (syntax "${Dsp-16-s8}[fb]") | |
2396 | (base-ifield f-8-4) | |
2397 | (encoding (+ (f-8-4 #xB) Dsp-16-s8)) | |
2398 | (ifield-assertion (eq f-8-4 #xB)) | |
2399 | (getter (mem16 xmode (add Dsp-16-s8 (reg h-fb)))) | |
2400 | (setter (set (mem16 xmode (add Dsp-16-s8 (reg h-fb))) newval)) | |
2401 | ) | |
2402 | (define-derived-operand | |
2403 | (name (.sym src16-16-8-An-relative- xmode)) | |
2404 | (comment (.str "m16c dsp:8[An] relative destination " xmode)) | |
2405 | (attrs (machine 16)) | |
2406 | (mode xmode) | |
2407 | (args (Src16An Dsp-16-u8)) | |
2408 | (syntax "${Dsp-16-u8}[$Src16An]") | |
2409 | (base-ifield f-8-4) | |
2410 | (encoding (+ (f-8-2 2) (f-10-1 0) Dsp-16-u8 Src16An)) | |
2411 | (ifield-assertion (andif (eq f-8-2 2) (eq f-10-1 0))) | |
2412 | (getter (mem16 xmode (add Dsp-16-u8 Src16An))) | |
2413 | (setter (set (mem16 xmode (add Dsp-16-u8 Src16An)) newval)) | |
2414 | ) | |
2415 | (define-derived-operand | |
2416 | (name (.sym src16-16-16-An-relative- xmode)) | |
2417 | (comment (.str "m16c dsp:16[An] relative destination " xmode)) | |
2418 | (attrs (machine 16)) | |
2419 | (mode xmode) | |
2420 | (args (Src16An Dsp-16-u16)) | |
2421 | (syntax "${Dsp-16-u16}[$Src16An]") | |
2422 | (base-ifield f-8-4) | |
2423 | (encoding (+ (f-8-2 3) (f-10-1 0) Dsp-16-u16 Src16An)) | |
2424 | (ifield-assertion (andif (eq f-8-2 3) (eq f-10-1 0))) | |
2425 | (getter (mem16 xmode (add Dsp-16-u16 Src16An))) | |
2426 | (setter (set (mem16 xmode (add Dsp-16-u16 Src16An)) newval)) | |
2427 | ) | |
2428 | ) | |
2429 | ) | |
2430 | ||
2431 | (src16-relative-operand QI) | |
2432 | (src16-relative-operand HI) | |
2433 | ||
2434 | (define-pmacro (src32-relative-operand offset group base1 base2 xmode) | |
2435 | (begin | |
2436 | (define-derived-operand | |
2437 | (name (.sym src32- offset -8-SB-relative- group - xmode)) | |
2438 | (comment (.str "m32c dsp:8[sb] relative destination " xmode)) | |
2439 | (attrs (machine 32)) | |
2440 | (mode xmode) | |
2441 | (args ((.sym Dsp- offset -u8))) | |
2442 | (syntax (.str "${Dsp-" offset "-u8}[sb]")) | |
2443 | (base-ifield (.sym f- base1 -11)) | |
2444 | (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8))) | |
2445 | (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2))) | |
2446 | (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u8))) | |
2447 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u8))) | |
2448 | ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb)))) | |
2449 | ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval)) | |
2450 | ) | |
2451 | (define-derived-operand | |
2452 | (name (.sym src32- offset -16-SB-relative- group - xmode)) | |
2453 | (comment (.str "m32c dsp:16[sb] relative destination " xmode)) | |
2454 | (attrs (machine 32)) | |
2455 | (mode xmode) | |
2456 | (args ((.sym Dsp- offset -u16))) | |
2457 | (syntax (.str "${Dsp-" offset "-u16}[sb]")) | |
2458 | (base-ifield (.sym f- base1 -11)) | |
2459 | (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16))) | |
2460 | (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2))) | |
2461 | (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u16))) | |
2462 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u16))) | |
2463 | ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb)))) | |
2464 | ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval)) | |
2465 | ) | |
2466 | (define-derived-operand | |
2467 | (name (.sym src32- offset -8-FB-relative- group - xmode)) | |
2468 | (comment (.str "m32c dsp:8[fb] relative destination " xmode)) | |
2469 | (attrs (machine 32)) | |
2470 | (mode xmode) | |
2471 | (args ((.sym Dsp- offset -s8))) | |
2472 | (syntax (.str "${Dsp-" offset "-s8}[fb]")) | |
2473 | (base-ifield (.sym f- base1 -11)) | |
2474 | (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8))) | |
2475 | (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3))) | |
2476 | (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s8))) | |
2477 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s8))) | |
2478 | ; (getter (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb)))) | |
2479 | ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval)) | |
2480 | ) | |
2481 | (define-derived-operand | |
2482 | (name (.sym src32- offset -16-FB-relative- group - xmode)) | |
2483 | (comment (.str "m32c dsp:16[fb] relative destination " xmode)) | |
2484 | (attrs (machine 32)) | |
2485 | (mode xmode) | |
2486 | (args ((.sym Dsp- offset -s16))) | |
2487 | (syntax (.str "${Dsp-" offset "-s16}[fb]")) | |
2488 | (base-ifield (.sym f- base1 -11)) | |
2489 | (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16))) | |
2490 | (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3))) | |
2491 | (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s16))) | |
2492 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s16))) | |
2493 | ; (getter (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb)))) | |
2494 | ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval)) | |
2495 | ) | |
2496 | (define-derived-operand | |
2497 | (name (.sym src32- offset -8-An-relative- group - xmode)) | |
2498 | (comment (.str "m32c dsp:8[An] relative destination " xmode)) | |
2499 | (attrs (machine 32)) | |
2500 | (mode xmode) | |
2501 | (args ((.sym Src32An group) (.sym Dsp- offset -u8))) | |
2502 | (syntax (.str "${Dsp-" offset "-u8}[$Src32An" group "]")) | |
2503 | (base-ifield (.sym f- base1 -11)) | |
2504 | (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Src32An group))) | |
2505 | (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0))) | |
2506 | (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u8))) | |
2507 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u8))) | |
2508 | ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group)))) | |
2509 | ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group))) newval)) | |
2510 | ) | |
2511 | (define-derived-operand | |
2512 | (name (.sym src32- offset -16-An-relative- group - xmode)) | |
2513 | (comment (.str "m32c dsp:16[An] relative destination " xmode)) | |
2514 | (attrs (machine 32)) | |
2515 | (mode xmode) | |
2516 | (args ((.sym Src32An group) (.sym Dsp- offset -u16))) | |
2517 | (syntax (.str "${Dsp-" offset "-u16}[$Src32An" group "]")) | |
2518 | (base-ifield (.sym f- base1 -11)) | |
2519 | (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Src32An group))) | |
2520 | (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0))) | |
2521 | (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u16))) | |
2522 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u16))) | |
2523 | ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group)))) | |
2524 | ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group))) newval)) | |
2525 | ) | |
2526 | (define-derived-operand | |
2527 | (name (.sym src32- offset -24-An-relative- group - xmode)) | |
2528 | (comment (.str "m32c dsp:16[An] relative destination " xmode)) | |
2529 | (attrs (machine 32)) | |
2530 | (mode xmode) | |
2531 | (args ((.sym Src32An group) (.sym Dsp- offset -u24))) | |
2532 | (syntax (.str "${Dsp-" offset "-u24}[$Src32An" group "]")) | |
2533 | (base-ifield (.sym f- base1 -11)) | |
2534 | (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Src32An group))) | |
2535 | (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0))) | |
2536 | (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u24) )) | |
2537 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u24))) | |
2538 | ; (getter (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group)))) | |
2539 | ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group))) newval)) | |
2540 | ) | |
2541 | ) | |
2542 | ) | |
2543 | ||
2544 | (src32-relative-operand 16 Unprefixed 1 10 QI) | |
2545 | (src32-relative-operand 16 Unprefixed 1 10 HI) | |
2546 | (src32-relative-operand 16 Unprefixed 1 10 SI) | |
2547 | (src32-relative-operand 24 Prefixed 9 18 QI) | |
2548 | (src32-relative-operand 24 Prefixed 9 18 HI) | |
2549 | (src32-relative-operand 24 Prefixed 9 18 SI) | |
2550 | ||
2551 | ;------------------------------------------------------------- | |
2552 | ; Absolute address | |
2553 | ;------------------------------------------------------------- | |
2554 | ||
2555 | (define-pmacro (src16-absolute xmode) | |
2556 | (begin | |
2557 | (define-derived-operand | |
2558 | (name (.sym src16-16-16-absolute- xmode)) | |
2559 | (comment (.str "m16c absolute address " xmode)) | |
2560 | (attrs (machine 16)) | |
2561 | (mode xmode) | |
2562 | (args (Dsp-16-u16)) | |
2563 | (syntax (.str "${Dsp-16-u16}")) | |
2564 | (base-ifield f-8-4) | |
2565 | (encoding (+ (f-8-4 #xF) Dsp-16-u16)) | |
2566 | (ifield-assertion (eq f-8-4 #xF)) | |
2567 | (getter (mem16 xmode Dsp-16-u16)) | |
2568 | (setter (set (mem16 xmode Dsp-16-u16) newval)) | |
2569 | ) | |
2570 | ) | |
2571 | ) | |
2572 | ||
2573 | (src16-absolute QI) | |
2574 | (src16-absolute HI) | |
2575 | ||
2576 | (define-pmacro (src32-absolute offset group base1 base2 xmode) | |
2577 | (begin | |
2578 | (define-derived-operand | |
2579 | (name (.sym src32- offset -16-absolute- group - xmode)) | |
2580 | (comment (.str "m32c absolute address " xmode)) | |
2581 | (attrs (machine 32)) | |
2582 | (mode xmode) | |
2583 | (args ((.sym Dsp- offset -u16))) | |
2584 | (syntax (.str "${Dsp-" offset "-u16}")) | |
2585 | (base-ifield (.sym f- base1 -11)) | |
2586 | (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16))) | |
2587 | (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3))) | |
2588 | (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u16))) | |
2589 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u16))) | |
2590 | ; (getter (mem32 xmode (.sym Dsp- offset -u16))) | |
2591 | ; (setter (set (mem32 xmode (.sym Dsp- offset -u16)) newval)) | |
2592 | ) | |
2593 | (define-derived-operand | |
2594 | (name (.sym src32- offset -24-absolute- group - xmode)) | |
2595 | (comment (.str "m32c absolute address " xmode)) | |
2596 | (attrs (machine 32)) | |
2597 | (mode xmode) | |
2598 | (args ((.sym Dsp- offset -u24))) | |
2599 | (syntax (.str "${Dsp-" offset "-u24}")) | |
2600 | (base-ifield (.sym f- base1 -11)) | |
2601 | (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24))) | |
2602 | (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2))) | |
2603 | (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u24))) | |
2604 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u24))) | |
2605 | ; (getter (mem32 xmode (.sym Dsp- offset -u24))) | |
2606 | ; (setter (set (mem32 xmode (.sym Dsp- offset -u24)) newval)) | |
2607 | ) | |
2608 | ) | |
2609 | ) | |
2610 | ||
2611 | (src32-absolute 16 Unprefixed 1 10 QI) | |
2612 | (src32-absolute 16 Unprefixed 1 10 HI) | |
2613 | (src32-absolute 16 Unprefixed 1 10 SI) | |
2614 | (src32-absolute 24 Prefixed 9 18 QI) | |
2615 | (src32-absolute 24 Prefixed 9 18 HI) | |
2616 | (src32-absolute 24 Prefixed 9 18 SI) | |
2617 | ||
2618 | ;------------------------------------------------------------- | |
2619 | ; An indirect indirect | |
2620 | ; | |
2621 | ; Double indirect addressing uses the lower 3 bytes of the value stored | |
2622 | ; at the address referenced by 'op' as the effective address. | |
2623 | ;------------------------------------------------------------- | |
2624 | ||
2625 | (define-pmacro (indirect-addr op) (and USI (mem32 USI op) #x00ffffff)) | |
2626 | ||
2627 | ; (define-pmacro (src-An-indirect-indirect-operand xmode) | |
2628 | ; (define-derived-operand | |
2629 | ; (name (.sym src32-An-indirect-indirect- xmode)) | |
2630 | ; (comment (.str "m32c An indirect indirect destination " xmode)) | |
2631 | ; (attrs (machine 32)) | |
2632 | ; (mode xmode) | |
2633 | ; (args (Src32AnPrefixed)) | |
2634 | ; (syntax (.str "[[$Src32AnPrefixed]]")) | |
2635 | ; (base-ifield f-9-11) | |
2636 | ; (encoding (+ (f-9-3 0) (f-18-1 0) Src32AnPrefixed)) | |
2637 | ; (ifield-assertion (andif (eq f-9-3 0) (eq f-18-1 0))) | |
2638 | ; (getter (mem32 xmode (indirect-addr Src32AnPrefixed))) | |
2639 | ; (setter (set (mem32 xmode (indirect-addr Src32AnPrefixed)) newval)) | |
2640 | ; ) | |
2641 | ; ) | |
2642 | ||
2643 | ; (src-An-indirect-indirect-operand QI) | |
2644 | ; (src-An-indirect-indirect-operand HI) | |
2645 | ; (src-An-indirect-indirect-operand SI) | |
2646 | ||
2647 | ;------------------------------------------------------------- | |
2648 | ; Relative indirect | |
2649 | ;------------------------------------------------------------- | |
2650 | ||
2651 | (define-pmacro (src-relative-indirect-operand xmode) | |
2652 | (begin | |
2653 | ; (define-derived-operand | |
2654 | ; (name (.sym src32-24-8-SB-relative-indirect- xmode)) | |
2655 | ; (comment (.str "m32c dsp:8[sb] relative source " xmode)) | |
2656 | ; (attrs (machine 32)) | |
2657 | ; (mode xmode) | |
2658 | ; (args (Dsp-24-u8)) | |
2659 | ; (syntax "[${Dsp-24-u8}[sb]]") | |
2660 | ; (base-ifield f-9-11) | |
2661 | ; (encoding (+ (f-9-3 1) (f-18-2 2) Dsp-24-u8)) | |
2662 | ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 2))) | |
2663 | ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb))))) | |
2664 | ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb)))) newval)) | |
2665 | ; ) | |
2666 | ; (define-derived-operand | |
2667 | ; (name (.sym src32-24-16-SB-relative-indirect- xmode)) | |
2668 | ; (comment (.str "m32c dsp:16[sb] relative source " xmode)) | |
2669 | ; (attrs (machine 32)) | |
2670 | ; (mode xmode) | |
2671 | ; (args (Dsp-24-u16)) | |
2672 | ; (syntax "[${Dsp-24-u16}[sb]]") | |
2673 | ; (base-ifield f-9-11) | |
2674 | ; (encoding (+ (f-9-3 2) (f-18-2 2) Dsp-24-u16)) | |
2675 | ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 2))) | |
2676 | ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb))))) | |
2677 | ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb)))) newval)) | |
2678 | ; ) | |
2679 | ; (define-derived-operand | |
2680 | ; (name (.sym src32-24-8-FB-relative-indirect- xmode)) | |
2681 | ; (comment (.str "m32c dsp:8[fb] relative source " xmode)) | |
2682 | ; (attrs (machine 32)) | |
2683 | ; (mode xmode) | |
2684 | ; (args (Dsp-24-s8)) | |
2685 | ; (syntax "[${Dsp-24-s8}[fb]]") | |
2686 | ; (base-ifield f-9-11) | |
2687 | ; (encoding (+ (f-9-3 1) (f-18-2 3) Dsp-24-s8)) | |
2688 | ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 3))) | |
2689 | ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb))))) | |
2690 | ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb)))) newval)) | |
2691 | ; ) | |
2692 | ; (define-derived-operand | |
2693 | ; (name (.sym src32-24-16-FB-relative-indirect- xmode)) | |
2694 | ; (comment (.str "m32c dsp:16[fb] relative source " xmode)) | |
2695 | ; (attrs (machine 32)) | |
2696 | ; (mode xmode) | |
2697 | ; (args (Dsp-24-s16)) | |
2698 | ; (syntax "[${Dsp-24-s16}[fb]]") | |
2699 | ; (base-ifield f-9-11) | |
2700 | ; (encoding (+ (f-9-3 2) (f-18-2 3) Dsp-24-s16)) | |
2701 | ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 3))) | |
2702 | ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb))))) | |
2703 | ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb)))) newval)) | |
2704 | ; ) | |
2705 | ; (define-derived-operand | |
2706 | ; (name (.sym src32-24-8-An-relative-indirect- xmode)) | |
2707 | ; (comment (.str "m32c dsp:8[An] relative indirect source " xmode)) | |
2708 | ; (attrs (machine 32)) | |
2709 | ; (mode xmode) | |
2710 | ; (args (Src32AnPrefixed Dsp-24-u8)) | |
2711 | ; (syntax "[${Dsp-24-u8}[$Src32AnPrefixed]]") | |
2712 | ; (base-ifield f-9-11) | |
2713 | ; (encoding (+ (f-9-3 1) (f-18-1 0) Dsp-24-u8 Src32AnPrefixed)) | |
2714 | ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-1 0))) | |
2715 | ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed)))) | |
2716 | ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed))) newval)) | |
2717 | ; ) | |
2718 | ; (define-derived-operand | |
2719 | ; (name (.sym src32-24-16-An-relative-indirect- xmode)) | |
2720 | ; (comment (.str "m32c dsp:16[An] relative source " xmode)) | |
2721 | ; (attrs (machine 32)) | |
2722 | ; (mode xmode) | |
2723 | ; (args (Src32AnPrefixed Dsp-24-u16)) | |
2724 | ; (syntax "[${Dsp-24-u16}[$Src32AnPrefixed]]") | |
2725 | ; (base-ifield f-9-11) | |
2726 | ; (encoding (+ (f-9-3 2) (f-18-1 0) Dsp-24-u16 Src32AnPrefixed)) | |
2727 | ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-1 0))) | |
2728 | ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed)))) | |
2729 | ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed))) newval)) | |
2730 | ; ) | |
2731 | ; (define-derived-operand | |
2732 | ; (name (.sym src32-24-24-An-relative-indirect- xmode)) | |
2733 | ; (comment (.str "m32c dsp:24[An] relative source " xmode)) | |
2734 | ; (attrs (machine 32)) | |
2735 | ; (mode xmode) | |
2736 | ; (args (Src32AnPrefixed Dsp-24-u24)) | |
2737 | ; (syntax "[${Dsp-24-u24}[$Src32AnPrefixed]]") | |
2738 | ; (base-ifield f-9-11) | |
2739 | ; (encoding (+ (f-9-3 3) (f-18-1 0) Dsp-24-u24 Src32AnPrefixed)) | |
2740 | ; (ifield-assertion (andif (eq f-9-3 3) (eq f-18-1 0))) | |
2741 | ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed)))) | |
2742 | ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed))) newval)) | |
2743 | ; ) | |
2744 | ) | |
2745 | ) | |
2746 | ||
2747 | ; (src-relative-indirect-operand QI) | |
2748 | ; (src-relative-indirect-operand HI) | |
2749 | ; (src-relative-indirect-operand SI) | |
2750 | ||
2751 | ;------------------------------------------------------------- | |
2752 | ; Absolute Indirect address | |
2753 | ;------------------------------------------------------------- | |
2754 | ||
2755 | (define-pmacro (src32-absolute-indirect offset base1 base2 xmode) | |
2756 | (begin | |
2757 | ; (define-derived-operand | |
2758 | ; (name (.sym src32- offset -16-absolute-indirect-derived- xmode)) | |
2759 | ; (comment (.str "m32c absolute indirect address " xmode)) | |
2760 | ; (attrs (machine 32)) | |
2761 | ; (mode xmode) | |
2762 | ; (args ((.sym Dsp- offset -u16))) | |
2763 | ; (syntax (.str "[${Dsp-" offset "-u16}]")) | |
2764 | ; (base-ifield (.sym f- base1 -11)) | |
2765 | ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16))) | |
2766 | ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3))) | |
2767 | ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16)))) | |
2768 | ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval)) | |
2769 | ; ) | |
2770 | ; (define-derived-operand | |
2771 | ; (name (.sym src32- offset -24-absolute-indirect-derived- xmode)) | |
2772 | ; (comment (.str "m32c absolute indirect address " xmode)) | |
2773 | ; (attrs (machine 32)) | |
2774 | ; (mode xmode) | |
2775 | ; (args ((.sym Dsp- offset -u24))) | |
2776 | ; (syntax (.str "[${Dsp-" offset "-u24}]")) | |
2777 | ; (base-ifield (.sym f- base1 -11)) | |
2778 | ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24))) | |
2779 | ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2))) | |
2780 | ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24)))) | |
2781 | ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval)) | |
2782 | ; ) | |
2783 | ) | |
2784 | ) | |
2785 | ||
2786 | (src32-absolute-indirect 24 9 18 QI) | |
2787 | (src32-absolute-indirect 24 9 18 HI) | |
2788 | (src32-absolute-indirect 24 9 18 SI) | |
2789 | ||
2790 | ;------------------------------------------------------------- | |
2791 | ; Register relative source operands for short format insns | |
2792 | ;------------------------------------------------------------- | |
2793 | ||
2794 | (define-pmacro (src-2-S-operands mach xmode base opc1 opc2 opc3) | |
2795 | (begin | |
2796 | (define-derived-operand | |
2797 | (name (.sym src mach -2-S-8-SB-relative- xmode)) | |
2798 | (comment (.str "m" mach "c SB relative address")) | |
2799 | (attrs (machine mach)) | |
2800 | (mode xmode) | |
2801 | (args (Dsp-8-u8)) | |
2802 | (syntax "${Dsp-8-u8}[sb]") | |
2803 | (base-ifield (.sym f- base -2)) | |
2804 | (encoding (+ ((.sym f- base -2) opc1) Dsp-8-u8)) | |
2805 | (ifield-assertion (eq (.sym f- base -2) opc1)) | |
2806 | (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8)) | |
2807 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8)) | |
2808 | ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8)))) | |
2809 | ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8))) newval)) | |
2810 | ) | |
2811 | (define-derived-operand | |
2812 | (name (.sym src mach -2-S-8-FB-relative- xmode)) | |
2813 | (comment (.str "m" mach "c FB relative address")) | |
2814 | (attrs (machine mach)) | |
2815 | (mode xmode) | |
2816 | (args (Dsp-8-s8)) | |
2817 | (syntax "${Dsp-8-s8}[fb]") | |
2818 | (base-ifield (.sym f- base -2)) | |
2819 | (encoding (+ ((.sym f- base -2) opc2) Dsp-8-s8)) | |
2820 | (ifield-assertion (eq (.sym f- base -2) opc2)) | |
2821 | (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8)) | |
2822 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8)) | |
2823 | ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8)))) | |
2824 | ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8))) newval)) | |
2825 | ) | |
2826 | (define-derived-operand | |
2827 | (name (.sym src mach -2-S-16-absolute- xmode)) | |
2828 | (comment (.str "m" mach "c absolute address")) | |
2829 | (attrs (machine mach)) | |
2830 | (mode xmode) | |
2831 | (args (Dsp-8-u16)) | |
2832 | (syntax "${Dsp-8-u16}") | |
2833 | (base-ifield (.sym f- base -2)) | |
2834 | (encoding (+ ((.sym f- base -2) opc3) Dsp-8-u16)) | |
2835 | (ifield-assertion (eq (.sym f- base -2) opc3)) | |
2836 | (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16)) | |
2837 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16)) | |
2838 | ; (getter (mem-mach mach xmode Dsp-8-u16)) | |
2839 | ; (setter (set (mem-mach mach xmode Dsp-8-u16) newval)) | |
2840 | ) | |
2841 | ) | |
2842 | ) | |
2843 | ||
2844 | (src-2-S-operands 16 QI 6 1 2 3) | |
2845 | (src-2-S-operands 32 QI 2 2 3 1) | |
2846 | (src-2-S-operands 32 HI 2 2 3 1) | |
2847 | ||
2848 | ;============================================================= | |
2849 | ; Derived Operands | |
2850 | ;------------------------------------------------------------- | |
2851 | ; Destination | |
2852 | ;------------------------------------------------------------- | |
2853 | ; Rn direct | |
2854 | ;------------------------------------------------------------- | |
2855 | ||
2856 | (define-pmacro (dst16-Rn-direct-operand xmode) | |
2857 | (begin | |
2858 | (define-derived-operand | |
2859 | (name (.sym dst16-Rn-direct- xmode)) | |
2860 | (comment (.str "m16c Rn direct destination " xmode)) | |
2861 | (attrs (machine 16)) | |
2862 | (mode xmode) | |
2863 | (args ((.sym Dst16Rn xmode))) | |
2864 | (syntax (.str "$Dst16Rn" xmode)) | |
2865 | (base-ifield f-12-4) | |
2866 | (encoding (+ (f-12-2 0) (.sym Dst16Rn xmode))) | |
2867 | (ifield-assertion (eq f-12-2 0)) | |
2868 | (getter (trunc xmode (.sym Dst16Rn xmode))) | |
2869 | (setter (set (.sym Dst16Rn xmode) newval)) | |
2870 | ) | |
2871 | ) | |
2872 | ) | |
2873 | ||
2874 | (dst16-Rn-direct-operand QI) | |
2875 | (dst16-Rn-direct-operand HI) | |
2876 | (dst16-Rn-direct-operand SI) | |
2877 | ||
2878 | (define-derived-operand | |
2879 | (name dst16-Rn-direct-Ext-QI) | |
2880 | (comment "m16c Rn direct destination QI") | |
2881 | (attrs (machine 16)) | |
2882 | (mode HI) | |
2883 | (args (Dst16RnExtQI)) | |
2884 | (syntax "$Dst16RnExtQI") | |
2885 | (base-ifield f-12-4) | |
2886 | (encoding (+ (f-12-2 0) Dst16RnExtQI (f-15-1 0))) | |
2887 | (ifield-assertion (andif (eq f-12-2 0) (eq f-15-1 0))) | |
2888 | (getter (trunc QI (.sym Dst16RnExtQI))) | |
2889 | (setter (set Dst16RnExtQI newval)) | |
2890 | ) | |
2891 | ||
2892 | (define-pmacro (dst32-Rn-direct-operand group base xmode) | |
2893 | (begin | |
2894 | (define-derived-operand | |
2895 | (name (.sym dst32-Rn-direct- group - xmode)) | |
2896 | (comment (.str "m32c Rn direct destination " xmode)) | |
2897 | (attrs (machine 32)) | |
2898 | (mode xmode) | |
2899 | (args ((.sym Dst32Rn group xmode))) | |
2900 | (syntax (.str "$Dst32Rn" group xmode)) | |
2901 | (base-ifield (.sym f- base -6)) | |
2902 | (encoding (+ ((.sym f- base -3) 4) (.sym Dst32Rn group xmode))) | |
2903 | (ifield-assertion (eq (.sym f- base -3) 4)) | |
2904 | (getter (trunc xmode (.sym Dst32Rn group xmode))) | |
2905 | (setter (set (.sym Dst32Rn group xmode) newval)) | |
2906 | ) | |
2907 | ) | |
2908 | ) | |
2909 | ||
2910 | (dst32-Rn-direct-operand Unprefixed 4 QI) | |
2911 | (dst32-Rn-direct-operand Prefixed 12 QI) | |
2912 | (dst32-Rn-direct-operand Unprefixed 4 HI) | |
2913 | (dst32-Rn-direct-operand Prefixed 12 HI) | |
2914 | (dst32-Rn-direct-operand Unprefixed 4 SI) | |
2915 | (dst32-Rn-direct-operand Prefixed 12 SI) | |
2916 | ||
2917 | (define-pmacro (dst32-Rn-direct-Ext-operand group base1 base2 smode dmode) | |
2918 | (begin | |
2919 | (define-derived-operand | |
2920 | (name (.sym dst32-Rn-direct- group - smode)) | |
2921 | (comment (.str "m32c Rn direct destination " smode)) | |
2922 | (attrs (machine 32)) | |
2923 | (mode dmode) | |
2924 | (args ((.sym Dst32Rn group smode))) | |
2925 | (syntax (.str "$Dst32Rn" group smode)) | |
2926 | (base-ifield (.sym f- base1 -6)) | |
2927 | (encoding (+ ((.sym f- base1 -3) 4) ((.sym f- base2 -1) 1) (.sym Dst32Rn group smode))) | |
2928 | (ifield-assertion (andif (eq (.sym f- base1 -3) 4) (eq (.sym f- base2 -1) 1))) | |
2929 | (getter (trunc smode (.sym Dst32Rn group smode))) | |
2930 | (setter (set (.sym Dst32Rn group smode) newval)) | |
2931 | ) | |
2932 | ) | |
2933 | ) | |
2934 | ||
2935 | (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 QI HI) | |
2936 | (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 HI SI) | |
2937 | ||
2938 | (define-derived-operand | |
2939 | (name dst32-R3-direct-Unprefixed-HI) | |
2940 | (comment "m32c R3 direct HI") | |
2941 | (attrs (machine 32)) | |
2942 | (mode HI) | |
2943 | (args (R3)) | |
2944 | (syntax "$R3") | |
2945 | (base-ifield f-4-6) | |
2946 | (encoding (+ (f-4-3 4) (f-8-2 #x1))) | |
2947 | (ifield-assertion (andif (eq f-4-3 4) (eq f-8-2 #x1))) | |
2948 | (getter (trunc HI R3)) | |
2949 | (setter (set R3 newval)) | |
2950 | ) | |
2951 | ;------------------------------------------------------------- | |
2952 | ; An direct | |
2953 | ;------------------------------------------------------------- | |
2954 | ||
2955 | (define-pmacro (dst16-An-direct-operand xmode) | |
2956 | (begin | |
2957 | (define-derived-operand | |
2958 | (name (.sym dst16-An-direct- xmode)) | |
2959 | (comment (.str "m16c An direct destination " xmode)) | |
2960 | (attrs (machine 16)) | |
2961 | (mode xmode) | |
2962 | (args ((.sym Dst16An xmode))) | |
2963 | (syntax (.str "$Dst16An" xmode)) | |
2964 | (base-ifield f-12-4) | |
2965 | (encoding (+ (f-12-2 1) (f-14-1 0) (.sym Dst16An xmode))) | |
2966 | (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0))) | |
2967 | (getter (trunc xmode (.sym Dst16An xmode))) | |
2968 | (setter (set (.sym Dst16An xmode) newval)) | |
2969 | ) | |
2970 | ) | |
2971 | ) | |
2972 | ||
2973 | (dst16-An-direct-operand QI) | |
2974 | (dst16-An-direct-operand HI) | |
2975 | (dst16-An-direct-operand SI) | |
2976 | ||
2977 | (define-pmacro (dst32-An-direct-operand group base1 base2 xmode) | |
2978 | (begin | |
2979 | (define-derived-operand | |
2980 | (name (.sym dst32-An-direct- group - xmode)) | |
2981 | (comment (.str "m32c An direct destination " xmode)) | |
2982 | (attrs (machine 32)) | |
2983 | (mode xmode) | |
2984 | (args ((.sym Dst32An group xmode))) | |
2985 | (syntax (.str "$Dst32An" group xmode)) | |
2986 | (base-ifield (.sym f- base1 -6)) | |
2987 | (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Dst32An group xmode))) | |
2988 | (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1))) | |
2989 | (getter (trunc xmode (.sym Dst32An group xmode))) | |
2990 | (setter (set (.sym Dst32An group xmode) newval)) | |
2991 | ) | |
2992 | ) | |
2993 | ) | |
2994 | ||
2995 | (dst32-An-direct-operand Unprefixed 4 8 QI) | |
2996 | (dst32-An-direct-operand Prefixed 12 16 QI) | |
2997 | (dst32-An-direct-operand Unprefixed 4 8 HI) | |
2998 | (dst32-An-direct-operand Prefixed 12 16 HI) | |
2999 | (dst32-An-direct-operand Unprefixed 4 8 SI) | |
3000 | (dst32-An-direct-operand Prefixed 12 16 SI) | |
3001 | ||
3002 | ;------------------------------------------------------------- | |
3003 | ; An indirect | |
3004 | ;------------------------------------------------------------- | |
3005 | ||
3006 | (define-pmacro (dst16-An-indirect-operand xmode) | |
3007 | (begin | |
3008 | (define-derived-operand | |
3009 | (name (.sym dst16-An-indirect- xmode)) | |
3010 | (comment (.str "m16c An indirect destination " xmode)) | |
3011 | (attrs (machine 16)) | |
3012 | (mode xmode) | |
3013 | (args (Dst16An)) | |
3014 | (syntax "[$Dst16An]") | |
3015 | (base-ifield f-12-4) | |
3016 | (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An)) | |
3017 | (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1))) | |
3018 | (getter (mem16 xmode Dst16An)) | |
3019 | (setter (set (mem16 xmode Dst16An) newval)) | |
3020 | ) | |
3021 | ) | |
3022 | ) | |
3023 | ||
3024 | (dst16-An-indirect-operand QI) | |
3025 | (dst16-An-indirect-operand HI) | |
3026 | (dst16-An-indirect-operand SI) | |
3027 | ||
3028 | (define-derived-operand | |
3029 | (name dst16-An-indirect-Ext-QI) | |
3030 | (comment "m16c An indirect destination QI") | |
3031 | (attrs (machine 16)) | |
3032 | (mode HI) | |
3033 | (args (Dst16An)) | |
3034 | (syntax "[$Dst16An]") | |
3035 | (base-ifield f-12-4) | |
3036 | (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An)) | |
3037 | (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1))) | |
3038 | (getter (mem16 QI Dst16An)) | |
3039 | (setter (set (mem16 HI Dst16An) newval)) | |
3040 | ) | |
3041 | ||
3042 | (define-pmacro (dst32-An-indirect-operand group base1 base2 smode dmode) | |
3043 | (begin | |
3044 | (define-derived-operand | |
3045 | (name (.sym dst32-An-indirect- group - smode)) | |
3046 | (comment (.str "m32c An indirect destination " smode)) | |
3047 | (attrs (machine 32)) | |
3048 | (mode dmode) | |
3049 | (args ((.sym Dst32An group))) | |
3050 | (syntax (.str "[$Dst32An" group "]")) | |
3051 | (base-ifield (.sym f- base1 -6)) | |
3052 | (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Dst32An group))) | |
3053 | (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0))) | |
3054 | (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) | |
3055 | (const 0))) | |
3056 | (setter (c-call DFLT (.str "operand_setter_" dmode) newval | |
3057 | (.sym Dst32An group) (const 0))) | |
3058 | ; (getter (mem32 smode (.sym Dst32An group))) | |
3059 | ; (setter (set (mem32 dmode (.sym Dst32An group)) newval)) | |
3060 | ) | |
3061 | ) | |
3062 | ) | |
3063 | ||
3064 | (dst32-An-indirect-operand Unprefixed 4 8 QI QI) | |
3065 | (dst32-An-indirect-operand Prefixed 12 16 QI QI) | |
3066 | (dst32-An-indirect-operand Unprefixed 4 8 HI HI) | |
3067 | (dst32-An-indirect-operand Prefixed 12 16 HI HI) | |
3068 | (dst32-An-indirect-operand Unprefixed 4 8 SI SI) | |
3069 | (dst32-An-indirect-operand Prefixed 12 16 SI SI) | |
3070 | (dst32-An-indirect-operand ExtUnprefixed 4 8 QI HI) | |
3071 | (dst32-An-indirect-operand ExtUnprefixed 4 8 HI SI) | |
3072 | ||
3073 | ;------------------------------------------------------------- | |
3074 | ; dsp:d[r] relative | |
3075 | ;------------------------------------------------------------- | |
3076 | ||
3077 | (define-pmacro (dst16-relative-operand offset xmode) | |
3078 | (begin | |
3079 | (define-derived-operand | |
3080 | (name (.sym dst16- offset -8-SB-relative- xmode)) | |
3081 | (comment (.str "m16c dsp:8[sb] relative destination " xmode)) | |
3082 | (attrs (machine 16)) | |
3083 | (mode xmode) | |
3084 | (args ((.sym Dsp- offset -u8))) | |
3085 | (syntax (.str "${Dsp-" offset "-u8}[sb]")) | |
3086 | (base-ifield f-12-4) | |
3087 | (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8))) | |
3088 | (ifield-assertion (eq f-12-4 #xA)) | |
3089 | (getter (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb)))) | |
3090 | (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval)) | |
3091 | ) | |
3092 | (define-derived-operand | |
3093 | (name (.sym dst16- offset -16-SB-relative- xmode)) | |
3094 | (comment (.str "m16c dsp:16[sb] relative destination " xmode)) | |
3095 | (attrs (machine 16)) | |
3096 | (mode xmode) | |
3097 | (args ((.sym Dsp- offset -u16))) | |
3098 | (syntax (.str "${Dsp-" offset "-u16}[sb]")) | |
3099 | (base-ifield f-12-4) | |
3100 | (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16))) | |
3101 | (ifield-assertion (eq f-12-4 #xE)) | |
3102 | (getter (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb)))) | |
3103 | (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval)) | |
3104 | ) | |
3105 | (define-derived-operand | |
3106 | (name (.sym dst16- offset -8-FB-relative- xmode)) | |
3107 | (comment (.str "m16c dsp:8[fb] relative destination " xmode)) | |
3108 | (attrs (machine 16)) | |
3109 | (mode xmode) | |
3110 | (args ((.sym Dsp- offset -s8))) | |
3111 | (syntax (.str "${Dsp-" offset "-s8}[fb]")) | |
3112 | (base-ifield f-12-4) | |
3113 | (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8))) | |
3114 | (ifield-assertion (eq f-12-4 #xB)) | |
3115 | (getter (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb)))) | |
3116 | (setter (set (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval)) | |
3117 | ) | |
3118 | (define-derived-operand | |
3119 | (name (.sym dst16- offset -8-An-relative- xmode)) | |
3120 | (comment (.str "m16c dsp:8[An] relative destination " xmode)) | |
3121 | (attrs (machine 16)) | |
3122 | (mode xmode) | |
3123 | (args (Dst16An (.sym Dsp- offset -u8))) | |
3124 | (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]")) | |
3125 | (base-ifield f-12-4) | |
3126 | (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An)) | |
3127 | (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0))) | |
3128 | (getter (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An))) | |
3129 | (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An)) newval)) | |
3130 | ) | |
3131 | (define-derived-operand | |
3132 | (name (.sym dst16- offset -16-An-relative- xmode)) | |
3133 | (comment (.str "m16c dsp:16[An] relative destination " xmode)) | |
3134 | (attrs (machine 16)) | |
3135 | (mode xmode) | |
3136 | (args (Dst16An (.sym Dsp- offset -u16))) | |
3137 | (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]")) | |
3138 | (base-ifield f-12-4) | |
3139 | (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An)) | |
3140 | (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0))) | |
3141 | (getter (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An))) | |
3142 | (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An)) newval)) | |
3143 | ) | |
3144 | ) | |
3145 | ) | |
3146 | ||
3147 | (dst16-relative-operand 16 QI) | |
3148 | (dst16-relative-operand 24 QI) | |
3149 | (dst16-relative-operand 32 QI) | |
3150 | (dst16-relative-operand 40 QI) | |
3151 | (dst16-relative-operand 48 QI) | |
3152 | (dst16-relative-operand 16 HI) | |
3153 | (dst16-relative-operand 24 HI) | |
3154 | (dst16-relative-operand 32 HI) | |
3155 | (dst16-relative-operand 40 HI) | |
3156 | (dst16-relative-operand 48 HI) | |
3157 | (dst16-relative-operand 16 SI) | |
3158 | (dst16-relative-operand 24 SI) | |
3159 | (dst16-relative-operand 32 SI) | |
3160 | (dst16-relative-operand 40 SI) | |
3161 | (dst16-relative-operand 48 SI) | |
3162 | ||
3163 | (define-pmacro (dst16-relative-Ext-operand offset smode dmode) | |
3164 | (begin | |
3165 | (define-derived-operand | |
3166 | (name (.sym dst16- offset -8-SB-relative-Ext- smode)) | |
3167 | (comment (.str "m16c dsp:8[sb] relative destination " smode)) | |
3168 | (attrs (machine 16)) | |
3169 | (mode dmode) | |
3170 | (args ((.sym Dsp- offset -u8))) | |
3171 | (syntax (.str "${Dsp-" offset "-u8}[sb]")) | |
3172 | (base-ifield f-12-4) | |
3173 | (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8))) | |
3174 | (ifield-assertion (eq f-12-4 #xA)) | |
3175 | (getter (mem16 smode (add (.sym Dsp- offset -u8) (reg h-sb)))) | |
3176 | (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval)) | |
3177 | ) | |
3178 | (define-derived-operand | |
3179 | (name (.sym dst16- offset -16-SB-relative-Ext- smode)) | |
3180 | (comment (.str "m16c dsp:16[sb] relative destination " smode)) | |
3181 | (attrs (machine 16)) | |
3182 | (mode dmode) | |
3183 | (args ((.sym Dsp- offset -u16))) | |
3184 | (syntax (.str "${Dsp-" offset "-u16}[sb]")) | |
3185 | (base-ifield f-12-4) | |
3186 | (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16))) | |
3187 | (ifield-assertion (eq f-12-4 #xE)) | |
3188 | (getter (mem16 smode (add (.sym Dsp- offset -u16) (reg h-sb)))) | |
3189 | (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval)) | |
3190 | ) | |
3191 | (define-derived-operand | |
3192 | (name (.sym dst16- offset -8-FB-relative-Ext- smode)) | |
3193 | (comment (.str "m16c dsp:8[fb] relative destination " smode)) | |
3194 | (attrs (machine 16)) | |
3195 | (mode dmode) | |
3196 | (args ((.sym Dsp- offset -s8))) | |
3197 | (syntax (.str "${Dsp-" offset "-s8}[fb]")) | |
3198 | (base-ifield f-12-4) | |
3199 | (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8))) | |
3200 | (ifield-assertion (eq f-12-4 #xB)) | |
3201 | (getter (mem16 smode (add (.sym Dsp- offset -s8) (reg h-fb)))) | |
3202 | (setter (set (mem16 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval)) | |
3203 | ) | |
3204 | (define-derived-operand | |
3205 | (name (.sym dst16- offset -8-An-relative-Ext- smode)) | |
3206 | (comment (.str "m16c dsp:8[An] relative destination " smode)) | |
3207 | (attrs (machine 16)) | |
3208 | (mode dmode) | |
3209 | (args (Dst16An (.sym Dsp- offset -u8))) | |
3210 | (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]")) | |
3211 | (base-ifield f-12-4) | |
3212 | (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An)) | |
3213 | (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0))) | |
3214 | (getter (mem16 smode (add (.sym Dsp- offset -u8) Dst16An))) | |
3215 | (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) Dst16An)) newval)) | |
3216 | ) | |
3217 | (define-derived-operand | |
3218 | (name (.sym dst16- offset -16-An-relative-Ext- smode)) | |
3219 | (comment (.str "m16c dsp:16[An] relative destination " smode)) | |
3220 | (attrs (machine 16)) | |
3221 | (mode dmode) | |
3222 | (args (Dst16An (.sym Dsp- offset -u16))) | |
3223 | (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]")) | |
3224 | (base-ifield f-12-4) | |
3225 | (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An)) | |
3226 | (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0))) | |
3227 | (getter (mem16 smode (add (.sym Dsp- offset -u16) Dst16An))) | |
3228 | (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) Dst16An)) newval)) | |
3229 | ) | |
3230 | ) | |
3231 | ) | |
3232 | ||
3233 | (dst16-relative-Ext-operand 16 QI HI) | |
3234 | ||
3235 | (define-pmacro (dst32-relative-operand offset group base1 base2 smode dmode) | |
3236 | (begin | |
3237 | (define-derived-operand | |
3238 | (name (.sym dst32- offset -8-SB-relative- group - smode)) | |
3239 | (comment (.str "m32c dsp:8[sb] relative destination " smode)) | |
3240 | (attrs (machine 32)) | |
3241 | (mode dmode) | |
3242 | (args ((.sym Dsp- offset -u8))) | |
3243 | (syntax (.str "${Dsp-" offset "-u8}[sb]")) | |
3244 | (base-ifield (.sym f- base1 -6)) | |
3245 | (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8))) | |
3246 | (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2))) | |
3247 | (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u8))) | |
3248 | (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u8))) | |
3249 | ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (reg h-sb)))) | |
3250 | ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval)) | |
3251 | ) | |
3252 | (define-derived-operand | |
3253 | (name (.sym dst32- offset -16-SB-relative- group - smode)) | |
3254 | (comment (.str "m32c dsp:16[sb] relative destination " smode)) | |
3255 | (attrs (machine 32)) | |
3256 | (mode dmode) | |
3257 | (args ((.sym Dsp- offset -u16))) | |
3258 | (syntax (.str "${Dsp-" offset "-u16}[sb]")) | |
3259 | (base-ifield (.sym f- base1 -6)) | |
3260 | (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16))) | |
3261 | (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2))) | |
3262 | (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u16))) | |
3263 | (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u16))) | |
3264 | ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (reg h-sb)))) | |
3265 | ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval)) | |
3266 | ) | |
3267 | (define-derived-operand | |
3268 | (name (.sym dst32- offset -8-FB-relative- group - smode)) | |
3269 | (comment (.str "m32c dsp:8[fb] relative destination " smode)) | |
3270 | (attrs (machine 32)) | |
3271 | (mode dmode) | |
3272 | (args ((.sym Dsp- offset -s8))) | |
3273 | (syntax (.str "${Dsp-" offset "-s8}[fb]")) | |
3274 | (base-ifield (.sym f- base1 -6)) | |
3275 | (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8))) | |
3276 | (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3))) | |
3277 | (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s8))) | |
3278 | (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s8))) | |
3279 | ; (getter (mem32 smode (add (.sym Dsp- offset -s8) (reg h-fb)))) | |
3280 | ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval)) | |
3281 | ) | |
3282 | (define-derived-operand | |
3283 | (name (.sym dst32- offset -16-FB-relative- group - smode)) | |
3284 | (comment (.str "m32c dsp:16[fb] relative destination " smode)) | |
3285 | (attrs (machine 32)) | |
3286 | (mode dmode) | |
3287 | (args ((.sym Dsp- offset -s16))) | |
3288 | (syntax (.str "${Dsp-" offset "-s16}[fb]")) | |
3289 | (base-ifield (.sym f- base1 -6)) | |
3290 | (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16))) | |
3291 | (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3))) | |
3292 | (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s16))) | |
3293 | (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s16))) | |
3294 | ; (getter (mem32 smode (add (.sym Dsp- offset -s16) (reg h-fb)))) | |
3295 | ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval)) | |
3296 | ) | |
3297 | (define-derived-operand | |
3298 | (name (.sym dst32- offset -8-An-relative- group - smode)) | |
3299 | (comment (.str "m32c dsp:8[An] relative destination " smode)) | |
3300 | (attrs (machine 32)) | |
3301 | (mode dmode) | |
3302 | (args ((.sym Dst32An group) (.sym Dsp- offset -u8))) | |
3303 | (syntax (.str "${Dsp-" offset "-u8}[$Dst32An" group "]")) | |
3304 | (base-ifield (.sym f- base1 -6)) | |
3305 | (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Dst32An group))) | |
3306 | (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0))) | |
3307 | (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u8))) | |
3308 | (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u8))) | |
3309 | ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (.sym Dst32An group)))) | |
3310 | ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (.sym Dst32An group))) newval)) | |
3311 | ) | |
3312 | (define-derived-operand | |
3313 | (name (.sym dst32- offset -16-An-relative- group - smode)) | |
3314 | (comment (.str "m32c dsp:16[An] relative destination " smode)) | |
3315 | (attrs (machine 32)) | |
3316 | (mode dmode) | |
3317 | (args ((.sym Dst32An group) (.sym Dsp- offset -u16))) | |
3318 | (syntax (.str "${Dsp-" offset "-u16}[$Dst32An" group "]")) | |
3319 | (base-ifield (.sym f- base1 -6)) | |
3320 | (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Dst32An group))) | |
3321 | (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0))) | |
3322 | (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u16))) | |
3323 | (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u16))) | |
3324 | ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (.sym Dst32An group)))) | |
3325 | ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (.sym Dst32An group))) newval)) | |
3326 | ) | |
3327 | (define-derived-operand | |
3328 | (name (.sym dst32- offset -24-An-relative- group - smode)) | |
3329 | (comment (.str "m32c dsp:16[An] relative destination " smode)) | |
3330 | (attrs (machine 32)) | |
3331 | (mode dmode) | |
3332 | (args ((.sym Dst32An group) (.sym Dsp- offset -u24))) | |
3333 | (syntax (.str "${Dsp-" offset "-u24}[$Dst32An" group "]")) | |
3334 | (base-ifield (.sym f- base1 -6)) | |
3335 | (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Dst32An group))) | |
3336 | (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0))) | |
3337 | (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u24))) | |
3338 | (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u24))) | |
3339 | ; (getter (mem32 smode (add (.sym Dsp- offset -u24) (.sym Dst32An group)))) | |
3340 | ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u24) (.sym Dst32An group))) newval)) | |
3341 | ) | |
3342 | ) | |
3343 | ) | |
3344 | ||
3345 | (dst32-relative-operand 16 Unprefixed 4 8 QI QI) | |
3346 | (dst32-relative-operand 24 Unprefixed 4 8 QI QI) | |
3347 | (dst32-relative-operand 32 Unprefixed 4 8 QI QI) | |
3348 | (dst32-relative-operand 40 Unprefixed 4 8 QI QI) | |
3349 | (dst32-relative-operand 16 Unprefixed 4 8 HI HI) | |
3350 | (dst32-relative-operand 24 Unprefixed 4 8 HI HI) | |
3351 | (dst32-relative-operand 32 Unprefixed 4 8 HI HI) | |
3352 | (dst32-relative-operand 40 Unprefixed 4 8 HI HI) | |
3353 | (dst32-relative-operand 16 Unprefixed 4 8 SI SI) | |
3354 | (dst32-relative-operand 24 Unprefixed 4 8 SI SI) | |
3355 | (dst32-relative-operand 32 Unprefixed 4 8 SI SI) | |
3356 | (dst32-relative-operand 40 Unprefixed 4 8 SI SI) | |
3357 | ||
3358 | (dst32-relative-operand 24 Prefixed 12 16 QI QI) | |
3359 | (dst32-relative-operand 32 Prefixed 12 16 QI QI) | |
3360 | (dst32-relative-operand 40 Prefixed 12 16 QI QI) | |
3361 | (dst32-relative-operand 48 Prefixed 12 16 QI QI) | |
3362 | (dst32-relative-operand 24 Prefixed 12 16 HI HI) | |
3363 | (dst32-relative-operand 32 Prefixed 12 16 HI HI) | |
3364 | (dst32-relative-operand 40 Prefixed 12 16 HI HI) | |
3365 | (dst32-relative-operand 48 Prefixed 12 16 HI HI) | |
3366 | (dst32-relative-operand 24 Prefixed 12 16 SI SI) | |
3367 | (dst32-relative-operand 32 Prefixed 12 16 SI SI) | |
3368 | (dst32-relative-operand 40 Prefixed 12 16 SI SI) | |
3369 | (dst32-relative-operand 48 Prefixed 12 16 SI SI) | |
3370 | ||
3371 | (dst32-relative-operand 16 ExtUnprefixed 4 8 QI HI) | |
3372 | (dst32-relative-operand 16 ExtUnprefixed 4 8 HI SI) | |
3373 | ||
3374 | ;------------------------------------------------------------- | |
3375 | ; Absolute address | |
3376 | ;------------------------------------------------------------- | |
3377 | ||
3378 | (define-pmacro (dst16-absolute offset xmode) | |
3379 | (begin | |
3380 | (define-derived-operand | |
3381 | (name (.sym dst16- offset -16-absolute- xmode)) | |
3382 | (comment (.str "m16c absolute address " xmode)) | |
3383 | (attrs (machine 16)) | |
3384 | (mode xmode) | |
3385 | (args ((.sym Dsp- offset -u16))) | |
3386 | (syntax (.str "${Dsp-" offset "-u16}")) | |
3387 | (base-ifield f-12-4) | |
3388 | (encoding (+ (f-12-4 #xF) (.sym Dsp- offset -u16))) | |
3389 | (ifield-assertion (eq f-12-4 #xF)) | |
3390 | (getter (mem16 xmode (.sym Dsp- offset -u16))) | |
3391 | (setter (set (mem16 xmode (.sym Dsp- offset -u16)) newval)) | |
3392 | ) | |
3393 | ) | |
3394 | ) | |
3395 | ||
3396 | (dst16-absolute 16 QI) | |
3397 | (dst16-absolute 24 QI) | |
3398 | (dst16-absolute 32 QI) | |
3399 | (dst16-absolute 40 QI) | |
3400 | (dst16-absolute 48 QI) | |
3401 | (dst16-absolute 16 HI) | |
3402 | (dst16-absolute 24 HI) | |
3403 | (dst16-absolute 32 HI) | |
3404 | (dst16-absolute 40 HI) | |
3405 | (dst16-absolute 48 HI) | |
3406 | (dst16-absolute 16 SI) | |
3407 | (dst16-absolute 24 SI) | |
3408 | (dst16-absolute 32 SI) | |
3409 | (dst16-absolute 40 SI) | |
3410 | (dst16-absolute 48 SI) | |
3411 | ||
3412 | (define-derived-operand | |
3413 | (name dst16-16-16-absolute-Ext-QI) | |
3414 | (comment "m16c absolute address QI") | |
3415 | (attrs (machine 16)) | |
3416 | (mode HI) | |
3417 | (args (Dsp-16-u16)) | |
3418 | (syntax "${Dsp-16-u16}") | |
3419 | (base-ifield f-12-4) | |
3420 | (encoding (+ (f-12-4 #xF) Dsp-16-u16)) | |
3421 | (ifield-assertion (eq f-12-4 #xF)) | |
3422 | (getter (mem16 QI Dsp-16-u16)) | |
3423 | (setter (set (mem16 HI Dsp-16-u16) newval)) | |
3424 | ) | |
3425 | ||
3426 | (define-pmacro (dst32-absolute offset group base1 base2 smode dmode) | |
3427 | (begin | |
3428 | (define-derived-operand | |
3429 | (name (.sym dst32- offset -16-absolute- group - smode)) | |
3430 | (comment (.str "m32c absolute address " smode)) | |
3431 | (attrs (machine 32)) | |
3432 | (mode dmode) | |
3433 | (args ((.sym Dsp- offset -u16))) | |
3434 | (syntax (.str "${Dsp-" offset "-u16}")) | |
3435 | (base-ifield (.sym f- base1 -6)) | |
3436 | (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16))) | |
3437 | (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3))) | |
3438 | (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u16))) | |
3439 | (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u16))) | |
3440 | ; (getter (mem32 smode (.sym Dsp- offset -u16))) | |
3441 | ; (setter (set (mem32 dmode (.sym Dsp- offset -u16)) newval)) | |
3442 | ) | |
3443 | (define-derived-operand | |
3444 | (name (.sym dst32- offset -24-absolute- group - smode)) | |
3445 | (comment (.str "m32c absolute address " smode)) | |
3446 | (attrs (machine 32)) | |
3447 | (mode dmode) | |
3448 | (args ((.sym Dsp- offset -u24))) | |
3449 | (syntax (.str "${Dsp-" offset "-u24}")) | |
3450 | (base-ifield (.sym f- base1 -6)) | |
3451 | (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24))) | |
3452 | (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2))) | |
3453 | (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u24))) | |
3454 | (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u24))) | |
3455 | ; (getter (mem32 smode (.sym Dsp- offset -u24))) | |
3456 | ; (setter (set (mem32 dmode (.sym Dsp- offset -u24)) newval)) | |
3457 | ) | |
3458 | ) | |
3459 | ) | |
3460 | ||
3461 | (dst32-absolute 16 Unprefixed 4 8 QI QI) | |
3462 | (dst32-absolute 24 Unprefixed 4 8 QI QI) | |
3463 | (dst32-absolute 32 Unprefixed 4 8 QI QI) | |
3464 | (dst32-absolute 40 Unprefixed 4 8 QI QI) | |
3465 | (dst32-absolute 16 Unprefixed 4 8 HI HI) | |
3466 | (dst32-absolute 24 Unprefixed 4 8 HI HI) | |
3467 | (dst32-absolute 32 Unprefixed 4 8 HI HI) | |
3468 | (dst32-absolute 40 Unprefixed 4 8 HI HI) | |
3469 | (dst32-absolute 16 Unprefixed 4 8 SI SI) | |
3470 | (dst32-absolute 24 Unprefixed 4 8 SI SI) | |
3471 | (dst32-absolute 32 Unprefixed 4 8 SI SI) | |
3472 | (dst32-absolute 40 Unprefixed 4 8 SI SI) | |
3473 | ||
3474 | (dst32-absolute 24 Prefixed 12 16 QI QI) | |
3475 | (dst32-absolute 32 Prefixed 12 16 QI QI) | |
3476 | (dst32-absolute 40 Prefixed 12 16 QI QI) | |
3477 | (dst32-absolute 48 Prefixed 12 16 QI QI) | |
3478 | (dst32-absolute 24 Prefixed 12 16 HI HI) | |
3479 | (dst32-absolute 32 Prefixed 12 16 HI HI) | |
3480 | (dst32-absolute 40 Prefixed 12 16 HI HI) | |
3481 | (dst32-absolute 48 Prefixed 12 16 HI HI) | |
3482 | (dst32-absolute 24 Prefixed 12 16 SI SI) | |
3483 | (dst32-absolute 32 Prefixed 12 16 SI SI) | |
3484 | (dst32-absolute 40 Prefixed 12 16 SI SI) | |
3485 | (dst32-absolute 48 Prefixed 12 16 SI SI) | |
3486 | ||
3487 | (dst32-absolute 16 ExtUnprefixed 4 8 QI HI) | |
3488 | (dst32-absolute 16 ExtUnprefixed 4 8 HI SI) | |
3489 | ||
3490 | ;------------------------------------------------------------- | |
3491 | ; An indirect indirect | |
3492 | ;------------------------------------------------------------- | |
3493 | ||
3494 | ;(define-pmacro (dst-An-indirect-indirect-operand xmode) | |
3495 | ; (define-derived-operand | |
3496 | ; (name (.sym dst32-An-indirect-indirect- xmode)) | |
3497 | ; (comment (.str "m32c An indirect indirect destination " xmode)) | |
3498 | ; (attrs (machine 32)) | |
3499 | ; (mode xmode) | |
3500 | ; (args (Dst32AnPrefixed)) | |
3501 | ; (syntax (.str "[[$Dst32AnPrefixed]]")) | |
3502 | ; (base-ifield f-12-6) | |
3503 | ; (encoding (+ (f-12-3 0) (f-16-1 0) Dst32AnPrefixed)) | |
3504 | ; (ifield-assertion (andif (eq f-12-3 0) (eq f-16-1 0))) | |
3505 | ; (getter (mem32 xmode (indirect-addr Dst32AnPrefixed))) | |
3506 | ; (setter (set (mem32 xmode (indirect-addr Dst32AnPrefixed)) newval)) | |
3507 | ; ) | |
3508 | ;) | |
3509 | ||
3510 | ; (dst-An-indirect-indirect-operand QI) | |
3511 | ; (dst-An-indirect-indirect-operand HI) | |
3512 | ; (dst-An-indirect-indirect-operand SI) | |
3513 | ||
3514 | ;------------------------------------------------------------- | |
3515 | ; Relative indirect | |
3516 | ;------------------------------------------------------------- | |
3517 | ||
3518 | (define-pmacro (dst-relative-indirect-operand offset xmode) | |
3519 | (begin | |
3520 | ; (define-derived-operand | |
3521 | ; (name (.sym dst32- offset -8-SB-relative-indirect- xmode)) | |
3522 | ; (comment (.str "m32c dsp:8[sb] relative destination " xmode)) | |
3523 | ; (attrs (machine 32)) | |
3524 | ; (mode xmode) | |
3525 | ; (args ((.sym Dsp- offset -u8))) | |
3526 | ; (syntax (.str "[${Dsp-" offset "-u8}[sb]]")) | |
3527 | ; (base-ifield f-12-6) | |
3528 | ; (encoding (+ (f-12-3 1) (f-16-2 2) (.sym Dsp- offset -u8))) | |
3529 | ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 2))) | |
3530 | ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb))))) | |
3531 | ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb)))) newval)) | |
3532 | ; ) | |
3533 | ; (define-derived-operand | |
3534 | ; (name (.sym dst32- offset -16-SB-relative-indirect- xmode)) | |
3535 | ; (comment (.str "m32c dsp:16[sb] relative destination " xmode)) | |
3536 | ; (attrs (machine 32)) | |
3537 | ; (mode xmode) | |
3538 | ; (args ((.sym Dsp- offset -u16))) | |
3539 | ; (syntax (.str "[${Dsp-" offset "-u16}[sb]]")) | |
3540 | ; (base-ifield f-12-6) | |
3541 | ; (encoding (+ (f-12-3 2) (f-16-2 2) (.sym Dsp- offset -u16))) | |
3542 | ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 2))) | |
3543 | ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb))))) | |
3544 | ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb)))) newval)) | |
3545 | ; ) | |
3546 | ; (define-derived-operand | |
3547 | ; (name (.sym dst32- offset -8-FB-relative-indirect- xmode)) | |
3548 | ; (comment (.str "m32c dsp:8[fb] relative destination " xmode)) | |
3549 | ; (attrs (machine 32)) | |
3550 | ; (mode xmode) | |
3551 | ; (args ((.sym Dsp- offset -s8))) | |
3552 | ; (syntax (.str "[${Dsp-" offset "-s8}[fb]]")) | |
3553 | ; (base-ifield f-12-6) | |
3554 | ; (encoding (+ (f-12-3 1) (f-16-2 3) (.sym Dsp- offset -s8))) | |
3555 | ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 3))) | |
3556 | ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb))))) | |
3557 | ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb)))) newval)) | |
3558 | ; ) | |
3559 | ; (define-derived-operand | |
3560 | ; (name (.sym dst32- offset -16-FB-relative-indirect- xmode)) | |
3561 | ; (comment (.str "m32c dsp:16[fb] relative destination " xmode)) | |
3562 | ; (attrs (machine 32)) | |
3563 | ; (mode xmode) | |
3564 | ; (args ((.sym Dsp- offset -s16))) | |
3565 | ; (syntax (.str "[${Dsp-" offset "-s16}[fb]]")) | |
3566 | ; (base-ifield f-12-6) | |
3567 | ; (encoding (+ (f-12-3 2) (f-16-2 3) (.sym Dsp- offset -s16))) | |
3568 | ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 3))) | |
3569 | ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb))))) | |
3570 | ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb)))) newval)) | |
3571 | ; ) | |
3572 | ; (define-derived-operand | |
3573 | ; (name (.sym dst32- offset -8-An-relative-indirect- xmode)) | |
3574 | ; (comment (.str "m32c dsp:8[An] relative indirect destination " xmode)) | |
3575 | ; (attrs (machine 32)) | |
3576 | ; (mode xmode) | |
3577 | ; (args (Dst32AnPrefixed (.sym Dsp- offset -u8))) | |
3578 | ; (syntax (.str "[${Dsp-" offset "-u8}[$Dst32AnPrefixed]]")) | |
3579 | ; (base-ifield f-12-6) | |
3580 | ; (encoding (+ (f-12-3 1) (f-16-1 0) (.sym Dsp- offset -u8) Dst32AnPrefixed)) | |
3581 | ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-1 0))) | |
3582 | ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed)))) | |
3583 | ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed))) newval)) | |
3584 | ; ) | |
3585 | ; (define-derived-operand | |
3586 | ; (name (.sym dst32- offset -16-An-relative-indirect- xmode)) | |
3587 | ; (comment (.str "m32c dsp:16[An] relative destination " xmode)) | |
3588 | ; (attrs (machine 32)) | |
3589 | ; (mode xmode) | |
3590 | ; (args (Dst32AnPrefixed (.sym Dsp- offset -u16))) | |
3591 | ; (syntax (.str "[${Dsp-" offset "-u16}[$Dst32AnPrefixed]]")) | |
3592 | ; (base-ifield f-12-6) | |
3593 | ; (encoding (+ (f-12-3 2) (f-16-1 0) (.sym Dsp- offset -u16) Dst32AnPrefixed)) | |
3594 | ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-1 0))) | |
3595 | ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed)))) | |
3596 | ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed))) newval)) | |
3597 | ; ) | |
3598 | ; (define-derived-operand | |
3599 | ; (name (.sym dst32- offset -24-An-relative-indirect- xmode)) | |
3600 | ; (comment (.str "m32c dsp:24[An] relative destination " xmode)) | |
3601 | ; (attrs (machine 32)) | |
3602 | ; (mode xmode) | |
3603 | ; (args (Dst32AnPrefixed (.sym Dsp- offset -u24))) | |
3604 | ; (syntax (.str "[${Dsp-" offset "-u24}[$Dst32AnPrefixed]]")) | |
3605 | ; (base-ifield f-12-6) | |
3606 | ; (encoding (+ (f-12-3 3) (f-16-1 0) (.sym Dsp- offset -u24) Dst32AnPrefixed)) | |
3607 | ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-1 0))) | |
3608 | ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed)))) | |
3609 | ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed))) newval)) | |
3610 | ; ) | |
3611 | ) | |
3612 | ) | |
3613 | ||
3614 | ; (dst-relative-indirect-operand 24 QI) | |
3615 | ; (dst-relative-indirect-operand 32 QI) | |
3616 | ; (dst-relative-indirect-operand 40 QI) | |
3617 | ; (dst-relative-indirect-operand 48 QI) | |
3618 | ; (dst-relative-indirect-operand 24 HI) | |
3619 | ; (dst-relative-indirect-operand 32 HI) | |
3620 | ; (dst-relative-indirect-operand 40 HI) | |
3621 | ; (dst-relative-indirect-operand 48 HI) | |
3622 | ; (dst-relative-indirect-operand 24 SI) | |
3623 | ; (dst-relative-indirect-operand 32 SI) | |
3624 | ; (dst-relative-indirect-operand 40 SI) | |
3625 | ; (dst-relative-indirect-operand 48 SI) | |
3626 | ||
3627 | ;------------------------------------------------------------- | |
3628 | ; Absolute indirect | |
3629 | ;------------------------------------------------------------- | |
3630 | ||
3631 | (define-pmacro (dst-absolute-indirect offset xmode) | |
3632 | (begin | |
3633 | ; (define-derived-operand | |
3634 | ; (name (.sym dst32- offset -16-absolute-indirect-derived- xmode)) | |
3635 | ; (comment (.str "m32c absolute indirect address " xmode)) | |
3636 | ; (attrs (machine 32)) | |
3637 | ; (mode xmode) | |
3638 | ; (args ((.sym Dsp- offset -u16))) | |
3639 | ; (syntax (.str "[${Dsp-" offset "-u16}]")) | |
3640 | ; (base-ifield f-12-6) | |
3641 | ; (encoding (+ (f-12-3 3) (f-16-2 3) (.sym Dsp- offset -u16))) | |
3642 | ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 3))) | |
3643 | ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16)))) | |
3644 | ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval)) | |
3645 | ; ) | |
3646 | ; (define-derived-operand | |
3647 | ; (name (.sym dst32- offset -24-absolute-indirect-derived- xmode)) | |
3648 | ; (comment (.str "m32c absolute indirect address " xmode)) | |
3649 | ; (attrs (machine 32)) | |
3650 | ; (mode xmode) | |
3651 | ; (args ((.sym Dsp- offset -u24))) | |
3652 | ; (syntax (.str "[${Dsp-" offset "-u24}]")) | |
3653 | ; (base-ifield f-12-6) | |
3654 | ; (encoding (+ (f-12-3 3) (f-16-2 2) (.sym Dsp- offset -u24))) | |
3655 | ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 2))) | |
3656 | ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24)))) | |
3657 | ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval)) | |
3658 | ; ) | |
3659 | ) | |
3660 | ) | |
3661 | ||
3662 | (dst-absolute-indirect 24 QI) | |
3663 | (dst-absolute-indirect 32 QI) | |
3664 | (dst-absolute-indirect 40 QI) | |
3665 | (dst-absolute-indirect 48 QI) | |
3666 | (dst-absolute-indirect 24 HI) | |
3667 | (dst-absolute-indirect 32 HI) | |
3668 | (dst-absolute-indirect 40 HI) | |
3669 | (dst-absolute-indirect 48 HI) | |
3670 | (dst-absolute-indirect 24 SI) | |
3671 | (dst-absolute-indirect 32 SI) | |
3672 | (dst-absolute-indirect 40 SI) | |
3673 | (dst-absolute-indirect 48 SI) | |
3674 | ||
3675 | ;------------------------------------------------------------- | |
3676 | ; Bit operands | |
3677 | ;------------------------------------------------------------- | |
3678 | (define-pmacro (get-register-bit reg bitno) | |
3679 | (and (srl reg bitno) 1) | |
3680 | ) | |
3681 | ||
3682 | (define-pmacro (set-register-bit reg bitno value) | |
3683 | (set reg (or (and reg (inv (sll 1 bitno))) | |
3684 | (sll (and QI value 1) bitno))) | |
3685 | ) | |
3686 | ||
3687 | (define-pmacro (get-memory-bit mach base bitno) | |
3688 | (and (srl (mem-mach mach QI (add base (div bitno 8))) | |
3689 | (mod bitno 8)) | |
3690 | 1) | |
3691 | ) | |
3692 | ||
3693 | (define-pmacro (set-memory-bit mach base bitno value) | |
3694 | (sequence ((USI addr)) | |
3695 | (set addr (add base (div bitno 8))) | |
3696 | (set (mem-mach mach QI addr) | |
3697 | (or (and (mem-mach mach QI addr) | |
3698 | (inv (sll 1 (mod bitno 8)))) | |
3699 | (sll (and QI value 1) (mod bitno 8))))) | |
3700 | ) | |
3701 | ||
3702 | ;------------------------------------------------------------- | |
3703 | ; Rn direct | |
3704 | ;------------------------------------------------------------- | |
3705 | ||
3706 | (define-derived-operand | |
3707 | (name bit16-Rn-direct) | |
3708 | (comment "m16c Rn direct bit") | |
3709 | (attrs (machine 16)) | |
3710 | (mode BI) | |
3711 | (args (Bitno16R Bit16Rn)) | |
3712 | (syntax "$Bitno16R,$Bit16Rn") | |
3713 | (base-ifield f-12-4) | |
3714 | (encoding (+ (f-12-2 0) Bit16Rn Bitno16R)) | |
3715 | (ifield-assertion (eq f-12-2 0)) | |
3716 | (getter (get-register-bit Bit16Rn Bitno16R)) | |
3717 | (setter (set-register-bit Bit16Rn Bitno16R newval)) | |
3718 | ) | |
3719 | ||
3720 | (define-pmacro (bit32-Rn-direct-operand group base) | |
3721 | (begin | |
3722 | (define-derived-operand | |
3723 | (name (.sym bit32-Rn-direct- group)) | |
3724 | (comment "m32c Rn direct bit") | |
3725 | (attrs (machine 32)) | |
3726 | (mode BI) | |
3727 | (args ((.sym Bitno32 group) (.sym Bit32Rn group))) | |
3728 | (syntax (.str "$Bitno32" group ",$Bit32Rn" group)) | |
3729 | (base-ifield (.sym f- base -6)) | |
3730 | (encoding (+ ((.sym f- base -3) 4) (.sym Bit32Rn group) (.sym Bitno32 group))) | |
3731 | (ifield-assertion (eq (.sym f- base -3) 4)) | |
3732 | (getter (get-register-bit (.sym Bit32Rn group) (.sym Bitno32 group))) | |
3733 | (setter (set-register-bit (.sym Bit32Rn group) (.sym Bitno32 group) newval)) | |
3734 | ) | |
3735 | ) | |
3736 | ) | |
3737 | ||
3738 | (bit32-Rn-direct-operand Unprefixed 4) | |
3739 | (bit32-Rn-direct-operand Prefixed 12) | |
3740 | ||
3741 | ;------------------------------------------------------------- | |
3742 | ; An direct | |
3743 | ;------------------------------------------------------------- | |
3744 | ||
3745 | (define-derived-operand | |
3746 | (name bit16-An-direct) | |
3747 | (comment "m16c An direct bit") | |
3748 | (attrs (machine 16)) | |
3749 | (mode BI) | |
3750 | (args (Bitno16R Bit16An)) | |
3751 | (syntax "$Bitno16R,$Bit16An") | |
3752 | (base-ifield f-12-4) | |
3753 | (encoding (+ (f-12-2 1) (f-14-1 0) Bit16An Bitno16R)) | |
3754 | (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0))) | |
3755 | (getter (get-register-bit Bit16An Bitno16R)) | |
3756 | (setter (set-register-bit Bit16An Bitno16R newval)) | |
3757 | ) | |
3758 | ||
3759 | (define-pmacro (bit32-An-direct-operand group base1 base2) | |
3760 | (begin | |
3761 | (define-derived-operand | |
3762 | (name (.sym bit32-An-direct- group)) | |
3763 | (comment "m32c An direct bit") | |
3764 | (attrs (machine 32)) | |
3765 | (mode BI) | |
3766 | (args ((.sym Bitno32 group) (.sym Bit32An group))) | |
3767 | (syntax (.str "$Bitno32" group ",$Bit32An" group)) | |
3768 | (base-ifield (.sym f- base1 -6)) | |
3769 | (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Bit32An group) (.sym Bitno32 group))) | |
3770 | (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1))) | |
3771 | (getter (get-register-bit (.sym Bit32An group) (.sym Bitno32 group))) | |
3772 | (setter (set-register-bit (.sym Bit32An group) (.sym Bitno32 group) newval)) | |
3773 | ) | |
3774 | ) | |
3775 | ) | |
3776 | ||
3777 | (bit32-An-direct-operand Unprefixed 4 8) | |
3778 | (bit32-An-direct-operand Prefixed 12 16) | |
3779 | ||
3780 | ;------------------------------------------------------------- | |
3781 | ; An indirect | |
3782 | ;------------------------------------------------------------- | |
3783 | ||
3784 | (define-derived-operand | |
3785 | (name bit16-An-indirect) | |
3786 | (comment "m16c An indirect bit") | |
3787 | (attrs (machine 16)) | |
3788 | (mode BI) | |
3789 | (args (Bit16An)) | |
3790 | (syntax "[$Bit16An]") | |
3791 | (base-ifield f-12-4) | |
3792 | (encoding (+ (f-12-2 1) (f-14-1 1) Bit16An)) | |
3793 | (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1))) | |
3794 | (getter (get-memory-bit 16 0 Bit16An)) | |
3795 | (setter (set-memory-bit 16 0 Bit16An newval)) | |
3796 | ) | |
3797 | ||
3798 | (define-pmacro (bit32-An-indirect-operand group base1 base2) | |
3799 | (begin | |
3800 | (define-derived-operand | |
3801 | (name (.sym bit32-An-indirect- group)) | |
3802 | (comment "m32c An indirect destination ") | |
3803 | (attrs (machine 32)) | |
3804 | (mode BI) | |
3805 | (args ((.sym Bitno32 group) (.sym Bit32An group))) | |
3806 | (syntax (.str "$Bitno32" group ",[$Bit32An" group "]")) | |
3807 | (base-ifield (.sym f- base1 -6)) | |
3808 | (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Bit32An group) (.sym Bitno32 group))) | |
3809 | (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0))) | |
3810 | (getter (get-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group))) | |
3811 | (setter (set-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group) newval)) | |
3812 | ) | |
3813 | ) | |
3814 | ) | |
3815 | ||
3816 | (bit32-An-indirect-operand Unprefixed 4 8) | |
3817 | (bit32-An-indirect-operand Prefixed 12 16) | |
3818 | ||
3819 | ;------------------------------------------------------------- | |
3820 | ; dsp:d[r] relative | |
3821 | ;------------------------------------------------------------- | |
3822 | ||
3823 | (define-pmacro (bit16-relative-operand offset) | |
3824 | (begin | |
3825 | (define-derived-operand | |
3826 | (name (.sym bit16- offset -8-SB-relative)) | |
3827 | (comment (.str "m16c dsp:8[sb] relative bit " xmode)) | |
3828 | (attrs (machine 16)) | |
3829 | (mode BI) | |
3830 | (args ((.sym BitBase16- offset -u8))) | |
3831 | (syntax (.str "${BitBase16-" offset "-u8}[sb]")) | |
3832 | (base-ifield f-12-4) | |
3833 | (encoding (+ (f-12-4 #xA) (.sym BitBase16- offset -u8))) | |
3834 | (ifield-assertion (eq f-12-4 #xA)) | |
3835 | (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8))) | |
3836 | (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8) newval)) | |
3837 | ) | |
3838 | (define-derived-operand | |
3839 | (name (.sym bit16- offset -16-SB-relative)) | |
3840 | (comment (.str "m16c dsp:16[sb] relative bit " xmode)) | |
3841 | (attrs (machine 16)) | |
3842 | (mode BI) | |
3843 | (args ((.sym BitBase16- offset -u16))) | |
3844 | (syntax (.str "${BitBase16-" offset "-u16}[sb]")) | |
3845 | (base-ifield f-12-4) | |
3846 | (encoding (+ (f-12-4 #xE) (.sym BitBase16- offset -u16))) | |
3847 | (ifield-assertion (eq f-12-4 #xE)) | |
3848 | (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16))) | |
3849 | (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16) newval)) | |
3850 | ) | |
3851 | (define-derived-operand | |
3852 | (name (.sym bit16- offset -8-FB-relative)) | |
3853 | (comment (.str "m16c dsp:8[fb] relative bit " xmode)) | |
3854 | (attrs (machine 16)) | |
3855 | (mode BI) | |
3856 | (args ((.sym BitBase16- offset -s8))) | |
3857 | (syntax (.str "${BitBase16-" offset "-s8}[fb]")) | |
3858 | (base-ifield f-12-4) | |
3859 | (encoding (+ (f-12-4 #xB) (.sym BitBase16- offset -s8))) | |
3860 | (ifield-assertion (eq f-12-4 #xB)) | |
3861 | (getter (get-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8))) | |
3862 | (setter (set-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8) newval)) | |
3863 | ) | |
3864 | (define-derived-operand | |
3865 | (name (.sym bit16- offset -8-An-relative)) | |
3866 | (comment (.str "m16c dsp:8[An] relative bit " xmode)) | |
3867 | (attrs (machine 16)) | |
3868 | (mode BI) | |
3869 | (args (Bit16An (.sym Dsp- offset -u8))) | |
3870 | (syntax (.str "${Dsp-" offset "-u8}[$Bit16An]")) | |
3871 | (base-ifield f-12-4) | |
3872 | (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Bit16An)) | |
3873 | (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0))) | |
3874 | (getter (get-memory-bit 16 (.sym Dsp- offset -u8) Bit16An)) | |
3875 | (setter (set-memory-bit 16 (.sym Dsp- offset -u8) Bit16An newval)) | |
3876 | ) | |
3877 | (define-derived-operand | |
3878 | (name (.sym bit16- offset -16-An-relative)) | |
3879 | (comment (.str "m16c dsp:16[An] relative bit " xmode)) | |
3880 | (attrs (machine 16)) | |
3881 | (mode BI) | |
3882 | (args (Bit16An (.sym Dsp- offset -u16))) | |
3883 | (syntax (.str "${Dsp-" offset "-u16}[$Bit16An]")) | |
3884 | (base-ifield f-12-4) | |
3885 | (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Bit16An)) | |
3886 | (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0))) | |
3887 | (getter (get-memory-bit 16 (.sym Dsp- offset -u16) Bit16An)) | |
3888 | (setter (set-memory-bit 16 (.sym Dsp- offset -u16) Bit16An newval)) | |
3889 | ) | |
3890 | ) | |
3891 | ) | |
3892 | ||
3893 | (bit16-relative-operand 16) | |
3894 | ||
3895 | (define-pmacro (bit32-relative-operand offset group base1 base2) | |
3896 | (begin | |
3897 | (define-derived-operand | |
3898 | (name (.sym bit32- offset -11-SB-relative- group)) | |
3899 | (comment "m32c bit,base:11[sb] relative bit") | |
3900 | (attrs (machine 32)) | |
3901 | (mode BI) | |
3902 | (args ((.sym BitBase32- offset -u11- group))) | |
3903 | (syntax (.str "${BitBase32-" offset "-u11-" group "}[sb]")) | |
3904 | (base-ifield (.sym f- base1 -12)) | |
3905 | (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u11- group))) | |
3906 | (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2))) | |
3907 | (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group))) | |
3908 | (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group) newval)) | |
3909 | ) | |
3910 | (define-derived-operand | |
3911 | (name (.sym bit32- offset -19-SB-relative- group)) | |
3912 | (comment "m32c bit,base:19[sb] relative bit") | |
3913 | (attrs (machine 32)) | |
3914 | (mode BI) | |
3915 | (args ((.sym BitBase32- offset -u19- group))) | |
3916 | (syntax (.str "${BitBase32-" offset "-u19-" group "}[sb]")) | |
3917 | (base-ifield (.sym f- base1 -12)) | |
3918 | (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u19- group))) | |
3919 | (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2))) | |
3920 | (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group))) | |
3921 | (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group) newval)) | |
3922 | ) | |
3923 | (define-derived-operand | |
3924 | (name (.sym bit32- offset -11-FB-relative- group)) | |
3925 | (comment "m32c bit,base:11[fb] relative bit") | |
3926 | (attrs (machine 32)) | |
3927 | (mode BI) | |
3928 | (args ((.sym BitBase32- offset -s11- group))) | |
3929 | (syntax (.str "${BitBase32-" offset "-s11-" group "}[fb]")) | |
3930 | (base-ifield (.sym f- base1 -12)) | |
3931 | (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s11- group))) | |
3932 | (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3))) | |
3933 | (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group))) | |
3934 | (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group) newval)) | |
3935 | ) | |
3936 | (define-derived-operand | |
3937 | (name (.sym bit32- offset -19-FB-relative- group)) | |
3938 | (comment "m32c bit,base:19[fb] relative bit") | |
3939 | (attrs (machine 32)) | |
3940 | (mode BI) | |
3941 | (args ((.sym BitBase32- offset -s19- group))) | |
3942 | (syntax (.str "${BitBase32-" offset "-s19-" group "}[fb]")) | |
3943 | (base-ifield (.sym f- base1 -12)) | |
3944 | (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s19- group))) | |
3945 | (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3))) | |
3946 | (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group))) | |
3947 | (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group) newval)) | |
3948 | ) | |
3949 | (define-derived-operand | |
3950 | (name (.sym bit32- offset -11-An-relative- group)) | |
3951 | (comment "m32c bit,base:11[An] relative bit") | |
3952 | (attrs (machine 32)) | |
3953 | (mode BI) | |
3954 | (args ((.sym BitBase32- offset -u11- group) (.sym Bit32An group))) | |
3955 | (syntax (.str "${BitBase32-" offset "-u11-" group "}[$Bit32An" group "]")) | |
3956 | (base-ifield (.sym f- base1 -12)) | |
3957 | (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u11- group) (.sym Bit32An group))) | |
3958 | (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0))) | |
3959 | (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group))) | |
3960 | (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group) newval)) | |
3961 | ) | |
3962 | (define-derived-operand | |
3963 | (name (.sym bit32- offset -19-An-relative- group)) | |
3964 | (comment "m32c bit,base:19[An] relative bit") | |
3965 | (attrs (machine 32)) | |
3966 | (mode BI) | |
3967 | (args ((.sym BitBase32- offset -u19- group) (.sym Bit32An group))) | |
3968 | (syntax (.str "${BitBase32-" offset "-u19-" group "}[$Bit32An" group "]")) | |
3969 | (base-ifield (.sym f- base1 -12)) | |
3970 | (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u19- group) (.sym Bit32An group))) | |
3971 | (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0))) | |
3972 | (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group))) | |
3973 | (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group) newval)) | |
3974 | ) | |
3975 | (define-derived-operand | |
3976 | (name (.sym bit32- offset -27-An-relative- group)) | |
3977 | (comment "m32c bit,base:27[An] relative bit") | |
3978 | (attrs (machine 32)) | |
3979 | (mode BI) | |
3980 | (args ((.sym BitBase32- offset -u27- group) (.sym Bit32An group))) | |
3981 | (syntax (.str "${BitBase32-" offset "-u27-" group "}[$Bit32An" group "]")) | |
3982 | (base-ifield (.sym f- base1 -12)) | |
3983 | (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u27- group) (.sym Bit32An group))) | |
3984 | (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0))) | |
3985 | (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group))) | |
3986 | (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group) newval)) | |
3987 | ) | |
3988 | ) | |
3989 | ) | |
3990 | ||
3991 | (bit32-relative-operand 16 Unprefixed 4 8) | |
3992 | (bit32-relative-operand 24 Prefixed 12 16) | |
3993 | ||
3994 | (define-derived-operand | |
3995 | (name bit16-11-SB-relative-S) | |
3996 | (comment "m16c bit,base:11[sb] relative bit") | |
3997 | (attrs (machine 16)) | |
3998 | (mode BI) | |
3999 | (args (BitBase16-8-u11-S)) | |
4000 | (syntax "${BitBase16-8-u11-S}[sb]") | |
4001 | (base-ifield (.sym f-5-3)) | |
4002 | (encoding (+ BitBase16-8-u11-S)) | |
4003 | ; (ifield-assertion (#t)) | |
4004 | (getter (get-memory-bit 16 (reg h-sb) BitBase16-8-u11-S)) | |
4005 | (setter (set-memory-bit 16 (reg h-sb) BitBase16-8-u11-S newval)) | |
4006 | ) | |
4007 | ||
4008 | (define-derived-operand | |
4009 | (name Rn16-push-S-derived) | |
4010 | (comment "m16c r0[lh] for push,pop short version") | |
4011 | (attrs (machine 16)) | |
4012 | (mode QI) | |
4013 | (args (Rn16-push-S)) | |
4014 | (syntax "${Rn16-push-S}") | |
4015 | (base-ifield (.sym f-4-1)) | |
4016 | (encoding (+ Rn16-push-S)) | |
4017 | ; (ifield-assertion (#t)) | |
4018 | (getter (trunc QI Rn16-push-S)) | |
4019 | (setter (set Rn16-push-S newval)) | |
4020 | ) | |
4021 | ||
4022 | (define-derived-operand | |
4023 | (name An16-push-S-derived) | |
4024 | (comment "m16c r0[lh] for push,pop short version") | |
4025 | (attrs (machine 16)) | |
4026 | (mode HI) | |
4027 | (args (An16-push-S)) | |
4028 | (syntax "${An16-push-S}") | |
4029 | (base-ifield (.sym f-4-1)) | |
4030 | (encoding (+ An16-push-S)) | |
4031 | ; (ifield-assertion (#t)) | |
4032 | (getter (trunc QI An16-push-S)) | |
4033 | (setter (set An16-push-S newval)) | |
4034 | ) | |
4035 | ||
4036 | ;------------------------------------------------------------- | |
4037 | ; Absolute address | |
4038 | ;------------------------------------------------------------- | |
4039 | ||
4040 | (define-pmacro (bit16-absolute offset) | |
4041 | (begin | |
4042 | (define-derived-operand | |
4043 | (name (.sym bit16- offset -16-absolute)) | |
4044 | (comment "m16c absolute address") | |
4045 | (attrs (machine 16)) | |
4046 | (mode BI) | |
4047 | (args ((.sym BitBase16- offset -u16))) | |
4048 | (syntax (.str "${BitBase16-" offset "-u16}")) | |
4049 | (base-ifield f-12-4) | |
4050 | (encoding (+ (f-12-4 #xF) (.sym BitBase16- offset -u16))) | |
4051 | (ifield-assertion (eq f-12-4 #xF)) | |
4052 | (getter (get-memory-bit 16 0 (.sym BitBase16- offset -u16))) | |
4053 | (setter (set-memory-bit 16 0 (.sym BitBase16- offset -u16) newval)) | |
4054 | ) | |
4055 | ) | |
4056 | ) | |
4057 | ||
4058 | (bit16-absolute 16) | |
4059 | ||
4060 | (define-pmacro (bit32-absolute offset group base1 base2) | |
4061 | (begin | |
4062 | (define-derived-operand | |
4063 | (name (.sym bit32- offset -19-absolute- group)) | |
4064 | (comment "m32c absolute address bit") | |
4065 | (attrs (machine 32)) | |
4066 | (mode BI) | |
4067 | (args ((.sym BitBase32- offset -u19- group))) | |
4068 | (syntax (.str "${BitBase32-" offset "-u19-" group "}")) | |
4069 | (base-ifield (.sym f- base1 -12)) | |
4070 | (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -u19- group))) | |
4071 | (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3))) | |
4072 | (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u19- group))) | |
4073 | (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u19- group) newval)) | |
4074 | ) | |
4075 | (define-derived-operand | |
4076 | (name (.sym bit32- offset -27-absolute- group)) | |
4077 | (comment "m32c absolute address bit") | |
4078 | (attrs (machine 32)) | |
4079 | (mode BI) | |
4080 | (args ((.sym BitBase32- offset -u27- group))) | |
4081 | (syntax (.str "${BitBase32-" offset "-u27-" group "}")) | |
4082 | (base-ifield (.sym f- base1 -12)) | |
4083 | (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u27- group))) | |
4084 | (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2))) | |
4085 | (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u27- group))) | |
4086 | (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u27- group) newval)) | |
4087 | ) | |
4088 | ) | |
4089 | ) | |
4090 | ||
4091 | (bit32-absolute 16 Unprefixed 4 8) | |
4092 | (bit32-absolute 24 Prefixed 12 16) | |
4093 | ||
4094 | ;------------------------------------------------------------- | |
4095 | ; Destination operands for short fomat insns | |
4096 | ;------------------------------------------------------------- | |
4097 | ||
4098 | (define-derived-operand | |
4099 | (name dst16-3-S-R0l-direct-QI) | |
4100 | (comment "m16c R0l direct QI") | |
4101 | (attrs (machine 16)) | |
4102 | (mode QI) | |
4103 | (args (R0l)) | |
4104 | (syntax "r0l") | |
4105 | (base-ifield f-5-3) | |
4106 | (encoding (+ (f-5-3 4))) | |
4107 | (ifield-assertion (eq f-5-3 4)) | |
4108 | (getter (trunc QI R0l)) | |
4109 | (setter (set R0l newval)) | |
4110 | ) | |
4111 | (define-derived-operand | |
4112 | (name dst16-3-S-R0h-direct-QI) | |
4113 | (comment "m16c R0h direct QI") | |
4114 | (attrs (machine 16)) | |
4115 | (mode QI) | |
4116 | (args (R0h)) | |
4117 | (syntax "r0h") | |
4118 | (base-ifield f-5-3) | |
4119 | (encoding (+ (f-5-3 3))) | |
4120 | (ifield-assertion (eq f-5-3 3)) | |
4121 | (getter (trunc QI R0h)) | |
4122 | (setter (set R0h newval)) | |
4123 | ) | |
4124 | (define-derived-operand | |
4125 | (name dst16-3-S-8-8-SB-relative-QI) | |
4126 | (comment "m16c SB relative QI") | |
4127 | (attrs (machine 16)) | |
4128 | (mode QI) | |
4129 | (args (Dsp-8-u8)) | |
4130 | (syntax "${Dsp-8-u8}[sb]") | |
4131 | (base-ifield f-5-3) | |
4132 | (encoding (+ (f-5-3 5) Dsp-8-u8)) | |
4133 | (ifield-assertion (eq f-5-3 5)) | |
4134 | (getter (mem16 QI (add Dsp-8-u8 (reg h-sb)))) | |
4135 | (setter (set (mem16 QI (add Dsp-8-u8 (reg h-sb))) newval)) | |
4136 | ) | |
4137 | (define-derived-operand | |
4138 | (name dst16-3-S-8-8-FB-relative-QI) | |
4139 | (comment "m16c FB relative QI") | |
4140 | (attrs (machine 16)) | |
4141 | (mode QI) | |
4142 | (args (Dsp-8-s8)) | |
4143 | (syntax "${Dsp-8-s8}[fb]") | |
4144 | (base-ifield f-5-3) | |
4145 | (encoding (+ (f-5-3 6) Dsp-8-s8)) | |
4146 | (ifield-assertion (eq f-5-3 6)) | |
4147 | (getter (mem16 QI (add Dsp-8-s8 (reg h-fb)))) | |
4148 | (setter (set (mem16 QI (add Dsp-8-s8 (reg h-fb))) newval)) | |
4149 | ) | |
4150 | (define-derived-operand | |
4151 | (name dst16-3-S-8-16-absolute-QI) | |
4152 | (comment "m16c absolute address QI") | |
4153 | (attrs (machine 16)) | |
4154 | (mode QI) | |
4155 | (args (Dsp-8-u16)) | |
4156 | (syntax "${Dsp-8-u16}") | |
4157 | (base-ifield f-5-3) | |
4158 | (encoding (+ (f-5-3 7) Dsp-8-u16)) | |
4159 | (ifield-assertion (eq f-5-3 7)) | |
4160 | (getter (mem16 QI Dsp-8-u16)) | |
4161 | (setter (set (mem16 QI Dsp-8-u16) newval)) | |
4162 | ) | |
4163 | (define-derived-operand | |
4164 | (name dst16-3-S-16-8-SB-relative-QI) | |
4165 | (comment "m16c SB relative QI") | |
4166 | (attrs (machine 16)) | |
4167 | (mode QI) | |
4168 | (args (Dsp-16-u8)) | |
4169 | (syntax "${Dsp-16-u8}[sb]") | |
4170 | (base-ifield f-5-3) | |
4171 | (encoding (+ (f-5-3 5) Dsp-16-u8)) | |
4172 | (ifield-assertion (eq f-5-3 5)) | |
4173 | (getter (mem16 QI (add Dsp-16-u8 (reg h-sb)))) | |
4174 | (setter (set (mem16 QI (add Dsp-16-u8 (reg h-sb))) newval)) | |
4175 | ) | |
4176 | (define-derived-operand | |
4177 | (name dst16-3-S-16-8-FB-relative-QI) | |
4178 | (comment "m16c FB relative QI") | |
4179 | (attrs (machine 16)) | |
4180 | (mode QI) | |
4181 | (args (Dsp-16-s8)) | |
4182 | (syntax "${Dsp-16-s8}[fb]") | |
4183 | (base-ifield f-5-3) | |
4184 | (encoding (+ (f-5-3 6) Dsp-16-s8)) | |
4185 | (ifield-assertion (eq f-5-3 6)) | |
4186 | (getter (mem16 QI (add Dsp-16-s8 (reg h-fb)))) | |
4187 | (setter (set (mem16 QI (add Dsp-16-s8 (reg h-fb))) newval)) | |
4188 | ) | |
4189 | (define-derived-operand | |
4190 | (name dst16-3-S-16-16-absolute-QI) | |
4191 | (comment "m16c absolute address QI") | |
4192 | (attrs (machine 16)) | |
4193 | (mode QI) | |
4194 | (args (Dsp-16-u16)) | |
4195 | (syntax "${Dsp-16-u16}") | |
4196 | (base-ifield f-5-3) | |
4197 | (encoding (+ (f-5-3 7) Dsp-16-u16)) | |
4198 | (ifield-assertion (eq f-5-3 7)) | |
4199 | (getter (mem16 QI Dsp-16-u16)) | |
4200 | (setter (set (mem16 QI Dsp-16-u16) newval)) | |
4201 | ) | |
4202 | (define-derived-operand | |
4203 | (name srcdst16-r0l-r0h-S-derived) | |
4204 | (comment "m16c r0l/r0h operand for short format insns") | |
4205 | (attrs (machine 16)) | |
4206 | (mode SI) | |
4207 | (args (SrcDst16-r0l-r0h-S-normal)) | |
4208 | (syntax "${SrcDst16-r0l-r0h-S-normal}") | |
4209 | (base-ifield f-6-3) | |
4210 | (encoding (+ (f-6-2 0) SrcDst16-r0l-r0h-S-normal)) | |
4211 | (ifield-assertion (eq f-6-2 0)) | |
4212 | (getter (trunc SI SrcDst16-r0l-r0h-S-normal)) | |
4213 | (setter ()) ; no setter | |
4214 | ) | |
4215 | (define-derived-operand | |
4216 | (name dst32-2-S-R0l-direct-QI) | |
4217 | (comment "m32c R0l direct QI") | |
4218 | (attrs (machine 32)) | |
4219 | (mode QI) | |
4220 | (args (R0l)) | |
4221 | (syntax "r0l") | |
4222 | (base-ifield f-2-2) | |
4223 | (encoding (+ (f-2-2 0))) | |
4224 | (ifield-assertion (eq f-2-2 0)) | |
4225 | (getter (trunc QI R0l)) | |
4226 | (setter (set R0l newval)) | |
4227 | ) | |
4228 | (define-derived-operand | |
4229 | (name dst32-2-S-R0-direct-HI) | |
4230 | (comment "m32c R0 direct HI") | |
4231 | (attrs (machine 32)) | |
4232 | (mode HI) | |
4233 | (args (R0)) | |
4234 | (syntax "r0") | |
4235 | (base-ifield f-2-2) | |
4236 | (encoding (+ (f-2-2 0))) | |
4237 | (ifield-assertion (eq f-2-2 0)) | |
4238 | (getter (trunc HI R0)) | |
4239 | (setter (set R0 newval)) | |
4240 | ) | |
4241 | (define-derived-operand | |
4242 | (name dst32-1-S-A0-direct-HI) | |
4243 | (comment "m32c A0 direct HI") | |
4244 | (attrs (machine 32)) | |
4245 | (mode HI) | |
4246 | (args (A0)) | |
4247 | (syntax "a0") | |
4248 | (base-ifield f-7-1) | |
4249 | (encoding (+ (f-7-1 0))) | |
4250 | (ifield-assertion (eq f-7-1 0)) | |
4251 | (getter (trunc HI A0)) | |
4252 | (setter (set A0 newval)) | |
4253 | ) | |
4254 | (define-derived-operand | |
4255 | (name dst32-1-S-A1-direct-HI) | |
4256 | (comment "m32c A1 direct HI") | |
4257 | (attrs (machine 32)) | |
4258 | (mode HI) | |
4259 | (args (A1)) | |
4260 | (syntax "a1") | |
4261 | (base-ifield f-7-1) | |
4262 | (encoding (+ (f-7-1 1))) | |
4263 | (ifield-assertion (eq f-7-1 1)) | |
4264 | (getter (trunc HI A1)) | |
4265 | (setter (set A1 newval)) | |
4266 | ) | |
4267 | (define-pmacro (dst32-2-S-operands xmode) | |
4268 | (begin | |
4269 | (define-derived-operand | |
4270 | (name (.sym dst32-2-S-8-SB-relative- xmode)) | |
4271 | (comment "m32c SB relative for short binary insns") | |
4272 | (attrs (machine 32)) | |
4273 | (mode xmode) | |
4274 | (args (Dsp-8-u8)) | |
4275 | (syntax "${Dsp-8-u8}[sb]") | |
4276 | (base-ifield f-2-2) | |
4277 | (encoding (+ (f-2-2 2) Dsp-8-u8)) | |
4278 | (ifield-assertion (eq f-2-2 2)) | |
4279 | (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8)) | |
4280 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8)) | |
4281 | ; (getter (mem32 xmode (add Dsp-8-u8 (reg h-sb)))) | |
4282 | ; (setter (set (mem32 xmode (add Dsp-8-u8 (reg h-sb))) newval)) | |
4283 | ) | |
4284 | (define-derived-operand | |
4285 | (name (.sym dst32-2-S-8-FB-relative- xmode)) | |
4286 | (comment "m32c FB relative for short binary insns") | |
4287 | (attrs (machine 32)) | |
4288 | (mode xmode) | |
4289 | (args (Dsp-8-s8)) | |
4290 | (syntax "${Dsp-8-s8}[fb]") | |
4291 | (base-ifield f-2-2) | |
4292 | (encoding (+ (f-2-2 3) Dsp-8-s8)) | |
4293 | (ifield-assertion (eq f-2-2 3)) | |
4294 | (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8)) | |
4295 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8)) | |
4296 | ; (getter (mem32 xmode (add Dsp-8-s8 (reg h-fb)))) | |
4297 | ; (setter (set (mem32 xmode (add Dsp-8-s8 (reg h-fb))) newval)) | |
4298 | ) | |
4299 | (define-derived-operand | |
4300 | (name (.sym dst32-2-S-16-absolute- xmode)) | |
4301 | (comment "m32c absolute address for short binary insns") | |
4302 | (attrs (machine 32)) | |
4303 | (mode xmode) | |
4304 | (args (Dsp-8-u16)) | |
4305 | (syntax "${Dsp-8-u16}") | |
4306 | (base-ifield f-2-2) | |
4307 | (encoding (+ (f-2-2 1) Dsp-8-u16)) | |
4308 | (ifield-assertion (eq f-2-2 1)) | |
4309 | (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16)) | |
4310 | (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16)) | |
4311 | ; (getter (mem32 xmode Dsp-8-u16)) | |
4312 | ; (setter (set (mem32 xmode Dsp-8-u16) newval)) | |
4313 | ) | |
4314 | ; (define-derived-operand | |
4315 | ; (name (.sym dst32-2-S-8-SB-relative-indirect- xmode)) | |
4316 | ; (comment "m32c SB relative for short binary insns") | |
4317 | ; (attrs (machine 32)) | |
4318 | ; (mode xmode) | |
4319 | ; (args (Dsp-16-u8)) | |
4320 | ; (syntax "[${Dsp-16-u8}[sb]]") | |
4321 | ; (base-ifield f-10-2) | |
4322 | ; (encoding (+ (f-10-2 2) Dsp-16-u8)) | |
4323 | ; (ifield-assertion (eq f-10-2 2)) | |
4324 | ; (getter (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb))))) | |
4325 | ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb)))) newval)) | |
4326 | ; ) | |
4327 | ; (define-derived-operand | |
4328 | ; (name (.sym dst32-2-S-8-FB-relative-indirect- xmode)) | |
4329 | ; (comment "m32c FB relative for short binary insns") | |
4330 | ; (attrs (machine 32)) | |
4331 | ; (mode xmode) | |
4332 | ; (args (Dsp-16-s8)) | |
4333 | ; (syntax "[${Dsp-16-s8}[fb]]") | |
4334 | ; (base-ifield f-10-2) | |
4335 | ; (encoding (+ (f-10-2 3) Dsp-16-s8)) | |
4336 | ; (ifield-assertion (eq f-10-2 3)) | |
4337 | ; (getter (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb))))) | |
4338 | ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb)))) newval)) | |
4339 | ; ) | |
4340 | ; (define-derived-operand | |
4341 | ; (name (.sym dst32-2-S-16-absolute-indirect- xmode)) | |
4342 | ; (comment "m32c absolute address for short binary insns") | |
4343 | ; (attrs (machine 32)) | |
4344 | ; (mode xmode) | |
4345 | ; (args (Dsp-16-u16)) | |
4346 | ; (syntax "[${Dsp-16-u16}]") | |
4347 | ; (base-ifield f-10-2) | |
4348 | ; (encoding (+ (f-10-2 1) Dsp-16-u16)) | |
4349 | ; (ifield-assertion (eq f-10-2 1)) | |
4350 | ; (getter (mem32 xmode (indirect-addr Dsp-16-u16))) | |
4351 | ; (setter (set (mem32 xmode (indirect-addr Dsp-16-u16)) newval)) | |
4352 | ; ) | |
4353 | ) | |
4354 | ) | |
4355 | ||
4356 | (dst32-2-S-operands QI) | |
4357 | (dst32-2-S-operands HI) | |
4358 | (dst32-2-S-operands SI) | |
4359 | ||
4360 | ;============================================================= | |
4361 | ; Anyof operands | |
4362 | ;------------------------------------------------------------- | |
4363 | ; Source operands with no additional fields | |
4364 | ;------------------------------------------------------------- | |
4365 | ||
4366 | (define-pmacro (src16-basic-operand xmode) | |
4367 | (begin | |
4368 | (define-anyof-operand | |
4369 | (name (.sym src16-basic- xmode)) | |
4370 | (comment (.str "m16c source operand of size " xmode " with no additional fields")) | |
4371 | (attrs (machine 16)) | |
4372 | (mode xmode) | |
4373 | (choices | |
4374 | (.sym src16-Rn-direct- xmode) | |
4375 | (.sym src16-An-direct- xmode) | |
4376 | (.sym src16-An-indirect- xmode) | |
4377 | ) | |
4378 | ) | |
4379 | ) | |
4380 | ) | |
4381 | (src16-basic-operand QI) | |
4382 | (src16-basic-operand HI) | |
4383 | ||
4384 | (define-pmacro (src32-basic-operand xmode) | |
4385 | (begin | |
4386 | (define-anyof-operand | |
4387 | (name (.sym src32-basic-Unprefixed- xmode)) | |
4388 | (comment (.str "m32c destination operand of size " xmode " with no additional fields")) | |
4389 | (attrs (machine 32)) | |
4390 | (mode xmode) | |
4391 | (choices | |
4392 | (.sym src32-Rn-direct-Unprefixed- xmode) | |
4393 | (.sym src32-An-direct-Unprefixed- xmode) | |
4394 | (.sym src32-An-indirect-Unprefixed- xmode) | |
4395 | ) | |
4396 | ) | |
4397 | (define-anyof-operand | |
4398 | (name (.sym src32-basic-Prefixed- xmode)) | |
4399 | (comment (.str "m32c destination operand of size " xmode " with no additional fields")) | |
4400 | (attrs (machine 32)) | |
4401 | (mode xmode) | |
4402 | (choices | |
4403 | (.sym src32-Rn-direct-Prefixed- xmode) | |
4404 | (.sym src32-An-direct-Prefixed- xmode) | |
4405 | (.sym src32-An-indirect-Prefixed- xmode) | |
4406 | ) | |
4407 | ) | |
4408 | ; (define-anyof-operand | |
4409 | ; (name (.sym src32-basic-indirect- xmode)) | |
4410 | ; (comment (.str "m32c destination operand of size " xmode " indirect with no additional fields")) | |
4411 | ; (attrs (machine 32)) | |
4412 | ; (mode xmode) | |
4413 | ; (choices | |
4414 | ; (.sym src32-An-indirect-indirect- xmode) | |
4415 | ; ) | |
4416 | ; ) | |
4417 | ) | |
4418 | ) | |
4419 | ||
4420 | (src32-basic-operand QI) | |
4421 | (src32-basic-operand HI) | |
4422 | (src32-basic-operand SI) | |
4423 | ||
4424 | (define-anyof-operand | |
4425 | (name src32-basic-ExtPrefixed-QI) | |
4426 | (comment "m32c source operand of size QI with no additional fields") | |
4427 | (attrs (machine 32)) | |
4428 | (mode QI) | |
4429 | (choices | |
4430 | src32-Rn-direct-Prefixed-QI | |
4431 | src32-An-indirect-Prefixed-QI | |
4432 | ) | |
4433 | ) | |
4434 | ||
4435 | ;------------------------------------------------------------- | |
4436 | ; Source operands with additional fields at offset 16 bits | |
4437 | ;------------------------------------------------------------- | |
4438 | ||
4439 | (define-pmacro (src16-16-operand xmode) | |
4440 | (begin | |
4441 | (define-anyof-operand | |
4442 | (name (.sym src16-16-8- xmode)) | |
4443 | (comment (.str "m16c source operand of size " xmode " with additional 8 bit fields at offset 16")) | |
4444 | (attrs (machine 16)) | |
4445 | (mode xmode) | |
4446 | (choices | |
4447 | (.sym src16-16-8-An-relative- xmode) | |
4448 | (.sym src16-16-8-SB-relative- xmode) | |
4449 | (.sym src16-16-8-FB-relative- xmode) | |
4450 | ) | |
4451 | ) | |
4452 | (define-anyof-operand | |
4453 | (name (.sym src16-16-16- xmode)) | |
4454 | (comment (.str "m16c source operand of size " xmode " with additional 16 bit fields at offset 16")) | |
4455 | (attrs (machine 16)) | |
4456 | (mode xmode) | |
4457 | (choices | |
4458 | (.sym src16-16-16-An-relative- xmode) | |
4459 | (.sym src16-16-16-SB-relative- xmode) | |
4460 | (.sym src16-16-16-absolute- xmode) | |
4461 | ) | |
4462 | ) | |
4463 | ) | |
4464 | ) | |
4465 | (src16-16-operand QI) | |
4466 | (src16-16-operand HI) | |
4467 | ||
4468 | (define-pmacro (src32-16-operand xmode) | |
4469 | (begin | |
4470 | (define-anyof-operand | |
4471 | (name (.sym src32-16-8-Unprefixed- xmode)) | |
4472 | (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 16")) | |
4473 | (attrs (machine 32)) | |
4474 | (mode xmode) | |
4475 | (choices | |
4476 | (.sym src32-16-8-An-relative-Unprefixed- xmode) | |
4477 | (.sym src32-16-8-SB-relative-Unprefixed- xmode) | |
4478 | (.sym src32-16-8-FB-relative-Unprefixed- xmode) | |
4479 | ) | |
4480 | ) | |
4481 | (define-anyof-operand | |
4482 | (name (.sym src32-16-16-Unprefixed- xmode)) | |
4483 | (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16")) | |
4484 | (attrs (machine 32)) | |
4485 | (mode xmode) | |
4486 | (choices | |
4487 | (.sym src32-16-16-An-relative-Unprefixed- xmode) | |
4488 | (.sym src32-16-16-SB-relative-Unprefixed- xmode) | |
4489 | (.sym src32-16-16-FB-relative-Unprefixed- xmode) | |
4490 | (.sym src32-16-16-absolute-Unprefixed- xmode) | |
4491 | ) | |
4492 | ) | |
4493 | (define-anyof-operand | |
4494 | (name (.sym src32-16-24-Unprefixed- xmode)) | |
4495 | (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16")) | |
4496 | (attrs (machine 32)) | |
4497 | (mode xmode) | |
4498 | (choices | |
4499 | (.sym src32-16-24-An-relative-Unprefixed- xmode) | |
4500 | (.sym src32-16-24-absolute-Unprefixed- xmode) | |
4501 | ) | |
4502 | ) | |
4503 | ) | |
4504 | ) | |
4505 | ||
4506 | (src32-16-operand QI) | |
4507 | (src32-16-operand HI) | |
4508 | (src32-16-operand SI) | |
4509 | ||
4510 | ;------------------------------------------------------------- | |
4511 | ; Source operands with additional fields at offset 24 bits | |
4512 | ;------------------------------------------------------------- | |
4513 | ||
4514 | (define-pmacro (src-24-operand group xmode) | |
4515 | (begin | |
4516 | (define-anyof-operand | |
4517 | (name (.sym src32-24-8- group - xmode)) | |
4518 | (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 24")) | |
4519 | (attrs (machine 32)) | |
4520 | (mode xmode) | |
4521 | (choices | |
4522 | (.sym src32-24-8-An-relative- group - xmode) | |
4523 | (.sym src32-24-8-SB-relative- group - xmode) | |
4524 | (.sym src32-24-8-FB-relative- group - xmode) | |
4525 | ) | |
4526 | ) | |
4527 | (define-anyof-operand | |
4528 | (name (.sym src32-24-16- group - xmode)) | |
4529 | (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16")) | |
4530 | (attrs (machine 32)) | |
4531 | (mode xmode) | |
4532 | (choices | |
4533 | (.sym src32-24-16-An-relative- group - xmode) | |
4534 | (.sym src32-24-16-SB-relative- group - xmode) | |
4535 | (.sym src32-24-16-FB-relative- group - xmode) | |
4536 | (.sym src32-24-16-absolute- group - xmode) | |
4537 | ) | |
4538 | ) | |
4539 | (define-anyof-operand | |
4540 | (name (.sym src32-24-24- group - xmode)) | |
4541 | (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16")) | |
4542 | (attrs (machine 32)) | |
4543 | (mode xmode) | |
4544 | (choices | |
4545 | (.sym src32-24-24-An-relative- group - xmode) | |
4546 | (.sym src32-24-24-absolute- group - xmode) | |
4547 | ) | |
4548 | ) | |
4549 | ) | |
4550 | ) | |
4551 | ||
4552 | (src-24-operand Prefixed QI) | |
4553 | (src-24-operand Prefixed HI) | |
4554 | (src-24-operand Prefixed SI) | |
4555 | ||
4556 | (define-pmacro (src-24-indirect-operand xmode) | |
4557 | (begin | |
4558 | ; (define-anyof-operand | |
4559 | ; (name (.sym src32-24-8-indirect- xmode)) | |
4560 | ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
4561 | ; (attrs (machine 32)) | |
4562 | ; (mode xmode) | |
4563 | ; (choices | |
4564 | ; (.sym src32-24-8-An-relative-indirect- xmode) | |
4565 | ; (.sym src32-24-8-SB-relative-indirect- xmode) | |
4566 | ; (.sym src32-24-8-FB-relative-indirect- xmode) | |
4567 | ; ) | |
4568 | ; ) | |
4569 | ; (define-anyof-operand | |
4570 | ; (name (.sym src32-24-16-indirect- xmode)) | |
4571 | ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
4572 | ; (attrs (machine 32)) | |
4573 | ; (mode xmode) | |
4574 | ; (choices | |
4575 | ; (.sym src32-24-16-An-relative-indirect- xmode) | |
4576 | ; (.sym src32-24-16-SB-relative-indirect- xmode) | |
4577 | ; (.sym src32-24-16-FB-relative-indirect- xmode) | |
4578 | ; ) | |
4579 | ; ) | |
4580 | ; (define-anyof-operand | |
4581 | ; (name (.sym src32-24-24-indirect- xmode)) | |
4582 | ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
4583 | ; (attrs (machine 32)) | |
4584 | ; (mode xmode) | |
4585 | ; (choices | |
4586 | ; (.sym src32-24-24-An-relative-indirect- xmode) | |
4587 | ; ) | |
4588 | ; ) | |
4589 | ; (define-anyof-operand | |
4590 | ; (name (.sym src32-24-16-absolute-indirect- xmode)) | |
4591 | ; (comment (.str "m32c source operand of size " xmode " 16 bit absolute indirect")) | |
4592 | ; (attrs (machine 32)) | |
4593 | ; (mode xmode) | |
4594 | ; (choices | |
4595 | ; (.sym src32-24-16-absolute-indirect-derived- xmode) | |
4596 | ; ) | |
4597 | ; ) | |
4598 | ; (define-anyof-operand | |
4599 | ; (name (.sym src32-24-24-absolute-indirect- xmode)) | |
4600 | ; (comment (.str "m32c source operand of size " xmode " 24 bit absolute indirect")) | |
4601 | ; (attrs (machine 32)) | |
4602 | ; (mode xmode) | |
4603 | ; (choices | |
4604 | ; (.sym src32-24-24-absolute-indirect-derived- xmode) | |
4605 | ; ) | |
4606 | ; ) | |
4607 | ) | |
4608 | ) | |
4609 | ||
4610 | ; (src-24-indirect-operand QI) | |
4611 | ; (src-24-indirect-operand HI) | |
4612 | ; (src-24-indirect-operand SI) | |
4613 | ||
4614 | ;------------------------------------------------------------- | |
4615 | ; Destination operands with no additional fields | |
4616 | ;------------------------------------------------------------- | |
4617 | ||
4618 | (define-pmacro (dst16-basic-operand xmode) | |
4619 | (begin | |
4620 | (define-anyof-operand | |
4621 | (name (.sym dst16-basic- xmode)) | |
4622 | (comment (.str "m16c destination operand of size " xmode " with no additional fields")) | |
4623 | (attrs (machine 16)) | |
4624 | (mode xmode) | |
4625 | (choices | |
4626 | (.sym dst16-Rn-direct- xmode) | |
4627 | (.sym dst16-An-direct- xmode) | |
4628 | (.sym dst16-An-indirect- xmode) | |
4629 | ) | |
4630 | ) | |
4631 | ) | |
4632 | ) | |
4633 | ||
4634 | (dst16-basic-operand QI) | |
4635 | (dst16-basic-operand HI) | |
4636 | (dst16-basic-operand SI) | |
4637 | ||
4638 | (define-pmacro (dst32-basic-operand xmode) | |
4639 | (begin | |
4640 | (define-anyof-operand | |
4641 | (name (.sym dst32-basic-Unprefixed- xmode)) | |
4642 | (comment (.str "m32c destination operand of size " xmode " with no additional fields")) | |
4643 | (attrs (machine 32)) | |
4644 | (mode xmode) | |
4645 | (choices | |
4646 | (.sym dst32-Rn-direct-Unprefixed- xmode) | |
4647 | (.sym dst32-An-direct-Unprefixed- xmode) | |
4648 | (.sym dst32-An-indirect-Unprefixed- xmode) | |
4649 | ) | |
4650 | ) | |
4651 | (define-anyof-operand | |
4652 | (name (.sym dst32-basic-Prefixed- xmode)) | |
4653 | (comment (.str "m32c destination operand of size " xmode " with no additional fields")) | |
4654 | (attrs (machine 32)) | |
4655 | (mode xmode) | |
4656 | (choices | |
4657 | (.sym dst32-Rn-direct-Prefixed- xmode) | |
4658 | (.sym dst32-An-direct-Prefixed- xmode) | |
4659 | (.sym dst32-An-indirect-Prefixed- xmode) | |
4660 | ) | |
4661 | ) | |
4662 | ) | |
4663 | ) | |
4664 | ||
4665 | (dst32-basic-operand QI) | |
4666 | (dst32-basic-operand HI) | |
4667 | (dst32-basic-operand SI) | |
4668 | ||
4669 | ;------------------------------------------------------------- | |
4670 | ; Destination operands with possible additional fields at offset 16 bits | |
4671 | ;------------------------------------------------------------- | |
4672 | ||
4673 | (define-pmacro (dst16-16-operand xmode) | |
4674 | (begin | |
4675 | (define-anyof-operand | |
4676 | (name (.sym dst16-16- xmode)) | |
4677 | (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16")) | |
4678 | (attrs (machine 16)) | |
4679 | (mode xmode) | |
4680 | (choices | |
4681 | (.sym dst16-Rn-direct- xmode) | |
4682 | (.sym dst16-An-direct- xmode) | |
4683 | (.sym dst16-An-indirect- xmode) | |
4684 | (.sym dst16-16-8-An-relative- xmode) | |
4685 | (.sym dst16-16-16-An-relative- xmode) | |
4686 | (.sym dst16-16-8-SB-relative- xmode) | |
4687 | (.sym dst16-16-16-SB-relative- xmode) | |
4688 | (.sym dst16-16-8-FB-relative- xmode) | |
4689 | (.sym dst16-16-16-absolute- xmode) | |
4690 | ) | |
4691 | ) | |
4692 | (define-anyof-operand | |
4693 | (name (.sym dst16-16-8- xmode)) | |
4694 | (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16")) | |
4695 | (attrs (machine 16)) | |
4696 | (mode xmode) | |
4697 | (choices | |
4698 | (.sym dst16-16-8-An-relative- xmode) | |
4699 | (.sym dst16-16-8-SB-relative- xmode) | |
4700 | (.sym dst16-16-8-FB-relative- xmode) | |
4701 | ) | |
4702 | ) | |
4703 | (define-anyof-operand | |
4704 | (name (.sym dst16-16-16- xmode)) | |
4705 | (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16")) | |
4706 | (attrs (machine 16)) | |
4707 | (mode xmode) | |
4708 | (choices | |
4709 | (.sym dst16-16-16-An-relative- xmode) | |
4710 | (.sym dst16-16-16-SB-relative- xmode) | |
4711 | (.sym dst16-16-16-absolute- xmode) | |
4712 | ) | |
4713 | ) | |
4714 | ) | |
4715 | ) | |
4716 | ||
4717 | (dst16-16-operand QI) | |
4718 | (dst16-16-operand HI) | |
4719 | (dst16-16-operand SI) | |
4720 | ||
4721 | (define-anyof-operand | |
4722 | (name dst16-16-Ext-QI) | |
4723 | (comment "m16c destination operand of size QI for 'ext' insns with additional fields at offset 16") | |
4724 | (attrs (machine 16)) | |
4725 | (mode QI) | |
4726 | (choices | |
4727 | dst16-Rn-direct-Ext-QI | |
4728 | dst16-An-indirect-Ext-QI | |
4729 | dst16-16-8-An-relative-Ext-QI | |
4730 | dst16-16-16-An-relative-Ext-QI | |
4731 | dst16-16-8-SB-relative-Ext-QI | |
4732 | dst16-16-16-SB-relative-Ext-QI | |
4733 | dst16-16-8-FB-relative-Ext-QI | |
4734 | dst16-16-16-absolute-Ext-QI | |
4735 | ) | |
4736 | ) | |
4737 | ||
4738 | (define-derived-operand | |
4739 | (name dst16-An-indirect-Mova-HI) | |
4740 | (comment "m16c addressof An indirect destination HI") | |
4741 | (attrs (ISA m16c)) | |
4742 | (mode HI) | |
4743 | (args (Dst16An)) | |
4744 | (syntax "[$Dst16An]") | |
4745 | (base-ifield f-12-4) | |
4746 | (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An)) | |
4747 | (ifield-assertion | |
4748 | (andif (eq f-12-2 1) (eq f-14-1 1))) | |
4749 | (getter Dst16An) | |
4750 | (setter (nop)) | |
4751 | ) | |
4752 | ||
4753 | (define-derived-operand | |
4754 | (name dst16-16-8-An-relative-Mova-HI) | |
4755 | (comment | |
4756 | "m16c addressof dsp:8[An] relative destination HI") | |
4757 | (attrs (ISA m16c)) | |
4758 | (mode HI) | |
4759 | (args (Dst16An Dsp-16-u8)) | |
4760 | (syntax "${Dsp-16-u8}[$Dst16An]") | |
4761 | (base-ifield f-12-4) | |
4762 | (encoding | |
4763 | (+ (f-12-2 2) (f-14-1 0) Dsp-16-u8 Dst16An)) | |
4764 | (ifield-assertion | |
4765 | (andif (eq f-12-2 2) (eq f-14-1 0))) | |
4766 | (getter (add Dsp-16-u8 Dst16An)) | |
4767 | (setter (nop)) | |
4768 | ) | |
4769 | (define-derived-operand | |
4770 | (name dst16-16-16-An-relative-Mova-HI) | |
4771 | (comment | |
4772 | "m16c addressof dsp:16[An] relative destination HI") | |
4773 | (attrs (ISA m16c)) | |
4774 | (mode HI) | |
4775 | (args (Dst16An Dsp-16-u16)) | |
4776 | (syntax "${Dsp-16-u16}[$Dst16An]") | |
4777 | (base-ifield f-12-4) | |
4778 | (encoding | |
4779 | (+ (f-12-2 3) (f-14-1 0) Dsp-16-u16 Dst16An)) | |
4780 | (ifield-assertion | |
4781 | (andif (eq f-12-2 3) (eq f-14-1 0))) | |
4782 | (getter (add Dsp-16-u16 Dst16An)) | |
4783 | (setter (nop)) | |
4784 | ) | |
4785 | (define-derived-operand | |
4786 | (name dst16-16-8-SB-relative-Mova-HI) | |
4787 | (comment | |
4788 | "m16c addressof dsp:8[sb] relative destination HI") | |
4789 | (attrs (ISA m16c)) | |
4790 | (mode HI) | |
4791 | (args (Dsp-16-u8)) | |
4792 | (syntax "${Dsp-16-u8}[sb]") | |
4793 | (base-ifield f-12-4) | |
4794 | (encoding (+ (f-12-4 10) Dsp-16-u8)) | |
4795 | (ifield-assertion (eq f-12-4 10)) | |
4796 | (getter (add Dsp-16-u8 (reg h-sb))) | |
4797 | (setter (nop)) | |
4798 | ) | |
4799 | (define-derived-operand | |
4800 | (name dst16-16-16-SB-relative-Mova-HI) | |
4801 | (comment | |
4802 | "m16c addressof dsp:16[sb] relative destination HI") | |
4803 | (attrs (ISA m16c)) | |
4804 | (mode HI) | |
4805 | (args (Dsp-16-u16)) | |
4806 | (syntax "${Dsp-16-u16}[sb]") | |
4807 | (base-ifield f-12-4) | |
4808 | (encoding (+ (f-12-4 14) Dsp-16-u16)) | |
4809 | (ifield-assertion (eq f-12-4 14)) | |
4810 | (getter (add Dsp-16-u16 (reg h-sb))) | |
4811 | (setter (nop)) | |
4812 | ) | |
4813 | (define-derived-operand | |
4814 | (name dst16-16-8-FB-relative-Mova-HI) | |
4815 | (comment | |
4816 | "m16c addressof dsp:8[fb] relative destination HI") | |
4817 | (attrs (ISA m16c)) | |
4818 | (mode HI) | |
4819 | (args (Dsp-16-s8)) | |
4820 | (syntax "${Dsp-16-s8}[fb]") | |
4821 | (base-ifield f-12-4) | |
4822 | (encoding (+ (f-12-4 11) Dsp-16-s8)) | |
4823 | (ifield-assertion (eq f-12-4 11)) | |
4824 | (getter (add Dsp-16-s8 (reg h-fb))) | |
4825 | (setter (nop)) | |
4826 | ) | |
4827 | (define-derived-operand | |
4828 | (name dst16-16-16-absolute-Mova-HI) | |
4829 | (comment "m16c addressof absolute address HI") | |
4830 | (attrs (ISA m16c)) | |
4831 | (mode HI) | |
4832 | (args (Dsp-16-u16)) | |
4833 | (syntax "${Dsp-16-u16}") | |
4834 | (base-ifield f-12-4) | |
4835 | (encoding (+ (f-12-4 15) Dsp-16-u16)) | |
4836 | (ifield-assertion (eq f-12-4 15)) | |
4837 | (getter Dsp-16-u16) | |
4838 | (setter (nop)) | |
4839 | ) | |
4840 | ||
4841 | (define-anyof-operand | |
4842 | (name dst16-16-Mova-HI) | |
4843 | (comment "m16c addressof destination operand of size HI with additional fields at offset 16") | |
4844 | (attrs (machine 16)) | |
4845 | (mode HI) | |
4846 | (choices | |
4847 | dst16-An-indirect-Mova-HI | |
4848 | dst16-16-8-An-relative-Mova-HI | |
4849 | dst16-16-16-An-relative-Mova-HI | |
4850 | dst16-16-8-SB-relative-Mova-HI | |
4851 | dst16-16-16-SB-relative-Mova-HI | |
4852 | dst16-16-8-FB-relative-Mova-HI | |
4853 | dst16-16-16-absolute-Mova-HI | |
4854 | ) | |
4855 | ) | |
4856 | ||
4857 | (define-derived-operand | |
4858 | (name dst32-An-indirect-Unprefixed-Mova-SI) | |
4859 | (comment "m32c addressof An indirect destination SI") | |
4860 | (attrs (ISA m32c)) | |
4861 | (mode SI) | |
4862 | (args (Dst32AnUnprefixed)) | |
4863 | (syntax "[$Dst32AnUnprefixed]") | |
4864 | (base-ifield f-4-6) | |
4865 | (encoding | |
4866 | (+ (f-4-3 0) (f-8-1 0) Dst32AnUnprefixed)) | |
4867 | (ifield-assertion | |
4868 | (andif (eq f-4-3 0) (eq f-8-1 0))) | |
4869 | (getter Dst32AnUnprefixed) | |
4870 | (setter (nop)) | |
4871 | ) | |
4872 | ||
4873 | (define-derived-operand | |
4874 | (name dst32-16-8-An-relative-Unprefixed-Mova-SI) | |
4875 | (comment "m32c addressof dsp:8[An] relative destination SI") | |
4876 | (attrs (ISA m32c)) | |
4877 | (mode SI) | |
4878 | (args (Dst32AnUnprefixed Dsp-16-u8)) | |
4879 | (syntax "${Dsp-16-u8}[$Dst32AnUnprefixed]") | |
4880 | (base-ifield f-4-6) | |
4881 | (encoding | |
4882 | (+ (f-4-3 1) | |
4883 | (f-8-1 0) | |
4884 | Dsp-16-u8 | |
4885 | Dst32AnUnprefixed)) | |
4886 | (ifield-assertion | |
4887 | (andif (eq f-4-3 1) (eq f-8-1 0))) | |
4888 | (getter (add Dsp-16-u8 Dst32AnUnprefixed)) | |
4889 | (setter (nop)) | |
4890 | ) | |
4891 | ||
4892 | (define-derived-operand | |
4893 | (name dst32-16-16-An-relative-Unprefixed-Mova-SI) | |
4894 | (comment | |
4895 | "m32c addressof dsp:16[An] relative destination SI") | |
4896 | (attrs (ISA m32c)) | |
4897 | (mode SI) | |
4898 | (args (Dst32AnUnprefixed Dsp-16-u16)) | |
4899 | (syntax "${Dsp-16-u16}[$Dst32AnUnprefixed]") | |
4900 | (base-ifield f-4-6) | |
4901 | (encoding | |
4902 | (+ (f-4-3 2) | |
4903 | (f-8-1 0) | |
4904 | Dsp-16-u16 | |
4905 | Dst32AnUnprefixed)) | |
4906 | (ifield-assertion | |
4907 | (andif (eq f-4-3 2) (eq f-8-1 0))) | |
4908 | (getter (add Dsp-16-u16 Dst32AnUnprefixed)) | |
4909 | (setter (nop)) | |
4910 | ) | |
4911 | ||
4912 | (define-derived-operand | |
4913 | (name dst32-16-24-An-relative-Unprefixed-Mova-SI) | |
4914 | (comment "addressof m32c dsp:16[An] relative destination SI") | |
4915 | (attrs (ISA m32c)) | |
4916 | (mode SI) | |
4917 | (args (Dst32AnUnprefixed Dsp-16-u24)) | |
4918 | (syntax "${Dsp-16-u24}[$Dst32AnUnprefixed]") | |
4919 | (base-ifield f-4-6) | |
4920 | (encoding | |
4921 | (+ (f-4-3 3) | |
4922 | (f-8-1 0) | |
4923 | Dsp-16-u24 | |
4924 | Dst32AnUnprefixed)) | |
4925 | (ifield-assertion | |
4926 | (andif (eq f-4-3 3) (eq f-8-1 0))) | |
4927 | (getter (add Dsp-16-u24 Dst32AnUnprefixed)) | |
4928 | (setter (nop)) | |
4929 | ) | |
4930 | ||
4931 | (define-derived-operand | |
4932 | (name dst32-16-8-SB-relative-Unprefixed-Mova-SI) | |
4933 | (comment "m32c addressof dsp:8[sb] relative destination SI") | |
4934 | (attrs (ISA m32c)) | |
4935 | (mode SI) | |
4936 | (args (Dsp-16-u8)) | |
4937 | (syntax "${Dsp-16-u8}[sb]") | |
4938 | (base-ifield f-4-6) | |
4939 | (encoding (+ (f-4-3 1) (f-8-2 2) Dsp-16-u8)) | |
4940 | (ifield-assertion | |
4941 | (andif (eq f-4-3 1) (eq f-8-2 2))) | |
4942 | (getter (add Dsp-16-u8 (reg h-sb))) | |
4943 | (setter (nop)) | |
4944 | ) | |
4945 | ||
4946 | (define-derived-operand | |
4947 | (name dst32-16-16-SB-relative-Unprefixed-Mova-SI) | |
4948 | (comment "m32c addressof dsp:16[sb] relative destination SI") | |
4949 | (attrs (ISA m32c)) | |
4950 | (mode SI) | |
4951 | (args (Dsp-16-u16)) | |
4952 | (syntax "${Dsp-16-u16}[sb]") | |
4953 | (base-ifield f-4-6) | |
4954 | (encoding (+ (f-4-3 2) (f-8-2 2) Dsp-16-u16)) | |
4955 | (ifield-assertion | |
4956 | (andif (eq f-4-3 2) (eq f-8-2 2))) | |
4957 | (getter (add Dsp-16-u16 (reg h-sb))) | |
4958 | (setter (nop)) | |
4959 | ) | |
4960 | ||
4961 | (define-derived-operand | |
4962 | (name dst32-16-8-FB-relative-Unprefixed-Mova-SI) | |
4963 | (comment "m32c addressof dsp:8[fb] relative destination SI") | |
4964 | (attrs (ISA m32c)) | |
4965 | (mode SI) | |
4966 | (args (Dsp-16-s8)) | |
4967 | (syntax "${Dsp-16-s8}[fb]") | |
4968 | (base-ifield f-4-6) | |
4969 | (encoding (+ (f-4-3 1) (f-8-2 3) Dsp-16-s8)) | |
4970 | (ifield-assertion | |
4971 | (andif (eq f-4-3 1) (eq f-8-2 3))) | |
4972 | (getter (add Dsp-16-s8 (reg h-fb))) | |
4973 | (setter (nop)) | |
4974 | ) | |
4975 | ||
4976 | (define-derived-operand | |
4977 | (name dst32-16-16-FB-relative-Unprefixed-Mova-SI) | |
4978 | (comment "m32c addressof dsp:16[fb] relative destination SI") | |
4979 | (attrs (ISA m32c)) | |
4980 | (mode SI) | |
4981 | (args (Dsp-16-s16)) | |
4982 | (syntax "${Dsp-16-s16}[fb]") | |
4983 | (base-ifield f-4-6) | |
4984 | (encoding (+ (f-4-3 2) (f-8-2 3) Dsp-16-s16)) | |
4985 | (ifield-assertion | |
4986 | (andif (eq f-4-3 2) (eq f-8-2 3))) | |
4987 | (getter (add Dsp-16-s16 (reg h-fb))) | |
4988 | (setter (nop)) | |
4989 | ) | |
4990 | ||
4991 | (define-derived-operand | |
4992 | (name dst32-16-16-absolute-Unprefixed-Mova-SI) | |
4993 | (comment "m32c addressof absolute address SI") (attrs (ISA m32c)) | |
4994 | (mode SI) | |
4995 | (args (Dsp-16-u16)) | |
4996 | (syntax "${Dsp-16-u16}") | |
4997 | (base-ifield f-4-6) | |
4998 | (encoding (+ (f-4-3 3) (f-8-2 3) Dsp-16-u16)) | |
4999 | (ifield-assertion | |
5000 | (andif (eq f-4-3 3) (eq f-8-2 3))) | |
5001 | (getter Dsp-16-u16) | |
5002 | (setter (nop)) | |
5003 | ) | |
5004 | ||
5005 | (define-derived-operand | |
5006 | (name dst32-16-24-absolute-Unprefixed-Mova-SI) | |
5007 | (comment "m32c addressof absolute address SI") (attrs (ISA m32c)) | |
5008 | (mode SI) | |
5009 | (args (Dsp-16-u24)) | |
5010 | (syntax "${Dsp-16-u24}") | |
5011 | (base-ifield f-4-6) | |
5012 | (encoding (+ (f-4-3 3) (f-8-2 2) Dsp-16-u24)) | |
5013 | (ifield-assertion | |
5014 | (andif (eq f-4-3 3) (eq f-8-2 2))) | |
5015 | (getter Dsp-16-u24) | |
5016 | (setter (nop)) | |
5017 | ) | |
5018 | ||
5019 | (define-anyof-operand | |
5020 | (name dst32-16-Unprefixed-Mova-SI) | |
5021 | (comment | |
5022 | "m32c addressof destination operand of size SI with additional fields at offset 16") | |
5023 | (attrs (ISA m32c)) | |
5024 | (mode SI) | |
5025 | (choices | |
5026 | dst32-An-indirect-Unprefixed-Mova-SI | |
5027 | dst32-16-8-An-relative-Unprefixed-Mova-SI | |
5028 | dst32-16-16-An-relative-Unprefixed-Mova-SI | |
5029 | dst32-16-24-An-relative-Unprefixed-Mova-SI | |
5030 | dst32-16-8-SB-relative-Unprefixed-Mova-SI | |
5031 | dst32-16-16-SB-relative-Unprefixed-Mova-SI | |
5032 | dst32-16-8-FB-relative-Unprefixed-Mova-SI | |
5033 | dst32-16-16-FB-relative-Unprefixed-Mova-SI | |
5034 | dst32-16-16-absolute-Unprefixed-Mova-SI | |
5035 | dst32-16-24-absolute-Unprefixed-Mova-SI)) | |
5036 | ||
5037 | (define-pmacro (dst32-16-operand xmode) | |
5038 | (begin | |
5039 | (define-anyof-operand | |
5040 | (name (.sym dst32-16-Unprefixed- xmode)) | |
5041 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16")) | |
5042 | (attrs (machine 32)) | |
5043 | (mode xmode) | |
5044 | (choices | |
5045 | (.sym dst32-Rn-direct-Unprefixed- xmode) | |
5046 | (.sym dst32-An-direct-Unprefixed- xmode) | |
5047 | (.sym dst32-An-indirect-Unprefixed- xmode) | |
5048 | (.sym dst32-16-8-An-relative-Unprefixed- xmode) | |
5049 | (.sym dst32-16-16-An-relative-Unprefixed- xmode) | |
5050 | (.sym dst32-16-24-An-relative-Unprefixed- xmode) | |
5051 | (.sym dst32-16-8-SB-relative-Unprefixed- xmode) | |
5052 | (.sym dst32-16-16-SB-relative-Unprefixed- xmode) | |
5053 | (.sym dst32-16-8-FB-relative-Unprefixed- xmode) | |
5054 | (.sym dst32-16-16-FB-relative-Unprefixed- xmode) | |
5055 | (.sym dst32-16-16-absolute-Unprefixed- xmode) | |
5056 | (.sym dst32-16-24-absolute-Unprefixed- xmode) | |
5057 | ) | |
5058 | ) | |
5059 | (define-anyof-operand | |
5060 | (name (.sym dst32-16-8-Unprefixed- xmode)) | |
5061 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16")) | |
5062 | (attrs (machine 32)) | |
5063 | (mode xmode) | |
5064 | (choices | |
5065 | (.sym dst32-16-8-An-relative-Unprefixed- xmode) | |
5066 | (.sym dst32-16-8-SB-relative-Unprefixed- xmode) | |
5067 | (.sym dst32-16-8-FB-relative-Unprefixed- xmode) | |
5068 | ) | |
5069 | ) | |
5070 | (define-anyof-operand | |
5071 | (name (.sym dst32-16-16-Unprefixed- xmode)) | |
5072 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16")) | |
5073 | (attrs (machine 32)) | |
5074 | (mode xmode) | |
5075 | (choices | |
5076 | (.sym dst32-16-16-An-relative-Unprefixed- xmode) | |
5077 | (.sym dst32-16-16-SB-relative-Unprefixed- xmode) | |
5078 | (.sym dst32-16-16-FB-relative-Unprefixed- xmode) | |
5079 | (.sym dst32-16-16-absolute-Unprefixed- xmode) | |
5080 | ) | |
5081 | ) | |
5082 | (define-anyof-operand | |
5083 | (name (.sym dst32-16-24-Unprefixed- xmode)) | |
5084 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16")) | |
5085 | (attrs (machine 32)) | |
5086 | (mode xmode) | |
5087 | (choices | |
5088 | (.sym dst32-16-24-An-relative-Unprefixed- xmode) | |
5089 | (.sym dst32-16-24-absolute-Unprefixed- xmode) | |
5090 | ) | |
5091 | ) | |
5092 | ) | |
5093 | ) | |
5094 | ||
5095 | (dst32-16-operand QI) | |
5096 | (dst32-16-operand HI) | |
5097 | (dst32-16-operand SI) | |
5098 | ||
5099 | (define-pmacro (dst32-16-Ext-operand smode dmode) | |
5100 | (begin | |
5101 | (define-anyof-operand | |
5102 | (name (.sym dst32-16-ExtUnprefixed- smode)) | |
5103 | (comment (.str "m32c destination operand of size " smode " with additional fields at offset 16")) | |
5104 | (attrs (machine 32)) | |
5105 | (mode dmode) | |
5106 | (choices | |
5107 | (.sym dst32-Rn-direct-ExtUnprefixed- smode) | |
5108 | (.sym dst32-An-direct-Unprefixed- dmode) ; ExtUnprefixed mode not required for this operand -- use the normal dmode version | |
5109 | (.sym dst32-An-indirect-ExtUnprefixed- smode) | |
5110 | (.sym dst32-16-8-An-relative-ExtUnprefixed- smode) | |
5111 | (.sym dst32-16-16-An-relative-ExtUnprefixed- smode) | |
5112 | (.sym dst32-16-24-An-relative-ExtUnprefixed- smode) | |
5113 | (.sym dst32-16-8-SB-relative-ExtUnprefixed- smode) | |
5114 | (.sym dst32-16-16-SB-relative-ExtUnprefixed- smode) | |
5115 | (.sym dst32-16-8-FB-relative-ExtUnprefixed- smode) | |
5116 | (.sym dst32-16-16-FB-relative-ExtUnprefixed- smode) | |
5117 | (.sym dst32-16-16-absolute-ExtUnprefixed- smode) | |
5118 | (.sym dst32-16-24-absolute-ExtUnprefixed- smode) | |
5119 | ) | |
5120 | ) | |
5121 | ) | |
5122 | ) | |
5123 | ||
5124 | (dst32-16-Ext-operand QI HI) | |
5125 | (dst32-16-Ext-operand HI SI) | |
5126 | ||
5127 | (define-anyof-operand | |
5128 | (name dst32-16-Unprefixed-Mulex-HI) | |
5129 | (comment "m32c destination operand of size HI with additional fields at offset 16") | |
5130 | (attrs (machine 32)) | |
5131 | (mode HI) | |
5132 | (choices | |
5133 | dst32-R3-direct-Unprefixed-HI | |
5134 | dst32-An-direct-Unprefixed-HI | |
5135 | dst32-An-indirect-Unprefixed-HI | |
5136 | dst32-16-8-An-relative-Unprefixed-HI | |
5137 | dst32-16-16-An-relative-Unprefixed-HI | |
5138 | dst32-16-24-An-relative-Unprefixed-HI | |
5139 | dst32-16-8-SB-relative-Unprefixed-HI | |
5140 | dst32-16-16-SB-relative-Unprefixed-HI | |
5141 | dst32-16-8-FB-relative-Unprefixed-HI | |
5142 | dst32-16-16-FB-relative-Unprefixed-HI | |
5143 | dst32-16-16-absolute-Unprefixed-HI | |
5144 | dst32-16-24-absolute-Unprefixed-HI | |
5145 | ) | |
5146 | ) | |
5147 | ;------------------------------------------------------------- | |
5148 | ; Destination operands with possible additional fields at offset 24 bits | |
5149 | ;------------------------------------------------------------- | |
5150 | ||
5151 | (define-pmacro (dst16-24-operand xmode) | |
5152 | (begin | |
5153 | (define-anyof-operand | |
5154 | (name (.sym dst16-24- xmode)) | |
5155 | (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 24")) | |
5156 | (attrs (machine 16)) | |
5157 | (mode xmode) | |
5158 | (choices | |
5159 | (.sym dst16-Rn-direct- xmode) | |
5160 | (.sym dst16-An-direct- xmode) | |
5161 | (.sym dst16-An-indirect- xmode) | |
5162 | (.sym dst16-24-8-An-relative- xmode) | |
5163 | (.sym dst16-24-16-An-relative- xmode) | |
5164 | (.sym dst16-24-8-SB-relative- xmode) | |
5165 | (.sym dst16-24-16-SB-relative- xmode) | |
5166 | (.sym dst16-24-8-FB-relative- xmode) | |
5167 | (.sym dst16-24-16-absolute- xmode) | |
5168 | ) | |
5169 | ) | |
5170 | ) | |
5171 | ) | |
5172 | ||
5173 | (dst16-24-operand QI) | |
5174 | (dst16-24-operand HI) | |
5175 | ||
5176 | (define-pmacro (dst32-24-operand xmode) | |
5177 | (begin | |
5178 | (define-anyof-operand | |
5179 | (name (.sym dst32-24-Unprefixed- xmode)) | |
5180 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
5181 | (attrs (machine 32)) | |
5182 | (mode xmode) | |
5183 | (choices | |
5184 | (.sym dst32-Rn-direct-Unprefixed- xmode) | |
5185 | (.sym dst32-An-direct-Unprefixed- xmode) | |
5186 | (.sym dst32-An-indirect-Unprefixed- xmode) | |
5187 | (.sym dst32-24-8-An-relative-Unprefixed- xmode) | |
5188 | (.sym dst32-24-16-An-relative-Unprefixed- xmode) | |
5189 | (.sym dst32-24-24-An-relative-Unprefixed- xmode) | |
5190 | (.sym dst32-24-8-SB-relative-Unprefixed- xmode) | |
5191 | (.sym dst32-24-16-SB-relative-Unprefixed- xmode) | |
5192 | (.sym dst32-24-8-FB-relative-Unprefixed- xmode) | |
5193 | (.sym dst32-24-16-FB-relative-Unprefixed- xmode) | |
5194 | (.sym dst32-24-16-absolute-Unprefixed- xmode) | |
5195 | (.sym dst32-24-24-absolute-Unprefixed- xmode) | |
5196 | ) | |
5197 | ) | |
5198 | (define-anyof-operand | |
5199 | (name (.sym dst32-24-Prefixed- xmode)) | |
5200 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
5201 | (attrs (machine 32)) | |
5202 | (mode xmode) | |
5203 | (choices | |
5204 | (.sym dst32-Rn-direct-Prefixed- xmode) | |
5205 | (.sym dst32-An-direct-Prefixed- xmode) | |
5206 | (.sym dst32-An-indirect-Prefixed- xmode) | |
5207 | (.sym dst32-24-8-An-relative-Prefixed- xmode) | |
5208 | (.sym dst32-24-16-An-relative-Prefixed- xmode) | |
5209 | (.sym dst32-24-24-An-relative-Prefixed- xmode) | |
5210 | (.sym dst32-24-8-SB-relative-Prefixed- xmode) | |
5211 | (.sym dst32-24-16-SB-relative-Prefixed- xmode) | |
5212 | (.sym dst32-24-8-FB-relative-Prefixed- xmode) | |
5213 | (.sym dst32-24-16-FB-relative-Prefixed- xmode) | |
5214 | (.sym dst32-24-16-absolute-Prefixed- xmode) | |
5215 | (.sym dst32-24-24-absolute-Prefixed- xmode) | |
5216 | ) | |
5217 | ) | |
5218 | (define-anyof-operand | |
5219 | (name (.sym dst32-24-8-Prefixed- xmode)) | |
5220 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
5221 | (attrs (machine 32)) | |
5222 | (mode xmode) | |
5223 | (choices | |
5224 | (.sym dst32-24-8-An-relative-Prefixed- xmode) | |
5225 | (.sym dst32-24-8-SB-relative-Prefixed- xmode) | |
5226 | (.sym dst32-24-8-FB-relative-Prefixed- xmode) | |
5227 | ) | |
5228 | ) | |
5229 | (define-anyof-operand | |
5230 | (name (.sym dst32-24-16-Prefixed- xmode)) | |
5231 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
5232 | (attrs (machine 32)) | |
5233 | (mode xmode) | |
5234 | (choices | |
5235 | (.sym dst32-24-16-An-relative-Prefixed- xmode) | |
5236 | (.sym dst32-24-16-SB-relative-Prefixed- xmode) | |
5237 | (.sym dst32-24-16-FB-relative-Prefixed- xmode) | |
5238 | (.sym dst32-24-16-absolute-Prefixed- xmode) | |
5239 | ) | |
5240 | ) | |
5241 | (define-anyof-operand | |
5242 | (name (.sym dst32-24-24-Prefixed- xmode)) | |
5243 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
5244 | (attrs (machine 32)) | |
5245 | (mode xmode) | |
5246 | (choices | |
5247 | (.sym dst32-24-24-An-relative-Prefixed- xmode) | |
5248 | (.sym dst32-24-24-absolute-Prefixed- xmode) | |
5249 | ) | |
5250 | ) | |
5251 | ; (define-anyof-operand | |
5252 | ; (name (.sym dst32-24-indirect- xmode)) | |
5253 | ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
5254 | ; (attrs (machine 32)) | |
5255 | ; (mode xmode) | |
5256 | ; (choices | |
5257 | ; (.sym dst32-An-indirect-indirect- xmode) | |
5258 | ; (.sym dst32-24-8-An-relative-indirect- xmode) | |
5259 | ; (.sym dst32-24-16-An-relative-indirect- xmode) | |
5260 | ; (.sym dst32-24-24-An-relative-indirect- xmode) | |
5261 | ; (.sym dst32-24-8-SB-relative-indirect- xmode) | |
5262 | ; (.sym dst32-24-16-SB-relative-indirect- xmode) | |
5263 | ; (.sym dst32-24-8-FB-relative-indirect- xmode) | |
5264 | ; (.sym dst32-24-16-FB-relative-indirect- xmode) | |
5265 | ; ) | |
5266 | ; ) | |
5267 | ; (define-anyof-operand | |
5268 | ; (name (.sym dst32-basic-indirect- xmode)) | |
5269 | ; (comment (.str "m32c destination operand of size " xmode " with no additional fields")) | |
5270 | ; (attrs (machine 32)) | |
5271 | ; (mode xmode) | |
5272 | ; (choices | |
5273 | ; (.sym dst32-An-indirect-indirect- xmode) | |
5274 | ; ) | |
5275 | ; ) | |
5276 | ; (define-anyof-operand | |
5277 | ; (name (.sym dst32-24-8-indirect- xmode)) | |
5278 | ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
5279 | ; (attrs (machine 32)) | |
5280 | ; (mode xmode) | |
5281 | ; (choices | |
5282 | ; (.sym dst32-24-8-An-relative-indirect- xmode) | |
5283 | ; (.sym dst32-24-8-SB-relative-indirect- xmode) | |
5284 | ; (.sym dst32-24-8-FB-relative-indirect- xmode) | |
5285 | ; ) | |
5286 | ; ) | |
5287 | ; (define-anyof-operand | |
5288 | ; (name (.sym dst32-24-16-indirect- xmode)) | |
5289 | ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
5290 | ; (attrs (machine 32)) | |
5291 | ; (mode xmode) | |
5292 | ; (choices | |
5293 | ; (.sym dst32-24-16-An-relative-indirect- xmode) | |
5294 | ; (.sym dst32-24-16-SB-relative-indirect- xmode) | |
5295 | ; (.sym dst32-24-16-FB-relative-indirect- xmode) | |
5296 | ; ) | |
5297 | ; ) | |
5298 | ; (define-anyof-operand | |
5299 | ; (name (.sym dst32-24-24-indirect- xmode)) | |
5300 | ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24")) | |
5301 | ; (attrs (machine 32)) | |
5302 | ; (mode xmode) | |
5303 | ; (choices | |
5304 | ; (.sym dst32-24-24-An-relative-indirect- xmode) | |
5305 | ; ) | |
5306 | ; ) | |
5307 | ; (define-anyof-operand | |
5308 | ; (name (.sym dst32-24-absolute-indirect- xmode)) | |
5309 | ; (comment (.str "m32c destination operand of size " xmode " absolute indirect")) | |
5310 | ; (attrs (machine 32)) | |
5311 | ; (mode xmode) | |
5312 | ; (choices | |
5313 | ; (.sym dst32-24-16-absolute-indirect-derived- xmode) | |
5314 | ; (.sym dst32-24-24-absolute-indirect-derived- xmode) | |
5315 | ; ) | |
5316 | ; ) | |
5317 | ; (define-anyof-operand | |
5318 | ; (name (.sym dst32-24-16-absolute-indirect- xmode)) | |
5319 | ; (comment (.str "m32c destination operand of size " xmode " absolute indirect")) | |
5320 | ; (attrs (machine 32)) | |
5321 | ; (mode xmode) | |
5322 | ; (choices | |
5323 | ; (.sym dst32-24-16-absolute-indirect-derived- xmode) | |
5324 | ; ) | |
5325 | ; ) | |
5326 | ; (define-anyof-operand | |
5327 | ; (name (.sym dst32-24-24-absolute-indirect- xmode)) | |
5328 | ; (comment (.str "m32c destination operand of size " xmode " absolute indirect")) | |
5329 | ; (attrs (machine 32)) | |
5330 | ; (mode xmode) | |
5331 | ; (choices | |
5332 | ; (.sym dst32-24-24-absolute-indirect-derived- xmode) | |
5333 | ; ) | |
5334 | ; ) | |
5335 | ) | |
5336 | ) | |
5337 | ||
5338 | (dst32-24-operand QI) | |
5339 | (dst32-24-operand HI) | |
5340 | (dst32-24-operand SI) | |
5341 | ||
5342 | ;------------------------------------------------------------- | |
5343 | ; Destination operands with possible additional fields at offset 32 bits | |
5344 | ;------------------------------------------------------------- | |
5345 | ||
5346 | (define-pmacro (dst16-32-operand xmode) | |
5347 | (begin | |
5348 | (define-anyof-operand | |
5349 | (name (.sym dst16-32- xmode)) | |
5350 | (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 32")) | |
5351 | (attrs (machine 16)) | |
5352 | (mode xmode) | |
5353 | (choices | |
5354 | (.sym dst16-Rn-direct- xmode) | |
5355 | (.sym dst16-An-direct- xmode) | |
5356 | (.sym dst16-An-indirect- xmode) | |
5357 | (.sym dst16-32-8-An-relative- xmode) | |
5358 | (.sym dst16-32-16-An-relative- xmode) | |
5359 | (.sym dst16-32-8-SB-relative- xmode) | |
5360 | (.sym dst16-32-16-SB-relative- xmode) | |
5361 | (.sym dst16-32-8-FB-relative- xmode) | |
5362 | (.sym dst16-32-16-absolute- xmode) | |
5363 | ) | |
5364 | ) | |
5365 | ) | |
5366 | ) | |
5367 | (dst16-32-operand QI) | |
5368 | (dst16-32-operand HI) | |
5369 | ||
5370 | ; This macro actually handles operands at offset 32, 40 and 48 bits | |
5371 | (define-pmacro (dst32-32plus-operand offset xmode) | |
5372 | (begin | |
5373 | (define-anyof-operand | |
5374 | (name (.sym dst32- offset -Unprefixed- xmode)) | |
5375 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32")) | |
5376 | (attrs (machine 32)) | |
5377 | (mode xmode) | |
5378 | (choices | |
5379 | (.sym dst32-Rn-direct-Unprefixed- xmode) | |
5380 | (.sym dst32-An-direct-Unprefixed- xmode) | |
5381 | (.sym dst32-An-indirect-Unprefixed- xmode) | |
5382 | (.sym dst32- offset -8-An-relative-Unprefixed- xmode) | |
5383 | (.sym dst32- offset -16-An-relative-Unprefixed- xmode) | |
5384 | (.sym dst32- offset -24-An-relative-Unprefixed- xmode) | |
5385 | (.sym dst32- offset -8-SB-relative-Unprefixed- xmode) | |
5386 | (.sym dst32- offset -16-SB-relative-Unprefixed- xmode) | |
5387 | (.sym dst32- offset -8-FB-relative-Unprefixed- xmode) | |
5388 | (.sym dst32- offset -16-FB-relative-Unprefixed- xmode) | |
5389 | (.sym dst32- offset -16-absolute-Unprefixed- xmode) | |
5390 | (.sym dst32- offset -24-absolute-Unprefixed- xmode) | |
5391 | ) | |
5392 | ) | |
5393 | (define-anyof-operand | |
5394 | (name (.sym dst32- offset -Prefixed- xmode)) | |
5395 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32")) | |
5396 | (attrs (machine 32)) | |
5397 | (mode xmode) | |
5398 | (choices | |
5399 | (.sym dst32-Rn-direct-Prefixed- xmode) | |
5400 | (.sym dst32-An-direct-Prefixed- xmode) | |
5401 | (.sym dst32-An-indirect-Prefixed- xmode) | |
5402 | (.sym dst32- offset -8-An-relative-Prefixed- xmode) | |
5403 | (.sym dst32- offset -16-An-relative-Prefixed- xmode) | |
5404 | (.sym dst32- offset -24-An-relative-Prefixed- xmode) | |
5405 | (.sym dst32- offset -8-SB-relative-Prefixed- xmode) | |
5406 | (.sym dst32- offset -16-SB-relative-Prefixed- xmode) | |
5407 | (.sym dst32- offset -8-FB-relative-Prefixed- xmode) | |
5408 | (.sym dst32- offset -16-FB-relative-Prefixed- xmode) | |
5409 | (.sym dst32- offset -16-absolute-Prefixed- xmode) | |
5410 | (.sym dst32- offset -24-absolute-Prefixed- xmode) | |
5411 | ) | |
5412 | ) | |
5413 | ; (define-anyof-operand | |
5414 | ; (name (.sym dst32- offset -indirect- xmode)) | |
5415 | ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32")) | |
5416 | ; (attrs (machine 32)) | |
5417 | ; (mode xmode) | |
5418 | ; (choices | |
5419 | ; (.sym dst32-An-indirect-indirect- xmode) | |
5420 | ; (.sym dst32- offset -8-An-relative-indirect- xmode) | |
5421 | ; (.sym dst32- offset -16-An-relative-indirect- xmode) | |
5422 | ; (.sym dst32- offset -24-An-relative-indirect- xmode) | |
5423 | ; (.sym dst32- offset -8-SB-relative-indirect- xmode) | |
5424 | ; (.sym dst32- offset -16-SB-relative-indirect- xmode) | |
5425 | ; (.sym dst32- offset -8-FB-relative-indirect- xmode) | |
5426 | ; (.sym dst32- offset -16-FB-relative-indirect- xmode) | |
5427 | ; ) | |
5428 | ; ) | |
5429 | ; (define-anyof-operand | |
5430 | ; (name (.sym dst32- offset -absolute-indirect- xmode)) | |
5431 | ; (comment (.str "m32c destination operand of size " xmode " absolute indirect")) | |
5432 | ; (attrs (machine 32)) | |
5433 | ; (mode xmode) | |
5434 | ; (choices | |
5435 | ; (.sym dst32- offset -16-absolute-indirect-derived- xmode) | |
5436 | ; (.sym dst32- offset -24-absolute-indirect-derived- xmode) | |
5437 | ; ) | |
5438 | ; ) | |
5439 | ) | |
5440 | ) | |
5441 | ||
5442 | (dst32-32plus-operand 32 QI) | |
5443 | (dst32-32plus-operand 32 HI) | |
5444 | (dst32-32plus-operand 32 SI) | |
5445 | (dst32-32plus-operand 40 QI) | |
5446 | (dst32-32plus-operand 40 HI) | |
5447 | (dst32-32plus-operand 40 SI) | |
5448 | ||
5449 | ;------------------------------------------------------------- | |
5450 | ; Destination operands with possible additional fields at offset 48 bits | |
5451 | ;------------------------------------------------------------- | |
5452 | ||
5453 | (define-pmacro (dst32-48-operand offset xmode) | |
5454 | (begin | |
5455 | (define-anyof-operand | |
5456 | (name (.sym dst32- offset -Prefixed- xmode)) | |
5457 | (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32")) | |
5458 | (attrs (machine 32)) | |
5459 | (mode xmode) | |
5460 | (choices | |
5461 | (.sym dst32-Rn-direct-Prefixed- xmode) | |
5462 | (.sym dst32-An-direct-Prefixed- xmode) | |
5463 | (.sym dst32-An-indirect-Prefixed- xmode) | |
5464 | (.sym dst32- offset -8-An-relative-Prefixed- xmode) | |
5465 | (.sym dst32- offset -16-An-relative-Prefixed- xmode) | |
5466 | (.sym dst32- offset -24-An-relative-Prefixed- xmode) | |
5467 | (.sym dst32- offset -8-SB-relative-Prefixed- xmode) | |
5468 | (.sym dst32- offset -16-SB-relative-Prefixed- xmode) | |
5469 | (.sym dst32- offset -8-FB-relative-Prefixed- xmode) | |
5470 | (.sym dst32- offset -16-FB-relative-Prefixed- xmode) | |
5471 | (.sym dst32- offset -16-absolute-Prefixed- xmode) | |
5472 | (.sym dst32- offset -24-absolute-Prefixed- xmode) | |
5473 | ) | |
5474 | ) | |
5475 | ; (define-anyof-operand | |
5476 | ; (name (.sym dst32- offset -indirect- xmode)) | |
5477 | ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32")) | |
5478 | ; (attrs (machine 32)) | |
5479 | ; (mode xmode) | |
5480 | ; (choices | |
5481 | ; (.sym dst32-An-indirect-indirect- xmode) | |
5482 | ; (.sym dst32- offset -8-An-relative-indirect- xmode) | |
5483 | ; (.sym dst32- offset -16-An-relative-indirect- xmode) | |
5484 | ; (.sym dst32- offset -24-An-relative-indirect- xmode) | |
5485 | ; (.sym dst32- offset -8-SB-relative-indirect- xmode) | |
5486 | ; (.sym dst32- offset -16-SB-relative-indirect- xmode) | |
5487 | ; (.sym dst32- offset -8-FB-relative-indirect- xmode) | |
5488 | ; (.sym dst32- offset -16-FB-relative-indirect- xmode) | |
5489 | ; ) | |
5490 | ; ) | |
5491 | ; (define-anyof-operand | |
5492 | ; (name (.sym dst32- offset -absolute-indirect- xmode)) | |
5493 | ; (comment (.str "m32c destination operand of size " xmode " absolute indirect")) | |
5494 | ; (attrs (machine 32)) | |
5495 | ; (mode xmode) | |
5496 | ; (choices | |
5497 | ; (.sym dst32- offset -16-absolute-indirect-derived- xmode) | |
5498 | ; (.sym dst32- offset -24-absolute-indirect-derived- xmode) | |
5499 | ; ) | |
5500 | ; ) | |
5501 | ) | |
5502 | ) | |
5503 | ||
5504 | (dst32-48-operand 48 QI) | |
5505 | (dst32-48-operand 48 HI) | |
5506 | (dst32-48-operand 48 SI) | |
5507 | ||
5508 | ;------------------------------------------------------------- | |
5509 | ; Bit operands for m16c | |
5510 | ;------------------------------------------------------------- | |
5511 | ||
5512 | (define-pmacro (bit16-operand offset) | |
5513 | (begin | |
5514 | (define-anyof-operand | |
5515 | (name (.sym bit16- offset)) | |
5516 | (comment (.str "m16c bit operand with possible additional fields at offset 24")) | |
5517 | (attrs (machine 16)) | |
5518 | (mode BI) | |
5519 | (choices | |
5520 | bit16-Rn-direct | |
5521 | bit16-An-direct | |
5522 | bit16-An-indirect | |
5523 | (.sym bit16- offset -8-An-relative) | |
5524 | (.sym bit16- offset -16-An-relative) | |
5525 | (.sym bit16- offset -8-SB-relative) | |
5526 | (.sym bit16- offset -16-SB-relative) | |
5527 | (.sym bit16- offset -8-FB-relative) | |
5528 | (.sym bit16- offset -16-absolute) | |
5529 | ) | |
5530 | ) | |
5531 | (define-anyof-operand | |
5532 | (name (.sym bit16- offset -basic)) | |
5533 | (comment (.str "m16c bit operand with no additional fields")) | |
5534 | (attrs (machine 16)) | |
5535 | (mode BI) | |
5536 | (choices | |
5537 | bit16-An-indirect | |
5538 | ) | |
5539 | ) | |
5540 | (define-anyof-operand | |
5541 | (name (.sym bit16- offset -8)) | |
5542 | (comment (.str "m16c bit operand with possible additional fields at offset 24")) | |
5543 | (attrs (machine 16)) | |
5544 | (mode BI) | |
5545 | (choices | |
5546 | bit16-Rn-direct | |
5547 | bit16-An-direct | |
5548 | (.sym bit16- offset -8-An-relative) | |
5549 | (.sym bit16- offset -8-SB-relative) | |
5550 | (.sym bit16- offset -8-FB-relative) | |
5551 | ) | |
5552 | ) | |
5553 | (define-anyof-operand | |
5554 | (name (.sym bit16- offset -16)) | |
5555 | (comment (.str "m16c bit operand with possible additional fields at offset 24")) | |
5556 | (attrs (machine 16)) | |
5557 | (mode BI) | |
5558 | (choices | |
5559 | (.sym bit16- offset -16-An-relative) | |
5560 | (.sym bit16- offset -16-SB-relative) | |
5561 | (.sym bit16- offset -16-absolute) | |
5562 | ) | |
5563 | ) | |
5564 | ) | |
5565 | ) | |
5566 | ||
5567 | (bit16-operand 16) | |
5568 | ||
5569 | ;------------------------------------------------------------- | |
5570 | ; Bit operands for m32c | |
5571 | ;------------------------------------------------------------- | |
5572 | ||
5573 | (define-pmacro (bit32-operand offset group) | |
5574 | (begin | |
5575 | (define-anyof-operand | |
5576 | (name (.sym bit32- offset - group)) | |
5577 | (comment (.str "m32c bit operand with possible additional fields at offset 24")) | |
5578 | (attrs (machine 32)) | |
5579 | (mode BI) | |
5580 | (choices | |
5581 | (.sym bit32-Rn-direct- group) | |
5582 | (.sym bit32-An-direct- group) | |
5583 | (.sym bit32-An-indirect- group) | |
5584 | (.sym bit32- offset -11-An-relative- group) | |
5585 | (.sym bit32- offset -19-An-relative- group) | |
5586 | (.sym bit32- offset -27-An-relative- group) | |
5587 | (.sym bit32- offset -11-SB-relative- group) | |
5588 | (.sym bit32- offset -19-SB-relative- group) | |
5589 | (.sym bit32- offset -11-FB-relative- group) | |
5590 | (.sym bit32- offset -19-FB-relative- group) | |
5591 | (.sym bit32- offset -19-absolute- group) | |
5592 | (.sym bit32- offset -27-absolute- group) | |
5593 | ) | |
5594 | ) | |
5595 | ) | |
5596 | ) | |
5597 | ||
5598 | (bit32-operand 16 Unprefixed) | |
5599 | (bit32-operand 24 Prefixed) | |
5600 | ||
5601 | (define-anyof-operand | |
5602 | (name bit32-basic-Unprefixed) | |
5603 | (comment "m32c bit operand with no additional fields") | |
5604 | (attrs (machine 32)) | |
5605 | (mode BI) | |
5606 | (choices | |
5607 | bit32-Rn-direct-Unprefixed | |
5608 | bit32-An-direct-Unprefixed | |
5609 | bit32-An-indirect-Unprefixed | |
5610 | ) | |
5611 | ) | |
5612 | ||
5613 | (define-anyof-operand | |
5614 | (name bit32-16-8-Unprefixed) | |
5615 | (comment "m32c bit operand with 8 bit additional fields") | |
5616 | (attrs (machine 32)) | |
5617 | (mode BI) | |
5618 | (choices | |
5619 | bit32-16-11-An-relative-Unprefixed | |
5620 | bit32-16-11-SB-relative-Unprefixed | |
5621 | bit32-16-11-FB-relative-Unprefixed | |
5622 | ) | |
5623 | ) | |
5624 | ||
5625 | (define-anyof-operand | |
5626 | (name bit32-16-16-Unprefixed) | |
5627 | (comment "m32c bit operand with 16 bit additional fields") | |
5628 | (attrs (machine 32)) | |
5629 | (mode BI) | |
5630 | (choices | |
5631 | bit32-16-19-An-relative-Unprefixed | |
5632 | bit32-16-19-SB-relative-Unprefixed | |
5633 | bit32-16-19-FB-relative-Unprefixed | |
5634 | bit32-16-19-absolute-Unprefixed | |
5635 | ) | |
5636 | ) | |
5637 | ||
5638 | (define-anyof-operand | |
5639 | (name bit32-16-24-Unprefixed) | |
5640 | (comment "m32c bit operand with 24 bit additional fields") | |
5641 | (attrs (machine 32)) | |
5642 | (mode BI) | |
5643 | (choices | |
5644 | bit32-16-27-An-relative-Unprefixed | |
5645 | bit32-16-27-absolute-Unprefixed | |
5646 | ) | |
5647 | ) | |
5648 | ||
5649 | ;------------------------------------------------------------- | |
5650 | ; Operands for short format binary insns | |
5651 | ;------------------------------------------------------------- | |
5652 | ||
5653 | (define-anyof-operand | |
5654 | (name src16-2-S) | |
5655 | (comment "m16c source operand of size QI for short format insns") | |
5656 | (attrs (machine 16)) | |
5657 | (mode QI) | |
5658 | (choices | |
5659 | src16-2-S-8-SB-relative-QI | |
5660 | src16-2-S-8-FB-relative-QI | |
5661 | src16-2-S-16-absolute-QI | |
5662 | ) | |
5663 | ) | |
5664 | ||
5665 | (define-anyof-operand | |
5666 | (name src32-2-S-QI) | |
5667 | (comment "m32c source operand of size QI for short format insns") | |
5668 | (attrs (machine 32)) | |
5669 | (mode QI) | |
5670 | (choices | |
5671 | src32-2-S-8-SB-relative-QI | |
5672 | src32-2-S-8-FB-relative-QI | |
5673 | src32-2-S-16-absolute-QI | |
5674 | ) | |
5675 | ) | |
5676 | ||
5677 | (define-anyof-operand | |
5678 | (name src32-2-S-HI) | |
5679 | (comment "m32c source operand of size QI for short format insns") | |
5680 | (attrs (machine 32)) | |
5681 | (mode HI) | |
5682 | (choices | |
5683 | src32-2-S-8-SB-relative-HI | |
5684 | src32-2-S-8-FB-relative-HI | |
5685 | src32-2-S-16-absolute-HI | |
5686 | ) | |
5687 | ) | |
5688 | ||
5689 | (define-anyof-operand | |
5690 | (name Dst16-3-S-8) | |
5691 | (comment "m16c destination operand of size QI for short format insns") | |
5692 | (attrs (machine 16)) | |
5693 | (mode QI) | |
5694 | (choices | |
5695 | dst16-3-S-R0l-direct-QI | |
5696 | dst16-3-S-R0h-direct-QI | |
5697 | dst16-3-S-8-8-SB-relative-QI | |
5698 | dst16-3-S-8-8-FB-relative-QI | |
5699 | dst16-3-S-8-16-absolute-QI | |
5700 | ) | |
5701 | ) | |
5702 | ||
5703 | (define-anyof-operand | |
5704 | (name Dst16-3-S-16) | |
5705 | (comment "m16c destination operand of size QI for short format insns") | |
5706 | (attrs (machine 16)) | |
5707 | (mode QI) | |
5708 | (choices | |
5709 | dst16-3-S-R0l-direct-QI | |
5710 | dst16-3-S-R0h-direct-QI | |
5711 | dst16-3-S-16-8-SB-relative-QI | |
5712 | dst16-3-S-16-8-FB-relative-QI | |
5713 | dst16-3-S-16-16-absolute-QI | |
5714 | ) | |
5715 | ) | |
5716 | ||
5717 | (define-anyof-operand | |
5718 | (name srcdst16-r0l-r0h-S) | |
5719 | (comment "m16c r0l/r0h operand of size QI for short format insns") | |
5720 | (attrs (machine 16)) | |
5721 | (mode SI) | |
5722 | (choices | |
5723 | srcdst16-r0l-r0h-S-derived | |
5724 | ) | |
5725 | ) | |
5726 | ||
5727 | (define-anyof-operand | |
5728 | (name dst32-2-S-basic-QI) | |
5729 | (comment "m32c r0l operand of size QI for short format binary insns") | |
5730 | (attrs (machine 32)) | |
5731 | (mode QI) | |
5732 | (choices | |
5733 | dst32-2-S-R0l-direct-QI | |
5734 | ) | |
5735 | ) | |
5736 | ||
5737 | (define-anyof-operand | |
5738 | (name dst32-2-S-basic-HI) | |
5739 | (comment "m32c r0 operand of size HI for short format binary insns") | |
5740 | (attrs (machine 32)) | |
5741 | (mode HI) | |
5742 | (choices | |
5743 | dst32-2-S-R0-direct-HI | |
5744 | ) | |
5745 | ) | |
5746 | ||
5747 | (define-pmacro (dst32-2-S-operands xmode) | |
5748 | (begin | |
5749 | (define-anyof-operand | |
5750 | (name (.sym dst32-2-S-8- xmode)) | |
5751 | (comment "m32c operand of size " xmode " for short format binary insns") | |
5752 | (attrs (machine 32)) | |
5753 | (mode xmode) | |
5754 | (choices | |
5755 | (.sym dst32-2-S-8-SB-relative- xmode) | |
5756 | (.sym dst32-2-S-8-FB-relative- xmode) | |
5757 | ) | |
5758 | ) | |
5759 | (define-anyof-operand | |
5760 | (name (.sym dst32-2-S-16- xmode)) | |
5761 | (comment "m32c operand of size " xmode " for short format binary insns") | |
5762 | (attrs (machine 32)) | |
5763 | (mode xmode) | |
5764 | (choices | |
5765 | (.sym dst32-2-S-16-absolute- xmode) | |
5766 | ) | |
5767 | ) | |
5768 | ; (define-anyof-operand | |
5769 | ; (name (.sym dst32-2-S-8-indirect- xmode)) | |
5770 | ; (comment "m32c operand of size " xmode " for short format binary insns") | |
5771 | ; (attrs (machine 32)) | |
5772 | ; (mode xmode) | |
5773 | ; (choices | |
5774 | ; (.sym dst32-2-S-8-SB-relative-indirect- xmode) | |
5775 | ; (.sym dst32-2-S-8-FB-relative-indirect- xmode) | |
5776 | ; ) | |
5777 | ; ) | |
5778 | ; (define-anyof-operand | |
5779 | ; (name (.sym dst32-2-S-absolute-indirect- xmode)) | |
5780 | ; (comment "m32c operand of size " xmode " for short format binary insns") | |
5781 | ; (attrs (machine 32)) | |
5782 | ; (mode xmode) | |
5783 | ; (choices | |
5784 | ; (.sym dst32-2-S-16-absolute-indirect- xmode) | |
5785 | ; ) | |
5786 | ; ) | |
5787 | ) | |
5788 | ) | |
5789 | ||
5790 | (dst32-2-S-operands QI) | |
5791 | (dst32-2-S-operands HI) | |
5792 | (dst32-2-S-operands SI) | |
5793 | ||
5794 | (define-anyof-operand | |
5795 | (name dst32-an-S) | |
5796 | (comment "m32c An operand for short format binary insns") | |
5797 | (attrs (machine 32)) | |
5798 | (mode HI) | |
5799 | (choices | |
5800 | dst32-1-S-A0-direct-HI | |
5801 | dst32-1-S-A1-direct-HI | |
5802 | ) | |
5803 | ) | |
5804 | ||
5805 | (define-anyof-operand | |
5806 | (name bit16-11-S) | |
5807 | (comment "m16c bit operand for short format insns") | |
5808 | (attrs (machine 16)) | |
5809 | (mode BI) | |
5810 | (choices | |
5811 | bit16-11-SB-relative-S | |
5812 | ) | |
5813 | ) | |
5814 | ||
5815 | (define-anyof-operand | |
5816 | (name Rn16-push-S-anyof) | |
5817 | (comment "m16c bit operand for short format insns") | |
5818 | (attrs (machine 16)) | |
5819 | (mode QI) | |
5820 | (choices | |
5821 | Rn16-push-S-derived | |
5822 | ) | |
5823 | ) | |
5824 | ||
5825 | (define-anyof-operand | |
5826 | (name An16-push-S-anyof) | |
5827 | (comment "m16c bit operand for short format insns") | |
5828 | (attrs (machine 16)) | |
5829 | (mode HI) | |
5830 | (choices | |
5831 | An16-push-S-derived | |
5832 | ) | |
5833 | ) | |
5834 | ||
5835 | ;============================================================= | |
5836 | ; Common macros for instruction definitions | |
5837 | ; | |
5838 | (define-pmacro (set-z x) | |
5839 | (sequence () | |
5840 | (set zbit (zflag x))) | |
5841 | ||
5842 | ) | |
5843 | ||
5844 | (define-pmacro (set-s x) | |
5845 | (sequence () | |
5846 | (set sbit (nflag x))) | |
5847 | ) | |
5848 | ||
5849 | (define-pmacro (set-z-and-s x) | |
5850 | (sequence () | |
5851 | (set-z x) | |
5852 | (set-s x)) | |
5853 | ) | |
5854 | \f | |
5855 | ;============================================================= | |
5856 | ; Unary insn macros | |
5857 | ;------------------------------------------------------------- | |
5858 | ||
c6552317 | 5859 | (define-pmacro (unary-insn-defn-g mach group mode wstr op encoding sem opg) |
49f58d10 | 5860 | (dni (.sym op mach wstr - group) |
c6552317 | 5861 | (.str op wstr opg " dst" mach "-" group "-" mode) |
49f58d10 | 5862 | ((machine mach)) |
c6552317 | 5863 | (.str op wstr opg " ${dst" mach "-" group "-" mode "}") |
49f58d10 JB |
5864 | encoding |
5865 | (sem mode (.sym dst mach - group - mode)) | |
5866 | ()) | |
5867 | ) | |
5868 | ||
c6552317 DD |
5869 | (define-pmacro (unary-insn-defn mach group mode wstr op encoding sem) |
5870 | (unary-insn-defn-g mach group mode wstr op encoding sem "") | |
5871 | ) | |
5872 | ||
49f58d10 | 5873 | |
c6552317 DD |
5874 | (define-pmacro (unary16-defn-g mode wstr wbit op opc1 opc2 opc3 sem opg) |
5875 | (unary-insn-defn-g 16 16 mode wstr op | |
5876 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16- mode)) | |
5877 | sem opg) | |
5878 | ) | |
49f58d10 | 5879 | (define-pmacro (unary16-defn mode wstr wbit op opc1 opc2 opc3 sem) |
c6552317 | 5880 | (unary-16-defn-g mode wstr wbit op opc1 opc2 opc3 sem "") |
49f58d10 JB |
5881 | ) |
5882 | ||
c6552317 | 5883 | (define-pmacro (unary32-defn-g mode wstr wbit op opc1 opc2 opc3 sem opg) |
49f58d10 JB |
5884 | (begin |
5885 | ; Multi insns are tried for assembly in the reverse order in which they appear here, so | |
5886 | ; define the absolute-indirect insns first in order to prevent them from being selected | |
5887 | ; when the mode is register-indirect | |
5888 | ; (unary-insn-defn 32 24-absolute-indirect mode wstr op | |
5889 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (.sym dst32-24-absolute-indirect- mode) (f-18-2 opc2) (f-20-4 opc3)) | |
5890 | ; sem) | |
c6552317 DD |
5891 | (unary-insn-defn-g 32 16-Unprefixed mode wstr op |
5892 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3)) | |
5893 | sem opg) | |
49f58d10 JB |
5894 | ; (unary-insn-defn 32 24-indirect mode wstr op |
5895 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (.sym dst32-24-indirect- mode) (f-18-2 opc2) (f-20-4 opc3)) | |
5896 | ; sem) | |
5897 | ) | |
5898 | ) | |
c6552317 DD |
5899 | (define-pmacro (unary32-defn mode wstr wbit op opc1 opc2 opc3 sem) |
5900 | (unary32-defn-g mode wstr wbit op opc1 opc2 opc3 sem "") | |
5901 | ) | |
49f58d10 | 5902 | |
c6552317 | 5903 | (define-pmacro (unary-insn-mach-g mach op opc1 opc2 opc3 sem opg) |
49f58d10 | 5904 | (begin |
c6552317 DD |
5905 | (.apply (.sym unary mach -defn-g) (QI .b 0 op opc1 opc2 opc3 sem opg)) |
5906 | (.apply (.sym unary mach -defn-g) (HI .w 1 op opc1 opc2 opc3 sem opg)) | |
49f58d10 JB |
5907 | ) |
5908 | ) | |
c6552317 DD |
5909 | (define-pmacro (unary-insn-mach mach op opc1 opc2 opc3 sem) |
5910 | (unary-insn-mach-g mach op opc1 opc2 opc3 sem "") | |
5911 | ) | |
49f58d10 JB |
5912 | |
5913 | (define-pmacro (unary-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem) | |
5914 | (begin | |
c6552317 DD |
5915 | (unary-insn-mach-g 16 op opc16-1 opc16-2 opc16-3 sem "") |
5916 | (unary-insn-mach-g 32 op opc32-1 opc32-2 opc32-3 sem "") | |
5917 | ) | |
5918 | ) | |
5919 | ||
5920 | (define-pmacro (unary-insn-g op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem) | |
5921 | (begin | |
5922 | (unary-insn-mach-g 16 op opc16-1 opc16-2 opc16-3 sem "$G") | |
5923 | (unary-insn-mach-g 32 op opc32-1 opc32-2 opc32-3 sem "$G") | |
49f58d10 JB |
5924 | ) |
5925 | ) | |
5926 | ||
5927 | ;------------------------------------------------------------- | |
5928 | ; Sign/zero extension macros | |
5929 | ;------------------------------------------------------------- | |
5930 | ||
5931 | (define-pmacro (ext-insn-defn mach group smode dmode wstr op encoding sem) | |
5932 | (dni (.sym op mach wstr - group) | |
5933 | (.str op wstr " dst" mach "-" group "-" smode) | |
5934 | ((machine mach)) | |
5935 | (.str op wstr " ${dst" mach "-" group "-" smode "}") | |
5936 | encoding | |
5937 | (sem smode dmode (.sym dst mach - group - smode) (.sym dst mach - group - smode)) | |
5938 | ()) | |
5939 | ) | |
5940 | ||
5941 | (define-pmacro (ext16-defn smode dmode wstr wbit op opc1 opc2 opc3 sem) | |
5942 | (ext-insn-defn 16 16-Ext smode dmode wstr op | |
5943 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-Ext- smode)) | |
5944 | sem) | |
5945 | ) | |
5946 | ||
5947 | (define-pmacro (ext32-defn smode dmode wstr wbit op opc1 opc2 opc3 sem) | |
5948 | (ext-insn-defn 32 16-ExtUnprefixed smode dmode wstr op | |
5949 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst32-16-ExtUnprefixed- smode)) | |
5950 | sem) | |
5951 | ) | |
5952 | ||
5953 | (define-pmacro (ext32-binary-insn src-group dst-group op wstr encoding sem) | |
5954 | (dni (.sym op 32 wstr - src-group - dst-group) | |
5955 | (.str op 32 wstr " src32-" src-group "-QI,dst32-" dst-group "-HI") | |
5956 | ((machine 32)) | |
5957 | (.str op wstr " ${src32-" src-group "-QI},${dst32-" dst-group "-HI}") | |
5958 | encoding | |
5959 | (sem QI HI (.sym src32- src-group -QI) (.sym dst32 - dst-group -HI)) | |
5960 | ()) | |
5961 | ) | |
5962 | ||
5963 | (define-pmacro (ext32-binary-defn op wstr opc1 opc2 sem) | |
5964 | (begin | |
5965 | (ext32-binary-insn basic-ExtPrefixed 24-Prefixed op wstr | |
5966 | (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-basic-ExtPrefixed-QI dst32-24-Prefixed-HI (f-20-4 opc2)) | |
5967 | sem) | |
5968 | (ext32-binary-insn 24-24-Prefixed 48-Prefixed op wstr | |
5969 | (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-24-24-Prefixed-QI dst32-48-Prefixed-HI (f-20-4 opc2)) | |
5970 | sem) | |
5971 | (ext32-binary-insn 24-16-Prefixed 40-Prefixed op wstr | |
5972 | (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-24-16-Prefixed-QI dst32-40-Prefixed-HI (f-20-4 opc2)) | |
5973 | sem) | |
5974 | (ext32-binary-insn 24-8-Prefixed 32-Prefixed op wstr | |
5975 | (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-24-8-Prefixed-QI dst32-32-Prefixed-HI (f-20-4 opc2)) | |
5976 | sem) | |
5977 | ) | |
5978 | ) | |
5979 | ||
5980 | ;============================================================= | |
5981 | ; Binary Arithmetic macros | |
5982 | ; | |
5983 | ;------------------------------------------------------------- | |
5984 | ;<arith>.size:S src2,r0[l] -- for m32c | |
5985 | ;------------------------------------------------------------- | |
5986 | ||
5987 | (define-pmacro (binary-arith32-S-src2 op xmode wstr wbit opc1 opc2 sem) | |
5988 | (dni (.sym op 32 wstr .S-src2-r0- xmode) | |
5989 | (.str op 32 wstr ":S src2,r0[l]") | |
5990 | ((machine 32)) | |
5991 | (.str op wstr"$S ${src32-2-S-" xmode "},${Dst32R0" xmode "-S}") | |
5992 | (+ opc1 opc2 (.sym src32-2-S- xmode) (f-7-1 wbit)) | |
5993 | (sem xmode (.sym src32-2-S- xmode) (.sym Dst32R0 xmode -S)) | |
5994 | ()) | |
5995 | ) | |
5996 | ||
5997 | ;------------------------------------------------------------- | |
5998 | ;<arith>.b:S src2,r0l/r0h -- for m16c | |
5999 | ;------------------------------------------------------------- | |
6000 | ||
6001 | (define-pmacro (binary-arith16-b-S-src2 op opc1 opc2 sem) | |
6002 | (begin | |
6003 | (dni (.sym op 16 .b.S-src2) | |
6004 | (.str op ".b:S src2,r0[lh]") | |
6005 | ((machine 16)) | |
6006 | (.str op ".b$S ${src16-2-S},${Dst16RnQI-S}") | |
6007 | (+ opc1 opc2 Dst16RnQI-S src16-2-S) | |
6008 | (sem QI src16-2-S Dst16RnQI-S) | |
6009 | ()) | |
6010 | (dni (.sym op 16 .b.S-r0l-r0h) | |
6011 | (.str op ".b:S r0l/r0h") | |
6012 | ((machine 16)) | |
6013 | (.str op ".b$S ${srcdst16-r0l-r0h-S}") | |
6014 | (+ opc1 opc2 srcdst16-r0l-r0h-S) | |
6015 | (if (eq srcdst16-r0l-r0h-S 0) | |
6016 | (sem QI R0h R0l) | |
6017 | (sem QI R0l R0h)) | |
6018 | ()) | |
6019 | ) | |
6020 | ) | |
6021 | ||
6022 | ;------------------------------------------------------------- | |
6023 | ;<arith>.b:S #imm8,dst3 -- for m16c | |
6024 | ;------------------------------------------------------------- | |
6025 | ||
6026 | (define-pmacro (binary-arith16-b-S-imm8-dst3 op sz opc1 opc2 sem) | |
6027 | (dni (.sym op 16 .b.S-imm8-dst3) | |
6028 | (.str op sz ":S imm8,dst3") | |
6029 | ((machine 16)) | |
6030 | (.str op sz "$S #${Imm-8-QI},${Dst16-3-S-16}") | |
6031 | (+ opc1 opc2 Dst16-3-S-16 Imm-8-QI) | |
6032 | (sem QI Imm-8-QI Dst16-3-S-16) | |
6033 | ()) | |
6034 | ) | |
6035 | ||
6036 | ;------------------------------------------------------------- | |
6037 | ;<arith>.size:Q #imm4,sp -- for m16c | |
6038 | ;------------------------------------------------------------- | |
6039 | ||
6040 | (define-pmacro (binary-arith16-Q-sp op opc1 opc2 opc3 sem) | |
92e0a941 DD |
6041 | (dni (.sym op 16 -wQ-sp) |
6042 | (.str op ".w:q #imm4,sp") | |
49f58d10 | 6043 | ((machine 16)) |
92e0a941 | 6044 | (.str op ".w$Q #${Imm-12-s4},sp") |
49f58d10 JB |
6045 | (+ opc1 opc2 opc3 Imm-12-s4) |
6046 | (sem QI Imm-12-s4 sp) | |
6047 | ()) | |
6048 | ) | |
6049 | ||
6050 | ;------------------------------------------------------------- | |
6051 | ;<arith>.size:G #imm,sp -- for m16c | |
6052 | ;------------------------------------------------------------- | |
6053 | ||
6054 | (define-pmacro (binary-arith16-G-sp-defn mode wstr wbit op opc1 opc2 opc3 opc4 sem) | |
6055 | (dni (.sym op 16 wstr - G-sp) | |
6056 | (.str op wstr " imm-sp " mode) | |
6057 | ((machine 16)) | |
6058 | (.str op wstr "$G #${Imm-16-" mode "},sp") | |
6059 | (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16- mode)) | |
6060 | (sem mode (.sym Imm-16- mode) sp) | |
6061 | ()) | |
6062 | ) | |
6063 | ||
6064 | (define-pmacro (binary-arith16-G-sp op opc1 opc2 opc3 opc4 sem) | |
6065 | (begin | |
6066 | (binary-arith16-G-sp-defn QI .b 0 op opc1 opc2 opc3 opc4 sem) | |
6067 | (binary-arith16-G-sp-defn HI .w 1 op opc1 opc2 opc3 opc4 sem) | |
6068 | ) | |
6069 | ) | |
6070 | ||
6071 | ;------------------------------------------------------------- | |
6072 | ;<arith>.size:G #imm,dst -- for m16c and m32c | |
6073 | ;------------------------------------------------------------- | |
6074 | ||
6075 | (define-pmacro (binary-arith-imm-dst-defn mach src dstgroup dmode wstr op suffix encoding sem) | |
6076 | (dni (.sym op mach wstr - imm-G - dstgroup) | |
6077 | (.str op wstr " " mach "-imm-G-" dstgroup "-" dmode) | |
6078 | ((machine mach)) | |
6079 | (.str op wstr "$"suffix " #${" src "},${dst" mach "-" dstgroup "-" dmode "}") | |
6080 | encoding | |
6081 | (sem dmode src (.sym dst mach - dstgroup - dmode)) | |
6082 | ()) | |
6083 | ) | |
6084 | ||
6085 | ; m16c variants | |
6086 | (define-pmacro (binary-arith16-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem) | |
6087 | (begin | |
6088 | (binary-arith-imm-dst-defn 16 (.sym Imm-32- smode) 16-16 dmode wstr op suffix | |
6089 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- dmode) (.sym Imm-32- smode)) | |
6090 | sem) | |
6091 | (binary-arith-imm-dst-defn 16 (.sym Imm-24- smode) 16-8 dmode wstr op suffix | |
6092 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- dmode) (.sym Imm-24- smode)) | |
6093 | sem) | |
6094 | (binary-arith-imm-dst-defn 16 (.sym Imm-16- smode) basic dmode wstr op suffix | |
6095 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- dmode) (.sym Imm-16- smode)) | |
6096 | sem) | |
6097 | ) | |
6098 | ) | |
6099 | ||
6100 | ; m32c Unprefixed variants | |
6101 | (define-pmacro (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem) | |
6102 | (begin | |
6103 | (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 16-24-Unprefixed dmode wstr op suffix | |
6104 | (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-16-24-Unprefixed- dmode) (.sym Imm-40- smode)) | |
6105 | sem) | |
6106 | (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 16-16-Unprefixed dmode wstr op suffix | |
6107 | (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-16-16-Unprefixed- dmode) (.sym Imm-32- smode)) | |
6108 | sem) | |
6109 | (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) 16-8-Unprefixed dmode wstr op suffix | |
6110 | (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-16-8-Unprefixed- dmode) (.sym Imm-24- smode)) | |
6111 | sem) | |
6112 | (binary-arith-imm-dst-defn 32 (.sym Imm-16- smode) basic-Unprefixed dmode wstr op suffix | |
6113 | (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-basic-Unprefixed- dmode) (.sym Imm-16- smode)) | |
6114 | sem) | |
6115 | ) | |
6116 | ) | |
6117 | ||
6118 | ; m32c Prefixed variants | |
6119 | (define-pmacro (binary-arith32-imm-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem) | |
6120 | (begin | |
6121 | (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-Prefixed dmode wstr op suffix | |
6122 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-24-Prefixed- dmode) (.sym Imm-48- smode)) | |
6123 | sem) | |
6124 | (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-Prefixed dmode wstr op suffix | |
6125 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-16-Prefixed- dmode) (.sym Imm-40- smode)) | |
6126 | sem) | |
6127 | (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-Prefixed dmode wstr op suffix | |
6128 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-8-Prefixed- dmode) (.sym Imm-32- smode)) | |
6129 | sem) | |
6130 | (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-Prefixed dmode wstr op suffix | |
6131 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-basic-Prefixed- dmode) (.sym Imm-24- smode)) | |
6132 | sem) | |
6133 | ) | |
6134 | ) | |
6135 | ||
6136 | ; All m32c variants | |
6137 | (define-pmacro (binary-arith32-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem) | |
6138 | (begin | |
6139 | ; Multi insns are tried for assembly in the reverse order in which they appear here, so | |
6140 | ; define the absolute-indirect insns first in order to prevent them from being selected | |
6141 | ; when the mode is register-indirect | |
6142 | ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-absolute-indirect dmode wstr op suffix | |
6143 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-24-absolute-indirect- dmode) (.sym Imm-48- smode)) | |
6144 | ; sem) | |
6145 | ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-absolute-indirect dmode wstr op suffix | |
6146 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-16-absolute-indirect- dmode) (.sym Imm-40- smode)) | |
6147 | ; sem) | |
6148 | ; Unprefixed modes next | |
6149 | (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem) | |
6150 | ||
6151 | ; Remaining indirect modes | |
6152 | ; (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-indirect dmode wstr op suffix | |
6153 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-basic-indirect- dmode) (.sym Imm-24- smode)) | |
6154 | ; sem) | |
6155 | ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-indirect dmode wstr op suffix | |
6156 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-24-indirect- dmode) (.sym Imm-48- smode)) | |
6157 | ; sem) | |
6158 | ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-indirect dmode wstr op suffix | |
6159 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-16-indirect- dmode) (.sym Imm-40- smode)) | |
6160 | ; sem) | |
6161 | ; (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-indirect dmode wstr op suffix | |
6162 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-8-indirect- dmode) (.sym Imm-32- smode)) | |
6163 | ; sem) | |
6164 | ) | |
6165 | ) | |
6166 | ||
6167 | (define-pmacro (binary-arith-imm-dst-mach mach op suffix opc1 opc2 opc3 sem) | |
6168 | (begin | |
6169 | (.apply (.sym binary-arith mach -imm-dst-defn) (QI QI .b 0 op suffix opc1 opc2 opc3 sem)) | |
6170 | (.apply (.sym binary-arith mach -imm-dst-defn) (HI HI .w 1 op suffix opc1 opc2 opc3 sem)) | |
6171 | ) | |
6172 | ) | |
6173 | ||
6174 | (define-pmacro (binary-arith-imm-dst op suffix opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem) | |
6175 | (begin | |
6176 | (binary-arith-imm-dst-mach 16 op suffix opc16-1 opc16-2 opc16-3 sem) | |
6177 | (binary-arith-imm-dst-mach 32 op suffix opc32-1 opc32-2 opc32-3 sem) | |
6178 | ) | |
6179 | ) | |
6180 | ||
6181 | ;------------------------------------------------------------- | |
6182 | ;<arith>.size:Q #imm4,dst -- for m16c and m32c | |
6183 | ;------------------------------------------------------------- | |
6184 | ||
6185 | (define-pmacro (binary-arith-imm4-dst-defn mach src dstgroup mode wstr op encoding sem) | |
6186 | (dni (.sym op mach wstr - imm4-Q - dstgroup) | |
6187 | (.str op wstr " " mach "-imm4-Q-" dstgroup "-" mode) | |
6188 | ((machine mach)) | |
6189 | (.str op wstr "$Q #${" src "},${dst" mach "-" dstgroup "-" mode "}") | |
6190 | encoding | |
6191 | (sem mode src (.sym dst mach - dstgroup - mode)) | |
6192 | ()) | |
6193 | ) | |
6194 | ||
6195 | ; m16c variants | |
6196 | (define-pmacro (binary-arith16-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem) | |
6197 | (binary-arith-imm4-dst-defn 16 Imm-8-s4 16 mode wstr op | |
6198 | (+ opc1 opc2 (f-7-1 wbit2) Imm-8-s4 (.sym dst16-16- mode)) | |
6199 | sem) | |
6200 | ) | |
6201 | ||
6202 | (define-pmacro (binary-arith16-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem) | |
6203 | (binary-arith-imm4-dst-defn 16 Imm-sh-8-s4 16 mode wstr op | |
6204 | (+ opc1 opc2 (f-7-1 wbit2) Imm-sh-8-s4 (.sym dst16-16- mode)) | |
6205 | sem) | |
6206 | ) | |
6207 | ||
6208 | ; m32c variants | |
6209 | (define-pmacro (binary-arith32-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem) | |
6210 | (begin | |
6211 | ; Multi insns are tried for assembly in the reverse order in which they appear here, so | |
6212 | ; define the absolute-indirect insns first in order to prevent them from being selected | |
6213 | ; when the mode is register-indirect | |
6214 | ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-absolute-indirect mode wstr op | |
6215 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-absolute-indirect- mode) (f-18-2 opc2) Imm-20-s4) | |
6216 | ; sem) | |
6217 | (binary-arith-imm4-dst-defn 32 Imm-12-s4 16-Unprefixed mode wstr op | |
6218 | (+ (f-0-3 opc1) (f-3-1 wbit1) (f-7-1 wbit2) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) Imm-12-s4) | |
6219 | sem) | |
6220 | ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-indirect mode wstr op | |
6221 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-indirect- mode) (f-18-2 opc2) Imm-20-s4) | |
6222 | ; sem) | |
6223 | ) | |
6224 | ) | |
6225 | ||
6226 | (define-pmacro (binary-arith32-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem) | |
6227 | (begin | |
6228 | ; Multi insns are tried for assembly in the reverse order in which they appear here, so | |
6229 | ; define the absolute-indirect insns first in order to prevent them from being selected | |
6230 | ; when the mode is register-indirect | |
6231 | ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-absolute-indirect mode wstr op | |
6232 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-absolute-indirect- mode) (f-18-2 opc2) Imm-sh-20-s4) | |
6233 | ; sem) | |
6234 | (binary-arith-imm4-dst-defn 32 Imm-sh-12-s4 16-Unprefixed mode wstr op | |
6235 | (+ (f-0-3 opc1) (f-3-1 wbit1) (f-7-1 wbit2) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) Imm-sh-12-s4) | |
6236 | sem) | |
6237 | ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-indirect mode wstr op | |
6238 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-indirect- mode) (f-18-2 opc2) Imm-sh-20-s4) | |
6239 | ; sem) | |
6240 | ) | |
6241 | ) | |
6242 | ||
6243 | (define-pmacro (binary-arith-imm4-dst-mach mach op opc1 opc2 sem) | |
6244 | (begin | |
6245 | (.apply (.sym binary-arith mach -imm4-dst-defn) (QI .b 0 0 op opc1 opc2 sem)) | |
6246 | (.apply (.sym binary-arith mach -imm4-dst-defn) (HI .w 0 1 op opc1 opc2 sem)) | |
6247 | ) | |
6248 | ) | |
6249 | ||
6250 | (define-pmacro (binary-arith-imm4-dst op opc16-1 opc16-2 opc32-1 opc32-2 sem) | |
6251 | (begin | |
6252 | (binary-arith-imm4-dst-mach 16 op opc16-1 opc16-2 sem) | |
6253 | (binary-arith-imm4-dst-mach 32 op opc32-1 opc32-2 sem) | |
6254 | ) | |
6255 | ) | |
6256 | ||
6257 | ;------------------------------------------------------------- | |
6258 | ;<arith>.size:G src,dst -- for m16c and m32c | |
6259 | ;------------------------------------------------------------- | |
6260 | ||
6261 | (define-pmacro (binary-arith-src-dst-defn mach srcgroup dstgroup smode dmode wstr op suffix encoding sem) | |
6262 | (dni (.sym op mach wstr - srcgroup - dstgroup) | |
6263 | (.str op wstr " dst" mach "-" srcgroup "-" dstgroup "-" dmode) | |
6264 | ((machine mach)) | |
6265 | (.str op wstr "$" suffix " ${src" mach "-" srcgroup "-" smode "},${dst" mach "-" dstgroup "-" dmode "}") | |
6266 | encoding | |
6267 | (sem dmode (.sym src mach - srcgroup - smode) (.sym dst mach - dstgroup - dmode)) | |
6268 | ()) | |
6269 | ) | |
6270 | ||
6271 | ; m16c variants | |
6272 | (define-pmacro (binary-arith16-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem) | |
6273 | (begin | |
6274 | (binary-arith-src-dst-defn 16 basic 16 smode dmode wstr op suffix | |
6275 | (+ opc1 opc2 (f-7-1 wbit) (.sym src16-basic- smode) (.sym dst16-16- dmode)) | |
6276 | sem) | |
6277 | (binary-arith-src-dst-defn 16 16-16 32 smode dmode wstr op suffix | |
6278 | (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-16- smode) (.sym dst16-32- dmode)) | |
6279 | sem) | |
6280 | (binary-arith-src-dst-defn 16 16-8 24 smode dmode wstr op suffix | |
6281 | (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-8- smode) (.sym dst16-24- dmode)) | |
6282 | sem) | |
6283 | ) | |
6284 | ) | |
6285 | ||
6286 | ; m32c Prefixed variants | |
6287 | (define-pmacro (binary-arith32-src-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 sem) | |
6288 | (begin | |
6289 | (binary-arith-src-dst-defn 32 basic-Prefixed 24-Prefixed smode dmode wstr op suffix | |
6290 | (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-basic-Prefixed- smode) (.sym dst32-24-Prefixed- dmode) (f-20-4 opc2)) | |
6291 | sem) | |
6292 | (binary-arith-src-dst-defn 32 24-24-Prefixed 48-Prefixed smode dmode wstr op suffix | |
6293 | (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2)) | |
6294 | sem) | |
6295 | (binary-arith-src-dst-defn 32 24-16-Prefixed 40-Prefixed smode dmode wstr op suffix | |
6296 | (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2)) | |
6297 | sem) | |
6298 | (binary-arith-src-dst-defn 32 24-8-Prefixed 32-Prefixed smode dmode wstr op suffix | |
6299 | (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-Prefixed- dmode) (f-20-4 opc2)) | |
6300 | sem) | |
6301 | ) | |
6302 | ) | |
6303 | ||
6304 | ; all m32c variants | |
6305 | (define-pmacro (binary-arith32-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem) | |
6306 | (begin | |
6307 | ; Multi insns are tried for assembly in the reverse order in which they appear here, so | |
6308 | ; define the absolute-indirect insns first in order to prevent them from being selected | |
6309 | ; when the mode is register-indirect | |
6310 | ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-absolute-indirect smode dmode wstr op suffix | |
6311 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6312 | ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2)) | |
6313 | ; sem) | |
6314 | ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-absolute-indirect smode dmode wstr op suffix | |
6315 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6316 | ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2)) | |
6317 | ; sem) | |
6318 | ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-Prefixed smode dmode wstr op suffix | |
6319 | ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) | |
6320 | ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2)) | |
6321 | ; sem) | |
6322 | ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-Prefixed smode dmode wstr op suffix | |
6323 | ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) | |
6324 | ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2)) | |
6325 | ; sem) | |
6326 | ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-indirect smode dmode wstr op suffix | |
6327 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6328 | ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2)) | |
6329 | ; sem) | |
6330 | ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-indirect smode dmode wstr op suffix | |
6331 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6332 | ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2)) | |
6333 | ; sem) | |
6334 | ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-absolute-indirect smode dmode wstr op suffix | |
6335 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6336 | ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2)) | |
6337 | ; sem) | |
6338 | ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-absolute-indirect smode dmode wstr op suffix | |
6339 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6340 | ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2)) | |
6341 | ; sem) | |
6342 | ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-absolute-indirect smode dmode wstr op suffix | |
6343 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6344 | ; (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2)) | |
6345 | ; sem) | |
6346 | ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-absolute-indirect smode dmode wstr op suffix | |
6347 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6348 | ; (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2)) | |
6349 | ; sem) | |
6350 | ; (binary-arith-src-dst-defn 32 basic-indirect 24-absolute-indirect smode dmode wstr op suffix | |
6351 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6352 | ; (.sym src32-basic-indirect- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2)) | |
6353 | ; sem) | |
6354 | ; (binary-arith-src-dst-defn 32 24-24-indirect 48-absolute-indirect smode dmode wstr op suffix | |
6355 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6356 | ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2)) | |
6357 | ; sem) | |
6358 | ; (binary-arith-src-dst-defn 32 24-16-indirect 40-absolute-indirect smode dmode wstr op suffix | |
6359 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6360 | ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2)) | |
6361 | ; sem) | |
6362 | ; (binary-arith-src-dst-defn 32 24-8-indirect 32-absolute-indirect smode dmode wstr op suffix | |
6363 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6364 | ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2)) | |
6365 | ; sem) | |
6366 | (binary-arith-src-dst-defn 32 basic-Unprefixed 16-Unprefixed smode dmode wstr op suffix | |
6367 | (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-basic-Unprefixed- smode) (.sym dst32-16-Unprefixed- dmode) (f-12-4 opc2)) | |
6368 | sem) | |
6369 | (binary-arith-src-dst-defn 32 16-24-Unprefixed 40-Unprefixed smode dmode wstr op suffix | |
6370 | (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-24-Unprefixed- smode) (.sym dst32-40-Unprefixed- dmode) (f-12-4 opc2)) | |
6371 | sem) | |
6372 | (binary-arith-src-dst-defn 32 16-16-Unprefixed 32-Unprefixed smode dmode wstr op suffix | |
6373 | (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-16-Unprefixed- smode) (.sym dst32-32-Unprefixed- dmode) (f-12-4 opc2)) | |
6374 | sem) | |
6375 | (binary-arith-src-dst-defn 32 16-8-Unprefixed 24-Unprefixed smode dmode wstr op suffix | |
6376 | (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-8-Unprefixed- smode) (.sym dst32-24-Unprefixed- dmode) (f-12-4 opc2)) | |
6377 | sem) | |
6378 | ; (binary-arith-src-dst-defn 32 basic-indirect 24-Prefixed smode dmode wstr op suffix | |
6379 | ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) | |
6380 | ; (.sym src32-basic-indirect- smode) (.sym dst32-24-Prefixed- dmode) (f-20-4 opc2)) | |
6381 | ; sem) | |
6382 | ; (binary-arith-src-dst-defn 32 24-24-indirect 48-Prefixed smode dmode wstr op suffix | |
6383 | ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) | |
6384 | ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2)) | |
6385 | ; sem) | |
6386 | ; (binary-arith-src-dst-defn 32 24-16-indirect 40-Prefixed smode dmode wstr op suffix | |
6387 | ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) | |
6388 | ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2)) | |
6389 | ; sem) | |
6390 | ; (binary-arith-src-dst-defn 32 24-8-indirect 32-Prefixed smode dmode wstr op suffix | |
6391 | ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) | |
6392 | ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-Prefixed- dmode) (f-20-4 opc2)) | |
6393 | ; sem) | |
6394 | ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-indirect smode dmode wstr op suffix | |
6395 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6396 | ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2)) | |
6397 | ; sem) | |
6398 | ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-indirect smode dmode wstr op suffix | |
6399 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6400 | ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2)) | |
6401 | ; sem) | |
6402 | ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-indirect smode dmode wstr op suffix | |
6403 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6404 | ; (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2)) | |
6405 | ; sem) | |
6406 | ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-indirect smode dmode wstr op suffix | |
6407 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6408 | ; (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2)) | |
6409 | ; sem) | |
6410 | ; (binary-arith-src-dst-defn 32 basic-indirect 24-indirect smode dmode wstr op suffix | |
6411 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6412 | ; (.sym src32-basic-indirect- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2)) | |
6413 | ; sem) | |
6414 | ; (binary-arith-src-dst-defn 32 24-24-indirect 48-indirect smode dmode wstr op suffix | |
6415 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6416 | ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2)) | |
6417 | ; sem) | |
6418 | ; (binary-arith-src-dst-defn 32 24-16-indirect 40-indirect smode dmode wstr op suffix | |
6419 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6420 | ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2)) | |
6421 | ; sem) | |
6422 | ; (binary-arith-src-dst-defn 32 24-8-indirect 32-indirect smode dmode wstr op suffix | |
6423 | ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit) | |
6424 | ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2)) | |
6425 | ; sem) | |
6426 | ) | |
6427 | ) | |
6428 | ||
6429 | (define-pmacro (binary-arith-src-dst-mach mach op suffix opc1 opc2 sem) | |
6430 | (begin | |
6431 | (.apply (.sym binary-arith mach -src-dst-defn) (QI QI .b 0 op suffix opc1 opc2 sem)) | |
6432 | (.apply (.sym binary-arith mach -src-dst-defn) (HI HI .w 1 op suffix opc1 opc2 sem)) | |
6433 | ) | |
6434 | ) | |
6435 | ||
6436 | (define-pmacro (binary-arith-src-dst op suffix opc16-1 opc16-2 opc32-1 opc32-2 sem) | |
6437 | (begin | |
6438 | (binary-arith-src-dst-mach 16 op suffix opc16-1 opc16-2 sem) | |
6439 | (binary-arith-src-dst-mach 32 op suffix opc32-1 opc32-2 sem) | |
6440 | ) | |
6441 | ) | |
6442 | ||
6443 | ;------------------------------------------------------------- | |
6444 | ;<arith>.size:S #imm,dst -- for m32c | |
6445 | ;------------------------------------------------------------- | |
6446 | ||
6447 | (define-pmacro (binary-arith32-s-imm-dst-defn src dstgroup mode wstr op encoding sem) | |
6448 | (dni (.sym op 32 wstr - imm-S - dstgroup) | |
6449 | (.str op wstr " 32-imm-S-" dstgroup "-" mode) | |
6450 | ((machine 32)) | |
6451 | (.str op wstr "$S #${" src "},${dst32-" dstgroup "-" mode "}") | |
6452 | encoding | |
6453 | (sem mode src (.sym dst32- dstgroup - mode)) | |
6454 | ()) | |
6455 | ) | |
6456 | ||
6457 | (define-pmacro (binary-arith32-z-imm-dst-defn src dstgroup mode wstr op encoding sem) | |
6458 | (dni (.sym op 32 wstr - imm-Z - dstgroup) | |
6459 | (.str op wstr " 32-imm-Z-" dstgroup "-" mode) | |
6460 | ((machine 32)) | |
6461 | (.str op wstr "$Z #0,${dst32-" dstgroup "-" mode "}") | |
6462 | encoding | |
6463 | (sem mode (const 0) (.sym dst32- dstgroup - mode)) | |
6464 | ()) | |
6465 | ) | |
6466 | ||
6467 | (define-pmacro (binary-arith32-s-imm-dst mode wstr wbit op opc1 opc2 sem) | |
6468 | (begin | |
6469 | ; (binary-arith32-s-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op | |
6470 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-absolute-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-32- mode)) | |
6471 | ; sem) | |
6472 | (binary-arith32-s-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op | |
6473 | (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-8- mode)) | |
6474 | sem) | |
6475 | (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op | |
6476 | (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-24- mode)) | |
6477 | sem) | |
6478 | (binary-arith32-s-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op | |
6479 | (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-16- mode)) | |
6480 | sem) | |
6481 | ; (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op | |
6482 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-8-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-24- mode)) | |
6483 | ; sem) | |
6484 | ) | |
6485 | ) | |
6486 | ||
6487 | (define-pmacro (binary-arith32-z-imm-dst mode wstr wbit op opc1 opc2 sem) | |
6488 | (begin | |
6489 | ; (binary-arith32-z-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op | |
6490 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-absolute-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-32- mode)) | |
6491 | ; sem) | |
6492 | (binary-arith32-z-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op | |
6493 | (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit)) | |
6494 | sem) | |
6495 | (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op | |
6496 | (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit)) | |
6497 | sem) | |
6498 | (binary-arith32-z-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op | |
6499 | (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit)) | |
6500 | sem) | |
6501 | ; (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op | |
6502 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-8-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-24- mode)) | |
6503 | ; sem) | |
6504 | ) | |
6505 | ) | |
6506 | ||
6507 | ;------------------------------------------------------------- | |
6508 | ;<arith>.L:S #imm1,An -- for m32c | |
6509 | ;------------------------------------------------------------- | |
6510 | ||
6511 | (define-pmacro (binary-arith32-l-s-imm1-an op opc1 opc2 sem) | |
6512 | (begin | |
6513 | (dni (.sym op 32.l-s-imm1-S-an) | |
6514 | (.str op ".l 32-imm1-S-an") | |
6515 | ((machine 32)) | |
6516 | (.str op ".l$S #${Imm1-S},${dst32-an-S}") | |
6517 | (+ opc1 Imm1-S opc2 dst32-an-S) | |
6518 | (sem SI Imm1-S dst32-an-S) | |
6519 | ()) | |
6520 | ) | |
6521 | ) | |
6522 | ||
6523 | ;------------------------------------------------------------- | |
6524 | ;<arith>.L:Q #imm3,sp -- for m32c | |
6525 | ;------------------------------------------------------------- | |
6526 | ||
6527 | (define-pmacro (binary-arith32-l-q-imm3-sp op opc1 opc2 sem) | |
6528 | (begin | |
6529 | (dni (.sym op 32.l-imm3-Q) | |
6530 | (.str op ".l 32-imm3-Q") | |
6531 | ((machine 32)) | |
6532 | (.str op ".l$Q #${Imm3-S},sp") | |
6533 | (+ opc1 Imm3-S opc2) | |
6534 | (sem SI Imm3-S sp) | |
6535 | ()) | |
6536 | ) | |
6537 | ) | |
6538 | ||
6539 | ;------------------------------------------------------------- | |
6540 | ;<arith>.L:S #imm8,sp -- for m32c | |
6541 | ;------------------------------------------------------------- | |
6542 | ||
6543 | (define-pmacro (binary-arith32-l-s-imm8-sp op opc1 opc2 opc3 opc4 sem) | |
6544 | (begin | |
6545 | (dni (.sym op 32.l-imm8-S) | |
6546 | (.str op ".l 32-imm8-S") | |
6547 | ((machine 32)) | |
6548 | (.str op ".l$S #${Imm-16-QI},sp") | |
6549 | (+ opc1 opc2 opc3 opc4 Imm-16-QI) | |
6550 | (sem SI Imm-16-QI sp) | |
6551 | ()) | |
6552 | ) | |
6553 | ) | |
6554 | ||
6555 | ;------------------------------------------------------------- | |
6556 | ;<arith>.L:G #imm16,sp -- for m32c | |
6557 | ;------------------------------------------------------------- | |
6558 | ||
6559 | (define-pmacro (binary-arith32-l-g-imm16-sp op opc1 opc2 opc3 opc4 sem) | |
6560 | (begin | |
6561 | (dni (.sym op 32.l-imm16-G) | |
6562 | (.str op ".l 32-imm16-G") | |
6563 | ((machine 32)) | |
6564 | (.str op ".l$G #${Imm-16-HI},sp") | |
6565 | (+ opc1 opc2 opc3 opc4 Imm-16-HI) | |
6566 | (sem SI Imm-16-HI sp) | |
6567 | ()) | |
6568 | ) | |
6569 | ) | |
6570 | ||
6571 | ;------------------------------------------------------------- | |
6572 | ;<arith>jnz.size #imm4,dst,label -- for m16c and m32c | |
6573 | ;------------------------------------------------------------- | |
6574 | ||
6575 | (define-pmacro (arith-jnz-imm4-dst-defn mach src dstgroup label mode wstr op encoding sem) | |
6576 | (dni (.sym op mach wstr - imm4 - dstgroup) | |
6577 | (.str op wstr " " mach "-imm4-" dstgroup "-" label "-" mode) | |
6578 | ((machine mach)) | |
6579 | (.str op wstr " #${" src "},${dst" mach "-" dstgroup "-" mode "},${" label "}") | |
6580 | encoding | |
6581 | (sem mode src (.sym dst mach - dstgroup - mode) label) | |
6582 | ()) | |
6583 | ) | |
6584 | ||
6585 | ; m16c variants | |
c6552317 | 6586 | (define-pmacro (arith-jnz16-imm4-dst-defn mode wstr wbit op i4n opc1 opc2 sem) |
49f58d10 | 6587 | (begin |
c6552317 DD |
6588 | (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) basic Lab-16-8 mode wstr op |
6589 | (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-basic- mode) Lab-16-8) | |
49f58d10 | 6590 | sem) |
c6552317 DD |
6591 | (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) 16-16 Lab-32-8 mode wstr op |
6592 | (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-16-16- mode) Lab-16-8) | |
49f58d10 | 6593 | sem) |
c6552317 DD |
6594 | (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) 16-8 Lab-24-8 mode wstr op |
6595 | (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-16-8- mode) Lab-16-8) | |
49f58d10 JB |
6596 | sem) |
6597 | ) | |
6598 | ) | |
6599 | ||
6600 | ; m32c variants | |
c6552317 | 6601 | (define-pmacro (arith-jnz32-imm4-dst-defn mode wstr wbit op i4n opc1 opc2 sem) |
49f58d10 | 6602 | (begin |
c6552317 DD |
6603 | (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) basic-Unprefixed Lab-16-8 mode wstr op |
6604 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-16-8) | |
49f58d10 | 6605 | sem) |
c6552317 DD |
6606 | (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-24-Unprefixed Lab-40-8 mode wstr op |
6607 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-40-8) | |
49f58d10 | 6608 | sem) |
c6552317 DD |
6609 | (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-16-Unprefixed Lab-32-8 mode wstr op |
6610 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-32-8) | |
49f58d10 | 6611 | sem) |
c6552317 DD |
6612 | (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-8-Unprefixed Lab-24-8 mode wstr op |
6613 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-24-8) | |
49f58d10 JB |
6614 | sem) |
6615 | ) | |
6616 | ) | |
6617 | ||
c6552317 | 6618 | (define-pmacro (arith-jnz-imm4-dst-mach mach op i4n opc1 opc2 sem) |
49f58d10 | 6619 | (begin |
c6552317 DD |
6620 | (.apply (.sym arith-jnz mach -imm4-dst-defn) (QI .b 0 op i4n opc1 opc2 sem)) |
6621 | (.apply (.sym arith-jnz mach -imm4-dst-defn) (HI .w 1 op i4n opc1 opc2 sem)) | |
49f58d10 JB |
6622 | ) |
6623 | ) | |
6624 | ||
c6552317 | 6625 | (define-pmacro (arith-jnz-imm4-dst op i4n opc16-1 opc16-2 opc32-1 opc32-2 sem) |
49f58d10 | 6626 | (begin |
c6552317 DD |
6627 | (arith-jnz-imm4-dst-mach 16 op i4n opc16-1 opc16-2 sem) |
6628 | (arith-jnz-imm4-dst-mach 32 op i4n opc32-1 opc32-2 sem) | |
49f58d10 JB |
6629 | ) |
6630 | ) | |
6631 | ||
6632 | ;------------------------------------------------------------- | |
6633 | ;mov.size dsp8[sp],dst -- for m16c and m32c | |
6634 | ;------------------------------------------------------------- | |
6635 | (define-pmacro (mov-dspsp-dst-defn mach dstgroup dsp mode wstr op encoding sem) | |
6636 | (dni (.sym op mach wstr -dspsp-dst- dstgroup) | |
6637 | (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode) | |
6638 | ((machine mach)) | |
f75eb1c0 | 6639 | (.str op wstr "$G ${" dsp "}[sp],${dst" mach "-" dstgroup "-" mode "}") |
49f58d10 JB |
6640 | encoding |
6641 | (sem mach mode dsp (.sym dst mach - dstgroup - mode)) | |
6642 | ()) | |
6643 | ) | |
6644 | (define-pmacro (mov-src-dspsp-defn mach dstgroup dsp mode wstr op encoding sem) | |
6645 | (dni (.sym op mach wstr -dst-dspsp- dstgroup) | |
6646 | (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode) | |
6647 | ((machine mach)) | |
f75eb1c0 | 6648 | (.str op wstr "$G ${dst" mach "-" dstgroup "-" mode "},${" dsp "}[sp]") |
49f58d10 JB |
6649 | encoding |
6650 | (sem mach mode (.sym dst mach - dstgroup - mode) dsp) | |
6651 | ()) | |
6652 | ) | |
6653 | ||
6654 | ; m16c variants | |
6655 | (define-pmacro (mov16-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem) | |
6656 | (begin | |
f75eb1c0 DD |
6657 | (mov-dspsp-dst-defn 16 basic Dsp-16-s8 mode wstr op |
6658 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-s8) | |
49f58d10 | 6659 | sem) |
f75eb1c0 DD |
6660 | (mov-dspsp-dst-defn 16 16-16 Dsp-32-s8 mode wstr op |
6661 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-s8) | |
49f58d10 | 6662 | sem) |
f75eb1c0 DD |
6663 | (mov-dspsp-dst-defn 16 16-8 Dsp-24-s8 mode wstr op |
6664 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-s8) | |
49f58d10 JB |
6665 | sem) |
6666 | ) | |
6667 | ) | |
6668 | ||
6669 | (define-pmacro (mov16-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem) | |
6670 | (begin | |
f75eb1c0 DD |
6671 | (mov-src-dspsp-defn 16 basic Dsp-16-s8 mode wstr op |
6672 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-s8) | |
49f58d10 | 6673 | sem) |
f75eb1c0 DD |
6674 | (mov-src-dspsp-defn 16 16-16 Dsp-32-s8 mode wstr op |
6675 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-s8) | |
49f58d10 | 6676 | sem) |
f75eb1c0 DD |
6677 | (mov-src-dspsp-defn 16 16-8 Dsp-24-s8 mode wstr op |
6678 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-s8) | |
49f58d10 JB |
6679 | sem) |
6680 | ) | |
6681 | ) | |
6682 | ||
6683 | ; m32c variants | |
6684 | (define-pmacro (mov32-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem) | |
6685 | (begin | |
f75eb1c0 DD |
6686 | (mov-dspsp-dst-defn 32 basic-Unprefixed Dsp-16-s8 mode wstr op |
6687 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-s8) | |
49f58d10 | 6688 | sem) |
f75eb1c0 DD |
6689 | (mov-dspsp-dst-defn 32 16-24-Unprefixed Dsp-40-s8 mode wstr op |
6690 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-40-s8) | |
49f58d10 | 6691 | sem) |
f75eb1c0 DD |
6692 | (mov-dspsp-dst-defn 32 16-16-Unprefixed Dsp-32-s8 mode wstr op |
6693 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-32-s8) | |
49f58d10 | 6694 | sem) |
f75eb1c0 DD |
6695 | (mov-dspsp-dst-defn 32 16-8-Unprefixed Dsp-24-s8 mode wstr op |
6696 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-24-s8) | |
49f58d10 JB |
6697 | sem) |
6698 | ) | |
6699 | ) | |
6700 | (define-pmacro (mov32-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem) | |
6701 | (begin | |
f75eb1c0 DD |
6702 | (mov-src-dspsp-defn 32 basic-Unprefixed Dsp-16-s8 mode wstr op |
6703 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-s8) | |
49f58d10 | 6704 | sem) |
f75eb1c0 DD |
6705 | (mov-src-dspsp-defn 32 16-24-Unprefixed Dsp-40-s8 mode wstr op |
6706 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-40-s8) | |
49f58d10 | 6707 | sem) |
f75eb1c0 DD |
6708 | (mov-src-dspsp-defn 32 16-16-Unprefixed Dsp-32-s8 mode wstr op |
6709 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-32-s8) | |
49f58d10 | 6710 | sem) |
f75eb1c0 DD |
6711 | (mov-src-dspsp-defn 32 16-8-Unprefixed Dsp-24-s8 mode wstr op |
6712 | (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-24-s8) | |
49f58d10 JB |
6713 | sem) |
6714 | ) | |
6715 | ) | |
6716 | ||
6717 | (define-pmacro (mov-src-dspsp-mach mach op opc1 opc2 opc3 sem) | |
6718 | (begin | |
6719 | (.apply (.sym mov mach -src-dspsp-defn) (QI .b 0 op opc1 opc2 opc3 sem)) | |
6720 | (.apply (.sym mov mach -src-dspsp-defn) (HI .w 1 op opc1 opc2 opc3 sem)) | |
6721 | ) | |
6722 | ) | |
6723 | ||
6724 | (define-pmacro (mov-dspsp-dst-mach mach op opc1 opc2 opc3 sem) | |
6725 | (begin | |
6726 | (.apply (.sym mov mach -dspsp-dst-defn) (QI .b 0 op opc1 opc2 opc3 sem)) | |
6727 | (.apply (.sym mov mach -dspsp-dst-defn) (HI .w 1 op opc1 opc2 opc3 sem)) | |
6728 | ) | |
6729 | ) | |
6730 | ||
6731 | (define-pmacro (mov-dspsp-dst op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem) | |
6732 | (begin | |
6733 | (mov-dspsp-dst-mach 16 op opc16-1 opc16-2 opc16-3 sem) | |
6734 | (mov-dspsp-dst-mach 32 op opc32-1 opc32-2 opc32-3 sem) | |
6735 | ) | |
6736 | ) | |
6737 | (define-pmacro (mov-src-dspsp op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem) | |
6738 | (begin | |
6739 | (mov-src-dspsp-mach 16 op opc16-1 opc16-2 opc16-3 sem) | |
6740 | (mov-src-dspsp-mach 32 op opc32-1 opc32-2 opc32-3 sem) | |
6741 | ) | |
6742 | ) | |
6743 | ||
6744 | ;------------------------------------------------------------- | |
6745 | ; lde dsp24,dst -- for m16c | |
49f58d10 JB |
6746 | ;------------------------------------------------------------- |
6747 | ||
a1a280bb DD |
6748 | (define-pmacro (lde-dst-dsp mode wstr wbit dstgroup srcdisp) |
6749 | (begin | |
6750 | ||
6751 | (dni (.sym lde wstr - dstgroup -u20) | |
6752 | (.str "lde" wstr "-" dstgroup "-u20") | |
6753 | ((machine 16)) | |
6754 | (.str "lde" wstr " ${" srcdisp "},${dst16-" dstgroup "-" mode "}") | |
6755 | (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x8) | |
6756 | (.sym dst16- dstgroup - mode) srcdisp) | |
6757 | (nop) | |
6758 | ()) | |
49f58d10 | 6759 | |
a1a280bb DD |
6760 | (dni (.sym lde wstr - dstgroup -u20a0) |
6761 | (.str "lde" wstr "-" dstgroup "-u20a0") | |
6762 | ((machine 16)) | |
6763 | (.str "lde" wstr " ${" srcdisp "}[a0],${dst16-" dstgroup "-" mode "}") | |
6764 | (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x9) | |
6765 | (.sym dst16- dstgroup - mode) srcdisp) | |
6766 | (nop) | |
6767 | ()) | |
6768 | ||
6769 | (dni (.sym lde wstr - dstgroup -a1a0) | |
6770 | (.str "lde" wstr "-" dstgroup "-a1a0") | |
6771 | ((machine 16)) | |
6772 | (.str "lde" wstr " [a1a0],${dst16-" dstgroup "-" mode "}") | |
6773 | (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #xa) | |
6774 | (.sym dst16- dstgroup - mode)) | |
6775 | (nop) | |
6776 | ()) | |
6777 | ) | |
6778 | ) | |
6779 | ||
6780 | (define-pmacro (lde-dst mode wstr wbit) | |
49f58d10 | 6781 | (begin |
a1a280bb DD |
6782 | ; like: QI .b 0 |
6783 | (lde-dst-dsp mode wstr wbit basic Dsp-16-u20) | |
6784 | (lde-dst-dsp mode wstr wbit 16-8 Dsp-24-u20) | |
6785 | (lde-dst-dsp mode wstr wbit 16-16 Dsp-32-u20) | |
49f58d10 JB |
6786 | ) |
6787 | ) | |
6788 | ||
6789 | ;------------------------------------------------------------- | |
a1a280bb | 6790 | ; ste dst,dsp24 -- for m16c |
49f58d10 JB |
6791 | ;------------------------------------------------------------- |
6792 | ||
a1a280bb DD |
6793 | (define-pmacro (ste-dst-dsp mode wstr wbit dstgroup srcdisp) |
6794 | (begin | |
6795 | ||
6796 | (dni (.sym ste wstr - dstgroup -u20) | |
6797 | (.str "ste" wstr "-" dstgroup "-u20") | |
6798 | ((machine 16)) | |
6799 | (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},${" srcdisp "}") | |
6800 | (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x0) | |
6801 | (.sym dst16- dstgroup - mode) srcdisp) | |
6802 | (nop) | |
6803 | ()) | |
6804 | ||
6805 | (dni (.sym ste wstr - dstgroup -u20a0) | |
6806 | (.str "ste" wstr "-" dstgroup "-u20a0") | |
6807 | ((machine 16)) | |
6808 | (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},${" srcdisp "}[a0]") | |
6809 | (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x1) | |
6810 | (.sym dst16- dstgroup - mode) srcdisp) | |
6811 | (nop) | |
6812 | ()) | |
49f58d10 | 6813 | |
a1a280bb DD |
6814 | (dni (.sym ste wstr - dstgroup -a1a0) |
6815 | (.str "ste" wstr "-" dstgroup "-a1a0") | |
6816 | ((machine 16)) | |
6817 | (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},[a1a0]") | |
6818 | (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x2) | |
6819 | (.sym dst16- dstgroup - mode)) | |
6820 | (nop) | |
6821 | ()) | |
6822 | ) | |
6823 | ) | |
6824 | ||
6825 | (define-pmacro (ste-dst mode wstr wbit) | |
49f58d10 | 6826 | (begin |
a1a280bb DD |
6827 | ; like: QI .b 0 |
6828 | (ste-dst-dsp mode wstr wbit basic Dsp-16-u20) | |
6829 | (ste-dst-dsp mode wstr wbit 16-8 Dsp-24-u20) | |
6830 | (ste-dst-dsp mode wstr wbit 16-16 Dsp-32-u20) | |
49f58d10 JB |
6831 | ) |
6832 | ) | |
6833 | ||
6834 | ;============================================================= | |
6835 | ; Division | |
6836 | ;------------------------------------------------------------- | |
6837 | ||
6838 | (define-pmacro (div-sem divop modop opmode reg src quot rem max min) | |
6839 | (sequence () | |
6840 | (if (eq src 0) | |
6841 | (set obit (const BI 1)) | |
6842 | (sequence ((opmode quot-result) (opmode rem-result)) | |
6843 | (set quot-result (divop opmode (ext opmode reg) src)) | |
6844 | (set rem-result (modop opmode (ext opmode reg) src)) | |
6845 | (set obit (orif (gt opmode quot-result max) | |
6846 | (lt opmode quot-result min))) | |
6847 | (set quot quot-result) | |
6848 | (set rem rem-result)))) | |
6849 | ) | |
6850 | ||
6851 | ;<divop>.size #imm -- for m16c and m32c | |
6852 | (define-pmacro (div-imm-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem) | |
6853 | (dni (.sym op mach wstr - src) | |
6854 | (.str op mach wstr "-" src) | |
6855 | ((machine mach)) | |
6856 | (.str op wstr " #${" src "}") | |
6857 | encoding | |
6858 | (sem divop modop opmode reg src quot rem max min) | |
6859 | ()) | |
6860 | ) | |
6861 | (define-pmacro (div16-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem) | |
6862 | (div-imm-defn 16 wstr op (.sym Imm-16 - smode) | |
6863 | (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16 - smode)) | |
6864 | divop modop opmode reg quot rem max min | |
6865 | sem) | |
6866 | ) | |
6867 | (define-pmacro (div32-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem) | |
6868 | (div-imm-defn 32 wstr op (.sym Imm-16 - smode) | |
6869 | (+ (f-0-4 opc1) (f-4-4 opc2) (f-8-3 opc3) (f-11-1 wbit) (f-12-4 opc4) (.sym Imm-16 - smode)) | |
6870 | divop modop opmode reg quot rem max min | |
6871 | sem) | |
6872 | ) | |
6873 | (define-pmacro (div-imm-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 opc4 sem) | |
6874 | (begin | |
6875 | (.apply (.sym div mach -imm-defn) (QI .b 0 op divop modop opmode R0 R0l R0h max-QI min-QI opc1 opc2 opc3 opc4 sem)) | |
6876 | (.apply (.sym div mach -imm-defn) (HI .w 1 op divop modop opmode R2R0 R0 R2 max-HI min-HI opc1 opc2 opc3 opc4 sem)) | |
6877 | ) | |
6878 | ) | |
6879 | (define-pmacro (div-imm op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 opc16-4 opc32-1 opc32-2 opc32-3 opc32-4 sem) | |
6880 | (begin | |
6881 | (div-imm-mach 16 op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 opc16-4 sem) | |
6882 | (div-imm-mach 32 op divop modop opmode max-QI min-QI max-HI min-HI opc32-1 opc32-2 opc32-3 opc32-4 sem) | |
6883 | ) | |
6884 | ) | |
6885 | ||
6886 | ;<divop>.size src -- for m16c and m32c | |
6887 | (define-pmacro (div-src-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem) | |
6888 | (dni (.sym op mach wstr - src) | |
6889 | (.str op mach wstr "-" src) | |
6890 | ((machine mach)) | |
6891 | (.str op wstr " ${" src "}") | |
6892 | encoding | |
6893 | (sem divop modop opmode reg src quot rem max min) | |
6894 | ()) | |
6895 | ) | |
6896 | (define-pmacro (div16-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem) | |
6897 | (div-src-defn 16 wstr op (.sym dst16-16 - smode) | |
6898 | (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16 - smode)) | |
6899 | divop modop opmode reg quot rem max min | |
6900 | sem) | |
6901 | ) | |
6902 | (define-pmacro (div32-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem) | |
6903 | (begin | |
6904 | ; Multi insns are tried for assembly in the reverse order in which they appear here, so | |
6905 | ; define the absolute-indirect insns first in order to prevent them from being selected | |
6906 | ; when the mode is register-indirect | |
6907 | ; (div-src-defn 32 wstr op (.sym dst32-24-absolute-indirect- smode) | |
6908 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (f-18-2 opc2) (f-20-4 opc3) (.sym dst32-24-absolute-indirect - smode)) | |
6909 | ; divop modop opmode reg quot rem max min | |
6910 | ; sem) | |
6911 | (div-src-defn 32 wstr op (.sym dst32-16-Unprefixed- smode) | |
6912 | (+ (f-0-4 opc1) (f-7-1 wbit) (f-10-2 opc2) (f-12-4 opc3) (.sym dst32-16-Unprefixed- smode)) | |
6913 | divop modop opmode reg quot rem max min | |
6914 | sem) | |
6915 | ; (div-src-defn 32 wstr op (.sym dst32-24-indirect- smode) | |
6916 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (f-18-2 opc2) (f-20-4 opc3) (.sym dst32-24-indirect - smode)) | |
6917 | ; divop modop opmode reg quot rem max min | |
6918 | ; sem) | |
6919 | ) | |
6920 | ) | |
6921 | (define-pmacro (div-src-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 sem) | |
6922 | (begin | |
6923 | (.apply (.sym div mach -src-defn) (QI .b 0 op divop modop opmode R0 R0l R0h max-QI min-QI opc1 opc2 opc3 sem)) | |
6924 | (.apply (.sym div mach -src-defn) (HI .w 1 op divop modop opmode R2R0 R0 R2 max-HI min-HI opc1 opc2 opc3 sem)) | |
6925 | ) | |
6926 | ) | |
6927 | (define-pmacro (div-src op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem) | |
6928 | (begin | |
6929 | (div-src-mach 16 op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 sem) | |
6930 | (div-src-mach 32 op divop modop opmode max-QI min-QI max-HI min-HI opc32-1 opc32-2 opc32-3 sem) | |
6931 | ) | |
6932 | ) | |
6933 | ||
6934 | ;============================================================= | |
6935 | ; Bit manipulation | |
6936 | ; | |
6937 | (define-pmacro (bit-insn-defn mach op suffix opnd encoding sem) | |
6938 | (dni (.sym op mach - suffix - opnd) | |
6939 | (.str op mach ":" suffix " " opnd) | |
6940 | ((machine mach)) | |
6941 | (.str op "$" suffix " ${" opnd "}") | |
6942 | encoding | |
6943 | (sem opnd) | |
6944 | ()) | |
6945 | ) | |
6946 | ||
6947 | (define-pmacro (bitsrc16-defn op opc1 opc2 opc3 sem) | |
6948 | (bit-insn-defn 16 op X bit16-16 | |
6949 | (+ opc1 opc2 opc3 bit16-16) | |
6950 | sem) | |
6951 | ) | |
6952 | ||
6953 | (define-pmacro (bitsrc32-defn op opc1 opc2 opc3 sem) | |
6954 | (begin | |
6955 | (bit-insn-defn 32 op X bit32-24-Prefixed | |
6956 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) bit32-24-Prefixed (f-15-1 opc2) (f-18-3 opc3)) | |
6957 | sem) | |
6958 | ) | |
6959 | ) | |
6960 | ||
6961 | (define-pmacro (bitsrc-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem) | |
6962 | (begin | |
6963 | (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem) | |
6964 | (bitsrc32-defn op opc32-1 opc32-2 opc32-3 sem) | |
6965 | ) | |
6966 | ) | |
6967 | ||
6968 | (define-pmacro (bitdst16-defn op opc1 opc2 opc3 opc4 opc5 opc6 sem) | |
6969 | (begin | |
6970 | (bit-insn-defn 16 op G bit16-16-basic (+ opc1 opc2 opc3 bit16-16-basic) sem) | |
6971 | (bit-insn-defn 16 op G bit16-16-16 (+ opc1 opc2 opc3 bit16-16-16) sem) | |
6972 | (bit-insn-defn 16 op S bit16-11-S (+ opc4 opc5 opc6 bit16-11-S) sem) | |
6973 | (bit-insn-defn 16 op G bit16-16-8 (+ opc1 opc2 opc3 bit16-16-8) sem) | |
6974 | ) | |
6975 | ) | |
6976 | ||
6977 | (define-pmacro (bitdst32-defn op opc1 opc2 opc3 sem) | |
6978 | (begin | |
6979 | (bit-insn-defn 32 op X bit32-16-Unprefixed | |
6980 | (+ (f-0-4 opc1) bit32-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3)) | |
6981 | sem) | |
6982 | ) | |
6983 | ) | |
6984 | ||
6985 | (define-pmacro (bitdstnos-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem) | |
6986 | (begin | |
6987 | (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem) | |
6988 | (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem) | |
6989 | ) | |
6990 | ) | |
6991 | ||
6992 | (define-pmacro (bitdst-insn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 opc32-1 opc32-2 opc32-3 sem) | |
6993 | (begin | |
6994 | (bitdst16-defn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 sem) | |
6995 | (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem) | |
6996 | ) | |
6997 | ) | |
6998 | ||
6999 | ;============================================================= | |
7000 | ; Bit condition | |
7001 | ; | |
7002 | (define-pmacro (bitcond-insn-defn mach op bit-opnd cond-opnd encoding sem) | |
7003 | (dni (.sym op mach - bit-opnd - cond-opnd) | |
7004 | (.str op mach " " bit-opnd " " cond-opnd) | |
7005 | ((machine mach)) | |
7006 | (.str op "${" cond-opnd "} ${" bit-opnd "}") | |
7007 | encoding | |
7008 | (sem mach bit-opnd cond-opnd) | |
7009 | ()) | |
7010 | ) | |
7011 | ||
7012 | (define-pmacro (bitcond16-defn op opc1 opc2 opc3 sem) | |
7013 | (begin | |
7014 | (bitcond-insn-defn 16 op bit16-16-basic cond16-16 (+ opc1 opc2 opc3 bit16-16-basic cond16-16) sem) | |
7015 | (bitcond-insn-defn 16 op bit16-16-16 cond16-32 (+ opc1 opc2 opc3 bit16-16-16 cond16-32) sem) | |
7016 | (bitcond-insn-defn 16 op bit16-16-8 cond16-24 (+ opc1 opc2 opc3 bit16-16-8 cond16-24) sem) | |
7017 | ) | |
7018 | ) | |
7019 | ||
7020 | (define-pmacro (bitcond32-defn op opc1 opc2 opc3 sem) | |
7021 | (begin | |
7022 | (bitcond-insn-defn 32 op bit32-16-24-Unprefixed cond32-40 | |
7023 | (+ (f-0-4 opc1) bit32-16-24-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-40) | |
7024 | sem) | |
7025 | (bitcond-insn-defn 32 op bit32-16-16-Unprefixed cond32-32 | |
7026 | (+ (f-0-4 opc1) bit32-16-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-32) | |
7027 | sem) | |
7028 | (bitcond-insn-defn 32 op bit32-16-8-Unprefixed cond32-24 | |
7029 | (+ (f-0-4 opc1) bit32-16-8-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-24) | |
7030 | sem) | |
7031 | (bitcond-insn-defn 32 op bit32-basic-Unprefixed cond32-16 | |
7032 | (+ (f-0-4 opc1) bit32-basic-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-16) | |
7033 | sem) | |
7034 | ) | |
7035 | ) | |
7036 | ||
7037 | (define-pmacro (bitcond-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem) | |
7038 | (begin | |
7039 | (bitcond16-defn op opc16-1 opc16-2 opc16-3 sem) | |
7040 | (bitcond32-defn op opc32-1 opc32-2 opc32-3 sem) | |
7041 | ) | |
7042 | ) | |
7043 | ||
7044 | ;============================================================= | |
7045 | ;<insn>.size #imm1,#imm2,dst -- for m32c | |
7046 | ; | |
7047 | (define-pmacro (insn-imm1-imm2-dst-defn src1 src2 dstgroup xmode wstr op encoding sem) | |
7048 | (dni (.sym op 32 wstr - src1 - src2 - dstgroup) | |
7049 | (.str op 32 wstr "-" src1 "-" src2 "-" dstgroup "-" xmode) | |
7050 | ((machine 32)) | |
7051 | (.str op wstr " #${" src1 "},#${" src2 "},${dst32-" dstgroup "-" xmode "}") | |
7052 | encoding | |
7053 | (sem xmode src1 src2 (.sym dst32- dstgroup - xmode)) | |
7054 | ()) | |
7055 | ) | |
7056 | ||
7057 | ; m32c Prefixed variants | |
7058 | (define-pmacro (insn32-imm1-imm2-dst-Prefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem) | |
7059 | (begin | |
7060 | (insn-imm1-imm2-dst-defn (.sym Imm-48- xmode) (.sym Imm- base4 - xmode) 24-24-Prefixed xmode wstr op | |
7061 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) | |
7062 | (.sym dst32-24-24-Prefixed- xmode) (.sym Imm-48- xmode) (.sym Imm- base4 - xmode)) | |
7063 | sem) | |
7064 | (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base3 - xmode) 24-16-Prefixed xmode wstr op | |
7065 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) | |
7066 | (.sym dst32-24-16-Prefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base3 - xmode)) | |
7067 | sem) | |
7068 | (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base2 - xmode) 24-8-Prefixed xmode wstr op | |
7069 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) | |
7070 | (.sym dst32-24-8-Prefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base2 - xmode)) | |
7071 | sem) | |
7072 | (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base1 - xmode) basic-Prefixed xmode wstr op | |
7073 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) | |
7074 | (.sym dst32-basic-Prefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base1 - xmode)) | |
7075 | sem) | |
7076 | ) | |
7077 | ) | |
7078 | ||
7079 | ; m32c Unprefixed variants | |
7080 | (define-pmacro (insn32-imm1-imm2-dst-Unprefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem) | |
7081 | (begin | |
7082 | (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base4 - xmode) 16-24-Unprefixed xmode wstr op | |
7083 | (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) | |
7084 | (.sym dst32-16-24-Unprefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base4 - xmode)) | |
7085 | sem) | |
7086 | (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base3 - xmode) 16-16-Unprefixed xmode wstr op | |
7087 | (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) | |
7088 | (.sym dst32-16-16-Unprefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base3 - xmode)) | |
7089 | sem) | |
7090 | (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base2 - xmode) 16-8-Unprefixed xmode wstr op | |
7091 | (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) | |
7092 | (.sym dst32-16-8-Unprefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base2 - xmode)) | |
7093 | sem) | |
7094 | (insn-imm1-imm2-dst-defn (.sym Imm-16- xmode) (.sym Imm- base1 - xmode) basic-Unprefixed xmode wstr op | |
7095 | (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) | |
7096 | (.sym dst32-basic-Unprefixed- xmode) (.sym Imm-16- xmode) (.sym Imm- base1 - xmode)) | |
7097 | sem) | |
7098 | ) | |
7099 | ) | |
7100 | ||
7101 | (define-pmacro (insn-imm1-imm2-dst-Prefixed op opc32-1 opc32-2 opc32-3 sem) | |
7102 | (begin | |
7103 | (insn32-imm1-imm2-dst-Prefixed-defn QI .b 0 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem) | |
7104 | (insn32-imm1-imm2-dst-Prefixed-defn HI .w 1 40 48 56 64 op opc32-1 opc32-2 opc32-3 sem) | |
7105 | ) | |
7106 | ) | |
7107 | (define-pmacro (insn-imm1-imm2-dst-Unprefixed op opc32-1 opc32-2 opc32-3 sem) | |
7108 | (begin | |
7109 | (insn32-imm1-imm2-dst-Unprefixed-defn QI .b 0 24 32 40 48 op opc32-1 opc32-2 opc32-3 sem) | |
7110 | (insn32-imm1-imm2-dst-Unprefixed-defn HI .w 1 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem) | |
7111 | ) | |
7112 | ) | |
7113 | \f | |
7114 | ;============================================================= | |
7115 | ; Insn definitions | |
7116 | ;------------------------------------------------------------- | |
7117 | ; abs - absolute | |
7118 | ;------------------------------------------------------------- | |
7119 | ||
7120 | (define-pmacro (abs-sem mode dst) | |
7121 | (sequence ((mode result)) | |
7122 | (set result (abs mode dst)) | |
7123 | (set obit (eq result dst)) | |
7124 | (set-z-and-s result) | |
7125 | (set dst result)) | |
7126 | ) | |
7127 | (unary-insn abs (f-0-4 7) (f-4-3 3) (f-8-4 #xF) #xA #x1 #xF abs-sem) | |
7128 | ||
7129 | ;------------------------------------------------------------- | |
7130 | ; adcf - addition carry flag | |
7131 | ;------------------------------------------------------------- | |
7132 | ||
7133 | (define-pmacro (adcf-sem mode dst) | |
7134 | (sequence ((mode result)) | |
7135 | (set result (addc mode dst 0 cbit)) | |
7136 | (set obit (add-oflag mode dst 0 cbit)) | |
7137 | (set cbit (add-cflag mode dst 0 cbit)) | |
7138 | (set-z-and-s result) | |
7139 | (set dst result)) | |
7140 | ) | |
7141 | (unary-insn adcf (f-0-4 7) (f-4-3 3) (f-8-4 #xE) #xB #x1 #xE adcf-sem) | |
7142 | ||
7143 | ;------------------------------------------------------------- | |
7144 | ; add - binary addition | |
7145 | ;------------------------------------------------------------- | |
7146 | ||
7147 | (define-pmacro (add-sem mode src1 dst) | |
7148 | (sequence ((mode result)) | |
7149 | (set result (add mode src1 dst)) | |
7150 | (set obit (add-oflag mode src1 dst 0)) | |
7151 | (set cbit (add-cflag mode src1 dst 0)) | |
7152 | (set-z-and-s result) | |
7153 | (set dst result)) | |
7154 | ) | |
7155 | ||
7156 | ; add.L:G #imm32,dst (m32 #2) | |
7157 | (binary-arith32-imm-dst-defn SI SI .l 0 add G #x8 #x3 #x1 add-sem) | |
7158 | ; add.size:G #imm,dst (m16 #1 m32 #1) | |
7159 | (binary-arith-imm-dst add G (f-0-4 7) (f-4-3 3) (f-8-4 4) #x8 #x2 #xE add-sem) | |
7160 | ; add.size:Q #imm4,dst (m16 #2 m32 #3) | |
7161 | (binary-arith-imm4-dst add (f-0-4 #xC) (f-4-3 4) #x7 #x3 add-sem) | |
7162 | (binary-arith32-imm4-dst-defn SI .l 1 0 add #x7 #x3 add-sem) | |
7163 | ; add.b:S #imm8,dst3 (m16 #3) | |
7164 | (binary-arith16-b-S-imm8-dst3 add ".b" (f-0-4 8) (f-4-1 0) add-sem) | |
7165 | ; add.BW:Q #imm4,sp (m16 #7) | |
7166 | (binary-arith16-Q-sp add (f-0-4 7) (f-4-4 #xD) (f-8-4 #xB) add-sem) | |
92e0a941 DD |
7167 | (dnmi add16-bQ-sp "add16-bQ-sp" () |
7168 | "add.b:q #${Imm-12-s4},sp" | |
7169 | (emit add16-wQ-sp Imm-12-s4)) | |
49f58d10 JB |
7170 | ; add.BW:G #imm,sp (m16 #6) |
7171 | (binary-arith16-G-sp add (f-0-4 7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #xB) add-sem) | |
7172 | ; add.BW:G src,dst (m16 #4 m32 #6) | |
7173 | (binary-arith-src-dst add G (f-0-4 #xA) (f-4-3 0) #x1 #x8 add-sem) | |
7174 | ; add.B.S src2,r0l/r0h (m16 #5) | |
7175 | (binary-arith16-b-S-src2 add (f-0-4 2) (f-4-1 0) add-sem) | |
7176 | ; add.L:G src,dst (m32 #7) | |
7177 | (binary-arith32-src-dst-defn SI SI .l 1 add G #x1 #x2 add-sem) | |
7178 | ; add.L:S #imm{1,2},A0/A1 (m32 #5) | |
7179 | (binary-arith32-l-s-imm1-an add (f-0-2 2) (f-3-4 6) add-sem) | |
7180 | ; add.L:Q #imm3,sp (m32 #9) | |
7181 | (binary-arith32-l-q-imm3-sp add (f-0-2 1) (f-4-3 1) add-sem) | |
7182 | ; add.L:S #imm8,sp (m32 #10) | |
7183 | (binary-arith32-l-s-imm8-sp add (f-0-4 #xb) (f-4-4 6) (f-8-4 0) (f-12-4 3) add-sem) | |
7184 | ; add.L:G #imm16,sp (m32 #8) | |
7185 | (binary-arith32-l-g-imm16-sp add (f-0-4 #xb) (f-4-4 6) (f-8-4 1) (f-12-4 3) add-sem) | |
7186 | ; add.BW:S #imm,dst2 (m32 #4) | |
7187 | (binary-arith32-s-imm-dst QI .b 0 add #x0 #x3 add-sem) | |
7188 | (binary-arith32-s-imm-dst HI .w 1 add #x0 #x3 add-sem) | |
7189 | ||
7190 | ;------------------------------------------------------------- | |
7191 | ; adc - binary add with carry | |
7192 | ;------------------------------------------------------------- | |
7193 | ||
7194 | (define-pmacro (addc-sem mode src dst) | |
7195 | (sequence ((mode result)) | |
7196 | (set result (addc mode src dst cbit)) | |
7197 | (set obit (add-oflag mode src dst cbit)) | |
7198 | (set cbit (add-cflag mode src dst cbit)) | |
7199 | (set-z-and-s result) | |
7200 | (set dst result)) | |
7201 | ) | |
7202 | ||
7203 | ; adc.size:G #imm,dst | |
7204 | (binary-arith16-imm-dst-defn QI QI .b 0 adc X (f-0-4 7) (f-4-3 3) (f-8-4 6) addc-sem) | |
7205 | (binary-arith16-imm-dst-defn HI HI .w 1 adc X (f-0-4 7) (f-4-3 3) (f-8-4 6) addc-sem) | |
7206 | (binary-arith32-imm-dst-Prefixed QI QI .b 0 adc X #x8 #x2 #xE addc-sem) | |
7207 | (binary-arith32-imm-dst-Prefixed HI HI .w 1 adc X #x8 #x2 #xE addc-sem) | |
7208 | ||
7209 | ; adc.BW:G src,dst | |
7210 | (binary-arith16-src-dst-defn QI QI .b 0 adc X (f-0-4 #xB) (f-4-3 0) addc-sem) | |
7211 | (binary-arith16-src-dst-defn HI HI .w 1 adc X (f-0-4 #xB) (f-4-3 0) addc-sem) | |
7212 | (binary-arith32-src-dst-Prefixed QI QI .b 0 adc X #x1 #x4 addc-sem) | |
7213 | (binary-arith32-src-dst-Prefixed HI HI .w 1 adc X #x1 #x4 addc-sem) | |
7214 | ||
7215 | ;------------------------------------------------------------- | |
7216 | ; dadc - decimal add with carry | |
7217 | ; dadd - decimal addition | |
7218 | ;------------------------------------------------------------- | |
7219 | ||
7220 | (define-pmacro (dadc-sem mode src dst) | |
7221 | (sequence ((mode result)) | |
7222 | (set result (subc mode dst src (not cbit))) | |
7223 | (set cbit (sub-cflag mode dst src (not cbit))) | |
7224 | (set-z-and-s result) | |
7225 | (set dst result)) | |
7226 | ) | |
7227 | ||
7228 | (define-pmacro (decimal-subtraction16-insn op opc1 opc2) | |
7229 | (begin | |
7230 | ; op.b #imm8,r0l | |
7231 | (dni (.sym op 16.b-imm8) | |
7232 | (.str op ".b #imm8") | |
7233 | ((machine 16)) | |
7234 | (.str op ".b #${Imm-16-QI}") | |
7235 | (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc1) Imm-16-QI) | |
7236 | ((.sym op -sem) QI Imm-16-QI R0l) | |
7237 | ()) | |
7238 | ; op.w #imm16,r0 | |
7239 | (dni (.sym op 16.w-imm16) | |
7240 | (.str op ".b #imm16") | |
7241 | ((machine 16)) | |
7242 | (.str op ".w #${Imm-16-HI}") | |
7243 | (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc1) Imm-16-HI) | |
7244 | ((.sym op -sem) HI Imm-16-HI R0) | |
7245 | ()) | |
7246 | ; op.b #r0h,r0l | |
7247 | (dni (.sym op 16.b-r0h-r0l) | |
7248 | (.str op ".b r0h,r0l") | |
7249 | ((machine 16)) | |
7250 | (.str op ".b r0h,r0l") | |
7251 | (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc2)) | |
7252 | ((.sym op -sem) QI R0h R0l) | |
7253 | ()) | |
7254 | ; op.w #r1,r0 | |
7255 | (dni (.sym op 16.w-r1-r0) | |
7256 | (.str op ".b r1,r0") | |
7257 | ((machine 16)) | |
7258 | (.str op ".w r1,r0") | |
7259 | (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc2)) | |
7260 | ((.sym op -sem) HI R1 R0) | |
7261 | ()) | |
7262 | ) | |
7263 | ) | |
7264 | ||
7265 | ; dadc for m16c | |
7266 | (decimal-subtraction16-insn dadc #xE #x6 ) | |
7267 | ||
7268 | ; dadc.size #imm,dst | |
7269 | (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadc X #x8 #x0 #xE dadc-sem) | |
7270 | (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadc X #x8 #x0 #xE dadc-sem) | |
7271 | ; dadc.BW src,dst | |
7272 | (binary-arith32-src-dst-Prefixed QI QI .b 0 dadc X #x1 #x8 dadc-sem) | |
7273 | (binary-arith32-src-dst-Prefixed HI HI .w 1 dadc X #x1 #x8 dadc-sem) | |
7274 | ||
7275 | (define-pmacro (dadd-sem mode src dst) | |
7276 | (sequence ((mode result)) | |
7277 | (set result (subc mode dst src 0)) | |
7278 | (set cbit (sub-cflag mode dst src 0)) | |
7279 | (set-z-and-s result) | |
7280 | (set dst result)) | |
7281 | ) | |
7282 | ||
7283 | ; dadd for m16c | |
7284 | (decimal-subtraction16-insn dadd #xC #x4) | |
7285 | ||
7286 | ; dadd.size #imm,dst | |
7287 | (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadd X #x8 #x1 #xE dadd-sem) | |
7288 | (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadd X #x8 #x1 #xE dadd-sem) | |
7289 | ; dadd.BW src,dst | |
7290 | (binary-arith32-src-dst-Prefixed QI QI .b 0 dadd X #x1 #x0 dadd-sem) | |
7291 | (binary-arith32-src-dst-Prefixed HI HI .w 1 dadd X #x1 #x0 dadd-sem) | |
7292 | ||
7293 | ;-------------------------------------------------------------; | |
7294 | ; addx - Add extend sign with no carry | |
7295 | ;-------------------------------------------------------------; | |
7296 | ||
7297 | (define-pmacro (addx-sem mode src dst) | |
7298 | (sequence ((SI source) (SI result)) | |
7299 | (set source (zext SI (trunc QI src))) | |
7300 | (set result (add SI source dst)) | |
7301 | (set obit (add-oflag SI source dst 0)) | |
7302 | (set cbit (add-cflag SI source dst 0)) | |
7303 | (set-z-and-s result) | |
7304 | (set dst result)) | |
7305 | ) | |
7306 | ||
7307 | ; addx #imm,dst | |
7308 | (binary-arith32-imm-dst-defn QI SI "" 0 addx X #x8 #x1 #x1 addx-sem) | |
7309 | ; addx src,dst | |
7310 | (binary-arith32-src-dst-defn QI SI "" 0 addx X #x1 #x2 addx-sem) | |
7311 | ||
7312 | ;------------------------------------------------------------- | |
7313 | ; adjnz - Add/Sub and branch if not zero | |
7314 | ;------------------------------------------------------------- | |
7315 | ||
7316 | (define-pmacro (arith-jnz-sem mode src dst label) | |
7317 | (sequence ((mode result)) | |
7318 | (set result (add mode src dst)) | |
7319 | (set dst result) | |
7320 | (if (ne result 0) | |
7321 | (set pc label))) | |
7322 | ) | |
7323 | ||
7324 | ; adjnz.size #imm4,dst,label | |
c6552317 | 7325 | (arith-jnz-imm4-dst adjnz s4 (f-0-4 #xF) (f-4-3 4) #xf #x1 arith-jnz-sem) |
49f58d10 JB |
7326 | |
7327 | ;------------------------------------------------------------- | |
7328 | ; and - binary and | |
7329 | ;------------------------------------------------------------- | |
7330 | ||
7331 | (define-pmacro (and-sem mode src1 dst) | |
7332 | (sequence ((mode result)) | |
7333 | (set result (and mode src1 dst)) | |
7334 | (set-z-and-s result) | |
7335 | (set dst result)) | |
7336 | ) | |
7337 | ||
7338 | ; and.size:G #imm,dst (m16 #1 m32 #1) | |
7339 | (binary-arith-imm-dst and G (f-0-4 7) (f-4-3 3) (f-8-4 2) #x8 #x3 #xF and-sem) | |
7340 | ; and.b:S #imm8,dst3 (m16 #2) | |
7341 | (binary-arith16-b-S-imm8-dst3 and ".b" (f-0-4 9) (f-4-1 0) and-sem) | |
7342 | ; and.BW:G src,dst (m16 #3 m32 #3) | |
7343 | (binary-arith-src-dst and G (f-0-4 #x9) (f-4-3 0) #x1 #xD and-sem) | |
7344 | ; and.B.S src2,r0l/r0h (m16 #4) | |
7345 | (binary-arith16-b-S-src2 and (f-0-4 1) (f-4-1 0) and-sem) | |
7346 | ; and.BW:S #imm,dst2 (m32 #2) | |
7347 | (binary-arith32-s-imm-dst QI .b 0 and #x1 #x6 and-sem) | |
7348 | (binary-arith32-s-imm-dst HI .w 1 and #x1 #x6 and-sem) | |
7349 | ||
7350 | ;------------------------------------------------------------- | |
7351 | ; band - bit and | |
7352 | ;------------------------------------------------------------- | |
7353 | ||
7354 | (define-pmacro (band-sem src) | |
7355 | (set cbit (and src cbit)) | |
7356 | ) | |
7357 | (bitsrc-insn band (f-0-4 7) (f-4-4 #xE) (f-8-4 4) #xD #x0 #x1 band-sem) | |
7358 | ||
7359 | ;------------------------------------------------------------- | |
7360 | ; bclr - bit clear | |
7361 | ;------------------------------------------------------------- | |
7362 | ||
7363 | (define-pmacro (bclr-sem dst) | |
7364 | (set dst 0) | |
7365 | ) | |
7366 | (bitdst-insn bclr (f-0-4 7) (f-4-4 #xE) (f-8-4 8) (f-0-2 1) (f-2-2 0) (f-4-1 0) #xD #x0 #x6 bclr-sem) | |
7367 | ||
7368 | ;------------------------------------------------------------- | |
7369 | ; bitindex - bit index | |
7370 | ;------------------------------------------------------------- | |
7371 | ||
7372 | (define-pmacro (bitindex-sem mode dst) | |
7373 | (set BitIndex dst) | |
7374 | ) | |
7375 | (unary-insn-defn 32 16-Unprefixed QI .b bitindex | |
7376 | (+ (f-0-4 #xC) (f-7-1 0) dst32-16-Unprefixed-QI (f-10-2 #x2) (f-12-4 #xE)) | |
7377 | bitindex-sem) | |
7378 | (unary-insn-defn 32 16-Unprefixed HI .w bitindex | |
7379 | (+ (f-0-4 #xC) (f-7-1 1) dst32-16-Unprefixed-HI (f-10-2 #x2) (f-12-4 #xE)) | |
7380 | bitindex-sem) | |
7381 | ||
7382 | ;------------------------------------------------------------- | |
7383 | ; bmCnd - bit move condition | |
7384 | ;------------------------------------------------------------- | |
7385 | ||
7386 | (define-pmacro (test-condition16 cond) | |
7387 | (case UQI cond | |
7388 | ((#x00) (trunc BI cbit)) | |
7389 | ((#x01) (not (or cbit zbit))) | |
7390 | ((#x02) (trunc BI zbit)) | |
7391 | ((#x03) (trunc BI sbit)) | |
7392 | ((#x04) (or zbit (xor sbit obit))) | |
7393 | ((#x05) (trunc BI obit)) | |
7394 | ((#x06) (xor sbit obit)) | |
7395 | ((#xf8) (not cbit)) | |
7396 | ((#xf9) (or cbit zbit)) | |
7397 | ((#xfa) (not zbit)) | |
7398 | ((#xfb) (not sbit)) | |
7399 | ((#xfc) (not (or zbit (xor sbit obit)))) | |
7400 | ((#xfd) (not obit)) | |
7401 | ((#xfe) (not (xor sbit obit))) | |
7402 | (else (const BI 0)) | |
7403 | ) | |
7404 | ) | |
7405 | ||
7406 | (define-pmacro (test-condition32 cond) | |
7407 | (case UQI cond | |
7408 | ((#x00) (not cbit)) | |
7409 | ((#x01) (or cbit zbit)) | |
7410 | ((#x02) (not zbit)) | |
7411 | ((#x03) (not sbit)) | |
7412 | ((#x04) (not obit)) | |
7413 | ((#x05) (not (or zbit (xor sbit obit)))) | |
7414 | ((#x06) (not (xor sbit obit))) | |
7415 | ((#x08) (trunc BI cbit)) | |
7416 | ((#x09) (not (or cbit zbit))) | |
7417 | ((#x0a) (trunc BI zbit)) | |
7418 | ((#x0b) (trunc BI sbit)) | |
7419 | ((#x0c) (trunc BI obit)) | |
7420 | ((#x0d) (or zbit (xor sbit obit))) | |
7421 | ((#x0e) (xor sbit obit)) | |
7422 | (else (const BI 0)) | |
7423 | ) | |
7424 | ) | |
7425 | ||
7426 | (define-pmacro (bitcond-sem mach op cond) | |
7427 | (if ((.sym test-condition mach) cond) | |
7428 | (set op 1) | |
7429 | (set op 0)) | |
7430 | ) | |
7431 | (bitcond-insn bm (f-0-4 7) (f-4-4 #xE) (f-8-4 2) #xD #x0 #x2 bitcond-sem) | |
7432 | ||
7433 | (dni bm16-c | |
7434 | "bm16 C" | |
7435 | ((machine 16)) | |
7436 | "bm$cond16c c" | |
7437 | (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xD) cond16c) | |
7438 | (bitcond-sem 16 cbit cond16c) | |
7439 | ()) | |
7440 | ||
7441 | (dni bm32-c | |
7442 | "bm32 C" | |
7443 | ((machine 32)) | |
7444 | "bm$cond32 c" | |
7445 | (+ (f-0-4 #xD) (f-4-4 #x9) (f-8-1 0) (f-10-3 5) cond32) | |
7446 | (bitcond-sem 32 cbit cond32) | |
7447 | ()) | |
7448 | ||
7449 | ;------------------------------------------------------------- | |
7450 | ; bnand | |
7451 | ;------------------------------------------------------------- | |
7452 | ||
7453 | (define-pmacro (bnand-sem src) | |
7454 | (set cbit (and (inv src) cbit)) | |
7455 | ) | |
7456 | (bitsrc-insn bnand (f-0-4 7) (f-4-4 #xE) (f-8-4 5) #xD #x0 #x3 bnand-sem) | |
7457 | ||
7458 | ;------------------------------------------------------------- | |
7459 | ; bnor | |
7460 | ;------------------------------------------------------------- | |
7461 | ||
7462 | (define-pmacro (bnor-sem src) | |
7463 | (set cbit (or (inv src) cbit)) | |
7464 | ) | |
7465 | (bitsrc-insn bnor (f-0-4 7) (f-4-4 #xE) (f-8-4 7) #xD #x0 #x6 bnor-sem) | |
7466 | ||
7467 | ;------------------------------------------------------------- | |
7468 | ; bnot | |
7469 | ;------------------------------------------------------------- | |
7470 | ||
7471 | (define-pmacro (bnot-sem dst) | |
7472 | (set dst (inv dst)) | |
7473 | ) | |
7474 | (bitdst-insn bnot (f-0-4 7) (f-4-4 #xE) (f-8-4 #xA) (f-0-2 1) (f-2-2 1) (f-4-1 0) #xD #x0 #x3 bnot-sem) | |
7475 | ||
7476 | ;------------------------------------------------------------- | |
7477 | ; bntst | |
7478 | ;------------------------------------------------------------- | |
7479 | ||
7480 | (define-pmacro (bntst-sem src) | |
7481 | (set cbit (inv src)) | |
7482 | (set zbit (inv src)) | |
7483 | ) | |
7484 | (bitsrc-insn bntst (f-0-4 7) (f-4-4 #xE) (f-8-4 3) #xD #x0 #x0 bntst-sem) | |
7485 | ||
7486 | ;------------------------------------------------------------- | |
7487 | ; bnxor | |
7488 | ;------------------------------------------------------------- | |
7489 | ||
7490 | (define-pmacro (bnxor-sem src) | |
7491 | (set cbit (xor (inv src) cbit)) | |
7492 | ) | |
7493 | (bitsrc-insn bnxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xD) #xD #x0 #x7 bnxor-sem) | |
7494 | ||
7495 | ;------------------------------------------------------------- | |
7496 | ; bor | |
7497 | ;------------------------------------------------------------- | |
7498 | ||
7499 | (define-pmacro (bor-sem src) | |
7500 | (set cbit (or src cbit)) | |
7501 | ) | |
7502 | (bitsrc-insn bor (f-0-4 7) (f-4-4 #xE) (f-8-4 #x6) #xD #x0 #x4 bor-sem) | |
7503 | ||
7504 | ;------------------------------------------------------------- | |
7505 | ; brk | |
7506 | ;------------------------------------------------------------- | |
7507 | ||
7508 | (dni brk16 | |
7509 | "brk" | |
7510 | ((machine 16)) | |
7511 | "brk" | |
7512 | (+ (f-0-4 #x0) (f-4-4 #x0)) | |
7513 | (nop) | |
7514 | ()) | |
7515 | ||
7516 | (dni brk32 | |
7517 | "brk" | |
7518 | ((machine 32)) | |
7519 | "brk" | |
7520 | (+ (f-0-4 #x0) (f-4-4 #x0)) | |
7521 | (nop) | |
7522 | ()) | |
7523 | ||
7524 | ;------------------------------------------------------------- | |
7525 | ; brk2 | |
7526 | ;------------------------------------------------------------- | |
7527 | ||
7528 | (dni brk232 | |
7529 | "brk2" | |
7530 | ((machine 32)) | |
7531 | "brk2" | |
7532 | (+ (f-0-4 #x0) (f-4-4 #x8)) | |
7533 | (nop) | |
7534 | ()) | |
7535 | ||
7536 | ;------------------------------------------------------------- | |
7537 | ; bset | |
7538 | ;------------------------------------------------------------- | |
7539 | ||
7540 | (define-pmacro (bset-sem dst) | |
7541 | (set dst 1) | |
7542 | ) | |
7543 | (bitdst-insn bset (f-0-4 7) (f-4-4 #xE) (f-8-4 9) (f-0-2 1) (f-2-2 0) (f-4-1 1) #xD #x0 #x7 bset-sem) | |
7544 | ||
7545 | ;------------------------------------------------------------- | |
7546 | ; btst | |
7547 | ;------------------------------------------------------------- | |
7548 | ||
7549 | (define-pmacro (btst-sem dst) | |
7550 | (set zbit (inv dst)) | |
7551 | (set cbit dst) | |
7552 | ) | |
7553 | (bitdst-insn btst (f-0-4 7) (f-4-4 #xE) (f-8-4 #xB) (f-0-2 1) (f-2-2 1) (f-4-1 1) #xD #x0 #x0 btst-sem) | |
7554 | ||
7555 | ;------------------------------------------------------------- | |
7556 | ; btstc | |
7557 | ;------------------------------------------------------------- | |
7558 | ||
7559 | (define-pmacro (btstc-sem dst) | |
7560 | (set zbit (inv dst)) | |
7561 | (set cbit dst) | |
7562 | (set dst (const 0)) | |
7563 | ) | |
7564 | (bitdstnos-insn btstc (f-0-4 7) (f-4-4 #xE) (f-8-4 #x0) #xD #x0 #x4 btstc-sem) | |
7565 | ||
7566 | ;------------------------------------------------------------- | |
7567 | ; btsts | |
7568 | ;------------------------------------------------------------- | |
7569 | ||
7570 | (define-pmacro (btsts-sem dst) | |
7571 | (set zbit (inv dst)) | |
7572 | (set cbit dst) | |
7573 | (set dst (const 0)) | |
7574 | ) | |
7575 | (bitdstnos-insn btsts (f-0-4 7) (f-4-4 #xE) (f-8-4 #x1) #xD #x0 #x5 btsts-sem) | |
7576 | ||
7577 | ;------------------------------------------------------------- | |
7578 | ; bxor | |
7579 | ;------------------------------------------------------------- | |
7580 | ||
7581 | (define-pmacro (bxor-sem src) | |
7582 | (set cbit (xor src cbit)) | |
7583 | ) | |
7584 | (bitsrc-insn bxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xC) #xD #x0 #x5 bxor-sem) | |
7585 | ||
7586 | ;------------------------------------------------------------- | |
7587 | ; clip | |
7588 | ;------------------------------------------------------------- | |
7589 | ||
7590 | (define-pmacro (clip-sem mode imm1 imm2 dest) | |
7591 | (sequence () | |
7592 | (if (gt mode imm1 dest) | |
7593 | (set dest imm1)) | |
7594 | (if (lt mode imm2 dest) | |
7595 | (set dest imm2))) | |
7596 | ) | |
7597 | ||
7598 | (insn-imm1-imm2-dst-Prefixed clip #x8 #x3 #xE clip-sem) | |
7599 | ||
7600 | ;------------------------------------------------------------- | |
7601 | ; cmp - binary compare | |
7602 | ;------------------------------------------------------------- | |
7603 | ||
7604 | (define-pmacro (cmp-sem mode src1 dst) | |
7605 | (sequence ((mode result)) | |
7606 | (set result (sub mode dst src1)) | |
7607 | (set obit (sub-oflag mode dst src1 0)) | |
7608 | (set cbit (not (sub-cflag mode dst src1 0))) | |
7609 | (set-z-and-s result)) | |
7610 | ) | |
7611 | ||
7612 | ; cmp.L:G #imm32,dst (m32 #2) | |
7613 | (binary-arith32-imm-dst-defn SI SI .l 0 cmp G #xA #x3 #x1 cmp-sem) | |
7614 | ; cmp.size:G #imm,dst (m16 #1 m32 #1) | |
7615 | (binary-arith-imm-dst cmp G (f-0-4 7) (f-4-3 3) (f-8-4 8) #x9 #x2 #xE cmp-sem) | |
7616 | ; cmp.size:Q #imm4,dst (m16 #2 m32 #3) | |
7617 | (binary-arith-imm4-dst cmp (f-0-4 #xD) (f-4-3 0) #x7 #x1 cmp-sem) | |
7618 | ; cmp.b:S #imm8,dst3 (m16 #3) | |
7619 | (binary-arith16-b-S-imm8-dst3 cmp ".b" (f-0-4 #xE) (f-4-1 0) cmp-sem) | |
7620 | ; cmp.BW:G src,dst (m16 #4 m32 #5) | |
7621 | (binary-arith-src-dst cmp G (f-0-4 #xC) (f-4-3 0) #x1 #x6 cmp-sem) | |
7622 | ; cmp.B.S src2,r0l/r0h (m16 #5) | |
7623 | (binary-arith16-b-S-src2 cmp (f-0-4 3) (f-4-1 1) cmp-sem) | |
7624 | ; cmp.L:G src,dst (m32 #6) | |
7625 | (binary-arith32-src-dst-defn SI SI .l 1 cmp G #x1 #x1 cmp-sem) | |
7626 | ; cmp.BW:S #imm,dst2 (m32 #4) | |
7627 | (binary-arith32-s-imm-dst QI .b 0 cmp #x1 #x3 cmp-sem) | |
7628 | (binary-arith32-s-imm-dst HI .w 1 cmp #x1 #x3 cmp-sem) | |
7629 | ; cmp.BW:s src2,r0[l] (m32 #7) | |
7630 | (binary-arith32-S-src2 cmp QI .b 0 (f-0-2 1) (f-4-3 0) cmp-sem) | |
7631 | (binary-arith32-S-src2 cmp HI .w 1 (f-0-2 1) (f-4-3 0) cmp-sem) | |
7632 | ||
7633 | ;------------------------------------------------------------- | |
7634 | ; cmpx - binary compare extend sign | |
7635 | ;------------------------------------------------------------- | |
7636 | ||
7637 | (define-pmacro (cmpx-sem mode src1 dst) | |
7638 | (sequence ((mode result)) | |
7639 | (set result (sub mode dst (ext mode src1))) | |
7640 | (set obit (sub-oflag mode dst (ext mode src1) 0)) | |
7641 | (set cbit (sub-cflag mode dst (ext mode src1) 0)) | |
7642 | (set-z-and-s result)) | |
7643 | ) | |
7644 | ||
7645 | (binary-arith32-imm-dst-defn QI SI "" 0 cmpx X #xA #x1 #x1 cmpx-sem) | |
7646 | ||
7647 | ;------------------------------------------------------------- | |
7648 | ; dec - decrement | |
7649 | ;------------------------------------------------------------- | |
7650 | ||
7651 | (define-pmacro (dec-sem mode dest) | |
7652 | (sequence ((mode result)) | |
7653 | (set result (sub mode dest 1)) | |
7654 | (set-z-and-s result) | |
7655 | (set dest result)) | |
7656 | ) | |
7657 | ||
7658 | (dni dec16.b | |
7659 | "dec.b Dst16-3-S-8" | |
7660 | ((machine 16)) | |
7661 | "dec.b ${Dst16-3-S-8}" | |
7662 | (+ (f-0-4 #xA) (f-4-1 #x1) Dst16-3-S-8) | |
7663 | (dec-sem QI Dst16-3-S-8) | |
7664 | ()) | |
7665 | ||
7666 | (dni dec16.w | |
7667 | "dec.w Dst16An-S" | |
7668 | ((machine 16)) | |
7669 | "dec.w ${Dst16An-S}" | |
7670 | (+ (f-0-4 #xF) (f-5-3 #x2) Dst16An-S) | |
7671 | (dec-sem HI Dst16An-S) | |
7672 | ()) | |
7673 | ||
7674 | (unary32-defn QI .b 0 dec #xB #x0 #xE dec-sem) | |
7675 | (unary32-defn HI .w 1 dec #xB #x0 #xE dec-sem) | |
7676 | ||
7677 | ;------------------------------------------------------------- | |
7678 | ; div - divide | |
7679 | ; divu - divide unsigned | |
7680 | ; divx - divide extension | |
7681 | ;------------------------------------------------------------- | |
7682 | ||
7683 | ; div.BW #imm | |
7684 | (div-imm div div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #x1) #xB #x0 #x2 #x3 div-sem) | |
7685 | (div-imm divu udiv umod USI 255 0 65535 0 (f-0-4 #x7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #x0) #xB #x0 #x0 #x3 div-sem) | |
7686 | (div-imm divx div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #x3) #xB #x2 #x2 #x3 div-sem) | |
7687 | ; div.BW src | |
7688 | (div-src div div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 3) (f-8-4 #xD) #x8 #x1 #xE div-sem) | |
7689 | (div-src divu udiv umod USI 255 0 65535 0 (f-0-4 #x7) (f-4-3 3) (f-8-4 #xC) #x8 #x0 #xE div-sem) | |
7690 | (div-src divx div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 3) (f-8-4 #x9) #x9 #x1 #xE div-sem) | |
7691 | ||
7692 | (div-src-defn 32 .l div dst32-24-Prefixed-SI | |
7693 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xA) (f-15-1 1) (f-18-2 #x1) (f-20-4 #xf) dst32-24-Prefixed-SI) | |
7694 | div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000) | |
7695 | div-sem) | |
7696 | (div-src-defn 32 .l divu dst32-24-Prefixed-SI | |
7697 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xA) (f-15-1 1) (f-18-2 #x0) (f-20-4 #xf) dst32-24-Prefixed-SI) | |
7698 | udiv umod USI R2R0 R2R0 NoRemainder #x80000000 0 | |
7699 | div-sem) | |
7700 | (div-src-defn 32 .l divx dst32-24-Prefixed-SI | |
7701 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xA) (f-15-1 1) (f-18-2 #x2) (f-20-4 #xf) dst32-24-Prefixed-SI) | |
7702 | div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000) | |
7703 | div-sem) | |
7704 | ||
7705 | ;------------------------------------------------------------- | |
7706 | ; dsbb - decimal subtraction with borrow | |
7707 | ; dsub - decimal subtraction | |
7708 | ;------------------------------------------------------------- | |
7709 | ||
7710 | (define-pmacro (dsbb-sem mode src dst) | |
7711 | (sequence ((mode result)) | |
7712 | (set result (subc mode dst src (not cbit))) | |
7713 | (set cbit (sub-cflag mode dst src (not cbit))) | |
7714 | (set-z-and-s result) | |
7715 | (set dst result)) | |
7716 | ) | |
7717 | ||
7718 | ; dsbb for m16c | |
7719 | (decimal-subtraction16-insn dsbb #xF #x7) | |
7720 | ||
7721 | ; dsbb.size #imm,dst | |
7722 | (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsbb X #x9 #x0 #xE dsbb-sem) | |
7723 | (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsbb X #x9 #x0 #xE dsbb-sem) | |
7724 | ; dsbb.BW src,dst | |
7725 | (binary-arith32-src-dst-Prefixed QI QI .b 0 dsbb X #x1 #xA dsbb-sem) | |
7726 | (binary-arith32-src-dst-Prefixed HI HI .w 1 dsbb X #x1 #xA dsbb-sem) | |
7727 | ||
7728 | (define-pmacro (dsub-sem mode src dst) | |
7729 | (sequence ((mode result)) | |
7730 | (set result (subc mode dst src 0)) | |
7731 | (set cbit (sub-cflag mode dst src 0)) | |
7732 | (set-z-and-s result) | |
7733 | (set dst result)) | |
7734 | ) | |
7735 | ||
7736 | ; dsub for m16c | |
7737 | (decimal-subtraction16-insn dsub #xD #x5) | |
7738 | ||
7739 | ; dsub.size #imm,dst | |
7740 | (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsub X #x9 #x1 #xE dsub-sem) | |
7741 | (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsub X #x9 #x1 #xE dsub-sem) | |
7742 | ; dsub.BW src,dst | |
7743 | (binary-arith32-src-dst-Prefixed QI QI .b 0 dsub X #x1 #x2 dsub-sem) | |
7744 | (binary-arith32-src-dst-Prefixed HI HI .w 1 dsub X #x1 #x2 dsub-sem) | |
7745 | ||
7746 | ;------------------------------------------------------------- | |
7747 | ; sub - binary subtraction | |
7748 | ;------------------------------------------------------------- | |
7749 | ||
7750 | (define-pmacro (sub-sem mode src1 dst) | |
7751 | (sequence ((mode result)) | |
7752 | (set result (sub mode dst src1)) | |
7753 | (set obit (sub-oflag mode dst src1 0)) | |
7754 | (set cbit (sub-cflag mode dst src1 0)) | |
7755 | (set dst result) | |
7756 | (set-z-and-s result))) | |
7757 | ||
7758 | ; sub.size:G #imm,dst (m16 #1 m32 #1) | |
7759 | (binary-arith-imm-dst sub G (f-0-4 7) (f-4-3 3) (f-8-4 5) #x8 #x3 #xE sub-sem) | |
7760 | ; sub.b:S #imm8,dst3 (m16 #2) | |
7761 | (binary-arith16-b-S-imm8-dst3 sub ".b" (f-0-4 8) (f-4-1 1) sub-sem) | |
7762 | ; sub.BW:G src,dst (m16 #3 m32 #4) | |
7763 | (binary-arith-src-dst sub G (f-0-4 #xA) (f-4-3 4) #x1 #xA sub-sem) | |
7764 | ; sub.B.S src2,r0l/r0h (m16 #4) | |
7765 | (binary-arith16-b-S-src2 sub (f-0-4 2) (f-4-1 1) sub-sem) | |
7766 | ; sub.L:G #imm32,dst (m32 #2) | |
7767 | (binary-arith32-imm-dst-defn SI SI .l 0 sub G #x9 #x3 #x1 sub-sem) | |
7768 | ; sub.BW:S #imm,dst2 (m32 #3) | |
7769 | (binary-arith32-s-imm-dst QI .b 0 sub #x0 #x7 sub-sem) | |
7770 | (binary-arith32-s-imm-dst HI .w 1 sub #x0 #x7 sub-sem) | |
7771 | ; sub.L:G src,dst (m32 #5) | |
7772 | (binary-arith32-src-dst-defn SI SI .l 1 sub G #x1 #x0 sub-sem) | |
7773 | ||
7774 | ;------------------------------------------------------------- | |
7775 | ; enter - enter function | |
7776 | ; exitd - exit and deallocate stack frame | |
7777 | ;------------------------------------------------------------- | |
7778 | ||
7779 | (define-pmacro (enter16-sem mach amt) | |
7780 | (sequence () | |
7781 | (set (reg h-sp) (sub (reg h-sp) 2)) | |
7782 | (set (mem16 HI (reg h-sp)) (reg h-fb)) | |
7783 | (set (reg h-fb) (reg h-sp)) | |
7784 | (set (reg h-sp) (sub (reg h-sp) amt)))) | |
7785 | ||
7786 | (define-pmacro (exit16-sem mach) | |
7787 | (sequence ((SI newpc)) | |
7788 | (set (reg h-sp) (reg h-fb)) | |
7789 | (set (reg h-fb) (mem16 HI (reg h-sp))) | |
7790 | (set (reg h-sp) (add (reg h-sp) 2)) | |
7791 | (set newpc (mem16 HI (reg h-sp))) | |
7792 | (set (reg h-sp) (add (reg h-sp) 2)) | |
7793 | (set newpc (or newpc (sll (mem16 QI (reg h-sp)) (const 16)))) | |
7794 | (set (reg h-sp) (add (reg h-sp) 1)) | |
7795 | (set pc newpc))) | |
7796 | ||
7797 | (define-pmacro (enter32-sem mach amt) | |
7798 | (sequence () | |
7799 | (set (reg h-sp) (sub (reg h-sp) 4)) | |
7800 | (set (mem32 SI (reg h-sp)) (reg h-fb)) | |
7801 | (set (reg h-fb) (reg h-sp)) | |
7802 | (set (reg h-sp) (sub (reg h-sp) amt)))) | |
7803 | ||
7804 | (define-pmacro (exit32-sem mach) | |
7805 | (sequence ((SI newpc)) | |
7806 | (set (reg h-sp) (reg h-fb)) | |
7807 | (set (reg h-fb) (mem32 SI (reg h-sp))) | |
7808 | (set (reg h-sp) (add (reg h-sp) 4)) | |
7809 | (set newpc (mem32 SI (reg h-sp))) | |
7810 | (set (reg h-sp) (add (reg h-sp) 4)) | |
7811 | (set pc newpc))) | |
7812 | ||
7813 | (dni enter16 "enter #Imm-16-QI" ((machine 16)) | |
7814 | ("enter #${Dsp-16-u8}") | |
7815 | (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 2) Dsp-16-u8) | |
7816 | (enter16-sem 16 Dsp-16-u8) | |
7817 | ()) | |
7818 | ||
7819 | (dni exitd16 "exitd" ((machine 16)) | |
7820 | ("exitd") | |
7821 | (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 2)) | |
7822 | (exit16-sem 16) | |
7823 | ()) | |
7824 | ||
7825 | (dni enter32 "enter #Imm-8-QI" ((machine 32)) | |
7826 | ("enter #${Dsp-8-u8}") | |
7827 | (+ (f-0-4 #xE) (f-4-4 #xC) Dsp-8-u8) | |
7828 | (enter32-sem 32 Dsp-8-u8) | |
7829 | ()) | |
7830 | ||
7831 | (dni exitd32 "exitd" ((machine 32)) | |
7832 | ("exitd") | |
7833 | (+ (f-0-4 #xF) (f-4-4 #xC)) | |
7834 | (exit32-sem 32) | |
7835 | ()) | |
7836 | ||
7837 | ;------------------------------------------------------------- | |
7838 | ; fclr - flag register clear | |
7839 | ; fset - flag register set | |
7840 | ;------------------------------------------------------------- | |
7841 | ||
7842 | (define-pmacro (set-flags-sem flag) | |
7843 | (sequence ((SI tmp)) | |
7844 | (case DFLT flag | |
7845 | ((#x0) (set cbit 1)) | |
7846 | ((#x1) (set dbit 1)) | |
7847 | ((#x2) (set zbit 1)) | |
7848 | ((#x3) (set sbit 1)) | |
7849 | ((#x4) (set bbit 1)) | |
7850 | ((#x5) (set obit 1)) | |
7851 | ((#x6) (set ibit 1)) | |
7852 | ((#x7) (set ubit 1))) | |
7853 | ) | |
7854 | ) | |
7855 | ||
7856 | (define-pmacro (clear-flags-sem flag) | |
7857 | (sequence ((SI tmp)) | |
7858 | (case DFLT flag | |
7859 | ((#x0) (set cbit 0)) | |
7860 | ((#x1) (set dbit 0)) | |
7861 | ((#x2) (set zbit 0)) | |
7862 | ((#x3) (set sbit 0)) | |
7863 | ((#x4) (set bbit 0)) | |
7864 | ((#x5) (set obit 0)) | |
7865 | ((#x6) (set ibit 0)) | |
7866 | ((#x7) (set ubit 0))) | |
7867 | ) | |
7868 | ) | |
7869 | ||
7870 | (dni fclr16 "fclr flag" ((machine 16)) | |
7871 | ("fclr ${flags16}") | |
7872 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 5)) | |
7873 | (clear-flags-sem flags16) | |
7874 | ()) | |
7875 | ||
7876 | (dni fset16 "fset flag" ((machine 16)) | |
7877 | ("fset ${flags16}") | |
7878 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 4)) | |
7879 | (set-flags-sem flags16) | |
7880 | ()) | |
7881 | ||
7882 | (dni fclr "fclr" ((machine 32)) | |
7883 | ("fclr ${flags32}") | |
7884 | (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xE) (f-12-1 1) flags32) | |
7885 | (clear-flags-sem flags32) | |
7886 | ()) | |
7887 | ||
7888 | (dni fset "fset" ((machine 32)) | |
7889 | ("fset ${flags32}") | |
7890 | (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xE) (f-12-1 1) flags32) | |
7891 | (set-flags-sem flags32) | |
7892 | ()) | |
7893 | ||
7894 | ;------------------------------------------------------------- | |
7895 | ; inc - increment | |
7896 | ;------------------------------------------------------------- | |
7897 | ||
7898 | (define-pmacro (inc-sem mode dest) | |
7899 | (sequence ((mode result)) | |
7900 | (set result (add mode dest 1)) | |
7901 | (set-z-and-s result) | |
7902 | (set dest result)) | |
7903 | ) | |
7904 | ||
7905 | (dni inc16.b | |
7906 | "inc.b Dst16-3-S-8" | |
7907 | ((machine 16)) | |
7908 | "inc.b ${Dst16-3-S-8}" | |
7909 | (+ (f-0-4 #xA) (f-4-1 #x0) Dst16-3-S-8) | |
7910 | (inc-sem QI Dst16-3-S-8) | |
7911 | ()) | |
7912 | ||
7913 | (dni inc16.w | |
7914 | "inc.w Dst16An-S" | |
7915 | ((machine 16)) | |
7916 | "inc.w ${Dst16An-S}" | |
7917 | (+ (f-0-4 #xB) (f-5-3 #x2) Dst16An-S) | |
7918 | (inc-sem HI Dst16An-S) | |
7919 | ()) | |
7920 | ||
7921 | (unary32-defn QI .b 0 inc #xA #x0 #xE inc-sem) | |
7922 | (unary32-defn HI .w 1 inc #xA #x0 #xE inc-sem) | |
7923 | ||
7924 | ;------------------------------------------------------------- | |
7925 | ; freit - fast return from interrupt (m32) | |
7926 | ; int - interrupt | |
7927 | ; into - interrupt on overflow | |
7928 | ;------------------------------------------------------------- | |
7929 | ||
7930 | ; ??? semantics | |
7931 | (dni freit32 "FREIT" ((machine 32)) | |
7932 | ("freit") | |
7933 | (+ (f-0-4 9) (f-4-4 #xF)) | |
7934 | (nop) | |
7935 | ()) | |
7936 | ||
7937 | (dni int16 "int Dsp-10-u6" ((machine 16)) | |
7938 | ("int #${Dsp-10-u6}") | |
7939 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-2 3) Dsp-10-u6) | |
7940 | (c-call VOID "do_int" pc Dsp-10-u6) | |
7941 | ()) | |
7942 | ||
7943 | (dni into16 "into" ((machine 16)) | |
7944 | ("into") | |
7945 | (+ (f-0-4 #xF) (f-4-4 6)) | |
7946 | (nop) | |
7947 | ()) | |
7948 | ||
7949 | (dni int32 "int Dsp-8-u6" ((machine 32)) | |
7950 | ("int #${Dsp-8-u6}") | |
7951 | (+ (f-0-4 #xB) (f-4-4 #xE) Dsp-8-u6 (f-14-2 0)) | |
7952 | (c-call VOID "do_int" pc Dsp-8-u6) | |
7953 | ()) | |
7954 | ||
7955 | (dni into32 "into" ((machine 32)) | |
7956 | ("into") | |
7957 | (+ (f-0-4 #xB) (f-4-4 #xF)) | |
7958 | (nop) | |
7959 | ()) | |
7960 | ||
7961 | ;------------------------------------------------------------- | |
7962 | ; index (m32c) | |
7963 | ;------------------------------------------------------------- | |
7964 | ||
7965 | ; TODO add support to insns allowing index | |
7966 | (define-pmacro (indexb-sem mode d) (set SrcIndex d) (set DstIndex d)) | |
7967 | (define-pmacro (indexbd-sem mode d) (set SrcIndex (const 0)) (set DstIndex d)) | |
7968 | (define-pmacro (indexbs-sem mode d) (set SrcIndex d) (set DstIndex (const 0))) | |
7969 | (define-pmacro (indexw-sem mode d) | |
7970 | (set SrcIndex (sll d (const 2))) (set DstIndex (sll d (const 2)))) | |
7971 | (define-pmacro (indexwd-sem mode d) | |
7972 | (set SrcIndex (const 0)) (set DstIndex (sll d (const 2)))) | |
7973 | (define-pmacro (indexws-sem mode d) | |
7974 | (set SrcIndex (sll d (const 2))) (set DstIndex (const 0))) | |
7975 | (define-pmacro (indexl-sem mode d) | |
7976 | (set SrcIndex d) (set DstIndex (sll d (const 2)))) | |
7977 | (define-pmacro (indexld-sem mode d) | |
7978 | (set SrcIndex (const 0)) (set DstIndex (sll d (const 2)))) | |
7979 | (define-pmacro (indexls-sem mode d) | |
7980 | (set SrcIndex (sll d (const 2))) (set DstIndex (const 0))) | |
7981 | ||
7982 | ; indexb src (index byte) | |
7983 | (unary32-defn QI .b 0 indexb #x8 0 #x3 indexb-sem) | |
a1a280bb | 7984 | (unary32-defn HI .w 1 indexb #x8 1 #x3 indexb-sem) |
49f58d10 JB |
7985 | ; indexbd src (index byte dest) |
7986 | (unary32-defn QI .b 0 indexbd #xA 0 3 indexbd-sem) | |
a1a280bb | 7987 | (unary32-defn HI .w 1 indexbd #xA 1 3 indexbd-sem) |
49f58d10 JB |
7988 | ; indexbs src (index byte src) |
7989 | (unary32-defn QI .b 0 indexbs #xC 0 3 indexbs-sem) | |
a1a280bb | 7990 | (unary32-defn HI .w 1 indexbs #xC 1 3 indexbs-sem) |
49f58d10 JB |
7991 | ; indexl src (index long) |
7992 | (unary32-defn QI .b 0 indexl 9 2 3 indexl-sem) | |
a1a280bb | 7993 | (unary32-defn HI .w 1 indexl 9 3 3 indexl-sem) |
49f58d10 JB |
7994 | ; indexld src (index long dest) |
7995 | (unary32-defn QI .b 0 indexld #xB 2 3 indexld-sem) | |
a1a280bb | 7996 | (unary32-defn HI .w 1 indexld #xB 3 3 indexld-sem) |
49f58d10 JB |
7997 | ; indexls src (index long src) |
7998 | (unary32-defn QI .b 0 indexls 9 0 3 indexls-sem) | |
a1a280bb | 7999 | (unary32-defn HI .w 1 indexls 9 1 3 indexls-sem) |
49f58d10 JB |
8000 | ; indexw src (index word) |
8001 | (unary32-defn QI .b 0 indexw 8 2 3 indexw-sem) | |
a1a280bb | 8002 | (unary32-defn HI .w 1 indexw 8 3 3 indexw-sem) |
49f58d10 JB |
8003 | ; indexwd src (index word dest) |
8004 | (unary32-defn QI .b 0 indexwd #xA 2 3 indexwd-sem) | |
a1a280bb | 8005 | (unary32-defn HI .w 1 indexwd #xA 3 3 indexwd-sem) |
49f58d10 JB |
8006 | ; indexws (index word src) |
8007 | (unary32-defn QI .b 0 indexws #xC 2 3 indexws-sem) | |
a1a280bb | 8008 | (unary32-defn HI .w 1 indexws #xC 3 3 indexws-sem) |
49f58d10 JB |
8009 | |
8010 | ;------------------------------------------------------------- | |
8011 | ; jcc - jump on condition | |
8012 | ;------------------------------------------------------------- | |
8013 | ||
8014 | (define-pmacro (jcnd32-sem cnd label) | |
8015 | (sequence () | |
8016 | (case DFLT cnd | |
8017 | ((#x00) (if (not cbit) (set pc label))) ;ltu nc | |
8018 | ((#x01) (if (not (and cbit (not zbit))) (set pc label))) ;leu | |
8019 | ((#x02) (if (not zbit) (set pc label))) ;ne nz | |
8020 | ((#x03) (if (not sbit) (set pc label))) ;pz | |
8021 | ((#x04) (if (not obit) (set pc label))) ;no | |
8022 | ((#x05) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt | |
8023 | ((#x06) (if (not (xor sbit obit)) (set pc label))) ;ge | |
8024 | ((#x08) (if (trunc BI cbit) (set pc label))) ;geu c | |
8025 | ((#x09) (if (and cbit (not zbit)) (set pc label))) ;gtu | |
8026 | ((#x0a) (if (trunc BI zbit) (set pc label))) ;eq z | |
8027 | ((#x0b) (if (trunc BI sbit) (set pc label))) ;n | |
8028 | ((#x0c) (if (trunc BI obit) (set pc label))) ;o | |
8029 | ((#x0d) (if (or zbit (xor sbit obit)) (set pc label))) ;le | |
8030 | ((#x0e) (if (xor sbit obit) (set pc label))) ;lt | |
8031 | ) | |
8032 | ) | |
8033 | ) | |
8034 | ||
8035 | (define-pmacro (jcnd16-sem cnd label) | |
8036 | (sequence () | |
8037 | (case DFLT cnd | |
8038 | ((#x00) (if (trunc BI cbit) (set pc label))) ;geu c | |
8039 | ((#x01) (if (and cbit (not zbit)) (set pc label))) ;gtu | |
8040 | ((#x02) (if (trunc BI zbit) (set pc label))) ;eq z | |
8041 | ((#x03) (if (trunc BI sbit) (set pc label))) ;n | |
8042 | ((#x04) (if (not cbit) (set pc label))) ;ltu nc | |
8043 | ((#x05) (if (not (and cbit (not zbit))) (set pc label))) ;leu | |
8044 | ((#x06) (if (not zbit) (set pc label))) ;ne nz | |
8045 | ((#x07) (if (not sbit) (set pc label))) ;pz | |
8046 | ((#x08) (if (or zbit (xor sbit obit)) (set pc label))) ;le | |
8047 | ((#x09) (if (trunc BI obit) (set pc label))) ;o | |
8048 | ((#x0a) (if (not (xor sbit obit)) (set pc label))) ;ge | |
8049 | ((#x0c) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt | |
8050 | ((#x0d) (if (not obit) (set pc label))) ;no | |
8051 | ((#x0e) (if (xor sbit obit) (set pc label))) ;lt | |
8052 | ) | |
8053 | ) | |
8054 | ) | |
8055 | ||
8056 | (dni jcnd16-5 | |
8057 | "jCnd label" | |
e729279b | 8058 | (RELAXABLE (machine 16)) |
49f58d10 JB |
8059 | "j$cond16j5 ${Lab-8-8}" |
8060 | (+ (f-0-4 #x6) (f-4-1 1) cond16j5 Lab-8-8) | |
8061 | (jcnd16-sem cond16j5 Lab-8-8) | |
8062 | () | |
8063 | ) | |
8064 | ||
8065 | (dni jcnd16 | |
8066 | "jCnd label" | |
e729279b | 8067 | (RELAXABLE (machine 16)) |
49f58d10 JB |
8068 | "j$cond16j ${Lab-16-8}" |
8069 | (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xC) cond16j Lab-16-8) | |
8070 | (jcnd16-sem cond16j Lab-16-8) | |
8071 | () | |
8072 | ) | |
8073 | ||
8074 | (dni jcnd32 | |
8075 | "jCnd label" | |
e729279b | 8076 | (RELAXABLE (machine 32)) |
49f58d10 JB |
8077 | "j$cond32j ${Lab-8-8}" |
8078 | (+ (f-0-1 1) (f-4-3 5) cond32j Lab-8-8) | |
8079 | (jcnd32-sem cond32j Lab-8-8) | |
8080 | () | |
8081 | ) | |
8082 | ||
8083 | ;------------------------------------------------------------- | |
8084 | ; jmp - jump | |
8085 | ;------------------------------------------------------------- | |
8086 | ||
8087 | ; jmp.s label3 (m16 #1) | |
e729279b | 8088 | (dni jmp16.s "jmp.s Lab-5-3" (RELAXABLE (machine 16)) |
49f58d10 JB |
8089 | ("jmp.s ${Lab-5-3}") |
8090 | (+ (f-0-4 6) (f-4-1 0) Lab-5-3) | |
8091 | (sequence () (set pc Lab-5-3)) | |
8092 | ()) | |
8093 | ; jmp.b label8 (m16 #2) | |
e729279b | 8094 | (dni jmp16.b "jmp.b Lab-8-8" (RELAXABLE (machine 16)) |
49f58d10 JB |
8095 | ("jmp.b ${Lab-8-8}") |
8096 | (+ (f-0-4 #xF) (f-4-4 #xE) Lab-8-8) | |
8097 | (sequence () (set pc Lab-8-8)) | |
8098 | ()) | |
8099 | ; jmp.w label16 (m16 #3) | |
e729279b | 8100 | (dni jmp16.w "jmp.w Lab-8-16" (RELAXABLE (machine 16)) |
49f58d10 JB |
8101 | ("jmp.w ${Lab-8-16}") |
8102 | (+ (f-0-4 #xF) (f-4-4 4) Lab-8-16) | |
8103 | (sequence () (set pc Lab-8-16)) | |
8104 | ()) | |
8105 | ; jmp.a label24 (m16 #4) | |
8106 | (dni jmp16.a "jmp.a Lab-8-24" ((machine 16)) | |
8107 | ("jmp.a ${Lab-8-24}") | |
8108 | (+ (f-0-4 #xF) (f-4-4 #xC) Lab-8-24) | |
8109 | (sequence () (set pc Lab-8-24)) | |
8110 | ()) | |
8111 | ||
8112 | (define-pmacro (jmp16-sem mode dst) | |
8113 | (set pc (and dst #xfffff)) | |
8114 | ) | |
8115 | (define-pmacro (jmp32-sem mode dst) | |
8116 | (set pc dst) | |
8117 | ) | |
8118 | ; jmpi.w dst (m16 #1 m32 #2) | |
8119 | (unary-insn-defn 16 16 HI .w jmpi (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 2) dst16-16-HI) jmp16-sem) | |
8120 | (unary-insn-defn 32 16-Unprefixed HI .w jmpi (+ (f-0-4 #xC) (f-7-1 1) dst32-16-Unprefixed-HI (f-10-2 #x0) (f-12-4 #xF)) jmp32-sem) | |
8121 | ; jmpi.a dst (m16 #2 m32 #2) | |
8122 | (unary-insn-defn 16 16 SI .a jmpi (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 0) dst16-16-SI) jmp16-sem) | |
8123 | (unary-insn-defn 32 16-Unprefixed SI .a jmpi (+ (f-0-4 #x8) (f-7-1 0) dst32-16-Unprefixed-SI (f-10-2 #x0) (f-12-4 1)) jmp32-sem) | |
8124 | ; jmps imm8 (m16 #1) | |
8125 | (dni jmps16 "jmps Imm-8-QI" ((machine 16)) | |
8126 | ("jmps #${Imm-8-QI}") | |
8127 | (+ (f-0-4 #xE) (f-4-4 #xE) Imm-8-QI) | |
8128 | (sequence () (set pc Imm-8-QI)) | |
8129 | ()) | |
8130 | ; jmp.s label3 (m32 #1) | |
8131 | (dni jmp32.s | |
8132 | "jmp.s label" | |
e729279b | 8133 | (RELAXABLE (machine 32)) |
49f58d10 JB |
8134 | "jmp.s ${Lab32-jmp-s}" |
8135 | (+ (f-0-2 1) (f-4-3 5) Lab32-jmp-s) | |
8136 | (set pc Lab32-jmp-s) | |
8137 | () | |
8138 | ) | |
8139 | ; jmp.b label8 (m32 #2) | |
e729279b | 8140 | (dni jmp32.b "jmp.b Lab-8-8" (RELAXABLE (machine 32)) |
49f58d10 JB |
8141 | ("jmp.b ${Lab-8-8}") |
8142 | (+ (f-0-4 #xB) (f-4-4 #xB) Lab-8-8) | |
8143 | (set pc Lab-8-8) | |
8144 | ()) | |
8145 | ; jmp.w label16 (m32 #3) | |
e729279b | 8146 | (dni jmp32.w "jmp.w Lab-8-16" (RELAXABLE (machine 32)) |
49f58d10 JB |
8147 | ("jmp.w ${Lab-8-16}") |
8148 | (+ (f-0-4 #xC) (f-4-4 #xE) Lab-8-16) | |
8149 | (set pc Lab-8-16) | |
8150 | ()) | |
8151 | ; jmp.a label24 (m32 #4) | |
8152 | (dni jmp32.a "jmp.a Lab-8-24" ((machine 32)) | |
8153 | ("jmp.a ${Lab-8-24}") | |
8154 | (+ (f-0-4 #xC) (f-4-4 #xC) Lab-8-24) | |
8155 | (set pc Lab-8-24) | |
8156 | ()) | |
8157 | ; jmp.s imm8 (m32 #1) | |
8158 | (dni jmps32 "jmps Imm-8-QI" ((machine 32)) | |
8159 | ("jmps #${Imm-8-QI}") | |
8160 | (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI) | |
8161 | (set pc Imm-8-QI) | |
8162 | ()) | |
8163 | ||
8164 | ;------------------------------------------------------------- | |
8165 | ; jsr jump subroutine | |
8166 | ;------------------------------------------------------------- | |
8167 | ||
8168 | (define-pmacro (jsr16-sem length dst) | |
8169 | (sequence ((SI tpc)) | |
8170 | (set tpc (add pc length)) | |
8171 | (set (reg h-sp) (sub (reg h-sp) 2)) | |
8172 | (set (mem16 HI (reg h-sp)) (srl (and tpc #xffff00) 8)) | |
8173 | (set (reg h-sp) (sub (reg h-sp) 1)) | |
8174 | (set (mem16 QI (reg h-sp)) (and tpc #xff)) | |
8175 | (set pc dst) | |
8176 | ) | |
8177 | ) | |
8178 | (define-pmacro (jsr32-sem length dst) | |
8179 | (sequence ((SI tpc)) | |
8180 | (set tpc (add pc length)) | |
8181 | (set (reg h-sp) (sub (reg h-sp) 2)) | |
8182 | (set (mem32 HI (reg h-sp)) (srl (and tpc #xffff0000) 16)) | |
8183 | (set (reg h-sp) (sub (reg h-sp) 2)) | |
8184 | (set (mem32 HI (reg h-sp)) (and tpc #xffff)) | |
8185 | (set pc dst) | |
8186 | ) | |
8187 | ) | |
8188 | ||
8189 | ; jsr.w label16 (m16 #1) | |
e729279b | 8190 | (dni jsr16.w "jsr.w Lab-8-16" (RELAXABLE (machine 16)) |
49f58d10 JB |
8191 | ("jsr.w ${Lab-8-16}") |
8192 | (+ (f-0-4 #xF) (f-4-4 5) Lab-8-16) | |
8193 | (jsr16-sem 3 Lab-8-16) | |
8194 | ()) | |
8195 | ; jsr.a label24 (m16 #2) | |
8196 | (dni jsr16.a "jsr.a Lab-8-24" ((machine 16)) | |
8197 | ("jsr.a ${Lab-8-24}") | |
8198 | (+ (f-0-4 #xF) (f-4-4 #xD) Lab-8-24) | |
8199 | (jsr16-sem 4 Lab-8-24) | |
8200 | ()) | |
8201 | (define-pmacro (jsri-defn mode op16 op16-1 op16-2 op16-3 op16-sem | |
8202 | op32 op32-1 op32-2 op32-3 op32-4 op32-sem len) | |
8203 | (begin | |
8204 | (dni (.sym jsri16 mode - op16) | |
8205 | (.str "jsri." mode " " op16) | |
8206 | ((machine 16)) | |
8207 | (.str "jsri." mode " ${" op16 "}") | |
8208 | (+ op16-1 op16-2 op16-3 op16) | |
8209 | (op16-sem len op16) | |
8210 | ()) | |
8211 | (dni (.sym jsri32 mode - op32) | |
8212 | (.str "jsri." mode " " op32) | |
8213 | ((machine 32)) | |
8214 | (.str "jsri." mode " ${" op32 "}") | |
8215 | (+ op32-1 op32-2 op32-3 op32-4 op32) | |
8216 | (op32-sem len op32) | |
8217 | ()) | |
8218 | ) | |
8219 | ) | |
8220 | ; jsri.w dst (m16 #1 m32 #1)) | |
8221 | (jsri-defn w dst16-basic-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem | |
8222 | dst32-basic-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 2) | |
8223 | (jsri-defn w dst16-16-8-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem | |
8224 | dst32-16-8-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 3) | |
8225 | (jsri-defn w dst16-16-16-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem | |
8226 | dst32-16-16-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 4) | |
8227 | (dni jsri32.w "jsr.w dst32-16-24-Unprefixed-HI" ((machine 32)) | |
8228 | ("jsri.w ${dst32-16-24-Unprefixed-HI}") | |
8229 | (+ (f-0-4 #xC) (f-7-1 1) dst32-16-24-Unprefixed-HI (f-10-2 #x1) (f-12-4 #xF)) | |
8230 | (jsr32-sem 6 dst32-16-24-Unprefixed-HI) | |
8231 | ()) | |
8232 | ||
8233 | ; jsri.a (m16 #2 m32 #2) | |
8234 | (jsri-defn a dst16-basic-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem | |
8235 | dst32-basic-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 2) | |
8236 | (jsri-defn a dst16-16-8-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem | |
8237 | dst32-16-8-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 3) | |
8238 | (jsri-defn a dst16-16-16-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem | |
8239 | dst32-16-16-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 4) | |
8240 | (dni jsri32.a "jsr.w dst32-16-24-Unprefixed-HI" ((machine 32)) | |
8241 | ("jsri.w ${dst32-16-24-Unprefixed-SI}") | |
8242 | (+ (f-0-4 #x9) (f-7-1 0) dst32-16-24-Unprefixed-SI (f-10-2 #x0) (f-12-4 #x1)) | |
8243 | (jsr32-sem 6 dst32-16-24-Unprefixed-SI) | |
8244 | ()) | |
8245 | ; jsr.w label16 (m32 #1) | |
e729279b | 8246 | (dni jsr32.w "jsr.w label" (RELAXABLE (machine 32)) |
49f58d10 JB |
8247 | ("jsr.w ${Lab-8-16}") |
8248 | (+ (f-0-4 #xC) (f-4-4 #xF) Lab-8-16) | |
8249 | (jsr32-sem 3 Lab-8-16) | |
8250 | ()) | |
8251 | ; jsr.a label16 (m32 #2) | |
8252 | (dni jsr32.a "jsr.a label" ((machine 32)) | |
8253 | ("jsr.a ${Lab-8-24}") | |
8254 | (+ (f-0-4 #xC) (f-4-4 #xD) Lab-8-24) | |
8255 | (jsr32-sem 4 Lab-8-24) | |
8256 | ()) | |
8257 | ; jsrs imm8 (m16 #1) | |
8258 | (dni jsrs16 "jsrs Imm-8-QI" ((machine 16)) | |
8259 | ("jsrs #${Imm-8-QI}") | |
8260 | (+ (f-0-4 #xE) (f-4-4 #xF) Imm-8-QI) | |
8261 | (jsr16-sem 2 Imm-8-QI) | |
8262 | ()) | |
8263 | ; jsrs imm8 (m32 #1) | |
8264 | (dni jsrs "jsrs #Imm-8-QI" ((machine 32)) | |
8265 | ("jsrs #${Imm-8-QI}") | |
8266 | (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI) | |
8267 | (jsr32-sem 2 Imm-8-QI) | |
8268 | ()) | |
8269 | ||
8270 | ;------------------------------------------------------------- | |
8271 | ; ldc - load control register | |
8272 | ; stc - store control register | |
8273 | ;------------------------------------------------------------- | |
8274 | ||
8275 | (define-pmacro (ldc32-cr1-sem src dst) | |
8276 | (sequence () | |
8277 | (case DFLT dst | |
8278 | ((#x0) (set (reg h-dct0) src)) | |
8279 | ((#x1) (set (reg h-dct1) src)) | |
8280 | ((#x2) (sequence ((HI tflag)) | |
8281 | (set tflag src) | |
8282 | (if (and tflag #x1) (set cbit 1)) | |
8283 | (if (and tflag #x2) (set dbit 1)) | |
8284 | (if (and tflag #x4) (set zbit 1)) | |
8285 | (if (and tflag #x8) (set sbit 1)) | |
8286 | (if (and tflag #x10) (set bbit 1)) | |
8287 | (if (and tflag #x20) (set obit 1)) | |
8288 | (if (and tflag #x40) (set ibit 1)) | |
8289 | (if (and tflag #x80) (set ubit 1)))) | |
8290 | ((#x3) (set (reg h-svf) src)) | |
8291 | ((#x4) (set (reg h-drc0) src)) | |
8292 | ((#x5) (set (reg h-drc1) src)) | |
8293 | ((#x6) (set (reg h-dmd0) src)) | |
8294 | ((#x7) (set (reg h-dmd1) src)) | |
8295 | ) | |
8296 | ) | |
8297 | ) | |
8298 | (define-pmacro (ldc32-cr2-sem src dst) | |
8299 | (sequence () | |
8300 | (case DFLT dst | |
8301 | ((#x0) (set (reg h-intb) src)) | |
8302 | ((#x1) (set (reg h-sp) src)) | |
8303 | ((#x2) (set (reg h-sb) src)) | |
8304 | ((#x3) (set (reg h-fb) src)) | |
8305 | ((#x4) (set (reg h-svp) src)) | |
8306 | ((#x5) (set (reg h-vct) src)) | |
8307 | ((#x7) (set (reg h-isp) src)) | |
8308 | ) | |
8309 | ) | |
8310 | ) | |
8311 | (define-pmacro (ldc32-cr3-sem src dst) | |
8312 | (sequence () | |
8313 | (case DFLT dst | |
8314 | ((#x2) (set (reg h-dma0) src)) | |
8315 | ((#x3) (set (reg h-dma1) src)) | |
8316 | ((#x4) (set (reg h-dra0) src)) | |
8317 | ((#x5) (set (reg h-dra1) src)) | |
8318 | ((#x6) (set (reg h-dsa0) src)) | |
8319 | ((#x7) (set (reg h-dsa1) src)) | |
8320 | ) | |
8321 | ) | |
8322 | ) | |
8323 | (define-pmacro (ldc16-sem src dst) | |
8324 | (sequence () | |
8325 | (case DFLT dst | |
8326 | ((#x1) (set (reg h-intb) src)) | |
8327 | ((#x2) (set (reg h-intb) (or (reg h-intb) (sll src (const 16))))) | |
8328 | ((#x3) (sequence ((HI tflag)) | |
8329 | (set tflag src) | |
8330 | (if (and tflag #x1) (set cbit 1)) | |
8331 | (if (and tflag #x2) (set dbit 1)) | |
8332 | (if (and tflag #x4) (set zbit 1)) | |
8333 | (if (and tflag #x8) (set sbit 1)) | |
8334 | (if (and tflag #x10) (set bbit 1)) | |
8335 | (if (and tflag #x20) (set obit 1)) | |
8336 | (if (and tflag #x40) (set ibit 1)) | |
8337 | (if (and tflag #x80) (set ubit 1)))) | |
8338 | ((#x4) (set (reg h-isp) src)) | |
8339 | ((#x5) (set (reg h-sp) src)) | |
8340 | ((#x6) (set (reg h-sb) src)) | |
8341 | ((#x7) (set (reg h-fb) src)) | |
8342 | ) | |
8343 | ) | |
8344 | ) | |
8345 | ||
8346 | (define-pmacro (stc32-cr1-sem src dst) | |
8347 | (sequence () | |
8348 | (case DFLT src | |
8349 | ((#x0) (set dst (reg h-dct0))) | |
8350 | ((#x1) (set dst (reg h-dct1))) | |
8351 | ((#x2) (sequence ((HI tflag)) | |
8352 | (set tflag 0) | |
8353 | (if (eq cbit 1) (set tflag (or tflag #x1))) | |
8354 | (if (eq dbit 1) (set tflag (or tflag #x2))) | |
8355 | (if (eq zbit 1) (set tflag (or tflag #x4))) | |
8356 | (if (eq sbit 1) (set tflag (or tflag #x8))) | |
8357 | (if (eq bbit 1) (set tflag (or tflag #x10))) | |
8358 | (if (eq obit 1) (set tflag (or tflag #x20))) | |
8359 | (if (eq ibit 1) (set tflag (or tflag #x40))) | |
8360 | (if (eq ubit 1) (set tflag (or tflag #x80))) | |
8361 | (set dst tflag))) | |
8362 | ((#x3) (set dst (reg h-svf))) | |
8363 | ((#x4) (set dst (reg h-drc0))) | |
8364 | ((#x5) (set dst (reg h-drc1))) | |
8365 | ((#x6) (set dst (reg h-dmd0))) | |
8366 | ((#x7) (set dst (reg h-dmd1))) | |
8367 | ) | |
8368 | ) | |
8369 | ) | |
8370 | (define-pmacro (stc32-cr2-sem src dst) | |
8371 | (sequence () | |
8372 | (case DFLT src | |
8373 | ((#x0) (set dst (reg h-intb))) | |
8374 | ((#x1) (set dst (reg h-sp))) | |
8375 | ((#x2) (set dst (reg h-sb))) | |
8376 | ((#x3) (set dst (reg h-fb))) | |
8377 | ((#x4) (set dst (reg h-svp))) | |
8378 | ((#x5) (set dst (reg h-vct))) | |
8379 | ((#x7) (set dst (reg h-isp))) | |
8380 | ) | |
8381 | ) | |
8382 | ) | |
8383 | (define-pmacro (stc32-cr3-sem src dst) | |
8384 | (sequence () | |
8385 | (case DFLT src | |
8386 | ((#x2) (set dst (reg h-dma0))) | |
8387 | ((#x3) (set dst (reg h-dma1))) | |
8388 | ((#x4) (set dst (reg h-dra0))) | |
8389 | ((#x5) (set dst (reg h-dra1))) | |
8390 | ((#x6) (set dst (reg h-dsa0))) | |
8391 | ((#x7) (set dst (reg h-dsa1))) | |
8392 | ) | |
8393 | ) | |
8394 | ) | |
8395 | (define-pmacro (stc16-sem src dst) | |
8396 | (sequence () | |
8397 | (case DFLT src | |
8398 | ((#x1) (set dst (and (reg h-intb) (const #xffff)))) | |
8399 | ((#x2) (set dst (srl (reg h-intb) (const 16)))) | |
8400 | ((#x3) (sequence ((HI tflag)) | |
8401 | (set tflag 0) | |
8402 | (if (eq cbit 1) (set tflag (or tflag #x1))) | |
8403 | (if (eq dbit 1) (set tflag (or tflag #x2))) | |
8404 | (if (eq zbit 1) (set tflag (or tflag #x4))) | |
8405 | (if (eq sbit 1) (set tflag (or tflag #x8))) | |
8406 | (if (eq bbit 1) (set tflag (or tflag #x10))) | |
8407 | (if (eq obit 1) (set tflag (or tflag #x20))) | |
8408 | (if (eq ibit 1) (set tflag (or tflag #x40))) | |
8409 | (if (eq ubit 1) (set tflag (or tflag #x80))) | |
8410 | (set dst tflag))) | |
8411 | ((#x4) (set dst (reg h-isp))) | |
8412 | ((#x5) (set dst (reg h-sp))) | |
8413 | ((#x6) (set dst (reg h-sb))) | |
8414 | ((#x7) (set dst (reg h-fb))) | |
8415 | ) | |
8416 | ) | |
8417 | ) | |
8418 | ||
8419 | (dni ldc16.imm16 "ldc #imm,dst" ((machine 16)) | |
8420 | ("ldc #${Imm-16-HI},${cr16}") | |
8421 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 0) cr16 Imm-16-HI) | |
8422 | (ldc16-sem Imm-16-HI cr16) | |
8423 | ()) | |
8424 | ||
8425 | (dni ldc16.dst "ldc src,dest" ((machine 16)) | |
8426 | ("ldc ${dst16-16-HI},${cr16}") | |
8427 | (+ (f-0-4 7) (f-4-4 #xA) (f-8-1 1) cr16 dst16-16-HI) | |
8428 | (ldc16-sem dst16-16-HI cr16) | |
8429 | ()) | |
8430 | ; ldc src,dest (m32c #4) | |
8431 | (dni ldc32.src-cr1 "ldc src,dst" ((machine 32)) | |
8432 | ("ldc ${dst32-24-Prefixed-HI},${cr1-Prefixed-32}") | |
8433 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-HI (f-15-1 1) (f-18-2 0) (f-20-1 1) cr1-Prefixed-32) | |
8434 | (ldc32-cr1-sem dst32-24-Prefixed-HI cr1-Prefixed-32) | |
8435 | ()) | |
8436 | ; ldc src,dest (m32c #5) | |
8437 | (dni ldc32.src-cr2 "ldc src,dest" ((machine 32)) | |
8438 | ("ldc ${dst32-16-Unprefixed-SI},${cr2-32}") | |
8439 | (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 0) cr2-32) | |
8440 | (ldc32-cr2-sem dst32-16-Unprefixed-SI cr2-32) | |
8441 | ()) | |
8442 | ; ldc src,dest (m32c #6) | |
8443 | (dni ldc32.src-cr3 "ldc src,dst" ((machine 32)) | |
8444 | ("ldc ${dst32-24-Prefixed-SI},${cr3-Prefixed-32}") | |
8445 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-SI (f-15-1 1) (f-18-2 0) (f-20-1 0) cr3-Prefixed-32) | |
8446 | (ldc32-cr3-sem dst32-24-Prefixed-SI cr3-Prefixed-32) | |
8447 | ()) | |
8448 | ; ldc src,dest (m32c #1) | |
8449 | (dni ldc32.imm16-cr1 "ldc #imm,dst" ((machine 32)) | |
8450 | ("ldc #${Imm-16-HI},${cr1-Unprefixed-32}") | |
8451 | (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32 Imm-16-HI) | |
8452 | (ldc32-cr1-sem Imm-16-HI cr1-Unprefixed-32) | |
8453 | ()) | |
8454 | ; ldc src,dest (m32c #2) | |
8455 | (dni ldc32.imm16-cr2 "ldc #imm,dst" ((machine 32)) | |
8456 | ("ldc #${Dsp-16-u24},${cr2-32}") | |
8457 | (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 2) (f-12-1 1) cr2-32 Dsp-16-u24) | |
8458 | (ldc32-cr2-sem Dsp-16-u24 cr2-32) | |
8459 | ()) | |
8460 | ; ldc src,dest (m32c #3) | |
8461 | (dni ldc32.imm16-cr3 "ldc #imm,dst" ((machine 32)) | |
8462 | ("ldc #${Dsp-16-u24},${cr3-Unprefixed-32}") | |
8463 | (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 6) (f-12-1 1) cr3-Unprefixed-32 Dsp-16-u24) | |
8464 | (ldc32-cr3-sem Dsp-16-u24 cr3-Unprefixed-32) | |
8465 | ()) | |
8466 | ||
8467 | (dni stc16.src "stc src,dest" ((machine 16)) | |
8468 | ("stc ${cr16},${dst16-16-HI}") | |
8469 | (+ (f-0-4 7) (f-4-4 #xB) (f-8-1 1) cr16 dst16-16-HI) | |
8470 | (stc16-sem cr16 dst16-16-HI ) | |
8471 | ()) | |
8472 | ||
8473 | (dni stc16.pc "stc pc,dest" ((machine 16)) | |
8474 | ("stc pc,${dst16-16-HI}") | |
8475 | (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xC) dst16-16-HI) | |
8476 | (sequence () (set dst16-16-HI (reg h-pc))) | |
8477 | ()) | |
8478 | ||
8479 | (dni stc32.src-cr1 "stc src,dst" ((machine 32)) | |
8480 | ("stc ${cr1-Prefixed-32},${dst32-24-Prefixed-HI}") | |
8481 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-HI (f-15-1 1) (f-18-2 1) (f-20-1 1) cr1-Prefixed-32) | |
8482 | (stc32-cr1-sem cr1-Prefixed-32 dst32-24-Prefixed-HI ) | |
8483 | ()) | |
8484 | ||
8485 | (dni stc32.src-cr2 "stc src,dest" ((machine 32)) | |
8486 | ("stc ${cr2-32},${dst32-16-Unprefixed-SI}") | |
8487 | (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 2) cr2-32) | |
8488 | (stc32-cr2-sem cr2-32 dst32-16-Unprefixed-SI ) | |
8489 | ()) | |
8490 | ||
8491 | (dni stc32.src-cr3 "stc src,dst" ((machine 32)) | |
8492 | ("stc ${cr3-Prefixed-32},${dst32-24-Prefixed-SI}") | |
8493 | (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-SI (f-15-1 1) (f-18-2 1) (f-20-1 0) cr3-Prefixed-32) | |
8494 | (stc32-cr3-sem cr3-Prefixed-32 dst32-24-Prefixed-SI ) | |
8495 | ()) | |
8496 | ||
8497 | ;------------------------------------------------------------- | |
8498 | ; ldctx - load context | |
8499 | ; stctx - store context | |
8500 | ;------------------------------------------------------------- | |
8501 | ||
8502 | ; ??? semantics | |
8503 | (dni ldctx16 "ldctx abs16,abs24" ((machine 16)) | |
8504 | ("ldctx ${Dsp-16-u16},${Dsp-32-u24}") | |
8505 | (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24) | |
8506 | (nop) | |
8507 | ()) | |
8508 | (dni ldctx32 "ldctx abs16,abs24" ((machine 32)) | |
8509 | ("ldctx ${Dsp-16-u16},${Dsp-32-u24}") | |
8510 | (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xC) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24) | |
8511 | (nop) | |
8512 | ()) | |
8513 | (dni stctx16 "stctx abs16,abs24" ((machine 16)) | |
8514 | ("stctx ${Dsp-16-u16},${Dsp-32-u24}") | |
8515 | (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24) | |
8516 | (nop) | |
8517 | ()) | |
8518 | (dni stctx32 "stctx abs16,abs24" ((machine 32)) | |
8519 | ("stctx ${Dsp-16-u16},${Dsp-32-u24}") | |
8520 | (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xD) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24) | |
8521 | (nop) | |
8522 | ()) | |
8523 | ||
8524 | ;------------------------------------------------------------- | |
8525 | ; lde - load from extra far data area (m16) | |
8526 | ; ste - store to extra far data area (m16) | |
8527 | ;------------------------------------------------------------- | |
8528 | ||
a1a280bb DD |
8529 | (lde-dst QI .b 0) |
8530 | (lde-dst HI .w 1) | |
49f58d10 | 8531 | |
a1a280bb DD |
8532 | (ste-dst QI .b 0) |
8533 | (ste-dst HI .w 1) | |
49f58d10 JB |
8534 | |
8535 | ;------------------------------------------------------------- | |
8536 | ; ldipl - load interrupt permission level | |
8537 | ;------------------------------------------------------------- | |
8538 | ||
8539 | ; ??? semantics | |
8540 | ; ldintb <==> ldc #imm,intbh ; ldc #imm,intbl | |
8541 | (dni ldipl16.imm "ldipl #imm" ((machine 16)) | |
8542 | ("ldipl #${Imm-13-u3}") | |
8543 | (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xA) (f-12-1 0) Imm-13-u3) | |
8544 | (nop) | |
8545 | ()) | |
8546 | (dni ldipl32.imm "ldipl #imm" ((machine 32)) | |
8547 | ("ldipl #${Imm-13-u3}") | |
8548 | (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xE) (f-12-1 1) Imm-13-u3) | |
8549 | (nop) | |
8550 | ()) | |
8551 | ||
8552 | ||
8553 | ;------------------------------------------------------------- | |
8554 | ; max - maximum value | |
8555 | ;------------------------------------------------------------- | |
8556 | ||
8557 | ; TODO check semantics for min -1,0 | |
8558 | (define-pmacro (max-sem mode src dst) | |
8559 | (sequence () | |
8560 | (if (gt mode src dst) | |
8561 | (set mode dst src))) | |
8562 | ) | |
8563 | ||
8564 | ; max.size:G #imm,dst | |
8565 | (binary-arith32-imm-dst-Prefixed QI QI .b 0 max X #x8 #x3 #xF max-sem) | |
8566 | (binary-arith32-imm-dst-Prefixed HI HI .w 1 max X #x8 #x3 #xF max-sem) | |
8567 | ||
8568 | ; max.BW:G src,dst | |
8569 | (binary-arith32-src-dst-Prefixed QI QI .b 0 max X #x1 #xD max-sem) | |
8570 | (binary-arith32-src-dst-Prefixed HI HI .w 1 max X #x1 #xD max-sem) | |
8571 | ||
8572 | ;------------------------------------------------------------- | |
8573 | ; min - minimum value | |
8574 | ;------------------------------------------------------------- | |
8575 | ||
8576 | (define-pmacro (min-sem mode src dst) | |
8577 | (sequence () | |
8578 | (if (lt mode src dst) | |
8579 | (set mode dst src))) | |
8580 | ) | |
8581 | ||
8582 | ; min.size:G #imm,dst | |
8583 | (binary-arith32-imm-dst-Prefixed QI QI .b 0 min X #x8 #x2 #xF min-sem) | |
8584 | (binary-arith32-imm-dst-Prefixed HI HI .w 1 min X #x8 #x2 #xF min-sem) | |
8585 | ||
8586 | ; min.BW:G src,dst | |
8587 | (binary-arith32-src-dst-Prefixed QI QI .b 0 min X #x1 #xC min-sem) | |
8588 | (binary-arith32-src-dst-Prefixed HI HI .w 1 min X #x1 #xC min-sem) | |
8589 | ||
8590 | ;------------------------------------------------------------- | |
8591 | ; mov - move | |
8592 | ;------------------------------------------------------------- | |
8593 | ||
8594 | (define-pmacro (mov-sem mode src1 dst) | |
8595 | (sequence ((mode result)) | |
8596 | (set result src1) | |
8597 | (set-z-and-s result) | |
8598 | (set mode dst src1)) | |
8599 | ) | |
8600 | ||
8601 | (define-pmacro (mov-dspsp-dst-sem mach mode src1 dst) | |
8602 | (set dst (mem-mach mach mode (add sp src1))) | |
8603 | ) | |
8604 | ||
8605 | (define-pmacro (mov-src-dspsp-sem mach mode src dst1) | |
8606 | (set (mem-mach mach mode (add sp dst1)) src) | |
8607 | ) | |
8608 | ||
8609 | (define-pmacro (mov16-imm-an-defn size mode imm regn op1 op2) | |
8610 | (dni (.sym mov16. size .S-imm- regn) | |
8611 | (.str "mov." size ":S " imm "," regn) | |
8612 | ((machine 16)) | |
8613 | (.str "mov." size "$S #${" imm "}," regn) | |
8614 | (+ op1 op2 imm) | |
8615 | (mov-sem mode imm (reg (.sym h- regn))) | |
8616 | ()) | |
8617 | ) | |
8618 | ; mov.size:G #imm,dst (m16 #1 m32 #1) | |
8619 | (binary-arith-imm-dst mov G (f-0-4 7) (f-4-3 2) (f-8-4 #xC) #x9 #x2 #xF mov-sem) | |
8620 | ; mov.L:G #imm32,dst (m32 #2) | |
8621 | (binary-arith32-imm-dst-defn SI SI .l 0 mov G #xB #x3 #x1 mov-sem) | |
49f58d10 JB |
8622 | ; mov.BW:S #imm,dst2 (m32 #4) |
8623 | (binary-arith32-s-imm-dst QI .b 0 mov #x0 #x2 mov-sem) | |
8624 | (binary-arith32-s-imm-dst HI .w 1 mov #x0 #x2 mov-sem) | |
8625 | ; mov.b:S #imm8,dst3 (m16 #3) | |
8626 | (binary-arith16-b-S-imm8-dst3 mov ".b" (f-0-4 #xC) (f-4-1 0) mov-sem) | |
8627 | ; mov.b:S #imm8,aN (m16 #4) | |
8628 | (mov16-imm-an-defn b QI Imm-8-QI a0 (f-0-4 #xE) (f-4-4 2)) | |
8629 | (mov16-imm-an-defn b QI Imm-8-QI a1 (f-0-4 #xE) (f-4-4 #xA)) | |
8630 | (mov16-imm-an-defn w HI Imm-8-HI a0 (f-0-4 #xA) (f-4-4 2)) | |
8631 | (mov16-imm-an-defn w HI Imm-8-HI a1 (f-0-4 #xA) (f-4-4 #xA)) | |
8632 | ; mov.WL:S #imm,A0/A1 (m32 #5) | |
8633 | (define-pmacro (mov32-wl-s-defn mode sz op1 imm regn op2) | |
8634 | (dni (.sym mov32- sz - regn) | |
8635 | (.str "mov." sz ":s" imm "," regn) | |
8636 | ((machine 32)) | |
8637 | (.str "mov." sz "$S #${" imm "}," regn) | |
8638 | (+ (f-0-4 op1) (f-4-4 op2) imm) | |
8639 | (mov-sem mode imm (reg (.sym h- regn))) | |
8640 | ()) | |
8641 | ) | |
8642 | (mov32-wl-s-defn HI w #x9 Imm-8-HI a0 #xC) | |
8643 | (mov32-wl-s-defn HI w #x9 Imm-8-HI a1 #xD) | |
f75eb1c0 DD |
8644 | (mov32-wl-s-defn SI l #xB Dsp-8-s24 a0 #xC) |
8645 | (mov32-wl-s-defn SI l #xB Dsp-8-s24 a1 #xD) | |
e729279b NC |
8646 | |
8647 | ; mov.size:Q #imm4,dst (m16 #2 m32 #3) | |
8648 | (binary-arith16-imm4-dst-defn QI .b 0 0 mov (f-0-4 #xD) (f-4-3 4) mov-sem) | |
8649 | (binary-arith16-imm4-dst-defn QI .w 0 1 mov (f-0-4 #xD) (f-4-3 4) mov-sem) | |
8650 | (binary-arith32-imm4-dst-defn QI .b 1 0 mov #x7 #x2 mov-sem) | |
8651 | (binary-arith32-imm4-dst-defn HI .w 1 1 mov #x7 #x2 mov-sem) | |
49f58d10 JB |
8652 | |
8653 | ; mov.BW:Z #0,dst (m16 #5 m32 #6) | |
8654 | (dni mov16.b-Z-imm8-dst3 | |
8655 | "mov.b:Z #0,Dst16-3-S-8" | |
8656 | ((machine 16)) | |
8657 | "mov.b$Z #0,${Dst16-3-S-8}" | |
8658 | (+ (f-0-4 #xB) (f-4-1 #x0) Dst16-3-S-8) | |
8659 | (mov-sem QI (const 0) Dst16-3-S-8) | |
8660 | ()) | |
8661 | ; (binary-arith16-b-Z-imm8-dst3 mov ".b" (f-0-4 #xB) (f-4-1 0) mov-sem) | |
8662 | (binary-arith32-z-imm-dst QI .b 0 mov #x0 #x1 mov-sem) | |
8663 | (binary-arith32-z-imm-dst HI .w 1 mov #x0 #x1 mov-sem) | |
8664 | ; mov.BW:G src,dst (m16 #6 m32 #7) | |
8665 | (binary-arith-src-dst mov G (f-0-4 #x7) (f-4-3 1) #x1 #xB mov-sem) | |
8666 | ; mov.B:S src2,a0/a1 (m16 #7) | |
8667 | (dni (.sym mov 16 .b.S-An) | |
8668 | (.str mov ".b:S src2,a[01]") | |
8669 | ((machine 16)) | |
8670 | (.str mov ".b$S ${src16-2-S},${Dst16AnQI-S}") | |
8671 | (+ (f-0-4 #x3) (f-4-1 0) Dst16AnQI-S src16-2-S) | |
8672 | (mov-sem QI src16-2-S Dst16AnQI-S) | |
8673 | ()) | |
8674 | (define-pmacro (mov16-b-s-an-defn op1 op2 op2c) | |
8675 | (dni (.sym mov16.b.S- op1 - op2) | |
8676 | (.str mov ".b:S " op1 "," op2) | |
8677 | ((machine 16)) | |
8678 | (.str mov ".b$S " op1 "," op2) | |
8679 | (+ (f-0-4 #x3) op2c) | |
8680 | (mov-sem QI (reg (.sym h- op1)) (reg (.sym h- op2))) | |
8681 | ()) | |
8682 | ) | |
8683 | (mov16-b-s-an-defn r0l a1 (f-4-4 #x4)) | |
8684 | (mov16-b-s-an-defn r0h a0 (f-4-4 #x0)) | |
8685 | ||
8686 | ; mov.L:G src,dst (m32 #8) | |
8687 | (binary-arith32-src-dst-defn SI SI .l 1 mov G #x1 #x3 mov-sem) | |
8688 | ; mov.B:S r0l/r0h,dst2 (m16 #8) | |
8689 | (dni (.sym mov 16 .b.S-Rn-An) | |
8690 | (.str mov ".b:S r0[lh],src2") | |
8691 | ((machine 16)) | |
8692 | (.str mov ".b$S ${Dst16RnQI-S},${src16-2-S}") | |
8693 | (+ (f-0-4 #x0) (f-4-1 0) Dst16RnQI-S src16-2-S) | |
8694 | (mov-sem QI src16-2-S Dst16RnQI-S) | |
8695 | ()) | |
8696 | ||
8697 | ; mov.B.S src2,r0l/r0h (m16 #9) | |
8698 | (binary-arith16-b-S-src2 mov (f-0-4 0) (f-4-1 1) mov-sem) | |
8699 | ||
8700 | ; mov.BW:S src2,r0l/r0 (m32 #9) | |
8701 | ; mov.BW:S src2,r1l/r1 (m32 #10) | |
8702 | (define-pmacro (mov32-src-r sz szcode mode src dst opc1 opc2) | |
8703 | (begin | |
8704 | (dni (.sym mov32. sz - src - dst) | |
8705 | (.str "mov." sz "src," dst) | |
8706 | ((machine 32)) | |
8707 | (.str "mov." sz "$S ${" (.sym src - mode) "}," dst) | |
8708 | (+ (f-0-2 opc1) (.sym src - mode) (f-4-3 opc2) (f-7-1 szcode)) | |
8709 | (mov-sem mode (.sym src - mode) (reg (.sym h- dst))) | |
8710 | ()) | |
8711 | ) | |
8712 | ) | |
8713 | (mov32-src-r b 0 QI dst32-2-S-16 r0l 0 4) | |
8714 | (mov32-src-r w 1 HI dst32-2-S-16 r0 0 4) | |
8715 | (mov32-src-r b 0 QI dst32-2-S-8 r0l 0 4) | |
8716 | (mov32-src-r w 1 HI dst32-2-S-8 r0 0 4) | |
8717 | (mov32-src-r b 0 QI dst32-2-S-basic r1l 1 7) | |
f75eb1c0 | 8718 | (mov32-src-r w 1 HI dst32-2-S-basic r1 1 7) |
49f58d10 JB |
8719 | (mov32-src-r b 0 QI dst32-2-S-16 r1l 1 7) |
8720 | (mov32-src-r w 1 HI dst32-2-S-16 r1 1 7) | |
8721 | (mov32-src-r b 0 QI dst32-2-S-8 r1l 1 7) | |
8722 | (mov32-src-r w 1 HI dst32-2-S-8 r1 1 7) | |
8723 | ||
8724 | ; mov.BW:S r0l/r0,dst2 (m32 #11) | |
8725 | (define-pmacro (mov32-r-dest sz szcode mode src dst opc1 opc2) | |
8726 | (begin | |
8727 | (dni (.sym mov32. sz - src - dst) | |
8728 | (.str "mov." sz "src," dst) | |
8729 | ((machine 32)) | |
8730 | (.str "mov." sz "$S " src ",${" (.sym dst - mode) "}") | |
8731 | (+ (f-0-2 opc1) (.sym dst - mode) (f-4-3 opc2) (f-7-1 szcode)) | |
8732 | (mov-sem mode (reg (.sym h- src)) (.sym dst - mode)) | |
8733 | ()) | |
8734 | ) | |
8735 | ) | |
8736 | (mov32-r-dest b 0 QI r0l dst32-2-S-16 0 0) | |
8737 | (mov32-r-dest w 1 HI r0 dst32-2-S-16 0 0) | |
8738 | (mov32-r-dest b 0 QI r0l dst32-2-S-8 0 0) | |
8739 | (mov32-r-dest w 1 HI r0 dst32-2-S-8 0 0) | |
8740 | ||
8741 | ; mov.L:S src,A0/A1 (m32 #12) | |
8742 | (define-pmacro (mov32-src-a src dst dstcode opc1 opc2) | |
8743 | (begin | |
8744 | (dni (.sym mov32. sz - src - dst) | |
8745 | (.str "mov." sz "src," dst) | |
8746 | ((machine 32)) | |
8747 | (.str "mov.l" "$S ${" (.sym src - SI) "}," dst) | |
8748 | (+ (f-0-2 opc1) (.sym src - SI) (f-4-3 opc2) (f-7-1 dstcode)) | |
8749 | (mov-sem SI (.sym src - SI) (reg (.sym h- dst))) | |
8750 | ()) | |
8751 | ) | |
8752 | ) | |
8753 | (mov32-src-a dst32-2-S-16 a0 0 1 4) | |
8754 | (mov32-src-a dst32-2-S-16 a1 1 1 4) | |
8755 | (mov32-src-a dst32-2-S-8 a0 0 1 4) | |
8756 | (mov32-src-a dst32-2-S-8 a1 1 1 4) | |
8757 | ||
8758 | ; mov.BW:G dsp8[sp],dst (m16 #10 m32 #13) | |
8759 | ; mov.BW:G src,dsp8[sp] (m16 #11 m32 #14) | |
8760 | (mov-dspsp-dst mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #xB) #xB #x0 #xF mov-dspsp-dst-sem) | |
8761 | (mov-src-dspsp mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #x3) #xA #x0 #xF mov-src-dspsp-sem) | |
8762 | ||
8763 | ;------------------------------------------------------------- | |
8764 | ; mova - move effective address | |
8765 | ;------------------------------------------------------------- | |
8766 | ||
8767 | (define-pmacro (mov16a-defn dst dstop dstcode) | |
8768 | (dni (.sym mova16. src - dst) | |
8769 | (.str "mova src," dst) | |
8770 | ((machine 16)) | |
8771 | (.str "mova ${dst16-16-Mova-HI}," dst) | |
8772 | (+ (f-0-4 #xE) (f-4-4 #xB) dst16-16-Mova-HI (f-8-4 dstcode)) | |
8773 | (sequence () (set HI (reg dstop) dst16-16-Mova-HI)) | |
8774 | ()) | |
8775 | ) | |
8776 | (mov16a-defn r0 h-r0 0) | |
8777 | (mov16a-defn r1 h-r1 1) | |
8778 | (mov16a-defn r2 h-r2 2) | |
8779 | (mov16a-defn r3 h-r3 3) | |
8780 | (mov16a-defn a0 h-a0 4) | |
8781 | (mov16a-defn a1 h-a1 5) | |
8782 | ||
8783 | (define-pmacro (mov32a-defn dst dstop dstcode) | |
8784 | (dni (.sym mova32. src - dst) | |
8785 | (.str "mova src," dst) | |
8786 | ((machine 32)) | |
8787 | (.str "mova ${dst32-16-Unprefixed-Mova-SI}," dst) | |
8788 | (+ (f-0-4 #xD) dst32-16-Unprefixed-Mova-SI (f-7-1 1) (f-10-2 1) (f-12-1 1) (f-13-3 dstcode)) | |
8789 | (sequence () (set SI (reg dstop) dst32-16-Unprefixed-Mova-SI)) | |
8790 | ()) | |
8791 | ) | |
8792 | (mov32a-defn r2r0 h-r2r0 0) | |
8793 | (mov32a-defn r3r1 h-r3r1 1) | |
8794 | (mov32a-defn a0 h-a0 2) | |
8795 | (mov32a-defn a1 h-a1 3) | |
8796 | ||
8797 | ;------------------------------------------------------------- | |
8798 | ; movDir - move nibble | |
8799 | ;------------------------------------------------------------- | |
8800 | ||
8801 | (define-pmacro (movdir-sem nib src dst) | |
8802 | (sequence ((SI tmp)) | |
8803 | (case DFLT nib | |
8804 | ((0) (set dst (or (and dst #xf0) (and src #xf)))) | |
8805 | ((1) (set dst (or (and dst #x0f) (sll (and src #xf) 4)))) | |
8806 | ((2) (set dst (or (and dst #xf0) (srl (and src #xf0) 4)))) | |
8807 | ((3) (set dst (or (and dst #x0f) (and src #xf0)))) | |
8808 | ) | |
8809 | ) | |
8810 | ) | |
8811 | ; movDir src,dst | |
8812 | (define-pmacro (mov16dir-1-defn nib dircode dir) | |
8813 | (dni (.sym mov nib 16 ".r0l-dst") | |
8814 | (.str "mov" nib " r0l,dst") | |
8815 | ((machine 16)) | |
8816 | (.str "mov" nib " r0l,${dst16-16-QI}") | |
8817 | (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI) | |
8818 | (movdir-sem dircode (reg h-r0l) dst16-16-QI) | |
8819 | ()) | |
8820 | ) | |
8821 | (mov16dir-1-defn ll 0 8) | |
8822 | (mov16dir-1-defn lh 1 #xA) | |
8823 | (mov16dir-1-defn hl 2 9) | |
8824 | (mov16dir-1-defn hh 3 #xB) | |
8825 | (define-pmacro (mov16dir-2-defn nib dircode dir) | |
8826 | (dni (.sym mov nib 16 ".src-r0l") | |
8827 | (.str "mov" nib " src,r0l") | |
8828 | ((machine 16)) | |
8829 | (.str "mov" nib " ${dst16-16-QI},r0l") | |
8830 | (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI) | |
8831 | (movdir-sem dircode dst16-16-QI (reg h-r0l)) | |
8832 | ()) | |
8833 | ) | |
8834 | (mov16dir-2-defn ll 0 0) | |
8835 | (mov16dir-2-defn lh 1 2) | |
8836 | (mov16dir-2-defn hl 2 1) | |
8837 | (mov16dir-2-defn hh 3 3) | |
8838 | ||
8839 | (define-pmacro (mov32dir-1-defn nib o1o0) | |
8840 | (dni (.sym mov nib 32 ".r0l-dst") | |
8841 | (.str "mov" nib " r0l,dst") | |
8842 | ((machine 32)) | |
8843 | (.str "mov" nib " r0l,${dst32-24-Prefixed-QI}") | |
8844 | (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #xB) dst32-24-Prefixed-QI (f-15-1 0) (f-18-2 o1o0) (f-20-4 #xE)) | |
8845 | (movdir-sem o1o0 (reg h-r0l) dst32-24-Prefixed-QI) | |
8846 | ()) | |
8847 | ) | |
8848 | (mov32dir-1-defn ll 0) | |
8849 | (mov32dir-1-defn lh 1) | |
8850 | (mov32dir-1-defn hl 2) | |
8851 | (mov32dir-1-defn hh 3) | |
8852 | (define-pmacro (mov32dir-2-defn nib o1o0) | |
8853 | (dni (.sym mov nib 32 ".src-r0l") | |
8854 | (.str "mov" nib " src,r0l") | |
8855 | ((machine 32)) | |
8856 | (.str "mov" nib " ${dst32-24-Prefixed-QI},r0l") | |
8857 | (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #xA) dst32-24-Prefixed-QI (f-15-1 0) (f-18-2 o1o0) (f-20-4 #xE)) | |
8858 | (movdir-sem o1o0 dst32-24-Prefixed-QI (reg h-r0l)) | |
8859 | ()) | |
8860 | ) | |
8861 | (mov32dir-2-defn ll 0) | |
8862 | (mov32dir-2-defn lh 1) | |
8863 | (mov32dir-2-defn hl 2) | |
8864 | (mov32dir-2-defn hh 3) | |
8865 | ||
8866 | ;------------------------------------------------------------- | |
8867 | ; movx - move extend sign (m32) | |
8868 | ;------------------------------------------------------------- | |
8869 | ||
8870 | (define-pmacro (movx-sem mode src dst) | |
8871 | (sequence ((SI source) (SI result)) | |
8872 | (set SI result src) | |
8873 | (set-z-and-s result) | |
8874 | (set dst result)) | |
8875 | ) | |
8876 | ||
8877 | ; movx #imm,dst | |
8878 | (binary-arith32-imm-dst-defn QI SI "" 0 movx X #xB #x1 #x1 movx-sem) | |
8879 | ||
8880 | ;------------------------------------------------------------- | |
8881 | ; mul - multiply | |
8882 | ;------------------------------------------------------------- | |
8883 | ||
8884 | (define-pmacro (mul-sem mode src1 dst) | |
8885 | (sequence ((mode result)) | |
8886 | (set obit (add-oflag mode src1 dst 0)) | |
8887 | (set result (mul mode src1 dst)) | |
8888 | (set dst result)) | |
8889 | ) | |
8890 | ||
8891 | ; mul.BW #imm,dst | |
8892 | (binary-arith-imm-dst mul G (f-0-4 7) (f-4-3 6) (f-8-4 5) #x8 #x1 #xF mul-sem) | |
8893 | ; mul.BW src,dst | |
8894 | (binary-arith-src-dst mul G (f-0-4 #x7) (f-4-3 4) #x1 #xC mul-sem) | |
8895 | ||
8896 | ;------------------------------------------------------------- | |
8897 | ; mulex - multiple extend sign (m32) | |
8898 | ;------------------------------------------------------------- | |
8899 | ||
8900 | ; mulex src,dst | |
8901 | ; (dni mulex-absolute-indirect "mulex [src]" ((machine 32)) | |
8902 | ; ("mulex ${dst32-24-absolute-indirect-HI}") | |
8903 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 #xC) dst32-24-absolute-indirect-HI (f-15-1 1) (f-18-2 3) (f-20-4 #xE)) | |
8904 | ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-absolute-indirect-HI))) | |
8905 | ; ()) | |
8906 | (dni mulex "mulex src" ((machine 32)) | |
8907 | ("mulex ${dst32-16-Unprefixed-Mulex-HI}") | |
8908 | (+ (f-0-4 #xC) dst32-16-Unprefixed-Mulex-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE)) | |
8909 | (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-16-Unprefixed-Mulex-HI))) | |
8910 | ()) | |
8911 | ; (dni mulex-indirect "mulex [src]" ((machine 32)) | |
8912 | ; ("mulex ${dst32-24-indirect-HI}") | |
8913 | ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 #xC) dst32-24-indirect-HI (f-15-1 1) (f-18-2 3) (f-20-4 #xE)) | |
8914 | ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-indirect-HI))) | |
8915 | ; ()) | |
8916 | ||
8917 | ;------------------------------------------------------------- | |
8918 | ; mulu - multiply unsigned | |
8919 | ;------------------------------------------------------------- | |
8920 | ||
8921 | (define-pmacro (mulu-sem mode src1 dst) | |
8922 | (sequence ((mode result)) | |
8923 | (set obit (add-oflag mode src1 dst 0)) | |
8924 | (set result (mul mode src1 dst)) | |
8925 | (set dst result)) | |
8926 | ) | |
8927 | ||
8928 | ; mulu.BW #imm,dst | |
8929 | (binary-arith-imm-dst mulu G (f-0-4 7) (f-4-3 6) (f-8-4 4) #x8 #x0 #xF mulu-sem) | |
8930 | ; mulu.BW src,dst | |
8931 | (binary-arith-src-dst mulu G (f-0-4 #x7) (f-4-3 0) #x1 #x4 mulu-sem) | |
8932 | ||
8933 | ;------------------------------------------------------------- | |
8934 | ; neg - twos complement | |
8935 | ;------------------------------------------------------------- | |
8936 | ||
8937 | (define-pmacro (neg-sem mode dst) | |
8938 | (sequence ((mode result)) | |
8939 | (set result (neg mode dst)) | |
8940 | (set-z-and-s result) | |
8941 | (set dst result)) | |
8942 | ) | |
8943 | ||
8944 | ; neg.BW:G | |
8945 | (unary-insn neg (f-0-4 7) (f-4-3 2) (f-8-4 #x5) #xA #x2 #xF neg-sem) | |
8946 | ||
8947 | ;------------------------------------------------------------- | |
8948 | ; not - twos complement | |
8949 | ;------------------------------------------------------------- | |
8950 | ||
8951 | (define-pmacro (not-sem mode dst) | |
8952 | (sequence ((mode result)) | |
8953 | (set result (not mode dst)) | |
8954 | (set-z-and-s result) | |
8955 | (set dst result)) | |
8956 | ) | |
8957 | ||
8958 | ; not.BW:G | |
c6552317 DD |
8959 | (unary-insn-g not (f-0-4 7) (f-4-3 2) (f-8-4 #x7) #xA #x1 #xE not-sem) |
8960 | ||
8961 | (dni not16.b.s | |
8962 | "not.b:s Dst16-3-S-8" | |
8963 | ((machine 16)) | |
8964 | "not.b:s ${Dst16-3-S-8}" | |
8965 | (+ (f-0-4 #xb) (f-4-1 #x1) Dst16-3-S-8) | |
8966 | (not-sem QI Dst16-3-S-8) | |
8967 | ()) | |
49f58d10 JB |
8968 | |
8969 | ;------------------------------------------------------------- | |
8970 | ; nop | |
8971 | ;------------------------------------------------------------- | |
8972 | ||
8973 | (dni nop16 | |
8974 | "nop" | |
8975 | ((machine 16)) | |
8976 | "nop" | |
8977 | (+ (f-0-4 #x0) (f-4-4 #x4)) | |
8978 | (nop) | |
8979 | ()) | |
8980 | ||
8981 | (dni nop32 | |
8982 | "nop" | |
8983 | ((machine 32)) | |
8984 | "nop" | |
8985 | (+ (f-0-4 #xD) (f-4-4 #xE)) | |
8986 | (nop) | |
8987 | ()) | |
8988 | ||
8989 | ;------------------------------------------------------------- | |
8990 | ; or - logical or | |
8991 | ;------------------------------------------------------------- | |
8992 | ||
8993 | (define-pmacro (or-sem mode src1 dst) | |
8994 | (sequence ((mode result)) | |
8995 | (set result (or mode src1 dst)) | |
8996 | (set-z-and-s result) | |
8997 | (set dst result)) | |
8998 | ) | |
8999 | ||
9000 | ; or.BW #imm,dst (m16 #1 m32 #1) | |
9001 | (binary-arith-imm-dst or G (f-0-4 7) (f-4-3 3) (f-8-4 3) #x8 #x2 #xF or-sem) | |
9002 | ; or.b:S #imm8,dst3 (m16 #2 m32 #2) | |
9003 | (binary-arith16-b-S-imm8-dst3 or ".b" (f-0-4 9) (f-4-1 1) or-sem) | |
9004 | (binary-arith32-s-imm-dst QI .b 0 or #x1 #x2 or-sem) | |
9005 | (binary-arith32-s-imm-dst HI .w 1 or #x1 #x2 or-sem) | |
9006 | ; or.BW src,dst (m16 #3 m32 #3) | |
9007 | (binary-arith-src-dst or G (f-0-4 #x9) (f-4-3 4) #x1 #x5 or-sem) | |
9008 | ||
9009 | ;------------------------------------------------------------- | |
9010 | ; pop - restore register/memory | |
9011 | ;------------------------------------------------------------- | |
9012 | ||
9013 | ; TODO future: split this into .b and .w semantics | |
9014 | (define-pmacro (pop-sem-mach mach mode dst) | |
9015 | (sequence ((mode b_or_w) (SI length)) | |
9016 | (set b_or_w -1) | |
9017 | (set b_or_w (srl b_or_w #x8)) | |
9018 | (if (eq b_or_w #x0) | |
9019 | (set length 1) ; .b | |
9020 | (set length 2)) ; .w | |
9021 | ||
9022 | (case DFLT length | |
9023 | ((1) (set dst (mem-mach mach QI (reg h-sp)))) | |
9024 | ((2) (set dst (mem-mach mach HI (reg h-sp))))) | |
9025 | (set (reg h-sp) (add (reg h-sp) length)) | |
9026 | ) | |
9027 | ) | |
9028 | ||
9029 | (define-pmacro (pop-sem16 mode dest) (pop-sem-mach 16 mode dest)) | |
9030 | (define-pmacro (pop-sem32 mode dest) (pop-sem-mach 32 mode dest)) | |
9031 | ||
9032 | ; pop.BW:G (m16 #1) | |
9033 | (unary-insn-mach 16 pop (f-0-4 7) (f-4-3 2) (f-8-4 #xD) pop-sem16) | |
9034 | ; pop.BW:G (m32 #1) | |
9035 | (unary-insn-mach 32 pop #xB #x2 #xF pop-sem32) | |
9036 | ||
9037 | ; pop.b:S r0l/r0h | |
9038 | (dni pop16.b-s-rn "pop.b:S r0[lh]" ((machine 16)) | |
9039 | "pop.b$S ${Rn16-push-S-anyof}" | |
9040 | (+ (f-0-4 #x9) Rn16-push-S-anyof (f-5-3 #x2)) | |
9041 | (pop-sem16 QI Rn16-push-S-anyof) | |
9042 | ()) | |
9043 | ; pop.w:S a0/a1 | |
9044 | (dni pop16.b-s-an "pop.w:S a[01]" ((machine 16)) | |
9045 | "pop.w$S ${An16-push-S-anyof}" | |
9046 | (+ (f-0-4 #xD) An16-push-S-anyof (f-5-3 #x2)) | |
9047 | (pop-sem16 HI An16-push-S-anyof) | |
9048 | ()) | |
9049 | ||
9050 | ;------------------------------------------------------------- | |
9051 | ; popc - pop control register | |
9052 | ; pushc - push control register | |
9053 | ;------------------------------------------------------------- | |
9054 | ||
9055 | (define-pmacro (popc32-cr1-sem mode dst) | |
9056 | (sequence () | |
9057 | (case DFLT dst | |
9058 | ((#x0) (set (reg h-dct0) (mem32 mode (reg h-sp)))) | |
9059 | ((#x1) (set (reg h-dct1) (mem32 mode (reg h-sp)))) | |
9060 | ((#x2) (sequence ((HI tflag)) | |
9061 | (set tflag (mem32 mode (reg h-sp))) | |
9062 | (if (and tflag #x1) (set cbit 1)) | |
9063 | (if (and tflag #x2) (set dbit 1)) | |
9064 | (if (and tflag #x4) (set zbit 1)) | |
9065 | (if (and tflag #x8) (set sbit 1)) | |
9066 | (if (and tflag #x10) (set bbit 1)) | |
9067 | (if (and tflag #x20) (set obit 1)) | |
9068 | (if (and tflag #x40) (set ibit 1)) | |
9069 | (if (and tflag #x80) (set ubit 1)))) | |
9070 | ((#x3) (set (reg h-svf) (mem32 mode (reg h-sp)))) | |
9071 | ((#x4) (set (reg h-drc0) (mem32 mode (reg h-sp)))) | |
9072 | ((#x5) (set (reg h-drc1) (mem32 mode (reg h-sp)))) | |
9073 | ((#x6) (set (reg h-dmd0) (mem32 mode (reg h-sp)))) | |
9074 | ((#x7) (set (reg h-dmd1) (mem32 mode (reg h-sp)))) | |
9075 | ) | |
9076 | (set (reg h-sp) (add (reg h-sp) 2)) | |
9077 | ) | |
9078 | ) | |
9079 | (define-pmacro (popc32-cr2-sem mode dst) | |
9080 | (sequence () | |
9081 | (case DFLT dst | |
9082 | ((#x0) (set (reg h-intb) (mem32 mode (reg h-sp)))) | |
9083 | ((#x1) (set (reg h-sp) (mem32 mode (reg h-sp)))) | |
9084 | ((#x2) (set (reg h-sb) (mem32 mode (reg h-sp)))) | |
9085 | ((#x3) (set (reg h-fb) (mem32 mode (reg h-sp)))) | |
9086 | ((#x7) (set (reg h-isp) (mem32 mode (reg h-sp)))) | |
9087 | ) | |
9088 | (set (reg h-sp) (add (reg h-sp) 4)) | |
9089 | ) | |
9090 | ) | |
9091 | (define-pmacro (popc16-sem mode dst) | |
9092 | (sequence () | |
9093 | (case DFLT dst | |
9094 | ((#x1) (set (reg h-intb) (or (and (reg h-intb) #x0000) | |
9095 | (mem16 mode (reg h-sp))))) | |
9096 | ((#x2) (set (reg h-intb) (or (and (reg h-intb) #xffff0000) | |
9097 | (mem16 mode (reg h-sp))))) | |
9098 | ((#x3) (sequence ((HI tflag)) | |
9099 | (set tflag (mem16 mode (reg h-sp))) | |
9100 | (if (and tflag #x1) (set cbit 1)) | |
9101 | (if (and tflag #x2) (set dbit 1)) | |
9102 | (if (and tflag #x4) (set zbit 1)) | |
9103 | (if (and tflag #x8) (set sbit 1)) | |
9104 | (if (and tflag #x10) (set bbit 1)) | |
9105 | (if (and tflag #x20) (set obit 1)) | |
9106 | (if (and tflag #x40) (set ibit 1)) | |
9107 | (if (and tflag #x80) (set ubit 1)))) | |
9108 | ((#x4) (set (reg h-isp) (mem16 mode (reg h-sp)))) | |
9109 | ((#x5) (set (reg h-sp) (mem16 mode (reg h-sp)))) | |
9110 | ((#x6) (set (reg h-sb) (mem16 mode (reg h-sp)))) | |
9111 | ((#x7) (set (reg h-fb) (mem16 mode (reg h-sp)))) | |
9112 | ) | |
9113 | (set (reg h-sp) (add (reg h-sp) 2)) | |
9114 | ) | |
9115 | ) | |
9116 | ; popc dest (m16c #1) | |
9117 | (dni popc16.imm16 "popc dst" ((machine 16)) | |
9118 | ("popc ${cr16}") | |
9119 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 3) cr16) | |
9120 | (popc16-sem HI cr16) | |
9121 | ()) | |
9122 | ; popc dest (m32c #1) | |
9123 | (dni popc32.imm16-cr1 "popc dst" ((machine 32)) | |
9124 | ("popc ${cr1-Unprefixed-32}") | |
9125 | (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32) | |
9126 | (popc32-cr1-sem HI cr1-Unprefixed-32) | |
9127 | ()) | |
9128 | ; popc dest (m32c #2) | |
9129 | (dni popc32.imm16-cr2 "popc dst" ((machine 32)) | |
9130 | ("popc ${cr2-32}") | |
9131 | (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 2) (f-12-1 1) cr2-32) | |
9132 | (popc32-cr2-sem SI cr2-32) | |
9133 | ()) | |
9134 | ||
9135 | (define-pmacro (pushc32-cr1-sem mode dst) | |
9136 | (sequence () | |
9137 | (set (reg h-sp) (sub (reg h-sp) 2)) | |
9138 | (case DFLT dst | |
9139 | ((#x0) (set (mem32 mode (reg h-sp)) (reg h-dct0))) | |
9140 | ((#x1) (set (mem32 mode (reg h-sp)) (reg h-dct1))) | |
9141 | ((#x2) (sequence ((HI tflag)) | |
9142 | (set tflag 0) | |
9143 | (if (eq cbit 1) (set tflag (or tflag #x1))) | |
9144 | (if (eq dbit 1) (set tflag (or tflag #x2))) | |
9145 | (if (eq zbit 1) (set tflag (or tflag #x4))) | |
9146 | (if (eq sbit 1) (set tflag (or tflag #x8))) | |
9147 | (if (eq bbit 1) (set tflag (or tflag #x10))) | |
9148 | (if (eq obit 1) (set tflag (or tflag #x20))) | |
9149 | (if (eq ibit 1) (set tflag (or tflag #x40))) | |
9150 | (if (eq ubit 1) (set tflag (or tflag #x80))) | |
9151 | (set (mem32 mode (reg h-sp)) tflag))) | |
9152 | ((#x3) (set (mem32 mode (reg h-sp)) (reg h-svf))) | |
9153 | ((#x4) (set (mem32 mode (reg h-sp)) (reg h-drc0))) | |
9154 | ((#x5) (set (mem32 mode (reg h-sp)) (reg h-drc1))) | |
9155 | ((#x6) (set (mem32 mode (reg h-sp)) (reg h-dmd0))) | |
9156 | ((#x7) (set (mem32 mode (reg h-sp)) (reg h-dmd1))) | |
9157 | ) | |
9158 | ) | |
9159 | ) | |
9160 | (define-pmacro (pushc32-cr2-sem mode dst) | |
9161 | (sequence () | |
9162 | (set (reg h-sp) (sub (reg h-sp) 4)) | |
9163 | (case DFLT dst | |
9164 | ((#x0) (set (mem32 mode (reg h-sp)) (reg h-intb))) | |
9165 | ((#x1) (set (mem32 mode (reg h-sp)) (reg h-sp))) | |
9166 | ((#x2) (set (mem32 mode (reg h-sp)) (reg h-sb))) | |
9167 | ((#x3) (set (mem32 mode (reg h-sp)) (reg h-fb))) | |
9168 | ((#x7) (set (mem32 mode (reg h-sp)) (reg h-isp))) | |
9169 | ) | |
9170 | ) | |
9171 | ) | |
9172 | (define-pmacro (pushc16-sem mode dst) | |
9173 | (sequence () | |
9174 | (set (reg h-sp) (sub (reg h-sp) 2)) | |
9175 | (case DFLT dst | |
9176 | ((#x1) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff))) | |
9177 | ((#x2) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff0000))) | |
9178 | ((#x3) (sequence ((HI tflag)) | |
9179 | (if (eq cbit 1) (set tflag (or tflag #x1))) | |
9180 | (if (eq dbit 1) (set tflag (or tflag #x2))) | |
9181 | (if (eq zbit 1) (set tflag (or tflag #x4))) | |
9182 | (if (eq sbit 1) (set tflag (or tflag #x8))) | |
9183 | (if (eq bbit 1) (set tflag (or tflag #x10))) | |
9184 | (if (eq obit 1) (set tflag (or tflag #x20))) | |
9185 | (if (eq ibit 1) (set tflag (or tflag #x40))) | |
9186 | (if (eq ubit 1) (set tflag (or tflag #x80))) | |
9187 | (set (mem16 mode (reg h-sp)) tflag))) | |
9188 | ||
9189 | ((#x4) (set (mem16 mode (reg h-sp)) (reg h-isp))) | |
9190 | ((#x5) (set (mem16 mode (reg h-sp)) (reg h-sp))) | |
9191 | ((#x6) (set (mem16 mode (reg h-sp)) (reg h-sb))) | |
9192 | ((#x7) (set (mem16 mode (reg h-sp)) (reg h-fb))) | |
9193 | ) | |
9194 | ) | |
9195 | ) | |
9196 | ; pushc src (m16c) | |
9197 | (dni pushc16.imm16 "pushc dst" ((machine 16)) | |
9198 | ("pushc ${cr16}") | |
9199 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 2) cr16) | |
9200 | (pushc16-sem HI cr16) | |
9201 | ()) | |
9202 | ; pushc src (m32c #1) | |
9203 | (dni pushc32.imm16-cr1 "pushc dst" ((machine 32)) | |
9204 | ("pushc ${cr1-Unprefixed-32}") | |
9205 | (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32) | |
9206 | (pushc32-cr1-sem HI cr1-Unprefixed-32) | |
9207 | ()) | |
9208 | ; pushc src (m32c #2) | |
9209 | (dni pushc32.imm16-cr2 "pushc dst" ((machine 32)) | |
9210 | ("pushc ${cr2-32}") | |
9211 | (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 2) (f-12-1 1) cr2-32) | |
9212 | (pushc32-cr2-sem SI cr2-32) | |
9213 | ()) | |
9214 | ||
9215 | ;------------------------------------------------------------- | |
9216 | ; popm - pop multiple | |
9217 | ; pushm - push multiple | |
9218 | ;------------------------------------------------------------- | |
9219 | ||
9220 | (define-pmacro (popm-sem machine dst) | |
9221 | (sequence ((SI addrlen)) | |
9222 | (if (eq machine 16) | |
9223 | (set addrlen 2) | |
9224 | (set addrlen 4)) | |
9225 | (if (and dst 1) | |
9226 | (sequence () (set R0 (mem-mach machine HI (reg h-sp))) | |
9227 | (set (reg h-sp) (add (reg h-sp) 2)))) | |
9228 | (if (and dst 2) | |
9229 | (sequence () (set R1 (mem-mach machine HI (reg h-sp))) | |
9230 | (set (reg h-sp) (add (reg h-sp) 2)))) | |
9231 | (if (and dst 4) | |
9232 | (sequence () (set R2 (mem-mach machine HI (reg h-sp))) | |
9233 | (set (reg h-sp) (add (reg h-sp) 2)))) | |
9234 | (if (and dst 8) | |
9235 | (sequence () (set R3 (mem-mach machine HI (reg h-sp))) | |
9236 | (set (reg h-sp) (add (reg h-sp) 2)))) | |
9237 | (if (and dst 16) | |
9238 | (sequence () (set A0 (mem-mach machine HI (reg h-sp))) | |
9239 | (set (reg h-sp) (add (reg h-sp) addrlen)))) | |
9240 | (if (and dst 32) | |
9241 | (sequence () (set A1 (mem-mach machine HI (reg h-sp))) | |
9242 | (set (reg h-sp) (add (reg h-sp) addrlen)))) | |
9243 | (if (and dst 64) | |
9244 | (sequence () (set (reg h-sb) (mem-mach machine HI (reg h-sp))) | |
9245 | (set (reg h-sp) (add (reg h-sp) addrlen)))) | |
9246 | (if (eq dst 128) | |
9247 | (sequence () (set (reg h-fb) (mem-mach machine HI (reg h-sp))) | |
9248 | (set (reg h-sp) (add (reg h-sp) addrlen)))) | |
9249 | ) | |
9250 | ) | |
9251 | ||
9252 | (define-pmacro (pushm-sem machine dst) | |
9253 | (sequence ((SI count) (SI addrlen)) | |
9254 | (if (eq machine 16) | |
9255 | (set addrlen 2) | |
9256 | (set addrlen 4)) | |
9257 | (if (eq dst 1) | |
9258 | (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen)) | |
9259 | (set (mem-mach machine HI (reg h-sp)) (reg h-fb)))) | |
9260 | (if (and dst 2) | |
9261 | (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen)) | |
9262 | (set (mem-mach machine HI (reg h-sp)) (reg h-sb)))) | |
9263 | (if (and dst 4) | |
9264 | (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen)) | |
9265 | (set (mem-mach machine HI (reg h-sp)) A1))) | |
9266 | (if (and dst 8) | |
9267 | (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen)) | |
9268 | (set (mem-mach machine HI (reg h-sp)) A0))) | |
9269 | (if (and dst 16) | |
9270 | (sequence () (set (reg h-sp) (sub (reg h-sp) 2)) | |
9271 | (set (mem-mach machine HI (reg h-sp)) R3))) | |
9272 | (if (and dst 32) | |
9273 | (sequence () (set (reg h-sp) (sub (reg h-sp) 2)) | |
9274 | (set (mem-mach machine HI (reg h-sp)) R2))) | |
9275 | (if (and dst 64) | |
9276 | (sequence () (set (reg h-sp) (sub (reg h-sp) 2)) | |
9277 | (set (mem-mach machine HI (reg h-sp)) R1))) | |
9278 | (if (and dst 128) | |
9279 | (sequence () (set (reg h-sp) (sub (reg h-sp) 2)) | |
9280 | (set (mem-mach machine HI (reg h-sp)) R0))) | |
9281 | ) | |
9282 | ) | |
9283 | ||
9284 | (dni popm16 "popm regs" ((machine 16)) | |
9285 | ("popm ${Regsetpop}") | |
9286 | (+ (f-0-4 #xE) (f-4-4 #xD) Regsetpop) | |
9287 | (popm-sem 16 Regsetpop) | |
9288 | ()) | |
9289 | (dni pushm16 "pushm regs" ((machine 16)) | |
9290 | ("pushm ${Regsetpush}") | |
9291 | (+ (f-0-4 #xE) (f-4-4 #xC) Regsetpush) | |
9292 | (pushm-sem 16 Regsetpush) | |
9293 | ()) | |
9294 | (dni popm "popm regs" ((machine 32)) | |
9295 | ("popm ${Regsetpop}") | |
9296 | (+ (f-0-4 #x8) (f-4-4 #xE) Regsetpop) | |
9297 | (popm-sem 32 Regsetpop) | |
9298 | ()) | |
9299 | (dni pushm "pushm regs" ((machine 32)) | |
9300 | ("pushm ${Regsetpush}") | |
9301 | (+ (f-0-4 #x8) (f-4-4 #xF) Regsetpush) | |
9302 | (pushm-sem 32 Regsetpush) | |
9303 | ()) | |
9304 | ||
9305 | ;------------------------------------------------------------- | |
9306 | ; push - Save register/memory/immediate data | |
9307 | ;------------------------------------------------------------- | |
9308 | ||
9309 | ; TODO future: split this into .b and .w semantics | |
9310 | (define-pmacro (push-sem-mach mach mode dst) | |
9311 | (sequence ((mode b_or_w) (SI length)) | |
9312 | (set b_or_w -1) | |
9313 | (set b_or_w (srl b_or_w #x8)) | |
9314 | (if (eq b_or_w #x0) | |
9315 | (set length 1) ; .b | |
9316 | (if (eq b_or_w #xff) | |
9317 | (set length 2) ; .w | |
9318 | (set length 4))) ; .l | |
9319 | (set (reg h-sp) (sub (reg h-sp) length)) | |
9320 | (case DFLT length | |
9321 | ((1) (set (mem-mach mach QI (reg h-sp)) dst)) | |
9322 | ((2) (set (mem-mach mach HI (reg h-sp)) dst)) | |
9323 | ((4) (set (mem-mach mach SI (reg h-sp)) dst))) | |
9324 | ) | |
9325 | ) | |
9326 | ||
9327 | (define-pmacro (push-sem16 mode dst) (push-sem-mach 16 mode dst)) | |
9328 | (define-pmacro (push-sem32 mode dst) (push-sem-mach 32 mode dst)) | |
9329 | ||
9330 | ; push.BW:G imm (m16 #1 m32 #1) | |
9331 | (dni push16.b.G-imm "push.b:G #Imm-16-QI" ((machine 16)) | |
9332 | ("push.b$G #${Imm-16-QI}") | |
9333 | (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 2) Imm-16-QI) | |
9334 | (push-sem16 QI Imm-16-QI) | |
9335 | ()) | |
9336 | ||
9337 | (dni push16.w.G-imm "push.w:G #Imm-16-HI" ((machine 16)) | |
9338 | ("push.w$G #${Imm-16-HI}") | |
9339 | (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 2) Imm-16-HI) | |
9340 | (push-sem16 HI Imm-16-HI) | |
9341 | ()) | |
9342 | ||
9343 | (dni push32.b.imm "push.w #Imm-8-QI" ((machine 32)) | |
9344 | ("push.b #Imm-8-QI") | |
9345 | (+ (f-0-4 #xA) (f-4-4 #xE) Imm-8-QI) | |
9346 | (push-sem32 QI Imm-8-QI) | |
9347 | ()) | |
9348 | ||
9349 | (dni push32.w.imm "push.w #Imm-8-HI" ((machine 32)) | |
9350 | ("push.w #${Imm-8-HI}") | |
9351 | (+ (f-0-4 #xA) (f-4-4 #xF) Imm-8-HI) | |
9352 | (push-sem32 HI Imm-8-HI) | |
9353 | ()) | |
9354 | ||
9355 | ; push.BW:G src (m16 #2) | |
c6552317 | 9356 | (unary-insn-mach-g 16 push (f-0-4 7) (f-4-3 2) (f-8-4 #x4) push-sem16 $G) |
49f58d10 JB |
9357 | ; push.BW:G src (m32 #2) |
9358 | (unary-insn-mach 32 push #xC #x0 #xE push-sem32) | |
9359 | ||
9360 | ||
9361 | ; push.b:S r0l/r0h (m16 #3) | |
9362 | (dni push16.b-s-rn "push.b:S r0[lh]" ((machine 16)) | |
9363 | "push.b$S ${Rn16-push-S-anyof}" | |
9364 | (+ (f-0-4 #x8) Rn16-push-S-anyof (f-5-3 #x2)) | |
9365 | (push-sem16 QI Rn16-push-S-anyof) | |
9366 | ()) | |
9367 | ; push.w:S a0/a1 (m16 #4) | |
9368 | (dni push16.b-s-an "push.w:S a[01]" ((machine 16)) | |
9369 | "push.w$S ${An16-push-S-anyof}" | |
9370 | (+ (f-0-4 #xC) An16-push-S-anyof (f-5-3 #x2)) | |
9371 | (push-sem16 HI An16-push-S-anyof) | |
9372 | ()) | |
9373 | ||
9374 | ; push.l imm32 (m32 #3) | |
9375 | (dni push32.l.imm "push.l #Imm-16-SI" ((machine 32)) | |
9376 | ("push.l #${Imm-16-SI}") | |
9377 | (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 5) (f-12-4 3) Imm-16-SI) | |
9378 | (push-sem32 SI Imm-16-SI) | |
9379 | ()) | |
9380 | ; push.l src (m32 #4) | |
9381 | (unary-insn-defn 32 16-Unprefixed SI .l push (+ (f-0-4 #xA) (f-7-1 0) dst32-16-Unprefixed-SI (f-10-2 0) (f-12-4 1)) push-sem32) | |
9382 | ||
9383 | ;------------------------------------------------------------- | |
9384 | ; pusha - push effective address | |
9385 | ;------------------------------------------------------------ | |
9386 | ||
9387 | (define-pmacro (push16a-sem mode dst) | |
9388 | (sequence () | |
9389 | (set (reg h-sp) (sub (reg h-sp) 2)) | |
9390 | (set (mem16 HI (reg h-sp)) dst)) | |
9391 | ) | |
9392 | (define-pmacro (push32a-sem mode dst) | |
9393 | (sequence () | |
9394 | (set (reg h-sp) (sub (reg h-sp) 4)) | |
9395 | (set (mem32 SI (reg h-sp)) dst)) | |
9396 | ) | |
9397 | (unary-insn-defn 16 16-Mova HI "" pusha (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 9) dst16-16-Mova-HI) push16a-sem) | |
9398 | (unary-insn-defn 32 16-Unprefixed-Mova SI "" pusha (+ (f-0-4 #xB) (f-7-1 0) dst32-16-Unprefixed-Mova-SI (f-10-2 0) (f-12-4 1)) push32a-sem) | |
9399 | ||
9400 | ;------------------------------------------------------------- | |
9401 | ; reit - return from interrupt | |
9402 | ;------------------------------------------------------------- | |
9403 | ||
9404 | ; ??? semantics | |
9405 | (dni reit16 "REIT" ((machine 16)) | |
9406 | ("reit") | |
9407 | (+ (f-0-4 #xF) (f-4-4 #xB)) | |
9408 | (nop) | |
9409 | ()) | |
9410 | (dni reit32 "REIT" ((machine 32)) | |
9411 | ("reit") | |
9412 | (+ (f-0-4 9) (f-4-4 #xE)) | |
9413 | (nop) | |
9414 | ()) | |
9415 | ||
9416 | ;------------------------------------------------------------- | |
9417 | ; rmpa - repeat multiple and addition | |
9418 | ;------------------------------------------------------------- | |
9419 | ||
9420 | ; TODO semantics | |
9421 | (dni rmpa16.b "rmpa.size" ((machine 16)) | |
9422 | ("rmpa.b") | |
9423 | (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 1)) | |
9424 | (nop) | |
9425 | ()) | |
9426 | (dni rmpa16.w "rmpa.size" ((machine 16)) | |
9427 | ("rmpa.w") | |
9428 | (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 1)) | |
9429 | (nop) | |
9430 | ()) | |
9431 | (dni rmpa32.b "rmpa.size" ((machine 32)) | |
9432 | ("rmpa.b") | |
9433 | (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 4) (f-12-4 3)) | |
9434 | (nop) | |
9435 | ()) | |
9436 | ||
9437 | (dni rmpa32.w "rmpa.size" ((machine 32)) | |
9438 | ("rmpa.w") | |
9439 | (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 5) (f-12-4 3)) | |
9440 | (nop) | |
9441 | ()) | |
9442 | ||
9443 | ;------------------------------------------------------------- | |
9444 | ; rolc - rotate left with carry | |
9445 | ;------------------------------------------------------------- | |
9446 | ||
9447 | ; TODO check semantics | |
9448 | ; TODO future: split this into .b and .w semantics | |
9449 | (define-pmacro (rolc-sem mode dst) | |
9450 | (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask)) | |
9451 | (set b_or_w -1) | |
9452 | (set b_or_w (srl b_or_w #x8)) | |
9453 | (if (eq b_or_w #x0) | |
9454 | (set mask #x8000) ; .b | |
9455 | (set mask #x80000000)) ; .w | |
9456 | (set ocbit cbit) | |
9457 | (set cbit (and dst mask)) | |
9458 | (set result (sll mode dst 1)) | |
9459 | (set result (or result ocbit)) | |
9460 | (set-z-and-s result) | |
9461 | (set dst result)) | |
9462 | ) | |
9463 | ; rolc.BW src,dst | |
9464 | (unary-insn rolc (f-0-4 7) (f-4-3 3) (f-8-4 #xA) #xB #x2 #xE rolc-sem) | |
9465 | ||
9466 | ;------------------------------------------------------------- | |
9467 | ; rorc - rotate right with carry | |
9468 | ;------------------------------------------------------------- | |
9469 | ||
9470 | ; TODO check semantics | |
9471 | ; TODO future: split this into .b and .w semantics | |
9472 | (define-pmacro (rorc-sem mode dst) | |
9473 | (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask) (SI shamt)) | |
9474 | (set b_or_w -1) | |
9475 | (set b_or_w (srl b_or_w #x8)) | |
9476 | (if (eq b_or_w #x0) | |
9477 | (sequence () (set mask #x7fff) (set shamt 15)) ; .b | |
9478 | (sequence () (set mask #x7fffffff) (set shamt 31))) ; .w | |
9479 | (set ocbit cbit) | |
9480 | (set cbit (and dst #x1)) | |
9481 | (set result (srl mode dst (const 1))) | |
9482 | (set result (or (and result mask) (sll ocbit shamt))) | |
9483 | (set-z-and-s result) | |
9484 | (set dst result)) | |
9485 | ) | |
9486 | ; rorc.BW src,dst | |
9487 | (unary-insn rorc (f-0-4 7) (f-4-3 3) (f-8-4 #xB) #xA #x2 #xE rorc-sem) | |
9488 | ||
9489 | ;------------------------------------------------------------- | |
9490 | ; rot - rotate | |
9491 | ;------------------------------------------------------------- | |
9492 | ||
9493 | ; TODO future: split this into .b and .w semantics | |
9494 | (define-pmacro (rot-1-sem mode src1 dst) | |
9495 | (sequence ((mode tmp) (mode b_or_w) (USI mask) (SI shift)) | |
9496 | (case DFLT src1 | |
9497 | ((#x0) (set shift 1)) | |
9498 | ((#x1) (set shift 2)) | |
9499 | ((#x2) (set shift 3)) | |
9500 | ((#x3) (set shift 4)) | |
9501 | ((#x4) (set shift 5)) | |
9502 | ((#x5) (set shift 6)) | |
9503 | ((#x6) (set shift 7)) | |
9504 | ((#x7) (set shift 8)) | |
9505 | ((-8) (set shift -1)) | |
9506 | ((-7) (set shift -2)) | |
9507 | ((-6) (set shift -3)) | |
9508 | ((-5) (set shift -4)) | |
9509 | ((-4) (set shift -5)) | |
9510 | ((-3) (set shift -6)) | |
9511 | ((-2) (set shift -7)) | |
9512 | ((-1) (set shift -8)) | |
9513 | (else (set shift 0)) | |
9514 | ) | |
9515 | (set b_or_w -1) | |
9516 | (set b_or_w (srl b_or_w #x8)) | |
9517 | (if (eq b_or_w #x0) | |
9518 | (set mask #x7fff) ; .b | |
9519 | (set mask #x7fffffff)) ; .w | |
9520 | (set tmp dst) | |
9521 | (if (gt mode shift 0) | |
9522 | (sequence () | |
9523 | (set tmp (rol mode tmp shift)) | |
9524 | (set cbit (and tmp #x1))) | |
9525 | (sequence () | |
9526 | (set tmp (ror mode tmp (mul shift -1))) | |
9527 | (set cbit (and tmp mask)))) | |
9528 | (set-z-and-s tmp) | |
9529 | (set dst tmp)) | |
9530 | ) | |
9531 | (define-pmacro (rot-2-sem mode dst) | |
9532 | (sequence ((mode tmp) (mode b_or_w) (USI mask)) | |
9533 | (set b_or_w -1) | |
9534 | (set b_or_w (srl b_or_w #x8)) | |
9535 | (if (eq b_or_w #x0) | |
9536 | (set mask #x7fff) ; .b | |
9537 | (set mask #x7fffffff)) ; .w | |
9538 | (set tmp dst) | |
9539 | (if (gt mode (reg h-r1h) 0) | |
9540 | (sequence () | |
9541 | (set tmp (rol mode tmp (reg h-r1h))) | |
9542 | (set cbit (and tmp #x1))) | |
9543 | (sequence () | |
9544 | (set tmp (ror mode tmp (reg h-r1h))) | |
9545 | (set cbit (and tmp mask)))) | |
9546 | (set-z-and-s tmp) | |
9547 | (set dst tmp)) | |
9548 | ) | |
9549 | ||
9550 | ; rot.BW #imm4,dst | |
9551 | (binary-arith16-shimm4-dst-defn QI .b 0 0 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem) | |
9552 | (binary-arith16-shimm4-dst-defn HI .w 0 1 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem) | |
9553 | (binary-arith32-shimm4-dst-defn QI .b 0 0 rot #x7 #x2 rot-1-sem) | |
9554 | (binary-arith32-shimm4-dst-defn HI .w 0 1 rot #x7 #x2 rot-1-sem) | |
9555 | ; rot.BW src,dst | |
9556 | ||
9557 | (dni rot16.b-dst "rot r1h,dest" ((machine 16)) | |
a1a280bb DD |
9558 | ("rot.b r1h,${dst16-16-QI}") |
9559 | (+ (f-0-4 7) (f-4-4 #x4) (f-8-4 #x6) dst16-16-QI) | |
9560 | (rot-2-sem QI dst16-16-QI) | |
49f58d10 JB |
9561 | ()) |
9562 | (dni rot16.w-dst "rot r1h,dest" ((machine 16)) | |
9563 | ("rot.w r1h,${dst16-16-HI}") | |
9564 | (+ (f-0-4 7) (f-4-4 #x5) (f-8-4 #x6) dst16-16-HI) | |
9565 | (rot-2-sem HI dst16-16-HI) | |
9566 | ()) | |
9567 | ||
9568 | (dni rot32.b-dst "rot r1h,dest" ((machine 32)) | |
a1a280bb DD |
9569 | ("rot.b r1h,${dst32-16-Unprefixed-QI}") |
9570 | (+ (f-0-4 #xA) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xF)) | |
9571 | (rot-2-sem QI dst32-16-Unprefixed-QI) | |
49f58d10 JB |
9572 | ()) |
9573 | (dni rot32.w-dst "rot r1h,dest" ((machine 32)) | |
a1a280bb DD |
9574 | ("rot.w r1h,${dst32-16-Unprefixed-HI}") |
9575 | (+ (f-0-4 #xA) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xF)) | |
9576 | (rot-2-sem HI dst32-16-Unprefixed-HI) | |
49f58d10 JB |
9577 | ()) |
9578 | ||
9579 | ;------------------------------------------------------------- | |
9580 | ; rts - return from subroutine | |
9581 | ;------------------------------------------------------------- | |
9582 | ||
9583 | (define-pmacro (rts16-sem) | |
9584 | (sequence ((SI tpc)) | |
9585 | (set tpc (mem16 HI (reg h-sp))) | |
9586 | (set (reg h-sp) (add (reg h-sp) 2)) | |
9587 | (set tpc (or tpc (sll (mem16 QI (reg h-sp)) 16))) | |
9588 | (set (reg h-sp) (add (reg h-sp) 1)) | |
9589 | (set pc tpc) | |
9590 | ) | |
9591 | ) | |
9592 | (define-pmacro (rts32-sem) | |
9593 | (sequence ((SI tpc)) | |
9594 | (set tpc (mem32 HI (reg h-sp))) | |
9595 | (set (reg h-sp) (add (reg h-sp) 2)) | |
9596 | (set tpc (or tpc (sll (mem32 HI (reg h-sp)) 16))) | |
9597 | (set (reg h-sp) (add (reg h-sp) 2)) | |
9598 | (set pc tpc) | |
9599 | ) | |
9600 | ) | |
9601 | ||
9602 | (dni rts16 "rts" ((machine 16)) | |
9603 | ("rts") | |
9604 | (+ (f-0-4 #xF) (f-4-4 3)) | |
9605 | (rts16-sem) | |
9606 | ()) | |
9607 | ||
9608 | (dni rts32 "rts" ((machine 32)) | |
9609 | ("rts") | |
9610 | (+ (f-0-4 #xD) (f-4-4 #xF)) | |
9611 | (rts32-sem) | |
9612 | ()) | |
9613 | ||
9614 | ;------------------------------------------------------------- | |
9615 | ; sbb - subtract with borrow | |
9616 | ;------------------------------------------------------------- | |
9617 | ||
9618 | (define-pmacro (sbb-sem mode src dst) | |
9619 | (sequence ((mode result)) | |
9620 | (set result (subc mode dst src cbit)) | |
9621 | (set obit (add-oflag mode dst src cbit)) | |
9622 | (set cbit (add-oflag mode dst src cbit)) | |
9623 | (set-z-and-s result) | |
9624 | (set dst result)) | |
9625 | ) | |
9626 | ||
9627 | ; sbb.size:G #imm,dst | |
9628 | (binary-arith16-imm-dst-defn QI QI .b 0 sbb X (f-0-4 7) (f-4-3 3) (f-8-4 7) sbb-sem) | |
9629 | (binary-arith16-imm-dst-defn HI HI .w 1 sbb X (f-0-4 7) (f-4-3 3) (f-8-4 7) sbb-sem) | |
9630 | (binary-arith32-imm-dst-Prefixed QI QI .b 0 sbb X #x9 #x2 #xE sbb-sem) | |
9631 | (binary-arith32-imm-dst-Prefixed HI HI .w 1 sbb X #x9 #x2 #xE sbb-sem) | |
9632 | ||
9633 | ; sbb.BW:G src,dst | |
9634 | (binary-arith16-src-dst-defn QI QI .b 0 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem) | |
9635 | (binary-arith16-src-dst-defn HI HI .w 1 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem) | |
9636 | (binary-arith32-src-dst-Prefixed QI QI .b 0 sbb X #x1 #x6 sbb-sem) | |
9637 | (binary-arith32-src-dst-Prefixed HI HI .w 1 sbb X #x1 #x6 sbb-sem) | |
9638 | ||
9639 | ;------------------------------------------------------------- | |
9640 | ; sbjnz - subtract then jump on not zero | |
9641 | ;------------------------------------------------------------- | |
9642 | ||
9643 | (define-pmacro (sub-jnz-sem mode src dst label) | |
9644 | (sequence ((mode result)) | |
9645 | (set result (sub mode dst src)) | |
9646 | (set dst result) | |
9647 | (if (ne result 0) | |
9648 | (set pc label))) | |
9649 | ) | |
9650 | ||
9651 | ; sbjnz.size #imm4,dst,label | |
c6552317 | 9652 | (arith-jnz-imm4-dst sbjnz s4n (f-0-4 #xF) (f-4-3 4) #xf #x1 sub-jnz-sem) |
49f58d10 JB |
9653 | |
9654 | ;------------------------------------------------------------- | |
9655 | ; sccnd - store condition on condition (m32) | |
9656 | ;------------------------------------------------------------- | |
9657 | ||
9658 | (define-pmacro (sccnd-sem cnd dst) | |
9659 | (sequence () | |
9660 | (set dst 0) | |
9661 | (case DFLT cnd | |
9662 | ((#x00) (if (not cbit) (set dst 1))) ;ltu nc | |
9663 | ((#x01) (if (or cbit zbit) (set dst 1))) ;leu | |
9664 | ((#x02) (if (not zbit) (set dst 1))) ;ne nz | |
9665 | ((#x03) (if (not sbit) (set dst 1))) ;pz | |
9666 | ((#x04) (if (not obit) (set dst 1))) ;no | |
9667 | ((#x05) (if (not (or zbit (xor sbit obit))) (set dst 1))) ;gt | |
9668 | ((#x06) (if (xor sbit obit) (set dst 1))) ;ge | |
9669 | ((#x08) (if (trunc BI cbit) (set dst 1))) ;geu c | |
9670 | ((#x09) (if (not (or cbit zbit)) (set dst 1))) ;gtu | |
9671 | ((#x0a) (if (trunc BI zbit) (set dst 1))) ;eq z | |
9672 | ((#x0b) (if (trunc BI sbit) (set dst 1))) ;n | |
9673 | ((#x0c) (if (trunc BI obit) (set dst 1))) ;o | |
9674 | ((#x0d) (if (or zbit (xor sbit obit)) (set dst 1))) ;le | |
9675 | ((#x0e) (if (xor sbit obit) (set dst 1))) ;lt | |
9676 | ) | |
9677 | ) | |
9678 | ) | |
9679 | ||
9680 | ; scCND dst | |
9681 | (dni sccnd | |
9682 | "sccnd dst" | |
9683 | ((machine 32)) | |
9684 | "sc$sccond32 ${dst32-16-Unprefixed-HI}" | |
9685 | (+ (f-0-4 #xD) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) sccond32) | |
9686 | (sccnd-sem sccond32 dst32-16-Unprefixed-HI) | |
9687 | ()) | |
9688 | ||
9689 | ;------------------------------------------------------------- | |
9690 | ; scmpu - string compare unequal (m32) | |
9691 | ;------------------------------------------------------------- | |
9692 | ||
9693 | ; TODO semantics | |
9694 | (dni scmpu.b "scmpu.b" ((machine 32)) | |
9695 | ("scmpu.b") | |
9696 | (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xC) (f-12-4 3)) | |
9697 | (c-call VOID "scmpu_QI_semantics") | |
9698 | ()) | |
9699 | ||
9700 | (dni scmpu.w "scmpu.w" ((machine 32)) | |
9701 | ("scmpu.w") | |
9702 | (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xD) (f-12-4 3)) | |
9703 | (c-call VOID "scmpu_HI_semantics") | |
9704 | ()) | |
9705 | ||
9706 | ;------------------------------------------------------------- | |
9707 | ; sha - shift arithmetic | |
9708 | ;------------------------------------------------------------- | |
9709 | ||
9710 | ; TODO future: split this into .b and .w semantics | |
9711 | (define-pmacro (sha-sem mode src1 dst) | |
9712 | (sequence ((mode result)(mode shift)(mode shmode)) | |
9713 | (case DFLT src1 | |
9714 | ((#x0) (set shift 1)) | |
9715 | ((#x1) (set shift 2)) | |
9716 | ((#x2) (set shift 3)) | |
9717 | ((#x3) (set shift 4)) | |
9718 | ((#x4) (set shift 5)) | |
9719 | ((#x5) (set shift 6)) | |
9720 | ((#x6) (set shift 7)) | |
9721 | ((#x7) (set shift 8)) | |
9722 | ((-8) (set shift -1)) | |
9723 | ((-7) (set shift -2)) | |
9724 | ((-6) (set shift -3)) | |
9725 | ((-5) (set shift -4)) | |
9726 | ((-4) (set shift -5)) | |
9727 | ((-3) (set shift -6)) | |
9728 | ((-2) (set shift -7)) | |
9729 | ((-1) (set shift -8)) | |
9730 | (else (set shift 0)) | |
9731 | ) | |
9732 | (set shmode -1) | |
9733 | (set shmode (srl shmode #x8)) | |
9734 | (if (lt mode shift #x0) (set result (sra mode dst (mul shift -1)))) | |
9735 | (if (gt mode shift 0) (set result (sll mode dst shift))) | |
9736 | (if (eq shmode #x0) ; QI | |
9737 | (sequence | |
9738 | ((mode cbitamt)) | |
9739 | (if (lt mode shift #x0) | |
9740 | (set cbitamt (sub #x8 shift)) ; sra | |
9741 | (set cbitamt (sub shift 1))) ; sll | |
9742 | (set cbit (srl (and (sll dst cbitamt) #x80) #x7)) | |
9743 | (set obit (ne (and dst #x80) (and result #x80))) | |
9744 | )) | |
9745 | (if (eq shmode #xff) ; HI | |
9746 | (sequence | |
9747 | ((mode cbitamt)) | |
9748 | (if (lt mode shift #x0) | |
9749 | (set cbitamt (sub 16 shift)) ; sra | |
9750 | (set cbitamt (sub shift 1))) ; sll | |
9751 | (set cbit (srl (and (sll dst cbitamt) #x8000) #xf)) | |
9752 | (set obit (ne (and dst #x8000) (and result #x8000))) | |
9753 | )) | |
9754 | (set-z-and-s result) | |
9755 | (set dst result)) | |
9756 | ) | |
9757 | (define-pmacro (shar1h-sem mode dst) | |
9758 | (sequence ((mode result)(mode shmode)) | |
9759 | (set shmode -1) | |
9760 | (set shmode (srl shmode #x8)) | |
9761 | (if (lt mode (reg h-r1h) 0) (set result (sra mode dst (reg h-r1h)))) | |
9762 | (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h)))) | |
9763 | (if (eq shmode #x0) ; QI | |
9764 | (sequence | |
9765 | ((mode cbitamt)) | |
9766 | (if (lt mode (reg h-r1h) #x0) | |
9767 | (set cbitamt (sub #x8 (reg h-r1h))) ; sra | |
9768 | (set cbitamt (sub (reg h-r1h) 1))) ; sll | |
9769 | (set cbit (srl (and (sll dst cbitamt) #x80) #x7)) | |
9770 | (set obit (ne (and dst #x80) (and result #x80))) | |
9771 | )) | |
9772 | (if (eq shmode #xff) ; HI | |
9773 | (sequence | |
9774 | ((mode cbitamt)) | |
9775 | (if (lt mode (reg h-r1h) #x0) | |
9776 | (set cbitamt (sub 16 (reg h-r1h))) ; sra | |
9777 | (set cbitamt (sub (reg h-r1h) 1))) ; sll | |
9778 | (set cbit (srl (and (sll dst cbitamt) #x8000) #xf)) | |
9779 | (set obit (ne (and dst #x8000) (and result #x8000))) | |
9780 | )) | |
9781 | (set-z-and-s result) | |
9782 | (set dst result)) | |
9783 | ) | |
9784 | ; sha.BW #imm4,dst (m16 #1 m32 #1) | |
9785 | (binary-arith16-shimm4-dst-defn QI .b 0 0 sha (f-0-4 #xF) (f-4-3 0) sha-sem) | |
9786 | (binary-arith16-shimm4-dst-defn HI .w 0 1 sha (f-0-4 #xF) (f-4-3 0) sha-sem) | |
9787 | (binary-arith32-shimm4-dst-defn QI .b 1 0 sha #x7 #x0 sha-sem) | |
9788 | (binary-arith32-shimm4-dst-defn HI .w 1 1 sha #x7 #x0 sha-sem) | |
9789 | ; sha.BW r1h,dst (m16 #2 m32 #3) | |
9790 | (dni sha16.b-dst "sha.b r1h,dest" ((machine 16)) | |
9791 | ("sha.b r1h,${dst16-16-QI}") | |
9792 | (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xF) dst16-16-QI) | |
9793 | (shar1h-sem HI dst16-16-QI) | |
9794 | ()) | |
9795 | (dni sha16.w-dst "sha.w r1h,dest" ((machine 16)) | |
9796 | ("sha.w r1h,${dst16-16-HI}") | |
9797 | (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xF) dst16-16-HI) | |
9798 | (shar1h-sem HI dst16-16-HI) | |
9799 | ()) | |
9800 | (dni sha32.b-dst "sha.b r1h,dest" ((machine 32)) | |
9801 | ("sha.b r1h,${dst32-16-Unprefixed-QI}") | |
9802 | (+ (f-0-4 #xB) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE)) | |
9803 | (shar1h-sem QI dst32-16-Unprefixed-QI) | |
9804 | ()) | |
9805 | (dni sha32.w-dst "sha.w r1h,dest" ((machine 32)) | |
9806 | ("sha.w r1h,${dst32-16-Unprefixed-HI}") | |
9807 | (+ (f-0-4 #xB) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE)) | |
9808 | (shar1h-sem HI dst32-16-Unprefixed-HI) | |
9809 | ()) | |
9810 | ; sha.L #imm,dst (m16 #3) | |
9811 | (dni sha16-L-imm-r2r0 "sha.L #Imm-sh-12-s4,r2r0" ((machine 16)) | |
9812 | "sha.l #${Imm-sh-12-s4},r2r0" | |
9813 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xA) Imm-sh-12-s4) | |
9814 | (sha-sem SI Imm-sh-12-s4 (reg h-r2r0)) | |
9815 | ()) | |
9816 | (dni sha16-L-imm-r3r1 "sha.L #Imm-sh-12-s4,r3r1" ((machine 16)) | |
9817 | "sha.l #${Imm-sh-12-s4},r3r1" | |
9818 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xB) Imm-sh-12-s4) | |
9819 | (sha-sem SI Imm-sh-12-s4 (reg h-r3r1)) | |
9820 | ()) | |
9821 | ; sha.L r1h,dst (m16 #4) | |
9822 | (dni sha16-L-r1h-r2r0 "sha.L r1h,r2r0" ((machine 16)) | |
9823 | "sha.l r1h,r2r0" | |
9824 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 2) (f-12-4 1)) | |
9825 | (sha-sem SI (reg h-r1h) (reg h-r2r0)) | |
9826 | ()) | |
9827 | (dni sha16-L-r1h-r3r1 "sha.L r1h,r3r1" ((machine 16)) | |
9828 | "sha.l r1h,r3r1" | |
9829 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 3) (f-12-4 1)) | |
9830 | (sha-sem SI (reg h-r1h) (reg h-r3r1)) | |
9831 | ()) | |
9832 | ; sha.L #imm8,dst (m32 #2) | |
9833 | (binary-arith32-imm-dst-defn QI SI .l 0 sha X #xA #x2 #x1 sha-sem) | |
9834 | ; sha.L r1h,dst (m32 #4) | |
9835 | (dni sha32.l-dst "sha.l r1h,dest" ((machine 32)) | |
9836 | ("sha.l r1h,${dst32-16-Unprefixed-SI}") | |
9837 | (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 1) (f-12-4 1)) | |
9838 | (shar1h-sem QI dst32-16-Unprefixed-SI) | |
9839 | ()) | |
9840 | ||
9841 | ;------------------------------------------------------------- | |
9842 | ; shanc - shift arithmetic non carry (m32) | |
9843 | ;------------------------------------------------------------- | |
9844 | ||
9845 | ; TODO check semantics | |
9846 | ; shanc.L #imm8,dst | |
9847 | (binary-arith32-imm-dst-defn QI SI .l 0 shanc X #xC #x2 #x1 sha-sem) | |
9848 | ||
9849 | ;------------------------------------------------------------- | |
9850 | ; shl - shift logical | |
9851 | ;------------------------------------------------------------- | |
9852 | ||
9853 | ; TODO future: split this into .b and .w semantics | |
9854 | (define-pmacro (shl-sem mode src1 dst) | |
9855 | (sequence ((mode result)(mode shift)(mode shmode)) | |
9856 | (case DFLT src1 | |
9857 | ((#x0) (set shift 1)) | |
9858 | ((#x1) (set shift 2)) | |
9859 | ((#x2) (set shift 3)) | |
9860 | ((#x3) (set shift 4)) | |
9861 | ((#x4) (set shift 5)) | |
9862 | ((#x5) (set shift 6)) | |
9863 | ((#x6) (set shift 7)) | |
9864 | ((#x7) (set shift 8)) | |
9865 | ((-8) (set shift -1)) | |
9866 | ((-7) (set shift -2)) | |
9867 | ((-6) (set shift -3)) | |
9868 | ((-5) (set shift -4)) | |
9869 | ((-4) (set shift -5)) | |
9870 | ((-3) (set shift -6)) | |
9871 | ((-2) (set shift -7)) | |
9872 | ((-1) (set shift -8)) | |
9873 | (else (set shift 0)) | |
9874 | ) | |
9875 | (set shmode -1) | |
9876 | (set shmode (srl shmode #x8)) | |
9877 | (if (lt mode shift #x0) (set result (srl mode dst (mul shift -1)))) | |
9878 | (if (gt mode shift 0) (set result (sll mode dst shift))) | |
9879 | (if (eq shmode #x0) ; QI | |
9880 | (sequence | |
9881 | ((mode cbitamt)) | |
9882 | (if (lt mode shift #x0) | |
9883 | (set cbitamt (sub #x8 shift)); srl | |
9884 | (set cbitamt (sub shift 1))) ; sll | |
9885 | (set cbit (srl (and (sll dst cbitamt) #x80) #x7)) | |
9886 | (set obit (ne (and dst #x80) (and result #x80))) | |
9887 | )) | |
9888 | (if (eq shmode #xff) ; HI | |
9889 | (sequence | |
9890 | ((mode cbitamt)) | |
9891 | (if (lt mode shift #x0) | |
9892 | (set cbitamt (sub 16 shift)) ; srl | |
9893 | (set cbitamt (sub shift 1))) ; sll | |
9894 | (set cbit (srl (and (sll dst cbitamt) #x8000) #xf)) | |
9895 | (set obit (ne (and dst #x8000) (and result #x8000))) | |
9896 | )) | |
9897 | (set-z-and-s result) | |
9898 | (set dst result)) | |
9899 | ) | |
9900 | (define-pmacro (shlr1h-sem mode dst) | |
9901 | (sequence ((mode result)(mode shmode)) | |
9902 | (set shmode -1) | |
9903 | (set shmode (srl shmode #x8)) | |
9904 | (if (lt mode (reg h-r1h) 0) (set result (srl mode dst (reg h-r1h)))) | |
9905 | (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h)))) | |
9906 | (if (eq shmode #x0) ; QI | |
9907 | (sequence | |
9908 | ((mode cbitamt)) | |
9909 | (if (lt mode (reg h-r1h) #x0) | |
9910 | (set cbitamt (sub #x8 (reg h-r1h))) ; srl | |
9911 | (set cbitamt (sub (reg h-r1h) 1))) ; sll | |
9912 | (set cbit (srl (and (sll dst cbitamt) #x80) #x7)) | |
9913 | (set obit (ne (and dst #x80) (and result #x80))) | |
9914 | )) | |
9915 | (if (eq shmode #xff) ; HI | |
9916 | (sequence | |
9917 | ((mode cbitamt)) | |
9918 | (if (lt mode (reg h-r1h) #x0) | |
9919 | (set cbitamt (sub 16 (reg h-r1h))) ; srl | |
9920 | (set cbitamt (sub (reg h-r1h) 1))) ; sll | |
9921 | (set cbit (srl (and (sll dst cbitamt) #x8000) #xf)) | |
9922 | (set obit (ne (and dst #x8000) (and result #x8000))) | |
9923 | )) | |
9924 | (set-z-and-s result) | |
9925 | (set dst result)) | |
9926 | ) | |
9927 | ; shl.BW #imm4,dst (m16 #1 m32 #1) | |
9928 | (binary-arith16-shimm4-dst-defn QI .b 0 0 shl (f-0-4 #xE) (f-4-3 4) shl-sem) | |
9929 | (binary-arith16-shimm4-dst-defn HI .w 0 1 shl (f-0-4 #xE) (f-4-3 4) shl-sem) | |
9930 | (binary-arith32-shimm4-dst-defn QI .b 0 0 shl #x7 #x0 shl-sem) | |
9931 | (binary-arith32-shimm4-dst-defn HI .w 0 1 shl #x7 #x0 shl-sem) | |
9932 | ; shl.BW r1h,dst (m16 #2 m32 #3) | |
9933 | (dni shl16.b-dst "shl.b r1h,dest" ((machine 16)) | |
9934 | ("shl.b r1h,${dst16-16-QI}") | |
9935 | (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xE) dst16-16-QI) | |
9936 | (shlr1h-sem HI dst16-16-QI) | |
9937 | ()) | |
9938 | (dni shl16.w-dst "shl.w r1h,dest" ((machine 16)) | |
9939 | ("shl.w r1h,${dst16-16-HI}") | |
9940 | (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xE) dst16-16-HI) | |
9941 | (shlr1h-sem HI dst16-16-HI) | |
9942 | ()) | |
9943 | (dni shl32.b-dst "shl.b r1h,dest" ((machine 32)) | |
9944 | ("shl.b r1h,${dst32-16-Unprefixed-QI}") | |
9945 | (+ (f-0-4 #xA) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE)) | |
9946 | (shlr1h-sem QI dst32-16-Unprefixed-QI) | |
9947 | ()) | |
9948 | (dni shl32.w-dst "shl.w r1h,dest" ((machine 32)) | |
9949 | ("shl.w r1h,${dst32-16-Unprefixed-HI}") | |
9950 | (+ (f-0-4 #xA) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE)) | |
9951 | (shlr1h-sem HI dst32-16-Unprefixed-HI) | |
9952 | ()) | |
9953 | ; shl.L #imm,dst (m16 #3) | |
9954 | (dni shl16-L-imm-r2r0 "shl.L #Imm-sh-12-s4,r2r0" ((machine 16)) | |
9955 | "shl.l #${Imm-sh-12-s4},r2r0" | |
9956 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x8) Imm-sh-12-s4) | |
9957 | (shl-sem SI Imm-sh-12-s4 (reg h-r2r0)) | |
9958 | ()) | |
9959 | (dni shl16-L-imm-r3r1 "shl.L #Imm-sh-12-s4,r3r1" ((machine 16)) | |
9960 | "shl.l #${Imm-sh-12-s4},r3r1" | |
9961 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x9) Imm-sh-12-s4) | |
9962 | (shl-sem SI Imm-sh-12-s4 (reg h-r3r1)) | |
9963 | ()) | |
9964 | ; shl.L r1h,dst (m16 #4) | |
9965 | (dni shl16-L-r1h-r2r0 "shl.L r1h,r2r0" ((machine 16)) | |
9966 | "shl.l r1h,r2r0" | |
9967 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 0) (f-12-4 1)) | |
9968 | (shl-sem SI (reg h-r1h) (reg h-r2r0)) | |
9969 | ()) | |
9970 | (dni shl16-L-r1h-r3r1 "shl.L r1h,r3r1" ((machine 16)) | |
9971 | "shl.l r1h,r3r1" | |
9972 | (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 1) (f-12-4 1)) | |
9973 | (shl-sem SI (reg h-r1h) (reg h-r3r1)) | |
9974 | ()) | |
9975 | ; shl.L #imm8,dst (m32 #2) | |
9976 | (binary-arith32-imm-dst-defn QI SI .l 0 shl X #x9 #x2 #x1 shl-sem) | |
9977 | ; shl.L r1h,dst (m32 #4) | |
9978 | (dni shl32.l-dst "shl.l r1h,dest" ((machine 32)) | |
9979 | ("shl.l r1h,${dst32-16-Unprefixed-SI}") | |
9980 | (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 0) (f-12-4 1)) | |
9981 | (shlr1h-sem QI dst32-16-Unprefixed-SI) | |
9982 | ()) | |
9983 | ||
9984 | ;------------------------------------------------------------- | |
9985 | ; shlnc - shift logical non carry | |
9986 | ;------------------------------------------------------------- | |
9987 | ||
9988 | ; TODO check semantics | |
9989 | ; shlnc.L #imm8,dst | |
9990 | (binary-arith32-imm-dst-defn QI SI .l 0 shlnc X #x8 #x2 #x1 shl-sem) | |
9991 | ||
9992 | ;------------------------------------------------------------- | |
9993 | ; sin - string input (m32) | |
9994 | ;------------------------------------------------------------- | |
9995 | ||
9996 | ; TODO semantics | |
9997 | (dni sin32.b "sin" ((machine 32)) | |
9998 | ("sin.b") | |
9999 | (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 8) (f-12-4 3)) | |
10000 | (c-call VOID "sin_QI_semantics") | |
10001 | ()) | |
10002 | ||
10003 | (dni sin32.w "sin" ((machine 32)) | |
10004 | ("sin.w") | |
10005 | (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 9) (f-12-4 3)) | |
10006 | (c-call VOID "sin_HI_semantics") | |
10007 | ()) | |
10008 | ||
10009 | ;------------------------------------------------------------- | |
10010 | ; smovb - string move backward | |
10011 | ;------------------------------------------------------------- | |
10012 | ||
10013 | ; TODO semantics | |
10014 | (dni smovb16.b "smovb.b" ((machine 16)) | |
10015 | ("smovb.b") | |
10016 | (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 9)) | |
10017 | (c-call VOID "smovb_QI_semantics") | |
10018 | ()) | |
10019 | ||
10020 | (dni smovb16.w "smovb.w" ((machine 16)) | |
10021 | ("smovb.w") | |
10022 | (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 9)) | |
10023 | (c-call VOID "smovb_HI_semantics") | |
10024 | ()) | |
10025 | ||
10026 | (dni smovb32.b "smovb.b" ((machine 32)) | |
10027 | ("smovb.b") | |
10028 | (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 8) (f-12-4 3)) | |
10029 | (c-call VOID "smovb_QI_semantics") | |
10030 | ()) | |
10031 | ||
10032 | (dni smovb32.w "smovb.w" ((machine 32)) | |
10033 | ("smovb.w") | |
10034 | (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 9) (f-12-4 3)) | |
10035 | (c-call VOID "smovb_HI_semantics") | |
10036 | ()) | |
10037 | ||
10038 | ;------------------------------------------------------------- | |
10039 | ; smovf - string move forward (m32) | |
10040 | ;------------------------------------------------------------- | |
10041 | ||
10042 | ; TODO semantics | |
10043 | (dni smovf16.b "smovf.b" ((machine 16)) | |
10044 | ("smovf.b") | |
10045 | (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 8)) | |
10046 | (c-call VOID "smovf_QI_semantics") | |
10047 | ()) | |
10048 | ||
10049 | (dni smovf16.w "smovf.w" ((machine 16)) | |
10050 | ("smovf.w") | |
10051 | (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 8)) | |
10052 | (c-call VOID "smovf_HI_semantics") | |
10053 | ()) | |
10054 | ||
10055 | (dni smovf32.b "smovf.b" ((machine 32)) | |
10056 | ("smovf.b") | |
10057 | (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 8) (f-12-4 3)) | |
10058 | (c-call VOID "smovf_QI_semantics") | |
10059 | ()) | |
10060 | ||
10061 | (dni smovf32.w "smovf.w" ((machine 32)) | |
10062 | ("smovf.w") | |
10063 | (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 9) (f-12-4 3)) | |
10064 | (c-call VOID "smovf_HI_semantics") | |
10065 | ()) | |
10066 | ||
10067 | ;------------------------------------------------------------- | |
10068 | ; smovu - string move unequal (m32) | |
10069 | ;------------------------------------------------------------- | |
10070 | ||
10071 | ; TODO semantics | |
10072 | (dni smovu.b "smovu.b" ((machine 32)) | |
10073 | ("smovu.b") | |
10074 | (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 8) (f-12-4 3)) | |
10075 | (c-call VOID "smovu_QI_semantics") | |
10076 | ()) | |
10077 | ||
10078 | (dni smovu.w "smovu.w" ((machine 32)) | |
10079 | ("smovu.w") | |
10080 | (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 9) (f-12-4 3)) | |
10081 | (c-call VOID "smovu_HI_semantics") | |
10082 | ()) | |
10083 | ||
10084 | ;------------------------------------------------------------- | |
10085 | ; sout - string output (m32) | |
10086 | ;------------------------------------------------------------- | |
10087 | ||
10088 | ; TODO semantics | |
10089 | (dni sout.b "sout.b" ((machine 32)) | |
10090 | ("sout.b") | |
10091 | (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 8) (f-12-4 3)) | |
10092 | (c-call VOID "sout_QI_semantics") | |
10093 | ()) | |
10094 | ||
10095 | (dni sout.w "sout" ((machine 32)) | |
10096 | ("sout.w") | |
10097 | (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 9) (f-12-4 3)) | |
10098 | (c-call VOID "sout_HI_semantics") | |
10099 | ()) | |
10100 | ||
10101 | ;------------------------------------------------------------- | |
10102 | ; sstr - string store | |
10103 | ;------------------------------------------------------------- | |
10104 | ||
10105 | ; TODO semantics | |
10106 | (dni sstr16.b "sstr.b" ((machine 16)) | |
10107 | ("sstr.b") | |
10108 | (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 #xA)) | |
10109 | (c-call VOID "sstr_QI_semantics") | |
10110 | ()) | |
10111 | ||
10112 | (dni sstr16.w "sstr.w" ((machine 16)) | |
10113 | ("sstr.w") | |
10114 | (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 #xA)) | |
10115 | (c-call VOID "sstr_HI_semantics") | |
10116 | ()) | |
10117 | ||
10118 | (dni sstr.b "sstr" ((machine 32)) | |
10119 | ("sstr.b") | |
10120 | (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 0) (f-12-4 3)) | |
10121 | (c-call VOID "sstr_QI_semantics") | |
10122 | ()) | |
10123 | ||
10124 | (dni sstr.w "sstr" ((machine 32)) | |
10125 | ("sstr.w") | |
10126 | (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 1) (f-12-4 3)) | |
10127 | (c-call VOID "sstr_HI_semantics") | |
10128 | ()) | |
10129 | ||
10130 | ;------------------------------------------------------------- | |
10131 | ; stnz - store on not zero | |
10132 | ;------------------------------------------------------------- | |
10133 | ||
10134 | (define-pmacro (stnz-sem mode src dst) | |
10135 | (sequence () | |
10136 | (if (ne zbit (const 1)) | |
10137 | (set dst src))) | |
10138 | ) | |
10139 | ; stnz #imm8,dst3 (m16) | |
10140 | (binary-arith16-b-S-imm8-dst3 stnz "" (f-0-4 #xD) (f-4-1 0) stnz-sem) | |
10141 | ; stnz.BW #imm,dst (m32) | |
10142 | (binary-arith32-imm-dst-defn QI QI .b 0 stnz X #x9 #x1 #xF stnz-sem) | |
10143 | (binary-arith32-imm-dst-defn HI HI .w 1 stnz X #x9 #x1 #xF stnz-sem) | |
10144 | ||
10145 | ;------------------------------------------------------------- | |
10146 | ; stz - store on zero | |
10147 | ;------------------------------------------------------------- | |
10148 | ||
10149 | (define-pmacro (stz-sem mode src dst) | |
10150 | (sequence () | |
10151 | (if (eq zbit (const 1)) | |
10152 | (set dst src))) | |
10153 | ) | |
10154 | ; stz #imm8,dst3 (m16) | |
10155 | (binary-arith16-b-S-imm8-dst3 stz "" (f-0-4 #xC) (f-4-1 1) stz-sem) | |
10156 | ; stz.BW #imm,dst (m32) | |
10157 | (binary-arith32-imm-dst-defn QI QI .b 0 stz X #x9 #x0 #xF stz-sem) | |
10158 | (binary-arith32-imm-dst-defn HI HI .w 1 stz X #x9 #x0 #xF stz-sem) | |
10159 | ||
10160 | ;------------------------------------------------------------- | |
10161 | ; stzx - store on zero extention | |
10162 | ;------------------------------------------------------------- | |
10163 | ||
10164 | (define-pmacro (stzx-sem mode src1 src2 dst) | |
10165 | (sequence () | |
10166 | (if (eq zbit (const 1)) | |
10167 | (set dst src1) | |
10168 | (set dst src2))) | |
10169 | ) | |
10170 | ; stzx #imm8,dst3 (m16) | |
10171 | (dni stzx16-imm8-imm8-r0h "stzx #Imm8,#Imm8,r0h" ((machine 16)) | |
10172 | ("stzx #${Imm-8-QI},#${Imm-16-QI},r0h") | |
10173 | (+ (f-0-4 #xD) (f-4-4 #xB) Imm-8-QI Imm-16-QI) | |
10174 | (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0h)) | |
10175 | ()) | |
10176 | (dni stzx16-imm8-imm8-r0l "stzx #Imm8,#Imm8,r0l" ((machine 16)) | |
10177 | ("stzx #${Imm-8-QI},#${Imm-16-QI},r0l") | |
10178 | (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI Imm-16-QI) | |
10179 | (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0l)) | |
10180 | ()) | |
10181 | (dni stzx16-imm8-imm8-dsp8sb "stzx #Imm8,#Imm8,dsp8[sb]" ((machine 16)) | |
c6552317 | 10182 | ("stzx #${Imm-8-QI},#${Imm-24-QI},${Dsp-16-u8}[sb]") |
49f58d10 JB |
10183 | (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI Dsp-16-u8 Imm-24-QI) |
10184 | (stzx-sem QI Imm-8-QI Imm-16-QI (mem16 QI (add (reg h-sb) Dsp-24-u8))) | |
10185 | ()) | |
10186 | (dni stzx16-imm8-imm8-dsp8fb "stzx #Imm8,#Imm8,dsp8[fb]" ((machine 16)) | |
c6552317 DD |
10187 | ("stzx #${Imm-8-QI},#${Imm-24-QI},${Dsp-16-s8}[fb]") |
10188 | (+ (f-0-4 #xD) (f-4-4 #xE) Imm-8-QI Dsp-16-s8 Imm-24-QI) | |
10189 | (stzx-sem QI Imm-8-QI Imm-24-QI (mem16 QI (add (reg h-fb) Dsp-16-s8))) | |
49f58d10 JB |
10190 | ()) |
10191 | (dni stzx16-imm8-imm8-abs16 "stzx #Imm8,#Imm8,abs16" ((machine 16)) | |
c6552317 | 10192 | ("stzx #${Imm-8-QI},#${Imm-32-QI},${Dsp-16-u16}") |
49f58d10 JB |
10193 | (+ (f-0-4 #xD) (f-4-4 #xE) Imm-8-QI Dsp-16-u16 Imm-32-QI) |
10194 | (stzx-sem QI Imm-8-QI Imm-32-QI (mem16 QI Dsp-16-u16)) | |
10195 | ()) | |
10196 | ; stzx.BW #imm,dst (m32) | |
10197 | (insn-imm1-imm2-dst-Unprefixed stzx #x9 #x3 #xF stzx-sem) | |
10198 | ||
10199 | ;------------------------------------------------------------- | |
10200 | ; subx - subtract extend (m32) | |
10201 | ;------------------------------------------------------------- | |
10202 | ||
10203 | (define-pmacro (subx-sem mode src1 dst) | |
10204 | (sequence ((mode result)) | |
10205 | (set result (sub mode dst (ext mode src1))) | |
10206 | (set obit (sub-oflag mode dst (ext mode src1) 0)) | |
10207 | (set cbit (sub-cflag mode dst (ext mode src1) 0)) | |
10208 | (set dst result) | |
10209 | (set-z-and-s result))) | |
10210 | ; subx #imm8,dst | |
10211 | (binary-arith32-imm-dst-defn QI SI "" 0 subx G #x9 #x1 #x1 subx-sem) | |
10212 | ; subx src,dst | |
10213 | (binary-arith32-src-dst-defn QI SI "" 0 subx G #x1 #x0 subx-sem) | |
10214 | ||
10215 | ;------------------------------------------------------------- | |
10216 | ; tst - test | |
10217 | ;------------------------------------------------------------- | |
10218 | ||
10219 | (define-pmacro (tst-sem mode src1 dst) | |
10220 | (sequence ((mode result)) | |
10221 | (set result (and mode dst src1)) | |
10222 | (set-z-and-s result)) | |
10223 | ) | |
10224 | ||
10225 | ; tst.BW #imm,dst (m16 #1 m32 #1) | |
f75eb1c0 | 10226 | (binary-arith-imm-dst tst G (f-0-4 7) (f-4-3 3) (f-8-4 0) #x9 #x3 #xE tst-sem) |
49f58d10 JB |
10227 | ; tst.BW src,dst (m16 #2 m32 #3) |
10228 | (binary-arith16-src-dst-defn QI QI .b 0 tst X (f-0-4 #x8) (f-4-3 0) tst-sem) | |
10229 | (binary-arith16-src-dst-defn HI HI .w 1 tst X (f-0-4 #x8) (f-4-3 0) tst-sem) | |
f75eb1c0 DD |
10230 | (binary-arith32-src-dst-Prefixed QI QI .b 0 tst G #x1 #x9 tst-sem) |
10231 | (binary-arith32-src-dst-Prefixed HI HI .w 1 tst G #x1 #x9 tst-sem) | |
49f58d10 JB |
10232 | ; tst.BW:S #imm,dst2 (m32 #2) |
10233 | (binary-arith32-s-imm-dst QI .b 0 tst #x0 #x6 tst-sem) | |
10234 | (binary-arith32-s-imm-dst HI .w 1 tst #x0 #x6 tst-sem) | |
10235 | ||
10236 | ;------------------------------------------------------------- | |
10237 | ; und - undefined | |
10238 | ;------------------------------------------------------------- | |
10239 | ||
10240 | (dni und16 "und" ((machine 16)) | |
10241 | ("und") | |
10242 | (+ (f-0-4 #xF) (f-4-4 #xF)) | |
10243 | (nop) | |
10244 | ()) | |
10245 | ||
10246 | (dni und32 "und" ((machine 32)) | |
10247 | ("und") | |
10248 | (+ (f-0-4 #xF) (f-4-4 #xF)) | |
10249 | (nop) | |
10250 | ()) | |
10251 | ||
10252 | ;------------------------------------------------------------- | |
10253 | ; wait | |
10254 | ;------------------------------------------------------------- | |
10255 | ||
10256 | ; ??? semantics | |
10257 | (dni wait16 "wait" ((machine 16)) | |
10258 | ("wait") | |
10259 | (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 3)) | |
10260 | (nop) | |
10261 | ()) | |
10262 | ||
10263 | (dni wait "wait" ((machine 32)) | |
10264 | ("wait") | |
10265 | (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 0) (f-12-4 3)) | |
10266 | (nop) | |
10267 | ()) | |
10268 | ||
10269 | ;------------------------------------------------------------- | |
10270 | ; xchg - exchange | |
10271 | ;------------------------------------------------------------- | |
10272 | ||
10273 | (define-pmacro (xchg-sem mode src dst) | |
10274 | (sequence ((mode result)) | |
10275 | (set result src) | |
10276 | (set src dst) | |
10277 | (set dst result)) | |
10278 | ) | |
10279 | (define-pmacro (xchg16-defn mode sz szc src srcreg) | |
10280 | (dni (.sym xchg16 sz - srcreg) | |
10281 | (.str "xchg" sz "-" srcreg ",dst16-16-" mode) | |
10282 | ((machine 16)) | |
10283 | (.str "xchg." sz " " srcreg ",${dst16-16-" mode "}") | |
10284 | (+ (f-0-4 #x7) (f-4-3 #x5) (f-7-1 szc) (f-8-2 0) (f-10-2 src) (.sym dst16-16- mode)) | |
10285 | (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst16-16- mode)) | |
10286 | ()) | |
10287 | ) | |
10288 | (xchg16-defn QI b 0 0 r0l) | |
10289 | (xchg16-defn QI b 0 1 r0h) | |
10290 | (xchg16-defn QI b 0 2 r1l) | |
10291 | (xchg16-defn QI b 0 3 r1h) | |
a1a280bb | 10292 | (xchg16-defn HI w 1 0 r0) |
49f58d10 JB |
10293 | (xchg16-defn HI w 1 1 r1) |
10294 | (xchg16-defn HI w 1 2 r2) | |
10295 | (xchg16-defn HI w 1 3 r3) | |
10296 | (define-pmacro (xchg32-defn mode sz szc src srcreg) | |
10297 | (dni (.sym xchg32 sz - srcreg) | |
10298 | (.str "xchg" sz "-" srcreg ",dst32-16-Unprefixed-" mode) | |
10299 | ((machine 32)) | |
10300 | (.str "xchg." sz " " srcreg ",${dst32-16-Unprefixed-" mode "}") | |
10301 | (+ (f-0-4 #xD) (.sym dst32-16-Unprefixed- mode) (f-7-1 szc) (f-10-2 0) (f-12-1 1) (f-13-3 src)) | |
10302 | (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst32-16-Unprefixed- mode)) | |
10303 | ()) | |
10304 | ) | |
10305 | (xchg32-defn QI b 0 0 r0l) | |
10306 | (xchg32-defn QI b 0 1 r1l) | |
10307 | (xchg32-defn QI b 0 2 a0) | |
10308 | (xchg32-defn QI b 0 3 a1) | |
10309 | (xchg32-defn QI b 0 4 r0h) | |
10310 | (xchg32-defn QI b 0 5 r1h) | |
10311 | (xchg32-defn HI w 1 0 r0) | |
10312 | (xchg32-defn HI w 1 1 r1) | |
10313 | (xchg32-defn HI w 1 2 a0) | |
10314 | (xchg32-defn HI w 1 3 a1) | |
10315 | (xchg32-defn HI w 1 4 r2) | |
10316 | (xchg32-defn HI w 1 5 r3) | |
10317 | ||
10318 | ;------------------------------------------------------------- | |
10319 | ; xor - exclusive or | |
10320 | ;------------------------------------------------------------- | |
10321 | ||
10322 | (define-pmacro (xor-sem mode src1 dst) | |
10323 | (sequence ((mode result)) | |
10324 | (set result (xor mode src1 dst)) | |
10325 | (set-z-and-s result) | |
10326 | (set dst result)) | |
10327 | ) | |
10328 | ||
10329 | ; xor.BW #imm,dst (m16 #1 m32 #1) | |
10330 | (binary-arith-imm-dst xor G (f-0-4 7) (f-4-3 3) (f-8-4 1) #x9 #x0 #xE xor-sem) | |
10331 | ; xor.BW src,dst (m16 #3 m32 #3) | |
10332 | (binary-arith-src-dst xor G (f-0-4 #x8) (f-4-3 4) #x1 #x9 xor-sem) | |
10333 | ||
10334 | ;------------------------------------------------------------- | |
10335 | ; Widening | |
10336 | ;------------------------------------------------------------- | |
10337 | ||
10338 | (define-pmacro (exts-sem smode dmode src dst) | |
10339 | (set dst (ext dmode (trunc smode src))) | |
10340 | ) | |
10341 | (define-pmacro (extz-sem smode dmode src dst) | |
10342 | (set dst (zext dmode (trunc smode src))) | |
10343 | ) | |
10344 | ||
10345 | ; exts.b dst for m16c | |
10346 | (ext16-defn QI HI .b 0 exts (f-0-4 7) (f-4-3 6) (f-8-4 6) exts-sem) | |
10347 | ||
10348 | ; exts.w r0 for m16c | |
10349 | (dni exts16.w-r0 | |
10350 | "exts.w r0" | |
10351 | ((machine 16)) | |
10352 | "exts.w r0" | |
10353 | (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 3)) | |
10354 | (exts-sem HI SI R0 R2R0) | |
10355 | ()) | |
10356 | ||
10357 | ; exts.size dst for m32c | |
10358 | (ext32-defn QI HI .b 0 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem) | |
10359 | (ext32-defn HI SI .w 1 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem) | |
10360 | ; exts.b src,dst for m32c | |
10361 | (ext32-binary-defn exts .b #x1 #x7 exts-sem) | |
10362 | ||
10363 | ; extz.b src,dst for m32c | |
10364 | (ext32-binary-defn extz "" #x1 #xB extz-sem) | |
10365 | ||
10366 | ;------------------------------------------------------------- | |
10367 | ; Indirect | |
10368 | ;------------------------------------------------------------- | |
10369 | ||
10370 | ; TODO semantics | |
10371 | (dni srcind "SRC-INDIRECT" ((machine 32)) | |
10372 | ("src-indirect") | |
10373 | (+ (f-0-4 4) (f-4-4 1)) | |
10374 | (set (reg h-src-indirect) 1) | |
10375 | ()) | |
10376 | ||
10377 | (dni destind "DEST-INDIRECT" ((machine 32)) | |
10378 | ("dest-indirect") | |
10379 | (+ (f-0-4 0) (f-4-4 9)) | |
10380 | (set (reg h-dst-indirect) 1) | |
10381 | ()) | |
10382 | ||
10383 | (dni srcdestind "SRC-DEST-INDIRECT" ((machine 32)) | |
10384 | ("src-dest-indirect") | |
10385 | (+ (f-0-4 4) (f-4-4 9)) | |
10386 | (sequence () (set (reg h-src-indirect) 1) (set (reg h-dst-indirect) 1)) | |
10387 | ()) |