1 ; Renesas M32C CPU description. -*- Scheme -*-
3 ; Copyright 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
5 ; Contributed by Red Hat Inc; developed under contract from Renesas.
7 ; This file is part of the GNU Binutils.
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 3 of the License, or
12 ; (at your option) any later version.
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.
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,
24 (include "simplify.inc")
28 (comment "Renesas M32C")
29 (default-alignment forced)
38 (default-insn-bitsize 32)
40 ; Number of bytes of insn we can initially fetch.
41 (base-insn-bitsize 32)
43 ; Used in computing bit numbers.
44 (default-insn-word-bitsize 32)
46 (decode-assist (0 1 2 3 4 5 6 7)) ; Initial bitnumbers to decode insns by.
48 ; fetches 1 insn at a time.
51 ; executes 1 insn at a time.
58 (default-insn-bitsize 32)
60 ; Number of bytes of insn we can initially fetch.
61 (base-insn-bitsize 32)
63 ; Used in computing bit numbers.
64 (default-insn-word-bitsize 32)
66 (decode-assist (0 1 2 3 4 5 6 7)) ; Initial bitnumbers to decode insns by.
68 ; fetches 1 insn at a time.
71 ; executes 1 insn at a time.
76 ; cpu names must be distinct from the architecture name and machine names.
77 ; The "b" suffix stands for "base" and is the convention.
78 ; The "f" suffix stands for "family" and is the convention.
80 (comment "Renesas M16C base family")
87 ; cpu names must be distinct from the architecture name and machine names.
88 ; The "b" suffix stands for "base" and is the convention.
89 ; The "f" suffix stands for "family" and is the convention.
91 (comment "Renesas M32C base family")
99 (comment "Generic M16C cpu")
105 (comment "Generic M32C cpu")
109 ; Model descriptions.
113 (comment "m16c") (attrs)
116 ; `state' is a list of variables for recording model state
118 (unit u-exec "Execution Unit" ()
123 () ; profile action (default)
129 (comment "m32c") (attrs)
132 ; `state' is a list of variables for recording model state
134 (unit u-exec "Execution Unit" ()
139 () ; profile action (default)
146 (values NONE JUMP 1ADDR 2ADDR)
150 ; Macros to simplify MACH attribute specification.
152 (define-pmacro all-isas () (ISA m16c,m32c))
153 (define-pmacro m16c-isa () (ISA m16c))
154 (define-pmacro m32c-isa () (ISA m32c))
156 (define-pmacro MACH16 (MACH m16c))
157 (define-pmacro MACH32 (MACH m32c))
159 (define-pmacro (machine size)
160 (MACH (.sym m size c)) (ISA (.sym m size c)))
162 (define-pmacro RL_JUMP (RL_TYPE JUMP))
163 (define-pmacro RL_1ADDR (RL_TYPE 1ADDR))
164 (define-pmacro RL_2ADDR (RL_TYPE 2ADDR))
167 ;=============================================================
169 ;-------------------------------------------------------------
172 (dnf f-0-1 "opcode" (all-isas) 0 1)
173 (dnf f-0-2 "opcode" (all-isas) 0 2)
174 (dnf f-0-3 "opcode" (all-isas) 0 3)
175 (dnf f-0-4 "opcode" (all-isas) 0 4)
176 (dnf f-1-3 "opcode" (all-isas) 1 3)
177 (dnf f-2-2 "opcode" (all-isas) 2 2)
178 (dnf f-3-4 "opcode" (all-isas) 3 4)
179 (dnf f-3-1 "opcode" (all-isas) 3 1)
180 (dnf f-4-1 "opcode" (all-isas) 4 1)
181 (dnf f-4-3 "opcode" (all-isas) 4 3)
182 (dnf f-4-4 "opcode" (all-isas) 4 4)
183 (dnf f-4-6 "opcode" (all-isas) 4 6)
184 (dnf f-5-1 "opcode" (all-isas) 5 1)
185 (dnf f-5-3 "opcode" (all-isas) 5 3)
186 (dnf f-6-2 "opcode" (all-isas) 6 2)
187 (dnf f-7-1 "opcode" (all-isas) 7 1)
188 (dnf f-8-1 "opcode" (all-isas) 8 1)
189 (dnf f-8-2 "opcode" (all-isas) 8 2)
190 (dnf f-8-3 "opcode" (all-isas) 8 3)
191 (dnf f-8-4 "opcode" (all-isas) 8 4)
192 (dnf f-8-8 "opcode" (all-isas) 8 8)
193 (dnf f-9-3 "opcode" (all-isas) 9 3)
194 (dnf f-9-1 "opcode" (all-isas) 9 1)
195 (dnf f-10-1 "opcode" (all-isas) 10 1)
196 (dnf f-10-2 "opcode" (all-isas) 10 2)
197 (dnf f-10-3 "opcode" (all-isas) 10 3)
198 (dnf f-11-1 "opcode" (all-isas) 11 1)
199 (dnf f-12-1 "opcode" (all-isas) 12 1)
200 (dnf f-12-2 "opcode" (all-isas) 12 2)
201 (dnf f-12-3 "opcode" (all-isas) 12 3)
202 (dnf f-12-4 "opcode" (all-isas) 12 4)
203 (dnf f-12-6 "opcode" (all-isas) 12 6)
204 (dnf f-13-3 "opcode" (all-isas) 13 3)
205 (dnf f-14-1 "opcode" (all-isas) 14 1)
206 (dnf f-14-2 "opcode" (all-isas) 14 2)
207 (dnf f-15-1 "opcode" (all-isas) 15 1)
208 (dnf f-16-1 "opcode" (all-isas) 16 1)
209 (dnf f-16-2 "opcode" (all-isas) 16 2)
210 (dnf f-16-4 "opcode" (all-isas) 16 4)
211 (dnf f-16-8 "opcode" (all-isas) 16 8)
212 (dnf f-18-1 "opcode" (all-isas) 18 1)
213 (dnf f-18-2 "opcode" (all-isas) 18 2)
214 (dnf f-18-3 "opcode" (all-isas) 18 3)
215 (dnf f-20-1 "opcode" (all-isas) 20 1)
216 (dnf f-20-3 "opcode" (all-isas) 20 3)
217 (dnf f-20-2 "opcode" (all-isas) 20 2)
218 (dnf f-20-4 "opcode" (all-isas) 20 4)
219 (dnf f-21-3 "opcode" (all-isas) 21 3)
220 (dnf f-24-2 "opcode" (all-isas) 24 2)
221 (dnf f-24-8 "opcode" (all-isas) 24 8)
222 (dnf f-32-16 "opcode" (all-isas) 32 16)
224 ;-------------------------------------------------------------
226 ;-------------------------------------------------------------
228 (dnf f-src16-rn "source Rn for m16c" (MACH16 m16c-isa) 10 2)
229 (dnf f-src16-an "source An for m16c" (MACH16 m16c-isa) 11 1)
231 (dnf f-src32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 11 1)
232 (dnf f-src32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 19 1)
234 ; QI mode gr encoding for m32c is different than for m16c. The hardware
235 ; is indexed using the m16c encoding, so perform the transformation here.
237 ; ----------------------
242 (df f-src32-rn-unprefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 10 2 UINT
243 ((value pc) (or USI (and (inv (sll value 1)) 2) (and (srl value 1) 1))) ; insert
244 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
246 ; QI mode gr encoding for m32c is different than for m16c. The hardware
247 ; is indexed using the m16c encoding, so perform the transformation here.
249 ; ----------------------
254 (df f-src32-rn-prefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 18 2 UINT
255 ((value pc) (or USI (and (inv (sll value 1)) 2) (and (srl value 1) 1))) ; insert
256 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
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.
261 ; ----------------------
266 (df f-src32-rn-unprefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 10 2 UINT
267 ((value pc) (mod USI (add value 2) 4)) ; insert
268 ((value pc) (mod USI (add value 2) 4)) ; extract
271 ; HI mode gr encoding for m32c is different than for m16c. The hardware
272 ; is indexed using the m16c encoding, so perform the transformation here.
274 ; ----------------------
279 (df f-src32-rn-prefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 18 2 UINT
280 ((value pc) (mod USI (add value 2) 4)) ; insert
281 ((value pc) (mod USI (add value 2) 4)) ; extract
284 ; SI mode gr encoding for m32c is as follows:
285 ; register encoding index
286 ; -------------------------
289 (df f-src32-rn-unprefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 10 2 UINT
290 ((value pc) (add USI value 2)) ; insert
291 ((value pc) (sub USI value 2)) ; extract
293 (df f-src32-rn-prefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 18 2 UINT
294 ((value pc) (add USI value 2)) ; insert
295 ((value pc) (sub USI value 2)) ; extract
298 (dnf f-dst32-rn-ext-unprefixed "destination Rn for m32c" (MACH32 m32c-isa) 9 1)
300 (dnf f-dst16-rn "destination Rn for m16c" (MACH16 m16c-isa) 14 2)
301 (dnf f-dst16-rn-ext "destination Rn for m16c" (MACH16 m16c-isa) 14 1)
302 (dnf f-dst16-rn-QI-s "destination Rn for m16c" (MACH16 m16c-isa) 5 1)
304 (dnf f-dst16-an "destination An for m16c" (MACH16 m16c-isa) 15 1)
305 (dnf f-dst16-an-s "destination An for m16c" (MACH16 m16c-isa) 4 1)
307 (dnf f-dst32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 9 1)
308 (dnf f-dst32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 17 1)
310 ; QI mode gr encoding for m32c is different than for m16c. The hardware
311 ; is indexed using the m16c encoding, so perform the transformation here.
313 ; ----------------------
318 (df f-dst32-rn-unprefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 8 2 UINT
319 ((value pc) (or USI (and (inv (sll value 1)) 2) (and (srl value 1) 1))) ; insert
320 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
322 (df f-dst32-rn-prefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 16 2 UINT
323 ((value pc) (or USI (and (inv (sll value 1)) 2) (and (srl value 1) 1))) ; insert
324 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
326 ; HI mode gr encoding for m32c is different than for m16c. The hardware
327 ; is indexed using the m16c encoding, so perform the transformation here.
329 ; ----------------------
334 (df f-dst32-rn-unprefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 8 2 UINT
335 ((value pc) (mod USI (add value 2) 4)) ; insert
336 ((value pc) (mod USI (add value 2) 4)) ; extract
338 (df f-dst32-rn-prefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 16 2 UINT
339 ((value pc) (mod USI (add value 2) 4)) ; insert
340 ((value pc) (mod USI (add value 2) 4)) ; extract
342 ; SI mode gr encoding for m32c is as follows:
343 ; register encoding index
344 ; -------------------------
347 (df f-dst32-rn-unprefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 8 2 UINT
348 ((value pc) (add USI value 2)) ; insert
349 ((value pc) (sub USI value 2)) ; extract
351 (df f-dst32-rn-prefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 16 2 UINT
352 ((value pc) (add USI value 2)) ; insert
353 ((value pc) (sub USI value 2)) ; extract
356 (dnf f-dst16-1-S "destination R0[hl] for m16c" (MACH16 m16c-isa) 5 1)
358 ;-------------------------------------------------------------
359 ; Immediates embedded in the base insn
360 ;-------------------------------------------------------------
362 (df f-imm-8-s4 "4 bit signed" (all-isas) 8 4 INT #f #f)
363 (df f-imm-12-s4 "4 bit signed" (all-isas) 12 4 INT #f #f)
364 (df f-imm-13-u3 "3 bit unsigned" (all-isas) 13 3 UINT #f #f)
365 (df f-imm-20-s4 "4 bit signed" (all-isas) 20 4 INT #f #f)
367 (df f-imm1-S "1 bit immediate for short format binary insns" (MACH32 m32c-isa) 2 1 UINT
368 ((value pc) (sub USI value 1)) ; insert
369 ((value pc) (add USI value 1)) ; extract
372 (dnmf f-imm3-S "3 bit unsigned for short format insns" (all-isas) UINT
374 (sequence () ; insert
375 (set (ifield f-7-1) (and (sub (ifield f-imm3-S) 1) 1))
376 (set (ifield f-2-2) (and (srl (sub (ifield f-imm3-S) 1) 1) #x3))
378 (sequence () ; extract
379 (set (ifield f-imm3-S) (add (or (sll (ifield f-2-2) 1)
385 ;-------------------------------------------------------------
386 ; Immediates and displacements beyond the base insn
387 ;-------------------------------------------------------------
389 (df f-dsp-8-u6 "6 bit unsigned" (all-isas) 8 6 UINT #f #f)
390 (df f-dsp-8-u8 "8 bit unsigned" (all-isas) 8 8 UINT #f #f)
391 (df f-dsp-8-s8 "8 bit signed" (all-isas) 8 8 INT #f #f)
392 (df f-dsp-10-u6 "6 bit unsigned" (all-isas) 10 6 UINT #f #f)
393 (df f-dsp-16-u8 "8 bit unsigned" (all-isas) 16 8 UINT #f #f)
394 (df f-dsp-16-s8 "8 bit signed" (all-isas) 16 8 INT #f #f)
395 (df f-dsp-24-u8 "8 bit unsigned" (all-isas) 24 8 UINT #f #f)
396 (df f-dsp-24-s8 "8 bit signed" (all-isas) 24 8 INT #f #f)
397 (df f-dsp-32-u8 "8 bit unsigned" (all-isas) 32 8 UINT #f #f)
398 (df f-dsp-32-s8 "8 bit signed" (all-isas) 32 8 INT #f #f)
399 (df f-dsp-40-u8 "8 bit unsigned" (all-isas) 40 8 UINT #f #f)
400 (df f-dsp-40-s8 "8 bit signed" (all-isas) 40 8 INT #f #f)
401 (df f-dsp-48-u8 "8 bit unsigned" (all-isas) 48 8 UINT #f #f)
402 (df f-dsp-48-s8 "8 bit signed" (all-isas) 48 8 INT #f #f)
403 (df f-dsp-56-u8 "8 bit unsigned" (all-isas) 56 8 UINT #f #f)
404 (df f-dsp-56-s8 "8 bit signed" (all-isas) 56 8 INT #f #f)
405 (df f-dsp-64-u8 "8 bit unsigned" (all-isas) 64 8 UINT #f #f)
406 (df f-dsp-64-s8 "8 bit signed" (all-isas) 64 8 INT #f #f)
408 ; Insn opcode endianness is big, but the immediate fields are stored
409 ; in little endian. Handle this here at the field level for all immediate
410 ; fields longer that 1 byte.
412 ; CGEN can't handle a field which spans a 32 bit word boundary, so
413 ; handle those as multi ifields.
415 ; Take care in expressions using 'srl' or 'sll' as part of some larger
416 ; expression meant to yield sign-extended values. CGEN translates
417 ; uses of those operators into C expressions whose type is 'unsigned
418 ; int', which tends to make the whole expression 'unsigned int'.
419 ; Expressions like (set (ifield foo) X), however, just take X and
420 ; store it in some member of 'struct cgen_fields', all of whose
421 ; members are 'long'. On machines where 'long' is larger than
422 ; 'unsigned int', assigning a "sign-extended" unsigned int to a long
423 ; just produces a very large positive value. insert_normal will
424 ; range-check the field's value and produce odd error messages like
427 ; Error: operand out of range (4160684031 not between -2147483648 and 2147483647) `add.l #-265,-270[fb]'
429 ; Annoyingly, the code will work fine on machines where 'long' and
430 ; 'unsigned int' are the same size: the assignment will produce a
433 ; Just tell yourself over and over: overflow detection is expensive,
434 ; and you're glad C doesn't do it, because it never happens in real
437 (df f-dsp-8-u16 "16 bit unsigned" (all-isas) 8 16 UINT
439 (and (srl value 8) #xff)
440 (sll (and value #xff) 8))) ; insert
442 (and UHI (srl UHI value 8) #xff)
443 (sll UHI (and UHI value #xff) 8))) ; extract
446 (df f-dsp-8-s16 "8 bit signed" (all-isas) 8 16 INT
449 (or (and (srl value 8) #xff)
450 (sll (and value #xff) 8))))) ; insert
453 (or (and (srl value 8) #xff)
454 (sll (and value #xff) 8))))) ; extract
457 (df f-dsp-16-u16 "16 bit unsigned" (all-isas) 16 16 UINT
459 (and (srl value 8) #xff)
460 (sll (and value #xff) 8))) ; insert
462 (and UHI (srl UHI value 8) #xff)
463 (sll UHI (and UHI value #xff) 8))) ; extract
466 (df f-dsp-16-s16 "16 bit signed" (all-isas) 16 16 INT
469 (or (and (srl value 8) #xff)
470 (sll (and value #xff) 8))))) ; insert
473 (or (and (srl value 8) #xff)
474 (sll (and value #xff) 8))))) ; extract
477 (dnmf f-dsp-24-u16 "16 bit unsigned" (all-isas) UINT
478 (f-dsp-24-u8 f-dsp-32-u8)
479 (sequence () ; insert
480 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u16) #xff))
481 (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-24-u16) 8) #xff))
483 (sequence () ; extract
484 (set (ifield f-dsp-24-u16) (or (sll (ifield f-dsp-32-u8) 8)
485 (ifield f-dsp-24-u8)))
489 (dnmf f-dsp-24-s16 "16 bit signed" (all-isas) INT
490 (f-dsp-24-u8 f-dsp-32-u8)
491 (sequence () ; insert
492 (set (ifield f-dsp-24-u8)
493 (and (ifield f-dsp-24-s16) #xff))
494 (set (ifield f-dsp-32-u8)
495 (and (srl (ifield f-dsp-24-s16) 8) #xff))
497 (sequence () ; extract
498 (set (ifield f-dsp-24-s16)
500 (trunc HI (or (sll (ifield f-dsp-32-u8) 8)
501 (ifield f-dsp-24-u8)))))
505 (df f-dsp-32-u16 "16 bit unsigned" (all-isas) 32 16 UINT
507 (and (srl value 8) #xff)
508 (sll (and value #xff) 8))) ; insert
510 (and UHI (srl UHI value 8) #xff)
511 (sll UHI (and UHI value #xff) 8))) ; extract
514 (df f-dsp-32-s16 "16 bit signed" (all-isas) 32 16 INT
517 (or (and (srl value 8) #xff)
518 (sll (and value #xff) 8))))) ; insert
521 (or (and (srl value 8) #xff)
522 (sll (and value #xff) 8))))) ; extract
525 (df f-dsp-40-u16 "16 bit unsigned" (all-isas) 40 16 UINT
527 (and (srl value 8) #xff)
528 (sll (and value #xff) 8))) ; insert
530 (and UHI (srl UHI value 8) #xff)
531 (sll UHI (and UHI value #xff) 8))) ; extract
534 (df f-dsp-40-s16 "16 bit signed" (all-isas) 40 16 INT
537 (or (and (srl value 8) #xff)
538 (sll (and value #xff) 8))))) ; insert
541 (or (and (srl value 8) #xff)
542 (sll (and value #xff) 8))))) ; extract
545 (df f-dsp-48-u16 "16 bit unsigned" (all-isas) 48 16 UINT
547 (and (srl value 8) #xff)
548 (sll (and value #xff) 8))) ; insert
550 (and UHI (srl UHI value 8) #xff)
551 (sll UHI (and UHI value #xff) 8))) ; extract
554 (df f-dsp-48-s16 "16 bit signed" (all-isas) 48 16 INT
557 (or (and (srl value 8) #xff)
558 (sll (and value #xff) 8))))) ; insert
561 (or (and (srl value 8) #xff)
562 (sll (and value #xff) 8))))) ; extract
565 (df f-dsp-64-u16 "16 bit unsigned" (all-isas) 64 16 UINT
567 (and (srl value 8) #xff)
568 (sll (and value #xff) 8))) ; insert
570 (and UHI (srl UHI value 8) #xff)
571 (sll UHI (and UHI value #xff) 8))) ; extract
573 (df f-dsp-8-s24 "24 bit signed" (all-isas) 8 24 INT
574 ((value pc) (sub SI (xor (or SI (or (and (srl value 16) #xff)
576 (sll (and value #xff) 16))
578 ((value pc) (sub SI (xor (or SI
579 (or (and (srl value 16) #xff)
581 (sll (and value #xff) 16))
585 (df f-dsp-8-u24 "24 bit unsigned" (all-isas) 8 24 UINT
587 (or (srl value 16) (and value #xff00))
588 (sll (and value #xff) 16)))
590 (or (srl value 16) (and value #xff00))
591 (sll (and value #xff) 16)))
594 (dnmf f-dsp-16-u24 "24 bit unsigned" (all-isas) UINT
595 (f-dsp-16-u16 f-dsp-32-u8)
596 (sequence () ; insert
597 (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-u24) #xffff))
598 (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-16-u24) 16) #xff))
600 (sequence () ; extract
601 (set (ifield f-dsp-16-u24) (or (sll (ifield f-dsp-32-u8) 16)
602 (ifield f-dsp-16-u16)))
606 (dnmf f-dsp-24-u24 "24 bit unsigned" (all-isas) UINT
607 (f-dsp-24-u8 f-dsp-32-u16)
608 (sequence () ; insert
609 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u24) #xff))
610 (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-24-u24) 8) #xffff))
612 (sequence () ; extract
613 (set (ifield f-dsp-24-u24) (or (sll (ifield f-dsp-32-u16) 8)
614 (ifield f-dsp-24-u8)))
618 (df f-dsp-32-u24 "24 bit unsigned" (all-isas) 32 24 UINT
621 (and (srl value 16) #x0000ff)
622 (and value #x00ff00))
623 (and (sll value 16) #xff0000))) ; insert
626 (and USI (srl value 16) #x0000ff)
627 (and USI value #x00ff00))
628 (and USI (sll value 16) #xff0000))) ; extract
631 (df f-dsp-40-u20 "20 bit unsigned" (all-isas) 40 20 UINT
634 (and (srl value 16) #x0000ff)
635 (and value #x00ff00))
636 (and (sll value 16) #x0f0000))) ; insert
639 (and USI (srl value 16) #x0000ff)
640 (and USI value #x00ff00))
641 (and USI (sll value 16) #x0f0000))) ; extract
644 (df f-dsp-40-u24 "24 bit unsigned" (all-isas) 40 24 UINT
647 (and (srl value 16) #x0000ff)
648 (and value #x00ff00))
649 (and (sll value 16) #xff0000))) ; insert
652 (and USI (srl value 16) #x0000ff)
653 (and USI value #x00ff00))
654 (and USI (sll value 16) #xff0000))) ; extract
657 (dnmf f-dsp-40-s32 "32 bit signed" (all-isas) INT
658 (f-dsp-40-u24 f-dsp-64-u8)
659 (sequence () ; insert
660 (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-40-s32) 24) #xff))
661 (set (ifield f-dsp-40-u24) (and (ifield f-dsp-40-s32) #xffffff))
663 (sequence () ; extract
664 (set (ifield f-dsp-40-s32) (or (and (ifield f-dsp-40-u24) #xffffff)
665 (and (sll (ifield f-dsp-64-u8) 24) #xff000000)))
669 (dnmf f-dsp-48-u20 "20 bit unsigned" (all-isas) UINT
670 (f-dsp-48-u16 f-dsp-64-u8)
671 (sequence () ; insert
672 (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-48-u20) 16) #x0f))
673 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u20) #xffff))
675 (sequence () ; extract
676 (set (ifield f-dsp-48-u20) (or (and (ifield f-dsp-48-u16) #xffff)
677 (and (sll (ifield f-dsp-64-u8) 16) #x0f0000)))
680 (dnmf f-dsp-48-u24 "24 bit unsigned" (all-isas) UINT
681 (f-dsp-48-u16 f-dsp-64-u8)
682 (sequence () ; insert
683 (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-48-u24) 16) #xff))
684 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u24) #xffff))
686 (sequence () ; extract
687 (set (ifield f-dsp-48-u24) (or (and (ifield f-dsp-48-u16) #xffff)
688 (and (sll (ifield f-dsp-64-u8) 16) #xff0000)))
692 (dnmf f-dsp-16-s32 "32 bit signed" (all-isas) INT
693 (f-dsp-16-u16 f-dsp-32-u16)
694 (sequence () ; insert
695 (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-16-s32) 16) #xffff))
696 (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-s32) #xffff))
698 (sequence () ; extract
699 (set (ifield f-dsp-16-s32) (or (and (ifield f-dsp-16-u16) #xffff)
700 (and (sll (ifield f-dsp-32-u16) 16) #xffff0000)))
704 (dnmf f-dsp-24-s32 "32 bit signed" (all-isas) INT
705 (f-dsp-24-u8 f-dsp-32-u24)
706 (sequence () ; insert
707 (set (ifield f-dsp-32-u24) (and (srl (ifield f-dsp-24-s32) 8) #xffffff))
708 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-s32) #xff))
710 (sequence () ; extract
711 (set (ifield f-dsp-24-s32) (or (and (ifield f-dsp-24-u8) #xff)
712 (and (sll (ifield f-dsp-32-u24) 8) #xffffff00)))
716 (df f-dsp-32-s32 "32 bit signed" (all-isas) 32 32 INT
723 (and (srl value 24) #x00ff)
724 (and (srl value 8) #xff00))
726 (sll (and value #xff00) 8)
727 (sll (and value #x00ff) 24)))))
734 (and (srl value 24) #x00ff)
735 (and (srl value 8) #xff00))
737 (sll (and value #xff00) 8)
738 (sll (and value #x00ff) 24)))))
741 (dnmf f-dsp-48-u32 "32 bit unsigned" (all-isas) UINT
742 (f-dsp-48-u16 f-dsp-64-u16)
743 (sequence () ; insert
744 (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-u32) 16) #xffff))
745 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u32) #xffff))
747 (sequence () ; extract
748 (set (ifield f-dsp-48-u32) (or (and (ifield f-dsp-48-u16) #xffff)
749 (sll (and (ifield f-dsp-64-u16) #xffff) 16)))
753 (dnmf f-dsp-48-s32 "32 bit signed" (all-isas) INT
754 (f-dsp-48-u16 f-dsp-64-u16)
755 (sequence () ; insert
756 (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-s32) 16) #xffff))
757 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-s32) #xffff))
759 (sequence () ; extract
760 (set (ifield f-dsp-48-s32) (or (and (ifield f-dsp-48-u16) #xffff)
761 (sll (and (ifield f-dsp-64-u16) #xffff) 16)))
765 (dnmf f-dsp-56-s16 "16 bit signed" (all-isas) INT
766 (f-dsp-56-u8 f-dsp-64-u8)
767 (sequence () ; insert
768 (set (ifield f-dsp-56-u8)
769 (and (ifield f-dsp-56-s16) #xff))
770 (set (ifield f-dsp-64-u8)
771 (and (srl (ifield f-dsp-56-s16) 8) #xff))
773 (sequence () ; extract
774 (set (ifield f-dsp-56-s16)
776 (trunc HI (or (sll (ifield f-dsp-64-u8) 8)
777 (ifield f-dsp-56-u8)))))
781 (df f-dsp-64-s16 " 16 bit signed" (all-isas) 64 16 INT
784 (or (and (srl value 8) #xff)
785 (sll (and value #xff) 8))))) ; insert
788 (or (and (srl value 8) #xff)
789 (sll (and value #xff) 8))))) ; extract
792 ;-------------------------------------------------------------
794 ;-------------------------------------------------------------
796 (dnf f-bitno16-S "bit index for m16c" (all-isas) 5 3)
797 (dnf f-bitno32-prefixed "bit index for m32c" (all-isas) 21 3)
798 (dnf f-bitno32-unprefixed "bit index for m32c" (all-isas) 13 3)
800 (dnmf f-bitbase16-u11-S "unsigned bit,base:11" (all-isas) UINT
801 (f-bitno16-S f-dsp-8-u8)
802 (sequence () ; insert
803 (set (ifield f-bitno16-S) (and f-bitbase16-u11-S #x7))
804 (set (ifield f-dsp-8-u8) (and (srl (ifield f-bitbase16-u11-S) 3) #xff))
806 (sequence () ; extract
807 (set (ifield f-bitbase16-u11-S) (or (sll (ifield f-dsp-8-u8) 3)
808 (ifield f-bitno16-S)))
812 (dnmf f-bitbase32-16-u11-unprefixed "unsigned bit,base:11" (all-isas) UINT
813 (f-bitno32-unprefixed f-dsp-16-u8)
814 (sequence () ; insert
815 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u11-unprefixed #x7))
816 (set (ifield f-dsp-16-u8) (and (srl (ifield f-bitbase32-16-u11-unprefixed) 3) #xff))
818 (sequence () ; extract
819 (set (ifield f-bitbase32-16-u11-unprefixed) (or (sll (ifield f-dsp-16-u8) 3)
820 (ifield f-bitno32-unprefixed)))
823 (dnmf f-bitbase32-16-s11-unprefixed "signed bit,base:11" (all-isas) INT
824 (f-bitno32-unprefixed f-dsp-16-s8)
825 (sequence () ; insert
826 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s11-unprefixed #x7))
827 (set (ifield f-dsp-16-s8) (sra INT (ifield f-bitbase32-16-s11-unprefixed) 3))
829 (sequence () ; extract
830 (set (ifield f-bitbase32-16-s11-unprefixed) (or (mul (ifield f-dsp-16-s8) 8)
831 (ifield f-bitno32-unprefixed)))
834 (dnmf f-bitbase32-16-u19-unprefixed "unsigned bit,base:19" (all-isas) UINT
835 (f-bitno32-unprefixed f-dsp-16-u16)
836 (sequence () ; insert
837 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u19-unprefixed #x7))
838 (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u19-unprefixed) 3) #xffff))
840 (sequence () ; extract
841 (set (ifield f-bitbase32-16-u19-unprefixed) (or (sll (ifield f-dsp-16-u16) 3)
842 (ifield f-bitno32-unprefixed)))
845 (dnmf f-bitbase32-16-s19-unprefixed "signed bit,base:11" (all-isas) INT
846 (f-bitno32-unprefixed f-dsp-16-s16)
847 (sequence () ; insert
848 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s19-unprefixed #x7))
849 (set (ifield f-dsp-16-s16) (sra INT (ifield f-bitbase32-16-s19-unprefixed) 3))
851 (sequence () ; extract
852 (set (ifield f-bitbase32-16-s19-unprefixed) (or (mul (ifield f-dsp-16-s16) 8)
853 (ifield f-bitno32-unprefixed)))
856 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
857 (dnmf f-bitbase32-16-u27-unprefixed "unsigned bit,base:27" (all-isas) UINT
858 (f-bitno32-unprefixed f-dsp-16-u16 f-dsp-32-u8)
859 (sequence () ; insert
860 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u27-unprefixed #x7))
861 (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 3) #xffff))
862 (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 19) #xff))
864 (sequence () ; extract
865 (set (ifield f-bitbase32-16-u27-unprefixed) (or (sll (ifield f-dsp-16-u16) 3)
866 (or (sll (ifield f-dsp-32-u8) 19)
867 (ifield f-bitno32-unprefixed))))
870 (dnmf f-bitbase32-24-u11-prefixed "unsigned bit,base:11" (all-isas) UINT
871 (f-bitno32-prefixed f-dsp-24-u8)
872 (sequence () ; insert
873 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u11-prefixed #x7))
874 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u11-prefixed) 3) #xff))
876 (sequence () ; extract
877 (set (ifield f-bitbase32-24-u11-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
878 (ifield f-bitno32-prefixed)))
881 (dnmf f-bitbase32-24-s11-prefixed "signed bit,base:11" (all-isas) INT
882 (f-bitno32-prefixed f-dsp-24-s8)
883 (sequence () ; insert
884 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s11-prefixed #x7))
885 (set (ifield f-dsp-24-s8) (sra INT (ifield f-bitbase32-24-s11-prefixed) 3))
887 (sequence () ; extract
888 (set (ifield f-bitbase32-24-s11-prefixed) (or (mul (ifield f-dsp-24-s8) 8)
889 (ifield f-bitno32-prefixed)))
892 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
893 (dnmf f-bitbase32-24-u19-prefixed "unsigned bit,base:19" (all-isas) UINT
894 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u8)
895 (sequence () ; insert
896 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u19-prefixed #x7))
897 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 3) #xff))
898 (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 11) #xff))
900 (sequence () ; extract
901 (set (ifield f-bitbase32-24-u19-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
902 (or (sll (ifield f-dsp-32-u8) 11)
903 (ifield f-bitno32-prefixed))))
906 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
907 (dnmf f-bitbase32-24-s19-prefixed "signed bit,base:11" (all-isas) INT
908 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-s8)
909 (sequence () ; insert
910 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s19-prefixed #x7))
911 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-s19-prefixed) 3) #xff))
912 (set (ifield f-dsp-32-s8) (sra INT (ifield f-bitbase32-24-s19-prefixed) 11))
914 (sequence () ; extract
915 (set (ifield f-bitbase32-24-s19-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
916 (or (mul (ifield f-dsp-32-s8) 2048)
917 (ifield f-bitno32-prefixed))))
920 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
921 (dnmf f-bitbase32-24-u27-prefixed "unsigned bit,base:27" (all-isas) UINT
922 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u16)
923 (sequence () ; insert
924 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u27-prefixed #x7))
925 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u27-prefixed) 3) #xff))
926 (set (ifield f-dsp-32-u16) (and (srl (ifield f-bitbase32-24-u27-prefixed) 11) #xffff))
928 (sequence () ; extract
929 (set (ifield f-bitbase32-24-u27-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
930 (or (sll (ifield f-dsp-32-u16) 11)
931 (ifield f-bitno32-prefixed))))
935 ;-------------------------------------------------------------
937 ;-------------------------------------------------------------
939 (df f-lab-5-3 "3 bit pc relative unsigned offset" (PCREL-ADDR all-isas) 5 3 UINT
940 ((value pc) (sub SI value (add SI pc 2))) ; insert
941 ((value pc) (add SI value (add SI pc 2))) ; extract
943 (dnmf f-lab32-jmp-s "unsigned 3 bit pc relative offset" (PCREL-ADDR all-isas) UINT
945 (sequence ((SI val)) ; insert
946 (set val (sub (sub (ifield f-lab32-jmp-s) pc) 2))
947 (set (ifield f-7-1) (and val #x1))
948 (set (ifield f-2-2) (srl val 1))
950 (sequence () ; extract
951 (set (ifield f-lab32-jmp-s) (add pc (add (or (sll (ifield f-2-2) 1)
956 (df f-lab-8-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 8 8 INT
957 ((value pc) (sub SI value (add SI pc 1))) ; insert
958 ((value pc) (add SI value (add SI pc 1))) ; extract
960 (df f-lab-8-16 "16 bit pc relative signed offset" (PCREL-ADDR SIGN-OPT all-isas) 8 16 UINT
961 ((value pc) (or SI (sll (and (sub value (add pc 1)) #xff) 8)
962 (srl (and (sub value (add pc 1)) #xff00) 8)))
963 ((value pc) (add SI (sub (xor (or (srl (and value #xff00) 8)
964 (sll (and value #xff) 8))
969 (df f-lab-8-24 "24 bit absolute" (all-isas ABS-ADDR) 8 24 UINT
971 (or (srl value 16) (and value #xff00))
972 (sll (and value #xff) 16)))
974 (or (srl value 16) (and value #xff00))
975 (sll (and value #xff) 16)))
977 (df f-lab-16-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 16 8 INT
978 ((value pc) (sub SI value (add SI pc 2))) ; insert
979 ((value pc) (add SI value (add SI pc 2))) ; extract
981 (df f-lab-24-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 24 8 INT
982 ((value pc) (sub SI value (add SI pc 2))) ; insert
983 ((value pc) (add SI value (add SI pc 2))) ; extract
985 (df f-lab-32-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 32 8 INT
986 ((value pc) (sub SI value (add SI pc 2))) ; insert
987 ((value pc) (add SI value (add SI pc 2))) ; extract
989 (df f-lab-40-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 40 8 INT
990 ((value pc) (sub SI value (add SI pc 2))) ; insert
991 ((value pc) (add SI value (add SI pc 2))) ; extract
994 ;-------------------------------------------------------------
996 ;-------------------------------------------------------------
998 (dnf f-cond16 "condition code" (all-isas) 12 4)
999 (dnf f-cond16j-5 "condition code" (all-isas) 5 3)
1001 (dnmf f-cond32 "condition code" (all-isas) UINT
1003 (sequence () ; insert
1004 (set (ifield f-9-1) (and (srl (ifield f-cond32) 3) 1))
1005 (set (ifield f-13-3) (and (ifield f-cond32) #x7))
1007 (sequence () ; extract
1008 (set (ifield f-cond32) (or (sll (ifield f-9-1) 3)
1013 (dnmf f-cond32j "condition code" (all-isas) UINT
1015 (sequence () ; insert
1016 (set (ifield f-1-3) (and (srl (ifield f-cond32j) 1) #x7))
1017 (set (ifield f-7-1) (and (ifield f-cond32j) #x1))
1019 (sequence () ; extract
1020 (set (ifield f-cond32j) (or (sll (ifield f-1-3) 1)
1025 ;=============================================================
1028 (dnh h-pc "program counter" (PC all-isas) (pc USI) () () ())
1030 ;-------------------------------------------------------------
1032 ; The actual registers are 16 bits
1033 ;-------------------------------------------------------------
1037 (comment "general 16 bit registers")
1038 (attrs all-isas CACHE-ADDR)
1039 (type register HI (4))
1040 (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3))))
1042 ; Define different views of the grs as VIRTUAL with getter/setter specs
1046 (comment "general 8 bit registers")
1047 (attrs all-isas VIRTUAL)
1048 (type register QI (4))
1049 (indices keyword "" (("r0l" 0) ("r0h" 1) ("r1l" 2) ("r1h" 3)))
1050 (get (index) (and (if SI (mod index 2)
1051 (srl (reg h-gr (div index 2)) 8)
1052 (reg h-gr (div index 2)))
1054 (set (index newval) (set (reg h-gr (div index 2))
1055 (if SI (mod index 2)
1056 (or (and (reg h-gr (div index 2)) #xff)
1057 (sll (and newval #xff) 8))
1058 (or (and (reg h-gr (div index 2)) #xff00)
1059 (and newval #xff))))))
1063 (comment "general 16 bit registers")
1064 (attrs all-isas VIRTUAL)
1065 (type register HI (4))
1066 (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3)))
1067 (get (index) (reg h-gr index))
1068 (set (index newval) (set (reg h-gr index) newval)))
1072 (comment "general 32 bit registers")
1073 (attrs all-isas VIRTUAL)
1074 (type register SI (2))
1075 (indices keyword "" (("r2r0" 0) ("r3r1" 1)))
1077 (and (reg h-gr index) #xffff)
1078 (sll (and (reg h-gr (add index 2)) #xffff) 16)))
1079 (set (index newval) (sequence ()
1080 (set (reg h-gr index) (and newval #xffff))
1081 (set (reg h-gr (add index 2)) (srl newval 16)))))
1085 (comment "general 16 bit registers")
1086 (attrs all-isas VIRTUAL)
1087 (type register HI (2))
1088 (indices keyword "" (("r0l" 0) ("r1l" 1)))
1089 (get (index) (reg h-gr-QI (mul index 2)))
1090 (set (index newval) (set (reg h-gr (mul index 2)) newval)))
1094 (comment "general 16 bit registers")
1095 (attrs all-isas VIRTUAL)
1096 (type register SI (2))
1097 (indices keyword "" (("r0" 0) ("r1" 1)))
1098 (get (index) (reg h-gr (mul index 2)))
1099 (set (index newval) (set (reg h-gr-SI index) newval)))
1103 (comment "r0l register")
1104 (attrs all-isas VIRTUAL)
1106 (indices keyword "" (("r0l" 0)))
1107 (get () (reg h-gr-QI 0))
1108 (set (newval) (set (reg h-gr-QI 0) newval)))
1112 (comment "r0h register")
1113 (attrs all-isas VIRTUAL)
1115 (indices keyword "" (("r0h" 0)))
1116 (get () (reg h-gr-QI 1))
1117 (set (newval) (set (reg h-gr-QI 1) newval)))
1121 (comment "r1l register")
1122 (attrs all-isas VIRTUAL)
1124 (indices keyword "" (("r1l" 0)))
1125 (get () (reg h-gr-QI 2))
1126 (set (newval) (set (reg h-gr-QI 2) newval)))
1130 (comment "r1h register")
1131 (attrs all-isas VIRTUAL)
1133 (indices keyword "" (("r1h" 0)))
1134 (get () (reg h-gr-QI 3))
1135 (set (newval) (set (reg h-gr-QI 3) newval)))
1139 (comment "r0 register")
1140 (attrs all-isas VIRTUAL)
1142 (indices keyword "" (("r0" 0)))
1143 (get () (reg h-gr 0))
1144 (set (newval) (set (reg h-gr 0) newval)))
1148 (comment "r1 register")
1149 (attrs all-isas VIRTUAL)
1151 (indices keyword "" (("r1" 0)))
1152 (get () (reg h-gr 1))
1153 (set (newval) (set (reg h-gr 1) newval)))
1157 (comment "r2 register")
1158 (attrs all-isas VIRTUAL)
1160 (indices keyword "" (("r2" 0)))
1161 (get () (reg h-gr 2))
1162 (set (newval) (set (reg h-gr 2) newval)))
1166 (comment "r3 register")
1167 (attrs all-isas VIRTUAL)
1169 (indices keyword "" (("r3" 0)))
1170 (get () (reg h-gr 3))
1171 (set (newval) (set (reg h-gr 3) newval)))
1175 (comment "r0l or r0h")
1176 (attrs all-isas VIRTUAL)
1177 (type register QI (2))
1178 (indices keyword "" (("r0l" 0) ("r0h" 1)))
1179 (get (index) (reg h-gr-QI index))
1180 (set (index newval) (set (reg h-gr-QI index) newval)))
1184 (comment "r2r0 register")
1185 (attrs all-isas VIRTUAL)
1187 (indices keyword "" (("r2r0" 0)))
1188 (get () (or (sll (reg h-gr 2) 16) (reg h-gr 0)))
1191 (set (reg h-gr 0) newval)
1192 (set (reg h-gr 2) (sra newval 16)))))
1196 (comment "r3r1 register")
1197 (attrs all-isas VIRTUAL)
1199 (indices keyword "" (("r3r1" 0)))
1200 (get () (or (sll (reg h-gr 3) 16) (reg h-gr 1)))
1203 (set (reg h-gr 1) newval)
1204 (set (reg h-gr 3) (sra newval 16)))))
1208 (comment "r1r2r0 register")
1209 (attrs all-isas VIRTUAL)
1211 (indices keyword "" (("r1r2r0" 0)))
1212 (get () (or DI (sll DI (reg h-gr 1) 32) (or (sll (reg h-gr 2) 16) (reg h-gr 0))))
1215 (set (reg h-gr 0) newval)
1216 (set (reg h-gr 2) (sra newval 16))
1217 (set (reg h-gr 1) (sra newval 32)))))
1219 ;-------------------------------------------------------------
1221 ;-------------------------------------------------------------
1225 (comment "address registers")
1227 (type register USI (2))
1228 (indices keyword "" (("a0" 0) ("a1" 1)))
1229 (get (index) (c-call USI "h_ar_get_handler" index))
1230 (set (index newval) (c-call VOID "h_ar_set_handler" index newval)))
1232 ; Define different views of the ars as VIRTUAL with getter/setter specs
1235 (comment "8 bit view of address register")
1236 (attrs all-isas VIRTUAL)
1237 (type register QI (2))
1238 (indices keyword "" (("a0" 0) ("a1" 1)))
1239 (get (index) (reg h-ar index))
1240 (set (index newval) (set (reg h-ar index) newval)))
1244 (comment "16 bit view of address register")
1245 (attrs all-isas VIRTUAL)
1246 (type register HI (2))
1247 (indices keyword "" (("a0" 0) ("a1" 1)))
1248 (get (index) (reg h-ar index))
1249 (set (index newval) (set (reg h-ar index) newval)))
1253 (comment "32 bit view of address register")
1254 (attrs all-isas VIRTUAL)
1256 (indices keyword "" (("a1a0" 0)))
1257 (get () (or SI (sll SI (ext SI (reg h-ar 1)) 16) (ext SI (reg h-ar 0))))
1258 (set (newval) (sequence ()
1259 (set (reg h-ar 0) (and newval #xffff))
1260 (set (reg h-ar 1) (and (srl newval 16) #xffff)))))
1264 (comment "16 bit view of address register")
1265 (attrs all-isas VIRTUAL)
1267 (indices keyword "" (("a0" 0)))
1268 (get () (reg h-ar 0))
1269 (set (newval) (set (reg h-ar 0) newval)))
1273 (comment "16 bit view of address register")
1274 (attrs all-isas VIRTUAL)
1276 (indices keyword "" (("a1" 1)))
1277 (get () (reg h-ar 1))
1278 (set (newval) (set (reg h-ar 1) newval)))
1283 (comment "SB register")
1286 (get () (c-call USI "h_sb_get_handler"))
1287 (set (newval) (c-call VOID "h_sb_set_handler" newval))
1293 (comment "FB register")
1296 (get () (c-call USI "h_fb_get_handler"))
1297 (set (newval) (c-call VOID "h_fb_set_handler" newval))
1303 (comment "SP register")
1306 (get () (c-call USI "h_sp_get_handler"))
1307 (set (newval) (c-call VOID "h_sp_set_handler" newval))
1310 ;-------------------------------------------------------------
1311 ; condition-code bits
1312 ;-------------------------------------------------------------
1316 (comment "sign bit")
1323 (comment "zero bit")
1330 (comment "overflow bit")
1337 (comment "carry bit")
1344 (comment "stack pointer select bit")
1351 (comment "interrupt enable bit")
1358 (comment "register bank select bit")
1365 (comment "debug bit")
1372 (comment "dma transfer count 000")
1378 (comment "dma transfer count 001")
1384 (comment "save flag 011")
1390 (comment "dma transfer count reload 100")
1396 (comment "dma transfer count reload 101")
1402 (comment "dma mode 110")
1408 (comment "dma mode 111")
1414 (comment "interrupt table 000")
1420 (comment "save pc 100")
1426 (comment "vector 101")
1432 (comment "interrupt stack ptr 111")
1438 (comment "dma mem addr 010")
1444 (comment "dma mem addr 011")
1450 (comment "dma mem addr reload 100")
1456 (comment "dma mem addr reload 101")
1462 (comment "dma sfr addr 110")
1468 (comment "dma sfr addr 111")
1473 ;-------------------------------------------------------------
1474 ; Condition code operand hardware
1475 ;-------------------------------------------------------------
1479 (comment "condition code hardware for m16c")
1480 (attrs m16c-isa MACH16)
1481 (type immediate UQI)
1483 (("geu" #x00) ("c" #x00)
1485 ("eq" #x02) ("z" #x02)
1490 ("ltu" #xf8) ("nc" #xf8)
1492 ("ne" #xfa) ("nz" #xfa)
1502 (comment "condition code hardware for m16c")
1503 (attrs m16c-isa MACH16)
1504 (type immediate UQI)
1506 (("geu" #x00) ("c" #x00)
1508 ("eq" #x02) ("z" #x02)
1510 ("ltu" #x04) ("nc" #x04)
1512 ("ne" #x06) ("nz" #x06)
1525 (comment "condition code hardware for m16c")
1526 (attrs m16c-isa MACH16)
1527 (type immediate UQI)
1540 (comment "condition code hardware for m16c")
1541 (attrs m16c-isa MACH16)
1542 (type immediate UQI)
1544 (("geu" #x00) ("c" #x00)
1546 ("eq" #x02) ("z" #x02)
1548 ("ltu" #x04) ("nc" #x04)
1550 ("ne" #x06) ("nz" #x06)
1558 (comment "condition code hardware for m32c")
1559 (attrs m32c-isa MACH32)
1560 (type immediate UQI)
1562 (("ltu" #x00) ("nc" #x00)
1564 ("ne" #x02) ("nz" #x02)
1569 ("geu" #x08) ("c" #x08)
1571 ("eq" #x0a) ("z" #x0a)
1582 (comment "control registers")
1583 (attrs m32c-isa MACH32)
1584 (type immediate UQI)
1585 (values keyword "" (("dct0" 0) ("dct1" 1) ("flg" 2) ("svf" 3) ("drc0" 4)
1586 ("drc1" 5) ("dmd0" 6) ("dmd1" 7))))
1589 (comment "control registers")
1590 (attrs m32c-isa MACH32)
1591 (type immediate UQI)
1592 (values keyword "" (("intb" 0) ("sp" 1) ("sb" 2) ("fb" 3) ("svp" 4)
1593 ("vct" 5) ("isp" 7))))
1597 (comment "control registers")
1598 (attrs m32c-isa MACH32)
1599 (type immediate UQI)
1600 (values keyword "" (("dma0" 2) ("dma1" 3) ("dra0" 4)
1601 ("dra1" 5) ("dsa0" 6) ("dsa1" 7))))
1604 (comment "control registers")
1605 (attrs m16c-isa MACH16)
1606 (type immediate UQI)
1607 (values keyword "" (("intbl" 1) ("intbh" 2) ("flg" 3) ("isp" 4)
1608 ("sp" 5) ("sb" 6) ("fb" 7))))
1612 (comment "flag hardware for m32c")
1614 (type immediate UQI)
1628 ;-------------------------------------------------------------
1629 ; Misc helper hardware
1630 ;-------------------------------------------------------------
1634 (comment "shift immediate")
1636 (type immediate (INT 4))
1637 (values keyword "" (("1" 0) ("2" 1) ("3" 2) ("4" 3) ("5" 4) ("6" 5) ("7" 6)
1638 ("8" 7) ("-1" -8) ("-2" -7) ("-3" -6) ("-4" -5) ("-5" -4)
1639 ("-6" -3) ("-7" -2) ("-8" -1)
1643 (comment "bit index for the next insn")
1644 (attrs m32c-isa MACH32)
1649 (comment "source index for the next insn")
1650 (attrs m32c-isa MACH32)
1655 (comment "destination index for the next insn")
1656 (attrs m32c-isa MACH32)
1660 (name h-src-indirect)
1661 (comment "indirect src for the next insn")
1666 (name h-dst-indirect)
1667 (comment "indirect dst for the next insn")
1673 (comment "for storing unused values")
1674 (attrs m32c-isa MACH32)
1678 ;=============================================================
1680 ;-------------------------------------------------------------
1682 ;-------------------------------------------------------------
1684 (dnop Src16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-src16-rn)
1685 (dnop Src16RnHI "general register QH view" (MACH16 m16c-isa) h-gr-HI f-src16-rn)
1687 (dnop Src32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-unprefixed-QI)
1688 (dnop Src32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-unprefixed-HI)
1689 (dnop Src32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-unprefixed-SI)
1691 (dnop Src32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-prefixed-QI)
1692 (dnop Src32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-prefixed-HI)
1693 (dnop Src32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-prefixed-SI)
1695 (dnop Src16An "address register" (MACH16 m16c-isa) h-ar f-src16-an)
1696 (dnop Src16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-src16-an)
1697 (dnop Src16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-src16-an)
1699 (dnop Src32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed)
1700 (dnop Src32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-unprefixed)
1701 (dnop Src32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-unprefixed)
1702 (dnop Src32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed)
1704 (dnop Src32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-prefixed)
1705 (dnop Src32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-prefixed)
1706 (dnop Src32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-prefixed)
1707 (dnop Src32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-prefixed)
1709 ; Destination Registers
1711 (dnop Dst16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-dst16-rn)
1712 (dnop Dst16RnHI "general register HI view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn)
1713 (dnop Dst16RnSI "general register SI view" (MACH16 m16c-isa) h-gr-SI f-dst16-rn)
1714 (dnop Dst16RnExtQI "general register QI/HI view for 'ext' insns" (MACH16 m16c-isa) h-gr-ext-QI f-dst16-rn-ext)
1716 (dnop Dst32R0QI-S "general register QI view" (MACH32 m32c-isa) h-r0l f-nil)
1717 (dnop Dst32R0HI-S "general register HI view" (MACH32 m32c-isa) h-r0 f-nil)
1719 (dnop Dst32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI)
1720 (dnop Dst32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-unprefixed-HI)
1721 (dnop Dst32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-unprefixed-SI)
1722 (dnop Dst32RnExtUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-ext-QI f-dst32-rn-ext-unprefixed)
1723 (dnop Dst32RnExtUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-ext-HI f-dst32-rn-ext-unprefixed)
1725 (dnop Dst32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI)
1726 (dnop Dst32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-prefixed-HI)
1727 (dnop Dst32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-prefixed-SI)
1729 (dnop Dst16RnQI-S "general register QI view" (MACH16 m16c-isa) h-r0l-r0h f-dst16-rn-QI-s)
1731 (dnop Dst16AnQI-S "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-rn-QI-s)
1733 (dnop Bit16Rn "general register bit view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn)
1735 (dnop Bit32RnPrefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI)
1736 (dnop Bit32RnUnprefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI)
1738 (dnop R0 "r0" (all-isas) h-r0 f-nil)
1739 (dnop R1 "r1" (all-isas) h-r1 f-nil)
1740 (dnop R2 "r2" (all-isas) h-r2 f-nil)
1741 (dnop R3 "r3" (all-isas) h-r3 f-nil)
1742 (dnop R0l "r0l" (all-isas) h-r0l f-nil)
1743 (dnop R0h "r0h" (all-isas) h-r0h f-nil)
1744 (dnop R2R0 "r2r0" (all-isas) h-r2r0 f-nil)
1745 (dnop R3R1 "r3r1" (all-isas) h-r3r1 f-nil)
1746 (dnop R1R2R0 "r1r2r0" (all-isas) h-r1r2r0 f-nil)
1748 (dnop Dst16An "address register" (MACH16 m16c-isa) h-ar f-dst16-an)
1749 (dnop Dst16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-an)
1750 (dnop Dst16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an)
1751 (dnop Dst16AnSI "address register SI view" (MACH16 m16c-isa) h-ar-SI f-dst16-an)
1752 (dnop Dst16An-S "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an-s)
1754 (dnop Dst32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1755 (dnop Dst32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-unprefixed)
1756 (dnop Dst32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-unprefixed)
1757 (dnop Dst32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1759 (dnop Dst32AnExtUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1761 (dnop Dst32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1762 (dnop Dst32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-prefixed)
1763 (dnop Dst32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-prefixed)
1764 (dnop Dst32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1766 (dnop Bit16An "address register bit view" (MACH16 m16c-isa) h-ar f-dst16-an)
1768 (dnop Bit32AnPrefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1769 (dnop Bit32AnUnprefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1771 (dnop A0 "a0" (all-isas) h-a0 f-nil)
1772 (dnop A1 "a1" (all-isas) h-a1 f-nil)
1774 (dnop sb "SB register" (all-isas SEM-ONLY) h-sb f-nil)
1775 (dnop fb "FB register" (all-isas SEM-ONLY) h-fb f-nil)
1776 (dnop sp "SP register" (all-isas SEM-ONLY) h-sp f-nil)
1778 (define-full-operand SrcDst16-r0l-r0h-S-normal "r0l/r0h pair" (MACH16 m16c-isa)
1780 ((parse "r0l_r0h") (print "r0l_r0h")) () ()
1783 (define-full-operand Regsetpop "popm regset" (all-isas) h-uint
1784 DFLT f-8-8 ((parse "pop_regset") (print "pop_regset")) () ())
1785 (define-full-operand Regsetpush "pushm regset" (all-isas) h-uint
1786 DFLT f-8-8 ((parse "push_regset") (print "push_regset")) () ())
1788 (dnop Rn16-push-S "r0[lh]" (MACH16 m16c-isa) h-gr-QI f-4-1)
1789 (dnop An16-push-S "a[01]" (MACH16 m16c-isa) h-ar-HI f-4-1)
1791 ;-------------------------------------------------------------
1792 ; Offsets and absolutes
1793 ;-------------------------------------------------------------
1795 (define-full-operand Dsp-8-u6 "unsigned 6 bit displacement at offset 8 bits" (all-isas)
1796 h-uint DFLT f-dsp-8-u6
1797 ((parse "unsigned6")) () ()
1799 (define-full-operand Dsp-8-u8 "unsigned 8 bit displacement at offset 8 bits" (all-isas)
1800 h-uint DFLT f-dsp-8-u8
1801 ((parse "unsigned8")) () ()
1803 (define-full-operand Dsp-8-u16 "unsigned 16 bit displacement at offset 8 bits" (all-isas)
1804 h-uint DFLT f-dsp-8-u16
1805 ((parse "unsigned16")) () ()
1807 (define-full-operand Dsp-8-s8 "signed 8 bit displacement at offset 8 bits" (all-isas)
1808 h-sint DFLT f-dsp-8-s8
1809 ((parse "signed8")) () ()
1811 (define-full-operand Dsp-8-s24 "signed 24 bit displacement at offset 8 bits" (all-isas)
1812 h-sint DFLT f-dsp-8-s24
1813 ((parse "signed24")) () ()
1815 (define-full-operand Dsp-8-u24 "unsigned 24 bit displacement at offset 8 bits" (all-isas)
1816 h-uint DFLT f-dsp-8-u24
1817 ((parse "unsigned24")) () ()
1819 (define-full-operand Dsp-10-u6 "unsigned 6 bit displacement at offset 10 bits" (all-isas)
1820 h-uint DFLT f-dsp-10-u6
1821 ((parse "unsigned6")) () ()
1823 (define-full-operand Dsp-16-u8 "unsigned 8 bit displacement at offset 16 bits" (all-isas)
1824 h-uint DFLT f-dsp-16-u8
1825 ((parse "unsigned8")) () ()
1827 (define-full-operand Dsp-16-u16 "unsigned 16 bit displacement at offset 16 bits" (all-isas)
1828 h-uint DFLT f-dsp-16-u16
1829 ((parse "unsigned16")) () ()
1831 (define-full-operand Dsp-16-u20 "unsigned 20 bit displacement at offset 16 bits" (all-isas)
1832 h-uint DFLT f-dsp-16-u24
1833 ((parse "unsigned20")) () ()
1835 (define-full-operand Dsp-16-u24 "unsigned 24 bit displacement at offset 16 bits" (all-isas)
1836 h-uint DFLT f-dsp-16-u24
1837 ((parse "unsigned24")) () ()
1839 (define-full-operand Dsp-16-s8 "signed 8 bit displacement at offset 16 bits" (all-isas)
1840 h-sint DFLT f-dsp-16-s8
1841 ((parse "signed8")) () ()
1843 (define-full-operand Dsp-16-s16 "signed 16 bit displacement at offset 16 bits" (all-isas)
1844 h-sint DFLT f-dsp-16-s16
1845 ((parse "signed16")) () ()
1847 (define-full-operand Dsp-24-u8 "unsigned 8 bit displacement at offset 24 bits" (all-isas)
1848 h-uint DFLT f-dsp-24-u8
1849 ((parse "unsigned8")) () ()
1851 (define-full-operand Dsp-24-u16 "unsigned 16 bit displacement at offset 24 bits" (all-isas)
1852 h-uint DFLT f-dsp-24-u16
1853 ((parse "unsigned16")) () ()
1855 (define-full-operand Dsp-24-u20 "unsigned 20 bit displacement at offset 24 bits" (all-isas)
1856 h-uint DFLT f-dsp-24-u24
1857 ((parse "unsigned20")) () ()
1859 (define-full-operand Dsp-24-u24 "unsigned 24 bit displacement at offset 24 bits" (all-isas)
1860 h-uint DFLT f-dsp-24-u24
1861 ((parse "unsigned24")) () ()
1863 (define-full-operand Dsp-24-s8 "signed 8 bit displacement at offset 24 bits" (all-isas)
1864 h-sint DFLT f-dsp-24-s8
1865 ((parse "signed8")) () ()
1867 (define-full-operand Dsp-24-s16 "signed 16 bit displacement at offset 24 bits" (all-isas)
1868 h-sint DFLT f-dsp-24-s16
1869 ((parse "signed16")) () ()
1871 (define-full-operand Dsp-32-u8 "unsigned 8 bit displacement at offset 32 bits" (all-isas)
1872 h-uint DFLT f-dsp-32-u8
1873 ((parse "unsigned8")) () ()
1875 (define-full-operand Dsp-32-u16 "unsigned 16 bit displacement at offset 32 bits" (all-isas)
1876 h-uint DFLT f-dsp-32-u16
1877 ((parse "unsigned16")) () ()
1879 (define-full-operand Dsp-32-u24 "unsigned 24 bit displacement at offset 32 bits" (all-isas)
1880 h-uint DFLT f-dsp-32-u24
1881 ((parse "unsigned24")) () ()
1883 (define-full-operand Dsp-32-u20 "unsigned 20 bit displacement at offset 32 bits" (all-isas)
1884 h-uint DFLT f-dsp-32-u24
1885 ((parse "unsigned20")) () ()
1887 (define-full-operand Dsp-32-s8 "signed 8 bit displacement at offset 32 bits" (all-isas)
1888 h-sint DFLT f-dsp-32-s8
1889 ((parse "signed8")) () ()
1891 (define-full-operand Dsp-32-s16 "signed 16 bit displacement at offset 32 bits" (all-isas)
1892 h-sint DFLT f-dsp-32-s16
1893 ((parse "signed16")) () ()
1895 (define-full-operand Dsp-40-u8 "unsigned 8 bit displacement at offset 40 bits" (all-isas)
1896 h-uint DFLT f-dsp-40-u8
1897 ((parse "unsigned8")) () ()
1899 (define-full-operand Dsp-40-s8 "signed 8 bit displacement at offset 40 bits" (all-isas)
1900 h-sint DFLT f-dsp-40-s8
1901 ((parse "signed8")) () ()
1903 (define-full-operand Dsp-40-u16 "unsigned 16 bit displacement at offset 40 bits" (all-isas)
1904 h-uint DFLT f-dsp-40-u16
1905 ((parse "unsigned16")) () ()
1907 (define-full-operand Dsp-40-s16 "signed 16 bit displacement at offset 40 bits" (all-isas)
1908 h-sint DFLT f-dsp-40-s16
1909 ((parse "signed16")) () ()
1911 (define-full-operand Dsp-40-u20 "unsigned 20 bit displacement at offset 40 bits" (all-isas)
1912 h-uint DFLT f-dsp-40-u20
1913 ((parse "unsigned20")) () ()
1915 (define-full-operand Dsp-40-u24 "unsigned 24 bit displacement at offset 40 bits" (all-isas)
1916 h-uint DFLT f-dsp-40-u24
1917 ((parse "unsigned24")) () ()
1919 (define-full-operand Dsp-48-u8 "unsigned 8 bit displacement at offset 48 bits" (all-isas)
1920 h-uint DFLT f-dsp-48-u8
1921 ((parse "unsigned8")) () ()
1923 (define-full-operand Dsp-48-s8 "signed 8 bit displacement at offset 48 bits" (all-isas)
1924 h-sint DFLT f-dsp-48-s8
1925 ((parse "signed8")) () ()
1927 (define-full-operand Dsp-48-u16 "unsigned 16 bit displacement at offset 48 bits" (all-isas)
1928 h-uint DFLT f-dsp-48-u16
1929 ((parse "unsigned16")) () ()
1931 (define-full-operand Dsp-48-s16 "signed 16 bit displacement at offset 48 bits" (all-isas)
1932 h-sint DFLT f-dsp-48-s16
1933 ((parse "signed16")) () ()
1935 (define-full-operand Dsp-48-u20 "unsigned 24 bit displacement at offset 40 bits" (all-isas)
1936 h-uint DFLT f-dsp-48-u20
1937 ((parse "unsigned24")) () ()
1939 (define-full-operand Dsp-48-u24 "unsigned 24 bit displacement at offset 48 bits" (all-isas)
1940 h-uint DFLT f-dsp-48-u24
1941 ((parse "unsigned24")) () ()
1944 (define-full-operand Imm-8-s4 "signed 4 bit immediate at offset 8 bits" (all-isas)
1945 h-sint DFLT f-imm-8-s4
1946 ((parse "signed4")) () ()
1948 (define-full-operand Imm-8-s4n "negated 4 bit immediate at offset 8 bits" (all-isas)
1949 h-sint DFLT f-imm-8-s4
1950 ((parse "signed4n") (print "signed4n")) () ()
1952 (define-full-operand Imm-sh-8-s4 "signed 4 bit shift immediate at offset 8 bits" (all-isas)
1953 h-shimm DFLT f-imm-8-s4
1956 (define-full-operand Imm-8-QI "signed 8 bit immediate at offset 8 bits" (all-isas)
1957 h-sint DFLT f-dsp-8-s8
1958 ((parse "signed8")) () ()
1960 (define-full-operand Imm-8-HI "signed 16 bit immediate at offset 8 bits" (all-isas)
1961 h-sint DFLT f-dsp-8-s16
1962 ((parse "signed16")) () ()
1964 (define-full-operand Imm-12-s4 "signed 4 bit immediate at offset 12 bits" (all-isas)
1965 h-sint DFLT f-imm-12-s4
1966 ((parse "signed4")) () ()
1968 (define-full-operand Imm-12-s4n "negated 4 bit immediate at offset 12 bits" (all-isas)
1969 h-sint DFLT f-imm-12-s4
1970 ((parse "signed4n") (print "signed4n")) () ()
1972 (define-full-operand Imm-sh-12-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas)
1973 h-shimm DFLT f-imm-12-s4
1976 (define-full-operand Imm-13-u3 "signed 3 bit immediate at offset 13 bits" (all-isas)
1977 h-sint DFLT f-imm-13-u3
1978 ((parse "signed4")) () ()
1980 (define-full-operand Imm-20-s4 "signed 4 bit immediate at offset 20 bits" (all-isas)
1981 h-sint DFLT f-imm-20-s4
1982 ((parse "signed4")) () ()
1984 (define-full-operand Imm-sh-20-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas)
1985 h-shimm DFLT f-imm-20-s4
1988 (define-full-operand Imm-16-QI "signed 8 bit immediate at offset 16 bits" (all-isas)
1989 h-sint DFLT f-dsp-16-s8
1990 ((parse "signed8")) () ()
1992 (define-full-operand Imm-16-HI "signed 16 bit immediate at offset 16 bits" (all-isas)
1993 h-sint DFLT f-dsp-16-s16
1994 ((parse "signed16")) () ()
1996 (define-full-operand Imm-16-SI "signed 32 bit immediate at offset 16 bits" (all-isas)
1997 h-sint DFLT f-dsp-16-s32
1998 ((parse "signed32")) () ()
2000 (define-full-operand Imm-24-QI "signed 8 bit immediate at offset 24 bits" (all-isas)
2001 h-sint DFLT f-dsp-24-s8
2002 ((parse "signed8")) () ()
2004 (define-full-operand Imm-24-HI "signed 16 bit immediate at offset 24 bits" (all-isas)
2005 h-sint DFLT f-dsp-24-s16
2006 ((parse "signed16")) () ()
2008 (define-full-operand Imm-24-SI "signed 32 bit immediate at offset 24 bits" (all-isas)
2009 h-sint DFLT f-dsp-24-s32
2010 ((parse "signed32")) () ()
2012 (define-full-operand Imm-32-QI "signed 8 bit immediate at offset 32 bits" (all-isas)
2013 h-sint DFLT f-dsp-32-s8
2014 ((parse "signed8")) () ()
2016 (define-full-operand Imm-32-SI "signed 32 bit immediate at offset 32 bits" (all-isas)
2017 h-sint DFLT f-dsp-32-s32
2018 ((parse "signed32")) () ()
2020 (define-full-operand Imm-32-HI "signed 16 bit immediate at offset 32 bits" (all-isas)
2021 h-sint DFLT f-dsp-32-s16
2022 ((parse "signed16")) () ()
2024 (define-full-operand Imm-40-QI "signed 8 bit immediate at offset 40 bits" (all-isas)
2025 h-sint DFLT f-dsp-40-s8
2026 ((parse "signed8")) () ()
2028 (define-full-operand Imm-40-HI "signed 16 bit immediate at offset 40 bits" (all-isas)
2029 h-sint DFLT f-dsp-40-s16
2030 ((parse "signed16")) () ()
2032 (define-full-operand Imm-40-SI "signed 32 bit immediate at offset 40 bits" (all-isas)
2033 h-sint DFLT f-dsp-40-s32
2034 ((parse "signed32")) () ()
2036 (define-full-operand Imm-48-QI "signed 8 bit immediate at offset 48 bits" (all-isas)
2037 h-sint DFLT f-dsp-48-s8
2038 ((parse "signed8")) () ()
2040 (define-full-operand Imm-48-HI "signed 16 bit immediate at offset 48 bits" (all-isas)
2041 h-sint DFLT f-dsp-48-s16
2042 ((parse "signed16")) () ()
2044 (define-full-operand Imm-48-SI "signed 32 bit immediate at offset 48 bits" (all-isas)
2045 h-sint DFLT f-dsp-48-s32
2046 ((parse "signed32")) () ()
2048 (define-full-operand Imm-56-QI "signed 8 bit immediate at offset 56 bits" (all-isas)
2049 h-sint DFLT f-dsp-56-s8
2050 ((parse "signed8")) () ()
2052 (define-full-operand Imm-56-HI "signed 16 bit immediate at offset 56 bits" (all-isas)
2053 h-sint DFLT f-dsp-56-s16
2054 ((parse "signed16")) () ()
2056 (define-full-operand Imm-64-HI "signed 16 bit immediate at offset 64 bits" (all-isas)
2057 h-sint DFLT f-dsp-64-s16
2058 ((parse "signed16")) () ()
2060 (define-full-operand Imm1-S "signed 1 bit immediate for short format binary insns" (m32c-isa)
2061 h-sint DFLT f-imm1-S
2062 ((parse "imm1_S")) () ()
2064 (define-full-operand Imm3-S "signed 3 bit immediate for short format binary insns" (m32c-isa)
2065 h-sint DFLT f-imm3-S
2066 ((parse "imm3_S")) () ()
2068 (define-full-operand Bit3-S "3 bit bit number" (m32c-isa)
2069 h-sint DFLT f-imm3-S
2070 ((parse "bit3_S")) () ()
2073 ;-------------------------------------------------------------
2075 ;-------------------------------------------------------------
2077 (define-full-operand Bitno16R "bit number for indexing registers" (m16c-isa)
2078 h-uint DFLT f-dsp-16-u8
2079 ((parse "Bitno16R")) () ()
2081 (dnop Bitno32Prefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-prefixed)
2082 (dnop Bitno32Unprefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-unprefixed)
2084 (define-full-operand BitBase16-16-u8 "unsigned bit,base:8 at offset 16for m16c" (m16c-isa)
2085 h-uint DFLT f-dsp-16-u8
2086 ((parse "unsigned_bitbase8") (print "unsigned_bitbase")) () ()
2088 (define-full-operand BitBase16-16-s8 "signed bit,base:8 at offset 16for m16c" (m16c-isa)
2089 h-sint DFLT f-dsp-16-s8
2090 ((parse "signed_bitbase8") (print "signed_bitbase")) () ()
2092 (define-full-operand BitBase16-16-u16 "unsigned bit,base:16 at offset 16 for m16c" (m16c-isa)
2093 h-uint DFLT f-dsp-16-u16
2094 ((parse "unsigned_bitbase16") (print "unsigned_bitbase")) () ()
2096 (define-full-operand BitBase16-8-u11-S "signed bit,base:11 at offset 16 for m16c" (m16c-isa)
2097 h-uint DFLT f-bitbase16-u11-S
2098 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2101 (define-full-operand BitBase32-16-u11-Unprefixed "unsigned bit,base:11 at offset 16 for m32c" (m32c-isa)
2102 h-uint DFLT f-bitbase32-16-u11-unprefixed
2103 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2105 (define-full-operand BitBase32-16-s11-Unprefixed "signed bit,base:11 at offset 16 for m32c" (m32c-isa)
2106 h-sint DFLT f-bitbase32-16-s11-unprefixed
2107 ((parse "signed_bitbase11") (print "signed_bitbase")) () ()
2109 (define-full-operand BitBase32-16-u19-Unprefixed "unsigned bit,base:19 at offset 16 for m32c" (m32c-isa)
2110 h-uint DFLT f-bitbase32-16-u19-unprefixed
2111 ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () ()
2113 (define-full-operand BitBase32-16-s19-Unprefixed "signed bit,base:19 at offset 16 for m32c" (m32c-isa)
2114 h-sint DFLT f-bitbase32-16-s19-unprefixed
2115 ((parse "signed_bitbase19") (print "signed_bitbase")) () ()
2117 (define-full-operand BitBase32-16-u27-Unprefixed "unsigned bit,base:27 at offset 16 for m32c" (m32c-isa)
2118 h-uint DFLT f-bitbase32-16-u27-unprefixed
2119 ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () ()
2121 (define-full-operand BitBase32-24-u11-Prefixed "unsigned bit,base:11 at offset 24 for m32c" (m32c-isa)
2122 h-uint DFLT f-bitbase32-24-u11-prefixed
2123 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2125 (define-full-operand BitBase32-24-s11-Prefixed "signed bit,base:11 at offset 24 for m32c" (m32c-isa)
2126 h-sint DFLT f-bitbase32-24-s11-prefixed
2127 ((parse "signed_bitbase11") (print "signed_bitbase")) () ()
2129 (define-full-operand BitBase32-24-u19-Prefixed "unsigned bit,base:19 at offset 24 for m32c" (m32c-isa)
2130 h-uint DFLT f-bitbase32-24-u19-prefixed
2131 ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () ()
2133 (define-full-operand BitBase32-24-s19-Prefixed "signed bit,base:19 at offset 24 for m32c" (m32c-isa)
2134 h-sint DFLT f-bitbase32-24-s19-prefixed
2135 ((parse "signed_bitbase19") (print "signed_bitbase")) () ()
2137 (define-full-operand BitBase32-24-u27-Prefixed "unsigned bit,base:27 at offset 24 for m32c" (m32c-isa)
2138 h-uint DFLT f-bitbase32-24-u27-prefixed
2139 ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () ()
2141 ;-------------------------------------------------------------
2143 ;-------------------------------------------------------------
2145 (define-full-operand Lab-5-3 "3 bit label" (all-isas RELAX)
2146 h-iaddr DFLT f-lab-5-3
2147 ((parse "lab_5_3")) () () )
2149 (define-full-operand Lab32-jmp-s "3 bit label" (all-isas RELAX)
2150 h-iaddr DFLT f-lab32-jmp-s
2151 ((parse "lab_5_3")) () () )
2153 (dnop Lab-8-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-8-8)
2154 (dnop Lab-8-16 "16 bit label" (all-isas RELAX) h-iaddr f-lab-8-16)
2155 (dnop Lab-8-24 "24 bit label" (all-isas RELAX) h-iaddr f-lab-8-24)
2156 (dnop Lab-16-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-16-8)
2157 (dnop Lab-24-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-24-8)
2158 (dnop Lab-32-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-32-8)
2159 (dnop Lab-40-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-40-8)
2161 ;-------------------------------------------------------------
2162 ; Condition code bits
2163 ;-------------------------------------------------------------
2165 (dnop sbit "negative bit" (SEM-ONLY all-isas) h-sbit f-nil)
2166 (dnop obit "overflow bit" (SEM-ONLY all-isas) h-obit f-nil)
2167 (dnop zbit "zero bit" (SEM-ONLY all-isas) h-zbit f-nil)
2168 (dnop cbit "carry bit" (SEM-ONLY all-isas) h-cbit f-nil)
2169 (dnop ubit "stack ptr select bit" (SEM-ONLY all-isas) h-ubit f-nil)
2170 (dnop ibit "interrupt enable bit" (SEM-ONLY all-isas) h-ibit f-nil)
2171 (dnop bbit "reg bank select bit" (SEM-ONLY all-isas) h-bbit f-nil)
2172 (dnop dbit "debug bit" (SEM-ONLY all-isas) h-dbit f-nil)
2174 ;-------------------------------------------------------------
2175 ; Condition operands
2176 ;-------------------------------------------------------------
2178 (define-pmacro (cond-operand mach offset)
2179 (dnop (.sym cond mach - offset) "condition" ((.sym m mach c-isa)) (.sym h-cond mach) (.sym f-dsp- offset -u8))
2182 (cond-operand 16 16)
2183 (cond-operand 16 24)
2184 (cond-operand 16 32)
2185 (cond-operand 32 16)
2186 (cond-operand 32 24)
2187 (cond-operand 32 32)
2188 (cond-operand 32 40)
2190 (dnop cond16c "condition" (m16c-isa) h-cond16c f-cond16)
2191 (dnop cond16j "condition" (m16c-isa) h-cond16j f-cond16)
2192 (dnop cond16j5 "condition" (m16c-isa) h-cond16j-5 f-cond16j-5)
2193 (dnop cond32 "condition" (m32c-isa) h-cond32 f-cond32)
2194 (dnop cond32j "condition" (m32c-isa) h-cond32 f-cond32j)
2195 (dnop sccond32 "scCND condition" (m32c-isa) h-cond32 f-cond16)
2196 (dnop flags16 "flags" (m16c-isa) h-flags f-9-3)
2197 (dnop flags32 "flags" (m32c-isa) h-flags f-13-3)
2198 (dnop cr16 "control" (m16c-isa) h-cr-16 f-9-3)
2199 (dnop cr1-Unprefixed-32 "control" (m32c-isa) h-cr1-32 f-13-3)
2200 (dnop cr1-Prefixed-32 "control" (m32c-isa) h-cr1-32 f-21-3)
2201 (dnop cr2-32 "control" (m32c-isa) h-cr2-32 f-13-3)
2202 (dnop cr3-Unprefixed-32 "control" (m32c-isa) h-cr3-32 f-13-3)
2203 (dnop cr3-Prefixed-32 "control" (m32c-isa) h-cr3-32 f-21-3)
2205 ;-------------------------------------------------------------
2207 ;-------------------------------------------------------------
2209 (define-full-operand Z "Suffix for zero format insns" (all-isas)
2211 ((parse "Z") (print "Z")) () ()
2213 (define-full-operand S "Suffix for short format insns" (all-isas)
2215 ((parse "S") (print "S")) () ()
2217 (define-full-operand Q "Suffix for quick format insns" (all-isas)
2219 ((parse "Q") (print "Q")) () ()
2221 (define-full-operand G "Suffix for general format insns" (all-isas)
2223 ((parse "G") (print "G")) () ()
2225 (define-full-operand X "Empty suffix" (all-isas)
2227 ((parse "X") (print "X")) () ()
2229 (define-full-operand size "any size specifier" (all-isas)
2231 ((parse "size") (print "size")) () ()
2233 ;-------------------------------------------------------------
2235 ;-------------------------------------------------------------
2237 (dnop BitIndex "Bit Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-bit-index f-nil)
2238 (dnop SrcIndex "Source Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-src-index f-nil)
2239 (dnop DstIndex "Destination Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-dst-index f-nil)
2240 (dnop NoRemainder "Place holder for when the remainder is not kept" (SEM-ONLY MACH32 m32c-isa) h-none f-nil)
2242 ;=============================================================
2245 ; Memory reference macros that clip addresses appropriately. Refer to
2246 ; memory at ADDRESS in MODE, clipped appropriately for either the m16c
2248 (define-pmacro (mem16 mode address)
2249 (mem mode (and #xffff address)))
2251 (define-pmacro (mem20 mode address)
2252 (mem mode (and #xfffff address)))
2254 (define-pmacro (mem32 mode address)
2255 (mem mode (and #xffffff address)))
2257 ; Like mem16 and mem32, but takes MACH as a parameter. MACH must be
2259 (define-pmacro (mem-mach mach mode address)
2260 ((.sym mem mach) mode address))
2262 ;-------------------------------------------------------------
2264 ;-------------------------------------------------------------
2266 ;-------------------------------------------------------------
2268 (define-pmacro (src16-Rn-direct-operand xmode)
2270 (define-derived-operand
2271 (name (.sym src16-Rn-direct- xmode))
2272 (comment (.str "m16c Rn direct source " xmode))
2273 (attrs (machine 16))
2275 (args ((.sym Src16Rn xmode)))
2276 (syntax (.str "$Src16Rn" xmode))
2278 (encoding (+ (f-8-2 0) (.sym Src16Rn xmode)))
2279 (ifield-assertion (eq f-8-2 0))
2280 (getter (trunc xmode (.sym Src16Rn xmode)))
2281 (setter (set (.sym Src16Rn xmode) newval))
2285 (src16-Rn-direct-operand QI)
2286 (src16-Rn-direct-operand HI)
2288 (define-pmacro (src32-Rn-direct-operand group base xmode)
2290 (define-derived-operand
2291 (name (.sym src32-Rn-direct- group - xmode))
2292 (comment (.str "m32c Rn direct source " xmode))
2293 (attrs (machine 32))
2295 (args ((.sym Src32Rn group xmode)))
2296 (syntax (.str "$Src32Rn" group xmode))
2297 (base-ifield (.sym f- base -11))
2298 (encoding (+ ((.sym f- base -3) 4) (.sym Src32Rn group xmode)))
2299 (ifield-assertion (eq (.sym f- base -3) 4))
2300 (getter (trunc xmode (.sym Src32Rn group xmode)))
2301 (setter (set (.sym Src32Rn group xmode) newval))
2306 (src32-Rn-direct-operand Unprefixed 1 QI)
2307 (src32-Rn-direct-operand Prefixed 9 QI)
2308 (src32-Rn-direct-operand Unprefixed 1 HI)
2309 (src32-Rn-direct-operand Prefixed 9 HI)
2310 (src32-Rn-direct-operand Unprefixed 1 SI)
2311 (src32-Rn-direct-operand Prefixed 9 SI)
2313 ;-------------------------------------------------------------
2315 ;-------------------------------------------------------------
2317 (define-pmacro (src16-An-direct-operand xmode)
2319 (define-derived-operand
2320 (name (.sym src16-An-direct- xmode))
2321 (comment (.str "m16c An direct destination " xmode))
2322 (attrs (machine 16))
2324 (args ((.sym Src16An xmode)))
2325 (syntax (.str "$Src16An" xmode))
2327 (encoding (+ (f-8-2 1) (f-10-1 0) (.sym Src16An xmode)))
2328 (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 0)))
2329 (getter (trunc xmode (.sym Src16An xmode)))
2330 (setter (set (.sym Src16An xmode) newval))
2334 (src16-An-direct-operand QI)
2335 (src16-An-direct-operand HI)
2337 (define-pmacro (src32-An-direct-operand group base1 base2 xmode)
2339 (define-derived-operand
2340 (name (.sym src32-An-direct- group - xmode))
2341 (comment (.str "m32c An direct destination " xmode))
2342 (attrs (machine 32))
2344 (args ((.sym Src32An group xmode)))
2345 (syntax (.str "$Src32An" group xmode))
2346 (base-ifield (.sym f- base1 -11))
2347 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Src32An group xmode)))
2348 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
2349 (getter (trunc xmode (.sym Src32An group xmode)))
2350 (setter (set (.sym Src32An group xmode) newval))
2355 (src32-An-direct-operand Unprefixed 1 10 QI)
2356 (src32-An-direct-operand Unprefixed 1 10 HI)
2357 (src32-An-direct-operand Unprefixed 1 10 SI)
2358 (src32-An-direct-operand Prefixed 9 18 QI)
2359 (src32-An-direct-operand Prefixed 9 18 HI)
2360 (src32-An-direct-operand Prefixed 9 18 SI)
2362 ;-------------------------------------------------------------
2364 ;-------------------------------------------------------------
2366 (define-pmacro (src16-An-indirect-operand xmode)
2368 (define-derived-operand
2369 (name (.sym src16-An-indirect- xmode))
2370 (comment (.str "m16c An indirect destination " xmode))
2371 (attrs (machine 16))
2374 (syntax "[$Src16An]")
2376 (encoding (+ (f-8-2 1) (f-10-1 1) Src16An))
2377 (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 1)))
2378 (getter (mem16 xmode Src16An))
2379 (setter (set (mem16 xmode Src16An) newval))
2383 (src16-An-indirect-operand QI)
2384 (src16-An-indirect-operand HI)
2386 (define-pmacro (src32-An-indirect-operand group base1 base2 xmode)
2388 (define-derived-operand
2389 (name (.sym src32-An-indirect- group - xmode))
2390 (comment (.str "m32c An indirect destination " xmode))
2391 (attrs (machine 32))
2393 (args ((.sym Src32An group)))
2394 (syntax (.str "[$Src32An" group "]"))
2395 (base-ifield (.sym f- base1 -11))
2396 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Src32An group)))
2397 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
2398 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group)
2400 (setter (c-call DFLT (.str "operand_setter_" xmode) newval
2401 (.sym Src32An group) (const 0)))
2402 ; (getter (mem32 xmode (.sym Src32An group)))
2403 ; (setter (set (mem32 xmode (.sym Src32An group)) newval))
2408 (src32-An-indirect-operand Unprefixed 1 10 QI)
2409 (src32-An-indirect-operand Unprefixed 1 10 HI)
2410 (src32-An-indirect-operand Unprefixed 1 10 SI)
2411 (src32-An-indirect-operand Prefixed 9 18 QI)
2412 (src32-An-indirect-operand Prefixed 9 18 HI)
2413 (src32-An-indirect-operand Prefixed 9 18 SI)
2415 ;-------------------------------------------------------------
2417 ;-------------------------------------------------------------
2419 (define-pmacro (src16-relative-operand xmode)
2421 (define-derived-operand
2422 (name (.sym src16-16-8-SB-relative- xmode))
2423 (comment (.str "m16c dsp:8[sb] relative destination " xmode))
2424 (attrs (machine 16))
2427 (syntax "${Dsp-16-u8}[sb]")
2429 (encoding (+ (f-8-4 #xA) Dsp-16-u8))
2430 (ifield-assertion (eq f-8-4 #xA))
2431 (getter (mem16 xmode (add Dsp-16-u8 (reg h-sb))))
2432 (setter (set (mem16 xmode (add Dsp-16-u8 (reg h-sb))) newval))
2434 (define-derived-operand
2435 (name (.sym src16-16-16-SB-relative- xmode))
2436 (comment (.str "m16c dsp:16[sb] relative destination " xmode))
2437 (attrs (machine 16))
2440 (syntax "${Dsp-16-u16}[sb]")
2442 (encoding (+ (f-8-4 #xE) Dsp-16-u16))
2443 (ifield-assertion (eq f-8-4 #xE))
2444 (getter (mem16 xmode (add Dsp-16-u16 (reg h-sb))))
2445 (setter (set (mem16 xmode (add Dsp-16-u16 (reg h-sb))) newval))
2447 (define-derived-operand
2448 (name (.sym src16-16-8-FB-relative- xmode))
2449 (comment (.str "m16c dsp:8[fb] relative destination " xmode))
2450 (attrs (machine 16))
2453 (syntax "${Dsp-16-s8}[fb]")
2455 (encoding (+ (f-8-4 #xB) Dsp-16-s8))
2456 (ifield-assertion (eq f-8-4 #xB))
2457 (getter (mem16 xmode (add Dsp-16-s8 (reg h-fb))))
2458 (setter (set (mem16 xmode (add Dsp-16-s8 (reg h-fb))) newval))
2460 (define-derived-operand
2461 (name (.sym src16-16-8-An-relative- xmode))
2462 (comment (.str "m16c dsp:8[An] relative destination " xmode))
2463 (attrs (machine 16))
2465 (args (Src16An Dsp-16-u8))
2466 (syntax "${Dsp-16-u8}[$Src16An]")
2468 (encoding (+ (f-8-2 2) (f-10-1 0) Dsp-16-u8 Src16An))
2469 (ifield-assertion (andif (eq f-8-2 2) (eq f-10-1 0)))
2470 (getter (mem16 xmode (add Dsp-16-u8 Src16An)))
2471 (setter (set (mem16 xmode (add Dsp-16-u8 Src16An)) newval))
2473 (define-derived-operand
2474 (name (.sym src16-16-16-An-relative- xmode))
2475 (comment (.str "m16c dsp:16[An] relative destination " xmode))
2476 (attrs (machine 16))
2478 (args (Src16An Dsp-16-u16))
2479 (syntax "${Dsp-16-u16}[$Src16An]")
2481 (encoding (+ (f-8-2 3) (f-10-1 0) Dsp-16-u16 Src16An))
2482 (ifield-assertion (andif (eq f-8-2 3) (eq f-10-1 0)))
2483 (getter (mem16 xmode (add Dsp-16-u16 Src16An)))
2484 (setter (set (mem16 xmode (add Dsp-16-u16 Src16An)) newval))
2486 (define-derived-operand
2487 (name (.sym src16-16-20-An-relative- xmode))
2488 (comment (.str "m16c dsp:20[An] relative destination " xmode))
2489 (attrs (machine 16))
2491 (args (Src16An Dsp-16-u20))
2492 (syntax "${Dsp-16-u20}[$Src16An]")
2494 (encoding (+ (f-8-2 3) (f-10-1 0) Dsp-16-u20 Src16An))
2495 (ifield-assertion (andif (eq f-8-2 3) (eq f-10-1 0)))
2496 (getter (mem20 xmode (add Dsp-16-u20 Src16An)))
2497 (setter (set (mem20 xmode (add Dsp-16-u20 Src16An)) newval))
2502 (src16-relative-operand QI)
2503 (src16-relative-operand HI)
2505 (define-pmacro (src32-relative-operand offset group base1 base2 xmode)
2507 (define-derived-operand
2508 (name (.sym src32- offset -8-SB-relative- group - xmode))
2509 (comment (.str "m32c dsp:8[sb] relative destination " xmode))
2510 (attrs (machine 32))
2512 (args ((.sym Dsp- offset -u8)))
2513 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
2514 (base-ifield (.sym f- base1 -11))
2515 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8)))
2516 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
2517 (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u8)))
2518 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u8)))
2519 ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb))))
2520 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
2522 (define-derived-operand
2523 (name (.sym src32- offset -16-SB-relative- group - xmode))
2524 (comment (.str "m32c dsp:16[sb] relative destination " xmode))
2525 (attrs (machine 32))
2527 (args ((.sym Dsp- offset -u16)))
2528 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
2529 (base-ifield (.sym f- base1 -11))
2530 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16)))
2531 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
2532 (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u16)))
2533 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u16)))
2534 ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb))))
2535 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
2537 (define-derived-operand
2538 (name (.sym src32- offset -8-FB-relative- group - xmode))
2539 (comment (.str "m32c dsp:8[fb] relative destination " xmode))
2540 (attrs (machine 32))
2542 (args ((.sym Dsp- offset -s8)))
2543 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
2544 (base-ifield (.sym f- base1 -11))
2545 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8)))
2546 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
2547 (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s8)))
2548 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s8)))
2549 ; (getter (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb))))
2550 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
2552 (define-derived-operand
2553 (name (.sym src32- offset -16-FB-relative- group - xmode))
2554 (comment (.str "m32c dsp:16[fb] relative destination " xmode))
2555 (attrs (machine 32))
2557 (args ((.sym Dsp- offset -s16)))
2558 (syntax (.str "${Dsp-" offset "-s16}[fb]"))
2559 (base-ifield (.sym f- base1 -11))
2560 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16)))
2561 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
2562 (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s16)))
2563 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s16)))
2564 ; (getter (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb))))
2565 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval))
2567 (define-derived-operand
2568 (name (.sym src32- offset -8-An-relative- group - xmode))
2569 (comment (.str "m32c dsp:8[An] relative destination " xmode))
2570 (attrs (machine 32))
2572 (args ((.sym Src32An group) (.sym Dsp- offset -u8)))
2573 (syntax (.str "${Dsp-" offset "-u8}[$Src32An" group "]"))
2574 (base-ifield (.sym f- base1 -11))
2575 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Src32An group)))
2576 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
2577 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u8)))
2578 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u8)))
2579 ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group))))
2580 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group))) newval))
2582 (define-derived-operand
2583 (name (.sym src32- offset -16-An-relative- group - xmode))
2584 (comment (.str "m32c dsp:16[An] relative destination " xmode))
2585 (attrs (machine 32))
2587 (args ((.sym Src32An group) (.sym Dsp- offset -u16)))
2588 (syntax (.str "${Dsp-" offset "-u16}[$Src32An" group "]"))
2589 (base-ifield (.sym f- base1 -11))
2590 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Src32An group)))
2591 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
2592 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u16)))
2593 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u16)))
2594 ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group))))
2595 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group))) newval))
2597 (define-derived-operand
2598 (name (.sym src32- offset -24-An-relative- group - xmode))
2599 (comment (.str "m32c dsp:16[An] relative destination " xmode))
2600 (attrs (machine 32))
2602 (args ((.sym Src32An group) (.sym Dsp- offset -u24)))
2603 (syntax (.str "${Dsp-" offset "-u24}[$Src32An" group "]"))
2604 (base-ifield (.sym f- base1 -11))
2605 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Src32An group)))
2606 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
2607 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u24) ))
2608 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u24)))
2609 ; (getter (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group))))
2610 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group))) newval))
2615 (src32-relative-operand 16 Unprefixed 1 10 QI)
2616 (src32-relative-operand 16 Unprefixed 1 10 HI)
2617 (src32-relative-operand 16 Unprefixed 1 10 SI)
2618 (src32-relative-operand 24 Prefixed 9 18 QI)
2619 (src32-relative-operand 24 Prefixed 9 18 HI)
2620 (src32-relative-operand 24 Prefixed 9 18 SI)
2622 ;-------------------------------------------------------------
2624 ;-------------------------------------------------------------
2626 (define-pmacro (src16-absolute xmode)
2628 (define-derived-operand
2629 (name (.sym src16-16-16-absolute- xmode))
2630 (comment (.str "m16c absolute address " xmode))
2631 (attrs (machine 16))
2634 (syntax (.str "${Dsp-16-u16}"))
2636 (encoding (+ (f-8-4 #xF) Dsp-16-u16))
2637 (ifield-assertion (eq f-8-4 #xF))
2638 (getter (mem16 xmode Dsp-16-u16))
2639 (setter (set (mem16 xmode Dsp-16-u16) newval))
2647 (define-pmacro (src32-absolute offset group base1 base2 xmode)
2649 (define-derived-operand
2650 (name (.sym src32- offset -16-absolute- group - xmode))
2651 (comment (.str "m32c absolute address " xmode))
2652 (attrs (machine 32))
2654 (args ((.sym Dsp- offset -u16)))
2655 (syntax (.str "${Dsp-" offset "-u16}"))
2656 (base-ifield (.sym f- base1 -11))
2657 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
2658 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
2659 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u16)))
2660 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u16)))
2661 ; (getter (mem32 xmode (.sym Dsp- offset -u16)))
2662 ; (setter (set (mem32 xmode (.sym Dsp- offset -u16)) newval))
2664 (define-derived-operand
2665 (name (.sym src32- offset -24-absolute- group - xmode))
2666 (comment (.str "m32c absolute address " xmode))
2667 (attrs (machine 32))
2669 (args ((.sym Dsp- offset -u24)))
2670 (syntax (.str "${Dsp-" offset "-u24}"))
2671 (base-ifield (.sym f- base1 -11))
2672 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
2673 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
2674 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u24)))
2675 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u24)))
2676 ; (getter (mem32 xmode (.sym Dsp- offset -u24)))
2677 ; (setter (set (mem32 xmode (.sym Dsp- offset -u24)) newval))
2682 (src32-absolute 16 Unprefixed 1 10 QI)
2683 (src32-absolute 16 Unprefixed 1 10 HI)
2684 (src32-absolute 16 Unprefixed 1 10 SI)
2685 (src32-absolute 24 Prefixed 9 18 QI)
2686 (src32-absolute 24 Prefixed 9 18 HI)
2687 (src32-absolute 24 Prefixed 9 18 SI)
2689 ;-------------------------------------------------------------
2690 ; An indirect indirect
2692 ; Double indirect addressing uses the lower 3 bytes of the value stored
2693 ; at the address referenced by 'op' as the effective address.
2694 ;-------------------------------------------------------------
2696 (define-pmacro (indirect-addr op) (and USI (mem32 USI op) #x00ffffff))
2698 ; (define-pmacro (src-An-indirect-indirect-operand xmode)
2699 ; (define-derived-operand
2700 ; (name (.sym src32-An-indirect-indirect- xmode))
2701 ; (comment (.str "m32c An indirect indirect destination " xmode))
2702 ; (attrs (machine 32))
2704 ; (args (Src32AnPrefixed))
2705 ; (syntax (.str "[[$Src32AnPrefixed]]"))
2706 ; (base-ifield f-9-11)
2707 ; (encoding (+ (f-9-3 0) (f-18-1 0) Src32AnPrefixed))
2708 ; (ifield-assertion (andif (eq f-9-3 0) (eq f-18-1 0)))
2709 ; (getter (mem32 xmode (indirect-addr Src32AnPrefixed)))
2710 ; (setter (set (mem32 xmode (indirect-addr Src32AnPrefixed)) newval))
2714 ; (src-An-indirect-indirect-operand QI)
2715 ; (src-An-indirect-indirect-operand HI)
2716 ; (src-An-indirect-indirect-operand SI)
2718 ;-------------------------------------------------------------
2720 ;-------------------------------------------------------------
2722 (define-pmacro (src-relative-indirect-operand xmode)
2724 ; (define-derived-operand
2725 ; (name (.sym src32-24-8-SB-relative-indirect- xmode))
2726 ; (comment (.str "m32c dsp:8[sb] relative source " xmode))
2727 ; (attrs (machine 32))
2729 ; (args (Dsp-24-u8))
2730 ; (syntax "[${Dsp-24-u8}[sb]]")
2731 ; (base-ifield f-9-11)
2732 ; (encoding (+ (f-9-3 1) (f-18-2 2) Dsp-24-u8))
2733 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 2)))
2734 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb)))))
2735 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb)))) newval))
2737 ; (define-derived-operand
2738 ; (name (.sym src32-24-16-SB-relative-indirect- xmode))
2739 ; (comment (.str "m32c dsp:16[sb] relative source " xmode))
2740 ; (attrs (machine 32))
2742 ; (args (Dsp-24-u16))
2743 ; (syntax "[${Dsp-24-u16}[sb]]")
2744 ; (base-ifield f-9-11)
2745 ; (encoding (+ (f-9-3 2) (f-18-2 2) Dsp-24-u16))
2746 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 2)))
2747 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb)))))
2748 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb)))) newval))
2750 ; (define-derived-operand
2751 ; (name (.sym src32-24-8-FB-relative-indirect- xmode))
2752 ; (comment (.str "m32c dsp:8[fb] relative source " xmode))
2753 ; (attrs (machine 32))
2755 ; (args (Dsp-24-s8))
2756 ; (syntax "[${Dsp-24-s8}[fb]]")
2757 ; (base-ifield f-9-11)
2758 ; (encoding (+ (f-9-3 1) (f-18-2 3) Dsp-24-s8))
2759 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 3)))
2760 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb)))))
2761 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb)))) newval))
2763 ; (define-derived-operand
2764 ; (name (.sym src32-24-16-FB-relative-indirect- xmode))
2765 ; (comment (.str "m32c dsp:16[fb] relative source " xmode))
2766 ; (attrs (machine 32))
2768 ; (args (Dsp-24-s16))
2769 ; (syntax "[${Dsp-24-s16}[fb]]")
2770 ; (base-ifield f-9-11)
2771 ; (encoding (+ (f-9-3 2) (f-18-2 3) Dsp-24-s16))
2772 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 3)))
2773 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb)))))
2774 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb)))) newval))
2776 ; (define-derived-operand
2777 ; (name (.sym src32-24-8-An-relative-indirect- xmode))
2778 ; (comment (.str "m32c dsp:8[An] relative indirect source " xmode))
2779 ; (attrs (machine 32))
2781 ; (args (Src32AnPrefixed Dsp-24-u8))
2782 ; (syntax "[${Dsp-24-u8}[$Src32AnPrefixed]]")
2783 ; (base-ifield f-9-11)
2784 ; (encoding (+ (f-9-3 1) (f-18-1 0) Dsp-24-u8 Src32AnPrefixed))
2785 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-1 0)))
2786 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed))))
2787 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed))) newval))
2789 ; (define-derived-operand
2790 ; (name (.sym src32-24-16-An-relative-indirect- xmode))
2791 ; (comment (.str "m32c dsp:16[An] relative source " xmode))
2792 ; (attrs (machine 32))
2794 ; (args (Src32AnPrefixed Dsp-24-u16))
2795 ; (syntax "[${Dsp-24-u16}[$Src32AnPrefixed]]")
2796 ; (base-ifield f-9-11)
2797 ; (encoding (+ (f-9-3 2) (f-18-1 0) Dsp-24-u16 Src32AnPrefixed))
2798 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-1 0)))
2799 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed))))
2800 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed))) newval))
2802 ; (define-derived-operand
2803 ; (name (.sym src32-24-24-An-relative-indirect- xmode))
2804 ; (comment (.str "m32c dsp:24[An] relative source " xmode))
2805 ; (attrs (machine 32))
2807 ; (args (Src32AnPrefixed Dsp-24-u24))
2808 ; (syntax "[${Dsp-24-u24}[$Src32AnPrefixed]]")
2809 ; (base-ifield f-9-11)
2810 ; (encoding (+ (f-9-3 3) (f-18-1 0) Dsp-24-u24 Src32AnPrefixed))
2811 ; (ifield-assertion (andif (eq f-9-3 3) (eq f-18-1 0)))
2812 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed))))
2813 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed))) newval))
2818 ; (src-relative-indirect-operand QI)
2819 ; (src-relative-indirect-operand HI)
2820 ; (src-relative-indirect-operand SI)
2822 ;-------------------------------------------------------------
2823 ; Absolute Indirect address
2824 ;-------------------------------------------------------------
2826 (define-pmacro (src32-absolute-indirect offset base1 base2 xmode)
2828 ; (define-derived-operand
2829 ; (name (.sym src32- offset -16-absolute-indirect-derived- xmode))
2830 ; (comment (.str "m32c absolute indirect address " xmode))
2831 ; (attrs (machine 32))
2833 ; (args ((.sym Dsp- offset -u16)))
2834 ; (syntax (.str "[${Dsp-" offset "-u16}]"))
2835 ; (base-ifield (.sym f- base1 -11))
2836 ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
2837 ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
2838 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))))
2839 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval))
2841 ; (define-derived-operand
2842 ; (name (.sym src32- offset -24-absolute-indirect-derived- xmode))
2843 ; (comment (.str "m32c absolute indirect address " xmode))
2844 ; (attrs (machine 32))
2846 ; (args ((.sym Dsp- offset -u24)))
2847 ; (syntax (.str "[${Dsp-" offset "-u24}]"))
2848 ; (base-ifield (.sym f- base1 -11))
2849 ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
2850 ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
2851 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))))
2852 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval))
2857 (src32-absolute-indirect 24 9 18 QI)
2858 (src32-absolute-indirect 24 9 18 HI)
2859 (src32-absolute-indirect 24 9 18 SI)
2861 ;-------------------------------------------------------------
2862 ; Register relative source operands for short format insns
2863 ;-------------------------------------------------------------
2865 (define-pmacro (src-2-S-operands mach xmode base opc1 opc2 opc3)
2867 (define-derived-operand
2868 (name (.sym src mach -2-S-8-SB-relative- xmode))
2869 (comment (.str "m" mach "c SB relative address"))
2870 (attrs (machine mach))
2873 (syntax "${Dsp-8-u8}[sb]")
2874 (base-ifield (.sym f- base -2))
2875 (encoding (+ ((.sym f- base -2) opc1) Dsp-8-u8))
2876 (ifield-assertion (eq (.sym f- base -2) opc1))
2877 (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8))
2878 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8))
2879 ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8))))
2880 ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8))) newval))
2882 (define-derived-operand
2883 (name (.sym src mach -2-S-8-FB-relative- xmode))
2884 (comment (.str "m" mach "c FB relative address"))
2885 (attrs (machine mach))
2888 (syntax "${Dsp-8-s8}[fb]")
2889 (base-ifield (.sym f- base -2))
2890 (encoding (+ ((.sym f- base -2) opc2) Dsp-8-s8))
2891 (ifield-assertion (eq (.sym f- base -2) opc2))
2892 (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8))
2893 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8))
2894 ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8))))
2895 ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8))) newval))
2897 (define-derived-operand
2898 (name (.sym src mach -2-S-16-absolute- xmode))
2899 (comment (.str "m" mach "c absolute address"))
2900 (attrs (machine mach))
2903 (syntax "${Dsp-8-u16}")
2904 (base-ifield (.sym f- base -2))
2905 (encoding (+ ((.sym f- base -2) opc3) Dsp-8-u16))
2906 (ifield-assertion (eq (.sym f- base -2) opc3))
2907 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16))
2908 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16))
2909 ; (getter (mem-mach mach xmode Dsp-8-u16))
2910 ; (setter (set (mem-mach mach xmode Dsp-8-u16) newval))
2915 (src-2-S-operands 16 QI 6 1 2 3)
2916 (src-2-S-operands 32 QI 2 2 3 1)
2917 (src-2-S-operands 32 HI 2 2 3 1)
2919 ;=============================================================
2921 ;-------------------------------------------------------------
2923 ;-------------------------------------------------------------
2925 ;-------------------------------------------------------------
2927 (define-pmacro (dst16-Rn-direct-operand xmode)
2929 (define-derived-operand
2930 (name (.sym dst16-Rn-direct- xmode))
2931 (comment (.str "m16c Rn direct destination " xmode))
2932 (attrs (machine 16))
2934 (args ((.sym Dst16Rn xmode)))
2935 (syntax (.str "$Dst16Rn" xmode))
2936 (base-ifield f-12-4)
2937 (encoding (+ (f-12-2 0) (.sym Dst16Rn xmode)))
2938 (ifield-assertion (eq f-12-2 0))
2939 (getter (trunc xmode (.sym Dst16Rn xmode)))
2940 (setter (set (.sym Dst16Rn xmode) newval))
2945 (dst16-Rn-direct-operand QI)
2946 (dst16-Rn-direct-operand HI)
2947 (dst16-Rn-direct-operand SI)
2949 (define-derived-operand
2950 (name dst16-Rn-direct-Ext-QI)
2951 (comment "m16c Rn direct destination QI")
2952 (attrs (machine 16))
2954 (args (Dst16RnExtQI))
2955 (syntax "$Dst16RnExtQI")
2956 (base-ifield f-12-4)
2957 (encoding (+ (f-12-2 0) Dst16RnExtQI (f-15-1 0)))
2958 (ifield-assertion (andif (eq f-12-2 0) (eq f-15-1 0)))
2959 (getter (trunc QI (.sym Dst16RnExtQI)))
2960 (setter (set Dst16RnExtQI newval))
2963 (define-pmacro (dst32-Rn-direct-operand group base xmode)
2965 (define-derived-operand
2966 (name (.sym dst32-Rn-direct- group - xmode))
2967 (comment (.str "m32c Rn direct destination " xmode))
2968 (attrs (machine 32))
2970 (args ((.sym Dst32Rn group xmode)))
2971 (syntax (.str "$Dst32Rn" group xmode))
2972 (base-ifield (.sym f- base -6))
2973 (encoding (+ ((.sym f- base -3) 4) (.sym Dst32Rn group xmode)))
2974 (ifield-assertion (eq (.sym f- base -3) 4))
2975 (getter (trunc xmode (.sym Dst32Rn group xmode)))
2976 (setter (set (.sym Dst32Rn group xmode) newval))
2981 (dst32-Rn-direct-operand Unprefixed 4 QI)
2982 (dst32-Rn-direct-operand Prefixed 12 QI)
2983 (dst32-Rn-direct-operand Unprefixed 4 HI)
2984 (dst32-Rn-direct-operand Prefixed 12 HI)
2985 (dst32-Rn-direct-operand Unprefixed 4 SI)
2986 (dst32-Rn-direct-operand Prefixed 12 SI)
2988 (define-pmacro (dst32-Rn-direct-Ext-operand group base1 base2 smode dmode)
2990 (define-derived-operand
2991 (name (.sym dst32-Rn-direct- group - smode))
2992 (comment (.str "m32c Rn direct destination " smode))
2993 (attrs (machine 32))
2995 (args ((.sym Dst32Rn group smode)))
2996 (syntax (.str "$Dst32Rn" group smode))
2997 (base-ifield (.sym f- base1 -6))
2998 (encoding (+ ((.sym f- base1 -3) 4) ((.sym f- base2 -1) 1) (.sym Dst32Rn group smode)))
2999 (ifield-assertion (andif (eq (.sym f- base1 -3) 4) (eq (.sym f- base2 -1) 1)))
3000 (getter (trunc smode (.sym Dst32Rn group smode)))
3001 (setter (set (.sym Dst32Rn group smode) newval))
3006 (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 QI HI)
3007 (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 HI SI)
3009 (define-derived-operand
3010 (name dst32-R3-direct-Unprefixed-HI)
3011 (comment "m32c R3 direct HI")
3012 (attrs (machine 32))
3017 (encoding (+ (f-4-3 4) (f-8-2 #x1)))
3018 (ifield-assertion (andif (eq f-4-3 4) (eq f-8-2 #x1)))
3019 (getter (trunc HI R3))
3020 (setter (set R3 newval))
3022 ;-------------------------------------------------------------
3024 ;-------------------------------------------------------------
3026 (define-pmacro (dst16-An-direct-operand xmode)
3028 (define-derived-operand
3029 (name (.sym dst16-An-direct- xmode))
3030 (comment (.str "m16c An direct destination " xmode))
3031 (attrs (machine 16))
3033 (args ((.sym Dst16An xmode)))
3034 (syntax (.str "$Dst16An" xmode))
3035 (base-ifield f-12-4)
3036 (encoding (+ (f-12-2 1) (f-14-1 0) (.sym Dst16An xmode)))
3037 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0)))
3038 (getter (trunc xmode (.sym Dst16An xmode)))
3039 (setter (set (.sym Dst16An xmode) newval))
3044 (dst16-An-direct-operand QI)
3045 (dst16-An-direct-operand HI)
3046 (dst16-An-direct-operand SI)
3048 (define-pmacro (dst32-An-direct-operand group base1 base2 xmode)
3050 (define-derived-operand
3051 (name (.sym dst32-An-direct- group - xmode))
3052 (comment (.str "m32c An direct destination " xmode))
3053 (attrs (machine 32))
3055 (args ((.sym Dst32An group xmode)))
3056 (syntax (.str "$Dst32An" group xmode))
3057 (base-ifield (.sym f- base1 -6))
3058 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Dst32An group xmode)))
3059 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
3060 (getter (trunc xmode (.sym Dst32An group xmode)))
3061 (setter (set (.sym Dst32An group xmode) newval))
3066 (dst32-An-direct-operand Unprefixed 4 8 QI)
3067 (dst32-An-direct-operand Prefixed 12 16 QI)
3068 (dst32-An-direct-operand Unprefixed 4 8 HI)
3069 (dst32-An-direct-operand Prefixed 12 16 HI)
3070 (dst32-An-direct-operand Unprefixed 4 8 SI)
3071 (dst32-An-direct-operand Prefixed 12 16 SI)
3073 ;-------------------------------------------------------------
3075 ;-------------------------------------------------------------
3077 (define-pmacro (dst16-An-indirect-operand xmode)
3079 (define-derived-operand
3080 (name (.sym dst16-An-indirect- xmode))
3081 (comment (.str "m16c An indirect destination " xmode))
3082 (attrs (machine 16))
3085 (syntax "[$Dst16An]")
3086 (base-ifield f-12-4)
3087 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
3088 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
3089 (getter (mem16 xmode Dst16An))
3090 (setter (set (mem16 xmode Dst16An) newval))
3095 (dst16-An-indirect-operand QI)
3096 (dst16-An-indirect-operand HI)
3097 (dst16-An-indirect-operand SI)
3099 (define-derived-operand
3100 (name dst16-An-indirect-Ext-QI)
3101 (comment "m16c An indirect destination QI")
3102 (attrs (machine 16))
3105 (syntax "[$Dst16An]")
3106 (base-ifield f-12-4)
3107 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
3108 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
3109 (getter (mem16 QI Dst16An))
3110 (setter (set (mem16 HI Dst16An) newval))
3113 (define-pmacro (dst32-An-indirect-operand group base1 base2 smode dmode)
3115 (define-derived-operand
3116 (name (.sym dst32-An-indirect- group - smode))
3117 (comment (.str "m32c An indirect destination " smode))
3118 (attrs (machine 32))
3120 (args ((.sym Dst32An group)))
3121 (syntax (.str "[$Dst32An" group "]"))
3122 (base-ifield (.sym f- base1 -6))
3123 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Dst32An group)))
3124 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
3125 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group)
3127 (setter (c-call DFLT (.str "operand_setter_" dmode) newval
3128 (.sym Dst32An group) (const 0)))
3129 ; (getter (mem32 smode (.sym Dst32An group)))
3130 ; (setter (set (mem32 dmode (.sym Dst32An group)) newval))
3135 (dst32-An-indirect-operand Unprefixed 4 8 QI QI)
3136 (dst32-An-indirect-operand Prefixed 12 16 QI QI)
3137 (dst32-An-indirect-operand Unprefixed 4 8 HI HI)
3138 (dst32-An-indirect-operand Prefixed 12 16 HI HI)
3139 (dst32-An-indirect-operand Unprefixed 4 8 SI SI)
3140 (dst32-An-indirect-operand Prefixed 12 16 SI SI)
3141 (dst32-An-indirect-operand ExtUnprefixed 4 8 QI HI)
3142 (dst32-An-indirect-operand ExtUnprefixed 4 8 HI SI)
3144 ;-------------------------------------------------------------
3146 ;-------------------------------------------------------------
3148 (define-pmacro (dst16-relative-operand offset xmode)
3150 (define-derived-operand
3151 (name (.sym dst16- offset -8-SB-relative- xmode))
3152 (comment (.str "m16c dsp:8[sb] relative destination " xmode))
3153 (attrs (machine 16))
3155 (args ((.sym Dsp- offset -u8)))
3156 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3157 (base-ifield f-12-4)
3158 (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8)))
3159 (ifield-assertion (eq f-12-4 #xA))
3160 (getter (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb))))
3161 (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3163 (define-derived-operand
3164 (name (.sym dst16- offset -16-SB-relative- xmode))
3165 (comment (.str "m16c dsp:16[sb] relative destination " xmode))
3166 (attrs (machine 16))
3168 (args ((.sym Dsp- offset -u16)))
3169 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3170 (base-ifield f-12-4)
3171 (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16)))
3172 (ifield-assertion (eq f-12-4 #xE))
3173 (getter (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb))))
3174 (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3176 (define-derived-operand
3177 (name (.sym dst16- offset -8-FB-relative- xmode))
3178 (comment (.str "m16c dsp:8[fb] relative destination " xmode))
3179 (attrs (machine 16))
3181 (args ((.sym Dsp- offset -s8)))
3182 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3183 (base-ifield f-12-4)
3184 (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8)))
3185 (ifield-assertion (eq f-12-4 #xB))
3186 (getter (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb))))
3187 (setter (set (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3189 (define-derived-operand
3190 (name (.sym dst16- offset -8-An-relative- xmode))
3191 (comment (.str "m16c dsp:8[An] relative destination " xmode))
3192 (attrs (machine 16))
3194 (args (Dst16An (.sym Dsp- offset -u8)))
3195 (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]"))
3196 (base-ifield f-12-4)
3197 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An))
3198 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3199 (getter (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An)))
3200 (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An)) newval))
3202 (define-derived-operand
3203 (name (.sym dst16- offset -16-An-relative- xmode))
3204 (comment (.str "m16c dsp:16[An] relative destination " xmode))
3205 (attrs (machine 16))
3207 (args (Dst16An (.sym Dsp- offset -u16)))
3208 (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]"))
3209 (base-ifield f-12-4)
3210 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An))
3211 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3212 (getter (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An)))
3213 (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An)) newval))
3215 (define-derived-operand
3216 (name (.sym dst16- offset -20-An-relative- xmode))
3217 (comment (.str "m16c dsp:20[An] relative destination " xmode))
3218 (attrs (machine 16))
3220 (args (Dst16An (.sym Dsp- offset -u20)))
3221 (syntax (.str "${Dsp-" offset "-u20}[$Dst16An]"))
3222 (base-ifield f-12-4)
3223 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u20) Dst16An))
3224 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3225 (getter (mem16 xmode (add (.sym Dsp- offset -u20) Dst16An)))
3226 (setter (set (mem16 xmode (add (.sym Dsp- offset -u20) Dst16An)) newval))
3231 (dst16-relative-operand 16 QI)
3232 (dst16-relative-operand 24 QI)
3233 (dst16-relative-operand 32 QI)
3234 (dst16-relative-operand 40 QI)
3235 (dst16-relative-operand 48 QI)
3236 (dst16-relative-operand 16 HI)
3237 (dst16-relative-operand 24 HI)
3238 (dst16-relative-operand 32 HI)
3239 (dst16-relative-operand 40 HI)
3240 (dst16-relative-operand 48 HI)
3241 (dst16-relative-operand 16 SI)
3242 (dst16-relative-operand 24 SI)
3243 (dst16-relative-operand 32 SI)
3244 (dst16-relative-operand 40 SI)
3245 (dst16-relative-operand 48 SI)
3247 (define-pmacro (dst16-relative-Ext-operand offset smode dmode)
3249 (define-derived-operand
3250 (name (.sym dst16- offset -8-SB-relative-Ext- smode))
3251 (comment (.str "m16c dsp:8[sb] relative destination " smode))
3252 (attrs (machine 16))
3254 (args ((.sym Dsp- offset -u8)))
3255 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3256 (base-ifield f-12-4)
3257 (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8)))
3258 (ifield-assertion (eq f-12-4 #xA))
3259 (getter (mem16 smode (add (.sym Dsp- offset -u8) (reg h-sb))))
3260 (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3262 (define-derived-operand
3263 (name (.sym dst16- offset -16-SB-relative-Ext- smode))
3264 (comment (.str "m16c dsp:16[sb] relative destination " smode))
3265 (attrs (machine 16))
3267 (args ((.sym Dsp- offset -u16)))
3268 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3269 (base-ifield f-12-4)
3270 (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16)))
3271 (ifield-assertion (eq f-12-4 #xE))
3272 (getter (mem16 smode (add (.sym Dsp- offset -u16) (reg h-sb))))
3273 (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3275 (define-derived-operand
3276 (name (.sym dst16- offset -8-FB-relative-Ext- smode))
3277 (comment (.str "m16c dsp:8[fb] relative destination " smode))
3278 (attrs (machine 16))
3280 (args ((.sym Dsp- offset -s8)))
3281 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3282 (base-ifield f-12-4)
3283 (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8)))
3284 (ifield-assertion (eq f-12-4 #xB))
3285 (getter (mem16 smode (add (.sym Dsp- offset -s8) (reg h-fb))))
3286 (setter (set (mem16 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3288 (define-derived-operand
3289 (name (.sym dst16- offset -8-An-relative-Ext- smode))
3290 (comment (.str "m16c dsp:8[An] relative destination " smode))
3291 (attrs (machine 16))
3293 (args (Dst16An (.sym Dsp- offset -u8)))
3294 (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]"))
3295 (base-ifield f-12-4)
3296 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An))
3297 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3298 (getter (mem16 smode (add (.sym Dsp- offset -u8) Dst16An)))
3299 (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) Dst16An)) newval))
3301 (define-derived-operand
3302 (name (.sym dst16- offset -16-An-relative-Ext- smode))
3303 (comment (.str "m16c dsp:16[An] relative destination " smode))
3304 (attrs (machine 16))
3306 (args (Dst16An (.sym Dsp- offset -u16)))
3307 (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]"))
3308 (base-ifield f-12-4)
3309 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An))
3310 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3311 (getter (mem16 smode (add (.sym Dsp- offset -u16) Dst16An)))
3312 (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) Dst16An)) newval))
3317 (dst16-relative-Ext-operand 16 QI HI)
3319 (define-pmacro (dst32-relative-operand offset group base1 base2 smode dmode)
3321 (define-derived-operand
3322 (name (.sym dst32- offset -8-SB-relative- group - smode))
3323 (comment (.str "m32c dsp:8[sb] relative destination " smode))
3324 (attrs (machine 32))
3326 (args ((.sym Dsp- offset -u8)))
3327 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3328 (base-ifield (.sym f- base1 -6))
3329 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8)))
3330 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
3331 (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u8)))
3332 (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u8)))
3333 ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (reg h-sb))))
3334 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3336 (define-derived-operand
3337 (name (.sym dst32- offset -16-SB-relative- group - smode))
3338 (comment (.str "m32c dsp:16[sb] relative destination " smode))
3339 (attrs (machine 32))
3341 (args ((.sym Dsp- offset -u16)))
3342 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3343 (base-ifield (.sym f- base1 -6))
3344 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16)))
3345 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
3346 (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u16)))
3347 (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u16)))
3348 ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (reg h-sb))))
3349 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3351 (define-derived-operand
3352 (name (.sym dst32- offset -8-FB-relative- group - smode))
3353 (comment (.str "m32c dsp:8[fb] relative destination " smode))
3354 (attrs (machine 32))
3356 (args ((.sym Dsp- offset -s8)))
3357 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3358 (base-ifield (.sym f- base1 -6))
3359 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8)))
3360 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
3361 (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s8)))
3362 (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s8)))
3363 ; (getter (mem32 smode (add (.sym Dsp- offset -s8) (reg h-fb))))
3364 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3366 (define-derived-operand
3367 (name (.sym dst32- offset -16-FB-relative- group - smode))
3368 (comment (.str "m32c dsp:16[fb] relative destination " smode))
3369 (attrs (machine 32))
3371 (args ((.sym Dsp- offset -s16)))
3372 (syntax (.str "${Dsp-" offset "-s16}[fb]"))
3373 (base-ifield (.sym f- base1 -6))
3374 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16)))
3375 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
3376 (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s16)))
3377 (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s16)))
3378 ; (getter (mem32 smode (add (.sym Dsp- offset -s16) (reg h-fb))))
3379 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval))
3381 (define-derived-operand
3382 (name (.sym dst32- offset -8-An-relative- group - smode))
3383 (comment (.str "m32c dsp:8[An] relative destination " smode))
3384 (attrs (machine 32))
3386 (args ((.sym Dst32An group) (.sym Dsp- offset -u8)))
3387 (syntax (.str "${Dsp-" offset "-u8}[$Dst32An" group "]"))
3388 (base-ifield (.sym f- base1 -6))
3389 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Dst32An group)))
3390 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
3391 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u8)))
3392 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u8)))
3393 ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (.sym Dst32An group))))
3394 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (.sym Dst32An group))) newval))
3396 (define-derived-operand
3397 (name (.sym dst32- offset -16-An-relative- group - smode))
3398 (comment (.str "m32c dsp:16[An] relative destination " smode))
3399 (attrs (machine 32))
3401 (args ((.sym Dst32An group) (.sym Dsp- offset -u16)))
3402 (syntax (.str "${Dsp-" offset "-u16}[$Dst32An" group "]"))
3403 (base-ifield (.sym f- base1 -6))
3404 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Dst32An group)))
3405 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
3406 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u16)))
3407 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u16)))
3408 ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (.sym Dst32An group))))
3409 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (.sym Dst32An group))) newval))
3411 (define-derived-operand
3412 (name (.sym dst32- offset -24-An-relative- group - smode))
3413 (comment (.str "m32c dsp:16[An] relative destination " smode))
3414 (attrs (machine 32))
3416 (args ((.sym Dst32An group) (.sym Dsp- offset -u24)))
3417 (syntax (.str "${Dsp-" offset "-u24}[$Dst32An" group "]"))
3418 (base-ifield (.sym f- base1 -6))
3419 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Dst32An group)))
3420 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
3421 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u24)))
3422 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u24)))
3423 ; (getter (mem32 smode (add (.sym Dsp- offset -u24) (.sym Dst32An group))))
3424 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u24) (.sym Dst32An group))) newval))
3429 (dst32-relative-operand 16 Unprefixed 4 8 QI QI)
3430 (dst32-relative-operand 24 Unprefixed 4 8 QI QI)
3431 (dst32-relative-operand 32 Unprefixed 4 8 QI QI)
3432 (dst32-relative-operand 40 Unprefixed 4 8 QI QI)
3433 (dst32-relative-operand 16 Unprefixed 4 8 HI HI)
3434 (dst32-relative-operand 24 Unprefixed 4 8 HI HI)
3435 (dst32-relative-operand 32 Unprefixed 4 8 HI HI)
3436 (dst32-relative-operand 40 Unprefixed 4 8 HI HI)
3437 (dst32-relative-operand 16 Unprefixed 4 8 SI SI)
3438 (dst32-relative-operand 24 Unprefixed 4 8 SI SI)
3439 (dst32-relative-operand 32 Unprefixed 4 8 SI SI)
3440 (dst32-relative-operand 40 Unprefixed 4 8 SI SI)
3442 (dst32-relative-operand 24 Prefixed 12 16 QI QI)
3443 (dst32-relative-operand 32 Prefixed 12 16 QI QI)
3444 (dst32-relative-operand 40 Prefixed 12 16 QI QI)
3445 (dst32-relative-operand 48 Prefixed 12 16 QI QI)
3446 (dst32-relative-operand 24 Prefixed 12 16 HI HI)
3447 (dst32-relative-operand 32 Prefixed 12 16 HI HI)
3448 (dst32-relative-operand 40 Prefixed 12 16 HI HI)
3449 (dst32-relative-operand 48 Prefixed 12 16 HI HI)
3450 (dst32-relative-operand 24 Prefixed 12 16 SI SI)
3451 (dst32-relative-operand 32 Prefixed 12 16 SI SI)
3452 (dst32-relative-operand 40 Prefixed 12 16 SI SI)
3453 (dst32-relative-operand 48 Prefixed 12 16 SI SI)
3455 (dst32-relative-operand 16 ExtUnprefixed 4 8 QI HI)
3456 (dst32-relative-operand 16 ExtUnprefixed 4 8 HI SI)
3458 ;-------------------------------------------------------------
3460 ;-------------------------------------------------------------
3462 (define-pmacro (dst16-absolute offset xmode)
3464 (define-derived-operand
3465 (name (.sym dst16- offset -16-absolute- xmode))
3466 (comment (.str "m16c absolute address " xmode))
3467 (attrs (machine 16))
3469 (args ((.sym Dsp- offset -u16)))
3470 (syntax (.str "${Dsp-" offset "-u16}"))
3471 (base-ifield f-12-4)
3472 (encoding (+ (f-12-4 #xF) (.sym Dsp- offset -u16)))
3473 (ifield-assertion (eq f-12-4 #xF))
3474 (getter (mem16 xmode (.sym Dsp- offset -u16)))
3475 (setter (set (mem16 xmode (.sym Dsp- offset -u16)) newval))
3480 (dst16-absolute 16 QI)
3481 (dst16-absolute 24 QI)
3482 (dst16-absolute 32 QI)
3483 (dst16-absolute 40 QI)
3484 (dst16-absolute 48 QI)
3485 (dst16-absolute 16 HI)
3486 (dst16-absolute 24 HI)
3487 (dst16-absolute 32 HI)
3488 (dst16-absolute 40 HI)
3489 (dst16-absolute 48 HI)
3490 (dst16-absolute 16 SI)
3491 (dst16-absolute 24 SI)
3492 (dst16-absolute 32 SI)
3493 (dst16-absolute 40 SI)
3494 (dst16-absolute 48 SI)
3496 (define-derived-operand
3497 (name dst16-16-16-absolute-Ext-QI)
3498 (comment "m16c absolute address QI")
3499 (attrs (machine 16))
3502 (syntax "${Dsp-16-u16}")
3503 (base-ifield f-12-4)
3504 (encoding (+ (f-12-4 #xF) Dsp-16-u16))
3505 (ifield-assertion (eq f-12-4 #xF))
3506 (getter (mem16 QI Dsp-16-u16))
3507 (setter (set (mem16 HI Dsp-16-u16) newval))
3510 (define-pmacro (dst32-absolute offset group base1 base2 smode dmode)
3512 (define-derived-operand
3513 (name (.sym dst32- offset -16-absolute- group - smode))
3514 (comment (.str "m32c absolute address " smode))
3515 (attrs (machine 32))
3517 (args ((.sym Dsp- offset -u16)))
3518 (syntax (.str "${Dsp-" offset "-u16}"))
3519 (base-ifield (.sym f- base1 -6))
3520 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
3521 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
3522 (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u16)))
3523 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u16)))
3524 ; (getter (mem32 smode (.sym Dsp- offset -u16)))
3525 ; (setter (set (mem32 dmode (.sym Dsp- offset -u16)) newval))
3527 (define-derived-operand
3528 (name (.sym dst32- offset -24-absolute- group - smode))
3529 (comment (.str "m32c absolute address " smode))
3530 (attrs (machine 32))
3532 (args ((.sym Dsp- offset -u24)))
3533 (syntax (.str "${Dsp-" offset "-u24}"))
3534 (base-ifield (.sym f- base1 -6))
3535 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
3536 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
3537 (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u24)))
3538 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u24)))
3539 ; (getter (mem32 smode (.sym Dsp- offset -u24)))
3540 ; (setter (set (mem32 dmode (.sym Dsp- offset -u24)) newval))
3545 (dst32-absolute 16 Unprefixed 4 8 QI QI)
3546 (dst32-absolute 24 Unprefixed 4 8 QI QI)
3547 (dst32-absolute 32 Unprefixed 4 8 QI QI)
3548 (dst32-absolute 40 Unprefixed 4 8 QI QI)
3549 (dst32-absolute 16 Unprefixed 4 8 HI HI)
3550 (dst32-absolute 24 Unprefixed 4 8 HI HI)
3551 (dst32-absolute 32 Unprefixed 4 8 HI HI)
3552 (dst32-absolute 40 Unprefixed 4 8 HI HI)
3553 (dst32-absolute 16 Unprefixed 4 8 SI SI)
3554 (dst32-absolute 24 Unprefixed 4 8 SI SI)
3555 (dst32-absolute 32 Unprefixed 4 8 SI SI)
3556 (dst32-absolute 40 Unprefixed 4 8 SI SI)
3558 (dst32-absolute 24 Prefixed 12 16 QI QI)
3559 (dst32-absolute 32 Prefixed 12 16 QI QI)
3560 (dst32-absolute 40 Prefixed 12 16 QI QI)
3561 (dst32-absolute 48 Prefixed 12 16 QI QI)
3562 (dst32-absolute 24 Prefixed 12 16 HI HI)
3563 (dst32-absolute 32 Prefixed 12 16 HI HI)
3564 (dst32-absolute 40 Prefixed 12 16 HI HI)
3565 (dst32-absolute 48 Prefixed 12 16 HI HI)
3566 (dst32-absolute 24 Prefixed 12 16 SI SI)
3567 (dst32-absolute 32 Prefixed 12 16 SI SI)
3568 (dst32-absolute 40 Prefixed 12 16 SI SI)
3569 (dst32-absolute 48 Prefixed 12 16 SI SI)
3571 (dst32-absolute 16 ExtUnprefixed 4 8 QI HI)
3572 (dst32-absolute 16 ExtUnprefixed 4 8 HI SI)
3574 ;-------------------------------------------------------------
3575 ; An indirect indirect
3576 ;-------------------------------------------------------------
3578 ;(define-pmacro (dst-An-indirect-indirect-operand xmode)
3579 ; (define-derived-operand
3580 ; (name (.sym dst32-An-indirect-indirect- xmode))
3581 ; (comment (.str "m32c An indirect indirect destination " xmode))
3582 ; (attrs (machine 32))
3584 ; (args (Dst32AnPrefixed))
3585 ; (syntax (.str "[[$Dst32AnPrefixed]]"))
3586 ; (base-ifield f-12-6)
3587 ; (encoding (+ (f-12-3 0) (f-16-1 0) Dst32AnPrefixed))
3588 ; (ifield-assertion (andif (eq f-12-3 0) (eq f-16-1 0)))
3589 ; (getter (mem32 xmode (indirect-addr Dst32AnPrefixed)))
3590 ; (setter (set (mem32 xmode (indirect-addr Dst32AnPrefixed)) newval))
3594 ; (dst-An-indirect-indirect-operand QI)
3595 ; (dst-An-indirect-indirect-operand HI)
3596 ; (dst-An-indirect-indirect-operand SI)
3598 ;-------------------------------------------------------------
3600 ;-------------------------------------------------------------
3602 (define-pmacro (dst-relative-indirect-operand offset xmode)
3604 ; (define-derived-operand
3605 ; (name (.sym dst32- offset -8-SB-relative-indirect- xmode))
3606 ; (comment (.str "m32c dsp:8[sb] relative destination " xmode))
3607 ; (attrs (machine 32))
3609 ; (args ((.sym Dsp- offset -u8)))
3610 ; (syntax (.str "[${Dsp-" offset "-u8}[sb]]"))
3611 ; (base-ifield f-12-6)
3612 ; (encoding (+ (f-12-3 1) (f-16-2 2) (.sym Dsp- offset -u8)))
3613 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 2)))
3614 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb)))))
3615 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb)))) newval))
3617 ; (define-derived-operand
3618 ; (name (.sym dst32- offset -16-SB-relative-indirect- xmode))
3619 ; (comment (.str "m32c dsp:16[sb] relative destination " xmode))
3620 ; (attrs (machine 32))
3622 ; (args ((.sym Dsp- offset -u16)))
3623 ; (syntax (.str "[${Dsp-" offset "-u16}[sb]]"))
3624 ; (base-ifield f-12-6)
3625 ; (encoding (+ (f-12-3 2) (f-16-2 2) (.sym Dsp- offset -u16)))
3626 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 2)))
3627 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb)))))
3628 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb)))) newval))
3630 ; (define-derived-operand
3631 ; (name (.sym dst32- offset -8-FB-relative-indirect- xmode))
3632 ; (comment (.str "m32c dsp:8[fb] relative destination " xmode))
3633 ; (attrs (machine 32))
3635 ; (args ((.sym Dsp- offset -s8)))
3636 ; (syntax (.str "[${Dsp-" offset "-s8}[fb]]"))
3637 ; (base-ifield f-12-6)
3638 ; (encoding (+ (f-12-3 1) (f-16-2 3) (.sym Dsp- offset -s8)))
3639 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 3)))
3640 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb)))))
3641 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb)))) newval))
3643 ; (define-derived-operand
3644 ; (name (.sym dst32- offset -16-FB-relative-indirect- xmode))
3645 ; (comment (.str "m32c dsp:16[fb] relative destination " xmode))
3646 ; (attrs (machine 32))
3648 ; (args ((.sym Dsp- offset -s16)))
3649 ; (syntax (.str "[${Dsp-" offset "-s16}[fb]]"))
3650 ; (base-ifield f-12-6)
3651 ; (encoding (+ (f-12-3 2) (f-16-2 3) (.sym Dsp- offset -s16)))
3652 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 3)))
3653 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb)))))
3654 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb)))) newval))
3656 ; (define-derived-operand
3657 ; (name (.sym dst32- offset -8-An-relative-indirect- xmode))
3658 ; (comment (.str "m32c dsp:8[An] relative indirect destination " xmode))
3659 ; (attrs (machine 32))
3661 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u8)))
3662 ; (syntax (.str "[${Dsp-" offset "-u8}[$Dst32AnPrefixed]]"))
3663 ; (base-ifield f-12-6)
3664 ; (encoding (+ (f-12-3 1) (f-16-1 0) (.sym Dsp- offset -u8) Dst32AnPrefixed))
3665 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-1 0)))
3666 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed))))
3667 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed))) newval))
3669 ; (define-derived-operand
3670 ; (name (.sym dst32- offset -16-An-relative-indirect- xmode))
3671 ; (comment (.str "m32c dsp:16[An] relative destination " xmode))
3672 ; (attrs (machine 32))
3674 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u16)))
3675 ; (syntax (.str "[${Dsp-" offset "-u16}[$Dst32AnPrefixed]]"))
3676 ; (base-ifield f-12-6)
3677 ; (encoding (+ (f-12-3 2) (f-16-1 0) (.sym Dsp- offset -u16) Dst32AnPrefixed))
3678 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-1 0)))
3679 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed))))
3680 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed))) newval))
3682 ; (define-derived-operand
3683 ; (name (.sym dst32- offset -24-An-relative-indirect- xmode))
3684 ; (comment (.str "m32c dsp:24[An] relative destination " xmode))
3685 ; (attrs (machine 32))
3687 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u24)))
3688 ; (syntax (.str "[${Dsp-" offset "-u24}[$Dst32AnPrefixed]]"))
3689 ; (base-ifield f-12-6)
3690 ; (encoding (+ (f-12-3 3) (f-16-1 0) (.sym Dsp- offset -u24) Dst32AnPrefixed))
3691 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-1 0)))
3692 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed))))
3693 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed))) newval))
3698 ; (dst-relative-indirect-operand 24 QI)
3699 ; (dst-relative-indirect-operand 32 QI)
3700 ; (dst-relative-indirect-operand 40 QI)
3701 ; (dst-relative-indirect-operand 48 QI)
3702 ; (dst-relative-indirect-operand 24 HI)
3703 ; (dst-relative-indirect-operand 32 HI)
3704 ; (dst-relative-indirect-operand 40 HI)
3705 ; (dst-relative-indirect-operand 48 HI)
3706 ; (dst-relative-indirect-operand 24 SI)
3707 ; (dst-relative-indirect-operand 32 SI)
3708 ; (dst-relative-indirect-operand 40 SI)
3709 ; (dst-relative-indirect-operand 48 SI)
3711 ;-------------------------------------------------------------
3713 ;-------------------------------------------------------------
3715 (define-pmacro (dst-absolute-indirect offset xmode)
3717 ; (define-derived-operand
3718 ; (name (.sym dst32- offset -16-absolute-indirect-derived- xmode))
3719 ; (comment (.str "m32c absolute indirect address " xmode))
3720 ; (attrs (machine 32))
3722 ; (args ((.sym Dsp- offset -u16)))
3723 ; (syntax (.str "[${Dsp-" offset "-u16}]"))
3724 ; (base-ifield f-12-6)
3725 ; (encoding (+ (f-12-3 3) (f-16-2 3) (.sym Dsp- offset -u16)))
3726 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 3)))
3727 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))))
3728 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval))
3730 ; (define-derived-operand
3731 ; (name (.sym dst32- offset -24-absolute-indirect-derived- xmode))
3732 ; (comment (.str "m32c absolute indirect address " xmode))
3733 ; (attrs (machine 32))
3735 ; (args ((.sym Dsp- offset -u24)))
3736 ; (syntax (.str "[${Dsp-" offset "-u24}]"))
3737 ; (base-ifield f-12-6)
3738 ; (encoding (+ (f-12-3 3) (f-16-2 2) (.sym Dsp- offset -u24)))
3739 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 2)))
3740 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))))
3741 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval))
3746 (dst-absolute-indirect 24 QI)
3747 (dst-absolute-indirect 32 QI)
3748 (dst-absolute-indirect 40 QI)
3749 (dst-absolute-indirect 48 QI)
3750 (dst-absolute-indirect 24 HI)
3751 (dst-absolute-indirect 32 HI)
3752 (dst-absolute-indirect 40 HI)
3753 (dst-absolute-indirect 48 HI)
3754 (dst-absolute-indirect 24 SI)
3755 (dst-absolute-indirect 32 SI)
3756 (dst-absolute-indirect 40 SI)
3757 (dst-absolute-indirect 48 SI)
3759 ;-------------------------------------------------------------
3761 ;-------------------------------------------------------------
3762 (define-pmacro (get-register-bit reg bitno)
3763 (and (srl reg bitno) 1)
3766 (define-pmacro (set-register-bit reg bitno value)
3767 (set reg (or (and reg (inv (sll 1 bitno)))
3768 (sll (and QI value 1) bitno)))
3771 (define-pmacro (get-memory-bit mach base bitno)
3772 (and (srl (mem-mach mach QI (add base (div bitno 8)))
3777 (define-pmacro (set-memory-bit mach base bitno value)
3778 (sequence ((USI addr))
3779 (set addr (add base (div bitno 8)))
3780 (set (mem-mach mach QI addr)
3781 (or (and (mem-mach mach QI addr)
3782 (inv (sll 1 (mod bitno 8))))
3783 (sll (and QI value 1) (mod bitno 8)))))
3786 ;-------------------------------------------------------------
3788 ;-------------------------------------------------------------
3790 (define-derived-operand
3791 (name bit16-Rn-direct)
3792 (comment "m16c Rn direct bit")
3793 (attrs (machine 16))
3795 (args (Bitno16R Bit16Rn))
3796 (syntax "$Bitno16R,$Bit16Rn")
3797 (base-ifield f-12-4)
3798 (encoding (+ (f-12-2 0) Bit16Rn Bitno16R))
3799 (ifield-assertion (eq f-12-2 0))
3800 (getter (get-register-bit Bit16Rn Bitno16R))
3801 (setter (set-register-bit Bit16Rn Bitno16R newval))
3804 (define-pmacro (bit32-Rn-direct-operand group base)
3806 (define-derived-operand
3807 (name (.sym bit32-Rn-direct- group))
3808 (comment "m32c Rn direct bit")
3809 (attrs (machine 32))
3811 (args ((.sym Bitno32 group) (.sym Bit32Rn group)))
3812 (syntax (.str "$Bitno32" group ",$Bit32Rn" group))
3813 (base-ifield (.sym f- base -6))
3814 (encoding (+ ((.sym f- base -3) 4) (.sym Bit32Rn group) (.sym Bitno32 group)))
3815 (ifield-assertion (eq (.sym f- base -3) 4))
3816 (getter (get-register-bit (.sym Bit32Rn group) (.sym Bitno32 group)))
3817 (setter (set-register-bit (.sym Bit32Rn group) (.sym Bitno32 group) newval))
3822 (bit32-Rn-direct-operand Unprefixed 4)
3823 (bit32-Rn-direct-operand Prefixed 12)
3825 ;-------------------------------------------------------------
3827 ;-------------------------------------------------------------
3829 (define-derived-operand
3830 (name bit16-An-direct)
3831 (comment "m16c An direct bit")
3832 (attrs (machine 16))
3834 (args (Bitno16R Bit16An))
3835 (syntax "$Bitno16R,$Bit16An")
3836 (base-ifield f-12-4)
3837 (encoding (+ (f-12-2 1) (f-14-1 0) Bit16An Bitno16R))
3838 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0)))
3839 (getter (get-register-bit Bit16An Bitno16R))
3840 (setter (set-register-bit Bit16An Bitno16R newval))
3843 (define-pmacro (bit32-An-direct-operand group base1 base2)
3845 (define-derived-operand
3846 (name (.sym bit32-An-direct- group))
3847 (comment "m32c An direct bit")
3848 (attrs (machine 32))
3850 (args ((.sym Bitno32 group) (.sym Bit32An group)))
3851 (syntax (.str "$Bitno32" group ",$Bit32An" group))
3852 (base-ifield (.sym f- base1 -6))
3853 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Bit32An group) (.sym Bitno32 group)))
3854 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
3855 (getter (get-register-bit (.sym Bit32An group) (.sym Bitno32 group)))
3856 (setter (set-register-bit (.sym Bit32An group) (.sym Bitno32 group) newval))
3861 (bit32-An-direct-operand Unprefixed 4 8)
3862 (bit32-An-direct-operand Prefixed 12 16)
3864 ;-------------------------------------------------------------
3866 ;-------------------------------------------------------------
3868 (define-derived-operand
3869 (name bit16-An-indirect)
3870 (comment "m16c An indirect bit")
3871 (attrs (machine 16))
3874 (syntax "[$Bit16An]")
3875 (base-ifield f-12-4)
3876 (encoding (+ (f-12-2 1) (f-14-1 1) Bit16An))
3877 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
3878 (getter (get-memory-bit 16 0 Bit16An))
3879 (setter (set-memory-bit 16 0 Bit16An newval))
3882 (define-pmacro (bit32-An-indirect-operand group base1 base2)
3884 (define-derived-operand
3885 (name (.sym bit32-An-indirect- group))
3886 (comment "m32c An indirect destination ")
3887 (attrs (machine 32))
3889 (args ((.sym Bitno32 group) (.sym Bit32An group)))
3890 (syntax (.str "$Bitno32" group ",[$Bit32An" group "]"))
3891 (base-ifield (.sym f- base1 -6))
3892 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Bit32An group) (.sym Bitno32 group)))
3893 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
3894 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group)))
3895 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group) newval))
3900 (bit32-An-indirect-operand Unprefixed 4 8)
3901 (bit32-An-indirect-operand Prefixed 12 16)
3903 ;-------------------------------------------------------------
3905 ;-------------------------------------------------------------
3907 (define-pmacro (bit16-relative-operand offset)
3909 (define-derived-operand
3910 (name (.sym bit16- offset -8-SB-relative))
3911 (comment (.str "m16c dsp:8[sb] relative bit " xmode))
3912 (attrs (machine 16))
3914 (args ((.sym BitBase16- offset -u8)))
3915 (syntax (.str "${BitBase16-" offset "-u8}[sb]"))
3916 (base-ifield f-12-4)
3917 (encoding (+ (f-12-4 #xA) (.sym BitBase16- offset -u8)))
3918 (ifield-assertion (eq f-12-4 #xA))
3919 (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8)))
3920 (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8) newval))
3922 (define-derived-operand
3923 (name (.sym bit16- offset -16-SB-relative))
3924 (comment (.str "m16c dsp:16[sb] relative bit " xmode))
3925 (attrs (machine 16))
3927 (args ((.sym BitBase16- offset -u16)))
3928 (syntax (.str "${BitBase16-" offset "-u16}[sb]"))
3929 (base-ifield f-12-4)
3930 (encoding (+ (f-12-4 #xE) (.sym BitBase16- offset -u16)))
3931 (ifield-assertion (eq f-12-4 #xE))
3932 (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16)))
3933 (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16) newval))
3935 (define-derived-operand
3936 (name (.sym bit16- offset -8-FB-relative))
3937 (comment (.str "m16c dsp:8[fb] relative bit " xmode))
3938 (attrs (machine 16))
3940 (args ((.sym BitBase16- offset -s8)))
3941 (syntax (.str "${BitBase16-" offset "-s8}[fb]"))
3942 (base-ifield f-12-4)
3943 (encoding (+ (f-12-4 #xB) (.sym BitBase16- offset -s8)))
3944 (ifield-assertion (eq f-12-4 #xB))
3945 (getter (get-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8)))
3946 (setter (set-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8) newval))
3948 (define-derived-operand
3949 (name (.sym bit16- offset -8-An-relative))
3950 (comment (.str "m16c dsp:8[An] relative bit " xmode))
3951 (attrs (machine 16))
3953 (args (Bit16An (.sym Dsp- offset -u8)))
3954 (syntax (.str "${Dsp-" offset "-u8}[$Bit16An]"))
3955 (base-ifield f-12-4)
3956 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Bit16An))
3957 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3958 (getter (get-memory-bit 16 (.sym Dsp- offset -u8) Bit16An))
3959 (setter (set-memory-bit 16 (.sym Dsp- offset -u8) Bit16An newval))
3961 (define-derived-operand
3962 (name (.sym bit16- offset -16-An-relative))
3963 (comment (.str "m16c dsp:16[An] relative bit " xmode))
3964 (attrs (machine 16))
3966 (args (Bit16An (.sym Dsp- offset -u16)))
3967 (syntax (.str "${Dsp-" offset "-u16}[$Bit16An]"))
3968 (base-ifield f-12-4)
3969 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Bit16An))
3970 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3971 (getter (get-memory-bit 16 (.sym Dsp- offset -u16) Bit16An))
3972 (setter (set-memory-bit 16 (.sym Dsp- offset -u16) Bit16An newval))
3977 (bit16-relative-operand 16)
3979 (define-pmacro (bit32-relative-operand offset group base1 base2)
3981 (define-derived-operand
3982 (name (.sym bit32- offset -11-SB-relative- group))
3983 (comment "m32c bit,base:11[sb] relative bit")
3984 (attrs (machine 32))
3986 (args ((.sym BitBase32- offset -u11- group)))
3987 (syntax (.str "${BitBase32-" offset "-u11-" group "}[sb]"))
3988 (base-ifield (.sym f- base1 -12))
3989 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u11- group)))
3990 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
3991 (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group)))
3992 (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group) newval))
3994 (define-derived-operand
3995 (name (.sym bit32- offset -19-SB-relative- group))
3996 (comment "m32c bit,base:19[sb] relative bit")
3997 (attrs (machine 32))
3999 (args ((.sym BitBase32- offset -u19- group)))
4000 (syntax (.str "${BitBase32-" offset "-u19-" group "}[sb]"))
4001 (base-ifield (.sym f- base1 -12))
4002 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u19- group)))
4003 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
4004 (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group)))
4005 (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group) newval))
4007 (define-derived-operand
4008 (name (.sym bit32- offset -11-FB-relative- group))
4009 (comment "m32c bit,base:11[fb] relative bit")
4010 (attrs (machine 32))
4012 (args ((.sym BitBase32- offset -s11- group)))
4013 (syntax (.str "${BitBase32-" offset "-s11-" group "}[fb]"))
4014 (base-ifield (.sym f- base1 -12))
4015 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s11- group)))
4016 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
4017 (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group)))
4018 (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group) newval))
4020 (define-derived-operand
4021 (name (.sym bit32- offset -19-FB-relative- group))
4022 (comment "m32c bit,base:19[fb] relative bit")
4023 (attrs (machine 32))
4025 (args ((.sym BitBase32- offset -s19- group)))
4026 (syntax (.str "${BitBase32-" offset "-s19-" group "}[fb]"))
4027 (base-ifield (.sym f- base1 -12))
4028 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s19- group)))
4029 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
4030 (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group)))
4031 (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group) newval))
4033 (define-derived-operand
4034 (name (.sym bit32- offset -11-An-relative- group))
4035 (comment "m32c bit,base:11[An] relative bit")
4036 (attrs (machine 32))
4038 (args ((.sym BitBase32- offset -u11- group) (.sym Bit32An group)))
4039 (syntax (.str "${BitBase32-" offset "-u11-" group "}[$Bit32An" group "]"))
4040 (base-ifield (.sym f- base1 -12))
4041 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u11- group) (.sym Bit32An group)))
4042 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
4043 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group)))
4044 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group) newval))
4046 (define-derived-operand
4047 (name (.sym bit32- offset -19-An-relative- group))
4048 (comment "m32c bit,base:19[An] relative bit")
4049 (attrs (machine 32))
4051 (args ((.sym BitBase32- offset -u19- group) (.sym Bit32An group)))
4052 (syntax (.str "${BitBase32-" offset "-u19-" group "}[$Bit32An" group "]"))
4053 (base-ifield (.sym f- base1 -12))
4054 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u19- group) (.sym Bit32An group)))
4055 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
4056 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group)))
4057 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group) newval))
4059 (define-derived-operand
4060 (name (.sym bit32- offset -27-An-relative- group))
4061 (comment "m32c bit,base:27[An] relative bit")
4062 (attrs (machine 32))
4064 (args ((.sym BitBase32- offset -u27- group) (.sym Bit32An group)))
4065 (syntax (.str "${BitBase32-" offset "-u27-" group "}[$Bit32An" group "]"))
4066 (base-ifield (.sym f- base1 -12))
4067 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u27- group) (.sym Bit32An group)))
4068 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
4069 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group)))
4070 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group) newval))
4075 (bit32-relative-operand 16 Unprefixed 4 8)
4076 (bit32-relative-operand 24 Prefixed 12 16)
4078 (define-derived-operand
4079 (name bit16-11-SB-relative-S)
4080 (comment "m16c bit,base:11[sb] relative bit")
4081 (attrs (machine 16))
4083 (args (BitBase16-8-u11-S))
4084 (syntax "${BitBase16-8-u11-S}[sb]")
4085 (base-ifield (.sym f-5-3))
4086 (encoding (+ BitBase16-8-u11-S))
4087 ; (ifield-assertion (#t))
4088 (getter (get-memory-bit 16 (reg h-sb) BitBase16-8-u11-S))
4089 (setter (set-memory-bit 16 (reg h-sb) BitBase16-8-u11-S newval))
4092 (define-derived-operand
4093 (name Rn16-push-S-derived)
4094 (comment "m16c r0[lh] for push,pop short version")
4095 (attrs (machine 16))
4097 (args (Rn16-push-S))
4098 (syntax "${Rn16-push-S}")
4099 (base-ifield (.sym f-4-1))
4100 (encoding (+ Rn16-push-S))
4101 ; (ifield-assertion (#t))
4102 (getter (trunc QI Rn16-push-S))
4103 (setter (set Rn16-push-S newval))
4106 (define-derived-operand
4107 (name An16-push-S-derived)
4108 (comment "m16c r0[lh] for push,pop short version")
4109 (attrs (machine 16))
4111 (args (An16-push-S))
4112 (syntax "${An16-push-S}")
4113 (base-ifield (.sym f-4-1))
4114 (encoding (+ An16-push-S))
4115 ; (ifield-assertion (#t))
4116 (getter (trunc QI An16-push-S))
4117 (setter (set An16-push-S newval))
4120 ;-------------------------------------------------------------
4122 ;-------------------------------------------------------------
4124 (define-pmacro (bit16-absolute offset)
4126 (define-derived-operand
4127 (name (.sym bit16- offset -16-absolute))
4128 (comment "m16c absolute address")
4129 (attrs (machine 16))
4131 (args ((.sym BitBase16- offset -u16)))
4132 (syntax (.str "${BitBase16-" offset "-u16}"))
4133 (base-ifield f-12-4)
4134 (encoding (+ (f-12-4 #xF) (.sym BitBase16- offset -u16)))
4135 (ifield-assertion (eq f-12-4 #xF))
4136 (getter (get-memory-bit 16 0 (.sym BitBase16- offset -u16)))
4137 (setter (set-memory-bit 16 0 (.sym BitBase16- offset -u16) newval))
4144 (define-pmacro (bit32-absolute offset group base1 base2)
4146 (define-derived-operand
4147 (name (.sym bit32- offset -19-absolute- group))
4148 (comment "m32c absolute address bit")
4149 (attrs (machine 32))
4151 (args ((.sym BitBase32- offset -u19- group)))
4152 (syntax (.str "${BitBase32-" offset "-u19-" group "}"))
4153 (base-ifield (.sym f- base1 -12))
4154 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -u19- group)))
4155 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
4156 (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u19- group)))
4157 (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u19- group) newval))
4159 (define-derived-operand
4160 (name (.sym bit32- offset -27-absolute- group))
4161 (comment "m32c absolute address bit")
4162 (attrs (machine 32))
4164 (args ((.sym BitBase32- offset -u27- group)))
4165 (syntax (.str "${BitBase32-" offset "-u27-" group "}"))
4166 (base-ifield (.sym f- base1 -12))
4167 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u27- group)))
4168 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
4169 (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u27- group)))
4170 (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u27- group) newval))
4175 (bit32-absolute 16 Unprefixed 4 8)
4176 (bit32-absolute 24 Prefixed 12 16)
4178 ;-------------------------------------------------------------
4179 ; Destination operands for short fomat insns
4180 ;-------------------------------------------------------------
4182 (define-derived-operand
4183 (name dst16-3-S-R0l-direct-QI)
4184 (comment "m16c R0l direct QI")
4185 (attrs (machine 16))
4190 (encoding (+ (f-5-3 4)))
4191 (ifield-assertion (eq f-5-3 4))
4192 (getter (trunc QI R0l))
4193 (setter (set R0l newval))
4195 (define-derived-operand
4196 (name dst16-3-S-R0h-direct-QI)
4197 (comment "m16c R0h direct QI")
4198 (attrs (machine 16))
4203 (encoding (+ (f-5-3 3)))
4204 (ifield-assertion (eq f-5-3 3))
4205 (getter (trunc QI R0h))
4206 (setter (set R0h newval))
4208 (define-derived-operand
4209 (name dst16-3-S-8-8-SB-relative-QI)
4210 (comment "m16c SB relative QI")
4211 (attrs (machine 16))
4214 (syntax "${Dsp-8-u8}[sb]")
4216 (encoding (+ (f-5-3 5) Dsp-8-u8))
4217 (ifield-assertion (eq f-5-3 5))
4218 (getter (mem16 QI (add Dsp-8-u8 (reg h-sb))))
4219 (setter (set (mem16 QI (add Dsp-8-u8 (reg h-sb))) newval))
4221 (define-derived-operand
4222 (name dst16-3-S-8-8-FB-relative-QI)
4223 (comment "m16c FB relative QI")
4224 (attrs (machine 16))
4227 (syntax "${Dsp-8-s8}[fb]")
4229 (encoding (+ (f-5-3 6) Dsp-8-s8))
4230 (ifield-assertion (eq f-5-3 6))
4231 (getter (mem16 QI (add Dsp-8-s8 (reg h-fb))))
4232 (setter (set (mem16 QI (add Dsp-8-s8 (reg h-fb))) newval))
4234 (define-derived-operand
4235 (name dst16-3-S-8-16-absolute-QI)
4236 (comment "m16c absolute address QI")
4237 (attrs (machine 16))
4240 (syntax "${Dsp-8-u16}")
4242 (encoding (+ (f-5-3 7) Dsp-8-u16))
4243 (ifield-assertion (eq f-5-3 7))
4244 (getter (mem16 QI Dsp-8-u16))
4245 (setter (set (mem16 QI Dsp-8-u16) newval))
4247 (define-derived-operand
4248 (name dst16-3-S-16-8-SB-relative-QI)
4249 (comment "m16c SB relative QI")
4250 (attrs (machine 16))
4253 (syntax "${Dsp-16-u8}[sb]")
4255 (encoding (+ (f-5-3 5) Dsp-16-u8))
4256 (ifield-assertion (eq f-5-3 5))
4257 (getter (mem16 QI (add Dsp-16-u8 (reg h-sb))))
4258 (setter (set (mem16 QI (add Dsp-16-u8 (reg h-sb))) newval))
4260 (define-derived-operand
4261 (name dst16-3-S-16-8-FB-relative-QI)
4262 (comment "m16c FB relative QI")
4263 (attrs (machine 16))
4266 (syntax "${Dsp-16-s8}[fb]")
4268 (encoding (+ (f-5-3 6) Dsp-16-s8))
4269 (ifield-assertion (eq f-5-3 6))
4270 (getter (mem16 QI (add Dsp-16-s8 (reg h-fb))))
4271 (setter (set (mem16 QI (add Dsp-16-s8 (reg h-fb))) newval))
4273 (define-derived-operand
4274 (name dst16-3-S-16-16-absolute-QI)
4275 (comment "m16c absolute address QI")
4276 (attrs (machine 16))
4279 (syntax "${Dsp-16-u16}")
4281 (encoding (+ (f-5-3 7) Dsp-16-u16))
4282 (ifield-assertion (eq f-5-3 7))
4283 (getter (mem16 QI Dsp-16-u16))
4284 (setter (set (mem16 QI Dsp-16-u16) newval))
4286 (define-derived-operand
4287 (name srcdst16-r0l-r0h-S-derived)
4288 (comment "m16c r0l/r0h operand for short format insns")
4289 (attrs (machine 16))
4291 (args (SrcDst16-r0l-r0h-S-normal))
4292 (syntax "${SrcDst16-r0l-r0h-S-normal}")
4294 (encoding (+ (f-6-2 0) SrcDst16-r0l-r0h-S-normal))
4295 (ifield-assertion (eq f-6-2 0))
4296 (getter (trunc SI SrcDst16-r0l-r0h-S-normal))
4297 (setter ()) ; no setter
4299 (define-derived-operand
4300 (name dst32-2-S-R0l-direct-QI)
4301 (comment "m32c R0l direct QI")
4302 (attrs (machine 32))
4307 (encoding (+ (f-2-2 0)))
4308 (ifield-assertion (eq f-2-2 0))
4309 (getter (trunc QI R0l))
4310 (setter (set R0l newval))
4312 (define-derived-operand
4313 (name dst32-2-S-R0-direct-HI)
4314 (comment "m32c R0 direct HI")
4315 (attrs (machine 32))
4320 (encoding (+ (f-2-2 0)))
4321 (ifield-assertion (eq f-2-2 0))
4322 (getter (trunc HI R0))
4323 (setter (set R0 newval))
4325 (define-derived-operand
4326 (name dst32-1-S-A0-direct-HI)
4327 (comment "m32c A0 direct HI")
4328 (attrs (machine 32))
4333 (encoding (+ (f-7-1 0)))
4334 (ifield-assertion (eq f-7-1 0))
4335 (getter (trunc HI A0))
4336 (setter (set A0 newval))
4338 (define-derived-operand
4339 (name dst32-1-S-A1-direct-HI)
4340 (comment "m32c A1 direct HI")
4341 (attrs (machine 32))
4346 (encoding (+ (f-7-1 1)))
4347 (ifield-assertion (eq f-7-1 1))
4348 (getter (trunc HI A1))
4349 (setter (set A1 newval))
4351 (define-pmacro (dst32-2-S-operands xmode)
4353 (define-derived-operand
4354 (name (.sym dst32-2-S-8-SB-relative- xmode))
4355 (comment "m32c SB relative for short binary insns")
4356 (attrs (machine 32))
4359 (syntax "${Dsp-8-u8}[sb]")
4361 (encoding (+ (f-2-2 2) Dsp-8-u8))
4362 (ifield-assertion (eq f-2-2 2))
4363 (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8))
4364 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8))
4365 ; (getter (mem32 xmode (add Dsp-8-u8 (reg h-sb))))
4366 ; (setter (set (mem32 xmode (add Dsp-8-u8 (reg h-sb))) newval))
4368 (define-derived-operand
4369 (name (.sym dst32-2-S-8-FB-relative- xmode))
4370 (comment "m32c FB relative for short binary insns")
4371 (attrs (machine 32))
4374 (syntax "${Dsp-8-s8}[fb]")
4376 (encoding (+ (f-2-2 3) Dsp-8-s8))
4377 (ifield-assertion (eq f-2-2 3))
4378 (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8))
4379 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8))
4380 ; (getter (mem32 xmode (add Dsp-8-s8 (reg h-fb))))
4381 ; (setter (set (mem32 xmode (add Dsp-8-s8 (reg h-fb))) newval))
4383 (define-derived-operand
4384 (name (.sym dst32-2-S-16-absolute- xmode))
4385 (comment "m32c absolute address for short binary insns")
4386 (attrs (machine 32))
4389 (syntax "${Dsp-8-u16}")
4391 (encoding (+ (f-2-2 1) Dsp-8-u16))
4392 (ifield-assertion (eq f-2-2 1))
4393 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16))
4394 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16))
4395 ; (getter (mem32 xmode Dsp-8-u16))
4396 ; (setter (set (mem32 xmode Dsp-8-u16) newval))
4398 ; (define-derived-operand
4399 ; (name (.sym dst32-2-S-8-SB-relative-indirect- xmode))
4400 ; (comment "m32c SB relative for short binary insns")
4401 ; (attrs (machine 32))
4403 ; (args (Dsp-16-u8))
4404 ; (syntax "[${Dsp-16-u8}[sb]]")
4405 ; (base-ifield f-10-2)
4406 ; (encoding (+ (f-10-2 2) Dsp-16-u8))
4407 ; (ifield-assertion (eq f-10-2 2))
4408 ; (getter (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb)))))
4409 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb)))) newval))
4411 ; (define-derived-operand
4412 ; (name (.sym dst32-2-S-8-FB-relative-indirect- xmode))
4413 ; (comment "m32c FB relative for short binary insns")
4414 ; (attrs (machine 32))
4416 ; (args (Dsp-16-s8))
4417 ; (syntax "[${Dsp-16-s8}[fb]]")
4418 ; (base-ifield f-10-2)
4419 ; (encoding (+ (f-10-2 3) Dsp-16-s8))
4420 ; (ifield-assertion (eq f-10-2 3))
4421 ; (getter (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb)))))
4422 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb)))) newval))
4424 ; (define-derived-operand
4425 ; (name (.sym dst32-2-S-16-absolute-indirect- xmode))
4426 ; (comment "m32c absolute address for short binary insns")
4427 ; (attrs (machine 32))
4429 ; (args (Dsp-16-u16))
4430 ; (syntax "[${Dsp-16-u16}]")
4431 ; (base-ifield f-10-2)
4432 ; (encoding (+ (f-10-2 1) Dsp-16-u16))
4433 ; (ifield-assertion (eq f-10-2 1))
4434 ; (getter (mem32 xmode (indirect-addr Dsp-16-u16)))
4435 ; (setter (set (mem32 xmode (indirect-addr Dsp-16-u16)) newval))
4440 (dst32-2-S-operands QI)
4441 (dst32-2-S-operands HI)
4442 (dst32-2-S-operands SI)
4444 ;=============================================================
4446 ;-------------------------------------------------------------
4447 ; Source operands with no additional fields
4448 ;-------------------------------------------------------------
4450 (define-pmacro (src16-basic-operand xmode)
4452 (define-anyof-operand
4453 (name (.sym src16-basic- xmode))
4454 (comment (.str "m16c source operand of size " xmode " with no additional fields"))
4455 (attrs (machine 16))
4458 (.sym src16-Rn-direct- xmode)
4459 (.sym src16-An-direct- xmode)
4460 (.sym src16-An-indirect- xmode)
4465 (src16-basic-operand QI)
4466 (src16-basic-operand HI)
4468 (define-pmacro (src32-basic-operand xmode)
4470 (define-anyof-operand
4471 (name (.sym src32-basic-Unprefixed- xmode))
4472 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4473 (attrs (machine 32))
4476 (.sym src32-Rn-direct-Unprefixed- xmode)
4477 (.sym src32-An-direct-Unprefixed- xmode)
4478 (.sym src32-An-indirect-Unprefixed- xmode)
4481 (define-anyof-operand
4482 (name (.sym src32-basic-Prefixed- xmode))
4483 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4484 (attrs (machine 32))
4487 (.sym src32-Rn-direct-Prefixed- xmode)
4488 (.sym src32-An-direct-Prefixed- xmode)
4489 (.sym src32-An-indirect-Prefixed- xmode)
4492 ; (define-anyof-operand
4493 ; (name (.sym src32-basic-indirect- xmode))
4494 ; (comment (.str "m32c destination operand of size " xmode " indirect with no additional fields"))
4495 ; (attrs (machine 32))
4498 ; (.sym src32-An-indirect-indirect- xmode)
4504 (src32-basic-operand QI)
4505 (src32-basic-operand HI)
4506 (src32-basic-operand SI)
4508 (define-anyof-operand
4509 (name src32-basic-ExtPrefixed-QI)
4510 (comment "m32c source operand of size QI with no additional fields")
4511 (attrs (machine 32))
4514 src32-Rn-direct-Prefixed-QI
4515 src32-An-indirect-Prefixed-QI
4519 ;-------------------------------------------------------------
4520 ; Source operands with additional fields at offset 16 bits
4521 ;-------------------------------------------------------------
4523 (define-pmacro (src16-16-operand xmode)
4525 (define-anyof-operand
4526 (name (.sym src16-16-8- xmode))
4527 (comment (.str "m16c source operand of size " xmode " with additional 8 bit fields at offset 16"))
4528 (attrs (machine 16))
4531 (.sym src16-16-8-An-relative- xmode)
4532 (.sym src16-16-8-SB-relative- xmode)
4533 (.sym src16-16-8-FB-relative- xmode)
4536 (define-anyof-operand
4537 (name (.sym src16-16-16- xmode))
4538 (comment (.str "m16c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4539 (attrs (machine 16))
4542 (.sym src16-16-16-An-relative- xmode)
4543 (.sym src16-16-16-SB-relative- xmode)
4544 (.sym src16-16-16-absolute- xmode)
4549 (src16-16-operand QI)
4550 (src16-16-operand HI)
4552 (define-pmacro (src32-16-operand xmode)
4554 (define-anyof-operand
4555 (name (.sym src32-16-8-Unprefixed- xmode))
4556 (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 16"))
4557 (attrs (machine 32))
4560 (.sym src32-16-8-An-relative-Unprefixed- xmode)
4561 (.sym src32-16-8-SB-relative-Unprefixed- xmode)
4562 (.sym src32-16-8-FB-relative-Unprefixed- xmode)
4565 (define-anyof-operand
4566 (name (.sym src32-16-16-Unprefixed- xmode))
4567 (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4568 (attrs (machine 32))
4571 (.sym src32-16-16-An-relative-Unprefixed- xmode)
4572 (.sym src32-16-16-SB-relative-Unprefixed- xmode)
4573 (.sym src32-16-16-FB-relative-Unprefixed- xmode)
4574 (.sym src32-16-16-absolute-Unprefixed- xmode)
4577 (define-anyof-operand
4578 (name (.sym src32-16-24-Unprefixed- xmode))
4579 (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16"))
4580 (attrs (machine 32))
4583 (.sym src32-16-24-An-relative-Unprefixed- xmode)
4584 (.sym src32-16-24-absolute-Unprefixed- xmode)
4590 (src32-16-operand QI)
4591 (src32-16-operand HI)
4592 (src32-16-operand SI)
4594 ;-------------------------------------------------------------
4595 ; Source operands with additional fields at offset 24 bits
4596 ;-------------------------------------------------------------
4598 (define-pmacro (src-24-operand group xmode)
4600 (define-anyof-operand
4601 (name (.sym src32-24-8- group - xmode))
4602 (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 24"))
4603 (attrs (machine 32))
4606 (.sym src32-24-8-An-relative- group - xmode)
4607 (.sym src32-24-8-SB-relative- group - xmode)
4608 (.sym src32-24-8-FB-relative- group - xmode)
4611 (define-anyof-operand
4612 (name (.sym src32-24-16- group - xmode))
4613 (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4614 (attrs (machine 32))
4617 (.sym src32-24-16-An-relative- group - xmode)
4618 (.sym src32-24-16-SB-relative- group - xmode)
4619 (.sym src32-24-16-FB-relative- group - xmode)
4620 (.sym src32-24-16-absolute- group - xmode)
4623 (define-anyof-operand
4624 (name (.sym src32-24-24- group - xmode))
4625 (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16"))
4626 (attrs (machine 32))
4629 (.sym src32-24-24-An-relative- group - xmode)
4630 (.sym src32-24-24-absolute- group - xmode)
4636 (src-24-operand Prefixed QI)
4637 (src-24-operand Prefixed HI)
4638 (src-24-operand Prefixed SI)
4640 (define-pmacro (src-24-indirect-operand xmode)
4642 ; (define-anyof-operand
4643 ; (name (.sym src32-24-8-indirect- xmode))
4644 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4645 ; (attrs (machine 32))
4648 ; (.sym src32-24-8-An-relative-indirect- xmode)
4649 ; (.sym src32-24-8-SB-relative-indirect- xmode)
4650 ; (.sym src32-24-8-FB-relative-indirect- xmode)
4653 ; (define-anyof-operand
4654 ; (name (.sym src32-24-16-indirect- xmode))
4655 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4656 ; (attrs (machine 32))
4659 ; (.sym src32-24-16-An-relative-indirect- xmode)
4660 ; (.sym src32-24-16-SB-relative-indirect- xmode)
4661 ; (.sym src32-24-16-FB-relative-indirect- xmode)
4664 ; (define-anyof-operand
4665 ; (name (.sym src32-24-24-indirect- xmode))
4666 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4667 ; (attrs (machine 32))
4670 ; (.sym src32-24-24-An-relative-indirect- xmode)
4673 ; (define-anyof-operand
4674 ; (name (.sym src32-24-16-absolute-indirect- xmode))
4675 ; (comment (.str "m32c source operand of size " xmode " 16 bit absolute indirect"))
4676 ; (attrs (machine 32))
4679 ; (.sym src32-24-16-absolute-indirect-derived- xmode)
4682 ; (define-anyof-operand
4683 ; (name (.sym src32-24-24-absolute-indirect- xmode))
4684 ; (comment (.str "m32c source operand of size " xmode " 24 bit absolute indirect"))
4685 ; (attrs (machine 32))
4688 ; (.sym src32-24-24-absolute-indirect-derived- xmode)
4694 ; (src-24-indirect-operand QI)
4695 ; (src-24-indirect-operand HI)
4696 ; (src-24-indirect-operand SI)
4698 ;-------------------------------------------------------------
4699 ; Destination operands with no additional fields
4700 ;-------------------------------------------------------------
4702 (define-pmacro (dst16-basic-operand xmode)
4704 (define-anyof-operand
4705 (name (.sym dst16-basic- xmode))
4706 (comment (.str "m16c destination operand of size " xmode " with no additional fields"))
4707 (attrs (machine 16))
4710 (.sym dst16-Rn-direct- xmode)
4711 (.sym dst16-An-direct- xmode)
4712 (.sym dst16-An-indirect- xmode)
4718 (dst16-basic-operand QI)
4719 (dst16-basic-operand HI)
4720 (dst16-basic-operand SI)
4722 (define-pmacro (dst32-basic-operand xmode)
4724 (define-anyof-operand
4725 (name (.sym dst32-basic-Unprefixed- xmode))
4726 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4727 (attrs (machine 32))
4730 (.sym dst32-Rn-direct-Unprefixed- xmode)
4731 (.sym dst32-An-direct-Unprefixed- xmode)
4732 (.sym dst32-An-indirect-Unprefixed- xmode)
4735 (define-anyof-operand
4736 (name (.sym dst32-basic-Prefixed- xmode))
4737 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4738 (attrs (machine 32))
4741 (.sym dst32-Rn-direct-Prefixed- xmode)
4742 (.sym dst32-An-direct-Prefixed- xmode)
4743 (.sym dst32-An-indirect-Prefixed- xmode)
4749 (dst32-basic-operand QI)
4750 (dst32-basic-operand HI)
4751 (dst32-basic-operand SI)
4753 ;-------------------------------------------------------------
4754 ; Destination operands with possible additional fields at offset 16 bits
4755 ;-------------------------------------------------------------
4757 (define-pmacro (dst16-16-operand xmode)
4759 (define-anyof-operand
4760 (name (.sym dst16-16- xmode))
4761 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4762 (attrs (machine 16))
4765 (.sym dst16-Rn-direct- xmode)
4766 (.sym dst16-An-direct- xmode)
4767 (.sym dst16-An-indirect- xmode)
4768 (.sym dst16-16-8-An-relative- xmode)
4769 (.sym dst16-16-16-An-relative- xmode)
4770 (.sym dst16-16-8-SB-relative- xmode)
4771 (.sym dst16-16-16-SB-relative- xmode)
4772 (.sym dst16-16-8-FB-relative- xmode)
4773 (.sym dst16-16-16-absolute- xmode)
4776 (define-anyof-operand
4777 (name (.sym dst16-16-8- xmode))
4778 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4779 (attrs (machine 16))
4782 (.sym dst16-16-8-An-relative- xmode)
4783 (.sym dst16-16-8-SB-relative- xmode)
4784 (.sym dst16-16-8-FB-relative- xmode)
4787 (define-anyof-operand
4788 (name (.sym dst16-16-16- xmode))
4789 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4790 (attrs (machine 16))
4793 (.sym dst16-16-16-An-relative- xmode)
4794 (.sym dst16-16-16-SB-relative- xmode)
4795 (.sym dst16-16-16-absolute- xmode)
4798 (define-anyof-operand
4799 (name (.sym dst16-16-16sa- xmode))
4800 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4801 (attrs (machine 16))
4804 (.sym dst16-16-16-SB-relative- xmode)
4805 (.sym dst16-16-16-absolute- xmode)
4808 (define-anyof-operand
4809 (name (.sym dst16-16-20ar- xmode))
4810 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4811 (attrs (machine 16))
4814 (.sym dst16-16-20-An-relative- xmode)
4820 (dst16-16-operand QI)
4821 (dst16-16-operand HI)
4822 (dst16-16-operand SI)
4824 (define-anyof-operand
4825 (name dst16-16-Ext-QI)
4826 (comment "m16c destination operand of size QI for 'ext' insns with additional fields at offset 16")
4827 (attrs (machine 16))
4830 dst16-Rn-direct-Ext-QI
4831 dst16-An-indirect-Ext-QI
4832 dst16-16-8-An-relative-Ext-QI
4833 dst16-16-16-An-relative-Ext-QI
4834 dst16-16-8-SB-relative-Ext-QI
4835 dst16-16-16-SB-relative-Ext-QI
4836 dst16-16-8-FB-relative-Ext-QI
4837 dst16-16-16-absolute-Ext-QI
4841 (define-derived-operand
4842 (name dst16-An-indirect-Mova-HI)
4843 (comment "m16c addressof An indirect destination HI")
4847 (syntax "[$Dst16An]")
4848 (base-ifield f-12-4)
4849 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
4851 (andif (eq f-12-2 1) (eq f-14-1 1)))
4856 (define-derived-operand
4857 (name dst16-16-8-An-relative-Mova-HI)
4859 "m16c addressof dsp:8[An] relative destination HI")
4862 (args (Dst16An Dsp-16-u8))
4863 (syntax "${Dsp-16-u8}[$Dst16An]")
4864 (base-ifield f-12-4)
4866 (+ (f-12-2 2) (f-14-1 0) Dsp-16-u8 Dst16An))
4868 (andif (eq f-12-2 2) (eq f-14-1 0)))
4869 (getter (add Dsp-16-u8 Dst16An))
4872 (define-derived-operand
4873 (name dst16-16-16-An-relative-Mova-HI)
4875 "m16c addressof dsp:16[An] relative destination HI")
4878 (args (Dst16An Dsp-16-u16))
4879 (syntax "${Dsp-16-u16}[$Dst16An]")
4880 (base-ifield f-12-4)
4882 (+ (f-12-2 3) (f-14-1 0) Dsp-16-u16 Dst16An))
4884 (andif (eq f-12-2 3) (eq f-14-1 0)))
4885 (getter (add Dsp-16-u16 Dst16An))
4888 (define-derived-operand
4889 (name dst16-16-8-SB-relative-Mova-HI)
4891 "m16c addressof dsp:8[sb] relative destination HI")
4895 (syntax "${Dsp-16-u8}[sb]")
4896 (base-ifield f-12-4)
4897 (encoding (+ (f-12-4 10) Dsp-16-u8))
4898 (ifield-assertion (eq f-12-4 10))
4899 (getter (add Dsp-16-u8 (reg h-sb)))
4902 (define-derived-operand
4903 (name dst16-16-16-SB-relative-Mova-HI)
4905 "m16c addressof dsp:16[sb] relative destination HI")
4909 (syntax "${Dsp-16-u16}[sb]")
4910 (base-ifield f-12-4)
4911 (encoding (+ (f-12-4 14) Dsp-16-u16))
4912 (ifield-assertion (eq f-12-4 14))
4913 (getter (add Dsp-16-u16 (reg h-sb)))
4916 (define-derived-operand
4917 (name dst16-16-8-FB-relative-Mova-HI)
4919 "m16c addressof dsp:8[fb] relative destination HI")
4923 (syntax "${Dsp-16-s8}[fb]")
4924 (base-ifield f-12-4)
4925 (encoding (+ (f-12-4 11) Dsp-16-s8))
4926 (ifield-assertion (eq f-12-4 11))
4927 (getter (add Dsp-16-s8 (reg h-fb)))
4930 (define-derived-operand
4931 (name dst16-16-16-absolute-Mova-HI)
4932 (comment "m16c addressof absolute address HI")
4936 (syntax "${Dsp-16-u16}")
4937 (base-ifield f-12-4)
4938 (encoding (+ (f-12-4 15) Dsp-16-u16))
4939 (ifield-assertion (eq f-12-4 15))
4944 (define-anyof-operand
4945 (name dst16-16-Mova-HI)
4946 (comment "m16c addressof destination operand of size HI with additional fields at offset 16")
4947 (attrs (machine 16))
4950 dst16-An-indirect-Mova-HI
4951 dst16-16-8-An-relative-Mova-HI
4952 dst16-16-16-An-relative-Mova-HI
4953 dst16-16-8-SB-relative-Mova-HI
4954 dst16-16-16-SB-relative-Mova-HI
4955 dst16-16-8-FB-relative-Mova-HI
4956 dst16-16-16-absolute-Mova-HI
4960 (define-derived-operand
4961 (name dst32-An-indirect-Unprefixed-Mova-SI)
4962 (comment "m32c addressof An indirect destination SI")
4965 (args (Dst32AnUnprefixed))
4966 (syntax "[$Dst32AnUnprefixed]")
4969 (+ (f-4-3 0) (f-8-1 0) Dst32AnUnprefixed))
4971 (andif (eq f-4-3 0) (eq f-8-1 0)))
4972 (getter Dst32AnUnprefixed)
4976 (define-derived-operand
4977 (name dst32-16-8-An-relative-Unprefixed-Mova-SI)
4978 (comment "m32c addressof dsp:8[An] relative destination SI")
4981 (args (Dst32AnUnprefixed Dsp-16-u8))
4982 (syntax "${Dsp-16-u8}[$Dst32AnUnprefixed]")
4990 (andif (eq f-4-3 1) (eq f-8-1 0)))
4991 (getter (add Dsp-16-u8 Dst32AnUnprefixed))
4995 (define-derived-operand
4996 (name dst32-16-16-An-relative-Unprefixed-Mova-SI)
4998 "m32c addressof dsp:16[An] relative destination SI")
5001 (args (Dst32AnUnprefixed Dsp-16-u16))
5002 (syntax "${Dsp-16-u16}[$Dst32AnUnprefixed]")
5010 (andif (eq f-4-3 2) (eq f-8-1 0)))
5011 (getter (add Dsp-16-u16 Dst32AnUnprefixed))
5015 (define-derived-operand
5016 (name dst32-16-24-An-relative-Unprefixed-Mova-SI)
5017 (comment "addressof m32c dsp:16[An] relative destination SI")
5020 (args (Dst32AnUnprefixed Dsp-16-u24))
5021 (syntax "${Dsp-16-u24}[$Dst32AnUnprefixed]")
5029 (andif (eq f-4-3 3) (eq f-8-1 0)))
5030 (getter (add Dsp-16-u24 Dst32AnUnprefixed))
5034 (define-derived-operand
5035 (name dst32-16-8-SB-relative-Unprefixed-Mova-SI)
5036 (comment "m32c addressof dsp:8[sb] relative destination SI")
5040 (syntax "${Dsp-16-u8}[sb]")
5042 (encoding (+ (f-4-3 1) (f-8-2 2) Dsp-16-u8))
5044 (andif (eq f-4-3 1) (eq f-8-2 2)))
5045 (getter (add Dsp-16-u8 (reg h-sb)))
5049 (define-derived-operand
5050 (name dst32-16-16-SB-relative-Unprefixed-Mova-SI)
5051 (comment "m32c addressof dsp:16[sb] relative destination SI")
5055 (syntax "${Dsp-16-u16}[sb]")
5057 (encoding (+ (f-4-3 2) (f-8-2 2) Dsp-16-u16))
5059 (andif (eq f-4-3 2) (eq f-8-2 2)))
5060 (getter (add Dsp-16-u16 (reg h-sb)))
5064 (define-derived-operand
5065 (name dst32-16-8-FB-relative-Unprefixed-Mova-SI)
5066 (comment "m32c addressof dsp:8[fb] relative destination SI")
5070 (syntax "${Dsp-16-s8}[fb]")
5072 (encoding (+ (f-4-3 1) (f-8-2 3) Dsp-16-s8))
5074 (andif (eq f-4-3 1) (eq f-8-2 3)))
5075 (getter (add Dsp-16-s8 (reg h-fb)))
5079 (define-derived-operand
5080 (name dst32-16-16-FB-relative-Unprefixed-Mova-SI)
5081 (comment "m32c addressof dsp:16[fb] relative destination SI")
5085 (syntax "${Dsp-16-s16}[fb]")
5087 (encoding (+ (f-4-3 2) (f-8-2 3) Dsp-16-s16))
5089 (andif (eq f-4-3 2) (eq f-8-2 3)))
5090 (getter (add Dsp-16-s16 (reg h-fb)))
5094 (define-derived-operand
5095 (name dst32-16-16-absolute-Unprefixed-Mova-SI)
5096 (comment "m32c addressof absolute address SI") (attrs (ISA m32c))
5099 (syntax "${Dsp-16-u16}")
5101 (encoding (+ (f-4-3 3) (f-8-2 3) Dsp-16-u16))
5103 (andif (eq f-4-3 3) (eq f-8-2 3)))
5108 (define-derived-operand
5109 (name dst32-16-24-absolute-Unprefixed-Mova-SI)
5110 (comment "m32c addressof absolute address SI") (attrs (ISA m32c))
5113 (syntax "${Dsp-16-u24}")
5115 (encoding (+ (f-4-3 3) (f-8-2 2) Dsp-16-u24))
5117 (andif (eq f-4-3 3) (eq f-8-2 2)))
5122 (define-anyof-operand
5123 (name dst32-16-Unprefixed-Mova-SI)
5125 "m32c addressof destination operand of size SI with additional fields at offset 16")
5129 dst32-An-indirect-Unprefixed-Mova-SI
5130 dst32-16-8-An-relative-Unprefixed-Mova-SI
5131 dst32-16-16-An-relative-Unprefixed-Mova-SI
5132 dst32-16-24-An-relative-Unprefixed-Mova-SI
5133 dst32-16-8-SB-relative-Unprefixed-Mova-SI
5134 dst32-16-16-SB-relative-Unprefixed-Mova-SI
5135 dst32-16-8-FB-relative-Unprefixed-Mova-SI
5136 dst32-16-16-FB-relative-Unprefixed-Mova-SI
5137 dst32-16-16-absolute-Unprefixed-Mova-SI
5138 dst32-16-24-absolute-Unprefixed-Mova-SI))
5140 (define-pmacro (dst32-16-operand xmode)
5142 (define-anyof-operand
5143 (name (.sym dst32-16-Unprefixed- xmode))
5144 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5145 (attrs (machine 32))
5148 (.sym dst32-Rn-direct-Unprefixed- xmode)
5149 (.sym dst32-An-direct-Unprefixed- xmode)
5150 (.sym dst32-An-indirect-Unprefixed- xmode)
5151 (.sym dst32-16-8-An-relative-Unprefixed- xmode)
5152 (.sym dst32-16-16-An-relative-Unprefixed- xmode)
5153 (.sym dst32-16-24-An-relative-Unprefixed- xmode)
5154 (.sym dst32-16-8-SB-relative-Unprefixed- xmode)
5155 (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
5156 (.sym dst32-16-8-FB-relative-Unprefixed- xmode)
5157 (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
5158 (.sym dst32-16-16-absolute-Unprefixed- xmode)
5159 (.sym dst32-16-24-absolute-Unprefixed- xmode)
5162 (define-anyof-operand
5163 (name (.sym dst32-16-8-Unprefixed- xmode))
5164 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5165 (attrs (machine 32))
5168 (.sym dst32-16-8-An-relative-Unprefixed- xmode)
5169 (.sym dst32-16-8-SB-relative-Unprefixed- xmode)
5170 (.sym dst32-16-8-FB-relative-Unprefixed- xmode)
5173 (define-anyof-operand
5174 (name (.sym dst32-16-16-Unprefixed- xmode))
5175 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5176 (attrs (machine 32))
5179 (.sym dst32-16-16-An-relative-Unprefixed- xmode)
5180 (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
5181 (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
5182 (.sym dst32-16-16-absolute-Unprefixed- xmode)
5185 (define-anyof-operand
5186 (name (.sym dst32-16-16sa-Unprefixed- xmode))
5187 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5188 (attrs (machine 32))
5191 (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
5192 (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
5193 (.sym dst32-16-16-absolute-Unprefixed- xmode)
5196 (define-anyof-operand
5197 (name (.sym dst32-16-24-Unprefixed- xmode))
5198 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5199 (attrs (machine 32))
5202 (.sym dst32-16-24-An-relative-Unprefixed- xmode)
5203 (.sym dst32-16-24-absolute-Unprefixed- xmode)
5209 (dst32-16-operand QI)
5210 (dst32-16-operand HI)
5211 (dst32-16-operand SI)
5213 (define-pmacro (dst32-16-Ext-operand smode dmode)
5215 (define-anyof-operand
5216 (name (.sym dst32-16-ExtUnprefixed- smode))
5217 (comment (.str "m32c destination operand of size " smode " with additional fields at offset 16"))
5218 (attrs (machine 32))
5221 (.sym dst32-Rn-direct-ExtUnprefixed- smode)
5222 (.sym dst32-An-direct-Unprefixed- dmode) ; ExtUnprefixed mode not required for this operand -- use the normal dmode version
5223 (.sym dst32-An-indirect-ExtUnprefixed- smode)
5224 (.sym dst32-16-8-An-relative-ExtUnprefixed- smode)
5225 (.sym dst32-16-16-An-relative-ExtUnprefixed- smode)
5226 (.sym dst32-16-24-An-relative-ExtUnprefixed- smode)
5227 (.sym dst32-16-8-SB-relative-ExtUnprefixed- smode)
5228 (.sym dst32-16-16-SB-relative-ExtUnprefixed- smode)
5229 (.sym dst32-16-8-FB-relative-ExtUnprefixed- smode)
5230 (.sym dst32-16-16-FB-relative-ExtUnprefixed- smode)
5231 (.sym dst32-16-16-absolute-ExtUnprefixed- smode)
5232 (.sym dst32-16-24-absolute-ExtUnprefixed- smode)
5238 (dst32-16-Ext-operand QI HI)
5239 (dst32-16-Ext-operand HI SI)
5241 (define-anyof-operand
5242 (name dst32-16-Unprefixed-Mulex-HI)
5243 (comment "m32c destination operand of size HI with additional fields at offset 16")
5244 (attrs (machine 32))
5247 dst32-R3-direct-Unprefixed-HI
5248 dst32-An-direct-Unprefixed-HI
5249 dst32-An-indirect-Unprefixed-HI
5250 dst32-16-8-An-relative-Unprefixed-HI
5251 dst32-16-16-An-relative-Unprefixed-HI
5252 dst32-16-24-An-relative-Unprefixed-HI
5253 dst32-16-8-SB-relative-Unprefixed-HI
5254 dst32-16-16-SB-relative-Unprefixed-HI
5255 dst32-16-8-FB-relative-Unprefixed-HI
5256 dst32-16-16-FB-relative-Unprefixed-HI
5257 dst32-16-16-absolute-Unprefixed-HI
5258 dst32-16-24-absolute-Unprefixed-HI
5261 ;-------------------------------------------------------------
5262 ; Destination operands with possible additional fields at offset 24 bits
5263 ;-------------------------------------------------------------
5265 (define-pmacro (dst16-24-operand xmode)
5267 (define-anyof-operand
5268 (name (.sym dst16-24- xmode))
5269 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 24"))
5270 (attrs (machine 16))
5273 (.sym dst16-Rn-direct- xmode)
5274 (.sym dst16-An-direct- xmode)
5275 (.sym dst16-An-indirect- xmode)
5276 (.sym dst16-24-8-An-relative- xmode)
5277 (.sym dst16-24-16-An-relative- xmode)
5278 (.sym dst16-24-8-SB-relative- xmode)
5279 (.sym dst16-24-16-SB-relative- xmode)
5280 (.sym dst16-24-8-FB-relative- xmode)
5281 (.sym dst16-24-16-absolute- xmode)
5287 (dst16-24-operand QI)
5288 (dst16-24-operand HI)
5290 (define-pmacro (dst32-24-operand xmode)
5292 (define-anyof-operand
5293 (name (.sym dst32-24-Unprefixed- xmode))
5294 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5295 (attrs (machine 32))
5298 (.sym dst32-Rn-direct-Unprefixed- xmode)
5299 (.sym dst32-An-direct-Unprefixed- xmode)
5300 (.sym dst32-An-indirect-Unprefixed- xmode)
5301 (.sym dst32-24-8-An-relative-Unprefixed- xmode)
5302 (.sym dst32-24-16-An-relative-Unprefixed- xmode)
5303 (.sym dst32-24-24-An-relative-Unprefixed- xmode)
5304 (.sym dst32-24-8-SB-relative-Unprefixed- xmode)
5305 (.sym dst32-24-16-SB-relative-Unprefixed- xmode)
5306 (.sym dst32-24-8-FB-relative-Unprefixed- xmode)
5307 (.sym dst32-24-16-FB-relative-Unprefixed- xmode)
5308 (.sym dst32-24-16-absolute-Unprefixed- xmode)
5309 (.sym dst32-24-24-absolute-Unprefixed- xmode)
5312 (define-anyof-operand
5313 (name (.sym dst32-24-Prefixed- xmode))
5314 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5315 (attrs (machine 32))
5318 (.sym dst32-Rn-direct-Prefixed- xmode)
5319 (.sym dst32-An-direct-Prefixed- xmode)
5320 (.sym dst32-An-indirect-Prefixed- xmode)
5321 (.sym dst32-24-8-An-relative-Prefixed- xmode)
5322 (.sym dst32-24-16-An-relative-Prefixed- xmode)
5323 (.sym dst32-24-24-An-relative-Prefixed- xmode)
5324 (.sym dst32-24-8-SB-relative-Prefixed- xmode)
5325 (.sym dst32-24-16-SB-relative-Prefixed- xmode)
5326 (.sym dst32-24-8-FB-relative-Prefixed- xmode)
5327 (.sym dst32-24-16-FB-relative-Prefixed- xmode)
5328 (.sym dst32-24-16-absolute-Prefixed- xmode)
5329 (.sym dst32-24-24-absolute-Prefixed- xmode)
5332 (define-anyof-operand
5333 (name (.sym dst32-24-8-Prefixed- xmode))
5334 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5335 (attrs (machine 32))
5338 (.sym dst32-24-8-An-relative-Prefixed- xmode)
5339 (.sym dst32-24-8-SB-relative-Prefixed- xmode)
5340 (.sym dst32-24-8-FB-relative-Prefixed- xmode)
5343 (define-anyof-operand
5344 (name (.sym dst32-24-16-Prefixed- xmode))
5345 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5346 (attrs (machine 32))
5349 (.sym dst32-24-16-An-relative-Prefixed- xmode)
5350 (.sym dst32-24-16-SB-relative-Prefixed- xmode)
5351 (.sym dst32-24-16-FB-relative-Prefixed- xmode)
5352 (.sym dst32-24-16-absolute-Prefixed- xmode)
5355 (define-anyof-operand
5356 (name (.sym dst32-24-24-Prefixed- xmode))
5357 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5358 (attrs (machine 32))
5361 (.sym dst32-24-24-An-relative-Prefixed- xmode)
5362 (.sym dst32-24-24-absolute-Prefixed- xmode)
5365 ; (define-anyof-operand
5366 ; (name (.sym dst32-24-indirect- xmode))
5367 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5368 ; (attrs (machine 32))
5371 ; (.sym dst32-An-indirect-indirect- xmode)
5372 ; (.sym dst32-24-8-An-relative-indirect- xmode)
5373 ; (.sym dst32-24-16-An-relative-indirect- xmode)
5374 ; (.sym dst32-24-24-An-relative-indirect- xmode)
5375 ; (.sym dst32-24-8-SB-relative-indirect- xmode)
5376 ; (.sym dst32-24-16-SB-relative-indirect- xmode)
5377 ; (.sym dst32-24-8-FB-relative-indirect- xmode)
5378 ; (.sym dst32-24-16-FB-relative-indirect- xmode)
5381 ; (define-anyof-operand
5382 ; (name (.sym dst32-basic-indirect- xmode))
5383 ; (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
5384 ; (attrs (machine 32))
5387 ; (.sym dst32-An-indirect-indirect- xmode)
5390 ; (define-anyof-operand
5391 ; (name (.sym dst32-24-8-indirect- xmode))
5392 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5393 ; (attrs (machine 32))
5396 ; (.sym dst32-24-8-An-relative-indirect- xmode)
5397 ; (.sym dst32-24-8-SB-relative-indirect- xmode)
5398 ; (.sym dst32-24-8-FB-relative-indirect- xmode)
5401 ; (define-anyof-operand
5402 ; (name (.sym dst32-24-16-indirect- xmode))
5403 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5404 ; (attrs (machine 32))
5407 ; (.sym dst32-24-16-An-relative-indirect- xmode)
5408 ; (.sym dst32-24-16-SB-relative-indirect- xmode)
5409 ; (.sym dst32-24-16-FB-relative-indirect- xmode)
5412 ; (define-anyof-operand
5413 ; (name (.sym dst32-24-24-indirect- xmode))
5414 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5415 ; (attrs (machine 32))
5418 ; (.sym dst32-24-24-An-relative-indirect- xmode)
5421 ; (define-anyof-operand
5422 ; (name (.sym dst32-24-absolute-indirect- xmode))
5423 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5424 ; (attrs (machine 32))
5427 ; (.sym dst32-24-16-absolute-indirect-derived- xmode)
5428 ; (.sym dst32-24-24-absolute-indirect-derived- xmode)
5431 ; (define-anyof-operand
5432 ; (name (.sym dst32-24-16-absolute-indirect- xmode))
5433 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5434 ; (attrs (machine 32))
5437 ; (.sym dst32-24-16-absolute-indirect-derived- xmode)
5440 ; (define-anyof-operand
5441 ; (name (.sym dst32-24-24-absolute-indirect- xmode))
5442 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5443 ; (attrs (machine 32))
5446 ; (.sym dst32-24-24-absolute-indirect-derived- xmode)
5452 (dst32-24-operand QI)
5453 (dst32-24-operand HI)
5454 (dst32-24-operand SI)
5456 ;-------------------------------------------------------------
5457 ; Destination operands with possible additional fields at offset 32 bits
5458 ;-------------------------------------------------------------
5460 (define-pmacro (dst16-32-operand xmode)
5462 (define-anyof-operand
5463 (name (.sym dst16-32- xmode))
5464 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 32"))
5465 (attrs (machine 16))
5468 (.sym dst16-Rn-direct- xmode)
5469 (.sym dst16-An-direct- xmode)
5470 (.sym dst16-An-indirect- xmode)
5471 (.sym dst16-32-8-An-relative- xmode)
5472 (.sym dst16-32-16-An-relative- xmode)
5473 (.sym dst16-32-8-SB-relative- xmode)
5474 (.sym dst16-32-16-SB-relative- xmode)
5475 (.sym dst16-32-8-FB-relative- xmode)
5476 (.sym dst16-32-16-absolute- xmode)
5481 (dst16-32-operand QI)
5482 (dst16-32-operand HI)
5484 ; This macro actually handles operands at offset 32, 40 and 48 bits
5485 (define-pmacro (dst32-32plus-operand offset xmode)
5487 (define-anyof-operand
5488 (name (.sym dst32- offset -Unprefixed- xmode))
5489 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5490 (attrs (machine 32))
5493 (.sym dst32-Rn-direct-Unprefixed- xmode)
5494 (.sym dst32-An-direct-Unprefixed- xmode)
5495 (.sym dst32-An-indirect-Unprefixed- xmode)
5496 (.sym dst32- offset -8-An-relative-Unprefixed- xmode)
5497 (.sym dst32- offset -16-An-relative-Unprefixed- xmode)
5498 (.sym dst32- offset -24-An-relative-Unprefixed- xmode)
5499 (.sym dst32- offset -8-SB-relative-Unprefixed- xmode)
5500 (.sym dst32- offset -16-SB-relative-Unprefixed- xmode)
5501 (.sym dst32- offset -8-FB-relative-Unprefixed- xmode)
5502 (.sym dst32- offset -16-FB-relative-Unprefixed- xmode)
5503 (.sym dst32- offset -16-absolute-Unprefixed- xmode)
5504 (.sym dst32- offset -24-absolute-Unprefixed- xmode)
5507 (define-anyof-operand
5508 (name (.sym dst32- offset -Prefixed- xmode))
5509 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5510 (attrs (machine 32))
5513 (.sym dst32-Rn-direct-Prefixed- xmode)
5514 (.sym dst32-An-direct-Prefixed- xmode)
5515 (.sym dst32-An-indirect-Prefixed- xmode)
5516 (.sym dst32- offset -8-An-relative-Prefixed- xmode)
5517 (.sym dst32- offset -16-An-relative-Prefixed- xmode)
5518 (.sym dst32- offset -24-An-relative-Prefixed- xmode)
5519 (.sym dst32- offset -8-SB-relative-Prefixed- xmode)
5520 (.sym dst32- offset -16-SB-relative-Prefixed- xmode)
5521 (.sym dst32- offset -8-FB-relative-Prefixed- xmode)
5522 (.sym dst32- offset -16-FB-relative-Prefixed- xmode)
5523 (.sym dst32- offset -16-absolute-Prefixed- xmode)
5524 (.sym dst32- offset -24-absolute-Prefixed- xmode)
5527 ; (define-anyof-operand
5528 ; (name (.sym dst32- offset -indirect- xmode))
5529 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5530 ; (attrs (machine 32))
5533 ; (.sym dst32-An-indirect-indirect- xmode)
5534 ; (.sym dst32- offset -8-An-relative-indirect- xmode)
5535 ; (.sym dst32- offset -16-An-relative-indirect- xmode)
5536 ; (.sym dst32- offset -24-An-relative-indirect- xmode)
5537 ; (.sym dst32- offset -8-SB-relative-indirect- xmode)
5538 ; (.sym dst32- offset -16-SB-relative-indirect- xmode)
5539 ; (.sym dst32- offset -8-FB-relative-indirect- xmode)
5540 ; (.sym dst32- offset -16-FB-relative-indirect- xmode)
5543 ; (define-anyof-operand
5544 ; (name (.sym dst32- offset -absolute-indirect- xmode))
5545 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5546 ; (attrs (machine 32))
5549 ; (.sym dst32- offset -16-absolute-indirect-derived- xmode)
5550 ; (.sym dst32- offset -24-absolute-indirect-derived- xmode)
5556 (dst32-32plus-operand 32 QI)
5557 (dst32-32plus-operand 32 HI)
5558 (dst32-32plus-operand 32 SI)
5559 (dst32-32plus-operand 40 QI)
5560 (dst32-32plus-operand 40 HI)
5561 (dst32-32plus-operand 40 SI)
5563 ;-------------------------------------------------------------
5564 ; Destination operands with possible additional fields at offset 48 bits
5565 ;-------------------------------------------------------------
5567 (define-pmacro (dst32-48-operand offset xmode)
5569 (define-anyof-operand
5570 (name (.sym dst32- offset -Prefixed- xmode))
5571 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5572 (attrs (machine 32))
5575 (.sym dst32-Rn-direct-Prefixed- xmode)
5576 (.sym dst32-An-direct-Prefixed- xmode)
5577 (.sym dst32-An-indirect-Prefixed- xmode)
5578 (.sym dst32- offset -8-An-relative-Prefixed- xmode)
5579 (.sym dst32- offset -16-An-relative-Prefixed- xmode)
5580 (.sym dst32- offset -24-An-relative-Prefixed- xmode)
5581 (.sym dst32- offset -8-SB-relative-Prefixed- xmode)
5582 (.sym dst32- offset -16-SB-relative-Prefixed- xmode)
5583 (.sym dst32- offset -8-FB-relative-Prefixed- xmode)
5584 (.sym dst32- offset -16-FB-relative-Prefixed- xmode)
5585 (.sym dst32- offset -16-absolute-Prefixed- xmode)
5586 (.sym dst32- offset -24-absolute-Prefixed- xmode)
5589 ; (define-anyof-operand
5590 ; (name (.sym dst32- offset -indirect- xmode))
5591 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5592 ; (attrs (machine 32))
5595 ; (.sym dst32-An-indirect-indirect- xmode)
5596 ; (.sym dst32- offset -8-An-relative-indirect- xmode)
5597 ; (.sym dst32- offset -16-An-relative-indirect- xmode)
5598 ; (.sym dst32- offset -24-An-relative-indirect- xmode)
5599 ; (.sym dst32- offset -8-SB-relative-indirect- xmode)
5600 ; (.sym dst32- offset -16-SB-relative-indirect- xmode)
5601 ; (.sym dst32- offset -8-FB-relative-indirect- xmode)
5602 ; (.sym dst32- offset -16-FB-relative-indirect- xmode)
5605 ; (define-anyof-operand
5606 ; (name (.sym dst32- offset -absolute-indirect- xmode))
5607 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5608 ; (attrs (machine 32))
5611 ; (.sym dst32- offset -16-absolute-indirect-derived- xmode)
5612 ; (.sym dst32- offset -24-absolute-indirect-derived- xmode)
5618 (dst32-48-operand 48 QI)
5619 (dst32-48-operand 48 HI)
5620 (dst32-48-operand 48 SI)
5622 ;-------------------------------------------------------------
5623 ; Bit operands for m16c
5624 ;-------------------------------------------------------------
5626 (define-pmacro (bit16-operand offset)
5628 (define-anyof-operand
5629 (name (.sym bit16- offset))
5630 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5631 (attrs (machine 16))
5637 (.sym bit16- offset -8-An-relative)
5638 (.sym bit16- offset -16-An-relative)
5639 (.sym bit16- offset -8-SB-relative)
5640 (.sym bit16- offset -16-SB-relative)
5641 (.sym bit16- offset -8-FB-relative)
5642 (.sym bit16- offset -16-absolute)
5645 (define-anyof-operand
5646 (name (.sym bit16- offset -basic))
5647 (comment (.str "m16c bit operand with no additional fields"))
5648 (attrs (machine 16))
5654 (define-anyof-operand
5655 (name (.sym bit16- offset -8))
5656 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5657 (attrs (machine 16))
5662 (.sym bit16- offset -8-An-relative)
5663 (.sym bit16- offset -8-SB-relative)
5664 (.sym bit16- offset -8-FB-relative)
5667 (define-anyof-operand
5668 (name (.sym bit16- offset -16))
5669 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5670 (attrs (machine 16))
5673 (.sym bit16- offset -16-An-relative)
5674 (.sym bit16- offset -16-SB-relative)
5675 (.sym bit16- offset -16-absolute)
5683 ;-------------------------------------------------------------
5684 ; Bit operands for m32c
5685 ;-------------------------------------------------------------
5687 (define-pmacro (bit32-operand offset group)
5689 (define-anyof-operand
5690 (name (.sym bit32- offset - group))
5691 (comment (.str "m32c bit operand with possible additional fields at offset 24"))
5692 (attrs (machine 32))
5695 (.sym bit32-Rn-direct- group)
5696 (.sym bit32-An-direct- group)
5697 (.sym bit32-An-indirect- group)
5698 (.sym bit32- offset -11-An-relative- group)
5699 (.sym bit32- offset -19-An-relative- group)
5700 (.sym bit32- offset -27-An-relative- group)
5701 (.sym bit32- offset -11-SB-relative- group)
5702 (.sym bit32- offset -19-SB-relative- group)
5703 (.sym bit32- offset -11-FB-relative- group)
5704 (.sym bit32- offset -19-FB-relative- group)
5705 (.sym bit32- offset -19-absolute- group)
5706 (.sym bit32- offset -27-absolute- group)
5712 (bit32-operand 16 Unprefixed)
5713 (bit32-operand 24 Prefixed)
5715 (define-anyof-operand
5716 (name bit32-basic-Unprefixed)
5717 (comment "m32c bit operand with no additional fields")
5718 (attrs (machine 32))
5721 bit32-Rn-direct-Unprefixed
5722 bit32-An-direct-Unprefixed
5723 bit32-An-indirect-Unprefixed
5727 (define-anyof-operand
5728 (name bit32-16-8-Unprefixed)
5729 (comment "m32c bit operand with 8 bit additional fields")
5730 (attrs (machine 32))
5733 bit32-16-11-An-relative-Unprefixed
5734 bit32-16-11-SB-relative-Unprefixed
5735 bit32-16-11-FB-relative-Unprefixed
5739 (define-anyof-operand
5740 (name bit32-16-16-Unprefixed)
5741 (comment "m32c bit operand with 16 bit additional fields")
5742 (attrs (machine 32))
5745 bit32-16-19-An-relative-Unprefixed
5746 bit32-16-19-SB-relative-Unprefixed
5747 bit32-16-19-FB-relative-Unprefixed
5748 bit32-16-19-absolute-Unprefixed
5752 (define-anyof-operand
5753 (name bit32-16-24-Unprefixed)
5754 (comment "m32c bit operand with 24 bit additional fields")
5755 (attrs (machine 32))
5758 bit32-16-27-An-relative-Unprefixed
5759 bit32-16-27-absolute-Unprefixed
5763 ;-------------------------------------------------------------
5764 ; Operands for short format binary insns
5765 ;-------------------------------------------------------------
5767 (define-anyof-operand
5769 (comment "m16c source operand of size QI for short format insns")
5770 (attrs (machine 16))
5773 src16-2-S-8-SB-relative-QI
5774 src16-2-S-8-FB-relative-QI
5775 src16-2-S-16-absolute-QI
5779 (define-anyof-operand
5781 (comment "m32c source operand of size QI for short format insns")
5782 (attrs (machine 32))
5785 src32-2-S-8-SB-relative-QI
5786 src32-2-S-8-FB-relative-QI
5787 src32-2-S-16-absolute-QI
5791 (define-anyof-operand
5793 (comment "m32c source operand of size QI for short format insns")
5794 (attrs (machine 32))
5797 src32-2-S-8-SB-relative-HI
5798 src32-2-S-8-FB-relative-HI
5799 src32-2-S-16-absolute-HI
5803 (define-anyof-operand
5805 (comment "m16c destination operand of size QI for short format insns")
5806 (attrs (machine 16))
5809 dst16-3-S-R0l-direct-QI
5810 dst16-3-S-R0h-direct-QI
5811 dst16-3-S-8-8-SB-relative-QI
5812 dst16-3-S-8-8-FB-relative-QI
5813 dst16-3-S-8-16-absolute-QI
5817 (define-anyof-operand
5819 (comment "m16c destination operand of size QI for short format insns")
5820 (attrs (machine 16))
5823 dst16-3-S-R0l-direct-QI
5824 dst16-3-S-R0h-direct-QI
5825 dst16-3-S-16-8-SB-relative-QI
5826 dst16-3-S-16-8-FB-relative-QI
5827 dst16-3-S-16-16-absolute-QI
5831 (define-anyof-operand
5832 (name srcdst16-r0l-r0h-S)
5833 (comment "m16c r0l/r0h operand of size QI for short format insns")
5834 (attrs (machine 16))
5837 srcdst16-r0l-r0h-S-derived
5841 (define-anyof-operand
5842 (name dst32-2-S-basic-QI)
5843 (comment "m32c r0l operand of size QI for short format binary insns")
5844 (attrs (machine 32))
5847 dst32-2-S-R0l-direct-QI
5851 (define-anyof-operand
5852 (name dst32-2-S-basic-HI)
5853 (comment "m32c r0 operand of size HI for short format binary insns")
5854 (attrs (machine 32))
5857 dst32-2-S-R0-direct-HI
5861 (define-pmacro (dst32-2-S-operands xmode)
5863 (define-anyof-operand
5864 (name (.sym dst32-2-S-8- xmode))
5865 (comment "m32c operand of size " xmode " for short format binary insns")
5866 (attrs (machine 32))
5869 (.sym dst32-2-S-8-SB-relative- xmode)
5870 (.sym dst32-2-S-8-FB-relative- xmode)
5873 (define-anyof-operand
5874 (name (.sym dst32-2-S-16- xmode))
5875 (comment "m32c operand of size " xmode " for short format binary insns")
5876 (attrs (machine 32))
5879 (.sym dst32-2-S-16-absolute- xmode)
5882 ; (define-anyof-operand
5883 ; (name (.sym dst32-2-S-8-indirect- xmode))
5884 ; (comment "m32c operand of size " xmode " for short format binary insns")
5885 ; (attrs (machine 32))
5888 ; (.sym dst32-2-S-8-SB-relative-indirect- xmode)
5889 ; (.sym dst32-2-S-8-FB-relative-indirect- xmode)
5892 ; (define-anyof-operand
5893 ; (name (.sym dst32-2-S-absolute-indirect- xmode))
5894 ; (comment "m32c operand of size " xmode " for short format binary insns")
5895 ; (attrs (machine 32))
5898 ; (.sym dst32-2-S-16-absolute-indirect- xmode)
5904 (dst32-2-S-operands QI)
5905 (dst32-2-S-operands HI)
5906 (dst32-2-S-operands SI)
5908 (define-anyof-operand
5910 (comment "m32c An operand for short format binary insns")
5911 (attrs (machine 32))
5914 dst32-1-S-A0-direct-HI
5915 dst32-1-S-A1-direct-HI
5919 (define-anyof-operand
5921 (comment "m16c bit operand for short format insns")
5922 (attrs (machine 16))
5925 bit16-11-SB-relative-S
5929 (define-anyof-operand
5930 (name Rn16-push-S-anyof)
5931 (comment "m16c bit operand for short format insns")
5932 (attrs (machine 16))
5939 (define-anyof-operand
5940 (name An16-push-S-anyof)
5941 (comment "m16c bit operand for short format insns")
5942 (attrs (machine 16))
5949 ;=============================================================
5950 ; Common macros for instruction definitions
5952 (define-pmacro (set-z x)
5954 (set zbit (zflag x)))
5958 (define-pmacro (set-s x)
5960 (set sbit (nflag x)))
5963 (define-pmacro (set-z-and-s x)
5969 ;=============================================================
5971 ;-------------------------------------------------------------
5973 (define-pmacro (unary-insn-defn-g mach group mode wstr op encoding sem opg)
5974 (dni (.sym op mach wstr - group)
5975 (.str op wstr opg " dst" mach "-" group "-" mode)
5976 ((machine mach) RL_1ADDR)
5977 (.str op wstr opg " ${dst" mach "-" group "-" mode "}")
5979 (sem mode (.sym dst mach - group - mode))
5983 (define-pmacro (unary-insn-defn mach group mode wstr op encoding sem)
5984 (unary-insn-defn-g mach group mode wstr op encoding sem "")
5988 (define-pmacro (unary16-defn-g mode wstr wbit op opc1 opc2 opc3 sem opg)
5989 (unary-insn-defn-g 16 16 mode wstr op
5990 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16- mode))
5993 (define-pmacro (unary16-defn mode wstr wbit op opc1 opc2 opc3 sem)
5994 (unary-16-defn-g mode wstr wbit op opc1 opc2 opc3 sem "")
5997 (define-pmacro (unary32-defn-g mode wstr wbit op opc1 opc2 opc3 sem opg)
5999 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6000 ; define the absolute-indirect insns first in order to prevent them from being selected
6001 ; when the mode is register-indirect
6002 ; (unary-insn-defn 32 24-absolute-indirect mode wstr op
6003 ; (+ (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))
6005 (unary-insn-defn-g 32 16-Unprefixed mode wstr op
6006 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3))
6008 ; (unary-insn-defn 32 24-indirect mode wstr op
6009 ; (+ (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))
6013 (define-pmacro (unary32-defn mode wstr wbit op opc1 opc2 opc3 sem)
6014 (unary32-defn-g mode wstr wbit op opc1 opc2 opc3 sem "")
6017 (define-pmacro (unary-insn-mach-g mach op opc1 opc2 opc3 sem opg)
6019 (.apply (.sym unary mach -defn-g) (QI .b 0 op opc1 opc2 opc3 sem opg))
6020 (.apply (.sym unary mach -defn-g) (HI .w 1 op opc1 opc2 opc3 sem opg))
6023 (define-pmacro (unary-insn-mach mach op opc1 opc2 opc3 sem)
6024 (unary-insn-mach-g mach op opc1 opc2 opc3 sem "")
6027 (define-pmacro (unary-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6029 (unary-insn-mach-g 16 op opc16-1 opc16-2 opc16-3 sem "")
6030 (unary-insn-mach-g 32 op opc32-1 opc32-2 opc32-3 sem "")
6034 (define-pmacro (unary-insn-g op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6036 (unary-insn-mach-g 16 op opc16-1 opc16-2 opc16-3 sem "$G")
6037 (unary-insn-mach-g 32 op opc32-1 opc32-2 opc32-3 sem "$G")
6041 ;-------------------------------------------------------------
6042 ; Sign/zero extension macros
6043 ;-------------------------------------------------------------
6045 (define-pmacro (ext-insn-defn mach group smode dmode wstr op encoding sem)
6046 (dni (.sym op mach wstr - group)
6047 (.str op wstr " dst" mach "-" group "-" smode)
6049 (.str op wstr " ${dst" mach "-" group "-" smode "}")
6051 (sem smode dmode (.sym dst mach - group - smode) (.sym dst mach - group - smode))
6055 (define-pmacro (ext16-defn smode dmode wstr wbit op opc1 opc2 opc3 sem)
6056 (ext-insn-defn 16 16-Ext smode dmode wstr op
6057 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-Ext- smode))
6061 (define-pmacro (ext32-defn smode dmode wstr wbit op opc1 opc2 opc3 sem)
6062 (ext-insn-defn 32 16-ExtUnprefixed smode dmode wstr op
6063 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst32-16-ExtUnprefixed- smode))
6067 (define-pmacro (ext32-binary-insn src-group dst-group op wstr encoding sem)
6068 (dni (.sym op 32 wstr - src-group - dst-group)
6069 (.str op 32 wstr " src32-" src-group "-QI,dst32-" dst-group "-HI")
6071 (.str op wstr " ${src32-" src-group "-QI},${dst32-" dst-group "-HI}")
6073 (sem QI HI (.sym src32- src-group -QI) (.sym dst32 - dst-group -HI))
6077 (define-pmacro (ext32-binary-defn op wstr opc1 opc2 sem)
6079 (ext32-binary-insn basic-ExtPrefixed 24-Prefixed op wstr
6080 (+ (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))
6082 (ext32-binary-insn 24-24-Prefixed 48-Prefixed op wstr
6083 (+ (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))
6085 (ext32-binary-insn 24-16-Prefixed 40-Prefixed op wstr
6086 (+ (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))
6088 (ext32-binary-insn 24-8-Prefixed 32-Prefixed op wstr
6089 (+ (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))
6094 ;=============================================================
6095 ; Binary Arithmetic macros
6097 ;-------------------------------------------------------------
6098 ;<arith>.size:S src2,r0[l] -- for m32c
6099 ;-------------------------------------------------------------
6101 (define-pmacro (binary-arith32-S-src2 op xmode wstr wbit opc1 opc2 sem)
6102 (dni (.sym op 32 wstr .S-src2-r0- xmode)
6103 (.str op 32 wstr ":S src2,r0[l]")
6105 (.str op wstr"$S ${src32-2-S-" xmode "},${Dst32R0" xmode "-S}")
6106 (+ opc1 opc2 (.sym src32-2-S- xmode) (f-7-1 wbit))
6107 (sem xmode (.sym src32-2-S- xmode) (.sym Dst32R0 xmode -S))
6111 ;-------------------------------------------------------------
6112 ;<arith>.b:S src2,r0l/r0h -- for m16c
6113 ;-------------------------------------------------------------
6115 (define-pmacro (binary-arith16-b-S-src2 op opc1 opc2 sem)
6117 (dni (.sym op 16 .b.S-src2)
6118 (.str op ".b:S src2,r0[lh]")
6120 (.str op ".b$S ${src16-2-S},${Dst16RnQI-S}")
6121 (+ opc1 opc2 Dst16RnQI-S src16-2-S)
6122 (sem QI src16-2-S Dst16RnQI-S)
6124 (dni (.sym op 16 .b.S-r0l-r0h)
6125 (.str op ".b:S r0l/r0h")
6127 (.str op ".b$S ${srcdst16-r0l-r0h-S}")
6128 (+ opc1 opc2 srcdst16-r0l-r0h-S)
6129 (if (eq srcdst16-r0l-r0h-S 0)
6136 ;-------------------------------------------------------------
6137 ;<arith>.b:S #imm8,dst3 -- for m16c
6138 ;-------------------------------------------------------------
6140 (define-pmacro (binary-arith16-b-S-imm8-dst3 op sz opc1 opc2 sem)
6141 (dni (.sym op 16 .b.S-imm8-dst3)
6142 (.str op sz ":S imm8,dst3")
6144 (.str op sz "$S #${Imm-8-QI},${Dst16-3-S-16}")
6145 (+ opc1 opc2 Dst16-3-S-16 Imm-8-QI)
6146 (sem QI Imm-8-QI Dst16-3-S-16)
6150 ;-------------------------------------------------------------
6151 ;<arith>.size:Q #imm4,sp -- for m16c
6152 ;-------------------------------------------------------------
6154 (define-pmacro (binary-arith16-Q-sp op opc1 opc2 opc3 sem)
6155 (dni (.sym op 16 -wQ-sp)
6156 (.str op ".w:q #imm4,sp")
6158 (.str op ".w$Q #${Imm-12-s4},sp")
6159 (+ opc1 opc2 opc3 Imm-12-s4)
6160 (sem QI Imm-12-s4 sp)
6164 ;-------------------------------------------------------------
6165 ;<arith>.size:G #imm,sp -- for m16c
6166 ;-------------------------------------------------------------
6168 (define-pmacro (binary-arith16-G-sp-defn mode wstr wbit op opc1 opc2 opc3 opc4 sem)
6169 (dni (.sym op 16 wstr - G-sp)
6170 (.str op wstr " imm-sp " mode)
6172 (.str op wstr "$G #${Imm-16-" mode "},sp")
6173 (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16- mode))
6174 (sem mode (.sym Imm-16- mode) sp)
6178 (define-pmacro (binary-arith16-G-sp op opc1 opc2 opc3 opc4 sem)
6180 (binary-arith16-G-sp-defn QI .b 0 op opc1 opc2 opc3 opc4 sem)
6181 (binary-arith16-G-sp-defn HI .w 1 op opc1 opc2 opc3 opc4 sem)
6185 ;-------------------------------------------------------------
6186 ;<arith>.size:G #imm,dst -- for m16c and m32c
6187 ;-------------------------------------------------------------
6189 (define-pmacro (binary-arith-imm-dst-defn mach src dstgroup dmode wstr op suffix encoding sem)
6190 (dni (.sym op mach wstr - imm-G - dstgroup)
6191 (.str op wstr " " mach "-imm-G-" dstgroup "-" dmode)
6192 ((machine mach) RL_1ADDR)
6193 (.str op wstr "$"suffix " #${" src "},${dst" mach "-" dstgroup "-" dmode "}")
6195 (sem dmode src (.sym dst mach - dstgroup - dmode))
6200 (define-pmacro (binary-arith16-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6202 (binary-arith-imm-dst-defn 16 (.sym Imm-32- smode) 16-16 dmode wstr op suffix
6203 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- dmode) (.sym Imm-32- smode))
6205 (binary-arith-imm-dst-defn 16 (.sym Imm-24- smode) 16-8 dmode wstr op suffix
6206 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- dmode) (.sym Imm-24- smode))
6208 (binary-arith-imm-dst-defn 16 (.sym Imm-16- smode) basic dmode wstr op suffix
6209 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- dmode) (.sym Imm-16- smode))
6214 ; m32c Unprefixed variants
6215 (define-pmacro (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6217 (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 16-24-Unprefixed dmode wstr op suffix
6218 (+ (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))
6220 (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 16-16-Unprefixed dmode wstr op suffix
6221 (+ (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))
6223 (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) 16-8-Unprefixed dmode wstr op suffix
6224 (+ (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))
6226 (binary-arith-imm-dst-defn 32 (.sym Imm-16- smode) basic-Unprefixed dmode wstr op suffix
6227 (+ (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))
6232 ; m32c Prefixed variants
6233 (define-pmacro (binary-arith32-imm-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6235 (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-Prefixed dmode wstr op suffix
6236 (+ (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))
6238 (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-Prefixed dmode wstr op suffix
6239 (+ (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))
6241 (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-Prefixed dmode wstr op suffix
6242 (+ (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))
6244 (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-Prefixed dmode wstr op suffix
6245 (+ (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))
6251 (define-pmacro (binary-arith32-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6253 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6254 ; define the absolute-indirect insns first in order to prevent them from being selected
6255 ; when the mode is register-indirect
6256 ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-absolute-indirect dmode wstr op suffix
6257 ; (+ (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))
6259 ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-absolute-indirect dmode wstr op suffix
6260 ; (+ (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))
6262 ; Unprefixed modes next
6263 (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6265 ; Remaining indirect modes
6266 ; (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-indirect dmode wstr op suffix
6267 ; (+ (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))
6269 ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-indirect dmode wstr op suffix
6270 ; (+ (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))
6272 ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-indirect dmode wstr op suffix
6273 ; (+ (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))
6275 ; (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-indirect dmode wstr op suffix
6276 ; (+ (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))
6281 (define-pmacro (binary-arith-imm-dst-mach mach op suffix opc1 opc2 opc3 sem)
6283 (.apply (.sym binary-arith mach -imm-dst-defn) (QI QI .b 0 op suffix opc1 opc2 opc3 sem))
6284 (.apply (.sym binary-arith mach -imm-dst-defn) (HI HI .w 1 op suffix opc1 opc2 opc3 sem))
6288 (define-pmacro (binary-arith-imm-dst op suffix opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6290 (binary-arith-imm-dst-mach 16 op suffix opc16-1 opc16-2 opc16-3 sem)
6291 (binary-arith-imm-dst-mach 32 op suffix opc32-1 opc32-2 opc32-3 sem)
6295 ;-------------------------------------------------------------
6296 ;<arith>.size:Q #imm4,dst -- for m16c and m32c
6297 ;-------------------------------------------------------------
6299 (define-pmacro (binary-arith-imm4-dst-defn mach src dstgroup mode wstr op encoding sem)
6300 (dni (.sym op mach wstr - imm4-Q - dstgroup)
6301 (.str op wstr " " mach "-imm4-Q-" dstgroup "-" mode)
6302 ((machine mach) RL_1ADDR)
6303 (.str op wstr "$Q #${" src "},${dst" mach "-" dstgroup "-" mode "}")
6305 (sem mode src (.sym dst mach - dstgroup - mode))
6310 (define-pmacro (binary-arith16-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6311 (binary-arith-imm4-dst-defn 16 Imm-8-s4 16 mode wstr op
6312 (+ opc1 opc2 (f-7-1 wbit2) Imm-8-s4 (.sym dst16-16- mode))
6316 (define-pmacro (binary-arith16-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6317 (binary-arith-imm4-dst-defn 16 Imm-sh-8-s4 16 mode wstr op
6318 (+ opc1 opc2 (f-7-1 wbit2) Imm-sh-8-s4 (.sym dst16-16- mode))
6323 (define-pmacro (binary-arith32-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6325 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6326 ; define the absolute-indirect insns first in order to prevent them from being selected
6327 ; when the mode is register-indirect
6328 ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-absolute-indirect mode wstr op
6329 ; (+ (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)
6331 (binary-arith-imm4-dst-defn 32 Imm-12-s4 16-Unprefixed mode wstr op
6332 (+ (f-0-3 opc1) (f-3-1 wbit1) (f-7-1 wbit2) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) Imm-12-s4)
6334 ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-indirect mode wstr op
6335 ; (+ (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)
6340 (define-pmacro (binary-arith32-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6342 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6343 ; define the absolute-indirect insns first in order to prevent them from being selected
6344 ; when the mode is register-indirect
6345 ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-absolute-indirect mode wstr op
6346 ; (+ (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)
6348 (binary-arith-imm4-dst-defn 32 Imm-sh-12-s4 16-Unprefixed mode wstr op
6349 (+ (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)
6351 ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-indirect mode wstr op
6352 ; (+ (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)
6357 (define-pmacro (binary-arith-imm4-dst-mach mach op opc1 opc2 sem)
6359 (.apply (.sym binary-arith mach -imm4-dst-defn) (QI .b 0 0 op opc1 opc2 sem))
6360 (.apply (.sym binary-arith mach -imm4-dst-defn) (HI .w 0 1 op opc1 opc2 sem))
6364 (define-pmacro (binary-arith-imm4-dst op opc16-1 opc16-2 opc32-1 opc32-2 sem)
6366 (binary-arith-imm4-dst-mach 16 op opc16-1 opc16-2 sem)
6367 (binary-arith-imm4-dst-mach 32 op opc32-1 opc32-2 sem)
6371 ;-------------------------------------------------------------
6372 ;<arith>.size:G src,dst -- for m16c and m32c
6373 ;-------------------------------------------------------------
6375 (define-pmacro (binary-arith-src-dst-defn mach srcgroup dstgroup smode dmode wstr op suffix encoding sem)
6376 (dni (.sym op mach wstr - srcgroup - dstgroup)
6377 (.str op wstr " dst" mach "-" srcgroup "-" dstgroup "-" dmode)
6378 ((machine mach) RL_2ADDR)
6379 (.str op wstr "$" suffix " ${src" mach "-" srcgroup "-" smode "},${dst" mach "-" dstgroup "-" dmode "}")
6381 (sem dmode (.sym src mach - srcgroup - smode) (.sym dst mach - dstgroup - dmode))
6386 (define-pmacro (binary-arith16-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem)
6388 (binary-arith-src-dst-defn 16 basic 16 smode dmode wstr op suffix
6389 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-basic- smode) (.sym dst16-16- dmode))
6391 (binary-arith-src-dst-defn 16 16-16 32 smode dmode wstr op suffix
6392 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-16- smode) (.sym dst16-32- dmode))
6394 (binary-arith-src-dst-defn 16 16-8 24 smode dmode wstr op suffix
6395 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-8- smode) (.sym dst16-24- dmode))
6400 ; m32c Prefixed variants
6401 (define-pmacro (binary-arith32-src-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 sem)
6403 (binary-arith-src-dst-defn 32 basic-Prefixed 24-Prefixed smode dmode wstr op suffix
6404 (+ (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))
6406 (binary-arith-src-dst-defn 32 24-24-Prefixed 48-Prefixed smode dmode wstr op suffix
6407 (+ (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))
6409 (binary-arith-src-dst-defn 32 24-16-Prefixed 40-Prefixed smode dmode wstr op suffix
6410 (+ (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))
6412 (binary-arith-src-dst-defn 32 24-8-Prefixed 32-Prefixed smode dmode wstr op suffix
6413 (+ (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))
6419 (define-pmacro (binary-arith32-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem)
6421 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6422 ; define the absolute-indirect insns first in order to prevent them from being selected
6423 ; when the mode is register-indirect
6424 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-absolute-indirect smode dmode wstr op suffix
6425 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6426 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6428 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-absolute-indirect smode dmode wstr op suffix
6429 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6430 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6432 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-Prefixed smode dmode wstr op suffix
6433 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6434 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
6436 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-Prefixed smode dmode wstr op suffix
6437 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6438 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
6440 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-indirect smode dmode wstr op suffix
6441 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6442 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6444 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-indirect smode dmode wstr op suffix
6445 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6446 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6448 ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-absolute-indirect smode dmode wstr op suffix
6449 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6450 ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2))
6452 ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-absolute-indirect smode dmode wstr op suffix
6453 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6454 ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6456 ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-absolute-indirect smode dmode wstr op suffix
6457 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6458 ; (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6460 ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-absolute-indirect smode dmode wstr op suffix
6461 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6462 ; (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2))
6464 ; (binary-arith-src-dst-defn 32 basic-indirect 24-absolute-indirect smode dmode wstr op suffix
6465 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6466 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2))
6468 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-absolute-indirect smode dmode wstr op suffix
6469 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6470 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6472 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-absolute-indirect smode dmode wstr op suffix
6473 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6474 ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6476 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-absolute-indirect smode dmode wstr op suffix
6477 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6478 ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2))
6480 (binary-arith-src-dst-defn 32 basic-Unprefixed 16-Unprefixed smode dmode wstr op suffix
6481 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-basic-Unprefixed- smode) (.sym dst32-16-Unprefixed- dmode) (f-12-4 opc2))
6483 (binary-arith-src-dst-defn 32 16-24-Unprefixed 40-Unprefixed smode dmode wstr op suffix
6484 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-24-Unprefixed- smode) (.sym dst32-40-Unprefixed- dmode) (f-12-4 opc2))
6486 (binary-arith-src-dst-defn 32 16-16-Unprefixed 32-Unprefixed smode dmode wstr op suffix
6487 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-16-Unprefixed- smode) (.sym dst32-32-Unprefixed- dmode) (f-12-4 opc2))
6489 (binary-arith-src-dst-defn 32 16-8-Unprefixed 24-Unprefixed smode dmode wstr op suffix
6490 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-8-Unprefixed- smode) (.sym dst32-24-Unprefixed- dmode) (f-12-4 opc2))
6492 ; (binary-arith-src-dst-defn 32 basic-indirect 24-Prefixed smode dmode wstr op suffix
6493 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6494 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-Prefixed- dmode) (f-20-4 opc2))
6496 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-Prefixed smode dmode wstr op suffix
6497 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6498 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
6500 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-Prefixed smode dmode wstr op suffix
6501 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6502 ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
6504 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-Prefixed smode dmode wstr op suffix
6505 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6506 ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-Prefixed- dmode) (f-20-4 opc2))
6508 ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-indirect smode dmode wstr op suffix
6509 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6510 ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2))
6512 ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-indirect smode dmode wstr op suffix
6513 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6514 ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6516 ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-indirect smode dmode wstr op suffix
6517 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6518 ; (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6520 ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-indirect smode dmode wstr op suffix
6521 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6522 ; (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2))
6524 ; (binary-arith-src-dst-defn 32 basic-indirect 24-indirect smode dmode wstr op suffix
6525 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6526 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2))
6528 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-indirect smode dmode wstr op suffix
6529 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6530 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6532 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-indirect smode dmode wstr op suffix
6533 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6534 ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6536 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-indirect smode dmode wstr op suffix
6537 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6538 ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2))
6543 (define-pmacro (binary-arith-src-dst-mach mach op suffix opc1 opc2 sem)
6545 (.apply (.sym binary-arith mach -src-dst-defn) (QI QI .b 0 op suffix opc1 opc2 sem))
6546 (.apply (.sym binary-arith mach -src-dst-defn) (HI HI .w 1 op suffix opc1 opc2 sem))
6550 (define-pmacro (binary-arith-src-dst op suffix opc16-1 opc16-2 opc32-1 opc32-2 sem)
6552 (binary-arith-src-dst-mach 16 op suffix opc16-1 opc16-2 sem)
6553 (binary-arith-src-dst-mach 32 op suffix opc32-1 opc32-2 sem)
6557 ;-------------------------------------------------------------
6558 ;<arith>.size:S #imm,dst -- for m32c
6559 ;-------------------------------------------------------------
6561 (define-pmacro (binary-arith32-s-imm-dst-defn src dstgroup mode wstr op encoding sem)
6562 (dni (.sym op 32 wstr - imm-S - dstgroup)
6563 (.str op wstr " 32-imm-S-" dstgroup "-" mode)
6565 (.str op wstr "$S #${" src "},${dst32-" dstgroup "-" mode "}")
6567 (sem mode src (.sym dst32- dstgroup - mode))
6571 (define-pmacro (binary-arith32-z-imm-dst-defn src dstgroup mode wstr op encoding sem)
6572 (dni (.sym op 32 wstr - imm-Z - dstgroup)
6573 (.str op wstr " 32-imm-Z-" dstgroup "-" mode)
6575 (.str op wstr "$Z #0,${dst32-" dstgroup "-" mode "}")
6577 (sem mode (const 0) (.sym dst32- dstgroup - mode))
6581 (define-pmacro (binary-arith32-s-imm-dst mode wstr wbit op opc1 opc2 sem)
6583 ; (binary-arith32-s-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op
6584 ; (+ (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))
6586 (binary-arith32-s-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op
6587 (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-8- mode))
6589 (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op
6590 (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-24- mode))
6592 (binary-arith32-s-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op
6593 (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-16- mode))
6595 ; (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op
6596 ; (+ (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))
6601 (define-pmacro (binary-arith32-z-imm-dst mode wstr wbit op opc1 opc2 sem)
6603 ; (binary-arith32-z-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op
6604 ; (+ (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))
6606 (binary-arith32-z-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op
6607 (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit))
6609 (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op
6610 (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit))
6612 (binary-arith32-z-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op
6613 (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit))
6615 ; (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op
6616 ; (+ (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))
6621 ;-------------------------------------------------------------
6622 ;<arith>.L:S #imm1,An -- for m32c
6623 ;-------------------------------------------------------------
6625 (define-pmacro (binary-arith32-l-s-imm1-an op opc1 opc2 sem)
6627 (dni (.sym op 32.l-s-imm1-S-an)
6628 (.str op ".l 32-imm1-S-an")
6630 (.str op ".l$S #${Imm1-S},${dst32-an-S}")
6631 (+ opc1 Imm1-S opc2 dst32-an-S)
6632 (sem SI Imm1-S dst32-an-S)
6637 ;-------------------------------------------------------------
6638 ;<arith>.L:Q #imm3,sp -- for m32c
6639 ;-------------------------------------------------------------
6641 (define-pmacro (binary-arith32-l-q-imm3-sp op opc1 opc2 sem)
6643 (dni (.sym op 32.l-imm3-Q)
6644 (.str op ".l 32-imm3-Q")
6646 (.str op ".l$Q #${Imm3-S},sp")
6647 (+ opc1 Imm3-S opc2)
6653 ;-------------------------------------------------------------
6654 ;<arith>.L:S #imm8,sp -- for m32c
6655 ;-------------------------------------------------------------
6657 (define-pmacro (binary-arith32-l-s-imm8-sp op opc1 opc2 opc3 opc4 sem)
6659 (dni (.sym op 32.l-imm8-S)
6660 (.str op ".l 32-imm8-S")
6662 (.str op ".l$S #${Imm-16-QI},sp")
6663 (+ opc1 opc2 opc3 opc4 Imm-16-QI)
6664 (sem SI Imm-16-QI sp)
6669 ;-------------------------------------------------------------
6670 ;<arith>.L:G #imm16,sp -- for m32c
6671 ;-------------------------------------------------------------
6673 (define-pmacro (binary-arith32-l-g-imm16-sp op opc1 opc2 opc3 opc4 sem)
6675 (dni (.sym op 32.l-imm16-G)
6676 (.str op ".l 32-imm16-G")
6678 (.str op ".l$G #${Imm-16-HI},sp")
6679 (+ opc1 opc2 opc3 opc4 Imm-16-HI)
6680 (sem SI Imm-16-HI sp)
6685 ;-------------------------------------------------------------
6686 ;<arith>jnz.size #imm4,dst,label -- for m16c and m32c
6687 ;-------------------------------------------------------------
6689 (define-pmacro (arith-jnz-imm4-dst-defn mach src dstgroup label mode wstr op encoding sem)
6690 (dni (.sym op mach wstr - imm4 - dstgroup)
6691 (.str op wstr " " mach "-imm4-" dstgroup "-" label "-" mode)
6692 (RL_JUMP RELAXABLE (machine mach))
6693 (.str op wstr " #${" src "},${dst" mach "-" dstgroup "-" mode "},${" label "}")
6695 (sem mode src (.sym dst mach - dstgroup - mode) label)
6700 (define-pmacro (arith-jnz16-imm4-dst-defn mode wstr wbit op i4n opc1 opc2 sem)
6702 (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) basic Lab-16-8 mode wstr op
6703 (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-basic- mode) Lab-16-8)
6705 (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) 16-16 Lab-32-8 mode wstr op
6706 (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-16-16- mode) Lab-32-8)
6708 (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) 16-8 Lab-24-8 mode wstr op
6709 (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-16-8- mode) Lab-24-8)
6715 (define-pmacro (arith-jnz32-imm4-dst-defn mode wstr wbit op i4n opc1 opc2 sem)
6717 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) basic-Unprefixed Lab-16-8 mode wstr op
6718 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-16-8)
6720 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-24-Unprefixed Lab-40-8 mode wstr op
6721 (+ (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)
6723 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-16-Unprefixed Lab-32-8 mode wstr op
6724 (+ (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)
6726 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-8-Unprefixed Lab-24-8 mode wstr op
6727 (+ (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)
6732 (define-pmacro (arith-jnz-imm4-dst-mach mach op i4n opc1 opc2 sem)
6734 (.apply (.sym arith-jnz mach -imm4-dst-defn) (QI .b 0 op i4n opc1 opc2 sem))
6735 (.apply (.sym arith-jnz mach -imm4-dst-defn) (HI .w 1 op i4n opc1 opc2 sem))
6739 (define-pmacro (arith-jnz-imm4-dst op i4n opc16-1 opc16-2 opc32-1 opc32-2 sem)
6741 (arith-jnz-imm4-dst-mach 16 op i4n opc16-1 opc16-2 sem)
6742 (arith-jnz-imm4-dst-mach 32 op i4n opc32-1 opc32-2 sem)
6746 ;-------------------------------------------------------------
6747 ;mov.size dsp8[sp],dst -- for m16c and m32c
6748 ;-------------------------------------------------------------
6749 (define-pmacro (mov-dspsp-dst-defn mach dstgroup dsp mode wstr op encoding sem)
6750 (dni (.sym op mach wstr -dspsp-dst- dstgroup)
6751 (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
6753 (.str op wstr "$G ${" dsp "}[sp],${dst" mach "-" dstgroup "-" mode "}")
6755 (sem mach mode dsp (.sym dst mach - dstgroup - mode))
6758 (define-pmacro (mov-src-dspsp-defn mach dstgroup dsp mode wstr op encoding sem)
6759 (dni (.sym op mach wstr -dst-dspsp- dstgroup)
6760 (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
6762 (.str op wstr "$G ${dst" mach "-" dstgroup "-" mode "},${" dsp "}[sp]")
6764 (sem mach mode (.sym dst mach - dstgroup - mode) dsp)
6769 (define-pmacro (mov16-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem)
6771 (mov-dspsp-dst-defn 16 basic Dsp-16-s8 mode wstr op
6772 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-s8)
6774 (mov-dspsp-dst-defn 16 16-16 Dsp-32-s8 mode wstr op
6775 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-s8)
6777 (mov-dspsp-dst-defn 16 16-8 Dsp-24-s8 mode wstr op
6778 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-s8)
6783 (define-pmacro (mov16-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem)
6785 (mov-src-dspsp-defn 16 basic Dsp-16-s8 mode wstr op
6786 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-s8)
6788 (mov-src-dspsp-defn 16 16-16 Dsp-32-s8 mode wstr op
6789 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-s8)
6791 (mov-src-dspsp-defn 16 16-8 Dsp-24-s8 mode wstr op
6792 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-s8)
6798 (define-pmacro (mov32-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem)
6800 (mov-dspsp-dst-defn 32 basic-Unprefixed Dsp-16-s8 mode wstr op
6801 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-s8)
6803 (mov-dspsp-dst-defn 32 16-24-Unprefixed Dsp-40-s8 mode wstr op
6804 (+ (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)
6806 (mov-dspsp-dst-defn 32 16-16-Unprefixed Dsp-32-s8 mode wstr op
6807 (+ (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)
6809 (mov-dspsp-dst-defn 32 16-8-Unprefixed Dsp-24-s8 mode wstr op
6810 (+ (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)
6814 (define-pmacro (mov32-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem)
6816 (mov-src-dspsp-defn 32 basic-Unprefixed Dsp-16-s8 mode wstr op
6817 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-s8)
6819 (mov-src-dspsp-defn 32 16-24-Unprefixed Dsp-40-s8 mode wstr op
6820 (+ (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)
6822 (mov-src-dspsp-defn 32 16-16-Unprefixed Dsp-32-s8 mode wstr op
6823 (+ (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)
6825 (mov-src-dspsp-defn 32 16-8-Unprefixed Dsp-24-s8 mode wstr op
6826 (+ (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)
6831 (define-pmacro (mov-src-dspsp-mach mach op opc1 opc2 opc3 sem)
6833 (.apply (.sym mov mach -src-dspsp-defn) (QI .b 0 op opc1 opc2 opc3 sem))
6834 (.apply (.sym mov mach -src-dspsp-defn) (HI .w 1 op opc1 opc2 opc3 sem))
6838 (define-pmacro (mov-dspsp-dst-mach mach op opc1 opc2 opc3 sem)
6840 (.apply (.sym mov mach -dspsp-dst-defn) (QI .b 0 op opc1 opc2 opc3 sem))
6841 (.apply (.sym mov mach -dspsp-dst-defn) (HI .w 1 op opc1 opc2 opc3 sem))
6845 (define-pmacro (mov-dspsp-dst op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6847 (mov-dspsp-dst-mach 16 op opc16-1 opc16-2 opc16-3 sem)
6848 (mov-dspsp-dst-mach 32 op opc32-1 opc32-2 opc32-3 sem)
6851 (define-pmacro (mov-src-dspsp op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6853 (mov-src-dspsp-mach 16 op opc16-1 opc16-2 opc16-3 sem)
6854 (mov-src-dspsp-mach 32 op opc32-1 opc32-2 opc32-3 sem)
6858 ;-------------------------------------------------------------
6859 ; lde dsp24,dst -- for m16c
6860 ;-------------------------------------------------------------
6862 (define-pmacro (lde-dst-dsp mode wstr wbit dstgroup srcdisp)
6865 (dni (.sym lde wstr - dstgroup -u20)
6866 (.str "lde" wstr "-" dstgroup "-u20")
6868 (.str "lde" wstr " ${" srcdisp "},${dst16-" dstgroup "-" mode "}")
6869 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x8)
6870 (.sym dst16- dstgroup - mode) srcdisp)
6874 (dni (.sym lde wstr - dstgroup -u20a0)
6875 (.str "lde" wstr "-" dstgroup "-u20a0")
6877 (.str "lde" wstr " ${" srcdisp "}[a0],${dst16-" dstgroup "-" mode "}")
6878 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x9)
6879 (.sym dst16- dstgroup - mode) srcdisp)
6883 (dni (.sym lde wstr - dstgroup -a1a0)
6884 (.str "lde" wstr "-" dstgroup "-a1a0")
6886 (.str "lde" wstr " [a1a0],${dst16-" dstgroup "-" mode "}")
6887 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #xa)
6888 (.sym dst16- dstgroup - mode))
6894 (define-pmacro (lde-dst mode wstr wbit)
6897 (lde-dst-dsp mode wstr wbit basic Dsp-16-u20)
6898 (lde-dst-dsp mode wstr wbit 16-8 Dsp-24-u20)
6899 (lde-dst-dsp mode wstr wbit 16-16 Dsp-32-u20)
6903 ;-------------------------------------------------------------
6904 ; ste dst,dsp24 -- for m16c
6905 ;-------------------------------------------------------------
6907 (define-pmacro (ste-dst-dsp mode wstr wbit dstgroup srcdisp)
6910 (dni (.sym ste wstr - dstgroup -u20)
6911 (.str "ste" wstr "-" dstgroup "-u20")
6913 (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},${" srcdisp "}")
6914 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x0)
6915 (.sym dst16- dstgroup - mode) srcdisp)
6919 (dni (.sym ste wstr - dstgroup -u20a0)
6920 (.str "ste" wstr "-" dstgroup "-u20a0")
6922 (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},${" srcdisp "}[a0]")
6923 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x1)
6924 (.sym dst16- dstgroup - mode) srcdisp)
6928 (dni (.sym ste wstr - dstgroup -a1a0)
6929 (.str "ste" wstr "-" dstgroup "-a1a0")
6931 (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},[a1a0]")
6932 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x2)
6933 (.sym dst16- dstgroup - mode))
6939 (define-pmacro (ste-dst mode wstr wbit)
6942 (ste-dst-dsp mode wstr wbit basic Dsp-16-u20)
6943 (ste-dst-dsp mode wstr wbit 16-8 Dsp-24-u20)
6944 (ste-dst-dsp mode wstr wbit 16-16 Dsp-32-u20)
6948 ;=============================================================
6950 ;-------------------------------------------------------------
6952 (define-pmacro (div-sem divop modop opmode reg src quot rem max min)
6955 (set obit (const BI 1))
6956 (sequence ((opmode quot-result) (opmode rem-result))
6957 (set quot-result (divop opmode (ext opmode reg) src))
6958 (set rem-result (modop opmode (ext opmode reg) src))
6959 (set obit (orif (gt opmode quot-result max)
6960 (lt opmode quot-result min)))
6961 (set quot quot-result)
6962 (set rem rem-result))))
6965 ;<divop>.size #imm -- for m16c and m32c
6966 (define-pmacro (div-imm-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem)
6967 (dni (.sym op mach wstr - src)
6968 (.str op mach wstr "-" src)
6970 (.str op wstr " #${" src "}")
6972 (sem divop modop opmode reg src quot rem max min)
6975 (define-pmacro (div16-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem)
6976 (div-imm-defn 16 wstr op (.sym Imm-16 - smode)
6977 (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16 - smode))
6978 divop modop opmode reg quot rem max min
6981 (define-pmacro (div32-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem)
6982 (div-imm-defn 32 wstr op (.sym Imm-16 - smode)
6983 (+ (f-0-4 opc1) (f-4-4 opc2) (f-8-3 opc3) (f-11-1 wbit) (f-12-4 opc4) (.sym Imm-16 - smode))
6984 divop modop opmode reg quot rem max min
6987 (define-pmacro (div-imm-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 opc4 sem)
6989 (.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))
6990 (.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))
6993 (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)
6995 (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)
6996 (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)
7000 ;<divop>.size src -- for m16c and m32c
7001 (define-pmacro (div-src-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem)
7002 (dni (.sym op mach wstr - src)
7003 (.str op mach wstr "-" src)
7005 (.str op wstr " ${" src "}")
7007 (sem divop modop opmode reg src quot rem max min)
7010 (define-pmacro (div16-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem)
7011 (div-src-defn 16 wstr op (.sym dst16-16 - smode)
7012 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16 - smode))
7013 divop modop opmode reg quot rem max min
7016 (define-pmacro (div32-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem)
7018 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
7019 ; define the absolute-indirect insns first in order to prevent them from being selected
7020 ; when the mode is register-indirect
7021 ; (div-src-defn 32 wstr op (.sym dst32-24-absolute-indirect- smode)
7022 ; (+ (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))
7023 ; divop modop opmode reg quot rem max min
7025 (div-src-defn 32 wstr op (.sym dst32-16-Unprefixed- smode)
7026 (+ (f-0-4 opc1) (f-7-1 wbit) (f-10-2 opc2) (f-12-4 opc3) (.sym dst32-16-Unprefixed- smode))
7027 divop modop opmode reg quot rem max min
7029 ; (div-src-defn 32 wstr op (.sym dst32-24-indirect- smode)
7030 ; (+ (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))
7031 ; divop modop opmode reg quot rem max min
7035 (define-pmacro (div-src-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 sem)
7037 (.apply (.sym div mach -src-defn) (QI .b 0 op divop modop opmode R0 R0l R0h max-QI min-QI opc1 opc2 opc3 sem))
7038 (.apply (.sym div mach -src-defn) (HI .w 1 op divop modop opmode R2R0 R0 R2 max-HI min-HI opc1 opc2 opc3 sem))
7041 (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)
7043 (div-src-mach 16 op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 sem)
7044 (div-src-mach 32 op divop modop opmode max-QI min-QI max-HI min-HI opc32-1 opc32-2 opc32-3 sem)
7048 ;=============================================================
7051 (define-pmacro (bit-insn-defn mach op suffix opnd encoding sem)
7052 (dni (.sym op mach - suffix - opnd)
7053 (.str op mach ":" suffix " " opnd)
7055 (.str op "$" suffix " ${" opnd "}")
7061 (define-pmacro (bitsrc16-defn op opc1 opc2 opc3 sem)
7062 (bit-insn-defn 16 op X bit16-16
7063 (+ opc1 opc2 opc3 bit16-16)
7067 (define-pmacro (bitsrc32-defn op opc1 opc2 opc3 sem)
7069 (bit-insn-defn 32 op X bit32-24-Prefixed
7070 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) bit32-24-Prefixed (f-15-1 opc2) (f-18-3 opc3))
7075 (define-pmacro (bitsrc-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
7077 (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem)
7078 (bitsrc32-defn op opc32-1 opc32-2 opc32-3 sem)
7082 (define-pmacro (bitdst16-defn op opc1 opc2 opc3 opc4 opc5 opc6 sem)
7084 (bit-insn-defn 16 op G bit16-16-basic (+ opc1 opc2 opc3 bit16-16-basic) sem)
7085 (bit-insn-defn 16 op G bit16-16-16 (+ opc1 opc2 opc3 bit16-16-16) sem)
7086 (bit-insn-defn 16 op S bit16-11-S (+ opc4 opc5 opc6 bit16-11-S) sem)
7087 (bit-insn-defn 16 op G bit16-16-8 (+ opc1 opc2 opc3 bit16-16-8) sem)
7091 (define-pmacro (bitdst32-defn op opc1 opc2 opc3 sem)
7093 (bit-insn-defn 32 op X bit32-16-Unprefixed
7094 (+ (f-0-4 opc1) bit32-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3))
7099 (define-pmacro (bitdstnos-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
7101 (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem)
7102 (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem)
7106 (define-pmacro (bitdst-insn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 opc32-1 opc32-2 opc32-3 sem)
7108 (bitdst16-defn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 sem)
7109 (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem)
7113 ;=============================================================
7116 (define-pmacro (bitcond-insn-defn mach op bit-opnd cond-opnd encoding sem)
7117 (dni (.sym op mach - bit-opnd - cond-opnd)
7118 (.str op mach " " bit-opnd " " cond-opnd)
7120 (.str op "${" cond-opnd "} ${" bit-opnd "}")
7122 (sem mach bit-opnd cond-opnd)
7126 (define-pmacro (bitcond16-defn op opc1 opc2 opc3 sem)
7128 (bitcond-insn-defn 16 op bit16-16-basic cond16-16 (+ opc1 opc2 opc3 bit16-16-basic cond16-16) sem)
7129 (bitcond-insn-defn 16 op bit16-16-16 cond16-32 (+ opc1 opc2 opc3 bit16-16-16 cond16-32) sem)
7130 (bitcond-insn-defn 16 op bit16-16-8 cond16-24 (+ opc1 opc2 opc3 bit16-16-8 cond16-24) sem)
7134 (define-pmacro (bitcond32-defn op opc1 opc2 opc3 sem)
7136 (bitcond-insn-defn 32 op bit32-16-24-Unprefixed cond32-40
7137 (+ (f-0-4 opc1) bit32-16-24-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-40)
7139 (bitcond-insn-defn 32 op bit32-16-16-Unprefixed cond32-32
7140 (+ (f-0-4 opc1) bit32-16-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-32)
7142 (bitcond-insn-defn 32 op bit32-16-8-Unprefixed cond32-24
7143 (+ (f-0-4 opc1) bit32-16-8-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-24)
7145 (bitcond-insn-defn 32 op bit32-basic-Unprefixed cond32-16
7146 (+ (f-0-4 opc1) bit32-basic-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-16)
7151 (define-pmacro (bitcond-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
7153 (bitcond16-defn op opc16-1 opc16-2 opc16-3 sem)
7154 (bitcond32-defn op opc32-1 opc32-2 opc32-3 sem)
7158 ;=============================================================
7159 ;<insn>.size #imm1,#imm2,dst -- for m32c
7161 (define-pmacro (insn-imm1-imm2-dst-defn src1 src2 dstgroup xmode wstr op encoding sem)
7162 (dni (.sym op 32 wstr - src1 - src2 - dstgroup)
7163 (.str op 32 wstr "-" src1 "-" src2 "-" dstgroup "-" xmode)
7165 (.str op wstr " #${" src1 "},#${" src2 "},${dst32-" dstgroup "-" xmode "}")
7167 (sem xmode src1 src2 (.sym dst32- dstgroup - xmode))
7171 ; m32c Prefixed variants
7172 (define-pmacro (insn32-imm1-imm2-dst-Prefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem)
7174 (insn-imm1-imm2-dst-defn (.sym Imm-48- xmode) (.sym Imm- base4 - xmode) 24-24-Prefixed xmode wstr op
7175 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
7176 (.sym dst32-24-24-Prefixed- xmode) (.sym Imm-48- xmode) (.sym Imm- base4 - xmode))
7178 (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base3 - xmode) 24-16-Prefixed xmode wstr op
7179 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
7180 (.sym dst32-24-16-Prefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base3 - xmode))
7182 (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base2 - xmode) 24-8-Prefixed xmode wstr op
7183 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
7184 (.sym dst32-24-8-Prefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base2 - xmode))
7186 (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base1 - xmode) basic-Prefixed xmode wstr op
7187 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
7188 (.sym dst32-basic-Prefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base1 - xmode))
7193 ; m32c Unprefixed variants
7194 (define-pmacro (insn32-imm1-imm2-dst-Unprefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem)
7196 (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base4 - xmode) 16-24-Unprefixed xmode wstr op
7197 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7198 (.sym dst32-16-24-Unprefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base4 - xmode))
7200 (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base3 - xmode) 16-16-Unprefixed xmode wstr op
7201 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7202 (.sym dst32-16-16-Unprefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base3 - xmode))
7204 (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base2 - xmode) 16-8-Unprefixed xmode wstr op
7205 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7206 (.sym dst32-16-8-Unprefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base2 - xmode))
7208 (insn-imm1-imm2-dst-defn (.sym Imm-16- xmode) (.sym Imm- base1 - xmode) basic-Unprefixed xmode wstr op
7209 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7210 (.sym dst32-basic-Unprefixed- xmode) (.sym Imm-16- xmode) (.sym Imm- base1 - xmode))
7215 (define-pmacro (insn-imm1-imm2-dst-Prefixed op opc32-1 opc32-2 opc32-3 sem)
7217 (insn32-imm1-imm2-dst-Prefixed-defn QI .b 0 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem)
7218 (insn32-imm1-imm2-dst-Prefixed-defn HI .w 1 40 48 56 64 op opc32-1 opc32-2 opc32-3 sem)
7221 (define-pmacro (insn-imm1-imm2-dst-Unprefixed op opc32-1 opc32-2 opc32-3 sem)
7223 (insn32-imm1-imm2-dst-Unprefixed-defn QI .b 0 24 32 40 48 op opc32-1 opc32-2 opc32-3 sem)
7224 (insn32-imm1-imm2-dst-Unprefixed-defn HI .w 1 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem)
7228 ;=============================================================
7230 ;-------------------------------------------------------------
7232 ;-------------------------------------------------------------
7234 (define-pmacro (abs-sem mode dst)
7235 (sequence ((mode result))
7236 (set result (abs mode dst))
7237 (set obit (eq result dst))
7238 (set-z-and-s result)
7241 (unary-insn abs (f-0-4 7) (f-4-3 3) (f-8-4 #xF) #xA #x1 #xF abs-sem)
7243 ;-------------------------------------------------------------
7244 ; adcf - addition carry flag
7245 ;-------------------------------------------------------------
7247 (define-pmacro (adcf-sem mode dst)
7248 (sequence ((mode result))
7249 (set result (addc mode dst 0 cbit))
7250 (set obit (add-oflag mode dst 0 cbit))
7251 (set cbit (add-cflag mode dst 0 cbit))
7252 (set-z-and-s result)
7255 (unary-insn adcf (f-0-4 7) (f-4-3 3) (f-8-4 #xE) #xB #x1 #xE adcf-sem)
7257 ;-------------------------------------------------------------
7258 ; add - binary addition
7259 ;-------------------------------------------------------------
7261 (define-pmacro (add-sem mode src1 dst)
7262 (sequence ((mode result))
7263 (set result (add mode src1 dst))
7264 (set obit (add-oflag mode src1 dst 0))
7265 (set cbit (add-cflag mode src1 dst 0))
7266 (set-z-and-s result)
7270 ; add.L:G #imm32,dst (m32 #2)
7271 (binary-arith32-imm-dst-defn SI SI .l 0 add G #x8 #x3 #x1 add-sem)
7272 ; add.size:G #imm,dst (m16 #1 m32 #1)
7273 (binary-arith-imm-dst add G (f-0-4 7) (f-4-3 3) (f-8-4 4) #x8 #x2 #xE add-sem)
7274 ; add.size:Q #imm4,dst (m16 #2 m32 #3)
7275 (binary-arith-imm4-dst add (f-0-4 #xC) (f-4-3 4) #x7 #x3 add-sem)
7276 (binary-arith32-imm4-dst-defn SI .l 1 0 add #x7 #x3 add-sem)
7277 ; add.b:S #imm8,dst3 (m16 #3)
7278 (binary-arith16-b-S-imm8-dst3 add ".b" (f-0-4 8) (f-4-1 0) add-sem)
7279 ; add.BW:Q #imm4,sp (m16 #7)
7280 (binary-arith16-Q-sp add (f-0-4 7) (f-4-4 #xD) (f-8-4 #xB) add-sem)
7281 (dnmi add16-bQ-sp "add16-bQ-sp" ()
7282 "add.b:q #${Imm-12-s4},sp"
7283 (emit add16-wQ-sp Imm-12-s4))
7284 ; add.BW:G #imm,sp (m16 #6)
7285 (binary-arith16-G-sp add (f-0-4 7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #xB) add-sem)
7286 ; add.BW:G src,dst (m16 #4 m32 #6)
7287 (binary-arith-src-dst add G (f-0-4 #xA) (f-4-3 0) #x1 #x8 add-sem)
7288 ; add.B.S src2,r0l/r0h (m16 #5)
7289 (binary-arith16-b-S-src2 add (f-0-4 2) (f-4-1 0) add-sem)
7290 ; add.L:G src,dst (m32 #7)
7291 (binary-arith32-src-dst-defn SI SI .l 1 add G #x1 #x2 add-sem)
7292 ; add.L:S #imm{1,2},A0/A1 (m32 #5)
7293 (binary-arith32-l-s-imm1-an add (f-0-2 2) (f-3-4 6) add-sem)
7294 ; add.L:Q #imm3,sp (m32 #9)
7295 (binary-arith32-l-q-imm3-sp add (f-0-2 1) (f-4-3 1) add-sem)
7296 ; add.L:S #imm8,sp (m32 #10)
7297 (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)
7298 ; add.L:G #imm16,sp (m32 #8)
7299 (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)
7300 ; add.BW:S #imm,dst2 (m32 #4)
7301 (binary-arith32-s-imm-dst QI .b 0 add #x0 #x3 add-sem)
7302 (binary-arith32-s-imm-dst HI .w 1 add #x0 #x3 add-sem)
7304 ;-------------------------------------------------------------
7305 ; adc - binary add with carry
7306 ;-------------------------------------------------------------
7308 (define-pmacro (addc-sem mode src dst)
7309 (sequence ((mode result))
7310 (set result (addc mode src dst cbit))
7311 (set obit (add-oflag mode src dst cbit))
7312 (set cbit (add-cflag mode src dst cbit))
7313 (set-z-and-s result)
7317 ; adc.size:G #imm,dst
7318 (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)
7319 (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)
7320 (binary-arith32-imm-dst-Prefixed QI QI .b 0 adc X #x8 #x2 #xE addc-sem)
7321 (binary-arith32-imm-dst-Prefixed HI HI .w 1 adc X #x8 #x2 #xE addc-sem)
7324 (binary-arith16-src-dst-defn QI QI .b 0 adc X (f-0-4 #xB) (f-4-3 0) addc-sem)
7325 (binary-arith16-src-dst-defn HI HI .w 1 adc X (f-0-4 #xB) (f-4-3 0) addc-sem)
7326 (binary-arith32-src-dst-Prefixed QI QI .b 0 adc X #x1 #x4 addc-sem)
7327 (binary-arith32-src-dst-Prefixed HI HI .w 1 adc X #x1 #x4 addc-sem)
7329 ;-------------------------------------------------------------
7330 ; dadc - decimal add with carry
7331 ; dadd - decimal addition
7332 ;-------------------------------------------------------------
7334 (define-pmacro (dadc-sem mode src dst)
7335 (sequence ((mode result))
7336 (set result (subc mode dst src (not cbit)))
7337 (set cbit (sub-cflag mode dst src (not cbit)))
7338 (set-z-and-s result)
7342 (define-pmacro (decimal-subtraction16-insn op opc1 opc2)
7345 (dni (.sym op 16.b-imm8)
7346 (.str op ".b #imm8")
7348 (.str op ".b #${Imm-16-QI},r0l")
7349 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc1) Imm-16-QI)
7350 ((.sym op -sem) QI Imm-16-QI R0l)
7353 (dni (.sym op 16.w-imm16)
7354 (.str op ".b #imm16")
7356 (.str op ".w #${Imm-16-HI},r0")
7357 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc1) Imm-16-HI)
7358 ((.sym op -sem) HI Imm-16-HI R0)
7361 (dni (.sym op 16.b-r0h-r0l)
7362 (.str op ".b r0h,r0l")
7364 (.str op ".b r0h,r0l")
7365 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc2))
7366 ((.sym op -sem) QI R0h R0l)
7369 (dni (.sym op 16.w-r1-r0)
7370 (.str op ".b r1,r0")
7372 (.str op ".w r1,r0")
7373 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc2))
7374 ((.sym op -sem) HI R1 R0)
7380 (decimal-subtraction16-insn dadc #xE #x6 )
7382 ; dadc.size #imm,dst
7383 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadc X #x8 #x0 #xE dadc-sem)
7384 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadc X #x8 #x0 #xE dadc-sem)
7386 (binary-arith32-src-dst-Prefixed QI QI .b 0 dadc X #x1 #x8 dadc-sem)
7387 (binary-arith32-src-dst-Prefixed HI HI .w 1 dadc X #x1 #x8 dadc-sem)
7389 (define-pmacro (dadd-sem mode src dst)
7390 (sequence ((mode result))
7391 (set result (subc mode dst src 0))
7392 (set cbit (sub-cflag mode dst src 0))
7393 (set-z-and-s result)
7398 (decimal-subtraction16-insn dadd #xC #x4)
7400 ; dadd.size #imm,dst
7401 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadd X #x8 #x1 #xE dadd-sem)
7402 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadd X #x8 #x1 #xE dadd-sem)
7404 (binary-arith32-src-dst-Prefixed QI QI .b 0 dadd X #x1 #x0 dadd-sem)
7405 (binary-arith32-src-dst-Prefixed HI HI .w 1 dadd X #x1 #x0 dadd-sem)
7407 ;-------------------------------------------------------------;
7408 ; addx - Add extend sign with no carry
7409 ;-------------------------------------------------------------;
7411 (define-pmacro (addx-sem mode src dst)
7412 (sequence ((SI source) (SI result))
7413 (set source (zext SI (trunc QI src)))
7414 (set result (add SI source dst))
7415 (set obit (add-oflag SI source dst 0))
7416 (set cbit (add-cflag SI source dst 0))
7417 (set-z-and-s result)
7422 (binary-arith32-imm-dst-defn QI SI "" 0 addx X #x8 #x1 #x1 addx-sem)
7424 (binary-arith32-src-dst-defn QI SI "" 0 addx X #x1 #x2 addx-sem)
7426 ;-------------------------------------------------------------
7427 ; adjnz - Add/Sub and branch if not zero
7428 ;-------------------------------------------------------------
7430 (define-pmacro (arith-jnz-sem mode src dst label)
7431 (sequence ((mode result))
7432 (set result (add mode src dst))
7438 ; adjnz.size #imm4,dst,label
7439 (arith-jnz-imm4-dst adjnz s4 (f-0-4 #xF) (f-4-3 4) #xf #x1 arith-jnz-sem)
7441 ;-------------------------------------------------------------
7443 ;-------------------------------------------------------------
7445 (define-pmacro (and-sem mode src1 dst)
7446 (sequence ((mode result))
7447 (set result (and mode src1 dst))
7448 (set-z-and-s result)
7452 ; and.size:G #imm,dst (m16 #1 m32 #1)
7453 (binary-arith-imm-dst and G (f-0-4 7) (f-4-3 3) (f-8-4 2) #x8 #x3 #xF and-sem)
7454 ; and.b:S #imm8,dst3 (m16 #2)
7455 (binary-arith16-b-S-imm8-dst3 and ".b" (f-0-4 9) (f-4-1 0) and-sem)
7456 ; and.BW:G src,dst (m16 #3 m32 #3)
7457 (binary-arith-src-dst and G (f-0-4 #x9) (f-4-3 0) #x1 #xD and-sem)
7458 ; and.B.S src2,r0l/r0h (m16 #4)
7459 (binary-arith16-b-S-src2 and (f-0-4 1) (f-4-1 0) and-sem)
7460 ; and.BW:S #imm,dst2 (m32 #2)
7461 (binary-arith32-s-imm-dst QI .b 0 and #x1 #x6 and-sem)
7462 (binary-arith32-s-imm-dst HI .w 1 and #x1 #x6 and-sem)
7464 ;-------------------------------------------------------------
7466 ;-------------------------------------------------------------
7468 (define-pmacro (band-sem src)
7469 (set cbit (and src cbit))
7471 (bitsrc-insn band (f-0-4 7) (f-4-4 #xE) (f-8-4 4) #xD #x0 #x1 band-sem)
7473 ;-------------------------------------------------------------
7475 ;-------------------------------------------------------------
7477 (define-pmacro (bclr-sem dst)
7480 (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)
7482 ;-------------------------------------------------------------
7483 ; bitindex - bit index
7484 ;-------------------------------------------------------------
7486 (define-pmacro (bitindex-sem mode dst)
7489 (unary-insn-defn 32 16-Unprefixed QI .b bitindex
7490 (+ (f-0-4 #xC) (f-7-1 0) dst32-16-Unprefixed-QI (f-10-2 #x2) (f-12-4 #xE))
7492 (unary-insn-defn 32 16-Unprefixed HI .w bitindex
7493 (+ (f-0-4 #xC) (f-7-1 1) dst32-16-Unprefixed-HI (f-10-2 #x2) (f-12-4 #xE))
7496 ;-------------------------------------------------------------
7497 ; bmCnd - bit move condition
7498 ;-------------------------------------------------------------
7500 (define-pmacro (test-condition16 cond)
7502 ((#x00) (trunc BI cbit))
7503 ((#x01) (not (or cbit zbit)))
7504 ((#x02) (trunc BI zbit))
7505 ((#x03) (trunc BI sbit))
7506 ((#x04) (or zbit (xor sbit obit)))
7507 ((#x05) (trunc BI obit))
7508 ((#x06) (xor sbit obit))
7510 ((#xf9) (or cbit zbit))
7513 ((#xfc) (not (or zbit (xor sbit obit))))
7515 ((#xfe) (not (xor sbit obit)))
7520 (define-pmacro (test-condition32 cond)
7523 ((#x01) (or cbit zbit))
7527 ((#x05) (not (or zbit (xor sbit obit))))
7528 ((#x06) (not (xor sbit obit)))
7529 ((#x08) (trunc BI cbit))
7530 ((#x09) (not (or cbit zbit)))
7531 ((#x0a) (trunc BI zbit))
7532 ((#x0b) (trunc BI sbit))
7533 ((#x0c) (trunc BI obit))
7534 ((#x0d) (or zbit (xor sbit obit)))
7535 ((#x0e) (xor sbit obit))
7540 (define-pmacro (bitcond-sem mach op cond)
7541 (if ((.sym test-condition mach) cond)
7545 (bitcond-insn bm (f-0-4 7) (f-4-4 #xE) (f-8-4 2) #xD #x0 #x2 bitcond-sem)
7551 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xD) cond16c)
7552 (bitcond-sem 16 cbit cond16c)
7559 (+ (f-0-4 #xD) (f-4-4 #x9) (f-8-1 0) (f-10-3 5) cond32)
7560 (bitcond-sem 32 cbit cond32)
7563 ;-------------------------------------------------------------
7565 ;-------------------------------------------------------------
7567 (define-pmacro (bnand-sem src)
7568 (set cbit (and (inv src) cbit))
7570 (bitsrc-insn bnand (f-0-4 7) (f-4-4 #xE) (f-8-4 5) #xD #x0 #x3 bnand-sem)
7572 ;-------------------------------------------------------------
7574 ;-------------------------------------------------------------
7576 (define-pmacro (bnor-sem src)
7577 (set cbit (or (inv src) cbit))
7579 (bitsrc-insn bnor (f-0-4 7) (f-4-4 #xE) (f-8-4 7) #xD #x0 #x6 bnor-sem)
7581 ;-------------------------------------------------------------
7583 ;-------------------------------------------------------------
7585 (define-pmacro (bnot-sem dst)
7588 (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)
7590 ;-------------------------------------------------------------
7592 ;-------------------------------------------------------------
7594 (define-pmacro (bntst-sem src)
7595 (set cbit (inv src))
7596 (set zbit (inv src))
7598 (bitsrc-insn bntst (f-0-4 7) (f-4-4 #xE) (f-8-4 3) #xD #x0 #x0 bntst-sem)
7600 ;-------------------------------------------------------------
7602 ;-------------------------------------------------------------
7604 (define-pmacro (bnxor-sem src)
7605 (set cbit (xor (inv src) cbit))
7607 (bitsrc-insn bnxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xD) #xD #x0 #x7 bnxor-sem)
7609 ;-------------------------------------------------------------
7611 ;-------------------------------------------------------------
7613 (define-pmacro (bor-sem src)
7614 (set cbit (or src cbit))
7616 (bitsrc-insn bor (f-0-4 7) (f-4-4 #xE) (f-8-4 #x6) #xD #x0 #x4 bor-sem)
7618 ;-------------------------------------------------------------
7620 ;-------------------------------------------------------------
7626 (+ (f-0-4 #x0) (f-4-4 #x0))
7634 (+ (f-0-4 #x0) (f-4-4 #x0))
7638 ;-------------------------------------------------------------
7640 ;-------------------------------------------------------------
7646 (+ (f-0-4 #x0) (f-4-4 #x8))
7650 ;-------------------------------------------------------------
7652 ;-------------------------------------------------------------
7654 (define-pmacro (bset-sem dst)
7657 (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)
7659 ;-------------------------------------------------------------
7661 ;-------------------------------------------------------------
7663 (define-pmacro (btst-sem dst)
7664 (set zbit (inv dst))
7667 (bitdst16-defn 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) btst-sem)
7669 (bit-insn-defn 32 btst G bit32-16-Unprefixed
7670 (+ (f-0-4 #xD) bit32-16-Unprefixed (f-7-1 #x0) (f-10-3 #x0))
7673 (dni btst.s "btst:s" ((machine 32))
7674 "btst:s ${Bit3-S},${Dsp-8-u16}"
7675 (+ (f-0-2 #x0) (f-4-3 #x5) Bit3-S Dsp-8-u16)
7678 ;-------------------------------------------------------------
7680 ;-------------------------------------------------------------
7682 (define-pmacro (btstc-sem dst)
7683 (set zbit (inv dst))
7687 (bitdstnos-insn btstc (f-0-4 7) (f-4-4 #xE) (f-8-4 #x0) #xD #x0 #x4 btstc-sem)
7689 ;-------------------------------------------------------------
7691 ;-------------------------------------------------------------
7693 (define-pmacro (btsts-sem dst)
7694 (set zbit (inv dst))
7698 (bitdstnos-insn btsts (f-0-4 7) (f-4-4 #xE) (f-8-4 #x1) #xD #x0 #x5 btsts-sem)
7700 ;-------------------------------------------------------------
7702 ;-------------------------------------------------------------
7704 (define-pmacro (bxor-sem src)
7705 (set cbit (xor src cbit))
7707 (bitsrc-insn bxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xC) #xD #x0 #x5 bxor-sem)
7709 ;-------------------------------------------------------------
7711 ;-------------------------------------------------------------
7713 (define-pmacro (clip-sem mode imm1 imm2 dest)
7715 (if (gt mode imm1 dest)
7717 (if (lt mode imm2 dest)
7721 (insn-imm1-imm2-dst-Prefixed clip #x8 #x3 #xE clip-sem)
7723 ;-------------------------------------------------------------
7724 ; cmp - binary compare
7725 ;-------------------------------------------------------------
7727 (define-pmacro (cmp-sem mode src1 dst)
7728 (sequence ((mode result))
7729 (set result (sub mode dst src1))
7730 (set obit (sub-oflag mode dst src1 0))
7731 (set cbit (not (sub-cflag mode dst src1 0)))
7732 (set-z-and-s result))
7735 ; cmp.L:G #imm32,dst (m32 #2)
7736 (binary-arith32-imm-dst-defn SI SI .l 0 cmp G #xA #x3 #x1 cmp-sem)
7737 ; cmp.size:G #imm,dst (m16 #1 m32 #1)
7738 (binary-arith-imm-dst cmp G (f-0-4 7) (f-4-3 3) (f-8-4 8) #x9 #x2 #xE cmp-sem)
7739 ; cmp.size:Q #imm4,dst (m16 #2 m32 #3)
7740 (binary-arith-imm4-dst cmp (f-0-4 #xD) (f-4-3 0) #x7 #x1 cmp-sem)
7741 ; cmp.b:S #imm8,dst3 (m16 #3)
7742 (binary-arith16-b-S-imm8-dst3 cmp ".b" (f-0-4 #xE) (f-4-1 0) cmp-sem)
7743 ; cmp.BW:G src,dst (m16 #4 m32 #5)
7744 (binary-arith-src-dst cmp G (f-0-4 #xC) (f-4-3 0) #x1 #x6 cmp-sem)
7745 ; cmp.B.S src2,r0l/r0h (m16 #5)
7746 (binary-arith16-b-S-src2 cmp (f-0-4 3) (f-4-1 1) cmp-sem)
7747 ; cmp.L:G src,dst (m32 #6)
7748 (binary-arith32-src-dst-defn SI SI .l 1 cmp G #x1 #x1 cmp-sem)
7749 ; cmp.BW:S #imm,dst2 (m32 #4)
7750 (binary-arith32-s-imm-dst QI .b 0 cmp #x1 #x3 cmp-sem)
7751 (binary-arith32-s-imm-dst HI .w 1 cmp #x1 #x3 cmp-sem)
7752 ; cmp.BW:s src2,r0[l] (m32 #7)
7753 (binary-arith32-S-src2 cmp QI .b 0 (f-0-2 1) (f-4-3 0) cmp-sem)
7754 (binary-arith32-S-src2 cmp HI .w 1 (f-0-2 1) (f-4-3 0) cmp-sem)
7756 ;-------------------------------------------------------------
7757 ; cmpx - binary compare extend sign
7758 ;-------------------------------------------------------------
7760 (define-pmacro (cmpx-sem mode src1 dst)
7761 (sequence ((mode result))
7762 (set result (sub mode dst (ext mode src1)))
7763 (set obit (sub-oflag mode dst (ext mode src1) 0))
7764 (set cbit (sub-cflag mode dst (ext mode src1) 0))
7765 (set-z-and-s result))
7768 (binary-arith32-imm-dst-defn QI SI "" 0 cmpx X #xA #x1 #x1 cmpx-sem)
7770 ;-------------------------------------------------------------
7772 ;-------------------------------------------------------------
7774 (define-pmacro (dec-sem mode dest)
7775 (sequence ((mode result))
7776 (set result (sub mode dest 1))
7777 (set-z-and-s result)
7784 "dec.b ${Dst16-3-S-8}"
7785 (+ (f-0-4 #xA) (f-4-1 #x1) Dst16-3-S-8)
7786 (dec-sem QI Dst16-3-S-8)
7792 "dec.w ${Dst16An-S}"
7793 (+ (f-0-4 #xF) (f-5-3 #x2) Dst16An-S)
7794 (dec-sem HI Dst16An-S)
7797 (unary32-defn QI .b 0 dec #xB #x0 #xE dec-sem)
7798 (unary32-defn HI .w 1 dec #xB #x0 #xE dec-sem)
7800 ;-------------------------------------------------------------
7802 ; divu - divide unsigned
7803 ; divx - divide extension
7804 ;-------------------------------------------------------------
7807 (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)
7808 (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)
7809 (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)
7811 (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)
7812 (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)
7813 (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)
7815 (div-src-defn 32 .l div dst32-24-Prefixed-SI
7816 (+ (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)
7817 div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000)
7819 (div-src-defn 32 .l divu dst32-24-Prefixed-SI
7820 (+ (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)
7821 udiv umod USI R2R0 R2R0 NoRemainder #x80000000 0
7823 (div-src-defn 32 .l divx dst32-24-Prefixed-SI
7824 (+ (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)
7825 div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000)
7828 ;-------------------------------------------------------------
7829 ; dsbb - decimal subtraction with borrow
7830 ; dsub - decimal subtraction
7831 ;-------------------------------------------------------------
7833 (define-pmacro (dsbb-sem mode src dst)
7834 (sequence ((mode result))
7835 (set result (subc mode dst src (not cbit)))
7836 (set cbit (sub-cflag mode dst src (not cbit)))
7837 (set-z-and-s result)
7842 (decimal-subtraction16-insn dsbb #xF #x7)
7844 ; dsbb.size #imm,dst
7845 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsbb X #x9 #x0 #xE dsbb-sem)
7846 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsbb X #x9 #x0 #xE dsbb-sem)
7848 (binary-arith32-src-dst-Prefixed QI QI .b 0 dsbb X #x1 #xA dsbb-sem)
7849 (binary-arith32-src-dst-Prefixed HI HI .w 1 dsbb X #x1 #xA dsbb-sem)
7851 (define-pmacro (dsub-sem mode src dst)
7852 (sequence ((mode result))
7853 (set result (subc mode dst src 0))
7854 (set cbit (sub-cflag mode dst src 0))
7855 (set-z-and-s result)
7860 (decimal-subtraction16-insn dsub #xD #x5)
7862 ; dsub.size #imm,dst
7863 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsub X #x9 #x1 #xE dsub-sem)
7864 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsub X #x9 #x1 #xE dsub-sem)
7866 (binary-arith32-src-dst-Prefixed QI QI .b 0 dsub X #x1 #x2 dsub-sem)
7867 (binary-arith32-src-dst-Prefixed HI HI .w 1 dsub X #x1 #x2 dsub-sem)
7869 ;-------------------------------------------------------------
7870 ; sub - binary subtraction
7871 ;-------------------------------------------------------------
7873 (define-pmacro (sub-sem mode src1 dst)
7874 (sequence ((mode result))
7875 (set result (sub mode dst src1))
7876 (set obit (sub-oflag mode dst src1 0))
7877 (set cbit (sub-cflag mode dst src1 0))
7879 (set-z-and-s result)))
7881 ; sub.size:G #imm,dst (m16 #1 m32 #1)
7882 (binary-arith-imm-dst sub G (f-0-4 7) (f-4-3 3) (f-8-4 5) #x8 #x3 #xE sub-sem)
7883 ; sub.b:S #imm8,dst3 (m16 #2)
7884 (binary-arith16-b-S-imm8-dst3 sub ".b" (f-0-4 8) (f-4-1 1) sub-sem)
7885 ; sub.BW:G src,dst (m16 #3 m32 #4)
7886 (binary-arith-src-dst sub G (f-0-4 #xA) (f-4-3 4) #x1 #xA sub-sem)
7887 ; sub.B.S src2,r0l/r0h (m16 #4)
7888 (binary-arith16-b-S-src2 sub (f-0-4 2) (f-4-1 1) sub-sem)
7889 ; sub.L:G #imm32,dst (m32 #2)
7890 (binary-arith32-imm-dst-defn SI SI .l 0 sub G #x9 #x3 #x1 sub-sem)
7891 ; sub.BW:S #imm,dst2 (m32 #3)
7892 (binary-arith32-s-imm-dst QI .b 0 sub #x0 #x7 sub-sem)
7893 (binary-arith32-s-imm-dst HI .w 1 sub #x0 #x7 sub-sem)
7894 ; sub.L:G src,dst (m32 #5)
7895 (binary-arith32-src-dst-defn SI SI .l 1 sub G #x1 #x0 sub-sem)
7897 ;-------------------------------------------------------------
7898 ; enter - enter function
7899 ; exitd - exit and deallocate stack frame
7900 ;-------------------------------------------------------------
7902 (define-pmacro (enter16-sem mach amt)
7904 (set (reg h-sp) (sub (reg h-sp) 2))
7905 (set (mem16 HI (reg h-sp)) (reg h-fb))
7906 (set (reg h-fb) (reg h-sp))
7907 (set (reg h-sp) (sub (reg h-sp) amt))))
7909 (define-pmacro (exit16-sem mach)
7910 (sequence ((SI newpc))
7911 (set (reg h-sp) (reg h-fb))
7912 (set (reg h-fb) (mem16 HI (reg h-sp)))
7913 (set (reg h-sp) (add (reg h-sp) 2))
7914 (set newpc (mem16 HI (reg h-sp)))
7915 (set (reg h-sp) (add (reg h-sp) 2))
7916 (set newpc (or newpc (sll (mem16 QI (reg h-sp)) (const 16))))
7917 (set (reg h-sp) (add (reg h-sp) 1))
7920 (define-pmacro (enter32-sem mach amt)
7922 (set (reg h-sp) (sub (reg h-sp) 4))
7923 (set (mem32 SI (reg h-sp)) (reg h-fb))
7924 (set (reg h-fb) (reg h-sp))
7925 (set (reg h-sp) (sub (reg h-sp) amt))))
7927 (define-pmacro (exit32-sem mach)
7928 (sequence ((SI newpc))
7929 (set (reg h-sp) (reg h-fb))
7930 (set (reg h-fb) (mem32 SI (reg h-sp)))
7931 (set (reg h-sp) (add (reg h-sp) 4))
7932 (set newpc (mem32 SI (reg h-sp)))
7933 (set (reg h-sp) (add (reg h-sp) 4))
7936 (dni enter16 "enter #Imm-16-QI" ((machine 16))
7937 ("enter #${Dsp-16-u8}")
7938 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 2) Dsp-16-u8)
7939 (enter16-sem 16 Dsp-16-u8)
7942 (dni exitd16 "exitd" ((machine 16))
7944 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 2))
7948 (dni enter32 "enter #Imm-8-QI" ((machine 32))
7949 ("enter #${Dsp-8-u8}")
7950 (+ (f-0-4 #xE) (f-4-4 #xC) Dsp-8-u8)
7951 (enter32-sem 32 Dsp-8-u8)
7954 (dni exitd32 "exitd" ((machine 32))
7956 (+ (f-0-4 #xF) (f-4-4 #xC))
7960 ;-------------------------------------------------------------
7961 ; fclr - flag register clear
7962 ; fset - flag register set
7963 ;-------------------------------------------------------------
7965 (define-pmacro (set-flags-sem flag)
7966 (sequence ((SI tmp))
7968 ((#x0) (set cbit 1))
7969 ((#x1) (set dbit 1))
7970 ((#x2) (set zbit 1))
7971 ((#x3) (set sbit 1))
7972 ((#x4) (set bbit 1))
7973 ((#x5) (set obit 1))
7974 ((#x6) (set ibit 1))
7975 ((#x7) (set ubit 1)))
7979 (define-pmacro (clear-flags-sem flag)
7980 (sequence ((SI tmp))
7982 ((#x0) (set cbit 0))
7983 ((#x1) (set dbit 0))
7984 ((#x2) (set zbit 0))
7985 ((#x3) (set sbit 0))
7986 ((#x4) (set bbit 0))
7987 ((#x5) (set obit 0))
7988 ((#x6) (set ibit 0))
7989 ((#x7) (set ubit 0)))
7993 (dni fclr16 "fclr flag" ((machine 16))
7995 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 5))
7996 (clear-flags-sem flags16)
7999 (dni fset16 "fset flag" ((machine 16))
8001 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 4))
8002 (set-flags-sem flags16)
8005 (dni fclr "fclr" ((machine 32))
8007 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xE) (f-12-1 1) flags32)
8008 (clear-flags-sem flags32)
8011 (dni fset "fset" ((machine 32))
8013 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xE) (f-12-1 1) flags32)
8014 (set-flags-sem flags32)
8017 ;-------------------------------------------------------------
8019 ;-------------------------------------------------------------
8021 (define-pmacro (inc-sem mode dest)
8022 (sequence ((mode result))
8023 (set result (add mode dest 1))
8024 (set-z-and-s result)
8031 "inc.b ${Dst16-3-S-8}"
8032 (+ (f-0-4 #xA) (f-4-1 #x0) Dst16-3-S-8)
8033 (inc-sem QI Dst16-3-S-8)
8039 "inc.w ${Dst16An-S}"
8040 (+ (f-0-4 #xB) (f-5-3 #x2) Dst16An-S)
8041 (inc-sem HI Dst16An-S)
8044 (unary32-defn QI .b 0 inc #xA #x0 #xE inc-sem)
8045 (unary32-defn HI .w 1 inc #xA #x0 #xE inc-sem)
8047 ;-------------------------------------------------------------
8048 ; freit - fast return from interrupt (m32)
8050 ; into - interrupt on overflow
8051 ;-------------------------------------------------------------
8054 (dni freit32 "FREIT" ((machine 32))
8056 (+ (f-0-4 9) (f-4-4 #xF))
8060 (dni int16 "int Dsp-10-u6" ((machine 16))
8061 ("int #${Dsp-10-u6}")
8062 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-2 3) Dsp-10-u6)
8063 (c-call VOID "do_int" pc Dsp-10-u6)
8066 (dni into16 "into" ((machine 16))
8068 (+ (f-0-4 #xF) (f-4-4 6))
8072 (dni int32 "int Dsp-8-u6" ((machine 32))
8073 ("int #${Dsp-8-u6}")
8074 (+ (f-0-4 #xB) (f-4-4 #xE) Dsp-8-u6 (f-14-2 0))
8075 (c-call VOID "do_int" pc Dsp-8-u6)
8078 (dni into32 "into" ((machine 32))
8080 (+ (f-0-4 #xB) (f-4-4 #xF))
8084 ;-------------------------------------------------------------
8086 ;-------------------------------------------------------------
8088 ; TODO add support to insns allowing index
8089 (define-pmacro (indexb-sem mode d) (set SrcIndex d) (set DstIndex d))
8090 (define-pmacro (indexbd-sem mode d) (set SrcIndex (const 0)) (set DstIndex d))
8091 (define-pmacro (indexbs-sem mode d) (set SrcIndex d) (set DstIndex (const 0)))
8092 (define-pmacro (indexw-sem mode d)
8093 (set SrcIndex (sll d (const 2))) (set DstIndex (sll d (const 2))))
8094 (define-pmacro (indexwd-sem mode d)
8095 (set SrcIndex (const 0)) (set DstIndex (sll d (const 2))))
8096 (define-pmacro (indexws-sem mode d)
8097 (set SrcIndex (sll d (const 2))) (set DstIndex (const 0)))
8098 (define-pmacro (indexl-sem mode d)
8099 (set SrcIndex d) (set DstIndex (sll d (const 2))))
8100 (define-pmacro (indexld-sem mode d)
8101 (set SrcIndex (const 0)) (set DstIndex (sll d (const 2))))
8102 (define-pmacro (indexls-sem mode d)
8103 (set SrcIndex (sll d (const 2))) (set DstIndex (const 0)))
8105 ; Note that "wbit" not where the size bit goes here, hence, it's
8106 ; always 0 in these calls but op2 differs instead.
8108 ; indexb src (index byte)
8109 (unary32-defn QI .b 0 indexb #x8 0 #x3 indexb-sem)
8110 (unary32-defn HI .w 0 indexb #x8 1 #x3 indexb-sem)
8111 ; indexbd src (index byte dest)
8112 (unary32-defn QI .b 0 indexbd #xA 0 3 indexbd-sem)
8113 (unary32-defn HI .w 0 indexbd #xA 1 3 indexbd-sem)
8114 ; indexbs src (index byte src)
8115 (unary32-defn QI .b 0 indexbs #xC 0 3 indexbs-sem)
8116 (unary32-defn HI .w 0 indexbs #xC 1 3 indexbs-sem)
8117 ; indexl src (index long)
8118 (unary32-defn QI .b 0 indexl 9 2 3 indexl-sem)
8119 (unary32-defn HI .w 0 indexl 9 3 3 indexl-sem)
8120 ; indexld src (index long dest)
8121 (unary32-defn QI .b 0 indexld #xB 2 3 indexld-sem)
8122 (unary32-defn HI .w 0 indexld #xB 3 3 indexld-sem)
8123 ; indexls src (index long src)
8124 (unary32-defn QI .b 0 indexls 9 0 3 indexls-sem)
8125 (unary32-defn HI .w 0 indexls 9 1 3 indexls-sem)
8126 ; indexw src (index word)
8127 (unary32-defn QI .b 0 indexw 8 2 3 indexw-sem)
8128 (unary32-defn HI .w 0 indexw 8 3 3 indexw-sem)
8129 ; indexwd src (index word dest)
8130 (unary32-defn QI .b 0 indexwd #xA 2 3 indexwd-sem)
8131 (unary32-defn HI .w 0 indexwd #xA 3 3 indexwd-sem)
8132 ; indexws (index word src)
8133 (unary32-defn QI .b 0 indexws #xC 2 3 indexws-sem)
8134 (unary32-defn HI .w 0 indexws #xC 3 3 indexws-sem)
8136 ;-------------------------------------------------------------
8137 ; jcc - jump on condition
8138 ;-------------------------------------------------------------
8140 (define-pmacro (jcnd32-sem cnd label)
8143 ((#x00) (if (not cbit) (set pc label))) ;ltu nc
8144 ((#x01) (if (not (and cbit (not zbit))) (set pc label))) ;leu
8145 ((#x02) (if (not zbit) (set pc label))) ;ne nz
8146 ((#x03) (if (not sbit) (set pc label))) ;pz
8147 ((#x04) (if (not obit) (set pc label))) ;no
8148 ((#x05) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt
8149 ((#x06) (if (not (xor sbit obit)) (set pc label))) ;ge
8150 ((#x08) (if (trunc BI cbit) (set pc label))) ;geu c
8151 ((#x09) (if (and cbit (not zbit)) (set pc label))) ;gtu
8152 ((#x0a) (if (trunc BI zbit) (set pc label))) ;eq z
8153 ((#x0b) (if (trunc BI sbit) (set pc label))) ;n
8154 ((#x0c) (if (trunc BI obit) (set pc label))) ;o
8155 ((#x0d) (if (or zbit (xor sbit obit)) (set pc label))) ;le
8156 ((#x0e) (if (xor sbit obit) (set pc label))) ;lt
8161 (define-pmacro (jcnd16-sem cnd label)
8164 ((#x00) (if (trunc BI cbit) (set pc label))) ;geu c
8165 ((#x01) (if (and cbit (not zbit)) (set pc label))) ;gtu
8166 ((#x02) (if (trunc BI zbit) (set pc label))) ;eq z
8167 ((#x03) (if (trunc BI sbit) (set pc label))) ;n
8168 ((#x04) (if (not cbit) (set pc label))) ;ltu nc
8169 ((#x05) (if (not (and cbit (not zbit))) (set pc label))) ;leu
8170 ((#x06) (if (not zbit) (set pc label))) ;ne nz
8171 ((#x07) (if (not sbit) (set pc label))) ;pz
8172 ((#x08) (if (or zbit (xor sbit obit)) (set pc label))) ;le
8173 ((#x09) (if (trunc BI obit) (set pc label))) ;o
8174 ((#x0a) (if (not (xor sbit obit)) (set pc label))) ;ge
8175 ((#x0c) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt
8176 ((#x0d) (if (not obit) (set pc label))) ;no
8177 ((#x0e) (if (xor sbit obit) (set pc label))) ;lt
8184 (RL_JUMP RELAXABLE (machine 16))
8185 "j$cond16j5 ${Lab-8-8}"
8186 (+ (f-0-4 #x6) (f-4-1 1) cond16j5 Lab-8-8)
8187 (jcnd16-sem cond16j5 Lab-8-8)
8193 (RL_JUMP RELAXABLE (machine 16))
8194 "j$cond16j ${Lab-16-8}"
8195 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xC) cond16j Lab-16-8)
8196 (jcnd16-sem cond16j Lab-16-8)
8202 (RL_JUMP RELAXABLE (machine 32))
8203 "j$cond32j ${Lab-8-8}"
8204 (+ (f-0-1 1) (f-4-3 5) cond32j Lab-8-8)
8205 (jcnd32-sem cond32j Lab-8-8)
8209 ;-------------------------------------------------------------
8211 ;-------------------------------------------------------------
8213 ; jmp.s label3 (m16 #1)
8214 (dni jmp16.s "jmp.s Lab-5-3" (RL_JUMP RELAXABLE (machine 16))
8215 ("jmp.s ${Lab-5-3}")
8216 (+ (f-0-4 6) (f-4-1 0) Lab-5-3)
8217 (sequence () (set pc Lab-5-3))
8219 ; jmp.b label8 (m16 #2)
8220 (dni jmp16.b "jmp.b Lab-8-8" (RL_JUMP RELAXABLE (machine 16))
8221 ("jmp.b ${Lab-8-8}")
8222 (+ (f-0-4 #xF) (f-4-4 #xE) Lab-8-8)
8223 (sequence () (set pc Lab-8-8))
8225 ; jmp.w label16 (m16 #3)
8226 (dni jmp16.w "jmp.w Lab-8-16" (RL_JUMP RELAXABLE (machine 16))
8227 ("jmp.w ${Lab-8-16}")
8228 (+ (f-0-4 #xF) (f-4-4 4) Lab-8-16)
8229 (sequence () (set pc Lab-8-16))
8231 ; jmp.a label24 (m16 #4)
8232 (dni jmp16.a "jmp.a Lab-8-24" (RL_JUMP RELAXABLE (machine 16))
8233 ("jmp.a ${Lab-8-24}")
8234 (+ (f-0-4 #xF) (f-4-4 #xC) Lab-8-24)
8235 (sequence () (set pc Lab-8-24))
8238 (define-pmacro (jmp16-sem mode dst)
8239 (set pc (and dst #xfffff))
8241 (define-pmacro (jmp32-sem mode dst)
8244 ; jmpi.w dst (m16 #1 m32 #2)
8245 (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)
8246 (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)
8247 ; jmpi.a dst (m16 #2 m32 #2)
8248 (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)
8249 (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)
8250 ; jmps imm8 (m16 #1)
8251 (dni jmps16 "jmps Imm-8-QI" ((machine 16))
8252 ("jmps #${Imm-8-QI}")
8253 (+ (f-0-4 #xE) (f-4-4 #xE) Imm-8-QI)
8254 (sequence () (set pc Imm-8-QI))
8256 ; jmp.s label3 (m32 #1)
8259 (RL_JUMP RELAXABLE (machine 32))
8260 "jmp.s ${Lab32-jmp-s}"
8261 (+ (f-0-2 1) (f-4-3 5) Lab32-jmp-s)
8262 (set pc Lab32-jmp-s)
8265 ; jmp.b label8 (m32 #2)
8266 (dni jmp32.b "jmp.b Lab-8-8" (RL_JUMP RELAXABLE (machine 32))
8267 ("jmp.b ${Lab-8-8}")
8268 (+ (f-0-4 #xB) (f-4-4 #xB) Lab-8-8)
8271 ; jmp.w label16 (m32 #3)
8272 (dni jmp32.w "jmp.w Lab-8-16" (RL_JUMP RELAXABLE (machine 32))
8273 ("jmp.w ${Lab-8-16}")
8274 (+ (f-0-4 #xC) (f-4-4 #xE) Lab-8-16)
8277 ; jmp.a label24 (m32 #4)
8278 (dni jmp32.a "jmp.a Lab-8-24" (RL_JUMP RELAXABLE (machine 32))
8279 ("jmp.a ${Lab-8-24}")
8280 (+ (f-0-4 #xC) (f-4-4 #xC) Lab-8-24)
8283 ; jmp.s imm8 (m32 #1)
8284 (dni jmps32 "jmps Imm-8-QI" (RL_JUMP (machine 32))
8285 ("jmps #${Imm-8-QI}")
8286 (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI)
8290 ;-------------------------------------------------------------
8291 ; jsr jump subroutine
8292 ;-------------------------------------------------------------
8294 (define-pmacro (jsr16-sem length dst)
8295 (sequence ((SI tpc))
8296 (set tpc (add pc length))
8297 (set (reg h-sp) (sub (reg h-sp) 2))
8298 (set (mem16 HI (reg h-sp)) (srl (and tpc #xffff00) 8))
8299 (set (reg h-sp) (sub (reg h-sp) 1))
8300 (set (mem16 QI (reg h-sp)) (and tpc #xff))
8304 (define-pmacro (jsr32-sem length dst)
8305 (sequence ((SI tpc))
8306 (set tpc (add pc length))
8307 (set (reg h-sp) (sub (reg h-sp) 2))
8308 (set (mem32 HI (reg h-sp)) (srl (and tpc #xffff0000) 16))
8309 (set (reg h-sp) (sub (reg h-sp) 2))
8310 (set (mem32 HI (reg h-sp)) (and tpc #xffff))
8315 ; jsr.w label16 (m16 #1)
8316 (dni jsr16.w "jsr.w Lab-8-16" (RL_JUMP RELAXABLE (machine 16))
8317 ("jsr.w ${Lab-8-16}")
8318 (+ (f-0-4 #xF) (f-4-4 5) Lab-8-16)
8319 (jsr16-sem 3 Lab-8-16)
8321 ; jsr.a label24 (m16 #2)
8322 (dni jsr16.a "jsr.a Lab-8-24" (RL_JUMP RELAXABLE (machine 16))
8323 ("jsr.a ${Lab-8-24}")
8324 (+ (f-0-4 #xF) (f-4-4 #xD) Lab-8-24)
8325 (jsr16-sem 4 Lab-8-24)
8327 (define-pmacro (jsri-defn mode op16 op16-1 op16-2 op16-3 op16-sem
8328 op32 op32-1 op32-2 op32-3 op32-4 op32-sem len)
8330 (dni (.sym jsri16 mode - op16)
8331 (.str "jsri." mode " " op16)
8332 (RL_1ADDR (machine 16))
8333 (.str "jsri." mode " ${" op16 "}")
8334 (+ op16-1 op16-2 op16-3 op16)
8337 (dni (.sym jsri32 mode - op32)
8338 (.str "jsri." mode " " op32)
8339 (RL_1ADDR (machine 32))
8340 (.str "jsri." mode " ${" op32 "}")
8341 (+ op32-1 op32-2 op32-3 op32-4 op32)
8346 ; jsri.w dst (m16 #1 m32 #1))
8347 (jsri-defn w dst16-16-20ar-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8348 dst32-16-24-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 4)
8349 (jsri-defn w dst16-16-16sa-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8350 dst32-16-16sa-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 4)
8351 (jsri-defn w dst16-16-8-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8352 dst32-16-8-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 3)
8353 (jsri-defn w dst16-basic-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8354 dst32-basic-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 2)
8356 ; jsri.a (m16 #2 m32 #2)
8357 (jsri-defn a dst16-16-20ar-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8358 dst32-16-24-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 4)
8359 (jsri-defn a dst16-16-8-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8360 dst32-16-8-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 3)
8361 (jsri-defn a dst16-16-16sa-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8362 dst32-16-16sa-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 4)
8363 (jsri-defn a dst16-basic-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8364 dst32-basic-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 2)
8366 (dni jsri32.a "jsr.w dst32-16-24-Unprefixed-HI" (RL_1ADDR (machine 32))
8367 ("jsri.a ${dst32-16-24-Unprefixed-SI}")
8368 (+ (f-0-4 #x9) (f-7-1 0) dst32-16-24-Unprefixed-SI (f-10-2 #x0) (f-12-4 #x1))
8369 (jsr32-sem 6 dst32-16-24-Unprefixed-SI)
8371 ; jsr.w label16 (m32 #1)
8372 (dni jsr32.w "jsr.w label" (RL_JUMP RELAXABLE (machine 32))
8373 ("jsr.w ${Lab-8-16}")
8374 (+ (f-0-4 #xC) (f-4-4 #xF) Lab-8-16)
8375 (jsr32-sem 3 Lab-8-16)
8377 ; jsr.a label16 (m32 #2)
8378 (dni jsr32.a "jsr.a label" (RL_JUMP (machine 32))
8379 ("jsr.a ${Lab-8-24}")
8380 (+ (f-0-4 #xC) (f-4-4 #xD) Lab-8-24)
8381 (jsr32-sem 4 Lab-8-24)
8383 ; jsrs imm8 (m16 #1)
8384 (dni jsrs16 "jsrs Imm-8-QI" ((machine 16))
8385 ("jsrs #${Imm-8-QI}")
8386 (+ (f-0-4 #xE) (f-4-4 #xF) Imm-8-QI)
8387 (jsr16-sem 2 Imm-8-QI)
8389 ; jsrs imm8 (m32 #1)
8390 (dni jsrs "jsrs #Imm-8-QI" ((machine 32))
8391 ("jsrs #${Imm-8-QI}")
8392 (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI)
8393 (jsr32-sem 2 Imm-8-QI)
8396 ;-------------------------------------------------------------
8397 ; ldc - load control register
8398 ; stc - store control register
8399 ;-------------------------------------------------------------
8401 (define-pmacro (ldc32-cr1-sem src dst)
8404 ((#x0) (set (reg h-dct0) src))
8405 ((#x1) (set (reg h-dct1) src))
8406 ((#x2) (sequence ((HI tflag))
8408 (if (and tflag #x1) (set cbit 1))
8409 (if (and tflag #x2) (set dbit 1))
8410 (if (and tflag #x4) (set zbit 1))
8411 (if (and tflag #x8) (set sbit 1))
8412 (if (and tflag #x10) (set bbit 1))
8413 (if (and tflag #x20) (set obit 1))
8414 (if (and tflag #x40) (set ibit 1))
8415 (if (and tflag #x80) (set ubit 1))))
8416 ((#x3) (set (reg h-svf) src))
8417 ((#x4) (set (reg h-drc0) src))
8418 ((#x5) (set (reg h-drc1) src))
8419 ((#x6) (set (reg h-dmd0) src))
8420 ((#x7) (set (reg h-dmd1) src))
8424 (define-pmacro (ldc32-cr2-sem src dst)
8427 ((#x0) (set (reg h-intb) src))
8428 ((#x1) (set (reg h-sp) src))
8429 ((#x2) (set (reg h-sb) src))
8430 ((#x3) (set (reg h-fb) src))
8431 ((#x4) (set (reg h-svp) src))
8432 ((#x5) (set (reg h-vct) src))
8433 ((#x7) (set (reg h-isp) src))
8437 (define-pmacro (ldc32-cr3-sem src dst)
8440 ((#x2) (set (reg h-dma0) src))
8441 ((#x3) (set (reg h-dma1) src))
8442 ((#x4) (set (reg h-dra0) src))
8443 ((#x5) (set (reg h-dra1) src))
8444 ((#x6) (set (reg h-dsa0) src))
8445 ((#x7) (set (reg h-dsa1) src))
8449 (define-pmacro (ldc16-sem src dst)
8452 ((#x1) (set (reg h-intb) src))
8453 ((#x2) (set (reg h-intb) (or (reg h-intb) (sll src (const 16)))))
8454 ((#x3) (sequence ((HI tflag))
8456 (if (and tflag #x1) (set cbit 1))
8457 (if (and tflag #x2) (set dbit 1))
8458 (if (and tflag #x4) (set zbit 1))
8459 (if (and tflag #x8) (set sbit 1))
8460 (if (and tflag #x10) (set bbit 1))
8461 (if (and tflag #x20) (set obit 1))
8462 (if (and tflag #x40) (set ibit 1))
8463 (if (and tflag #x80) (set ubit 1))))
8464 ((#x4) (set (reg h-isp) src))
8465 ((#x5) (set (reg h-sp) src))
8466 ((#x6) (set (reg h-sb) src))
8467 ((#x7) (set (reg h-fb) src))
8472 (define-pmacro (stc32-cr1-sem src dst)
8475 ((#x0) (set dst (reg h-dct0)))
8476 ((#x1) (set dst (reg h-dct1)))
8477 ((#x2) (sequence ((HI tflag))
8479 (if (eq cbit 1) (set tflag (or tflag #x1)))
8480 (if (eq dbit 1) (set tflag (or tflag #x2)))
8481 (if (eq zbit 1) (set tflag (or tflag #x4)))
8482 (if (eq sbit 1) (set tflag (or tflag #x8)))
8483 (if (eq bbit 1) (set tflag (or tflag #x10)))
8484 (if (eq obit 1) (set tflag (or tflag #x20)))
8485 (if (eq ibit 1) (set tflag (or tflag #x40)))
8486 (if (eq ubit 1) (set tflag (or tflag #x80)))
8488 ((#x3) (set dst (reg h-svf)))
8489 ((#x4) (set dst (reg h-drc0)))
8490 ((#x5) (set dst (reg h-drc1)))
8491 ((#x6) (set dst (reg h-dmd0)))
8492 ((#x7) (set dst (reg h-dmd1)))
8496 (define-pmacro (stc32-cr2-sem src dst)
8499 ((#x0) (set dst (reg h-intb)))
8500 ((#x1) (set dst (reg h-sp)))
8501 ((#x2) (set dst (reg h-sb)))
8502 ((#x3) (set dst (reg h-fb)))
8503 ((#x4) (set dst (reg h-svp)))
8504 ((#x5) (set dst (reg h-vct)))
8505 ((#x7) (set dst (reg h-isp)))
8509 (define-pmacro (stc32-cr3-sem src dst)
8512 ((#x2) (set dst (reg h-dma0)))
8513 ((#x3) (set dst (reg h-dma1)))
8514 ((#x4) (set dst (reg h-dra0)))
8515 ((#x5) (set dst (reg h-dra1)))
8516 ((#x6) (set dst (reg h-dsa0)))
8517 ((#x7) (set dst (reg h-dsa1)))
8521 (define-pmacro (stc16-sem src dst)
8524 ((#x1) (set dst (and (reg h-intb) (const #xffff))))
8525 ((#x2) (set dst (srl (reg h-intb) (const 16))))
8526 ((#x3) (sequence ((HI tflag))
8528 (if (eq cbit 1) (set tflag (or tflag #x1)))
8529 (if (eq dbit 1) (set tflag (or tflag #x2)))
8530 (if (eq zbit 1) (set tflag (or tflag #x4)))
8531 (if (eq sbit 1) (set tflag (or tflag #x8)))
8532 (if (eq bbit 1) (set tflag (or tflag #x10)))
8533 (if (eq obit 1) (set tflag (or tflag #x20)))
8534 (if (eq ibit 1) (set tflag (or tflag #x40)))
8535 (if (eq ubit 1) (set tflag (or tflag #x80)))
8537 ((#x4) (set dst (reg h-isp)))
8538 ((#x5) (set dst (reg h-sp)))
8539 ((#x6) (set dst (reg h-sb)))
8540 ((#x7) (set dst (reg h-fb)))
8545 (dni ldc16.imm16 "ldc #imm,dst" ((machine 16))
8546 ("ldc #${Imm-16-HI},${cr16}")
8547 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 0) cr16 Imm-16-HI)
8548 (ldc16-sem Imm-16-HI cr16)
8551 (dni ldc16.dst "ldc src,dest" ((machine 16))
8552 ("ldc ${dst16-16-HI},${cr16}")
8553 (+ (f-0-4 7) (f-4-4 #xA) (f-8-1 1) cr16 dst16-16-HI)
8554 (ldc16-sem dst16-16-HI cr16)
8556 ; ldc src,dest (m32c #4)
8557 (dni ldc32.src-cr1 "ldc src,dst" ((machine 32))
8558 ("ldc ${dst32-24-Prefixed-HI},${cr1-Prefixed-32}")
8559 (+ (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)
8560 (ldc32-cr1-sem dst32-24-Prefixed-HI cr1-Prefixed-32)
8562 ; ldc src,dest (m32c #5)
8563 (dni ldc32.src-cr2 "ldc src,dest" ((machine 32))
8564 ("ldc ${dst32-16-Unprefixed-SI},${cr2-32}")
8565 (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 0) cr2-32)
8566 (ldc32-cr2-sem dst32-16-Unprefixed-SI cr2-32)
8568 ; ldc src,dest (m32c #6)
8569 (dni ldc32.src-cr3 "ldc src,dst" ((machine 32))
8570 ("ldc ${dst32-24-Prefixed-SI},${cr3-Prefixed-32}")
8571 (+ (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)
8572 (ldc32-cr3-sem dst32-24-Prefixed-SI cr3-Prefixed-32)
8574 ; ldc src,dest (m32c #1)
8575 (dni ldc32.imm16-cr1 "ldc #imm,dst" ((machine 32))
8576 ("ldc #${Imm-16-HI},${cr1-Unprefixed-32}")
8577 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32 Imm-16-HI)
8578 (ldc32-cr1-sem Imm-16-HI cr1-Unprefixed-32)
8580 ; ldc src,dest (m32c #2)
8581 (dni ldc32.imm16-cr2 "ldc #imm,dst" ((machine 32))
8582 ("ldc #${Dsp-16-u24},${cr2-32}")
8583 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 2) (f-12-1 1) cr2-32 Dsp-16-u24)
8584 (ldc32-cr2-sem Dsp-16-u24 cr2-32)
8586 ; ldc src,dest (m32c #3)
8587 (dni ldc32.imm16-cr3 "ldc #imm,dst" ((machine 32))
8588 ("ldc #${Dsp-16-u24},${cr3-Unprefixed-32}")
8589 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 6) (f-12-1 1) cr3-Unprefixed-32 Dsp-16-u24)
8590 (ldc32-cr3-sem Dsp-16-u24 cr3-Unprefixed-32)
8593 (dni stc16.src "stc src,dest" ((machine 16))
8594 ("stc ${cr16},${dst16-16-HI}")
8595 (+ (f-0-4 7) (f-4-4 #xB) (f-8-1 1) cr16 dst16-16-HI)
8596 (stc16-sem cr16 dst16-16-HI )
8599 (dni stc16.pc "stc pc,dest" ((machine 16))
8600 ("stc pc,${dst16-16-HI}")
8601 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xC) dst16-16-HI)
8602 (sequence () (set dst16-16-HI (reg h-pc)))
8605 (dni stc32.src-cr1 "stc src,dst" ((machine 32))
8606 ("stc ${cr1-Prefixed-32},${dst32-24-Prefixed-HI}")
8607 (+ (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)
8608 (stc32-cr1-sem cr1-Prefixed-32 dst32-24-Prefixed-HI )
8611 (dni stc32.src-cr2 "stc src,dest" ((machine 32))
8612 ("stc ${cr2-32},${dst32-16-Unprefixed-SI}")
8613 (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 2) cr2-32)
8614 (stc32-cr2-sem cr2-32 dst32-16-Unprefixed-SI )
8617 (dni stc32.src-cr3 "stc src,dst" ((machine 32))
8618 ("stc ${cr3-Prefixed-32},${dst32-24-Prefixed-SI}")
8619 (+ (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)
8620 (stc32-cr3-sem cr3-Prefixed-32 dst32-24-Prefixed-SI )
8623 ;-------------------------------------------------------------
8624 ; ldctx - load context
8625 ; stctx - store context
8626 ;-------------------------------------------------------------
8629 (dni ldctx16 "ldctx abs16,abs24" ((machine 16))
8630 ("ldctx ${Dsp-16-u16},${Dsp-32-u24}")
8631 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24)
8634 (dni ldctx32 "ldctx abs16,abs24" ((machine 32))
8635 ("ldctx ${Dsp-16-u16},${Dsp-32-u24}")
8636 (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xC) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24)
8639 (dni stctx16 "stctx abs16,abs24" ((machine 16))
8640 ("stctx ${Dsp-16-u16},${Dsp-32-u24}")
8641 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24)
8644 (dni stctx32 "stctx abs16,abs24" ((machine 32))
8645 ("stctx ${Dsp-16-u16},${Dsp-32-u24}")
8646 (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xD) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24)
8650 ;-------------------------------------------------------------
8651 ; lde - load from extra far data area (m16)
8652 ; ste - store to extra far data area (m16)
8653 ;-------------------------------------------------------------
8661 ;-------------------------------------------------------------
8662 ; ldipl - load interrupt permission level
8663 ;-------------------------------------------------------------
8666 ; ldintb <==> ldc #imm,intbh ; ldc #imm,intbl
8668 (dni ldipl16.imm "ldipl #imm" ((machine 16))
8669 ("ldipl #${Imm-13-u3}")
8670 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xA) (f-12-1 0) Imm-13-u3)
8673 (dni ldipl32.imm "ldipl #imm" ((machine 32))
8674 ("ldipl #${Imm-13-u3}")
8675 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xE) (f-12-1 1) Imm-13-u3)
8680 ;-------------------------------------------------------------
8681 ; max - maximum value
8682 ;-------------------------------------------------------------
8684 ; TODO check semantics for min -1,0
8685 (define-pmacro (max-sem mode src dst)
8687 (if (gt mode src dst)
8688 (set mode dst src)))
8691 ; max.size:G #imm,dst
8692 (binary-arith32-imm-dst-Prefixed QI QI .b 0 max X #x8 #x3 #xF max-sem)
8693 (binary-arith32-imm-dst-Prefixed HI HI .w 1 max X #x8 #x3 #xF max-sem)
8696 (binary-arith32-src-dst-Prefixed QI QI .b 0 max X #x1 #xD max-sem)
8697 (binary-arith32-src-dst-Prefixed HI HI .w 1 max X #x1 #xD max-sem)
8699 ;-------------------------------------------------------------
8700 ; min - minimum value
8701 ;-------------------------------------------------------------
8703 (define-pmacro (min-sem mode src dst)
8705 (if (lt mode src dst)
8706 (set mode dst src)))
8709 ; min.size:G #imm,dst
8710 (binary-arith32-imm-dst-Prefixed QI QI .b 0 min X #x8 #x2 #xF min-sem)
8711 (binary-arith32-imm-dst-Prefixed HI HI .w 1 min X #x8 #x2 #xF min-sem)
8714 (binary-arith32-src-dst-Prefixed QI QI .b 0 min X #x1 #xC min-sem)
8715 (binary-arith32-src-dst-Prefixed HI HI .w 1 min X #x1 #xC min-sem)
8717 ;-------------------------------------------------------------
8719 ;-------------------------------------------------------------
8721 (define-pmacro (mov-sem mode src1 dst)
8722 (sequence ((mode result))
8724 (set-z-and-s result)
8725 (set mode dst src1))
8728 (define-pmacro (mov-dspsp-dst-sem mach mode src1 dst)
8729 (set dst (mem-mach mach mode (add sp src1)))
8732 (define-pmacro (mov-src-dspsp-sem mach mode src dst1)
8733 (set (mem-mach mach mode (add sp dst1)) src)
8736 (define-pmacro (mov16-imm-an-defn size mode imm regn op1 op2)
8737 (dni (.sym mov16. size .S-imm- regn)
8738 (.str "mov." size ":S " imm "," regn)
8740 (.str "mov." size "$S #${" imm "}," regn)
8742 (mov-sem mode imm (reg (.sym h- regn)))
8745 ; mov.size:G #imm,dst (m16 #1 m32 #1)
8746 (binary-arith-imm-dst mov G (f-0-4 7) (f-4-3 2) (f-8-4 #xC) #x9 #x2 #xF mov-sem)
8747 ; mov.L:G #imm32,dst (m32 #2)
8748 (binary-arith32-imm-dst-defn SI SI .l 0 mov G #xB #x3 #x1 mov-sem)
8749 ; mov.BW:S #imm,dst2 (m32 #4)
8750 (binary-arith32-s-imm-dst QI .b 0 mov #x0 #x2 mov-sem)
8751 (binary-arith32-s-imm-dst HI .w 1 mov #x0 #x2 mov-sem)
8752 ; mov.b:S #imm8,dst3 (m16 #3)
8753 (binary-arith16-b-S-imm8-dst3 mov ".b" (f-0-4 #xC) (f-4-1 0) mov-sem)
8754 ; mov.b:S #imm8,aN (m16 #4)
8755 (mov16-imm-an-defn b QI Imm-8-QI a0 (f-0-4 #xE) (f-4-4 2))
8756 (mov16-imm-an-defn b QI Imm-8-QI a1 (f-0-4 #xE) (f-4-4 #xA))
8757 (mov16-imm-an-defn w HI Imm-8-HI a0 (f-0-4 #xA) (f-4-4 2))
8758 (mov16-imm-an-defn w HI Imm-8-HI a1 (f-0-4 #xA) (f-4-4 #xA))
8759 ; mov.WL:S #imm,A0/A1 (m32 #5)
8760 (define-pmacro (mov32-wl-s-defn mode sz op1 imm regn op2)
8761 (dni (.sym mov32- sz - regn)
8762 (.str "mov." sz ":s" imm "," regn)
8764 (.str "mov." sz "$S #${" imm "}," regn)
8765 (+ (f-0-4 op1) (f-4-4 op2) imm)
8766 (mov-sem mode imm (reg (.sym h- regn)))
8769 (mov32-wl-s-defn HI w #x9 Imm-8-HI a0 #xC)
8770 (mov32-wl-s-defn HI w #x9 Imm-8-HI a1 #xD)
8771 (mov32-wl-s-defn SI l #xB Dsp-8-s24 a0 #xC)
8772 (mov32-wl-s-defn SI l #xB Dsp-8-s24 a1 #xD)
8774 ; mov.size:Q #imm4,dst (m16 #2 m32 #3)
8775 (binary-arith16-imm4-dst-defn QI .b 0 0 mov (f-0-4 #xD) (f-4-3 4) mov-sem)
8776 (binary-arith16-imm4-dst-defn HI .w 0 1 mov (f-0-4 #xD) (f-4-3 4) mov-sem)
8777 (binary-arith32-imm4-dst-defn QI .b 1 0 mov #x7 #x2 mov-sem)
8778 (binary-arith32-imm4-dst-defn HI .w 1 1 mov #x7 #x2 mov-sem)
8780 ; mov.BW:Z #0,dst (m16 #5 m32 #6)
8781 (dni mov16.b-Z-imm8-dst3
8782 "mov.b:Z #0,Dst16-3-S-8"
8784 "mov.b$Z #0,${Dst16-3-S-8}"
8785 (+ (f-0-4 #xB) (f-4-1 #x0) Dst16-3-S-8)
8786 (mov-sem QI (const 0) Dst16-3-S-8)
8788 ; (binary-arith16-b-Z-imm8-dst3 mov ".b" (f-0-4 #xB) (f-4-1 0) mov-sem)
8789 (binary-arith32-z-imm-dst QI .b 0 mov #x0 #x1 mov-sem)
8790 (binary-arith32-z-imm-dst HI .w 1 mov #x0 #x1 mov-sem)
8791 ; mov.BW:G src,dst (m16 #6 m32 #7)
8792 (binary-arith-src-dst mov G (f-0-4 #x7) (f-4-3 1) #x1 #xB mov-sem)
8793 ; mov.B:S src2,a0/a1 (m16 #7)
8794 (dni (.sym mov 16 .b.S-An)
8795 (.str mov ".b:S src2,a[01]")
8797 (.str mov ".b$S ${src16-2-S},${Dst16AnQI-S}")
8798 (+ (f-0-4 #x3) (f-4-1 0) Dst16AnQI-S src16-2-S)
8799 (mov-sem QI src16-2-S Dst16AnQI-S)
8801 (define-pmacro (mov16-b-s-an-defn op1 op2 op2c)
8802 (dni (.sym mov16.b.S- op1 - op2)
8803 (.str mov ".b:S " op1 "," op2)
8805 (.str mov ".b$S " op1 "," op2)
8806 (+ (f-0-4 #x3) op2c)
8807 (mov-sem QI (reg (.sym h- op1)) (reg (.sym h- op2)))
8810 (mov16-b-s-an-defn r0l a1 (f-4-4 #x4))
8811 (mov16-b-s-an-defn r0h a0 (f-4-4 #x0))
8813 ; mov.L:G src,dst (m32 #8)
8814 (binary-arith32-src-dst-defn SI SI .l 1 mov G #x1 #x3 mov-sem)
8815 ; mov.B:S r0l/r0h,dst2 (m16 #8)
8816 (dni (.sym mov 16 .b.S-Rn-An)
8817 (.str mov ".b:S r0[lh],src2")
8819 (.str mov ".b$S ${Dst16RnQI-S},${src16-2-S}")
8820 (+ (f-0-4 #x0) (f-4-1 0) Dst16RnQI-S src16-2-S)
8821 (mov-sem QI src16-2-S Dst16RnQI-S)
8824 ; mov.B.S src2,r0l/r0h (m16 #9)
8825 (binary-arith16-b-S-src2 mov (f-0-4 0) (f-4-1 1) mov-sem)
8827 ; mov.BW:S src2,r0l/r0 (m32 #9)
8828 ; mov.BW:S src2,r1l/r1 (m32 #10)
8829 (define-pmacro (mov32-src-r sz szcode mode src dst opc1 opc2)
8831 (dni (.sym mov32. sz - src - dst)
8832 (.str "mov." sz "src," dst)
8834 (.str "mov." sz "$S ${" (.sym src - mode) "}," dst)
8835 (+ (f-0-2 opc1) (.sym src - mode) (f-4-3 opc2) (f-7-1 szcode))
8836 (mov-sem mode (.sym src - mode) (reg (.sym h- dst)))
8840 (mov32-src-r b 0 QI dst32-2-S-16 r0l 0 4)
8841 (mov32-src-r w 1 HI dst32-2-S-16 r0 0 4)
8842 (mov32-src-r b 0 QI dst32-2-S-8 r0l 0 4)
8843 (mov32-src-r w 1 HI dst32-2-S-8 r0 0 4)
8844 (mov32-src-r b 0 QI dst32-2-S-basic r1l 1 7)
8845 (mov32-src-r w 1 HI dst32-2-S-basic r1 1 7)
8846 (mov32-src-r b 0 QI dst32-2-S-16 r1l 1 7)
8847 (mov32-src-r w 1 HI dst32-2-S-16 r1 1 7)
8848 (mov32-src-r b 0 QI dst32-2-S-8 r1l 1 7)
8849 (mov32-src-r w 1 HI dst32-2-S-8 r1 1 7)
8851 ; mov.BW:S r0l/r0,dst2 (m32 #11)
8852 (define-pmacro (mov32-r-dest sz szcode mode src dst opc1 opc2)
8854 (dni (.sym mov32. sz - src - dst)
8855 (.str "mov." sz "src," dst)
8857 (.str "mov." sz "$S " src ",${" (.sym dst - mode) "}")
8858 (+ (f-0-2 opc1) (.sym dst - mode) (f-4-3 opc2) (f-7-1 szcode))
8859 (mov-sem mode (reg (.sym h- src)) (.sym dst - mode))
8863 (mov32-r-dest b 0 QI r0l dst32-2-S-16 0 0)
8864 (mov32-r-dest w 1 HI r0 dst32-2-S-16 0 0)
8865 (mov32-r-dest b 0 QI r0l dst32-2-S-8 0 0)
8866 (mov32-r-dest w 1 HI r0 dst32-2-S-8 0 0)
8868 ; mov.L:S src,A0/A1 (m32 #12)
8869 (define-pmacro (mov32-src-a src dst dstcode opc1 opc2)
8871 (dni (.sym mov32. sz - src - dst)
8872 (.str "mov." sz "src," dst)
8874 (.str "mov.l" "$S ${" (.sym src - SI) "}," dst)
8875 (+ (f-0-2 opc1) (.sym src - SI) (f-4-3 opc2) (f-7-1 dstcode))
8876 (mov-sem SI (.sym src - SI) (reg (.sym h- dst)))
8880 (mov32-src-a dst32-2-S-16 a0 0 1 4)
8881 (mov32-src-a dst32-2-S-16 a1 1 1 4)
8882 (mov32-src-a dst32-2-S-8 a0 0 1 4)
8883 (mov32-src-a dst32-2-S-8 a1 1 1 4)
8885 ; mov.BW:G dsp8[sp],dst (m16 #10 m32 #13)
8886 ; mov.BW:G src,dsp8[sp] (m16 #11 m32 #14)
8887 (mov-dspsp-dst mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #xB) #xB #x0 #xF mov-dspsp-dst-sem)
8888 (mov-src-dspsp mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #x3) #xA #x0 #xF mov-src-dspsp-sem)
8890 ;-------------------------------------------------------------
8891 ; mova - move effective address
8892 ;-------------------------------------------------------------
8894 (define-pmacro (mov16a-defn dst dstop dstcode)
8895 (dni (.sym mova16. src - dst)
8896 (.str "mova src," dst)
8898 (.str "mova ${dst16-16-Mova-HI}," dst)
8899 (+ (f-0-4 #xE) (f-4-4 #xB) dst16-16-Mova-HI (f-8-4 dstcode))
8900 (sequence () (set HI (reg dstop) dst16-16-Mova-HI))
8903 (mov16a-defn r0 h-r0 0)
8904 (mov16a-defn r1 h-r1 1)
8905 (mov16a-defn r2 h-r2 2)
8906 (mov16a-defn r3 h-r3 3)
8907 (mov16a-defn a0 h-a0 4)
8908 (mov16a-defn a1 h-a1 5)
8910 (define-pmacro (mov32a-defn dst dstop dstcode)
8911 (dni (.sym mova32. src - dst)
8912 (.str "mova src," dst)
8914 (.str "mova ${dst32-16-Unprefixed-Mova-SI}," dst)
8915 (+ (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))
8916 (sequence () (set SI (reg dstop) dst32-16-Unprefixed-Mova-SI))
8919 (mov32a-defn r2r0 h-r2r0 0)
8920 (mov32a-defn r3r1 h-r3r1 1)
8921 (mov32a-defn a0 h-a0 2)
8922 (mov32a-defn a1 h-a1 3)
8924 ;-------------------------------------------------------------
8925 ; movDir - move nibble
8926 ;-------------------------------------------------------------
8928 (define-pmacro (movdir-sem nib src dst)
8929 (sequence ((SI tmp))
8931 ((0) (set dst (or (and dst #xf0) (and src #xf))))
8932 ((1) (set dst (or (and dst #x0f) (sll (and src #xf) 4))))
8933 ((2) (set dst (or (and dst #xf0) (srl (and src #xf0) 4))))
8934 ((3) (set dst (or (and dst #x0f) (and src #xf0))))
8939 (define-pmacro (mov16dir-1-defn nib dircode dir)
8940 (dni (.sym mov nib 16 ".r0l-dst")
8941 (.str "mov" nib " r0l,dst")
8943 (.str "mov" nib " r0l,${dst16-16-QI}")
8944 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI)
8945 (movdir-sem dircode (reg h-r0l) dst16-16-QI)
8948 (mov16dir-1-defn ll 0 8)
8949 (mov16dir-1-defn lh 1 #xA)
8950 (mov16dir-1-defn hl 2 9)
8951 (mov16dir-1-defn hh 3 #xB)
8952 (define-pmacro (mov16dir-2-defn nib dircode dir)
8953 (dni (.sym mov nib 16 ".src-r0l")
8954 (.str "mov" nib " src,r0l")
8956 (.str "mov" nib " ${dst16-16-QI},r0l")
8957 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI)
8958 (movdir-sem dircode dst16-16-QI (reg h-r0l))
8961 (mov16dir-2-defn ll 0 0)
8962 (mov16dir-2-defn lh 1 2)
8963 (mov16dir-2-defn hl 2 1)
8964 (mov16dir-2-defn hh 3 3)
8966 (define-pmacro (mov32dir-1-defn nib o1o0)
8967 (dni (.sym mov nib 32 ".r0l-dst")
8968 (.str "mov" nib " r0l,dst")
8970 (.str "mov" nib " r0l,${dst32-24-Prefixed-QI}")
8971 (+ (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))
8972 (movdir-sem o1o0 (reg h-r0l) dst32-24-Prefixed-QI)
8975 (mov32dir-1-defn ll 0)
8976 (mov32dir-1-defn lh 1)
8977 (mov32dir-1-defn hl 2)
8978 (mov32dir-1-defn hh 3)
8979 (define-pmacro (mov32dir-2-defn nib o1o0)
8980 (dni (.sym mov nib 32 ".src-r0l")
8981 (.str "mov" nib " src,r0l")
8983 (.str "mov" nib " ${dst32-24-Prefixed-QI},r0l")
8984 (+ (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))
8985 (movdir-sem o1o0 dst32-24-Prefixed-QI (reg h-r0l))
8988 (mov32dir-2-defn ll 0)
8989 (mov32dir-2-defn lh 1)
8990 (mov32dir-2-defn hl 2)
8991 (mov32dir-2-defn hh 3)
8993 ;-------------------------------------------------------------
8994 ; movx - move extend sign (m32)
8995 ;-------------------------------------------------------------
8997 (define-pmacro (movx-sem mode src dst)
8998 (sequence ((SI source) (SI result))
9000 (set-z-and-s result)
9005 (binary-arith32-imm-dst-defn QI SI "" 0 movx X #xB #x1 #x1 movx-sem)
9007 ;-------------------------------------------------------------
9009 ;-------------------------------------------------------------
9011 (define-pmacro (mul-sem mode src1 dst)
9012 (sequence ((mode result))
9013 (set obit (add-oflag mode src1 dst 0))
9014 (set result (mul mode src1 dst))
9019 (binary-arith-imm-dst mul G (f-0-4 7) (f-4-3 6) (f-8-4 5) #x8 #x1 #xF mul-sem)
9021 (binary-arith-src-dst mul G (f-0-4 #x7) (f-4-3 4) #x1 #xC mul-sem)
9023 (dni mul_l "mul.l src,r2r0" ((machine 32))
9024 ("mul.l ${dst32-24-Prefixed-SI},r2r0")
9025 (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #x8) (f-15-1 #x1) (f-18-2 #x1) (f-20-4 #xf)
9026 dst32-24-Prefixed-SI)
9029 (dni mulu_l "mulu.l src,r2r0" ((machine 32))
9030 ("mulu.l ${dst32-24-Prefixed-SI},r2r0")
9031 (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #x8) (f-15-1 #x1) (f-18-2 #x0) (f-20-4 #xf)
9032 dst32-24-Prefixed-SI)
9034 ;-------------------------------------------------------------
9035 ; mulex - multiple extend sign (m32)
9036 ;-------------------------------------------------------------
9039 ; (dni mulex-absolute-indirect "mulex [src]" ((machine 32))
9040 ; ("mulex ${dst32-24-absolute-indirect-HI}")
9041 ; (+ (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))
9042 ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-absolute-indirect-HI)))
9044 (dni mulex "mulex src" ((machine 32))
9045 ("mulex ${dst32-16-Unprefixed-Mulex-HI}")
9046 (+ (f-0-4 #xC) dst32-16-Unprefixed-Mulex-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
9047 (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-16-Unprefixed-Mulex-HI)))
9049 ; (dni mulex-indirect "mulex [src]" ((machine 32))
9050 ; ("mulex ${dst32-24-indirect-HI}")
9051 ; (+ (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))
9052 ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-indirect-HI)))
9055 ;-------------------------------------------------------------
9056 ; mulu - multiply unsigned
9057 ;-------------------------------------------------------------
9059 (define-pmacro (mulu-sem mode src1 dst)
9060 (sequence ((mode result))
9061 (set obit (add-oflag mode src1 dst 0))
9062 (set result (mul mode src1 dst))
9067 (binary-arith-imm-dst mulu G (f-0-4 7) (f-4-3 6) (f-8-4 4) #x8 #x0 #xF mulu-sem)
9069 (binary-arith-src-dst mulu G (f-0-4 #x7) (f-4-3 0) #x1 #x4 mulu-sem)
9071 ;-------------------------------------------------------------
9072 ; neg - twos complement
9073 ;-------------------------------------------------------------
9075 (define-pmacro (neg-sem mode dst)
9076 (sequence ((mode result))
9077 (set result (neg mode dst))
9078 (set-z-and-s result)
9083 (unary-insn neg (f-0-4 7) (f-4-3 2) (f-8-4 #x5) #xA #x2 #xF neg-sem)
9085 ;-------------------------------------------------------------
9086 ; not - twos complement
9087 ;-------------------------------------------------------------
9089 (define-pmacro (not-sem mode dst)
9090 (sequence ((mode result))
9091 (set result (not mode dst))
9092 (set-z-and-s result)
9097 (unary-insn-g not (f-0-4 7) (f-4-3 2) (f-8-4 #x7) #xA #x1 #xE not-sem)
9100 "not.b:s Dst16-3-S-8"
9102 "not.b:s ${Dst16-3-S-8}"
9103 (+ (f-0-4 #xb) (f-4-1 #x1) Dst16-3-S-8)
9104 (not-sem QI Dst16-3-S-8)
9107 ;-------------------------------------------------------------
9109 ;-------------------------------------------------------------
9115 (+ (f-0-4 #x0) (f-4-4 #x4))
9123 (+ (f-0-4 #xD) (f-4-4 #xE))
9127 ;-------------------------------------------------------------
9129 ;-------------------------------------------------------------
9131 (define-pmacro (or-sem mode src1 dst)
9132 (sequence ((mode result))
9133 (set result (or mode src1 dst))
9134 (set-z-and-s result)
9138 ; or.BW #imm,dst (m16 #1 m32 #1)
9139 (binary-arith-imm-dst or G (f-0-4 7) (f-4-3 3) (f-8-4 3) #x8 #x2 #xF or-sem)
9140 ; or.b:S #imm8,dst3 (m16 #2 m32 #2)
9141 (binary-arith16-b-S-imm8-dst3 or ".b" (f-0-4 9) (f-4-1 1) or-sem)
9142 (binary-arith32-s-imm-dst QI .b 0 or #x1 #x2 or-sem)
9143 (binary-arith32-s-imm-dst HI .w 1 or #x1 #x2 or-sem)
9144 ; or.BW src,dst (m16 #3 m32 #3)
9145 (binary-arith-src-dst or G (f-0-4 #x9) (f-4-3 4) #x1 #x5 or-sem)
9146 ; or.b:S src,r0[lh] (m16)
9147 (binary-arith16-b-S-src2 or (f-0-4 1) (f-4-1 1) or-sem)
9149 ;-------------------------------------------------------------
9150 ; pop - restore register/memory
9151 ;-------------------------------------------------------------
9153 ; TODO future: split this into .b and .w semantics
9154 (define-pmacro (pop-sem-mach mach mode dst)
9155 (sequence ((mode b_or_w) (SI length))
9157 (set b_or_w (srl b_or_w #x8))
9160 (set length 2)) ; .w
9163 ((1) (set dst (mem-mach mach QI (reg h-sp))))
9164 ((2) (set dst (mem-mach mach HI (reg h-sp)))))
9165 (set (reg h-sp) (add (reg h-sp) length))
9169 (define-pmacro (pop-sem16 mode dest) (pop-sem-mach 16 mode dest))
9170 (define-pmacro (pop-sem32 mode dest) (pop-sem-mach 32 mode dest))
9173 (unary-insn-mach-g 16 pop (f-0-4 7) (f-4-3 2) (f-8-4 #xD) pop-sem16 $G)
9175 (unary-insn-mach 32 pop #xB #x2 #xF pop-sem32)
9178 (dni pop16.b-s-rn "pop.b:S r0[lh]" ((machine 16))
9179 "pop.b$S ${Rn16-push-S-anyof}"
9180 (+ (f-0-4 #x9) Rn16-push-S-anyof (f-5-3 #x2))
9181 (pop-sem16 QI Rn16-push-S-anyof)
9184 (dni pop16.b-s-an "pop.w:S a[01]" ((machine 16))
9185 "pop.w$S ${An16-push-S-anyof}"
9186 (+ (f-0-4 #xD) An16-push-S-anyof (f-5-3 #x2))
9187 (pop-sem16 HI An16-push-S-anyof)
9190 ;-------------------------------------------------------------
9191 ; popc - pop control register
9192 ; pushc - push control register
9193 ;-------------------------------------------------------------
9195 (define-pmacro (popc32-cr1-sem mode dst)
9198 ((#x0) (set (reg h-dct0) (mem32 mode (reg h-sp))))
9199 ((#x1) (set (reg h-dct1) (mem32 mode (reg h-sp))))
9200 ((#x2) (sequence ((HI tflag))
9201 (set tflag (mem32 mode (reg h-sp)))
9202 (if (and tflag #x1) (set cbit 1))
9203 (if (and tflag #x2) (set dbit 1))
9204 (if (and tflag #x4) (set zbit 1))
9205 (if (and tflag #x8) (set sbit 1))
9206 (if (and tflag #x10) (set bbit 1))
9207 (if (and tflag #x20) (set obit 1))
9208 (if (and tflag #x40) (set ibit 1))
9209 (if (and tflag #x80) (set ubit 1))))
9210 ((#x3) (set (reg h-svf) (mem32 mode (reg h-sp))))
9211 ((#x4) (set (reg h-drc0) (mem32 mode (reg h-sp))))
9212 ((#x5) (set (reg h-drc1) (mem32 mode (reg h-sp))))
9213 ((#x6) (set (reg h-dmd0) (mem32 mode (reg h-sp))))
9214 ((#x7) (set (reg h-dmd1) (mem32 mode (reg h-sp))))
9216 (set (reg h-sp) (add (reg h-sp) 2))
9219 (define-pmacro (popc32-cr2-sem mode dst)
9222 ((#x0) (set (reg h-intb) (mem32 mode (reg h-sp))))
9223 ((#x1) (set (reg h-sp) (mem32 mode (reg h-sp))))
9224 ((#x2) (set (reg h-sb) (mem32 mode (reg h-sp))))
9225 ((#x3) (set (reg h-fb) (mem32 mode (reg h-sp))))
9226 ((#x7) (set (reg h-isp) (mem32 mode (reg h-sp))))
9228 (set (reg h-sp) (add (reg h-sp) 4))
9231 (define-pmacro (popc16-sem mode dst)
9234 ((#x1) (set (reg h-intb) (or (and (reg h-intb) #x0000)
9235 (mem16 mode (reg h-sp)))))
9236 ((#x2) (set (reg h-intb) (or (and (reg h-intb) #xffff0000)
9237 (mem16 mode (reg h-sp)))))
9238 ((#x3) (sequence ((HI tflag))
9239 (set tflag (mem16 mode (reg h-sp)))
9240 (if (and tflag #x1) (set cbit 1))
9241 (if (and tflag #x2) (set dbit 1))
9242 (if (and tflag #x4) (set zbit 1))
9243 (if (and tflag #x8) (set sbit 1))
9244 (if (and tflag #x10) (set bbit 1))
9245 (if (and tflag #x20) (set obit 1))
9246 (if (and tflag #x40) (set ibit 1))
9247 (if (and tflag #x80) (set ubit 1))))
9248 ((#x4) (set (reg h-isp) (mem16 mode (reg h-sp))))
9249 ((#x5) (set (reg h-sp) (mem16 mode (reg h-sp))))
9250 ((#x6) (set (reg h-sb) (mem16 mode (reg h-sp))))
9251 ((#x7) (set (reg h-fb) (mem16 mode (reg h-sp))))
9253 (set (reg h-sp) (add (reg h-sp) 2))
9256 ; popc dest (m16c #1)
9257 (dni popc16.imm16 "popc dst" ((machine 16))
9259 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 3) cr16)
9260 (popc16-sem HI cr16)
9262 ; popc dest (m32c #1)
9263 (dni popc32.imm16-cr1 "popc dst" ((machine 32))
9264 ("popc ${cr1-Unprefixed-32}")
9265 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32)
9266 (popc32-cr1-sem HI cr1-Unprefixed-32)
9268 ; popc dest (m32c #2)
9269 (dni popc32.imm16-cr2 "popc dst" ((machine 32))
9271 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 2) (f-12-1 1) cr2-32)
9272 (popc32-cr2-sem SI cr2-32)
9275 (define-pmacro (pushc32-cr1-sem mode dst)
9277 (set (reg h-sp) (sub (reg h-sp) 2))
9279 ((#x0) (set (mem32 mode (reg h-sp)) (reg h-dct0)))
9280 ((#x1) (set (mem32 mode (reg h-sp)) (reg h-dct1)))
9281 ((#x2) (sequence ((HI tflag))
9283 (if (eq cbit 1) (set tflag (or tflag #x1)))
9284 (if (eq dbit 1) (set tflag (or tflag #x2)))
9285 (if (eq zbit 1) (set tflag (or tflag #x4)))
9286 (if (eq sbit 1) (set tflag (or tflag #x8)))
9287 (if (eq bbit 1) (set tflag (or tflag #x10)))
9288 (if (eq obit 1) (set tflag (or tflag #x20)))
9289 (if (eq ibit 1) (set tflag (or tflag #x40)))
9290 (if (eq ubit 1) (set tflag (or tflag #x80)))
9291 (set (mem32 mode (reg h-sp)) tflag)))
9292 ((#x3) (set (mem32 mode (reg h-sp)) (reg h-svf)))
9293 ((#x4) (set (mem32 mode (reg h-sp)) (reg h-drc0)))
9294 ((#x5) (set (mem32 mode (reg h-sp)) (reg h-drc1)))
9295 ((#x6) (set (mem32 mode (reg h-sp)) (reg h-dmd0)))
9296 ((#x7) (set (mem32 mode (reg h-sp)) (reg h-dmd1)))
9300 (define-pmacro (pushc32-cr2-sem mode dst)
9302 (set (reg h-sp) (sub (reg h-sp) 4))
9304 ((#x0) (set (mem32 mode (reg h-sp)) (reg h-intb)))
9305 ((#x1) (set (mem32 mode (reg h-sp)) (reg h-sp)))
9306 ((#x2) (set (mem32 mode (reg h-sp)) (reg h-sb)))
9307 ((#x3) (set (mem32 mode (reg h-sp)) (reg h-fb)))
9308 ((#x7) (set (mem32 mode (reg h-sp)) (reg h-isp)))
9312 (define-pmacro (pushc16-sem mode dst)
9314 (set (reg h-sp) (sub (reg h-sp) 2))
9316 ((#x1) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff)))
9317 ((#x2) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff0000)))
9318 ((#x3) (sequence ((HI tflag))
9319 (if (eq cbit 1) (set tflag (or tflag #x1)))
9320 (if (eq dbit 1) (set tflag (or tflag #x2)))
9321 (if (eq zbit 1) (set tflag (or tflag #x4)))
9322 (if (eq sbit 1) (set tflag (or tflag #x8)))
9323 (if (eq bbit 1) (set tflag (or tflag #x10)))
9324 (if (eq obit 1) (set tflag (or tflag #x20)))
9325 (if (eq ibit 1) (set tflag (or tflag #x40)))
9326 (if (eq ubit 1) (set tflag (or tflag #x80)))
9327 (set (mem16 mode (reg h-sp)) tflag)))
9329 ((#x4) (set (mem16 mode (reg h-sp)) (reg h-isp)))
9330 ((#x5) (set (mem16 mode (reg h-sp)) (reg h-sp)))
9331 ((#x6) (set (mem16 mode (reg h-sp)) (reg h-sb)))
9332 ((#x7) (set (mem16 mode (reg h-sp)) (reg h-fb)))
9337 (dni pushc16.imm16 "pushc dst" ((machine 16))
9339 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 2) cr16)
9340 (pushc16-sem HI cr16)
9342 ; pushc src (m32c #1)
9343 (dni pushc32.imm16-cr1 "pushc dst" ((machine 32))
9344 ("pushc ${cr1-Unprefixed-32}")
9345 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32)
9346 (pushc32-cr1-sem HI cr1-Unprefixed-32)
9348 ; pushc src (m32c #2)
9349 (dni pushc32.imm16-cr2 "pushc dst" ((machine 32))
9351 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 2) (f-12-1 1) cr2-32)
9352 (pushc32-cr2-sem SI cr2-32)
9355 ;-------------------------------------------------------------
9356 ; popm - pop multiple
9357 ; pushm - push multiple
9358 ;-------------------------------------------------------------
9360 (define-pmacro (popm-sem machine dst)
9361 (sequence ((SI addrlen))
9366 (sequence () (set R0 (mem-mach machine HI (reg h-sp)))
9367 (set (reg h-sp) (add (reg h-sp) 2))))
9369 (sequence () (set R1 (mem-mach machine HI (reg h-sp)))
9370 (set (reg h-sp) (add (reg h-sp) 2))))
9372 (sequence () (set R2 (mem-mach machine HI (reg h-sp)))
9373 (set (reg h-sp) (add (reg h-sp) 2))))
9375 (sequence () (set R3 (mem-mach machine HI (reg h-sp)))
9376 (set (reg h-sp) (add (reg h-sp) 2))))
9378 (sequence () (set A0 (mem-mach machine HI (reg h-sp)))
9379 (set (reg h-sp) (add (reg h-sp) addrlen))))
9381 (sequence () (set A1 (mem-mach machine HI (reg h-sp)))
9382 (set (reg h-sp) (add (reg h-sp) addrlen))))
9384 (sequence () (set (reg h-sb) (mem-mach machine HI (reg h-sp)))
9385 (set (reg h-sp) (add (reg h-sp) addrlen))))
9387 (sequence () (set (reg h-fb) (mem-mach machine HI (reg h-sp)))
9388 (set (reg h-sp) (add (reg h-sp) addrlen))))
9392 (define-pmacro (pushm-sem machine dst)
9393 (sequence ((SI count) (SI addrlen))
9398 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9399 (set (mem-mach machine HI (reg h-sp)) (reg h-fb))))
9401 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9402 (set (mem-mach machine HI (reg h-sp)) (reg h-sb))))
9404 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9405 (set (mem-mach machine HI (reg h-sp)) A1)))
9407 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9408 (set (mem-mach machine HI (reg h-sp)) A0)))
9410 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9411 (set (mem-mach machine HI (reg h-sp)) R3)))
9413 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9414 (set (mem-mach machine HI (reg h-sp)) R2)))
9416 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9417 (set (mem-mach machine HI (reg h-sp)) R1)))
9419 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9420 (set (mem-mach machine HI (reg h-sp)) R0)))
9424 (dni popm16 "popm regs" ((machine 16))
9425 ("popm ${Regsetpop}")
9426 (+ (f-0-4 #xE) (f-4-4 #xD) Regsetpop)
9427 (popm-sem 16 Regsetpop)
9429 (dni pushm16 "pushm regs" ((machine 16))
9430 ("pushm ${Regsetpush}")
9431 (+ (f-0-4 #xE) (f-4-4 #xC) Regsetpush)
9432 (pushm-sem 16 Regsetpush)
9434 (dni popm "popm regs" ((machine 32))
9435 ("popm ${Regsetpop}")
9436 (+ (f-0-4 #x8) (f-4-4 #xE) Regsetpop)
9437 (popm-sem 32 Regsetpop)
9439 (dni pushm "pushm regs" ((machine 32))
9440 ("pushm ${Regsetpush}")
9441 (+ (f-0-4 #x8) (f-4-4 #xF) Regsetpush)
9442 (pushm-sem 32 Regsetpush)
9445 ;-------------------------------------------------------------
9446 ; push - Save register/memory/immediate data
9447 ;-------------------------------------------------------------
9449 ; TODO future: split this into .b and .w semantics
9450 (define-pmacro (push-sem-mach mach mode dst)
9451 (sequence ((mode b_or_w) (SI length))
9453 (set b_or_w (srl b_or_w #x8))
9456 (if (eq b_or_w #xff)
9458 (set length 4))) ; .l
9459 (set (reg h-sp) (sub (reg h-sp) length))
9461 ((1) (set (mem-mach mach QI (reg h-sp)) dst))
9462 ((2) (set (mem-mach mach HI (reg h-sp)) dst))
9463 ((4) (set (mem-mach mach SI (reg h-sp)) dst)))
9467 (define-pmacro (push-sem16 mode dst) (push-sem-mach 16 mode dst))
9468 (define-pmacro (push-sem32 mode dst) (push-sem-mach 32 mode dst))
9470 ; push.BW:G imm (m16 #1 m32 #1)
9471 (dni push16.b.G-imm "push.b:G #Imm-16-QI" ((machine 16))
9472 ("push.b$G #${Imm-16-QI}")
9473 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 2) Imm-16-QI)
9474 (push-sem16 QI Imm-16-QI)
9477 (dni push16.w.G-imm "push.w:G #Imm-16-HI" ((machine 16))
9478 ("push.w$G #${Imm-16-HI}")
9479 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 2) Imm-16-HI)
9480 (push-sem16 HI Imm-16-HI)
9483 (dni push32.b.imm "push.b #Imm-8-QI" ((machine 32))
9484 ("push.b #${Imm-8-QI}")
9485 (+ (f-0-4 #xA) (f-4-4 #xE) Imm-8-QI)
9486 (push-sem32 QI Imm-8-QI)
9489 (dni push32.w.imm "push.w #Imm-8-HI" ((machine 32))
9490 ("push.w #${Imm-8-HI}")
9491 (+ (f-0-4 #xA) (f-4-4 #xF) Imm-8-HI)
9492 (push-sem32 HI Imm-8-HI)
9495 ; push.BW:G src (m16 #2)
9496 (unary-insn-mach-g 16 push (f-0-4 7) (f-4-3 2) (f-8-4 #x4) push-sem16 $G)
9497 ; push.BW:G src (m32 #2)
9498 (unary-insn-mach 32 push #xC #x0 #xE push-sem32)
9501 ; push.b:S r0l/r0h (m16 #3)
9502 (dni push16.b-s-rn "push.b:S r0[lh]" ((machine 16))
9503 "push.b$S ${Rn16-push-S-anyof}"
9504 (+ (f-0-4 #x8) Rn16-push-S-anyof (f-5-3 #x2))
9505 (push-sem16 QI Rn16-push-S-anyof)
9507 ; push.w:S a0/a1 (m16 #4)
9508 (dni push16.b-s-an "push.w:S a[01]" ((machine 16))
9509 "push.w$S ${An16-push-S-anyof}"
9510 (+ (f-0-4 #xC) An16-push-S-anyof (f-5-3 #x2))
9511 (push-sem16 HI An16-push-S-anyof)
9514 ; push.l imm32 (m32 #3)
9515 (dni push32.l.imm "push.l #Imm-16-SI" ((machine 32))
9516 ("push.l #${Imm-16-SI}")
9517 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 5) (f-12-4 3) Imm-16-SI)
9518 (push-sem32 SI Imm-16-SI)
9520 ; push.l src (m32 #4)
9521 (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)
9523 ;-------------------------------------------------------------
9524 ; pusha - push effective address
9525 ;------------------------------------------------------------
9527 (define-pmacro (push16a-sem mode dst)
9529 (set (reg h-sp) (sub (reg h-sp) 2))
9530 (set (mem16 HI (reg h-sp)) dst))
9532 (define-pmacro (push32a-sem mode dst)
9534 (set (reg h-sp) (sub (reg h-sp) 4))
9535 (set (mem32 SI (reg h-sp)) dst))
9537 (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)
9538 (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)
9540 ;-------------------------------------------------------------
9541 ; reit - return from interrupt
9542 ;-------------------------------------------------------------
9545 (dni reit16 "REIT" ((machine 16))
9547 (+ (f-0-4 #xF) (f-4-4 #xB))
9550 (dni reit32 "REIT" ((machine 32))
9552 (+ (f-0-4 9) (f-4-4 #xE))
9556 ;-------------------------------------------------------------
9557 ; rmpa - repeat multiple and addition
9558 ;-------------------------------------------------------------
9561 (dni rmpa16.b "rmpa.size" ((machine 16))
9563 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 1))
9566 (dni rmpa16.w "rmpa.size" ((machine 16))
9568 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 1))
9571 (dni rmpa32.b "rmpa.size" ((machine 32))
9573 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 4) (f-12-4 3))
9577 (dni rmpa32.w "rmpa.size" ((machine 32))
9579 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 5) (f-12-4 3))
9583 ;-------------------------------------------------------------
9584 ; rolc - rotate left with carry
9585 ;-------------------------------------------------------------
9587 ; TODO check semantics
9588 ; TODO future: split this into .b and .w semantics
9589 (define-pmacro (rolc-sem mode dst)
9590 (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask))
9592 (set b_or_w (srl b_or_w #x8))
9594 (set mask #x8000) ; .b
9595 (set mask #x80000000)) ; .w
9597 (set cbit (and dst mask))
9598 (set result (sll mode dst 1))
9599 (set result (or result ocbit))
9600 (set-z-and-s result)
9604 (unary-insn rolc (f-0-4 7) (f-4-3 3) (f-8-4 #xA) #xB #x2 #xE rolc-sem)
9606 ;-------------------------------------------------------------
9607 ; rorc - rotate right with carry
9608 ;-------------------------------------------------------------
9610 ; TODO check semantics
9611 ; TODO future: split this into .b and .w semantics
9612 (define-pmacro (rorc-sem mode dst)
9613 (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask) (SI shamt))
9615 (set b_or_w (srl b_or_w #x8))
9617 (sequence () (set mask #x7fff) (set shamt 15)) ; .b
9618 (sequence () (set mask #x7fffffff) (set shamt 31))) ; .w
9620 (set cbit (and dst #x1))
9621 (set result (srl mode dst (const 1)))
9622 (set result (or (and result mask) (sll ocbit shamt)))
9623 (set-z-and-s result)
9627 (unary-insn rorc (f-0-4 7) (f-4-3 3) (f-8-4 #xB) #xA #x2 #xE rorc-sem)
9629 ;-------------------------------------------------------------
9631 ;-------------------------------------------------------------
9633 ; TODO future: split this into .b and .w semantics
9634 (define-pmacro (rot-1-sem mode src1 dst)
9635 (sequence ((mode tmp) (mode b_or_w) (USI mask) (SI shift))
9637 ((#x0) (set shift 1))
9638 ((#x1) (set shift 2))
9639 ((#x2) (set shift 3))
9640 ((#x3) (set shift 4))
9641 ((#x4) (set shift 5))
9642 ((#x5) (set shift 6))
9643 ((#x6) (set shift 7))
9644 ((#x7) (set shift 8))
9645 ((-8) (set shift -1))
9646 ((-7) (set shift -2))
9647 ((-6) (set shift -3))
9648 ((-5) (set shift -4))
9649 ((-4) (set shift -5))
9650 ((-3) (set shift -6))
9651 ((-2) (set shift -7))
9652 ((-1) (set shift -8))
9653 (else (set shift 0))
9656 (set b_or_w (srl b_or_w #x8))
9658 (set mask #x7fff) ; .b
9659 (set mask #x7fffffff)) ; .w
9661 (if (gt mode shift 0)
9663 (set tmp (rol mode tmp shift))
9664 (set cbit (and tmp #x1)))
9666 (set tmp (ror mode tmp (mul shift -1)))
9667 (set cbit (and tmp mask))))
9671 (define-pmacro (rot-2-sem mode dst)
9672 (sequence ((mode tmp) (mode b_or_w) (USI mask))
9674 (set b_or_w (srl b_or_w #x8))
9676 (set mask #x7fff) ; .b
9677 (set mask #x7fffffff)) ; .w
9679 (if (gt mode (reg h-r1h) 0)
9681 (set tmp (rol mode tmp (reg h-r1h)))
9682 (set cbit (and tmp #x1)))
9684 (set tmp (ror mode tmp (reg h-r1h)))
9685 (set cbit (and tmp mask))))
9691 (binary-arith16-shimm4-dst-defn QI .b 0 0 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem)
9692 (binary-arith16-shimm4-dst-defn HI .w 0 1 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem)
9693 (binary-arith32-shimm4-dst-defn QI .b 0 0 rot #x7 #x2 rot-1-sem)
9694 (binary-arith32-shimm4-dst-defn HI .w 0 1 rot #x7 #x2 rot-1-sem)
9697 (dni rot16.b-dst "rot r1h,dest" ((machine 16))
9698 ("rot.b r1h,${dst16-16-QI}")
9699 (+ (f-0-4 7) (f-4-4 #x4) (f-8-4 #x6) dst16-16-QI)
9700 (rot-2-sem QI dst16-16-QI)
9702 (dni rot16.w-dst "rot r1h,dest" ((machine 16))
9703 ("rot.w r1h,${dst16-16-HI}")
9704 (+ (f-0-4 7) (f-4-4 #x5) (f-8-4 #x6) dst16-16-HI)
9705 (rot-2-sem HI dst16-16-HI)
9708 (dni rot32.b-dst "rot r1h,dest" ((machine 32))
9709 ("rot.b r1h,${dst32-16-Unprefixed-QI}")
9710 (+ (f-0-4 #xA) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xF))
9711 (rot-2-sem QI dst32-16-Unprefixed-QI)
9713 (dni rot32.w-dst "rot r1h,dest" ((machine 32))
9714 ("rot.w r1h,${dst32-16-Unprefixed-HI}")
9715 (+ (f-0-4 #xA) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xF))
9716 (rot-2-sem HI dst32-16-Unprefixed-HI)
9719 ;-------------------------------------------------------------
9720 ; rts - return from subroutine
9721 ;-------------------------------------------------------------
9723 (define-pmacro (rts16-sem)
9724 (sequence ((SI tpc))
9725 (set tpc (mem16 HI (reg h-sp)))
9726 (set (reg h-sp) (add (reg h-sp) 2))
9727 (set tpc (or tpc (sll (mem16 QI (reg h-sp)) 16)))
9728 (set (reg h-sp) (add (reg h-sp) 1))
9732 (define-pmacro (rts32-sem)
9733 (sequence ((SI tpc))
9734 (set tpc (mem32 HI (reg h-sp)))
9735 (set (reg h-sp) (add (reg h-sp) 2))
9736 (set tpc (or tpc (sll (mem32 HI (reg h-sp)) 16)))
9737 (set (reg h-sp) (add (reg h-sp) 2))
9742 (dni rts16 "rts" ((machine 16))
9744 (+ (f-0-4 #xF) (f-4-4 3))
9748 (dni rts32 "rts" ((machine 32))
9750 (+ (f-0-4 #xD) (f-4-4 #xF))
9754 ;-------------------------------------------------------------
9755 ; sbb - subtract with borrow
9756 ;-------------------------------------------------------------
9758 (define-pmacro (sbb-sem mode src dst)
9759 (sequence ((mode result))
9760 (set result (subc mode dst src cbit))
9761 (set obit (add-oflag mode dst src cbit))
9762 (set cbit (add-oflag mode dst src cbit))
9763 (set-z-and-s result)
9767 ; sbb.size:G #imm,dst
9768 (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)
9769 (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)
9770 (binary-arith32-imm-dst-Prefixed QI QI .b 0 sbb X #x9 #x2 #xE sbb-sem)
9771 (binary-arith32-imm-dst-Prefixed HI HI .w 1 sbb X #x9 #x2 #xE sbb-sem)
9774 (binary-arith16-src-dst-defn QI QI .b 0 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem)
9775 (binary-arith16-src-dst-defn HI HI .w 1 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem)
9776 (binary-arith32-src-dst-Prefixed QI QI .b 0 sbb X #x1 #x6 sbb-sem)
9777 (binary-arith32-src-dst-Prefixed HI HI .w 1 sbb X #x1 #x6 sbb-sem)
9779 ;-------------------------------------------------------------
9780 ; sbjnz - subtract then jump on not zero
9781 ;-------------------------------------------------------------
9783 (define-pmacro (sub-jnz-sem mode src dst label)
9784 (sequence ((mode result))
9785 (set result (sub mode dst src))
9791 ; sbjnz.size #imm4,dst,label
9792 (arith-jnz-imm4-dst sbjnz s4n (f-0-4 #xF) (f-4-3 4) #xf #x1 sub-jnz-sem)
9794 ;-------------------------------------------------------------
9795 ; sccnd - store condition on condition (m32)
9796 ;-------------------------------------------------------------
9798 (define-pmacro (sccnd-sem cnd dst)
9802 ((#x00) (if (not cbit) (set dst 1))) ;ltu nc
9803 ((#x01) (if (or cbit zbit) (set dst 1))) ;leu
9804 ((#x02) (if (not zbit) (set dst 1))) ;ne nz
9805 ((#x03) (if (not sbit) (set dst 1))) ;pz
9806 ((#x04) (if (not obit) (set dst 1))) ;no
9807 ((#x05) (if (not (or zbit (xor sbit obit))) (set dst 1))) ;gt
9808 ((#x06) (if (xor sbit obit) (set dst 1))) ;ge
9809 ((#x08) (if (trunc BI cbit) (set dst 1))) ;geu c
9810 ((#x09) (if (not (or cbit zbit)) (set dst 1))) ;gtu
9811 ((#x0a) (if (trunc BI zbit) (set dst 1))) ;eq z
9812 ((#x0b) (if (trunc BI sbit) (set dst 1))) ;n
9813 ((#x0c) (if (trunc BI obit) (set dst 1))) ;o
9814 ((#x0d) (if (or zbit (xor sbit obit)) (set dst 1))) ;le
9815 ((#x0e) (if (xor sbit obit) (set dst 1))) ;lt
9824 "sc$sccond32 ${dst32-16-Unprefixed-HI}"
9825 (+ (f-0-4 #xD) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) sccond32)
9826 (sccnd-sem sccond32 dst32-16-Unprefixed-HI)
9829 ;-------------------------------------------------------------
9830 ; scmpu - string compare unequal (m32)
9831 ;-------------------------------------------------------------
9834 (dni scmpu.b "scmpu.b" ((machine 32))
9836 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xC) (f-12-4 3))
9837 (c-call VOID "scmpu_QI_semantics")
9840 (dni scmpu.w "scmpu.w" ((machine 32))
9842 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xD) (f-12-4 3))
9843 (c-call VOID "scmpu_HI_semantics")
9846 ;-------------------------------------------------------------
9847 ; sha - shift arithmetic
9848 ;-------------------------------------------------------------
9850 ; TODO future: split this into .b and .w semantics
9851 (define-pmacro (sha-sem mode src1 dst)
9852 (sequence ((mode result)(mode shift)(mode shmode))
9854 ((#x0) (set shift 1))
9855 ((#x1) (set shift 2))
9856 ((#x2) (set shift 3))
9857 ((#x3) (set shift 4))
9858 ((#x4) (set shift 5))
9859 ((#x5) (set shift 6))
9860 ((#x6) (set shift 7))
9861 ((#x7) (set shift 8))
9862 ((-8) (set shift -1))
9863 ((-7) (set shift -2))
9864 ((-6) (set shift -3))
9865 ((-5) (set shift -4))
9866 ((-4) (set shift -5))
9867 ((-3) (set shift -6))
9868 ((-2) (set shift -7))
9869 ((-1) (set shift -8))
9870 (else (set shift 0))
9873 (set shmode (srl shmode #x8))
9874 (if (lt mode shift #x0) (set result (sra mode dst (mul shift -1))))
9875 (if (gt mode shift 0) (set result (sll mode dst shift)))
9876 (if (eq shmode #x0) ; QI
9879 (if (lt mode shift #x0)
9880 (set cbitamt (sub #x8 shift)) ; sra
9881 (set cbitamt (sub shift 1))) ; sll
9882 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9883 (set obit (ne (and dst #x80) (and result #x80)))
9885 (if (eq shmode #xff) ; HI
9888 (if (lt mode shift #x0)
9889 (set cbitamt (sub 16 shift)) ; sra
9890 (set cbitamt (sub shift 1))) ; sll
9891 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9892 (set obit (ne (and dst #x8000) (and result #x8000)))
9894 (set-z-and-s result)
9897 (define-pmacro (shar1h-sem mode dst)
9898 (sequence ((mode result)(mode shmode))
9900 (set shmode (srl shmode #x8))
9901 (if (lt mode (reg h-r1h) 0) (set result (sra mode dst (reg h-r1h))))
9902 (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h))))
9903 (if (eq shmode #x0) ; QI
9906 (if (lt mode (reg h-r1h) #x0)
9907 (set cbitamt (sub #x8 (reg h-r1h))) ; sra
9908 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9909 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9910 (set obit (ne (and dst #x80) (and result #x80)))
9912 (if (eq shmode #xff) ; HI
9915 (if (lt mode (reg h-r1h) #x0)
9916 (set cbitamt (sub 16 (reg h-r1h))) ; sra
9917 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9918 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9919 (set obit (ne (and dst #x8000) (and result #x8000)))
9921 (set-z-and-s result)
9924 ; sha.BW #imm4,dst (m16 #1 m32 #1)
9925 (binary-arith16-shimm4-dst-defn QI .b 0 0 sha (f-0-4 #xF) (f-4-3 0) sha-sem)
9926 (binary-arith16-shimm4-dst-defn HI .w 0 1 sha (f-0-4 #xF) (f-4-3 0) sha-sem)
9927 (binary-arith32-shimm4-dst-defn QI .b 1 0 sha #x7 #x0 sha-sem)
9928 (binary-arith32-shimm4-dst-defn HI .w 1 1 sha #x7 #x0 sha-sem)
9929 ; sha.BW r1h,dst (m16 #2 m32 #3)
9930 (dni sha16.b-dst "sha.b r1h,dest" ((machine 16))
9931 ("sha.b r1h,${dst16-16-QI}")
9932 (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xF) dst16-16-QI)
9933 (shar1h-sem HI dst16-16-QI)
9935 (dni sha16.w-dst "sha.w r1h,dest" ((machine 16))
9936 ("sha.w r1h,${dst16-16-HI}")
9937 (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xF) dst16-16-HI)
9938 (shar1h-sem HI dst16-16-HI)
9940 (dni sha32.b-dst "sha.b r1h,dest" ((machine 32))
9941 ("sha.b r1h,${dst32-16-Unprefixed-QI}")
9942 (+ (f-0-4 #xB) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE))
9943 (shar1h-sem QI dst32-16-Unprefixed-QI)
9945 (dni sha32.w-dst "sha.w r1h,dest" ((machine 32))
9946 ("sha.w r1h,${dst32-16-Unprefixed-HI}")
9947 (+ (f-0-4 #xB) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
9948 (shar1h-sem HI dst32-16-Unprefixed-HI)
9950 ; sha.L #imm,dst (m16 #3)
9951 (dni sha16-L-imm-r2r0 "sha.L #Imm-sh-12-s4,r2r0" ((machine 16))
9952 "sha.l #${Imm-sh-12-s4},r2r0"
9953 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xA) Imm-sh-12-s4)
9954 (sha-sem SI Imm-sh-12-s4 (reg h-r2r0))
9956 (dni sha16-L-imm-r3r1 "sha.L #Imm-sh-12-s4,r3r1" ((machine 16))
9957 "sha.l #${Imm-sh-12-s4},r3r1"
9958 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xB) Imm-sh-12-s4)
9959 (sha-sem SI Imm-sh-12-s4 (reg h-r3r1))
9961 ; sha.L r1h,dst (m16 #4)
9962 (dni sha16-L-r1h-r2r0 "sha.L r1h,r2r0" ((machine 16))
9964 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 2) (f-12-4 1))
9965 (sha-sem SI (reg h-r1h) (reg h-r2r0))
9967 (dni sha16-L-r1h-r3r1 "sha.L r1h,r3r1" ((machine 16))
9969 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 3) (f-12-4 1))
9970 (sha-sem SI (reg h-r1h) (reg h-r3r1))
9972 ; sha.L #imm8,dst (m32 #2)
9973 (binary-arith32-imm-dst-defn QI SI .l 0 sha X #xA #x2 #x1 sha-sem)
9974 ; sha.L r1h,dst (m32 #4)
9975 (dni sha32.l-dst "sha.l r1h,dest" ((machine 32))
9976 ("sha.l r1h,${dst32-16-Unprefixed-SI}")
9977 (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 1) (f-12-4 1))
9978 (shar1h-sem QI dst32-16-Unprefixed-SI)
9981 ;-------------------------------------------------------------
9982 ; shanc - shift arithmetic non carry (m32)
9983 ;-------------------------------------------------------------
9985 ; TODO check semantics
9987 (binary-arith32-imm-dst-defn QI SI .l 0 shanc X #xC #x2 #x1 sha-sem)
9989 ;-------------------------------------------------------------
9990 ; shl - shift logical
9991 ;-------------------------------------------------------------
9993 ; TODO future: split this into .b and .w semantics
9994 (define-pmacro (shl-sem mode src1 dst)
9995 (sequence ((mode result)(mode shift)(mode shmode))
9997 ((#x0) (set shift 1))
9998 ((#x1) (set shift 2))
9999 ((#x2) (set shift 3))
10000 ((#x3) (set shift 4))
10001 ((#x4) (set shift 5))
10002 ((#x5) (set shift 6))
10003 ((#x6) (set shift 7))
10004 ((#x7) (set shift 8))
10005 ((-8) (set shift -1))
10006 ((-7) (set shift -2))
10007 ((-6) (set shift -3))
10008 ((-5) (set shift -4))
10009 ((-4) (set shift -5))
10010 ((-3) (set shift -6))
10011 ((-2) (set shift -7))
10012 ((-1) (set shift -8))
10013 (else (set shift 0))
10016 (set shmode (srl shmode #x8))
10017 (if (lt mode shift #x0) (set result (srl mode dst (mul shift -1))))
10018 (if (gt mode shift 0) (set result (sll mode dst shift)))
10019 (if (eq shmode #x0) ; QI
10022 (if (lt mode shift #x0)
10023 (set cbitamt (sub #x8 shift)); srl
10024 (set cbitamt (sub shift 1))) ; sll
10025 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
10026 (set obit (ne (and dst #x80) (and result #x80)))
10028 (if (eq shmode #xff) ; HI
10031 (if (lt mode shift #x0)
10032 (set cbitamt (sub 16 shift)) ; srl
10033 (set cbitamt (sub shift 1))) ; sll
10034 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
10035 (set obit (ne (and dst #x8000) (and result #x8000)))
10037 (set-z-and-s result)
10040 (define-pmacro (shlr1h-sem mode dst)
10041 (sequence ((mode result)(mode shmode))
10043 (set shmode (srl shmode #x8))
10044 (if (lt mode (reg h-r1h) 0) (set result (srl mode dst (reg h-r1h))))
10045 (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h))))
10046 (if (eq shmode #x0) ; QI
10049 (if (lt mode (reg h-r1h) #x0)
10050 (set cbitamt (sub #x8 (reg h-r1h))) ; srl
10051 (set cbitamt (sub (reg h-r1h) 1))) ; sll
10052 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
10053 (set obit (ne (and dst #x80) (and result #x80)))
10055 (if (eq shmode #xff) ; HI
10058 (if (lt mode (reg h-r1h) #x0)
10059 (set cbitamt (sub 16 (reg h-r1h))) ; srl
10060 (set cbitamt (sub (reg h-r1h) 1))) ; sll
10061 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
10062 (set obit (ne (and dst #x8000) (and result #x8000)))
10064 (set-z-and-s result)
10067 ; shl.BW #imm4,dst (m16 #1 m32 #1)
10068 (binary-arith16-shimm4-dst-defn QI .b 0 0 shl (f-0-4 #xE) (f-4-3 4) shl-sem)
10069 (binary-arith16-shimm4-dst-defn HI .w 0 1 shl (f-0-4 #xE) (f-4-3 4) shl-sem)
10070 (binary-arith32-shimm4-dst-defn QI .b 0 0 shl #x7 #x0 shl-sem)
10071 (binary-arith32-shimm4-dst-defn HI .w 0 1 shl #x7 #x0 shl-sem)
10072 ; shl.BW r1h,dst (m16 #2 m32 #3)
10073 (dni shl16.b-dst "shl.b r1h,dest" ((machine 16))
10074 ("shl.b r1h,${dst16-16-QI}")
10075 (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xE) dst16-16-QI)
10076 (shlr1h-sem HI dst16-16-QI)
10078 (dni shl16.w-dst "shl.w r1h,dest" ((machine 16))
10079 ("shl.w r1h,${dst16-16-HI}")
10080 (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xE) dst16-16-HI)
10081 (shlr1h-sem HI dst16-16-HI)
10083 (dni shl32.b-dst "shl.b r1h,dest" ((machine 32))
10084 ("shl.b r1h,${dst32-16-Unprefixed-QI}")
10085 (+ (f-0-4 #xA) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE))
10086 (shlr1h-sem QI dst32-16-Unprefixed-QI)
10088 (dni shl32.w-dst "shl.w r1h,dest" ((machine 32))
10089 ("shl.w r1h,${dst32-16-Unprefixed-HI}")
10090 (+ (f-0-4 #xA) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
10091 (shlr1h-sem HI dst32-16-Unprefixed-HI)
10093 ; shl.L #imm,dst (m16 #3)
10094 (dni shl16-L-imm-r2r0 "shl.L #Imm-sh-12-s4,r2r0" ((machine 16))
10095 "shl.l #${Imm-sh-12-s4},r2r0"
10096 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x8) Imm-sh-12-s4)
10097 (shl-sem SI Imm-sh-12-s4 (reg h-r2r0))
10099 (dni shl16-L-imm-r3r1 "shl.L #Imm-sh-12-s4,r3r1" ((machine 16))
10100 "shl.l #${Imm-sh-12-s4},r3r1"
10101 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x9) Imm-sh-12-s4)
10102 (shl-sem SI Imm-sh-12-s4 (reg h-r3r1))
10104 ; shl.L r1h,dst (m16 #4)
10105 (dni shl16-L-r1h-r2r0 "shl.L r1h,r2r0" ((machine 16))
10107 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 0) (f-12-4 1))
10108 (shl-sem SI (reg h-r1h) (reg h-r2r0))
10110 (dni shl16-L-r1h-r3r1 "shl.L r1h,r3r1" ((machine 16))
10112 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 1) (f-12-4 1))
10113 (shl-sem SI (reg h-r1h) (reg h-r3r1))
10115 ; shl.L #imm8,dst (m32 #2)
10116 (binary-arith32-imm-dst-defn QI SI .l 0 shl X #x9 #x2 #x1 shl-sem)
10117 ; shl.L r1h,dst (m32 #4)
10118 (dni shl32.l-dst "shl.l r1h,dest" ((machine 32))
10119 ("shl.l r1h,${dst32-16-Unprefixed-SI}")
10120 (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 0) (f-12-4 1))
10121 (shlr1h-sem QI dst32-16-Unprefixed-SI)
10124 ;-------------------------------------------------------------
10125 ; shlnc - shift logical non carry
10126 ;-------------------------------------------------------------
10128 ; TODO check semantics
10129 ; shlnc.L #imm8,dst
10130 (binary-arith32-imm-dst-defn QI SI .l 0 shlnc X #x8 #x2 #x1 shl-sem)
10132 ;-------------------------------------------------------------
10133 ; sin - string input (m32)
10134 ;-------------------------------------------------------------
10137 (dni sin32.b "sin" ((machine 32))
10139 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 8) (f-12-4 3))
10140 (c-call VOID "sin_QI_semantics")
10143 (dni sin32.w "sin" ((machine 32))
10145 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 9) (f-12-4 3))
10146 (c-call VOID "sin_HI_semantics")
10149 ;-------------------------------------------------------------
10150 ; smovb - string move backward
10151 ;-------------------------------------------------------------
10154 (dni smovb16.b "smovb.b" ((machine 16))
10156 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 9))
10157 (c-call VOID "smovb_QI_semantics")
10160 (dni smovb16.w "smovb.w" ((machine 16))
10162 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 9))
10163 (c-call VOID "smovb_HI_semantics")
10166 (dni smovb32.b "smovb.b" ((machine 32))
10168 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 8) (f-12-4 3))
10169 (c-call VOID "smovb_QI_semantics")
10172 (dni smovb32.w "smovb.w" ((machine 32))
10174 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 9) (f-12-4 3))
10175 (c-call VOID "smovb_HI_semantics")
10178 ;-------------------------------------------------------------
10179 ; smovf - string move forward (m32)
10180 ;-------------------------------------------------------------
10183 (dni smovf16.b "smovf.b" ((machine 16))
10185 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 8))
10186 (c-call VOID "smovf_QI_semantics")
10189 (dni smovf16.w "smovf.w" ((machine 16))
10191 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 8))
10192 (c-call VOID "smovf_HI_semantics")
10195 (dni smovf32.b "smovf.b" ((machine 32))
10197 (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 8) (f-12-4 3))
10198 (c-call VOID "smovf_QI_semantics")
10201 (dni smovf32.w "smovf.w" ((machine 32))
10203 (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 9) (f-12-4 3))
10204 (c-call VOID "smovf_HI_semantics")
10207 ;-------------------------------------------------------------
10208 ; smovu - string move unequal (m32)
10209 ;-------------------------------------------------------------
10212 (dni smovu.b "smovu.b" ((machine 32))
10214 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 8) (f-12-4 3))
10215 (c-call VOID "smovu_QI_semantics")
10218 (dni smovu.w "smovu.w" ((machine 32))
10220 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 9) (f-12-4 3))
10221 (c-call VOID "smovu_HI_semantics")
10224 ;-------------------------------------------------------------
10225 ; sout - string output (m32)
10226 ;-------------------------------------------------------------
10229 (dni sout.b "sout.b" ((machine 32))
10231 (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 8) (f-12-4 3))
10232 (c-call VOID "sout_QI_semantics")
10235 (dni sout.w "sout" ((machine 32))
10237 (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 9) (f-12-4 3))
10238 (c-call VOID "sout_HI_semantics")
10241 ;-------------------------------------------------------------
10242 ; sstr - string store
10243 ;-------------------------------------------------------------
10246 (dni sstr16.b "sstr.b" ((machine 16))
10248 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 #xA))
10249 (c-call VOID "sstr_QI_semantics")
10252 (dni sstr16.w "sstr.w" ((machine 16))
10254 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 #xA))
10255 (c-call VOID "sstr_HI_semantics")
10258 (dni sstr.b "sstr" ((machine 32))
10260 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 0) (f-12-4 3))
10261 (c-call VOID "sstr_QI_semantics")
10264 (dni sstr.w "sstr" ((machine 32))
10266 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 1) (f-12-4 3))
10267 (c-call VOID "sstr_HI_semantics")
10270 ;-------------------------------------------------------------
10271 ; stnz - store on not zero
10272 ;-------------------------------------------------------------
10274 (define-pmacro (stnz-sem mode src dst)
10276 (if (ne zbit (const 1))
10279 ; stnz #imm8,dst3 (m16)
10280 (binary-arith16-b-S-imm8-dst3 stnz "" (f-0-4 #xD) (f-4-1 0) stnz-sem)
10281 ; stnz.BW #imm,dst (m32)
10282 (binary-arith32-imm-dst-defn QI QI .b 0 stnz X #x9 #x1 #xF stnz-sem)
10283 (binary-arith32-imm-dst-defn HI HI .w 1 stnz X #x9 #x1 #xF stnz-sem)
10285 ;-------------------------------------------------------------
10286 ; stz - store on zero
10287 ;-------------------------------------------------------------
10289 (define-pmacro (stz-sem mode src dst)
10291 (if (eq zbit (const 1))
10294 ; stz #imm8,dst3 (m16)
10295 (binary-arith16-b-S-imm8-dst3 stz "" (f-0-4 #xC) (f-4-1 1) stz-sem)
10296 ; stz.BW #imm,dst (m32)
10297 (binary-arith32-imm-dst-defn QI QI .b 0 stz X #x9 #x0 #xF stz-sem)
10298 (binary-arith32-imm-dst-defn HI HI .w 1 stz X #x9 #x0 #xF stz-sem)
10300 ;-------------------------------------------------------------
10301 ; stzx - store on zero extention
10302 ;-------------------------------------------------------------
10304 (define-pmacro (stzx-sem mode src1 src2 dst)
10306 (if (eq zbit (const 1))
10310 ; stzx #imm8,dst3 (m16)
10311 (dni stzx16-imm8-imm8-r0h "stzx #Imm8,#Imm8,r0h" ((machine 16))
10312 ("stzx #${Imm-8-QI},#${Imm-16-QI},r0h")
10313 (+ (f-0-4 #xD) (f-4-4 #xB) Imm-8-QI Imm-16-QI)
10314 (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0h))
10316 (dni stzx16-imm8-imm8-r0l "stzx #Imm8,#Imm8,r0l" ((machine 16))
10317 ("stzx #${Imm-8-QI},#${Imm-16-QI},r0l")
10318 (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI Imm-16-QI)
10319 (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0l))
10321 (dni stzx16-imm8-imm8-dsp8sb "stzx #Imm8,#Imm8,dsp8[sb]" ((machine 16))
10322 ("stzx #${Imm-8-QI},#${Imm-24-QI},${Dsp-16-u8}[sb]")
10323 (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI Dsp-16-u8 Imm-24-QI)
10324 (stzx-sem QI Imm-8-QI Imm-16-QI (mem16 QI (add (reg h-sb) Dsp-24-u8)))
10326 (dni stzx16-imm8-imm8-dsp8fb "stzx #Imm8,#Imm8,dsp8[fb]" ((machine 16))
10327 ("stzx #${Imm-8-QI},#${Imm-24-QI},${Dsp-16-s8}[fb]")
10328 (+ (f-0-4 #xD) (f-4-4 #xE) Imm-8-QI Dsp-16-s8 Imm-24-QI)
10329 (stzx-sem QI Imm-8-QI Imm-24-QI (mem16 QI (add (reg h-fb) Dsp-16-s8)))
10331 (dni stzx16-imm8-imm8-abs16 "stzx #Imm8,#Imm8,abs16" ((machine 16))
10332 ("stzx #${Imm-8-QI},#${Imm-32-QI},${Dsp-16-u16}")
10333 (+ (f-0-4 #xD) (f-4-4 #xF) Imm-8-QI Dsp-16-u16 Imm-32-QI)
10334 (stzx-sem QI Imm-8-QI Imm-32-QI (mem16 QI Dsp-16-u16))
10336 ; stzx.BW #imm,dst (m32)
10337 (insn-imm1-imm2-dst-Unprefixed stzx #x9 #x3 #xF stzx-sem)
10339 ;-------------------------------------------------------------
10340 ; subx - subtract extend (m32)
10341 ;-------------------------------------------------------------
10343 (define-pmacro (subx-sem mode src1 dst)
10344 (sequence ((mode result))
10345 (set result (sub mode dst (ext mode src1)))
10346 (set obit (sub-oflag mode dst (ext mode src1) 0))
10347 (set cbit (sub-cflag mode dst (ext mode src1) 0))
10349 (set-z-and-s result)))
10351 (binary-arith32-imm-dst-defn QI SI "" 0 subx G #x9 #x1 #x1 subx-sem)
10353 (binary-arith32-src-dst-defn QI SI "" 0 subx G #x1 #x0 subx-sem)
10355 ;-------------------------------------------------------------
10357 ;-------------------------------------------------------------
10359 (define-pmacro (tst-sem mode src1 dst)
10360 (sequence ((mode result))
10361 (set result (and mode dst src1))
10362 (set-z-and-s result))
10365 ; tst.BW #imm,dst (m16 #1 m32 #1)
10366 (binary-arith-imm-dst tst G (f-0-4 7) (f-4-3 3) (f-8-4 0) #x9 #x3 #xE tst-sem)
10367 ; tst.BW src,dst (m16 #2 m32 #3)
10368 (binary-arith16-src-dst-defn QI QI .b 0 tst X (f-0-4 #x8) (f-4-3 0) tst-sem)
10369 (binary-arith16-src-dst-defn HI HI .w 1 tst X (f-0-4 #x8) (f-4-3 0) tst-sem)
10370 (binary-arith32-src-dst-Prefixed QI QI .b 0 tst G #x1 #x9 tst-sem)
10371 (binary-arith32-src-dst-Prefixed HI HI .w 1 tst G #x1 #x9 tst-sem)
10372 ; tst.BW:S #imm,dst2 (m32 #2)
10373 (binary-arith32-s-imm-dst QI .b 0 tst #x0 #x6 tst-sem)
10374 (binary-arith32-s-imm-dst HI .w 1 tst #x0 #x6 tst-sem)
10376 ;-------------------------------------------------------------
10378 ;-------------------------------------------------------------
10380 (dni und16 "und" ((machine 16))
10382 (+ (f-0-4 #xF) (f-4-4 #xF))
10386 (dni und32 "und" ((machine 32))
10388 (+ (f-0-4 #xF) (f-4-4 #xF))
10392 ;-------------------------------------------------------------
10394 ;-------------------------------------------------------------
10397 (dni wait16 "wait" ((machine 16))
10399 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 3))
10403 (dni wait "wait" ((machine 32))
10405 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 0) (f-12-4 3))
10409 ;-------------------------------------------------------------
10411 ;-------------------------------------------------------------
10413 (define-pmacro (xchg-sem mode src dst)
10414 (sequence ((mode result))
10419 (define-pmacro (xchg16-defn mode sz szc src srcreg)
10420 (dni (.sym xchg16 sz - srcreg)
10421 (.str "xchg" sz "-" srcreg ",dst16-16-" mode)
10423 (.str "xchg." sz " " srcreg ",${dst16-16-" mode "}")
10424 (+ (f-0-4 #x7) (f-4-3 #x5) (f-7-1 szc) (f-8-2 0) (f-10-2 src) (.sym dst16-16- mode))
10425 (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst16-16- mode))
10428 (xchg16-defn QI b 0 0 r0l)
10429 (xchg16-defn QI b 0 1 r0h)
10430 (xchg16-defn QI b 0 2 r1l)
10431 (xchg16-defn QI b 0 3 r1h)
10432 (xchg16-defn HI w 1 0 r0)
10433 (xchg16-defn HI w 1 1 r1)
10434 (xchg16-defn HI w 1 2 r2)
10435 (xchg16-defn HI w 1 3 r3)
10436 (define-pmacro (xchg32-defn mode sz szc src srcreg)
10437 (dni (.sym xchg32 sz - srcreg)
10438 (.str "xchg" sz "-" srcreg ",dst32-16-Unprefixed-" mode)
10440 (.str "xchg." sz " " srcreg ",${dst32-16-Unprefixed-" mode "}")
10441 (+ (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))
10442 (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst32-16-Unprefixed- mode))
10445 (xchg32-defn QI b 0 0 r0l)
10446 (xchg32-defn QI b 0 1 r1l)
10447 (xchg32-defn QI b 0 2 a0)
10448 (xchg32-defn QI b 0 3 a1)
10449 (xchg32-defn QI b 0 4 r0h)
10450 (xchg32-defn QI b 0 5 r1h)
10451 (xchg32-defn HI w 1 0 r0)
10452 (xchg32-defn HI w 1 1 r1)
10453 (xchg32-defn HI w 1 2 a0)
10454 (xchg32-defn HI w 1 3 a1)
10455 (xchg32-defn HI w 1 4 r2)
10456 (xchg32-defn HI w 1 5 r3)
10458 ;-------------------------------------------------------------
10459 ; xor - exclusive or
10460 ;-------------------------------------------------------------
10462 (define-pmacro (xor-sem mode src1 dst)
10463 (sequence ((mode result))
10464 (set result (xor mode src1 dst))
10465 (set-z-and-s result)
10469 ; xor.BW #imm,dst (m16 #1 m32 #1)
10470 (binary-arith-imm-dst xor G (f-0-4 7) (f-4-3 3) (f-8-4 1) #x9 #x0 #xE xor-sem)
10471 ; xor.BW src,dst (m16 #3 m32 #3)
10472 (binary-arith-src-dst xor G (f-0-4 #x8) (f-4-3 4) #x1 #x9 xor-sem)
10474 ;-------------------------------------------------------------
10476 ;-------------------------------------------------------------
10478 (define-pmacro (exts-sem smode dmode src dst)
10479 (set dst (ext dmode (trunc smode src)))
10481 (define-pmacro (extz-sem smode dmode src dst)
10482 (set dst (zext dmode (trunc smode src)))
10485 ; exts.b dst for m16c
10486 (ext16-defn QI HI .b 0 exts (f-0-4 7) (f-4-3 6) (f-8-4 6) exts-sem)
10488 ; exts.w r0 for m16c
10493 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 3))
10494 (exts-sem HI SI R0 R2R0)
10497 ; exts.size dst for m32c
10498 (ext32-defn QI HI .b 0 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem)
10499 (ext32-defn HI SI .w 1 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem)
10500 ; exts.b src,dst for m32c
10501 (ext32-binary-defn exts .b #x1 #x7 exts-sem)
10503 ; extz.b src,dst for m32c
10504 (ext32-binary-defn extz "" #x1 #xB extz-sem)
10506 ;-------------------------------------------------------------
10508 ;-------------------------------------------------------------
10511 (dni srcind "SRC-INDIRECT" ((machine 32))
10513 (+ (f-0-4 4) (f-4-4 1))
10514 (set (reg h-src-indirect) 1)
10517 (dni destind "DEST-INDIRECT" ((machine 32))
10519 (+ (f-0-4 0) (f-4-4 9))
10520 (set (reg h-dst-indirect) 1)
10523 (dni srcdestind "SRC-DEST-INDIRECT" ((machine 32))
10524 ("src-dest-indirect")
10525 (+ (f-0-4 4) (f-4-4 9))
10526 (sequence () (set (reg h-src-indirect) 1) (set (reg h-dst-indirect) 1))