1 ; Renesas M32C CPU description. -*- Scheme -*-
3 ; Copyright 2005, 2006 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 2 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, MA 02110-1301, USA.
23 (include "simplify.inc")
27 (comment "Renesas M32C")
28 (default-alignment forced)
37 (default-insn-bitsize 32)
39 ; Number of bytes of insn we can initially fetch.
40 (base-insn-bitsize 32)
42 ; Used in computing bit numbers.
43 (default-insn-word-bitsize 32)
45 (decode-assist (0 1 2 3 4 5 6 7)) ; Initial bitnumbers to decode insns by.
47 ; fetches 1 insn at a time.
50 ; executes 1 insn at a time.
57 (default-insn-bitsize 32)
59 ; Number of bytes of insn we can initially fetch.
60 (base-insn-bitsize 32)
62 ; Used in computing bit numbers.
63 (default-insn-word-bitsize 32)
65 (decode-assist (0 1 2 3 4 5 6 7)) ; Initial bitnumbers to decode insns by.
67 ; fetches 1 insn at a time.
70 ; executes 1 insn at a time.
75 ; cpu names must be distinct from the architecture name and machine names.
76 ; The "b" suffix stands for "base" and is the convention.
77 ; The "f" suffix stands for "family" and is the convention.
79 (comment "Renesas M16C base family")
86 ; cpu names must be distinct from the architecture name and machine names.
87 ; The "b" suffix stands for "base" and is the convention.
88 ; The "f" suffix stands for "family" and is the convention.
90 (comment "Renesas M32C base family")
98 (comment "Generic M16C cpu")
104 (comment "Generic M32C cpu")
108 ; Model descriptions.
112 (comment "m16c") (attrs)
115 ; `state' is a list of variables for recording model state
117 (unit u-exec "Execution Unit" ()
122 () ; profile action (default)
128 (comment "m32c") (attrs)
131 ; `state' is a list of variables for recording model state
133 (unit u-exec "Execution Unit" ()
138 () ; profile action (default)
145 (values NONE JUMP 1ADDR 2ADDR)
149 ; Macros to simplify MACH attribute specification.
151 (define-pmacro all-isas () (ISA m16c,m32c))
152 (define-pmacro m16c-isa () (ISA m16c))
153 (define-pmacro m32c-isa () (ISA m32c))
155 (define-pmacro MACH16 (MACH m16c))
156 (define-pmacro MACH32 (MACH m32c))
158 (define-pmacro (machine size)
159 (MACH (.sym m size c)) (ISA (.sym m size c)))
161 (define-pmacro RL_JUMP (RL_TYPE JUMP))
162 (define-pmacro RL_1ADDR (RL_TYPE 1ADDR))
163 (define-pmacro RL_2ADDR (RL_TYPE 2ADDR))
166 ;=============================================================
168 ;-------------------------------------------------------------
171 (dnf f-0-1 "opcode" (all-isas) 0 1)
172 (dnf f-0-2 "opcode" (all-isas) 0 2)
173 (dnf f-0-3 "opcode" (all-isas) 0 3)
174 (dnf f-0-4 "opcode" (all-isas) 0 4)
175 (dnf f-1-3 "opcode" (all-isas) 1 3)
176 (dnf f-2-2 "opcode" (all-isas) 2 2)
177 (dnf f-3-4 "opcode" (all-isas) 3 4)
178 (dnf f-3-1 "opcode" (all-isas) 3 1)
179 (dnf f-4-1 "opcode" (all-isas) 4 1)
180 (dnf f-4-3 "opcode" (all-isas) 4 3)
181 (dnf f-4-4 "opcode" (all-isas) 4 4)
182 (dnf f-4-6 "opcode" (all-isas) 4 6)
183 (dnf f-5-1 "opcode" (all-isas) 5 1)
184 (dnf f-5-3 "opcode" (all-isas) 5 3)
185 (dnf f-6-2 "opcode" (all-isas) 6 2)
186 (dnf f-7-1 "opcode" (all-isas) 7 1)
187 (dnf f-8-1 "opcode" (all-isas) 8 1)
188 (dnf f-8-2 "opcode" (all-isas) 8 2)
189 (dnf f-8-3 "opcode" (all-isas) 8 3)
190 (dnf f-8-4 "opcode" (all-isas) 8 4)
191 (dnf f-8-8 "opcode" (all-isas) 8 8)
192 (dnf f-9-3 "opcode" (all-isas) 9 3)
193 (dnf f-9-1 "opcode" (all-isas) 9 1)
194 (dnf f-10-1 "opcode" (all-isas) 10 1)
195 (dnf f-10-2 "opcode" (all-isas) 10 2)
196 (dnf f-10-3 "opcode" (all-isas) 10 3)
197 (dnf f-11-1 "opcode" (all-isas) 11 1)
198 (dnf f-12-1 "opcode" (all-isas) 12 1)
199 (dnf f-12-2 "opcode" (all-isas) 12 2)
200 (dnf f-12-3 "opcode" (all-isas) 12 3)
201 (dnf f-12-4 "opcode" (all-isas) 12 4)
202 (dnf f-12-6 "opcode" (all-isas) 12 6)
203 (dnf f-13-3 "opcode" (all-isas) 13 3)
204 (dnf f-14-1 "opcode" (all-isas) 14 1)
205 (dnf f-14-2 "opcode" (all-isas) 14 2)
206 (dnf f-15-1 "opcode" (all-isas) 15 1)
207 (dnf f-16-1 "opcode" (all-isas) 16 1)
208 (dnf f-16-2 "opcode" (all-isas) 16 2)
209 (dnf f-16-4 "opcode" (all-isas) 16 4)
210 (dnf f-16-8 "opcode" (all-isas) 16 8)
211 (dnf f-18-1 "opcode" (all-isas) 18 1)
212 (dnf f-18-2 "opcode" (all-isas) 18 2)
213 (dnf f-18-3 "opcode" (all-isas) 18 3)
214 (dnf f-20-1 "opcode" (all-isas) 20 1)
215 (dnf f-20-3 "opcode" (all-isas) 20 3)
216 (dnf f-20-2 "opcode" (all-isas) 20 2)
217 (dnf f-20-4 "opcode" (all-isas) 20 4)
218 (dnf f-21-3 "opcode" (all-isas) 21 3)
219 (dnf f-24-2 "opcode" (all-isas) 24 2)
220 (dnf f-24-8 "opcode" (all-isas) 24 8)
221 (dnf f-32-16 "opcode" (all-isas) 32 16)
223 ;-------------------------------------------------------------
225 ;-------------------------------------------------------------
227 (dnf f-src16-rn "source Rn for m16c" (MACH16 m16c-isa) 10 2)
228 (dnf f-src16-an "source An for m16c" (MACH16 m16c-isa) 11 1)
230 (dnf f-src32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 11 1)
231 (dnf f-src32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 19 1)
233 ; QI mode gr encoding for m32c is different than for m16c. The hardware
234 ; is indexed using the m16c encoding, so perform the transformation here.
236 ; ----------------------
241 (df f-src32-rn-unprefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 10 2 UINT
242 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
243 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
245 ; QI mode gr encoding for m32c is different than for m16c. The hardware
246 ; is indexed using the m16c encoding, so perform the transformation here.
248 ; ----------------------
253 (df f-src32-rn-prefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 18 2 UINT
254 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
255 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
257 ; HI mode gr encoding for m32c is different than for m16c. The hardware
258 ; is indexed using the m16c encoding, so perform the transformation here.
260 ; ----------------------
265 (df f-src32-rn-unprefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 10 2 UINT
266 ((value pc) (mod USI (add value 2) 4)) ; insert
267 ((value pc) (mod USI (add value 2) 4)) ; extract
270 ; HI mode gr encoding for m32c is different than for m16c. The hardware
271 ; is indexed using the m16c encoding, so perform the transformation here.
273 ; ----------------------
278 (df f-src32-rn-prefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 18 2 UINT
279 ((value pc) (mod USI (add value 2) 4)) ; insert
280 ((value pc) (mod USI (add value 2) 4)) ; extract
283 ; SI mode gr encoding for m32c is as follows:
284 ; register encoding index
285 ; -------------------------
288 (df f-src32-rn-unprefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 10 2 UINT
289 ((value pc) (add USI value 2)) ; insert
290 ((value pc) (sub USI value 2)) ; extract
292 (df f-src32-rn-prefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 18 2 UINT
293 ((value pc) (add USI value 2)) ; insert
294 ((value pc) (sub USI value 2)) ; extract
297 (dnf f-dst32-rn-ext-unprefixed "destination Rn for m32c" (MACH32 m32c-isa) 9 1)
299 (dnf f-dst16-rn "destination Rn for m16c" (MACH16 m16c-isa) 14 2)
300 (dnf f-dst16-rn-ext "destination Rn for m16c" (MACH16 m16c-isa) 14 1)
301 (dnf f-dst16-rn-QI-s "destination Rn for m16c" (MACH16 m16c-isa) 5 1)
303 (dnf f-dst16-an "destination An for m16c" (MACH16 m16c-isa) 15 1)
304 (dnf f-dst16-an-s "destination An for m16c" (MACH16 m16c-isa) 4 1)
306 (dnf f-dst32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 9 1)
307 (dnf f-dst32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 17 1)
309 ; QI mode gr encoding for m32c is different than for m16c. The hardware
310 ; is indexed using the m16c encoding, so perform the transformation here.
312 ; ----------------------
317 (df f-dst32-rn-unprefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 8 2 UINT
318 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
319 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
321 (df f-dst32-rn-prefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 16 2 UINT
322 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
323 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
325 ; HI mode gr encoding for m32c is different than for m16c. The hardware
326 ; is indexed using the m16c encoding, so perform the transformation here.
328 ; ----------------------
333 (df f-dst32-rn-unprefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 8 2 UINT
334 ((value pc) (mod USI (add value 2) 4)) ; insert
335 ((value pc) (mod USI (add value 2) 4)) ; extract
337 (df f-dst32-rn-prefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 16 2 UINT
338 ((value pc) (mod USI (add value 2) 4)) ; insert
339 ((value pc) (mod USI (add value 2) 4)) ; extract
341 ; SI mode gr encoding for m32c is as follows:
342 ; register encoding index
343 ; -------------------------
346 (df f-dst32-rn-unprefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 8 2 UINT
347 ((value pc) (add USI value 2)) ; insert
348 ((value pc) (sub USI value 2)) ; extract
350 (df f-dst32-rn-prefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 16 2 UINT
351 ((value pc) (add USI value 2)) ; insert
352 ((value pc) (sub USI value 2)) ; extract
355 (dnf f-dst16-1-S "destination R0[hl] for m16c" (MACH16 m16c-isa) 5 1)
357 ;-------------------------------------------------------------
358 ; Immediates embedded in the base insn
359 ;-------------------------------------------------------------
361 (df f-imm-8-s4 "4 bit signed" (all-isas) 8 4 INT #f #f)
362 (df f-imm-12-s4 "4 bit signed" (all-isas) 12 4 INT #f #f)
363 (df f-imm-13-u3 "3 bit unsigned" (all-isas) 13 3 UINT #f #f)
364 (df f-imm-20-s4 "4 bit signed" (all-isas) 20 4 INT #f #f)
366 (df f-imm1-S "1 bit immediate for short format binary insns" (MACH32 m32c-isa) 2 1 UINT
367 ((value pc) (sub USI value 1)) ; insert
368 ((value pc) (add USI value 1)) ; extract
371 (dnmf f-imm3-S "3 bit unsigned for short format insns" (all-isas) UINT
373 (sequence () ; insert
374 (set (ifield f-7-1) (and (sub (ifield f-imm3-S) 1) 1))
375 (set (ifield f-2-2) (and (srl (sub (ifield f-imm3-S) 1) 1) #x3))
377 (sequence () ; extract
378 (set (ifield f-imm3-S) (add (or (sll (ifield f-2-2) 1)
384 ;-------------------------------------------------------------
385 ; Immediates and displacements beyond the base insn
386 ;-------------------------------------------------------------
388 (df f-dsp-8-u6 "6 bit unsigned" (all-isas) 8 6 UINT #f #f)
389 (df f-dsp-8-u8 "8 bit unsigned" (all-isas) 8 8 UINT #f #f)
390 (df f-dsp-8-s8 "8 bit signed" (all-isas) 8 8 INT #f #f)
391 (df f-dsp-10-u6 "6 bit unsigned" (all-isas) 10 6 UINT #f #f)
392 (df f-dsp-16-u8 "8 bit unsigned" (all-isas) 16 8 UINT #f #f)
393 (df f-dsp-16-s8 "8 bit signed" (all-isas) 16 8 INT #f #f)
394 (df f-dsp-24-u8 "8 bit unsigned" (all-isas) 24 8 UINT #f #f)
395 (df f-dsp-24-s8 "8 bit signed" (all-isas) 24 8 INT #f #f)
396 (df f-dsp-32-u8 "8 bit unsigned" (all-isas) 32 8 UINT #f #f)
397 (df f-dsp-32-s8 "8 bit signed" (all-isas) 32 8 INT #f #f)
398 (df f-dsp-40-u8 "8 bit unsigned" (all-isas) 40 8 UINT #f #f)
399 (df f-dsp-40-s8 "8 bit signed" (all-isas) 40 8 INT #f #f)
400 (df f-dsp-48-u8 "8 bit unsigned" (all-isas) 48 8 UINT #f #f)
401 (df f-dsp-48-s8 "8 bit signed" (all-isas) 48 8 INT #f #f)
402 (df f-dsp-56-u8 "8 bit unsigned" (all-isas) 56 8 UINT #f #f)
403 (df f-dsp-56-s8 "8 bit signed" (all-isas) 56 8 INT #f #f)
404 (df f-dsp-64-u8 "8 bit unsigned" (all-isas) 64 8 UINT #f #f)
405 (df f-dsp-64-s8 "8 bit signed" (all-isas) 64 8 INT #f #f)
407 ; Insn opcode endianness is big, but the immediate fields are stored
408 ; in little endian. Handle this here at the field level for all immediate
409 ; fields longer that 1 byte.
411 ; CGEN can't handle a field which spans a 32 bit word boundary, so
412 ; handle those as multi ifields.
414 ; Take care in expressions using 'srl' or 'sll' as part of some larger
415 ; expression meant to yield sign-extended values. CGEN translates
416 ; uses of those operators into C expressions whose type is 'unsigned
417 ; int', which tends to make the whole expression 'unsigned int'.
418 ; Expressions like (set (ifield foo) X), however, just take X and
419 ; store it in some member of 'struct cgen_fields', all of whose
420 ; members are 'long'. On machines where 'long' is larger than
421 ; 'unsigned int', assigning a "sign-extended" unsigned int to a long
422 ; just produces a very large positive value. insert_normal will
423 ; range-check the field's value and produce odd error messages like
426 ; Error: operand out of range (4160684031 not between -2147483648 and 2147483647) `add.l #-265,-270[fb]'
428 ; Annoyingly, the code will work fine on machines where 'long' and
429 ; 'unsigned int' are the same size: the assignment will produce a
432 ; Just tell yourself over and over: overflow detection is expensive,
433 ; and you're glad C doesn't do it, because it never happens in real
436 (df f-dsp-8-u16 "16 bit unsigned" (all-isas) 8 16 UINT
438 (and (srl value 8) #x00ff)
439 (and (sll value 8) #xff00))) ; insert
441 (and UHI (srl UHI value 8) #x00ff)
442 (and UHI (sll UHI value 8) #xff00))) ; extract
445 (df f-dsp-8-s16 "8 bit signed" (all-isas) 8 16 INT
448 (or (and (srl value 8) #x00ff)
449 (and (sll value 8) #xff00))))) ; insert
452 (or (and (srl value 8) #x00ff)
453 (and (sll value 8) #xff00))))) ; extract
456 (df f-dsp-16-u16 "16 bit unsigned" (all-isas) 16 16 UINT
458 (and (srl value 8) #x00ff)
459 (and (sll value 8) #xff00))) ; insert
461 (and UHI (srl UHI value 8) #x00ff)
462 (and UHI (sll UHI value 8) #xff00))) ; extract
465 (df f-dsp-16-s16 "16 bit signed" (all-isas) 16 16 INT
468 (or (and (srl value 8) #x00ff)
469 (and (sll value 8) #xff00))))) ; insert
472 (or (and (srl value 8) #x00ff)
473 (and (sll value 8) #xff00))))) ; extract
476 (dnmf f-dsp-24-u16 "16 bit unsigned" (all-isas) UINT
477 (f-dsp-24-u8 f-dsp-32-u8)
478 (sequence () ; insert
479 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u16) #xff))
480 (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-24-u16) 8) #xff))
482 (sequence () ; extract
483 (set (ifield f-dsp-24-u16) (or (sll (ifield f-dsp-32-u8) 8)
484 (ifield f-dsp-24-u8)))
488 (dnmf f-dsp-24-s16 "16 bit signed" (all-isas) INT
489 (f-dsp-24-u8 f-dsp-32-u8)
490 (sequence () ; insert
491 (set (ifield f-dsp-24-u8)
492 (and (ifield f-dsp-24-s16) #xff))
493 (set (ifield f-dsp-32-u8)
494 (and (srl (ifield f-dsp-24-s16) 8) #xff))
496 (sequence () ; extract
497 (set (ifield f-dsp-24-s16)
499 (trunc HI (or (sll (ifield f-dsp-32-u8) 8)
500 (ifield f-dsp-24-u8)))))
504 (df f-dsp-32-u16 "16 bit unsigned" (all-isas) 32 16 UINT
506 (and (srl value 8) #x00ff)
507 (and (sll value 8) #xff00))) ; insert
509 (and UHI (srl UHI value 8) #x00ff)
510 (and UHI (sll UHI value 8) #xff00))) ; extract
513 (df f-dsp-32-s16 "16 bit signed" (all-isas) 32 16 INT
516 (or (and (srl value 8) #x00ff)
517 (and (sll value 8) #xff00))))) ; insert
520 (or (and (srl value 8) #x00ff)
521 (and (sll value 8) #xff00))))) ; extract
524 (df f-dsp-40-u16 "16 bit unsigned" (all-isas) 40 16 UINT
526 (and (srl value 8) #x00ff)
527 (and (sll value 8) #xff00))) ; insert
529 (and UHI (srl UHI value 8) #x00ff)
530 (and UHI (sll UHI value 8) #xff00))) ; extract
533 (df f-dsp-40-s16 "16 bit signed" (all-isas) 40 16 INT
536 (or (and (srl value 8) #x00ff)
537 (and (sll value 8) #xff00))))) ; insert
540 (or (and (srl value 8) #x00ff)
541 (and (sll value 8) #xff00))))) ; extract
544 (df f-dsp-48-u16 "16 bit unsigned" (all-isas) 48 16 UINT
546 (and (srl value 8) #x00ff)
547 (and (sll value 8) #xff00))) ; insert
549 (and UHI (srl UHI value 8) #x00ff)
550 (and UHI (sll UHI value 8) #xff00))) ; extract
553 (df f-dsp-48-s16 "16 bit signed" (all-isas) 48 16 INT
556 (or (and (srl value 8) #x00ff)
557 (and (sll value 8) #xff00))))) ; insert
560 (or (and (srl value 8) #x00ff)
561 (and (sll value 8) #xff00))))) ; extract
564 (df f-dsp-64-u16 "16 bit unsigned" (all-isas) 64 16 UINT
566 (and (srl value 8) #x00ff)
567 (and (sll value 8) #xff00))) ; insert
569 (and UHI (srl UHI value 8) #x00ff)
570 (and UHI (sll UHI value 8) #xff00))) ; extract
572 (df f-dsp-8-s24 "24 bit signed" (all-isas) 8 24 INT
574 (or (srl value 16) (and value #xff00))
575 (sll (ext INT (trunc QI (and value #xff))) 16)))
577 (or (srl value 16) (and value #xff00))
578 (sll (ext INT (trunc QI (and value #xff))) 16)))
581 (df f-dsp-8-u24 "24 bit unsigned" (all-isas) 8 24 UINT
583 (or (srl value 16) (and value #xff00))
584 (sll (and value #xff) 16)))
586 (or (srl value 16) (and value #xff00))
587 (sll (and value #xff) 16)))
590 (dnmf f-dsp-16-u24 "24 bit unsigned" (all-isas) UINT
591 (f-dsp-16-u16 f-dsp-32-u8)
592 (sequence () ; insert
593 (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-u24) #xffff))
594 (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-16-u24) 16) #xff))
596 (sequence () ; extract
597 (set (ifield f-dsp-16-u24) (or (sll (ifield f-dsp-32-u8) 16)
598 (ifield f-dsp-16-u16)))
602 (dnmf f-dsp-24-u24 "24 bit unsigned" (all-isas) UINT
603 (f-dsp-24-u8 f-dsp-32-u16)
604 (sequence () ; insert
605 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u24) #xff))
606 (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-24-u24) 8) #xffff))
608 (sequence () ; extract
609 (set (ifield f-dsp-24-u24) (or (sll (ifield f-dsp-32-u16) 8)
610 (ifield f-dsp-24-u8)))
614 (df f-dsp-32-u24 "24 bit unsigned" (all-isas) 32 24 UINT
617 (and (srl value 16) #x0000ff)
618 (and value #x00ff00))
619 (and (sll value 16) #xff0000))) ; insert
622 (and USI (srl UHI value 16) #x0000ff)
623 (and USI value #x00ff00))
624 (and USI (sll UHI value 16) #xff0000))) ; extract
627 (df f-dsp-40-u20 "20 bit unsigned" (all-isas) 40 20 UINT
630 (and (srl value 16) #x0000ff)
631 (and value #x00ff00))
632 (and (sll value 16) #x0f0000))) ; insert
635 (and USI (srl UHI value 16) #x0000ff)
636 (and USI value #x00ff00))
637 (and USI (sll UHI value 16) #x0f0000))) ; extract
639 (df f-dsp-40-u24 "24 bit unsigned" (all-isas) 40 24 UINT
642 (and (srl value 16) #x0000ff)
643 (and value #x00ff00))
644 (and (sll value 16) #xff0000))) ; insert
647 (and USI (srl UHI value 16) #x0000ff)
648 (and USI value #x00ff00))
649 (and USI (sll UHI value 16) #xff0000))) ; extract
652 (dnmf f-dsp-40-s32 "32 bit signed" (all-isas) INT
653 (f-dsp-40-u24 f-dsp-64-u8)
654 (sequence () ; insert
655 (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-40-s32) 24) #xff))
656 (set (ifield f-dsp-40-u24) (and (ifield f-dsp-40-s32) #xffffff))
658 (sequence () ; extract
659 (set (ifield f-dsp-40-s32) (or (and (ifield f-dsp-40-u24) #xffffff)
660 (and (sll (ifield f-dsp-64-u8) 24) #xff000000)))
664 (dnmf f-dsp-48-u20 "20 bit unsigned" (all-isas) UINT
665 (f-dsp-48-u16 f-dsp-64-u8)
666 (sequence () ; insert
667 (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-48-u20) 16) #x0f))
668 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u20) #xffff))
670 (sequence () ; extract
671 (set (ifield f-dsp-48-u20) (or (and (ifield f-dsp-48-u16) #xffff)
672 (and (sll (ifield f-dsp-64-u8) 16) #x0f0000)))
675 (dnmf f-dsp-48-u24 "24 bit unsigned" (all-isas) UINT
676 (f-dsp-48-u16 f-dsp-64-u8)
677 (sequence () ; insert
678 (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-48-u24) 16) #xff))
679 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u24) #xffff))
681 (sequence () ; extract
682 (set (ifield f-dsp-48-u24) (or (and (ifield f-dsp-48-u16) #xffff)
683 (and (sll (ifield f-dsp-64-u8) 16) #xff0000)))
687 (dnmf f-dsp-16-s32 "32 bit signed" (all-isas) INT
688 (f-dsp-16-u16 f-dsp-32-u16)
689 (sequence () ; insert
690 (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-16-s32) 16) #xffff))
691 (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-s32) #xffff))
693 (sequence () ; extract
694 (set (ifield f-dsp-16-s32) (or (and (ifield f-dsp-16-u16) #xffff)
695 (and (sll (ifield f-dsp-32-u16) 16) #xffff0000)))
699 (dnmf f-dsp-24-s32 "32 bit signed" (all-isas) INT
700 (f-dsp-24-u8 f-dsp-32-u24)
701 (sequence () ; insert
702 (set (ifield f-dsp-32-u24) (and (srl (ifield f-dsp-24-s32) 8) #xffffff))
703 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-s32) #xff))
705 (sequence () ; extract
706 (set (ifield f-dsp-24-s32) (or (and (ifield f-dsp-24-u8) #xff)
707 (and (sll (ifield f-dsp-32-u24) 8) #xffffff00)))
711 (df f-dsp-32-s32 "32 bit signed" (all-isas) 32 32 INT
718 (and (srl value 24) #x000000ff)
719 (and (srl value 8) #x0000ff00))
721 (and (sll value 8) #x00ff0000)
722 (and (sll value 24) #xff000000)))))
729 (and (srl value 24) #x000000ff)
730 (and (srl value 8) #x0000ff00))
732 (and (sll value 8) #x00ff0000)
733 (and (sll value 24) #xff000000)))))
736 (dnmf f-dsp-48-u32 "32 bit unsigned" (all-isas) UINT
737 (f-dsp-48-u16 f-dsp-64-u16)
738 (sequence () ; insert
739 (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-u32) 16) #xffff))
740 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u32) #xffff))
742 (sequence () ; extract
743 (set (ifield f-dsp-48-u32) (or (and (ifield f-dsp-48-u16) #xffff)
744 (and (sll (ifield f-dsp-64-u16) 16) #xffff0000)))
748 (dnmf f-dsp-48-s32 "32 bit signed" (all-isas) INT
749 (f-dsp-48-u16 f-dsp-64-u16)
750 (sequence () ; insert
751 (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-s32) 16) #xffff))
752 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-s32) #xffff))
754 (sequence () ; extract
755 (set (ifield f-dsp-48-s32) (or (and (ifield f-dsp-48-u16) #xffff)
756 (and (sll (ifield f-dsp-64-u16) 16) #xffff0000)))
760 (dnmf f-dsp-56-s16 "16 bit signed" (all-isas) INT
761 (f-dsp-56-u8 f-dsp-64-u8)
762 (sequence () ; insert
763 (set (ifield f-dsp-56-u8)
764 (and (ifield f-dsp-56-s16) #xff))
765 (set (ifield f-dsp-64-u8)
766 (and (srl (ifield f-dsp-56-s16) 8) #xff))
768 (sequence () ; extract
769 (set (ifield f-dsp-56-s16)
771 (trunc HI (or (sll (ifield f-dsp-64-u8) 8)
772 (ifield f-dsp-56-u8)))))
776 (df f-dsp-64-s16 " 16 bit signed" (all-isas) 64 16 INT
779 (or (and (srl value 8) #x00ff)
780 (and (sll value 8) #xff00))))) ; insert
783 (or (and (srl value 8) #x00ff)
784 (and (sll value 8) #xff00))))) ; extract
787 ;-------------------------------------------------------------
789 ;-------------------------------------------------------------
791 (dnf f-bitno16-S "bit index for m16c" (all-isas) 5 3)
792 (dnf f-bitno32-prefixed "bit index for m32c" (all-isas) 21 3)
793 (dnf f-bitno32-unprefixed "bit index for m32c" (all-isas) 13 3)
795 (dnmf f-bitbase16-u11-S "unsigned bit,base:11" (all-isas) UINT
796 (f-bitno16-S f-dsp-8-u8)
797 (sequence () ; insert
798 (set (ifield f-bitno16-S) (and f-bitbase16-u11-S #x7))
799 (set (ifield f-dsp-8-u8) (and (srl (ifield f-bitbase16-u11-S) 3) #xff))
801 (sequence () ; extract
802 (set (ifield f-bitbase16-u11-S) (or (sll (ifield f-dsp-8-u8) 3)
803 (ifield f-bitno16-S)))
807 (dnmf f-bitbase32-16-u11-unprefixed "unsigned bit,base:11" (all-isas) UINT
808 (f-bitno32-unprefixed f-dsp-16-u8)
809 (sequence () ; insert
810 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u11-unprefixed #x7))
811 (set (ifield f-dsp-16-u8) (and (srl (ifield f-bitbase32-16-u11-unprefixed) 3) #xff))
813 (sequence () ; extract
814 (set (ifield f-bitbase32-16-u11-unprefixed) (or (sll (ifield f-dsp-16-u8) 3)
815 (ifield f-bitno32-unprefixed)))
818 (dnmf f-bitbase32-16-s11-unprefixed "signed bit,base:11" (all-isas) INT
819 (f-bitno32-unprefixed f-dsp-16-s8)
820 (sequence () ; insert
821 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s11-unprefixed #x7))
822 (set (ifield f-dsp-16-s8) (sra INT (ifield f-bitbase32-16-s11-unprefixed) 3))
824 (sequence () ; extract
825 (set (ifield f-bitbase32-16-s11-unprefixed) (or (sll (ifield f-dsp-16-s8) 3)
826 (ifield f-bitno32-unprefixed)))
829 (dnmf f-bitbase32-16-u19-unprefixed "unsigned bit,base:19" (all-isas) UINT
830 (f-bitno32-unprefixed f-dsp-16-u16)
831 (sequence () ; insert
832 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u19-unprefixed #x7))
833 (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u19-unprefixed) 3) #xffff))
835 (sequence () ; extract
836 (set (ifield f-bitbase32-16-u19-unprefixed) (or (sll (ifield f-dsp-16-u16) 3)
837 (ifield f-bitno32-unprefixed)))
840 (dnmf f-bitbase32-16-s19-unprefixed "signed bit,base:11" (all-isas) INT
841 (f-bitno32-unprefixed f-dsp-16-s16)
842 (sequence () ; insert
843 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s19-unprefixed #x7))
844 (set (ifield f-dsp-16-s16) (sra INT (ifield f-bitbase32-16-s19-unprefixed) 3))
846 (sequence () ; extract
847 (set (ifield f-bitbase32-16-s19-unprefixed) (or (sll (ifield f-dsp-16-s16) 3)
848 (ifield f-bitno32-unprefixed)))
851 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
852 (dnmf f-bitbase32-16-u27-unprefixed "unsigned bit,base:27" (all-isas) UINT
853 (f-bitno32-unprefixed f-dsp-16-u16 f-dsp-32-u8)
854 (sequence () ; insert
855 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u27-unprefixed #x7))
856 (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 3) #xffff))
857 (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 19) #xff))
859 (sequence () ; extract
860 (set (ifield f-bitbase32-16-u27-unprefixed) (or (sll (ifield f-dsp-16-u16) 3)
861 (or (sll (ifield f-dsp-32-u8) 19)
862 (ifield f-bitno32-unprefixed))))
865 (dnmf f-bitbase32-24-u11-prefixed "unsigned bit,base:11" (all-isas) UINT
866 (f-bitno32-prefixed f-dsp-24-u8)
867 (sequence () ; insert
868 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u11-prefixed #x7))
869 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u11-prefixed) 3) #xff))
871 (sequence () ; extract
872 (set (ifield f-bitbase32-24-u11-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
873 (ifield f-bitno32-prefixed)))
876 (dnmf f-bitbase32-24-s11-prefixed "signed bit,base:11" (all-isas) INT
877 (f-bitno32-prefixed f-dsp-24-s8)
878 (sequence () ; insert
879 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s11-prefixed #x7))
880 (set (ifield f-dsp-24-s8) (sra INT (ifield f-bitbase32-24-s11-prefixed) 3))
882 (sequence () ; extract
883 (set (ifield f-bitbase32-24-s11-prefixed) (or (sll (ifield f-dsp-24-s8) 3)
884 (ifield f-bitno32-prefixed)))
887 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
888 (dnmf f-bitbase32-24-u19-prefixed "unsigned bit,base:19" (all-isas) UINT
889 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u8)
890 (sequence () ; insert
891 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u19-prefixed #x7))
892 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 3) #xff))
893 (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 11) #xff))
895 (sequence () ; extract
896 (set (ifield f-bitbase32-24-u19-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
897 (or (sll (ifield f-dsp-32-u8) 11)
898 (ifield f-bitno32-prefixed))))
901 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
902 (dnmf f-bitbase32-24-s19-prefixed "signed bit,base:11" (all-isas) INT
903 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-s8)
904 (sequence () ; insert
905 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s19-prefixed #x7))
906 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-s19-prefixed) 3) #xff))
907 (set (ifield f-dsp-32-s8) (sra INT (ifield f-bitbase32-24-s19-prefixed) 11))
909 (sequence () ; extract
910 (set (ifield f-bitbase32-24-s19-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
911 (or (sll (ifield f-dsp-32-s8) 11)
912 (ifield f-bitno32-prefixed))))
915 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
916 (dnmf f-bitbase32-24-u27-prefixed "unsigned bit,base:27" (all-isas) UINT
917 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u16)
918 (sequence () ; insert
919 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u27-prefixed #x7))
920 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u27-prefixed) 3) #xff))
921 (set (ifield f-dsp-32-u16) (and (srl (ifield f-bitbase32-24-u27-prefixed) 11) #xffff))
923 (sequence () ; extract
924 (set (ifield f-bitbase32-24-u27-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
925 (or (sll (ifield f-dsp-32-u16) 11)
926 (ifield f-bitno32-prefixed))))
930 ;-------------------------------------------------------------
932 ;-------------------------------------------------------------
934 (df f-lab-5-3 "3 bit pc relative unsigned offset" (PCREL-ADDR all-isas) 5 3 UINT
935 ((value pc) (sub SI value (add SI pc 2))) ; insert
936 ((value pc) (add SI value (add SI pc 2))) ; extract
938 (dnmf f-lab32-jmp-s "unsigned 3 bit pc relative offset" (PCREL-ADDR all-isas) UINT
940 (sequence ((SI val)) ; insert
941 (set val (sub (sub (ifield f-lab32-jmp-s) pc) 2))
942 (set (ifield f-7-1) (and val #x1))
943 (set (ifield f-2-2) (srl val 1))
945 (sequence () ; extract
946 (set (ifield f-lab32-jmp-s) (add pc (add (or (sll (ifield f-2-2) 1)
951 (df f-lab-8-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 8 8 INT
952 ((value pc) (sub SI value (add SI pc 1))) ; insert
953 ((value pc) (add SI value (add SI pc 1))) ; extract
955 (df f-lab-8-16 "16 bit pc relative signed offset" (PCREL-ADDR SIGN-OPT all-isas) 8 16 UINT
956 ((value pc) (or SI (sll (and (sub value (add pc 1)) #xff) 8)
957 (srl (and (sub value (add pc 1)) #xffff) 8)))
958 ((value pc) (add SI (or (srl (and value #xffff) 8)
959 (sra (sll (and value #xff) 24) 16)) (add pc 1)))
961 (df f-lab-8-24 "24 bit absolute" (all-isas ABS-ADDR) 8 24 UINT
963 (or (srl value 16) (and value #xff00))
964 (sll (and value #xff) 16)))
966 (or (srl value 16) (and value #xff00))
967 (sll (and value #xff) 16)))
969 (df f-lab-16-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 16 8 INT
970 ((value pc) (sub SI value (add SI pc 2))) ; insert
971 ((value pc) (add SI value (add SI pc 2))) ; extract
973 (df f-lab-24-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 24 8 INT
974 ((value pc) (sub SI value (add SI pc 2))) ; insert
975 ((value pc) (add SI value (add SI pc 2))) ; extract
977 (df f-lab-32-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 32 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-40-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 40 8 INT
982 ((value pc) (sub SI value (add SI pc 2))) ; insert
983 ((value pc) (add SI value (add SI pc 2))) ; extract
986 ;-------------------------------------------------------------
988 ;-------------------------------------------------------------
990 (dnf f-cond16 "condition code" (all-isas) 12 4)
991 (dnf f-cond16j-5 "condition code" (all-isas) 5 3)
993 (dnmf f-cond32 "condition code" (all-isas) UINT
995 (sequence () ; insert
996 (set (ifield f-9-1) (and (srl (ifield f-cond32) 3) 1))
997 (set (ifield f-13-3) (and (ifield f-cond32) #x7))
999 (sequence () ; extract
1000 (set (ifield f-cond32) (or (sll (ifield f-9-1) 3)
1005 (dnmf f-cond32j "condition code" (all-isas) UINT
1007 (sequence () ; insert
1008 (set (ifield f-1-3) (and (srl (ifield f-cond32j) 1) #x7))
1009 (set (ifield f-7-1) (and (ifield f-cond32j) #x1))
1011 (sequence () ; extract
1012 (set (ifield f-cond32j) (or (sll (ifield f-1-3) 1)
1017 ;=============================================================
1020 (dnh h-pc "program counter" (PC all-isas) (pc USI) () () ())
1022 ;-------------------------------------------------------------
1024 ; The actual registers are 16 bits
1025 ;-------------------------------------------------------------
1029 (comment "general 16 bit registers")
1030 (attrs all-isas CACHE-ADDR)
1031 (type register HI (4))
1032 (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3))))
1034 ; Define different views of the grs as VIRTUAL with getter/setter specs
1038 (comment "general 8 bit registers")
1039 (attrs all-isas VIRTUAL)
1040 (type register QI (4))
1041 (indices keyword "" (("r0l" 0) ("r0h" 1) ("r1l" 2) ("r1h" 3)))
1042 (get (index) (and (if SI (mod index 2)
1043 (srl (reg h-gr (div index 2)) 8)
1044 (reg h-gr (div index 2)))
1046 (set (index newval) (set (reg h-gr (div index 2))
1047 (if SI (mod index 2)
1048 (or (and (reg h-gr (div index 2)) #xff)
1049 (sll (and newval #xff) 8))
1050 (or (and (reg h-gr (div index 2)) #xff00)
1051 (and newval #xff))))))
1055 (comment "general 16 bit registers")
1056 (attrs all-isas VIRTUAL)
1057 (type register HI (4))
1058 (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3)))
1059 (get (index) (reg h-gr index))
1060 (set (index newval) (set (reg h-gr index) newval)))
1064 (comment "general 32 bit registers")
1065 (attrs all-isas VIRTUAL)
1066 (type register SI (2))
1067 (indices keyword "" (("r2r0" 0) ("r3r1" 1)))
1069 (and (reg h-gr index) #xffff)
1070 (and (sll (reg h-gr (add index 2)) 16) #xffff0000)))
1071 (set (index newval) (sequence ()
1072 (set (reg h-gr index) (and newval #xffff))
1073 (set (reg h-gr (add index 2)) (srl newval 16)))))
1077 (comment "general 16 bit registers")
1078 (attrs all-isas VIRTUAL)
1079 (type register HI (2))
1080 (indices keyword "" (("r0l" 0) ("r1l" 1)))
1081 (get (index) (reg h-gr-QI (mul index 2)))
1082 (set (index newval) (set (reg h-gr (mul index 2)) newval)))
1086 (comment "general 16 bit registers")
1087 (attrs all-isas VIRTUAL)
1088 (type register SI (2))
1089 (indices keyword "" (("r0" 0) ("r1" 1)))
1090 (get (index) (reg h-gr (mul index 2)))
1091 (set (index newval) (set (reg h-gr-SI index) newval)))
1095 (comment "r0l register")
1096 (attrs all-isas VIRTUAL)
1098 (indices keyword "" (("r0l" 0)))
1099 (get () (reg h-gr-QI 0))
1100 (set (newval) (set (reg h-gr-QI 0) newval)))
1104 (comment "r0h register")
1105 (attrs all-isas VIRTUAL)
1107 (indices keyword "" (("r0h" 0)))
1108 (get () (reg h-gr-QI 1))
1109 (set (newval) (set (reg h-gr-QI 1) newval)))
1113 (comment "r1l register")
1114 (attrs all-isas VIRTUAL)
1116 (indices keyword "" (("r1l" 0)))
1117 (get () (reg h-gr-QI 2))
1118 (set (newval) (set (reg h-gr-QI 2) newval)))
1122 (comment "r1h register")
1123 (attrs all-isas VIRTUAL)
1125 (indices keyword "" (("r1h" 0)))
1126 (get () (reg h-gr-QI 3))
1127 (set (newval) (set (reg h-gr-QI 3) newval)))
1131 (comment "r0 register")
1132 (attrs all-isas VIRTUAL)
1134 (indices keyword "" (("r0" 0)))
1135 (get () (reg h-gr 0))
1136 (set (newval) (set (reg h-gr 0) newval)))
1140 (comment "r1 register")
1141 (attrs all-isas VIRTUAL)
1143 (indices keyword "" (("r1" 0)))
1144 (get () (reg h-gr 1))
1145 (set (newval) (set (reg h-gr 1) newval)))
1149 (comment "r2 register")
1150 (attrs all-isas VIRTUAL)
1152 (indices keyword "" (("r2" 0)))
1153 (get () (reg h-gr 2))
1154 (set (newval) (set (reg h-gr 2) newval)))
1158 (comment "r3 register")
1159 (attrs all-isas VIRTUAL)
1161 (indices keyword "" (("r3" 0)))
1162 (get () (reg h-gr 3))
1163 (set (newval) (set (reg h-gr 3) newval)))
1167 (comment "r0l or r0h")
1168 (attrs all-isas VIRTUAL)
1169 (type register QI (2))
1170 (indices keyword "" (("r0l" 0) ("r0h" 1)))
1171 (get (index) (reg h-gr-QI index))
1172 (set (index newval) (set (reg h-gr-QI index) newval)))
1176 (comment "r2r0 register")
1177 (attrs all-isas VIRTUAL)
1179 (indices keyword "" (("r2r0" 0)))
1180 (get () (or (sll (reg h-gr 2) 16) (reg h-gr 0)))
1183 (set (reg h-gr 0) newval)
1184 (set (reg h-gr 2) (sra newval 16)))))
1188 (comment "r3r1 register")
1189 (attrs all-isas VIRTUAL)
1191 (indices keyword "" (("r3r1" 0)))
1192 (get () (or (sll (reg h-gr 3) 16) (reg h-gr 1)))
1195 (set (reg h-gr 1) newval)
1196 (set (reg h-gr 3) (sra newval 16)))))
1200 (comment "r1r2r0 register")
1201 (attrs all-isas VIRTUAL)
1203 (indices keyword "" (("r1r2r0" 0)))
1204 (get () (or DI (sll DI (reg h-gr 1) 32) (or (sll (reg h-gr 2) 16) (reg h-gr 0))))
1207 (set (reg h-gr 0) newval)
1208 (set (reg h-gr 2) (sra newval 16))
1209 (set (reg h-gr 1) (sra newval 32)))))
1211 ;-------------------------------------------------------------
1213 ;-------------------------------------------------------------
1217 (comment "address registers")
1219 (type register USI (2))
1220 (indices keyword "" (("a0" 0) ("a1" 1)))
1221 (get (index) (c-call USI "h_ar_get_handler" index))
1222 (set (index newval) (c-call VOID "h_ar_set_handler" index newval)))
1224 ; Define different views of the ars as VIRTUAL with getter/setter specs
1227 (comment "8 bit view of address register")
1228 (attrs all-isas VIRTUAL)
1229 (type register QI (2))
1230 (indices keyword "" (("a0" 0) ("a1" 1)))
1231 (get (index) (reg h-ar index))
1232 (set (index newval) (set (reg h-ar index) newval)))
1236 (comment "16 bit view of address register")
1237 (attrs all-isas VIRTUAL)
1238 (type register HI (2))
1239 (indices keyword "" (("a0" 0) ("a1" 1)))
1240 (get (index) (reg h-ar index))
1241 (set (index newval) (set (reg h-ar index) newval)))
1245 (comment "32 bit view of address register")
1246 (attrs all-isas VIRTUAL)
1248 (indices keyword "" (("a1a0" 0)))
1249 (get () (or SI (sll SI (ext SI (reg h-ar 1)) 16) (ext SI (reg h-ar 0))))
1250 (set (newval) (sequence ()
1251 (set (reg h-ar 0) (and newval #xffff))
1252 (set (reg h-ar 1) (and (srl newval 16) #xffff)))))
1256 (comment "16 bit view of address register")
1257 (attrs all-isas VIRTUAL)
1259 (indices keyword "" (("a0" 0)))
1260 (get () (reg h-ar 0))
1261 (set (newval) (set (reg h-ar 0) newval)))
1265 (comment "16 bit view of address register")
1266 (attrs all-isas VIRTUAL)
1268 (indices keyword "" (("a1" 1)))
1269 (get () (reg h-ar 1))
1270 (set (newval) (set (reg h-ar 1) newval)))
1275 (comment "SB register")
1278 (get () (c-call USI "h_sb_get_handler"))
1279 (set (newval) (c-call VOID "h_sb_set_handler" newval))
1285 (comment "FB register")
1288 (get () (c-call USI "h_fb_get_handler"))
1289 (set (newval) (c-call VOID "h_fb_set_handler" newval))
1295 (comment "SP register")
1298 (get () (c-call USI "h_sp_get_handler"))
1299 (set (newval) (c-call VOID "h_sp_set_handler" newval))
1302 ;-------------------------------------------------------------
1303 ; condition-code bits
1304 ;-------------------------------------------------------------
1308 (comment "sign bit")
1315 (comment "zero bit")
1322 (comment "overflow bit")
1329 (comment "carry bit")
1336 (comment "stack pointer select bit")
1343 (comment "interrupt enable bit")
1350 (comment "register bank select bit")
1357 (comment "debug bit")
1364 (comment "dma transfer count 000")
1370 (comment "dma transfer count 001")
1376 (comment "save flag 011")
1382 (comment "dma transfer count reload 100")
1388 (comment "dma transfer count reload 101")
1394 (comment "dma mode 110")
1400 (comment "dma mode 111")
1406 (comment "interrupt table 000")
1412 (comment "save pc 100")
1418 (comment "vector 101")
1424 (comment "interrupt stack ptr 111")
1430 (comment "dma mem addr 010")
1436 (comment "dma mem addr 011")
1442 (comment "dma mem addr reload 100")
1448 (comment "dma mem addr reload 101")
1454 (comment "dma sfr addr 110")
1460 (comment "dma sfr addr 111")
1465 ;-------------------------------------------------------------
1466 ; Condition code operand hardware
1467 ;-------------------------------------------------------------
1471 (comment "condition code hardware for m16c")
1472 (attrs m16c-isa MACH16)
1473 (type immediate UQI)
1475 (("geu" #x00) ("c" #x00)
1477 ("eq" #x02) ("z" #x02)
1482 ("ltu" #xf8) ("nc" #xf8)
1484 ("ne" #xfa) ("nz" #xfa)
1494 (comment "condition code hardware for m16c")
1495 (attrs m16c-isa MACH16)
1496 (type immediate UQI)
1498 (("geu" #x00) ("c" #x00)
1500 ("eq" #x02) ("z" #x02)
1502 ("ltu" #x04) ("nc" #x04)
1504 ("ne" #x06) ("nz" #x06)
1517 (comment "condition code hardware for m16c")
1518 (attrs m16c-isa MACH16)
1519 (type immediate UQI)
1532 (comment "condition code hardware for m16c")
1533 (attrs m16c-isa MACH16)
1534 (type immediate UQI)
1536 (("geu" #x00) ("c" #x00)
1538 ("eq" #x02) ("z" #x02)
1540 ("ltu" #x04) ("nc" #x04)
1542 ("ne" #x06) ("nz" #x06)
1550 (comment "condition code hardware for m32c")
1551 (attrs m32c-isa MACH32)
1552 (type immediate UQI)
1554 (("ltu" #x00) ("nc" #x00)
1556 ("ne" #x02) ("nz" #x02)
1561 ("geu" #x08) ("c" #x08)
1563 ("eq" #x0a) ("z" #x0a)
1574 (comment "control registers")
1575 (attrs m32c-isa MACH32)
1576 (type immediate UQI)
1577 (values keyword "" (("dct0" 0) ("dct1" 1) ("flg" 2) ("svf" 3) ("drc0" 4)
1578 ("drc1" 5) ("dmd0" 6) ("dmd1" 7))))
1581 (comment "control registers")
1582 (attrs m32c-isa MACH32)
1583 (type immediate UQI)
1584 (values keyword "" (("intb" 0) ("sp" 1) ("sb" 2) ("fb" 3) ("svp" 4)
1585 ("vct" 5) ("isp" 7))))
1589 (comment "control registers")
1590 (attrs m32c-isa MACH32)
1591 (type immediate UQI)
1592 (values keyword "" (("dma0" 2) ("dma1" 3) ("dra0" 4)
1593 ("dra1" 5) ("dsa0" 6) ("dsa1" 7))))
1596 (comment "control registers")
1597 (attrs m16c-isa MACH16)
1598 (type immediate UQI)
1599 (values keyword "" (("intbl" 1) ("intbh" 2) ("flg" 3) ("isp" 4)
1600 ("sp" 5) ("sb" 6) ("fb" 7))))
1604 (comment "flag hardware for m32c")
1606 (type immediate UQI)
1620 ;-------------------------------------------------------------
1621 ; Misc helper hardware
1622 ;-------------------------------------------------------------
1626 (comment "shift immediate")
1628 (type immediate (INT 4))
1629 (values keyword "" (("1" 0) ("2" 1) ("3" 2) ("4" 3) ("5" 4) ("6" 5) ("7" 6)
1630 ("8" 7) ("-1" -8) ("-2" -7) ("-3" -6) ("-4" -5) ("-5" -4)
1631 ("-6" -3) ("-7" -2) ("-8" -1)
1635 (comment "bit index for the next insn")
1636 (attrs m32c-isa MACH32)
1641 (comment "source index for the next insn")
1642 (attrs m32c-isa MACH32)
1647 (comment "destination index for the next insn")
1648 (attrs m32c-isa MACH32)
1652 (name h-src-indirect)
1653 (comment "indirect src for the next insn")
1658 (name h-dst-indirect)
1659 (comment "indirect dst for the next insn")
1665 (comment "for storing unused values")
1666 (attrs m32c-isa MACH32)
1670 ;=============================================================
1672 ;-------------------------------------------------------------
1674 ;-------------------------------------------------------------
1676 (dnop Src16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-src16-rn)
1677 (dnop Src16RnHI "general register QH view" (MACH16 m16c-isa) h-gr-HI f-src16-rn)
1679 (dnop Src32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-unprefixed-QI)
1680 (dnop Src32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-unprefixed-HI)
1681 (dnop Src32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-unprefixed-SI)
1683 (dnop Src32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-prefixed-QI)
1684 (dnop Src32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-prefixed-HI)
1685 (dnop Src32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-prefixed-SI)
1687 (dnop Src16An "address register" (MACH16 m16c-isa) h-ar f-src16-an)
1688 (dnop Src16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-src16-an)
1689 (dnop Src16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-src16-an)
1691 (dnop Src32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed)
1692 (dnop Src32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-unprefixed)
1693 (dnop Src32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-unprefixed)
1694 (dnop Src32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed)
1696 (dnop Src32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-prefixed)
1697 (dnop Src32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-prefixed)
1698 (dnop Src32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-prefixed)
1699 (dnop Src32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-prefixed)
1701 ; Destination Registers
1703 (dnop Dst16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-dst16-rn)
1704 (dnop Dst16RnHI "general register HI view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn)
1705 (dnop Dst16RnSI "general register SI view" (MACH16 m16c-isa) h-gr-SI f-dst16-rn)
1706 (dnop Dst16RnExtQI "general register QI/HI view for 'ext' insns" (MACH16 m16c-isa) h-gr-ext-QI f-dst16-rn-ext)
1708 (dnop Dst32R0QI-S "general register QI view" (MACH32 m32c-isa) h-r0l f-nil)
1709 (dnop Dst32R0HI-S "general register HI view" (MACH32 m32c-isa) h-r0 f-nil)
1711 (dnop Dst32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI)
1712 (dnop Dst32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-unprefixed-HI)
1713 (dnop Dst32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-unprefixed-SI)
1714 (dnop Dst32RnExtUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-ext-QI f-dst32-rn-ext-unprefixed)
1715 (dnop Dst32RnExtUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-ext-HI f-dst32-rn-ext-unprefixed)
1717 (dnop Dst32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI)
1718 (dnop Dst32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-prefixed-HI)
1719 (dnop Dst32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-prefixed-SI)
1721 (dnop Dst16RnQI-S "general register QI view" (MACH16 m16c-isa) h-r0l-r0h f-dst16-rn-QI-s)
1723 (dnop Dst16AnQI-S "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-rn-QI-s)
1725 (dnop Bit16Rn "general register bit view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn)
1727 (dnop Bit32RnPrefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI)
1728 (dnop Bit32RnUnprefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI)
1730 (dnop R0 "r0" (all-isas) h-r0 f-nil)
1731 (dnop R1 "r1" (all-isas) h-r1 f-nil)
1732 (dnop R2 "r2" (all-isas) h-r2 f-nil)
1733 (dnop R3 "r3" (all-isas) h-r3 f-nil)
1734 (dnop R0l "r0l" (all-isas) h-r0l f-nil)
1735 (dnop R0h "r0h" (all-isas) h-r0h f-nil)
1736 (dnop R2R0 "r2r0" (all-isas) h-r2r0 f-nil)
1737 (dnop R3R1 "r3r1" (all-isas) h-r3r1 f-nil)
1738 (dnop R1R2R0 "r1r2r0" (all-isas) h-r1r2r0 f-nil)
1740 (dnop Dst16An "address register" (MACH16 m16c-isa) h-ar f-dst16-an)
1741 (dnop Dst16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-an)
1742 (dnop Dst16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an)
1743 (dnop Dst16AnSI "address register SI view" (MACH16 m16c-isa) h-ar-SI f-dst16-an)
1744 (dnop Dst16An-S "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an-s)
1746 (dnop Dst32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1747 (dnop Dst32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-unprefixed)
1748 (dnop Dst32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-unprefixed)
1749 (dnop Dst32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1751 (dnop Dst32AnExtUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1753 (dnop Dst32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1754 (dnop Dst32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-prefixed)
1755 (dnop Dst32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-prefixed)
1756 (dnop Dst32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1758 (dnop Bit16An "address register bit view" (MACH16 m16c-isa) h-ar f-dst16-an)
1760 (dnop Bit32AnPrefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1761 (dnop Bit32AnUnprefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1763 (dnop A0 "a0" (all-isas) h-a0 f-nil)
1764 (dnop A1 "a1" (all-isas) h-a1 f-nil)
1766 (dnop sb "SB register" (all-isas SEM-ONLY) h-sb f-nil)
1767 (dnop fb "FB register" (all-isas SEM-ONLY) h-fb f-nil)
1768 (dnop sp "SP register" (all-isas SEM-ONLY) h-sp f-nil)
1770 (define-full-operand SrcDst16-r0l-r0h-S-normal "r0l/r0h pair" (MACH16 m16c-isa)
1772 ((parse "r0l_r0h") (print "r0l_r0h")) () ()
1775 (define-full-operand Regsetpop "popm regset" (all-isas) h-uint
1776 DFLT f-8-8 ((parse "pop_regset") (print "pop_regset")) () ())
1777 (define-full-operand Regsetpush "pushm regset" (all-isas) h-uint
1778 DFLT f-8-8 ((parse "push_regset") (print "push_regset")) () ())
1780 (dnop Rn16-push-S "r0[lh]" (MACH16 m16c-isa) h-gr-QI f-4-1)
1781 (dnop An16-push-S "a[01]" (MACH16 m16c-isa) h-ar-HI f-4-1)
1783 ;-------------------------------------------------------------
1784 ; Offsets and absolutes
1785 ;-------------------------------------------------------------
1787 (define-full-operand Dsp-8-u6 "unsigned 6 bit displacement at offset 8 bits" (all-isas)
1788 h-uint DFLT f-dsp-8-u6
1789 ((parse "unsigned6")) () ()
1791 (define-full-operand Dsp-8-u8 "unsigned 8 bit displacement at offset 8 bits" (all-isas)
1792 h-uint DFLT f-dsp-8-u8
1793 ((parse "unsigned8")) () ()
1795 (define-full-operand Dsp-8-u16 "unsigned 16 bit displacement at offset 8 bits" (all-isas)
1796 h-uint DFLT f-dsp-8-u16
1797 ((parse "unsigned16")) () ()
1799 (define-full-operand Dsp-8-s8 "signed 8 bit displacement at offset 8 bits" (all-isas)
1800 h-sint DFLT f-dsp-8-s8
1801 ((parse "signed8")) () ()
1803 (define-full-operand Dsp-8-s24 "signed 24 bit displacement at offset 8 bits" (all-isas)
1804 h-sint DFLT f-dsp-8-s24
1805 ((parse "signed24")) () ()
1807 (define-full-operand Dsp-8-u24 "unsigned 24 bit displacement at offset 8 bits" (all-isas)
1808 h-uint DFLT f-dsp-8-u24
1809 ((parse "unsigned24")) () ()
1811 (define-full-operand Dsp-10-u6 "unsigned 6 bit displacement at offset 10 bits" (all-isas)
1812 h-uint DFLT f-dsp-10-u6
1813 ((parse "unsigned6")) () ()
1815 (define-full-operand Dsp-16-u8 "unsigned 8 bit displacement at offset 16 bits" (all-isas)
1816 h-uint DFLT f-dsp-16-u8
1817 ((parse "unsigned8")) () ()
1819 (define-full-operand Dsp-16-u16 "unsigned 16 bit displacement at offset 16 bits" (all-isas)
1820 h-uint DFLT f-dsp-16-u16
1821 ((parse "unsigned16")) () ()
1823 (define-full-operand Dsp-16-u20 "unsigned 20 bit displacement at offset 16 bits" (all-isas)
1824 h-uint DFLT f-dsp-16-u24
1825 ((parse "unsigned20")) () ()
1827 (define-full-operand Dsp-16-u24 "unsigned 24 bit displacement at offset 16 bits" (all-isas)
1828 h-uint DFLT f-dsp-16-u24
1829 ((parse "unsigned24")) () ()
1831 (define-full-operand Dsp-16-s8 "signed 8 bit displacement at offset 16 bits" (all-isas)
1832 h-sint DFLT f-dsp-16-s8
1833 ((parse "signed8")) () ()
1835 (define-full-operand Dsp-16-s16 "signed 16 bit displacement at offset 16 bits" (all-isas)
1836 h-sint DFLT f-dsp-16-s16
1837 ((parse "signed16")) () ()
1839 (define-full-operand Dsp-24-u8 "unsigned 8 bit displacement at offset 24 bits" (all-isas)
1840 h-uint DFLT f-dsp-24-u8
1841 ((parse "unsigned8")) () ()
1843 (define-full-operand Dsp-24-u16 "unsigned 16 bit displacement at offset 24 bits" (all-isas)
1844 h-uint DFLT f-dsp-24-u16
1845 ((parse "unsigned16")) () ()
1847 (define-full-operand Dsp-24-u20 "unsigned 20 bit displacement at offset 24 bits" (all-isas)
1848 h-uint DFLT f-dsp-24-u24
1849 ((parse "unsigned20")) () ()
1851 (define-full-operand Dsp-24-u24 "unsigned 24 bit displacement at offset 24 bits" (all-isas)
1852 h-uint DFLT f-dsp-24-u24
1853 ((parse "unsigned24")) () ()
1855 (define-full-operand Dsp-24-s8 "signed 8 bit displacement at offset 24 bits" (all-isas)
1856 h-sint DFLT f-dsp-24-s8
1857 ((parse "signed8")) () ()
1859 (define-full-operand Dsp-24-s16 "signed 16 bit displacement at offset 24 bits" (all-isas)
1860 h-sint DFLT f-dsp-24-s16
1861 ((parse "signed16")) () ()
1863 (define-full-operand Dsp-32-u8 "unsigned 8 bit displacement at offset 32 bits" (all-isas)
1864 h-uint DFLT f-dsp-32-u8
1865 ((parse "unsigned8")) () ()
1867 (define-full-operand Dsp-32-u16 "unsigned 16 bit displacement at offset 32 bits" (all-isas)
1868 h-uint DFLT f-dsp-32-u16
1869 ((parse "unsigned16")) () ()
1871 (define-full-operand Dsp-32-u24 "unsigned 24 bit displacement at offset 32 bits" (all-isas)
1872 h-uint DFLT f-dsp-32-u24
1873 ((parse "unsigned24")) () ()
1875 (define-full-operand Dsp-32-u20 "unsigned 20 bit displacement at offset 32 bits" (all-isas)
1876 h-uint DFLT f-dsp-32-u24
1877 ((parse "unsigned20")) () ()
1879 (define-full-operand Dsp-32-s8 "signed 8 bit displacement at offset 32 bits" (all-isas)
1880 h-sint DFLT f-dsp-32-s8
1881 ((parse "signed8")) () ()
1883 (define-full-operand Dsp-32-s16 "signed 16 bit displacement at offset 32 bits" (all-isas)
1884 h-sint DFLT f-dsp-32-s16
1885 ((parse "signed16")) () ()
1887 (define-full-operand Dsp-40-u8 "unsigned 8 bit displacement at offset 40 bits" (all-isas)
1888 h-uint DFLT f-dsp-40-u8
1889 ((parse "unsigned8")) () ()
1891 (define-full-operand Dsp-40-s8 "signed 8 bit displacement at offset 40 bits" (all-isas)
1892 h-sint DFLT f-dsp-40-s8
1893 ((parse "signed8")) () ()
1895 (define-full-operand Dsp-40-u16 "unsigned 16 bit displacement at offset 40 bits" (all-isas)
1896 h-uint DFLT f-dsp-40-u16
1897 ((parse "unsigned16")) () ()
1899 (define-full-operand Dsp-40-s16 "signed 16 bit displacement at offset 40 bits" (all-isas)
1900 h-sint DFLT f-dsp-40-s16
1901 ((parse "signed16")) () ()
1903 (define-full-operand Dsp-40-u20 "unsigned 20 bit displacement at offset 40 bits" (all-isas)
1904 h-uint DFLT f-dsp-40-u20
1905 ((parse "unsigned20")) () ()
1907 (define-full-operand Dsp-40-u24 "unsigned 24 bit displacement at offset 40 bits" (all-isas)
1908 h-uint DFLT f-dsp-40-u24
1909 ((parse "unsigned24")) () ()
1911 (define-full-operand Dsp-48-u8 "unsigned 8 bit displacement at offset 48 bits" (all-isas)
1912 h-uint DFLT f-dsp-48-u8
1913 ((parse "unsigned8")) () ()
1915 (define-full-operand Dsp-48-s8 "signed 8 bit displacement at offset 48 bits" (all-isas)
1916 h-sint DFLT f-dsp-48-s8
1917 ((parse "signed8")) () ()
1919 (define-full-operand Dsp-48-u16 "unsigned 16 bit displacement at offset 48 bits" (all-isas)
1920 h-uint DFLT f-dsp-48-u16
1921 ((parse "unsigned16")) () ()
1923 (define-full-operand Dsp-48-s16 "signed 16 bit displacement at offset 48 bits" (all-isas)
1924 h-sint DFLT f-dsp-48-s16
1925 ((parse "signed16")) () ()
1927 (define-full-operand Dsp-48-u20 "unsigned 24 bit displacement at offset 40 bits" (all-isas)
1928 h-uint DFLT f-dsp-48-u20
1929 ((parse "unsigned24")) () ()
1931 (define-full-operand Dsp-48-u24 "unsigned 24 bit displacement at offset 48 bits" (all-isas)
1932 h-uint DFLT f-dsp-48-u24
1933 ((parse "unsigned24")) () ()
1936 (define-full-operand Imm-8-s4 "signed 4 bit immediate at offset 8 bits" (all-isas)
1937 h-sint DFLT f-imm-8-s4
1938 ((parse "signed4")) () ()
1940 (define-full-operand Imm-8-s4n "negated 4 bit immediate at offset 8 bits" (all-isas)
1941 h-sint DFLT f-imm-8-s4
1942 ((parse "signed4n")) () ()
1944 (define-full-operand Imm-sh-8-s4 "signed 4 bit shift immediate at offset 8 bits" (all-isas)
1945 h-shimm DFLT f-imm-8-s4
1948 (define-full-operand Imm-8-QI "signed 8 bit immediate at offset 8 bits" (all-isas)
1949 h-sint DFLT f-dsp-8-s8
1950 ((parse "signed8")) () ()
1952 (define-full-operand Imm-8-HI "signed 16 bit immediate at offset 8 bits" (all-isas)
1953 h-sint DFLT f-dsp-8-s16
1954 ((parse "signed16")) () ()
1956 (define-full-operand Imm-12-s4 "signed 4 bit immediate at offset 12 bits" (all-isas)
1957 h-sint DFLT f-imm-12-s4
1958 ((parse "signed4")) () ()
1960 (define-full-operand Imm-12-s4n "negated 4 bit immediate at offset 12 bits" (all-isas)
1961 h-sint DFLT f-imm-12-s4
1962 ((parse "signed4n") (print "signed4n")) () ()
1964 (define-full-operand Imm-sh-12-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas)
1965 h-shimm DFLT f-imm-12-s4
1968 (define-full-operand Imm-13-u3 "signed 3 bit immediate at offset 13 bits" (all-isas)
1969 h-sint DFLT f-imm-13-u3
1970 ((parse "signed4")) () ()
1972 (define-full-operand Imm-20-s4 "signed 4 bit immediate at offset 20 bits" (all-isas)
1973 h-sint DFLT f-imm-20-s4
1974 ((parse "signed4")) () ()
1976 (define-full-operand Imm-sh-20-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas)
1977 h-shimm DFLT f-imm-20-s4
1980 (define-full-operand Imm-16-QI "signed 8 bit immediate at offset 16 bits" (all-isas)
1981 h-sint DFLT f-dsp-16-s8
1982 ((parse "signed8")) () ()
1984 (define-full-operand Imm-16-HI "signed 16 bit immediate at offset 16 bits" (all-isas)
1985 h-sint DFLT f-dsp-16-s16
1986 ((parse "signed16")) () ()
1988 (define-full-operand Imm-16-SI "signed 32 bit immediate at offset 16 bits" (all-isas)
1989 h-sint DFLT f-dsp-16-s32
1990 ((parse "signed32")) () ()
1992 (define-full-operand Imm-24-QI "signed 8 bit immediate at offset 24 bits" (all-isas)
1993 h-sint DFLT f-dsp-24-s8
1994 ((parse "signed8")) () ()
1996 (define-full-operand Imm-24-HI "signed 16 bit immediate at offset 24 bits" (all-isas)
1997 h-sint DFLT f-dsp-24-s16
1998 ((parse "signed16")) () ()
2000 (define-full-operand Imm-24-SI "signed 32 bit immediate at offset 24 bits" (all-isas)
2001 h-sint DFLT f-dsp-24-s32
2002 ((parse "signed32")) () ()
2004 (define-full-operand Imm-32-QI "signed 8 bit immediate at offset 32 bits" (all-isas)
2005 h-sint DFLT f-dsp-32-s8
2006 ((parse "signed8")) () ()
2008 (define-full-operand Imm-32-SI "signed 32 bit immediate at offset 32 bits" (all-isas)
2009 h-sint DFLT f-dsp-32-s32
2010 ((parse "signed32")) () ()
2012 (define-full-operand Imm-32-HI "signed 16 bit immediate at offset 32 bits" (all-isas)
2013 h-sint DFLT f-dsp-32-s16
2014 ((parse "signed16")) () ()
2016 (define-full-operand Imm-40-QI "signed 8 bit immediate at offset 40 bits" (all-isas)
2017 h-sint DFLT f-dsp-40-s8
2018 ((parse "signed8")) () ()
2020 (define-full-operand Imm-40-HI "signed 16 bit immediate at offset 40 bits" (all-isas)
2021 h-sint DFLT f-dsp-40-s16
2022 ((parse "signed16")) () ()
2024 (define-full-operand Imm-40-SI "signed 32 bit immediate at offset 40 bits" (all-isas)
2025 h-sint DFLT f-dsp-40-s32
2026 ((parse "signed32")) () ()
2028 (define-full-operand Imm-48-QI "signed 8 bit immediate at offset 48 bits" (all-isas)
2029 h-sint DFLT f-dsp-48-s8
2030 ((parse "signed8")) () ()
2032 (define-full-operand Imm-48-HI "signed 16 bit immediate at offset 48 bits" (all-isas)
2033 h-sint DFLT f-dsp-48-s16
2034 ((parse "signed16")) () ()
2036 (define-full-operand Imm-48-SI "signed 32 bit immediate at offset 48 bits" (all-isas)
2037 h-sint DFLT f-dsp-48-s32
2038 ((parse "signed32")) () ()
2040 (define-full-operand Imm-56-QI "signed 8 bit immediate at offset 56 bits" (all-isas)
2041 h-sint DFLT f-dsp-56-s8
2042 ((parse "signed8")) () ()
2044 (define-full-operand Imm-56-HI "signed 16 bit immediate at offset 56 bits" (all-isas)
2045 h-sint DFLT f-dsp-56-s16
2046 ((parse "signed16")) () ()
2048 (define-full-operand Imm-64-HI "signed 16 bit immediate at offset 64 bits" (all-isas)
2049 h-sint DFLT f-dsp-64-s16
2050 ((parse "signed16")) () ()
2052 (define-full-operand Imm1-S "signed 1 bit immediate for short format binary insns" (m32c-isa)
2053 h-sint DFLT f-imm1-S
2054 ((parse "imm1_S")) () ()
2056 (define-full-operand Imm3-S "signed 3 bit immediate for short format binary insns" (m32c-isa)
2057 h-sint DFLT f-imm3-S
2058 ((parse "imm3_S")) () ()
2060 (define-full-operand Bit3-S "3 bit bit number" (m32c-isa)
2061 h-sint DFLT f-imm3-S
2062 ((parse "bit3_S")) () ()
2065 ;-------------------------------------------------------------
2067 ;-------------------------------------------------------------
2069 (define-full-operand Bitno16R "bit number for indexing registers" (m16c-isa)
2070 h-uint DFLT f-dsp-16-u8
2071 ((parse "Bitno16R")) () ()
2073 (dnop Bitno32Prefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-prefixed)
2074 (dnop Bitno32Unprefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-unprefixed)
2076 (define-full-operand BitBase16-16-u8 "unsigned bit,base:8 at offset 16for m16c" (m16c-isa)
2077 h-uint DFLT f-dsp-16-u8
2078 ((parse "unsigned_bitbase8") (print "unsigned_bitbase")) () ()
2080 (define-full-operand BitBase16-16-s8 "signed bit,base:8 at offset 16for m16c" (m16c-isa)
2081 h-sint DFLT f-dsp-16-s8
2082 ((parse "signed_bitbase8") (print "signed_bitbase")) () ()
2084 (define-full-operand BitBase16-16-u16 "unsigned bit,base:16 at offset 16 for m16c" (m16c-isa)
2085 h-uint DFLT f-dsp-16-u16
2086 ((parse "unsigned_bitbase16") (print "unsigned_bitbase")) () ()
2088 (define-full-operand BitBase16-8-u11-S "signed bit,base:11 at offset 16 for m16c" (m16c-isa)
2089 h-uint DFLT f-bitbase16-u11-S
2090 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2093 (define-full-operand BitBase32-16-u11-Unprefixed "unsigned bit,base:11 at offset 16 for m32c" (m32c-isa)
2094 h-uint DFLT f-bitbase32-16-u11-unprefixed
2095 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2097 (define-full-operand BitBase32-16-s11-Unprefixed "signed bit,base:11 at offset 16 for m32c" (m32c-isa)
2098 h-sint DFLT f-bitbase32-16-s11-unprefixed
2099 ((parse "signed_bitbase11") (print "signed_bitbase")) () ()
2101 (define-full-operand BitBase32-16-u19-Unprefixed "unsigned bit,base:19 at offset 16 for m32c" (m32c-isa)
2102 h-uint DFLT f-bitbase32-16-u19-unprefixed
2103 ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () ()
2105 (define-full-operand BitBase32-16-s19-Unprefixed "signed bit,base:19 at offset 16 for m32c" (m32c-isa)
2106 h-sint DFLT f-bitbase32-16-s19-unprefixed
2107 ((parse "signed_bitbase19") (print "signed_bitbase")) () ()
2109 (define-full-operand BitBase32-16-u27-Unprefixed "unsigned bit,base:27 at offset 16 for m32c" (m32c-isa)
2110 h-uint DFLT f-bitbase32-16-u27-unprefixed
2111 ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () ()
2113 (define-full-operand BitBase32-24-u11-Prefixed "unsigned bit,base:11 at offset 24 for m32c" (m32c-isa)
2114 h-uint DFLT f-bitbase32-24-u11-prefixed
2115 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2117 (define-full-operand BitBase32-24-s11-Prefixed "signed bit,base:11 at offset 24 for m32c" (m32c-isa)
2118 h-sint DFLT f-bitbase32-24-s11-prefixed
2119 ((parse "signed_bitbase11") (print "signed_bitbase")) () ()
2121 (define-full-operand BitBase32-24-u19-Prefixed "unsigned bit,base:19 at offset 24 for m32c" (m32c-isa)
2122 h-uint DFLT f-bitbase32-24-u19-prefixed
2123 ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () ()
2125 (define-full-operand BitBase32-24-s19-Prefixed "signed bit,base:19 at offset 24 for m32c" (m32c-isa)
2126 h-sint DFLT f-bitbase32-24-s19-prefixed
2127 ((parse "signed_bitbase19") (print "signed_bitbase")) () ()
2129 (define-full-operand BitBase32-24-u27-Prefixed "unsigned bit,base:27 at offset 24 for m32c" (m32c-isa)
2130 h-uint DFLT f-bitbase32-24-u27-prefixed
2131 ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () ()
2133 ;-------------------------------------------------------------
2135 ;-------------------------------------------------------------
2137 (define-full-operand Lab-5-3 "3 bit label" (all-isas RELAX)
2138 h-iaddr DFLT f-lab-5-3
2139 ((parse "lab_5_3")) () () )
2141 (define-full-operand Lab32-jmp-s "3 bit label" (all-isas RELAX)
2142 h-iaddr DFLT f-lab32-jmp-s
2143 ((parse "lab_5_3")) () () )
2145 (dnop Lab-8-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-8-8)
2146 (dnop Lab-8-16 "16 bit label" (all-isas RELAX) h-iaddr f-lab-8-16)
2147 (dnop Lab-8-24 "24 bit label" (all-isas RELAX) h-iaddr f-lab-8-24)
2148 (dnop Lab-16-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-16-8)
2149 (dnop Lab-24-8 "8 bit label" (all-isas) h-iaddr f-lab-24-8)
2150 (dnop Lab-32-8 "8 bit label" (all-isas) h-iaddr f-lab-32-8)
2151 (dnop Lab-40-8 "8 bit label" (all-isas) h-iaddr f-lab-40-8)
2153 ;-------------------------------------------------------------
2154 ; Condition code bits
2155 ;-------------------------------------------------------------
2157 (dnop sbit "negative bit" (SEM-ONLY all-isas) h-sbit f-nil)
2158 (dnop obit "overflow bit" (SEM-ONLY all-isas) h-obit f-nil)
2159 (dnop zbit "zero bit" (SEM-ONLY all-isas) h-zbit f-nil)
2160 (dnop cbit "carry bit" (SEM-ONLY all-isas) h-cbit f-nil)
2161 (dnop ubit "stack ptr select bit" (SEM-ONLY all-isas) h-ubit f-nil)
2162 (dnop ibit "interrupt enable bit" (SEM-ONLY all-isas) h-ibit f-nil)
2163 (dnop bbit "reg bank select bit" (SEM-ONLY all-isas) h-bbit f-nil)
2164 (dnop dbit "debug bit" (SEM-ONLY all-isas) h-dbit f-nil)
2166 ;-------------------------------------------------------------
2167 ; Condition operands
2168 ;-------------------------------------------------------------
2170 (define-pmacro (cond-operand mach offset)
2171 (dnop (.sym cond mach - offset) "condition" ((.sym m mach c-isa)) (.sym h-cond mach) (.sym f-dsp- offset -u8))
2174 (cond-operand 16 16)
2175 (cond-operand 16 24)
2176 (cond-operand 16 32)
2177 (cond-operand 32 16)
2178 (cond-operand 32 24)
2179 (cond-operand 32 32)
2180 (cond-operand 32 40)
2182 (dnop cond16c "condition" (m16c-isa) h-cond16c f-cond16)
2183 (dnop cond16j "condition" (m16c-isa) h-cond16j f-cond16)
2184 (dnop cond16j5 "condition" (m16c-isa) h-cond16j-5 f-cond16j-5)
2185 (dnop cond32 "condition" (m32c-isa) h-cond32 f-cond32)
2186 (dnop cond32j "condition" (m32c-isa) h-cond32 f-cond32j)
2187 (dnop sccond32 "scCND condition" (m32c-isa) h-cond32 f-cond16)
2188 (dnop flags16 "flags" (m16c-isa) h-flags f-9-3)
2189 (dnop flags32 "flags" (m32c-isa) h-flags f-13-3)
2190 (dnop cr16 "control" (m16c-isa) h-cr-16 f-9-3)
2191 (dnop cr1-Unprefixed-32 "control" (m32c-isa) h-cr1-32 f-13-3)
2192 (dnop cr1-Prefixed-32 "control" (m32c-isa) h-cr1-32 f-21-3)
2193 (dnop cr2-32 "control" (m32c-isa) h-cr2-32 f-13-3)
2194 (dnop cr3-Unprefixed-32 "control" (m32c-isa) h-cr3-32 f-13-3)
2195 (dnop cr3-Prefixed-32 "control" (m32c-isa) h-cr3-32 f-21-3)
2197 ;-------------------------------------------------------------
2199 ;-------------------------------------------------------------
2201 (define-full-operand Z "Suffix for zero format insns" (all-isas)
2203 ((parse "Z") (print "Z")) () ()
2205 (define-full-operand S "Suffix for short format insns" (all-isas)
2207 ((parse "S") (print "S")) () ()
2209 (define-full-operand Q "Suffix for quick format insns" (all-isas)
2211 ((parse "Q") (print "Q")) () ()
2213 (define-full-operand G "Suffix for general format insns" (all-isas)
2215 ((parse "G") (print "G")) () ()
2217 (define-full-operand X "Empty suffix" (all-isas)
2219 ((parse "X") (print "X")) () ()
2221 (define-full-operand size "any size specifier" (all-isas)
2223 ((parse "size") (print "size")) () ()
2225 ;-------------------------------------------------------------
2227 ;-------------------------------------------------------------
2229 (dnop BitIndex "Bit Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-bit-index f-nil)
2230 (dnop SrcIndex "Source Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-src-index f-nil)
2231 (dnop DstIndex "Destination Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-dst-index f-nil)
2232 (dnop NoRemainder "Place holder for when the remainder is not kept" (SEM-ONLY MACH32 m32c-isa) h-none f-nil)
2234 ;=============================================================
2237 ; Memory reference macros that clip addresses appropriately. Refer to
2238 ; memory at ADDRESS in MODE, clipped appropriately for either the m16c
2240 (define-pmacro (mem16 mode address)
2241 (mem mode (and #xffff address)))
2243 (define-pmacro (mem20 mode address)
2244 (mem mode (and #xfffff address)))
2246 (define-pmacro (mem32 mode address)
2247 (mem mode (and #xffffff address)))
2249 ; Like mem16 and mem32, but takes MACH as a parameter. MACH must be
2251 (define-pmacro (mem-mach mach mode address)
2252 ((.sym mem mach) mode address))
2254 ;-------------------------------------------------------------
2256 ;-------------------------------------------------------------
2258 ;-------------------------------------------------------------
2260 (define-pmacro (src16-Rn-direct-operand xmode)
2262 (define-derived-operand
2263 (name (.sym src16-Rn-direct- xmode))
2264 (comment (.str "m16c Rn direct source " xmode))
2265 (attrs (machine 16))
2267 (args ((.sym Src16Rn xmode)))
2268 (syntax (.str "$Src16Rn" xmode))
2270 (encoding (+ (f-8-2 0) (.sym Src16Rn xmode)))
2271 (ifield-assertion (eq f-8-2 0))
2272 (getter (trunc xmode (.sym Src16Rn xmode)))
2273 (setter (set (.sym Src16Rn xmode) newval))
2277 (src16-Rn-direct-operand QI)
2278 (src16-Rn-direct-operand HI)
2280 (define-pmacro (src32-Rn-direct-operand group base xmode)
2282 (define-derived-operand
2283 (name (.sym src32-Rn-direct- group - xmode))
2284 (comment (.str "m32c Rn direct source " xmode))
2285 (attrs (machine 32))
2287 (args ((.sym Src32Rn group xmode)))
2288 (syntax (.str "$Src32Rn" group xmode))
2289 (base-ifield (.sym f- base -11))
2290 (encoding (+ ((.sym f- base -3) 4) (.sym Src32Rn group xmode)))
2291 (ifield-assertion (eq (.sym f- base -3) 4))
2292 (getter (trunc xmode (.sym Src32Rn group xmode)))
2293 (setter (set (.sym Src32Rn group xmode) newval))
2298 (src32-Rn-direct-operand Unprefixed 1 QI)
2299 (src32-Rn-direct-operand Prefixed 9 QI)
2300 (src32-Rn-direct-operand Unprefixed 1 HI)
2301 (src32-Rn-direct-operand Prefixed 9 HI)
2302 (src32-Rn-direct-operand Unprefixed 1 SI)
2303 (src32-Rn-direct-operand Prefixed 9 SI)
2305 ;-------------------------------------------------------------
2307 ;-------------------------------------------------------------
2309 (define-pmacro (src16-An-direct-operand xmode)
2311 (define-derived-operand
2312 (name (.sym src16-An-direct- xmode))
2313 (comment (.str "m16c An direct destination " xmode))
2314 (attrs (machine 16))
2316 (args ((.sym Src16An xmode)))
2317 (syntax (.str "$Src16An" xmode))
2319 (encoding (+ (f-8-2 1) (f-10-1 0) (.sym Src16An xmode)))
2320 (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 0)))
2321 (getter (trunc xmode (.sym Src16An xmode)))
2322 (setter (set (.sym Src16An xmode) newval))
2326 (src16-An-direct-operand QI)
2327 (src16-An-direct-operand HI)
2329 (define-pmacro (src32-An-direct-operand group base1 base2 xmode)
2331 (define-derived-operand
2332 (name (.sym src32-An-direct- group - xmode))
2333 (comment (.str "m32c An direct destination " xmode))
2334 (attrs (machine 32))
2336 (args ((.sym Src32An group xmode)))
2337 (syntax (.str "$Src32An" group xmode))
2338 (base-ifield (.sym f- base1 -11))
2339 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Src32An group xmode)))
2340 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
2341 (getter (trunc xmode (.sym Src32An group xmode)))
2342 (setter (set (.sym Src32An group xmode) newval))
2347 (src32-An-direct-operand Unprefixed 1 10 QI)
2348 (src32-An-direct-operand Unprefixed 1 10 HI)
2349 (src32-An-direct-operand Unprefixed 1 10 SI)
2350 (src32-An-direct-operand Prefixed 9 18 QI)
2351 (src32-An-direct-operand Prefixed 9 18 HI)
2352 (src32-An-direct-operand Prefixed 9 18 SI)
2354 ;-------------------------------------------------------------
2356 ;-------------------------------------------------------------
2358 (define-pmacro (src16-An-indirect-operand xmode)
2360 (define-derived-operand
2361 (name (.sym src16-An-indirect- xmode))
2362 (comment (.str "m16c An indirect destination " xmode))
2363 (attrs (machine 16))
2366 (syntax "[$Src16An]")
2368 (encoding (+ (f-8-2 1) (f-10-1 1) Src16An))
2369 (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 1)))
2370 (getter (mem16 xmode Src16An))
2371 (setter (set (mem16 xmode Src16An) newval))
2375 (src16-An-indirect-operand QI)
2376 (src16-An-indirect-operand HI)
2378 (define-pmacro (src32-An-indirect-operand group base1 base2 xmode)
2380 (define-derived-operand
2381 (name (.sym src32-An-indirect- group - xmode))
2382 (comment (.str "m32c An indirect destination " xmode))
2383 (attrs (machine 32))
2385 (args ((.sym Src32An group)))
2386 (syntax (.str "[$Src32An" group "]"))
2387 (base-ifield (.sym f- base1 -11))
2388 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Src32An group)))
2389 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
2390 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group)
2392 (setter (c-call DFLT (.str "operand_setter_" xmode) newval
2393 (.sym Src32An group) (const 0)))
2394 ; (getter (mem32 xmode (.sym Src32An group)))
2395 ; (setter (set (mem32 xmode (.sym Src32An group)) newval))
2400 (src32-An-indirect-operand Unprefixed 1 10 QI)
2401 (src32-An-indirect-operand Unprefixed 1 10 HI)
2402 (src32-An-indirect-operand Unprefixed 1 10 SI)
2403 (src32-An-indirect-operand Prefixed 9 18 QI)
2404 (src32-An-indirect-operand Prefixed 9 18 HI)
2405 (src32-An-indirect-operand Prefixed 9 18 SI)
2407 ;-------------------------------------------------------------
2409 ;-------------------------------------------------------------
2411 (define-pmacro (src16-relative-operand xmode)
2413 (define-derived-operand
2414 (name (.sym src16-16-8-SB-relative- xmode))
2415 (comment (.str "m16c dsp:8[sb] relative destination " xmode))
2416 (attrs (machine 16))
2419 (syntax "${Dsp-16-u8}[sb]")
2421 (encoding (+ (f-8-4 #xA) Dsp-16-u8))
2422 (ifield-assertion (eq f-8-4 #xA))
2423 (getter (mem16 xmode (add Dsp-16-u8 (reg h-sb))))
2424 (setter (set (mem16 xmode (add Dsp-16-u8 (reg h-sb))) newval))
2426 (define-derived-operand
2427 (name (.sym src16-16-16-SB-relative- xmode))
2428 (comment (.str "m16c dsp:16[sb] relative destination " xmode))
2429 (attrs (machine 16))
2432 (syntax "${Dsp-16-u16}[sb]")
2434 (encoding (+ (f-8-4 #xE) Dsp-16-u16))
2435 (ifield-assertion (eq f-8-4 #xE))
2436 (getter (mem16 xmode (add Dsp-16-u16 (reg h-sb))))
2437 (setter (set (mem16 xmode (add Dsp-16-u16 (reg h-sb))) newval))
2439 (define-derived-operand
2440 (name (.sym src16-16-8-FB-relative- xmode))
2441 (comment (.str "m16c dsp:8[fb] relative destination " xmode))
2442 (attrs (machine 16))
2445 (syntax "${Dsp-16-s8}[fb]")
2447 (encoding (+ (f-8-4 #xB) Dsp-16-s8))
2448 (ifield-assertion (eq f-8-4 #xB))
2449 (getter (mem16 xmode (add Dsp-16-s8 (reg h-fb))))
2450 (setter (set (mem16 xmode (add Dsp-16-s8 (reg h-fb))) newval))
2452 (define-derived-operand
2453 (name (.sym src16-16-8-An-relative- xmode))
2454 (comment (.str "m16c dsp:8[An] relative destination " xmode))
2455 (attrs (machine 16))
2457 (args (Src16An Dsp-16-u8))
2458 (syntax "${Dsp-16-u8}[$Src16An]")
2460 (encoding (+ (f-8-2 2) (f-10-1 0) Dsp-16-u8 Src16An))
2461 (ifield-assertion (andif (eq f-8-2 2) (eq f-10-1 0)))
2462 (getter (mem16 xmode (add Dsp-16-u8 Src16An)))
2463 (setter (set (mem16 xmode (add Dsp-16-u8 Src16An)) newval))
2465 (define-derived-operand
2466 (name (.sym src16-16-16-An-relative- xmode))
2467 (comment (.str "m16c dsp:16[An] relative destination " xmode))
2468 (attrs (machine 16))
2470 (args (Src16An Dsp-16-u16))
2471 (syntax "${Dsp-16-u16}[$Src16An]")
2473 (encoding (+ (f-8-2 3) (f-10-1 0) Dsp-16-u16 Src16An))
2474 (ifield-assertion (andif (eq f-8-2 3) (eq f-10-1 0)))
2475 (getter (mem16 xmode (add Dsp-16-u16 Src16An)))
2476 (setter (set (mem16 xmode (add Dsp-16-u16 Src16An)) newval))
2478 (define-derived-operand
2479 (name (.sym src16-16-20-An-relative- xmode))
2480 (comment (.str "m16c dsp:20[An] relative destination " xmode))
2481 (attrs (machine 16))
2483 (args (Src16An Dsp-16-u20))
2484 (syntax "${Dsp-16-u20}[$Src16An]")
2486 (encoding (+ (f-8-2 3) (f-10-1 0) Dsp-16-u20 Src16An))
2487 (ifield-assertion (andif (eq f-8-2 3) (eq f-10-1 0)))
2488 (getter (mem20 xmode (add Dsp-16-u20 Src16An)))
2489 (setter (set (mem20 xmode (add Dsp-16-u20 Src16An)) newval))
2494 (src16-relative-operand QI)
2495 (src16-relative-operand HI)
2497 (define-pmacro (src32-relative-operand offset group base1 base2 xmode)
2499 (define-derived-operand
2500 (name (.sym src32- offset -8-SB-relative- group - xmode))
2501 (comment (.str "m32c dsp:8[sb] relative destination " xmode))
2502 (attrs (machine 32))
2504 (args ((.sym Dsp- offset -u8)))
2505 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
2506 (base-ifield (.sym f- base1 -11))
2507 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8)))
2508 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
2509 (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u8)))
2510 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u8)))
2511 ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb))))
2512 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
2514 (define-derived-operand
2515 (name (.sym src32- offset -16-SB-relative- group - xmode))
2516 (comment (.str "m32c dsp:16[sb] relative destination " xmode))
2517 (attrs (machine 32))
2519 (args ((.sym Dsp- offset -u16)))
2520 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
2521 (base-ifield (.sym f- base1 -11))
2522 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16)))
2523 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
2524 (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u16)))
2525 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u16)))
2526 ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb))))
2527 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
2529 (define-derived-operand
2530 (name (.sym src32- offset -8-FB-relative- group - xmode))
2531 (comment (.str "m32c dsp:8[fb] relative destination " xmode))
2532 (attrs (machine 32))
2534 (args ((.sym Dsp- offset -s8)))
2535 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
2536 (base-ifield (.sym f- base1 -11))
2537 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8)))
2538 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
2539 (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s8)))
2540 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s8)))
2541 ; (getter (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb))))
2542 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
2544 (define-derived-operand
2545 (name (.sym src32- offset -16-FB-relative- group - xmode))
2546 (comment (.str "m32c dsp:16[fb] relative destination " xmode))
2547 (attrs (machine 32))
2549 (args ((.sym Dsp- offset -s16)))
2550 (syntax (.str "${Dsp-" offset "-s16}[fb]"))
2551 (base-ifield (.sym f- base1 -11))
2552 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16)))
2553 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
2554 (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s16)))
2555 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s16)))
2556 ; (getter (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb))))
2557 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval))
2559 (define-derived-operand
2560 (name (.sym src32- offset -8-An-relative- group - xmode))
2561 (comment (.str "m32c dsp:8[An] relative destination " xmode))
2562 (attrs (machine 32))
2564 (args ((.sym Src32An group) (.sym Dsp- offset -u8)))
2565 (syntax (.str "${Dsp-" offset "-u8}[$Src32An" group "]"))
2566 (base-ifield (.sym f- base1 -11))
2567 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Src32An group)))
2568 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
2569 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u8)))
2570 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u8)))
2571 ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group))))
2572 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group))) newval))
2574 (define-derived-operand
2575 (name (.sym src32- offset -16-An-relative- group - xmode))
2576 (comment (.str "m32c dsp:16[An] relative destination " xmode))
2577 (attrs (machine 32))
2579 (args ((.sym Src32An group) (.sym Dsp- offset -u16)))
2580 (syntax (.str "${Dsp-" offset "-u16}[$Src32An" group "]"))
2581 (base-ifield (.sym f- base1 -11))
2582 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Src32An group)))
2583 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
2584 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u16)))
2585 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u16)))
2586 ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group))))
2587 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group))) newval))
2589 (define-derived-operand
2590 (name (.sym src32- offset -24-An-relative- group - xmode))
2591 (comment (.str "m32c dsp:16[An] relative destination " xmode))
2592 (attrs (machine 32))
2594 (args ((.sym Src32An group) (.sym Dsp- offset -u24)))
2595 (syntax (.str "${Dsp-" offset "-u24}[$Src32An" group "]"))
2596 (base-ifield (.sym f- base1 -11))
2597 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Src32An group)))
2598 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
2599 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u24) ))
2600 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u24)))
2601 ; (getter (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group))))
2602 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group))) newval))
2607 (src32-relative-operand 16 Unprefixed 1 10 QI)
2608 (src32-relative-operand 16 Unprefixed 1 10 HI)
2609 (src32-relative-operand 16 Unprefixed 1 10 SI)
2610 (src32-relative-operand 24 Prefixed 9 18 QI)
2611 (src32-relative-operand 24 Prefixed 9 18 HI)
2612 (src32-relative-operand 24 Prefixed 9 18 SI)
2614 ;-------------------------------------------------------------
2616 ;-------------------------------------------------------------
2618 (define-pmacro (src16-absolute xmode)
2620 (define-derived-operand
2621 (name (.sym src16-16-16-absolute- xmode))
2622 (comment (.str "m16c absolute address " xmode))
2623 (attrs (machine 16))
2626 (syntax (.str "${Dsp-16-u16}"))
2628 (encoding (+ (f-8-4 #xF) Dsp-16-u16))
2629 (ifield-assertion (eq f-8-4 #xF))
2630 (getter (mem16 xmode Dsp-16-u16))
2631 (setter (set (mem16 xmode Dsp-16-u16) newval))
2639 (define-pmacro (src32-absolute offset group base1 base2 xmode)
2641 (define-derived-operand
2642 (name (.sym src32- offset -16-absolute- group - xmode))
2643 (comment (.str "m32c absolute address " xmode))
2644 (attrs (machine 32))
2646 (args ((.sym Dsp- offset -u16)))
2647 (syntax (.str "${Dsp-" offset "-u16}"))
2648 (base-ifield (.sym f- base1 -11))
2649 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
2650 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
2651 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u16)))
2652 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u16)))
2653 ; (getter (mem32 xmode (.sym Dsp- offset -u16)))
2654 ; (setter (set (mem32 xmode (.sym Dsp- offset -u16)) newval))
2656 (define-derived-operand
2657 (name (.sym src32- offset -24-absolute- group - xmode))
2658 (comment (.str "m32c absolute address " xmode))
2659 (attrs (machine 32))
2661 (args ((.sym Dsp- offset -u24)))
2662 (syntax (.str "${Dsp-" offset "-u24}"))
2663 (base-ifield (.sym f- base1 -11))
2664 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
2665 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
2666 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u24)))
2667 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u24)))
2668 ; (getter (mem32 xmode (.sym Dsp- offset -u24)))
2669 ; (setter (set (mem32 xmode (.sym Dsp- offset -u24)) newval))
2674 (src32-absolute 16 Unprefixed 1 10 QI)
2675 (src32-absolute 16 Unprefixed 1 10 HI)
2676 (src32-absolute 16 Unprefixed 1 10 SI)
2677 (src32-absolute 24 Prefixed 9 18 QI)
2678 (src32-absolute 24 Prefixed 9 18 HI)
2679 (src32-absolute 24 Prefixed 9 18 SI)
2681 ;-------------------------------------------------------------
2682 ; An indirect indirect
2684 ; Double indirect addressing uses the lower 3 bytes of the value stored
2685 ; at the address referenced by 'op' as the effective address.
2686 ;-------------------------------------------------------------
2688 (define-pmacro (indirect-addr op) (and USI (mem32 USI op) #x00ffffff))
2690 ; (define-pmacro (src-An-indirect-indirect-operand xmode)
2691 ; (define-derived-operand
2692 ; (name (.sym src32-An-indirect-indirect- xmode))
2693 ; (comment (.str "m32c An indirect indirect destination " xmode))
2694 ; (attrs (machine 32))
2696 ; (args (Src32AnPrefixed))
2697 ; (syntax (.str "[[$Src32AnPrefixed]]"))
2698 ; (base-ifield f-9-11)
2699 ; (encoding (+ (f-9-3 0) (f-18-1 0) Src32AnPrefixed))
2700 ; (ifield-assertion (andif (eq f-9-3 0) (eq f-18-1 0)))
2701 ; (getter (mem32 xmode (indirect-addr Src32AnPrefixed)))
2702 ; (setter (set (mem32 xmode (indirect-addr Src32AnPrefixed)) newval))
2706 ; (src-An-indirect-indirect-operand QI)
2707 ; (src-An-indirect-indirect-operand HI)
2708 ; (src-An-indirect-indirect-operand SI)
2710 ;-------------------------------------------------------------
2712 ;-------------------------------------------------------------
2714 (define-pmacro (src-relative-indirect-operand xmode)
2716 ; (define-derived-operand
2717 ; (name (.sym src32-24-8-SB-relative-indirect- xmode))
2718 ; (comment (.str "m32c dsp:8[sb] relative source " xmode))
2719 ; (attrs (machine 32))
2721 ; (args (Dsp-24-u8))
2722 ; (syntax "[${Dsp-24-u8}[sb]]")
2723 ; (base-ifield f-9-11)
2724 ; (encoding (+ (f-9-3 1) (f-18-2 2) Dsp-24-u8))
2725 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 2)))
2726 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb)))))
2727 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb)))) newval))
2729 ; (define-derived-operand
2730 ; (name (.sym src32-24-16-SB-relative-indirect- xmode))
2731 ; (comment (.str "m32c dsp:16[sb] relative source " xmode))
2732 ; (attrs (machine 32))
2734 ; (args (Dsp-24-u16))
2735 ; (syntax "[${Dsp-24-u16}[sb]]")
2736 ; (base-ifield f-9-11)
2737 ; (encoding (+ (f-9-3 2) (f-18-2 2) Dsp-24-u16))
2738 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 2)))
2739 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb)))))
2740 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb)))) newval))
2742 ; (define-derived-operand
2743 ; (name (.sym src32-24-8-FB-relative-indirect- xmode))
2744 ; (comment (.str "m32c dsp:8[fb] relative source " xmode))
2745 ; (attrs (machine 32))
2747 ; (args (Dsp-24-s8))
2748 ; (syntax "[${Dsp-24-s8}[fb]]")
2749 ; (base-ifield f-9-11)
2750 ; (encoding (+ (f-9-3 1) (f-18-2 3) Dsp-24-s8))
2751 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 3)))
2752 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb)))))
2753 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb)))) newval))
2755 ; (define-derived-operand
2756 ; (name (.sym src32-24-16-FB-relative-indirect- xmode))
2757 ; (comment (.str "m32c dsp:16[fb] relative source " xmode))
2758 ; (attrs (machine 32))
2760 ; (args (Dsp-24-s16))
2761 ; (syntax "[${Dsp-24-s16}[fb]]")
2762 ; (base-ifield f-9-11)
2763 ; (encoding (+ (f-9-3 2) (f-18-2 3) Dsp-24-s16))
2764 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 3)))
2765 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb)))))
2766 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb)))) newval))
2768 ; (define-derived-operand
2769 ; (name (.sym src32-24-8-An-relative-indirect- xmode))
2770 ; (comment (.str "m32c dsp:8[An] relative indirect source " xmode))
2771 ; (attrs (machine 32))
2773 ; (args (Src32AnPrefixed Dsp-24-u8))
2774 ; (syntax "[${Dsp-24-u8}[$Src32AnPrefixed]]")
2775 ; (base-ifield f-9-11)
2776 ; (encoding (+ (f-9-3 1) (f-18-1 0) Dsp-24-u8 Src32AnPrefixed))
2777 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-1 0)))
2778 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed))))
2779 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed))) newval))
2781 ; (define-derived-operand
2782 ; (name (.sym src32-24-16-An-relative-indirect- xmode))
2783 ; (comment (.str "m32c dsp:16[An] relative source " xmode))
2784 ; (attrs (machine 32))
2786 ; (args (Src32AnPrefixed Dsp-24-u16))
2787 ; (syntax "[${Dsp-24-u16}[$Src32AnPrefixed]]")
2788 ; (base-ifield f-9-11)
2789 ; (encoding (+ (f-9-3 2) (f-18-1 0) Dsp-24-u16 Src32AnPrefixed))
2790 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-1 0)))
2791 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed))))
2792 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed))) newval))
2794 ; (define-derived-operand
2795 ; (name (.sym src32-24-24-An-relative-indirect- xmode))
2796 ; (comment (.str "m32c dsp:24[An] relative source " xmode))
2797 ; (attrs (machine 32))
2799 ; (args (Src32AnPrefixed Dsp-24-u24))
2800 ; (syntax "[${Dsp-24-u24}[$Src32AnPrefixed]]")
2801 ; (base-ifield f-9-11)
2802 ; (encoding (+ (f-9-3 3) (f-18-1 0) Dsp-24-u24 Src32AnPrefixed))
2803 ; (ifield-assertion (andif (eq f-9-3 3) (eq f-18-1 0)))
2804 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed))))
2805 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed))) newval))
2810 ; (src-relative-indirect-operand QI)
2811 ; (src-relative-indirect-operand HI)
2812 ; (src-relative-indirect-operand SI)
2814 ;-------------------------------------------------------------
2815 ; Absolute Indirect address
2816 ;-------------------------------------------------------------
2818 (define-pmacro (src32-absolute-indirect offset base1 base2 xmode)
2820 ; (define-derived-operand
2821 ; (name (.sym src32- offset -16-absolute-indirect-derived- xmode))
2822 ; (comment (.str "m32c absolute indirect address " xmode))
2823 ; (attrs (machine 32))
2825 ; (args ((.sym Dsp- offset -u16)))
2826 ; (syntax (.str "[${Dsp-" offset "-u16}]"))
2827 ; (base-ifield (.sym f- base1 -11))
2828 ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
2829 ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
2830 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))))
2831 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval))
2833 ; (define-derived-operand
2834 ; (name (.sym src32- offset -24-absolute-indirect-derived- xmode))
2835 ; (comment (.str "m32c absolute indirect address " xmode))
2836 ; (attrs (machine 32))
2838 ; (args ((.sym Dsp- offset -u24)))
2839 ; (syntax (.str "[${Dsp-" offset "-u24}]"))
2840 ; (base-ifield (.sym f- base1 -11))
2841 ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
2842 ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
2843 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))))
2844 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval))
2849 (src32-absolute-indirect 24 9 18 QI)
2850 (src32-absolute-indirect 24 9 18 HI)
2851 (src32-absolute-indirect 24 9 18 SI)
2853 ;-------------------------------------------------------------
2854 ; Register relative source operands for short format insns
2855 ;-------------------------------------------------------------
2857 (define-pmacro (src-2-S-operands mach xmode base opc1 opc2 opc3)
2859 (define-derived-operand
2860 (name (.sym src mach -2-S-8-SB-relative- xmode))
2861 (comment (.str "m" mach "c SB relative address"))
2862 (attrs (machine mach))
2865 (syntax "${Dsp-8-u8}[sb]")
2866 (base-ifield (.sym f- base -2))
2867 (encoding (+ ((.sym f- base -2) opc1) Dsp-8-u8))
2868 (ifield-assertion (eq (.sym f- base -2) opc1))
2869 (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8))
2870 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8))
2871 ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8))))
2872 ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8))) newval))
2874 (define-derived-operand
2875 (name (.sym src mach -2-S-8-FB-relative- xmode))
2876 (comment (.str "m" mach "c FB relative address"))
2877 (attrs (machine mach))
2880 (syntax "${Dsp-8-s8}[fb]")
2881 (base-ifield (.sym f- base -2))
2882 (encoding (+ ((.sym f- base -2) opc2) Dsp-8-s8))
2883 (ifield-assertion (eq (.sym f- base -2) opc2))
2884 (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8))
2885 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8))
2886 ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8))))
2887 ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8))) newval))
2889 (define-derived-operand
2890 (name (.sym src mach -2-S-16-absolute- xmode))
2891 (comment (.str "m" mach "c absolute address"))
2892 (attrs (machine mach))
2895 (syntax "${Dsp-8-u16}")
2896 (base-ifield (.sym f- base -2))
2897 (encoding (+ ((.sym f- base -2) opc3) Dsp-8-u16))
2898 (ifield-assertion (eq (.sym f- base -2) opc3))
2899 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16))
2900 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16))
2901 ; (getter (mem-mach mach xmode Dsp-8-u16))
2902 ; (setter (set (mem-mach mach xmode Dsp-8-u16) newval))
2907 (src-2-S-operands 16 QI 6 1 2 3)
2908 (src-2-S-operands 32 QI 2 2 3 1)
2909 (src-2-S-operands 32 HI 2 2 3 1)
2911 ;=============================================================
2913 ;-------------------------------------------------------------
2915 ;-------------------------------------------------------------
2917 ;-------------------------------------------------------------
2919 (define-pmacro (dst16-Rn-direct-operand xmode)
2921 (define-derived-operand
2922 (name (.sym dst16-Rn-direct- xmode))
2923 (comment (.str "m16c Rn direct destination " xmode))
2924 (attrs (machine 16))
2926 (args ((.sym Dst16Rn xmode)))
2927 (syntax (.str "$Dst16Rn" xmode))
2928 (base-ifield f-12-4)
2929 (encoding (+ (f-12-2 0) (.sym Dst16Rn xmode)))
2930 (ifield-assertion (eq f-12-2 0))
2931 (getter (trunc xmode (.sym Dst16Rn xmode)))
2932 (setter (set (.sym Dst16Rn xmode) newval))
2937 (dst16-Rn-direct-operand QI)
2938 (dst16-Rn-direct-operand HI)
2939 (dst16-Rn-direct-operand SI)
2941 (define-derived-operand
2942 (name dst16-Rn-direct-Ext-QI)
2943 (comment "m16c Rn direct destination QI")
2944 (attrs (machine 16))
2946 (args (Dst16RnExtQI))
2947 (syntax "$Dst16RnExtQI")
2948 (base-ifield f-12-4)
2949 (encoding (+ (f-12-2 0) Dst16RnExtQI (f-15-1 0)))
2950 (ifield-assertion (andif (eq f-12-2 0) (eq f-15-1 0)))
2951 (getter (trunc QI (.sym Dst16RnExtQI)))
2952 (setter (set Dst16RnExtQI newval))
2955 (define-pmacro (dst32-Rn-direct-operand group base xmode)
2957 (define-derived-operand
2958 (name (.sym dst32-Rn-direct- group - xmode))
2959 (comment (.str "m32c Rn direct destination " xmode))
2960 (attrs (machine 32))
2962 (args ((.sym Dst32Rn group xmode)))
2963 (syntax (.str "$Dst32Rn" group xmode))
2964 (base-ifield (.sym f- base -6))
2965 (encoding (+ ((.sym f- base -3) 4) (.sym Dst32Rn group xmode)))
2966 (ifield-assertion (eq (.sym f- base -3) 4))
2967 (getter (trunc xmode (.sym Dst32Rn group xmode)))
2968 (setter (set (.sym Dst32Rn group xmode) newval))
2973 (dst32-Rn-direct-operand Unprefixed 4 QI)
2974 (dst32-Rn-direct-operand Prefixed 12 QI)
2975 (dst32-Rn-direct-operand Unprefixed 4 HI)
2976 (dst32-Rn-direct-operand Prefixed 12 HI)
2977 (dst32-Rn-direct-operand Unprefixed 4 SI)
2978 (dst32-Rn-direct-operand Prefixed 12 SI)
2980 (define-pmacro (dst32-Rn-direct-Ext-operand group base1 base2 smode dmode)
2982 (define-derived-operand
2983 (name (.sym dst32-Rn-direct- group - smode))
2984 (comment (.str "m32c Rn direct destination " smode))
2985 (attrs (machine 32))
2987 (args ((.sym Dst32Rn group smode)))
2988 (syntax (.str "$Dst32Rn" group smode))
2989 (base-ifield (.sym f- base1 -6))
2990 (encoding (+ ((.sym f- base1 -3) 4) ((.sym f- base2 -1) 1) (.sym Dst32Rn group smode)))
2991 (ifield-assertion (andif (eq (.sym f- base1 -3) 4) (eq (.sym f- base2 -1) 1)))
2992 (getter (trunc smode (.sym Dst32Rn group smode)))
2993 (setter (set (.sym Dst32Rn group smode) newval))
2998 (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 QI HI)
2999 (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 HI SI)
3001 (define-derived-operand
3002 (name dst32-R3-direct-Unprefixed-HI)
3003 (comment "m32c R3 direct HI")
3004 (attrs (machine 32))
3009 (encoding (+ (f-4-3 4) (f-8-2 #x1)))
3010 (ifield-assertion (andif (eq f-4-3 4) (eq f-8-2 #x1)))
3011 (getter (trunc HI R3))
3012 (setter (set R3 newval))
3014 ;-------------------------------------------------------------
3016 ;-------------------------------------------------------------
3018 (define-pmacro (dst16-An-direct-operand xmode)
3020 (define-derived-operand
3021 (name (.sym dst16-An-direct- xmode))
3022 (comment (.str "m16c An direct destination " xmode))
3023 (attrs (machine 16))
3025 (args ((.sym Dst16An xmode)))
3026 (syntax (.str "$Dst16An" xmode))
3027 (base-ifield f-12-4)
3028 (encoding (+ (f-12-2 1) (f-14-1 0) (.sym Dst16An xmode)))
3029 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0)))
3030 (getter (trunc xmode (.sym Dst16An xmode)))
3031 (setter (set (.sym Dst16An xmode) newval))
3036 (dst16-An-direct-operand QI)
3037 (dst16-An-direct-operand HI)
3038 (dst16-An-direct-operand SI)
3040 (define-pmacro (dst32-An-direct-operand group base1 base2 xmode)
3042 (define-derived-operand
3043 (name (.sym dst32-An-direct- group - xmode))
3044 (comment (.str "m32c An direct destination " xmode))
3045 (attrs (machine 32))
3047 (args ((.sym Dst32An group xmode)))
3048 (syntax (.str "$Dst32An" group xmode))
3049 (base-ifield (.sym f- base1 -6))
3050 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Dst32An group xmode)))
3051 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
3052 (getter (trunc xmode (.sym Dst32An group xmode)))
3053 (setter (set (.sym Dst32An group xmode) newval))
3058 (dst32-An-direct-operand Unprefixed 4 8 QI)
3059 (dst32-An-direct-operand Prefixed 12 16 QI)
3060 (dst32-An-direct-operand Unprefixed 4 8 HI)
3061 (dst32-An-direct-operand Prefixed 12 16 HI)
3062 (dst32-An-direct-operand Unprefixed 4 8 SI)
3063 (dst32-An-direct-operand Prefixed 12 16 SI)
3065 ;-------------------------------------------------------------
3067 ;-------------------------------------------------------------
3069 (define-pmacro (dst16-An-indirect-operand xmode)
3071 (define-derived-operand
3072 (name (.sym dst16-An-indirect- xmode))
3073 (comment (.str "m16c An indirect destination " xmode))
3074 (attrs (machine 16))
3077 (syntax "[$Dst16An]")
3078 (base-ifield f-12-4)
3079 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
3080 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
3081 (getter (mem16 xmode Dst16An))
3082 (setter (set (mem16 xmode Dst16An) newval))
3087 (dst16-An-indirect-operand QI)
3088 (dst16-An-indirect-operand HI)
3089 (dst16-An-indirect-operand SI)
3091 (define-derived-operand
3092 (name dst16-An-indirect-Ext-QI)
3093 (comment "m16c An indirect destination QI")
3094 (attrs (machine 16))
3097 (syntax "[$Dst16An]")
3098 (base-ifield f-12-4)
3099 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
3100 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
3101 (getter (mem16 QI Dst16An))
3102 (setter (set (mem16 HI Dst16An) newval))
3105 (define-pmacro (dst32-An-indirect-operand group base1 base2 smode dmode)
3107 (define-derived-operand
3108 (name (.sym dst32-An-indirect- group - smode))
3109 (comment (.str "m32c An indirect destination " smode))
3110 (attrs (machine 32))
3112 (args ((.sym Dst32An group)))
3113 (syntax (.str "[$Dst32An" group "]"))
3114 (base-ifield (.sym f- base1 -6))
3115 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Dst32An group)))
3116 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
3117 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group)
3119 (setter (c-call DFLT (.str "operand_setter_" dmode) newval
3120 (.sym Dst32An group) (const 0)))
3121 ; (getter (mem32 smode (.sym Dst32An group)))
3122 ; (setter (set (mem32 dmode (.sym Dst32An group)) newval))
3127 (dst32-An-indirect-operand Unprefixed 4 8 QI QI)
3128 (dst32-An-indirect-operand Prefixed 12 16 QI QI)
3129 (dst32-An-indirect-operand Unprefixed 4 8 HI HI)
3130 (dst32-An-indirect-operand Prefixed 12 16 HI HI)
3131 (dst32-An-indirect-operand Unprefixed 4 8 SI SI)
3132 (dst32-An-indirect-operand Prefixed 12 16 SI SI)
3133 (dst32-An-indirect-operand ExtUnprefixed 4 8 QI HI)
3134 (dst32-An-indirect-operand ExtUnprefixed 4 8 HI SI)
3136 ;-------------------------------------------------------------
3138 ;-------------------------------------------------------------
3140 (define-pmacro (dst16-relative-operand offset xmode)
3142 (define-derived-operand
3143 (name (.sym dst16- offset -8-SB-relative- xmode))
3144 (comment (.str "m16c dsp:8[sb] relative destination " xmode))
3145 (attrs (machine 16))
3147 (args ((.sym Dsp- offset -u8)))
3148 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3149 (base-ifield f-12-4)
3150 (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8)))
3151 (ifield-assertion (eq f-12-4 #xA))
3152 (getter (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb))))
3153 (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3155 (define-derived-operand
3156 (name (.sym dst16- offset -16-SB-relative- xmode))
3157 (comment (.str "m16c dsp:16[sb] relative destination " xmode))
3158 (attrs (machine 16))
3160 (args ((.sym Dsp- offset -u16)))
3161 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3162 (base-ifield f-12-4)
3163 (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16)))
3164 (ifield-assertion (eq f-12-4 #xE))
3165 (getter (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb))))
3166 (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3168 (define-derived-operand
3169 (name (.sym dst16- offset -8-FB-relative- xmode))
3170 (comment (.str "m16c dsp:8[fb] relative destination " xmode))
3171 (attrs (machine 16))
3173 (args ((.sym Dsp- offset -s8)))
3174 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3175 (base-ifield f-12-4)
3176 (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8)))
3177 (ifield-assertion (eq f-12-4 #xB))
3178 (getter (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb))))
3179 (setter (set (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3181 (define-derived-operand
3182 (name (.sym dst16- offset -8-An-relative- xmode))
3183 (comment (.str "m16c dsp:8[An] relative destination " xmode))
3184 (attrs (machine 16))
3186 (args (Dst16An (.sym Dsp- offset -u8)))
3187 (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]"))
3188 (base-ifield f-12-4)
3189 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An))
3190 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3191 (getter (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An)))
3192 (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An)) newval))
3194 (define-derived-operand
3195 (name (.sym dst16- offset -16-An-relative- xmode))
3196 (comment (.str "m16c dsp:16[An] relative destination " xmode))
3197 (attrs (machine 16))
3199 (args (Dst16An (.sym Dsp- offset -u16)))
3200 (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]"))
3201 (base-ifield f-12-4)
3202 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An))
3203 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3204 (getter (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An)))
3205 (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An)) newval))
3207 (define-derived-operand
3208 (name (.sym dst16- offset -20-An-relative- xmode))
3209 (comment (.str "m16c dsp:20[An] relative destination " xmode))
3210 (attrs (machine 16))
3212 (args (Dst16An (.sym Dsp- offset -u20)))
3213 (syntax (.str "${Dsp-" offset "-u20}[$Dst16An]"))
3214 (base-ifield f-12-4)
3215 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u20) Dst16An))
3216 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3217 (getter (mem16 xmode (add (.sym Dsp- offset -u20) Dst16An)))
3218 (setter (set (mem16 xmode (add (.sym Dsp- offset -u20) Dst16An)) newval))
3223 (dst16-relative-operand 16 QI)
3224 (dst16-relative-operand 24 QI)
3225 (dst16-relative-operand 32 QI)
3226 (dst16-relative-operand 40 QI)
3227 (dst16-relative-operand 48 QI)
3228 (dst16-relative-operand 16 HI)
3229 (dst16-relative-operand 24 HI)
3230 (dst16-relative-operand 32 HI)
3231 (dst16-relative-operand 40 HI)
3232 (dst16-relative-operand 48 HI)
3233 (dst16-relative-operand 16 SI)
3234 (dst16-relative-operand 24 SI)
3235 (dst16-relative-operand 32 SI)
3236 (dst16-relative-operand 40 SI)
3237 (dst16-relative-operand 48 SI)
3239 (define-pmacro (dst16-relative-Ext-operand offset smode dmode)
3241 (define-derived-operand
3242 (name (.sym dst16- offset -8-SB-relative-Ext- smode))
3243 (comment (.str "m16c dsp:8[sb] relative destination " smode))
3244 (attrs (machine 16))
3246 (args ((.sym Dsp- offset -u8)))
3247 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3248 (base-ifield f-12-4)
3249 (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8)))
3250 (ifield-assertion (eq f-12-4 #xA))
3251 (getter (mem16 smode (add (.sym Dsp- offset -u8) (reg h-sb))))
3252 (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3254 (define-derived-operand
3255 (name (.sym dst16- offset -16-SB-relative-Ext- smode))
3256 (comment (.str "m16c dsp:16[sb] relative destination " smode))
3257 (attrs (machine 16))
3259 (args ((.sym Dsp- offset -u16)))
3260 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3261 (base-ifield f-12-4)
3262 (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16)))
3263 (ifield-assertion (eq f-12-4 #xE))
3264 (getter (mem16 smode (add (.sym Dsp- offset -u16) (reg h-sb))))
3265 (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3267 (define-derived-operand
3268 (name (.sym dst16- offset -8-FB-relative-Ext- smode))
3269 (comment (.str "m16c dsp:8[fb] relative destination " smode))
3270 (attrs (machine 16))
3272 (args ((.sym Dsp- offset -s8)))
3273 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3274 (base-ifield f-12-4)
3275 (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8)))
3276 (ifield-assertion (eq f-12-4 #xB))
3277 (getter (mem16 smode (add (.sym Dsp- offset -s8) (reg h-fb))))
3278 (setter (set (mem16 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3280 (define-derived-operand
3281 (name (.sym dst16- offset -8-An-relative-Ext- smode))
3282 (comment (.str "m16c dsp:8[An] relative destination " smode))
3283 (attrs (machine 16))
3285 (args (Dst16An (.sym Dsp- offset -u8)))
3286 (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]"))
3287 (base-ifield f-12-4)
3288 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An))
3289 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3290 (getter (mem16 smode (add (.sym Dsp- offset -u8) Dst16An)))
3291 (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) Dst16An)) newval))
3293 (define-derived-operand
3294 (name (.sym dst16- offset -16-An-relative-Ext- smode))
3295 (comment (.str "m16c dsp:16[An] relative destination " smode))
3296 (attrs (machine 16))
3298 (args (Dst16An (.sym Dsp- offset -u16)))
3299 (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]"))
3300 (base-ifield f-12-4)
3301 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An))
3302 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3303 (getter (mem16 smode (add (.sym Dsp- offset -u16) Dst16An)))
3304 (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) Dst16An)) newval))
3309 (dst16-relative-Ext-operand 16 QI HI)
3311 (define-pmacro (dst32-relative-operand offset group base1 base2 smode dmode)
3313 (define-derived-operand
3314 (name (.sym dst32- offset -8-SB-relative- group - smode))
3315 (comment (.str "m32c dsp:8[sb] relative destination " smode))
3316 (attrs (machine 32))
3318 (args ((.sym Dsp- offset -u8)))
3319 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3320 (base-ifield (.sym f- base1 -6))
3321 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8)))
3322 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
3323 (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u8)))
3324 (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u8)))
3325 ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (reg h-sb))))
3326 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3328 (define-derived-operand
3329 (name (.sym dst32- offset -16-SB-relative- group - smode))
3330 (comment (.str "m32c dsp:16[sb] relative destination " smode))
3331 (attrs (machine 32))
3333 (args ((.sym Dsp- offset -u16)))
3334 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3335 (base-ifield (.sym f- base1 -6))
3336 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16)))
3337 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
3338 (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u16)))
3339 (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u16)))
3340 ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (reg h-sb))))
3341 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3343 (define-derived-operand
3344 (name (.sym dst32- offset -8-FB-relative- group - smode))
3345 (comment (.str "m32c dsp:8[fb] relative destination " smode))
3346 (attrs (machine 32))
3348 (args ((.sym Dsp- offset -s8)))
3349 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3350 (base-ifield (.sym f- base1 -6))
3351 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8)))
3352 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
3353 (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s8)))
3354 (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s8)))
3355 ; (getter (mem32 smode (add (.sym Dsp- offset -s8) (reg h-fb))))
3356 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3358 (define-derived-operand
3359 (name (.sym dst32- offset -16-FB-relative- group - smode))
3360 (comment (.str "m32c dsp:16[fb] relative destination " smode))
3361 (attrs (machine 32))
3363 (args ((.sym Dsp- offset -s16)))
3364 (syntax (.str "${Dsp-" offset "-s16}[fb]"))
3365 (base-ifield (.sym f- base1 -6))
3366 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16)))
3367 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
3368 (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s16)))
3369 (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s16)))
3370 ; (getter (mem32 smode (add (.sym Dsp- offset -s16) (reg h-fb))))
3371 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval))
3373 (define-derived-operand
3374 (name (.sym dst32- offset -8-An-relative- group - smode))
3375 (comment (.str "m32c dsp:8[An] relative destination " smode))
3376 (attrs (machine 32))
3378 (args ((.sym Dst32An group) (.sym Dsp- offset -u8)))
3379 (syntax (.str "${Dsp-" offset "-u8}[$Dst32An" group "]"))
3380 (base-ifield (.sym f- base1 -6))
3381 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Dst32An group)))
3382 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
3383 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u8)))
3384 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u8)))
3385 ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (.sym Dst32An group))))
3386 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (.sym Dst32An group))) newval))
3388 (define-derived-operand
3389 (name (.sym dst32- offset -16-An-relative- group - smode))
3390 (comment (.str "m32c dsp:16[An] relative destination " smode))
3391 (attrs (machine 32))
3393 (args ((.sym Dst32An group) (.sym Dsp- offset -u16)))
3394 (syntax (.str "${Dsp-" offset "-u16}[$Dst32An" group "]"))
3395 (base-ifield (.sym f- base1 -6))
3396 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Dst32An group)))
3397 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
3398 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u16)))
3399 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u16)))
3400 ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (.sym Dst32An group))))
3401 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (.sym Dst32An group))) newval))
3403 (define-derived-operand
3404 (name (.sym dst32- offset -24-An-relative- group - smode))
3405 (comment (.str "m32c dsp:16[An] relative destination " smode))
3406 (attrs (machine 32))
3408 (args ((.sym Dst32An group) (.sym Dsp- offset -u24)))
3409 (syntax (.str "${Dsp-" offset "-u24}[$Dst32An" group "]"))
3410 (base-ifield (.sym f- base1 -6))
3411 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Dst32An group)))
3412 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
3413 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u24)))
3414 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u24)))
3415 ; (getter (mem32 smode (add (.sym Dsp- offset -u24) (.sym Dst32An group))))
3416 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u24) (.sym Dst32An group))) newval))
3421 (dst32-relative-operand 16 Unprefixed 4 8 QI QI)
3422 (dst32-relative-operand 24 Unprefixed 4 8 QI QI)
3423 (dst32-relative-operand 32 Unprefixed 4 8 QI QI)
3424 (dst32-relative-operand 40 Unprefixed 4 8 QI QI)
3425 (dst32-relative-operand 16 Unprefixed 4 8 HI HI)
3426 (dst32-relative-operand 24 Unprefixed 4 8 HI HI)
3427 (dst32-relative-operand 32 Unprefixed 4 8 HI HI)
3428 (dst32-relative-operand 40 Unprefixed 4 8 HI HI)
3429 (dst32-relative-operand 16 Unprefixed 4 8 SI SI)
3430 (dst32-relative-operand 24 Unprefixed 4 8 SI SI)
3431 (dst32-relative-operand 32 Unprefixed 4 8 SI SI)
3432 (dst32-relative-operand 40 Unprefixed 4 8 SI SI)
3434 (dst32-relative-operand 24 Prefixed 12 16 QI QI)
3435 (dst32-relative-operand 32 Prefixed 12 16 QI QI)
3436 (dst32-relative-operand 40 Prefixed 12 16 QI QI)
3437 (dst32-relative-operand 48 Prefixed 12 16 QI QI)
3438 (dst32-relative-operand 24 Prefixed 12 16 HI HI)
3439 (dst32-relative-operand 32 Prefixed 12 16 HI HI)
3440 (dst32-relative-operand 40 Prefixed 12 16 HI HI)
3441 (dst32-relative-operand 48 Prefixed 12 16 HI HI)
3442 (dst32-relative-operand 24 Prefixed 12 16 SI SI)
3443 (dst32-relative-operand 32 Prefixed 12 16 SI SI)
3444 (dst32-relative-operand 40 Prefixed 12 16 SI SI)
3445 (dst32-relative-operand 48 Prefixed 12 16 SI SI)
3447 (dst32-relative-operand 16 ExtUnprefixed 4 8 QI HI)
3448 (dst32-relative-operand 16 ExtUnprefixed 4 8 HI SI)
3450 ;-------------------------------------------------------------
3452 ;-------------------------------------------------------------
3454 (define-pmacro (dst16-absolute offset xmode)
3456 (define-derived-operand
3457 (name (.sym dst16- offset -16-absolute- xmode))
3458 (comment (.str "m16c absolute address " xmode))
3459 (attrs (machine 16))
3461 (args ((.sym Dsp- offset -u16)))
3462 (syntax (.str "${Dsp-" offset "-u16}"))
3463 (base-ifield f-12-4)
3464 (encoding (+ (f-12-4 #xF) (.sym Dsp- offset -u16)))
3465 (ifield-assertion (eq f-12-4 #xF))
3466 (getter (mem16 xmode (.sym Dsp- offset -u16)))
3467 (setter (set (mem16 xmode (.sym Dsp- offset -u16)) newval))
3472 (dst16-absolute 16 QI)
3473 (dst16-absolute 24 QI)
3474 (dst16-absolute 32 QI)
3475 (dst16-absolute 40 QI)
3476 (dst16-absolute 48 QI)
3477 (dst16-absolute 16 HI)
3478 (dst16-absolute 24 HI)
3479 (dst16-absolute 32 HI)
3480 (dst16-absolute 40 HI)
3481 (dst16-absolute 48 HI)
3482 (dst16-absolute 16 SI)
3483 (dst16-absolute 24 SI)
3484 (dst16-absolute 32 SI)
3485 (dst16-absolute 40 SI)
3486 (dst16-absolute 48 SI)
3488 (define-derived-operand
3489 (name dst16-16-16-absolute-Ext-QI)
3490 (comment "m16c absolute address QI")
3491 (attrs (machine 16))
3494 (syntax "${Dsp-16-u16}")
3495 (base-ifield f-12-4)
3496 (encoding (+ (f-12-4 #xF) Dsp-16-u16))
3497 (ifield-assertion (eq f-12-4 #xF))
3498 (getter (mem16 QI Dsp-16-u16))
3499 (setter (set (mem16 HI Dsp-16-u16) newval))
3502 (define-pmacro (dst32-absolute offset group base1 base2 smode dmode)
3504 (define-derived-operand
3505 (name (.sym dst32- offset -16-absolute- group - smode))
3506 (comment (.str "m32c absolute address " smode))
3507 (attrs (machine 32))
3509 (args ((.sym Dsp- offset -u16)))
3510 (syntax (.str "${Dsp-" offset "-u16}"))
3511 (base-ifield (.sym f- base1 -6))
3512 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
3513 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
3514 (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u16)))
3515 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u16)))
3516 ; (getter (mem32 smode (.sym Dsp- offset -u16)))
3517 ; (setter (set (mem32 dmode (.sym Dsp- offset -u16)) newval))
3519 (define-derived-operand
3520 (name (.sym dst32- offset -24-absolute- group - smode))
3521 (comment (.str "m32c absolute address " smode))
3522 (attrs (machine 32))
3524 (args ((.sym Dsp- offset -u24)))
3525 (syntax (.str "${Dsp-" offset "-u24}"))
3526 (base-ifield (.sym f- base1 -6))
3527 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
3528 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
3529 (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u24)))
3530 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u24)))
3531 ; (getter (mem32 smode (.sym Dsp- offset -u24)))
3532 ; (setter (set (mem32 dmode (.sym Dsp- offset -u24)) newval))
3537 (dst32-absolute 16 Unprefixed 4 8 QI QI)
3538 (dst32-absolute 24 Unprefixed 4 8 QI QI)
3539 (dst32-absolute 32 Unprefixed 4 8 QI QI)
3540 (dst32-absolute 40 Unprefixed 4 8 QI QI)
3541 (dst32-absolute 16 Unprefixed 4 8 HI HI)
3542 (dst32-absolute 24 Unprefixed 4 8 HI HI)
3543 (dst32-absolute 32 Unprefixed 4 8 HI HI)
3544 (dst32-absolute 40 Unprefixed 4 8 HI HI)
3545 (dst32-absolute 16 Unprefixed 4 8 SI SI)
3546 (dst32-absolute 24 Unprefixed 4 8 SI SI)
3547 (dst32-absolute 32 Unprefixed 4 8 SI SI)
3548 (dst32-absolute 40 Unprefixed 4 8 SI SI)
3550 (dst32-absolute 24 Prefixed 12 16 QI QI)
3551 (dst32-absolute 32 Prefixed 12 16 QI QI)
3552 (dst32-absolute 40 Prefixed 12 16 QI QI)
3553 (dst32-absolute 48 Prefixed 12 16 QI QI)
3554 (dst32-absolute 24 Prefixed 12 16 HI HI)
3555 (dst32-absolute 32 Prefixed 12 16 HI HI)
3556 (dst32-absolute 40 Prefixed 12 16 HI HI)
3557 (dst32-absolute 48 Prefixed 12 16 HI HI)
3558 (dst32-absolute 24 Prefixed 12 16 SI SI)
3559 (dst32-absolute 32 Prefixed 12 16 SI SI)
3560 (dst32-absolute 40 Prefixed 12 16 SI SI)
3561 (dst32-absolute 48 Prefixed 12 16 SI SI)
3563 (dst32-absolute 16 ExtUnprefixed 4 8 QI HI)
3564 (dst32-absolute 16 ExtUnprefixed 4 8 HI SI)
3566 ;-------------------------------------------------------------
3567 ; An indirect indirect
3568 ;-------------------------------------------------------------
3570 ;(define-pmacro (dst-An-indirect-indirect-operand xmode)
3571 ; (define-derived-operand
3572 ; (name (.sym dst32-An-indirect-indirect- xmode))
3573 ; (comment (.str "m32c An indirect indirect destination " xmode))
3574 ; (attrs (machine 32))
3576 ; (args (Dst32AnPrefixed))
3577 ; (syntax (.str "[[$Dst32AnPrefixed]]"))
3578 ; (base-ifield f-12-6)
3579 ; (encoding (+ (f-12-3 0) (f-16-1 0) Dst32AnPrefixed))
3580 ; (ifield-assertion (andif (eq f-12-3 0) (eq f-16-1 0)))
3581 ; (getter (mem32 xmode (indirect-addr Dst32AnPrefixed)))
3582 ; (setter (set (mem32 xmode (indirect-addr Dst32AnPrefixed)) newval))
3586 ; (dst-An-indirect-indirect-operand QI)
3587 ; (dst-An-indirect-indirect-operand HI)
3588 ; (dst-An-indirect-indirect-operand SI)
3590 ;-------------------------------------------------------------
3592 ;-------------------------------------------------------------
3594 (define-pmacro (dst-relative-indirect-operand offset xmode)
3596 ; (define-derived-operand
3597 ; (name (.sym dst32- offset -8-SB-relative-indirect- xmode))
3598 ; (comment (.str "m32c dsp:8[sb] relative destination " xmode))
3599 ; (attrs (machine 32))
3601 ; (args ((.sym Dsp- offset -u8)))
3602 ; (syntax (.str "[${Dsp-" offset "-u8}[sb]]"))
3603 ; (base-ifield f-12-6)
3604 ; (encoding (+ (f-12-3 1) (f-16-2 2) (.sym Dsp- offset -u8)))
3605 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 2)))
3606 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb)))))
3607 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb)))) newval))
3609 ; (define-derived-operand
3610 ; (name (.sym dst32- offset -16-SB-relative-indirect- xmode))
3611 ; (comment (.str "m32c dsp:16[sb] relative destination " xmode))
3612 ; (attrs (machine 32))
3614 ; (args ((.sym Dsp- offset -u16)))
3615 ; (syntax (.str "[${Dsp-" offset "-u16}[sb]]"))
3616 ; (base-ifield f-12-6)
3617 ; (encoding (+ (f-12-3 2) (f-16-2 2) (.sym Dsp- offset -u16)))
3618 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 2)))
3619 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb)))))
3620 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb)))) newval))
3622 ; (define-derived-operand
3623 ; (name (.sym dst32- offset -8-FB-relative-indirect- xmode))
3624 ; (comment (.str "m32c dsp:8[fb] relative destination " xmode))
3625 ; (attrs (machine 32))
3627 ; (args ((.sym Dsp- offset -s8)))
3628 ; (syntax (.str "[${Dsp-" offset "-s8}[fb]]"))
3629 ; (base-ifield f-12-6)
3630 ; (encoding (+ (f-12-3 1) (f-16-2 3) (.sym Dsp- offset -s8)))
3631 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 3)))
3632 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb)))))
3633 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb)))) newval))
3635 ; (define-derived-operand
3636 ; (name (.sym dst32- offset -16-FB-relative-indirect- xmode))
3637 ; (comment (.str "m32c dsp:16[fb] relative destination " xmode))
3638 ; (attrs (machine 32))
3640 ; (args ((.sym Dsp- offset -s16)))
3641 ; (syntax (.str "[${Dsp-" offset "-s16}[fb]]"))
3642 ; (base-ifield f-12-6)
3643 ; (encoding (+ (f-12-3 2) (f-16-2 3) (.sym Dsp- offset -s16)))
3644 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 3)))
3645 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb)))))
3646 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb)))) newval))
3648 ; (define-derived-operand
3649 ; (name (.sym dst32- offset -8-An-relative-indirect- xmode))
3650 ; (comment (.str "m32c dsp:8[An] relative indirect destination " xmode))
3651 ; (attrs (machine 32))
3653 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u8)))
3654 ; (syntax (.str "[${Dsp-" offset "-u8}[$Dst32AnPrefixed]]"))
3655 ; (base-ifield f-12-6)
3656 ; (encoding (+ (f-12-3 1) (f-16-1 0) (.sym Dsp- offset -u8) Dst32AnPrefixed))
3657 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-1 0)))
3658 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed))))
3659 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed))) newval))
3661 ; (define-derived-operand
3662 ; (name (.sym dst32- offset -16-An-relative-indirect- xmode))
3663 ; (comment (.str "m32c dsp:16[An] relative destination " xmode))
3664 ; (attrs (machine 32))
3666 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u16)))
3667 ; (syntax (.str "[${Dsp-" offset "-u16}[$Dst32AnPrefixed]]"))
3668 ; (base-ifield f-12-6)
3669 ; (encoding (+ (f-12-3 2) (f-16-1 0) (.sym Dsp- offset -u16) Dst32AnPrefixed))
3670 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-1 0)))
3671 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed))))
3672 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed))) newval))
3674 ; (define-derived-operand
3675 ; (name (.sym dst32- offset -24-An-relative-indirect- xmode))
3676 ; (comment (.str "m32c dsp:24[An] relative destination " xmode))
3677 ; (attrs (machine 32))
3679 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u24)))
3680 ; (syntax (.str "[${Dsp-" offset "-u24}[$Dst32AnPrefixed]]"))
3681 ; (base-ifield f-12-6)
3682 ; (encoding (+ (f-12-3 3) (f-16-1 0) (.sym Dsp- offset -u24) Dst32AnPrefixed))
3683 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-1 0)))
3684 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed))))
3685 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed))) newval))
3690 ; (dst-relative-indirect-operand 24 QI)
3691 ; (dst-relative-indirect-operand 32 QI)
3692 ; (dst-relative-indirect-operand 40 QI)
3693 ; (dst-relative-indirect-operand 48 QI)
3694 ; (dst-relative-indirect-operand 24 HI)
3695 ; (dst-relative-indirect-operand 32 HI)
3696 ; (dst-relative-indirect-operand 40 HI)
3697 ; (dst-relative-indirect-operand 48 HI)
3698 ; (dst-relative-indirect-operand 24 SI)
3699 ; (dst-relative-indirect-operand 32 SI)
3700 ; (dst-relative-indirect-operand 40 SI)
3701 ; (dst-relative-indirect-operand 48 SI)
3703 ;-------------------------------------------------------------
3705 ;-------------------------------------------------------------
3707 (define-pmacro (dst-absolute-indirect offset xmode)
3709 ; (define-derived-operand
3710 ; (name (.sym dst32- offset -16-absolute-indirect-derived- xmode))
3711 ; (comment (.str "m32c absolute indirect address " xmode))
3712 ; (attrs (machine 32))
3714 ; (args ((.sym Dsp- offset -u16)))
3715 ; (syntax (.str "[${Dsp-" offset "-u16}]"))
3716 ; (base-ifield f-12-6)
3717 ; (encoding (+ (f-12-3 3) (f-16-2 3) (.sym Dsp- offset -u16)))
3718 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 3)))
3719 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))))
3720 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval))
3722 ; (define-derived-operand
3723 ; (name (.sym dst32- offset -24-absolute-indirect-derived- xmode))
3724 ; (comment (.str "m32c absolute indirect address " xmode))
3725 ; (attrs (machine 32))
3727 ; (args ((.sym Dsp- offset -u24)))
3728 ; (syntax (.str "[${Dsp-" offset "-u24}]"))
3729 ; (base-ifield f-12-6)
3730 ; (encoding (+ (f-12-3 3) (f-16-2 2) (.sym Dsp- offset -u24)))
3731 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 2)))
3732 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))))
3733 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval))
3738 (dst-absolute-indirect 24 QI)
3739 (dst-absolute-indirect 32 QI)
3740 (dst-absolute-indirect 40 QI)
3741 (dst-absolute-indirect 48 QI)
3742 (dst-absolute-indirect 24 HI)
3743 (dst-absolute-indirect 32 HI)
3744 (dst-absolute-indirect 40 HI)
3745 (dst-absolute-indirect 48 HI)
3746 (dst-absolute-indirect 24 SI)
3747 (dst-absolute-indirect 32 SI)
3748 (dst-absolute-indirect 40 SI)
3749 (dst-absolute-indirect 48 SI)
3751 ;-------------------------------------------------------------
3753 ;-------------------------------------------------------------
3754 (define-pmacro (get-register-bit reg bitno)
3755 (and (srl reg bitno) 1)
3758 (define-pmacro (set-register-bit reg bitno value)
3759 (set reg (or (and reg (inv (sll 1 bitno)))
3760 (sll (and QI value 1) bitno)))
3763 (define-pmacro (get-memory-bit mach base bitno)
3764 (and (srl (mem-mach mach QI (add base (div bitno 8)))
3769 (define-pmacro (set-memory-bit mach base bitno value)
3770 (sequence ((USI addr))
3771 (set addr (add base (div bitno 8)))
3772 (set (mem-mach mach QI addr)
3773 (or (and (mem-mach mach QI addr)
3774 (inv (sll 1 (mod bitno 8))))
3775 (sll (and QI value 1) (mod bitno 8)))))
3778 ;-------------------------------------------------------------
3780 ;-------------------------------------------------------------
3782 (define-derived-operand
3783 (name bit16-Rn-direct)
3784 (comment "m16c Rn direct bit")
3785 (attrs (machine 16))
3787 (args (Bitno16R Bit16Rn))
3788 (syntax "$Bitno16R,$Bit16Rn")
3789 (base-ifield f-12-4)
3790 (encoding (+ (f-12-2 0) Bit16Rn Bitno16R))
3791 (ifield-assertion (eq f-12-2 0))
3792 (getter (get-register-bit Bit16Rn Bitno16R))
3793 (setter (set-register-bit Bit16Rn Bitno16R newval))
3796 (define-pmacro (bit32-Rn-direct-operand group base)
3798 (define-derived-operand
3799 (name (.sym bit32-Rn-direct- group))
3800 (comment "m32c Rn direct bit")
3801 (attrs (machine 32))
3803 (args ((.sym Bitno32 group) (.sym Bit32Rn group)))
3804 (syntax (.str "$Bitno32" group ",$Bit32Rn" group))
3805 (base-ifield (.sym f- base -6))
3806 (encoding (+ ((.sym f- base -3) 4) (.sym Bit32Rn group) (.sym Bitno32 group)))
3807 (ifield-assertion (eq (.sym f- base -3) 4))
3808 (getter (get-register-bit (.sym Bit32Rn group) (.sym Bitno32 group)))
3809 (setter (set-register-bit (.sym Bit32Rn group) (.sym Bitno32 group) newval))
3814 (bit32-Rn-direct-operand Unprefixed 4)
3815 (bit32-Rn-direct-operand Prefixed 12)
3817 ;-------------------------------------------------------------
3819 ;-------------------------------------------------------------
3821 (define-derived-operand
3822 (name bit16-An-direct)
3823 (comment "m16c An direct bit")
3824 (attrs (machine 16))
3826 (args (Bitno16R Bit16An))
3827 (syntax "$Bitno16R,$Bit16An")
3828 (base-ifield f-12-4)
3829 (encoding (+ (f-12-2 1) (f-14-1 0) Bit16An Bitno16R))
3830 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0)))
3831 (getter (get-register-bit Bit16An Bitno16R))
3832 (setter (set-register-bit Bit16An Bitno16R newval))
3835 (define-pmacro (bit32-An-direct-operand group base1 base2)
3837 (define-derived-operand
3838 (name (.sym bit32-An-direct- group))
3839 (comment "m32c An direct bit")
3840 (attrs (machine 32))
3842 (args ((.sym Bitno32 group) (.sym Bit32An group)))
3843 (syntax (.str "$Bitno32" group ",$Bit32An" group))
3844 (base-ifield (.sym f- base1 -6))
3845 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Bit32An group) (.sym Bitno32 group)))
3846 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
3847 (getter (get-register-bit (.sym Bit32An group) (.sym Bitno32 group)))
3848 (setter (set-register-bit (.sym Bit32An group) (.sym Bitno32 group) newval))
3853 (bit32-An-direct-operand Unprefixed 4 8)
3854 (bit32-An-direct-operand Prefixed 12 16)
3856 ;-------------------------------------------------------------
3858 ;-------------------------------------------------------------
3860 (define-derived-operand
3861 (name bit16-An-indirect)
3862 (comment "m16c An indirect bit")
3863 (attrs (machine 16))
3866 (syntax "[$Bit16An]")
3867 (base-ifield f-12-4)
3868 (encoding (+ (f-12-2 1) (f-14-1 1) Bit16An))
3869 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
3870 (getter (get-memory-bit 16 0 Bit16An))
3871 (setter (set-memory-bit 16 0 Bit16An newval))
3874 (define-pmacro (bit32-An-indirect-operand group base1 base2)
3876 (define-derived-operand
3877 (name (.sym bit32-An-indirect- group))
3878 (comment "m32c An indirect destination ")
3879 (attrs (machine 32))
3881 (args ((.sym Bitno32 group) (.sym Bit32An group)))
3882 (syntax (.str "$Bitno32" group ",[$Bit32An" group "]"))
3883 (base-ifield (.sym f- base1 -6))
3884 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Bit32An group) (.sym Bitno32 group)))
3885 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
3886 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group)))
3887 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group) newval))
3892 (bit32-An-indirect-operand Unprefixed 4 8)
3893 (bit32-An-indirect-operand Prefixed 12 16)
3895 ;-------------------------------------------------------------
3897 ;-------------------------------------------------------------
3899 (define-pmacro (bit16-relative-operand offset)
3901 (define-derived-operand
3902 (name (.sym bit16- offset -8-SB-relative))
3903 (comment (.str "m16c dsp:8[sb] relative bit " xmode))
3904 (attrs (machine 16))
3906 (args ((.sym BitBase16- offset -u8)))
3907 (syntax (.str "${BitBase16-" offset "-u8}[sb]"))
3908 (base-ifield f-12-4)
3909 (encoding (+ (f-12-4 #xA) (.sym BitBase16- offset -u8)))
3910 (ifield-assertion (eq f-12-4 #xA))
3911 (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8)))
3912 (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8) newval))
3914 (define-derived-operand
3915 (name (.sym bit16- offset -16-SB-relative))
3916 (comment (.str "m16c dsp:16[sb] relative bit " xmode))
3917 (attrs (machine 16))
3919 (args ((.sym BitBase16- offset -u16)))
3920 (syntax (.str "${BitBase16-" offset "-u16}[sb]"))
3921 (base-ifield f-12-4)
3922 (encoding (+ (f-12-4 #xE) (.sym BitBase16- offset -u16)))
3923 (ifield-assertion (eq f-12-4 #xE))
3924 (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16)))
3925 (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16) newval))
3927 (define-derived-operand
3928 (name (.sym bit16- offset -8-FB-relative))
3929 (comment (.str "m16c dsp:8[fb] relative bit " xmode))
3930 (attrs (machine 16))
3932 (args ((.sym BitBase16- offset -s8)))
3933 (syntax (.str "${BitBase16-" offset "-s8}[fb]"))
3934 (base-ifield f-12-4)
3935 (encoding (+ (f-12-4 #xB) (.sym BitBase16- offset -s8)))
3936 (ifield-assertion (eq f-12-4 #xB))
3937 (getter (get-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8)))
3938 (setter (set-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8) newval))
3940 (define-derived-operand
3941 (name (.sym bit16- offset -8-An-relative))
3942 (comment (.str "m16c dsp:8[An] relative bit " xmode))
3943 (attrs (machine 16))
3945 (args (Bit16An (.sym Dsp- offset -u8)))
3946 (syntax (.str "${Dsp-" offset "-u8}[$Bit16An]"))
3947 (base-ifield f-12-4)
3948 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Bit16An))
3949 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3950 (getter (get-memory-bit 16 (.sym Dsp- offset -u8) Bit16An))
3951 (setter (set-memory-bit 16 (.sym Dsp- offset -u8) Bit16An newval))
3953 (define-derived-operand
3954 (name (.sym bit16- offset -16-An-relative))
3955 (comment (.str "m16c dsp:16[An] relative bit " xmode))
3956 (attrs (machine 16))
3958 (args (Bit16An (.sym Dsp- offset -u16)))
3959 (syntax (.str "${Dsp-" offset "-u16}[$Bit16An]"))
3960 (base-ifield f-12-4)
3961 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Bit16An))
3962 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3963 (getter (get-memory-bit 16 (.sym Dsp- offset -u16) Bit16An))
3964 (setter (set-memory-bit 16 (.sym Dsp- offset -u16) Bit16An newval))
3969 (bit16-relative-operand 16)
3971 (define-pmacro (bit32-relative-operand offset group base1 base2)
3973 (define-derived-operand
3974 (name (.sym bit32- offset -11-SB-relative- group))
3975 (comment "m32c bit,base:11[sb] relative bit")
3976 (attrs (machine 32))
3978 (args ((.sym BitBase32- offset -u11- group)))
3979 (syntax (.str "${BitBase32-" offset "-u11-" group "}[sb]"))
3980 (base-ifield (.sym f- base1 -12))
3981 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u11- group)))
3982 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
3983 (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group)))
3984 (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group) newval))
3986 (define-derived-operand
3987 (name (.sym bit32- offset -19-SB-relative- group))
3988 (comment "m32c bit,base:19[sb] relative bit")
3989 (attrs (machine 32))
3991 (args ((.sym BitBase32- offset -u19- group)))
3992 (syntax (.str "${BitBase32-" offset "-u19-" group "}[sb]"))
3993 (base-ifield (.sym f- base1 -12))
3994 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u19- group)))
3995 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
3996 (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group)))
3997 (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group) newval))
3999 (define-derived-operand
4000 (name (.sym bit32- offset -11-FB-relative- group))
4001 (comment "m32c bit,base:11[fb] relative bit")
4002 (attrs (machine 32))
4004 (args ((.sym BitBase32- offset -s11- group)))
4005 (syntax (.str "${BitBase32-" offset "-s11-" group "}[fb]"))
4006 (base-ifield (.sym f- base1 -12))
4007 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s11- group)))
4008 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
4009 (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group)))
4010 (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group) newval))
4012 (define-derived-operand
4013 (name (.sym bit32- offset -19-FB-relative- group))
4014 (comment "m32c bit,base:19[fb] relative bit")
4015 (attrs (machine 32))
4017 (args ((.sym BitBase32- offset -s19- group)))
4018 (syntax (.str "${BitBase32-" offset "-s19-" group "}[fb]"))
4019 (base-ifield (.sym f- base1 -12))
4020 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s19- group)))
4021 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
4022 (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group)))
4023 (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group) newval))
4025 (define-derived-operand
4026 (name (.sym bit32- offset -11-An-relative- group))
4027 (comment "m32c bit,base:11[An] relative bit")
4028 (attrs (machine 32))
4030 (args ((.sym BitBase32- offset -u11- group) (.sym Bit32An group)))
4031 (syntax (.str "${BitBase32-" offset "-u11-" group "}[$Bit32An" group "]"))
4032 (base-ifield (.sym f- base1 -12))
4033 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u11- group) (.sym Bit32An group)))
4034 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
4035 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group)))
4036 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group) newval))
4038 (define-derived-operand
4039 (name (.sym bit32- offset -19-An-relative- group))
4040 (comment "m32c bit,base:19[An] relative bit")
4041 (attrs (machine 32))
4043 (args ((.sym BitBase32- offset -u19- group) (.sym Bit32An group)))
4044 (syntax (.str "${BitBase32-" offset "-u19-" group "}[$Bit32An" group "]"))
4045 (base-ifield (.sym f- base1 -12))
4046 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u19- group) (.sym Bit32An group)))
4047 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
4048 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group)))
4049 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group) newval))
4051 (define-derived-operand
4052 (name (.sym bit32- offset -27-An-relative- group))
4053 (comment "m32c bit,base:27[An] relative bit")
4054 (attrs (machine 32))
4056 (args ((.sym BitBase32- offset -u27- group) (.sym Bit32An group)))
4057 (syntax (.str "${BitBase32-" offset "-u27-" group "}[$Bit32An" group "]"))
4058 (base-ifield (.sym f- base1 -12))
4059 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u27- group) (.sym Bit32An group)))
4060 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
4061 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group)))
4062 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group) newval))
4067 (bit32-relative-operand 16 Unprefixed 4 8)
4068 (bit32-relative-operand 24 Prefixed 12 16)
4070 (define-derived-operand
4071 (name bit16-11-SB-relative-S)
4072 (comment "m16c bit,base:11[sb] relative bit")
4073 (attrs (machine 16))
4075 (args (BitBase16-8-u11-S))
4076 (syntax "${BitBase16-8-u11-S}[sb]")
4077 (base-ifield (.sym f-5-3))
4078 (encoding (+ BitBase16-8-u11-S))
4079 ; (ifield-assertion (#t))
4080 (getter (get-memory-bit 16 (reg h-sb) BitBase16-8-u11-S))
4081 (setter (set-memory-bit 16 (reg h-sb) BitBase16-8-u11-S newval))
4084 (define-derived-operand
4085 (name Rn16-push-S-derived)
4086 (comment "m16c r0[lh] for push,pop short version")
4087 (attrs (machine 16))
4089 (args (Rn16-push-S))
4090 (syntax "${Rn16-push-S}")
4091 (base-ifield (.sym f-4-1))
4092 (encoding (+ Rn16-push-S))
4093 ; (ifield-assertion (#t))
4094 (getter (trunc QI Rn16-push-S))
4095 (setter (set Rn16-push-S newval))
4098 (define-derived-operand
4099 (name An16-push-S-derived)
4100 (comment "m16c r0[lh] for push,pop short version")
4101 (attrs (machine 16))
4103 (args (An16-push-S))
4104 (syntax "${An16-push-S}")
4105 (base-ifield (.sym f-4-1))
4106 (encoding (+ An16-push-S))
4107 ; (ifield-assertion (#t))
4108 (getter (trunc QI An16-push-S))
4109 (setter (set An16-push-S newval))
4112 ;-------------------------------------------------------------
4114 ;-------------------------------------------------------------
4116 (define-pmacro (bit16-absolute offset)
4118 (define-derived-operand
4119 (name (.sym bit16- offset -16-absolute))
4120 (comment "m16c absolute address")
4121 (attrs (machine 16))
4123 (args ((.sym BitBase16- offset -u16)))
4124 (syntax (.str "${BitBase16-" offset "-u16}"))
4125 (base-ifield f-12-4)
4126 (encoding (+ (f-12-4 #xF) (.sym BitBase16- offset -u16)))
4127 (ifield-assertion (eq f-12-4 #xF))
4128 (getter (get-memory-bit 16 0 (.sym BitBase16- offset -u16)))
4129 (setter (set-memory-bit 16 0 (.sym BitBase16- offset -u16) newval))
4136 (define-pmacro (bit32-absolute offset group base1 base2)
4138 (define-derived-operand
4139 (name (.sym bit32- offset -19-absolute- group))
4140 (comment "m32c absolute address bit")
4141 (attrs (machine 32))
4143 (args ((.sym BitBase32- offset -u19- group)))
4144 (syntax (.str "${BitBase32-" offset "-u19-" group "}"))
4145 (base-ifield (.sym f- base1 -12))
4146 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -u19- group)))
4147 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
4148 (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u19- group)))
4149 (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u19- group) newval))
4151 (define-derived-operand
4152 (name (.sym bit32- offset -27-absolute- group))
4153 (comment "m32c absolute address bit")
4154 (attrs (machine 32))
4156 (args ((.sym BitBase32- offset -u27- group)))
4157 (syntax (.str "${BitBase32-" offset "-u27-" group "}"))
4158 (base-ifield (.sym f- base1 -12))
4159 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u27- group)))
4160 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
4161 (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u27- group)))
4162 (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u27- group) newval))
4167 (bit32-absolute 16 Unprefixed 4 8)
4168 (bit32-absolute 24 Prefixed 12 16)
4170 ;-------------------------------------------------------------
4171 ; Destination operands for short fomat insns
4172 ;-------------------------------------------------------------
4174 (define-derived-operand
4175 (name dst16-3-S-R0l-direct-QI)
4176 (comment "m16c R0l direct QI")
4177 (attrs (machine 16))
4182 (encoding (+ (f-5-3 4)))
4183 (ifield-assertion (eq f-5-3 4))
4184 (getter (trunc QI R0l))
4185 (setter (set R0l newval))
4187 (define-derived-operand
4188 (name dst16-3-S-R0h-direct-QI)
4189 (comment "m16c R0h direct QI")
4190 (attrs (machine 16))
4195 (encoding (+ (f-5-3 3)))
4196 (ifield-assertion (eq f-5-3 3))
4197 (getter (trunc QI R0h))
4198 (setter (set R0h newval))
4200 (define-derived-operand
4201 (name dst16-3-S-8-8-SB-relative-QI)
4202 (comment "m16c SB relative QI")
4203 (attrs (machine 16))
4206 (syntax "${Dsp-8-u8}[sb]")
4208 (encoding (+ (f-5-3 5) Dsp-8-u8))
4209 (ifield-assertion (eq f-5-3 5))
4210 (getter (mem16 QI (add Dsp-8-u8 (reg h-sb))))
4211 (setter (set (mem16 QI (add Dsp-8-u8 (reg h-sb))) newval))
4213 (define-derived-operand
4214 (name dst16-3-S-8-8-FB-relative-QI)
4215 (comment "m16c FB relative QI")
4216 (attrs (machine 16))
4219 (syntax "${Dsp-8-s8}[fb]")
4221 (encoding (+ (f-5-3 6) Dsp-8-s8))
4222 (ifield-assertion (eq f-5-3 6))
4223 (getter (mem16 QI (add Dsp-8-s8 (reg h-fb))))
4224 (setter (set (mem16 QI (add Dsp-8-s8 (reg h-fb))) newval))
4226 (define-derived-operand
4227 (name dst16-3-S-8-16-absolute-QI)
4228 (comment "m16c absolute address QI")
4229 (attrs (machine 16))
4232 (syntax "${Dsp-8-u16}")
4234 (encoding (+ (f-5-3 7) Dsp-8-u16))
4235 (ifield-assertion (eq f-5-3 7))
4236 (getter (mem16 QI Dsp-8-u16))
4237 (setter (set (mem16 QI Dsp-8-u16) newval))
4239 (define-derived-operand
4240 (name dst16-3-S-16-8-SB-relative-QI)
4241 (comment "m16c SB relative QI")
4242 (attrs (machine 16))
4245 (syntax "${Dsp-16-u8}[sb]")
4247 (encoding (+ (f-5-3 5) Dsp-16-u8))
4248 (ifield-assertion (eq f-5-3 5))
4249 (getter (mem16 QI (add Dsp-16-u8 (reg h-sb))))
4250 (setter (set (mem16 QI (add Dsp-16-u8 (reg h-sb))) newval))
4252 (define-derived-operand
4253 (name dst16-3-S-16-8-FB-relative-QI)
4254 (comment "m16c FB relative QI")
4255 (attrs (machine 16))
4258 (syntax "${Dsp-16-s8}[fb]")
4260 (encoding (+ (f-5-3 6) Dsp-16-s8))
4261 (ifield-assertion (eq f-5-3 6))
4262 (getter (mem16 QI (add Dsp-16-s8 (reg h-fb))))
4263 (setter (set (mem16 QI (add Dsp-16-s8 (reg h-fb))) newval))
4265 (define-derived-operand
4266 (name dst16-3-S-16-16-absolute-QI)
4267 (comment "m16c absolute address QI")
4268 (attrs (machine 16))
4271 (syntax "${Dsp-16-u16}")
4273 (encoding (+ (f-5-3 7) Dsp-16-u16))
4274 (ifield-assertion (eq f-5-3 7))
4275 (getter (mem16 QI Dsp-16-u16))
4276 (setter (set (mem16 QI Dsp-16-u16) newval))
4278 (define-derived-operand
4279 (name srcdst16-r0l-r0h-S-derived)
4280 (comment "m16c r0l/r0h operand for short format insns")
4281 (attrs (machine 16))
4283 (args (SrcDst16-r0l-r0h-S-normal))
4284 (syntax "${SrcDst16-r0l-r0h-S-normal}")
4286 (encoding (+ (f-6-2 0) SrcDst16-r0l-r0h-S-normal))
4287 (ifield-assertion (eq f-6-2 0))
4288 (getter (trunc SI SrcDst16-r0l-r0h-S-normal))
4289 (setter ()) ; no setter
4291 (define-derived-operand
4292 (name dst32-2-S-R0l-direct-QI)
4293 (comment "m32c R0l direct QI")
4294 (attrs (machine 32))
4299 (encoding (+ (f-2-2 0)))
4300 (ifield-assertion (eq f-2-2 0))
4301 (getter (trunc QI R0l))
4302 (setter (set R0l newval))
4304 (define-derived-operand
4305 (name dst32-2-S-R0-direct-HI)
4306 (comment "m32c R0 direct HI")
4307 (attrs (machine 32))
4312 (encoding (+ (f-2-2 0)))
4313 (ifield-assertion (eq f-2-2 0))
4314 (getter (trunc HI R0))
4315 (setter (set R0 newval))
4317 (define-derived-operand
4318 (name dst32-1-S-A0-direct-HI)
4319 (comment "m32c A0 direct HI")
4320 (attrs (machine 32))
4325 (encoding (+ (f-7-1 0)))
4326 (ifield-assertion (eq f-7-1 0))
4327 (getter (trunc HI A0))
4328 (setter (set A0 newval))
4330 (define-derived-operand
4331 (name dst32-1-S-A1-direct-HI)
4332 (comment "m32c A1 direct HI")
4333 (attrs (machine 32))
4338 (encoding (+ (f-7-1 1)))
4339 (ifield-assertion (eq f-7-1 1))
4340 (getter (trunc HI A1))
4341 (setter (set A1 newval))
4343 (define-pmacro (dst32-2-S-operands xmode)
4345 (define-derived-operand
4346 (name (.sym dst32-2-S-8-SB-relative- xmode))
4347 (comment "m32c SB relative for short binary insns")
4348 (attrs (machine 32))
4351 (syntax "${Dsp-8-u8}[sb]")
4353 (encoding (+ (f-2-2 2) Dsp-8-u8))
4354 (ifield-assertion (eq f-2-2 2))
4355 (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8))
4356 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8))
4357 ; (getter (mem32 xmode (add Dsp-8-u8 (reg h-sb))))
4358 ; (setter (set (mem32 xmode (add Dsp-8-u8 (reg h-sb))) newval))
4360 (define-derived-operand
4361 (name (.sym dst32-2-S-8-FB-relative- xmode))
4362 (comment "m32c FB relative for short binary insns")
4363 (attrs (machine 32))
4366 (syntax "${Dsp-8-s8}[fb]")
4368 (encoding (+ (f-2-2 3) Dsp-8-s8))
4369 (ifield-assertion (eq f-2-2 3))
4370 (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8))
4371 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8))
4372 ; (getter (mem32 xmode (add Dsp-8-s8 (reg h-fb))))
4373 ; (setter (set (mem32 xmode (add Dsp-8-s8 (reg h-fb))) newval))
4375 (define-derived-operand
4376 (name (.sym dst32-2-S-16-absolute- xmode))
4377 (comment "m32c absolute address for short binary insns")
4378 (attrs (machine 32))
4381 (syntax "${Dsp-8-u16}")
4383 (encoding (+ (f-2-2 1) Dsp-8-u16))
4384 (ifield-assertion (eq f-2-2 1))
4385 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16))
4386 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16))
4387 ; (getter (mem32 xmode Dsp-8-u16))
4388 ; (setter (set (mem32 xmode Dsp-8-u16) newval))
4390 ; (define-derived-operand
4391 ; (name (.sym dst32-2-S-8-SB-relative-indirect- xmode))
4392 ; (comment "m32c SB relative for short binary insns")
4393 ; (attrs (machine 32))
4395 ; (args (Dsp-16-u8))
4396 ; (syntax "[${Dsp-16-u8}[sb]]")
4397 ; (base-ifield f-10-2)
4398 ; (encoding (+ (f-10-2 2) Dsp-16-u8))
4399 ; (ifield-assertion (eq f-10-2 2))
4400 ; (getter (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb)))))
4401 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb)))) newval))
4403 ; (define-derived-operand
4404 ; (name (.sym dst32-2-S-8-FB-relative-indirect- xmode))
4405 ; (comment "m32c FB relative for short binary insns")
4406 ; (attrs (machine 32))
4408 ; (args (Dsp-16-s8))
4409 ; (syntax "[${Dsp-16-s8}[fb]]")
4410 ; (base-ifield f-10-2)
4411 ; (encoding (+ (f-10-2 3) Dsp-16-s8))
4412 ; (ifield-assertion (eq f-10-2 3))
4413 ; (getter (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb)))))
4414 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb)))) newval))
4416 ; (define-derived-operand
4417 ; (name (.sym dst32-2-S-16-absolute-indirect- xmode))
4418 ; (comment "m32c absolute address for short binary insns")
4419 ; (attrs (machine 32))
4421 ; (args (Dsp-16-u16))
4422 ; (syntax "[${Dsp-16-u16}]")
4423 ; (base-ifield f-10-2)
4424 ; (encoding (+ (f-10-2 1) Dsp-16-u16))
4425 ; (ifield-assertion (eq f-10-2 1))
4426 ; (getter (mem32 xmode (indirect-addr Dsp-16-u16)))
4427 ; (setter (set (mem32 xmode (indirect-addr Dsp-16-u16)) newval))
4432 (dst32-2-S-operands QI)
4433 (dst32-2-S-operands HI)
4434 (dst32-2-S-operands SI)
4436 ;=============================================================
4438 ;-------------------------------------------------------------
4439 ; Source operands with no additional fields
4440 ;-------------------------------------------------------------
4442 (define-pmacro (src16-basic-operand xmode)
4444 (define-anyof-operand
4445 (name (.sym src16-basic- xmode))
4446 (comment (.str "m16c source operand of size " xmode " with no additional fields"))
4447 (attrs (machine 16))
4450 (.sym src16-Rn-direct- xmode)
4451 (.sym src16-An-direct- xmode)
4452 (.sym src16-An-indirect- xmode)
4457 (src16-basic-operand QI)
4458 (src16-basic-operand HI)
4460 (define-pmacro (src32-basic-operand xmode)
4462 (define-anyof-operand
4463 (name (.sym src32-basic-Unprefixed- xmode))
4464 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4465 (attrs (machine 32))
4468 (.sym src32-Rn-direct-Unprefixed- xmode)
4469 (.sym src32-An-direct-Unprefixed- xmode)
4470 (.sym src32-An-indirect-Unprefixed- xmode)
4473 (define-anyof-operand
4474 (name (.sym src32-basic-Prefixed- xmode))
4475 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4476 (attrs (machine 32))
4479 (.sym src32-Rn-direct-Prefixed- xmode)
4480 (.sym src32-An-direct-Prefixed- xmode)
4481 (.sym src32-An-indirect-Prefixed- xmode)
4484 ; (define-anyof-operand
4485 ; (name (.sym src32-basic-indirect- xmode))
4486 ; (comment (.str "m32c destination operand of size " xmode " indirect with no additional fields"))
4487 ; (attrs (machine 32))
4490 ; (.sym src32-An-indirect-indirect- xmode)
4496 (src32-basic-operand QI)
4497 (src32-basic-operand HI)
4498 (src32-basic-operand SI)
4500 (define-anyof-operand
4501 (name src32-basic-ExtPrefixed-QI)
4502 (comment "m32c source operand of size QI with no additional fields")
4503 (attrs (machine 32))
4506 src32-Rn-direct-Prefixed-QI
4507 src32-An-indirect-Prefixed-QI
4511 ;-------------------------------------------------------------
4512 ; Source operands with additional fields at offset 16 bits
4513 ;-------------------------------------------------------------
4515 (define-pmacro (src16-16-operand xmode)
4517 (define-anyof-operand
4518 (name (.sym src16-16-8- xmode))
4519 (comment (.str "m16c source operand of size " xmode " with additional 8 bit fields at offset 16"))
4520 (attrs (machine 16))
4523 (.sym src16-16-8-An-relative- xmode)
4524 (.sym src16-16-8-SB-relative- xmode)
4525 (.sym src16-16-8-FB-relative- xmode)
4528 (define-anyof-operand
4529 (name (.sym src16-16-16- xmode))
4530 (comment (.str "m16c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4531 (attrs (machine 16))
4534 (.sym src16-16-16-An-relative- xmode)
4535 (.sym src16-16-16-SB-relative- xmode)
4536 (.sym src16-16-16-absolute- xmode)
4541 (src16-16-operand QI)
4542 (src16-16-operand HI)
4544 (define-pmacro (src32-16-operand xmode)
4546 (define-anyof-operand
4547 (name (.sym src32-16-8-Unprefixed- xmode))
4548 (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 16"))
4549 (attrs (machine 32))
4552 (.sym src32-16-8-An-relative-Unprefixed- xmode)
4553 (.sym src32-16-8-SB-relative-Unprefixed- xmode)
4554 (.sym src32-16-8-FB-relative-Unprefixed- xmode)
4557 (define-anyof-operand
4558 (name (.sym src32-16-16-Unprefixed- xmode))
4559 (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4560 (attrs (machine 32))
4563 (.sym src32-16-16-An-relative-Unprefixed- xmode)
4564 (.sym src32-16-16-SB-relative-Unprefixed- xmode)
4565 (.sym src32-16-16-FB-relative-Unprefixed- xmode)
4566 (.sym src32-16-16-absolute-Unprefixed- xmode)
4569 (define-anyof-operand
4570 (name (.sym src32-16-24-Unprefixed- xmode))
4571 (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16"))
4572 (attrs (machine 32))
4575 (.sym src32-16-24-An-relative-Unprefixed- xmode)
4576 (.sym src32-16-24-absolute-Unprefixed- xmode)
4582 (src32-16-operand QI)
4583 (src32-16-operand HI)
4584 (src32-16-operand SI)
4586 ;-------------------------------------------------------------
4587 ; Source operands with additional fields at offset 24 bits
4588 ;-------------------------------------------------------------
4590 (define-pmacro (src-24-operand group xmode)
4592 (define-anyof-operand
4593 (name (.sym src32-24-8- group - xmode))
4594 (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 24"))
4595 (attrs (machine 32))
4598 (.sym src32-24-8-An-relative- group - xmode)
4599 (.sym src32-24-8-SB-relative- group - xmode)
4600 (.sym src32-24-8-FB-relative- group - xmode)
4603 (define-anyof-operand
4604 (name (.sym src32-24-16- group - xmode))
4605 (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4606 (attrs (machine 32))
4609 (.sym src32-24-16-An-relative- group - xmode)
4610 (.sym src32-24-16-SB-relative- group - xmode)
4611 (.sym src32-24-16-FB-relative- group - xmode)
4612 (.sym src32-24-16-absolute- group - xmode)
4615 (define-anyof-operand
4616 (name (.sym src32-24-24- group - xmode))
4617 (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16"))
4618 (attrs (machine 32))
4621 (.sym src32-24-24-An-relative- group - xmode)
4622 (.sym src32-24-24-absolute- group - xmode)
4628 (src-24-operand Prefixed QI)
4629 (src-24-operand Prefixed HI)
4630 (src-24-operand Prefixed SI)
4632 (define-pmacro (src-24-indirect-operand xmode)
4634 ; (define-anyof-operand
4635 ; (name (.sym src32-24-8-indirect- xmode))
4636 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4637 ; (attrs (machine 32))
4640 ; (.sym src32-24-8-An-relative-indirect- xmode)
4641 ; (.sym src32-24-8-SB-relative-indirect- xmode)
4642 ; (.sym src32-24-8-FB-relative-indirect- xmode)
4645 ; (define-anyof-operand
4646 ; (name (.sym src32-24-16-indirect- xmode))
4647 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4648 ; (attrs (machine 32))
4651 ; (.sym src32-24-16-An-relative-indirect- xmode)
4652 ; (.sym src32-24-16-SB-relative-indirect- xmode)
4653 ; (.sym src32-24-16-FB-relative-indirect- xmode)
4656 ; (define-anyof-operand
4657 ; (name (.sym src32-24-24-indirect- xmode))
4658 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4659 ; (attrs (machine 32))
4662 ; (.sym src32-24-24-An-relative-indirect- xmode)
4665 ; (define-anyof-operand
4666 ; (name (.sym src32-24-16-absolute-indirect- xmode))
4667 ; (comment (.str "m32c source operand of size " xmode " 16 bit absolute indirect"))
4668 ; (attrs (machine 32))
4671 ; (.sym src32-24-16-absolute-indirect-derived- xmode)
4674 ; (define-anyof-operand
4675 ; (name (.sym src32-24-24-absolute-indirect- xmode))
4676 ; (comment (.str "m32c source operand of size " xmode " 24 bit absolute indirect"))
4677 ; (attrs (machine 32))
4680 ; (.sym src32-24-24-absolute-indirect-derived- xmode)
4686 ; (src-24-indirect-operand QI)
4687 ; (src-24-indirect-operand HI)
4688 ; (src-24-indirect-operand SI)
4690 ;-------------------------------------------------------------
4691 ; Destination operands with no additional fields
4692 ;-------------------------------------------------------------
4694 (define-pmacro (dst16-basic-operand xmode)
4696 (define-anyof-operand
4697 (name (.sym dst16-basic- xmode))
4698 (comment (.str "m16c destination operand of size " xmode " with no additional fields"))
4699 (attrs (machine 16))
4702 (.sym dst16-Rn-direct- xmode)
4703 (.sym dst16-An-direct- xmode)
4704 (.sym dst16-An-indirect- xmode)
4710 (dst16-basic-operand QI)
4711 (dst16-basic-operand HI)
4712 (dst16-basic-operand SI)
4714 (define-pmacro (dst32-basic-operand xmode)
4716 (define-anyof-operand
4717 (name (.sym dst32-basic-Unprefixed- xmode))
4718 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4719 (attrs (machine 32))
4722 (.sym dst32-Rn-direct-Unprefixed- xmode)
4723 (.sym dst32-An-direct-Unprefixed- xmode)
4724 (.sym dst32-An-indirect-Unprefixed- xmode)
4727 (define-anyof-operand
4728 (name (.sym dst32-basic-Prefixed- xmode))
4729 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4730 (attrs (machine 32))
4733 (.sym dst32-Rn-direct-Prefixed- xmode)
4734 (.sym dst32-An-direct-Prefixed- xmode)
4735 (.sym dst32-An-indirect-Prefixed- xmode)
4741 (dst32-basic-operand QI)
4742 (dst32-basic-operand HI)
4743 (dst32-basic-operand SI)
4745 ;-------------------------------------------------------------
4746 ; Destination operands with possible additional fields at offset 16 bits
4747 ;-------------------------------------------------------------
4749 (define-pmacro (dst16-16-operand xmode)
4751 (define-anyof-operand
4752 (name (.sym dst16-16- xmode))
4753 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4754 (attrs (machine 16))
4757 (.sym dst16-Rn-direct- xmode)
4758 (.sym dst16-An-direct- xmode)
4759 (.sym dst16-An-indirect- xmode)
4760 (.sym dst16-16-8-An-relative- xmode)
4761 (.sym dst16-16-16-An-relative- xmode)
4762 (.sym dst16-16-8-SB-relative- xmode)
4763 (.sym dst16-16-16-SB-relative- xmode)
4764 (.sym dst16-16-8-FB-relative- xmode)
4765 (.sym dst16-16-16-absolute- xmode)
4768 (define-anyof-operand
4769 (name (.sym dst16-16-8- xmode))
4770 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4771 (attrs (machine 16))
4774 (.sym dst16-16-8-An-relative- xmode)
4775 (.sym dst16-16-8-SB-relative- xmode)
4776 (.sym dst16-16-8-FB-relative- xmode)
4779 (define-anyof-operand
4780 (name (.sym dst16-16-16- xmode))
4781 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4782 (attrs (machine 16))
4785 (.sym dst16-16-16-An-relative- xmode)
4786 (.sym dst16-16-16-SB-relative- xmode)
4787 (.sym dst16-16-16-absolute- xmode)
4790 (define-anyof-operand
4791 (name (.sym dst16-16-16sa- xmode))
4792 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4793 (attrs (machine 16))
4796 (.sym dst16-16-16-SB-relative- xmode)
4797 (.sym dst16-16-16-absolute- xmode)
4800 (define-anyof-operand
4801 (name (.sym dst16-16-20ar- xmode))
4802 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4803 (attrs (machine 16))
4806 (.sym dst16-16-20-An-relative- xmode)
4812 (dst16-16-operand QI)
4813 (dst16-16-operand HI)
4814 (dst16-16-operand SI)
4816 (define-anyof-operand
4817 (name dst16-16-Ext-QI)
4818 (comment "m16c destination operand of size QI for 'ext' insns with additional fields at offset 16")
4819 (attrs (machine 16))
4822 dst16-Rn-direct-Ext-QI
4823 dst16-An-indirect-Ext-QI
4824 dst16-16-8-An-relative-Ext-QI
4825 dst16-16-16-An-relative-Ext-QI
4826 dst16-16-8-SB-relative-Ext-QI
4827 dst16-16-16-SB-relative-Ext-QI
4828 dst16-16-8-FB-relative-Ext-QI
4829 dst16-16-16-absolute-Ext-QI
4833 (define-derived-operand
4834 (name dst16-An-indirect-Mova-HI)
4835 (comment "m16c addressof An indirect destination HI")
4839 (syntax "[$Dst16An]")
4840 (base-ifield f-12-4)
4841 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
4843 (andif (eq f-12-2 1) (eq f-14-1 1)))
4848 (define-derived-operand
4849 (name dst16-16-8-An-relative-Mova-HI)
4851 "m16c addressof dsp:8[An] relative destination HI")
4854 (args (Dst16An Dsp-16-u8))
4855 (syntax "${Dsp-16-u8}[$Dst16An]")
4856 (base-ifield f-12-4)
4858 (+ (f-12-2 2) (f-14-1 0) Dsp-16-u8 Dst16An))
4860 (andif (eq f-12-2 2) (eq f-14-1 0)))
4861 (getter (add Dsp-16-u8 Dst16An))
4864 (define-derived-operand
4865 (name dst16-16-16-An-relative-Mova-HI)
4867 "m16c addressof dsp:16[An] relative destination HI")
4870 (args (Dst16An Dsp-16-u16))
4871 (syntax "${Dsp-16-u16}[$Dst16An]")
4872 (base-ifield f-12-4)
4874 (+ (f-12-2 3) (f-14-1 0) Dsp-16-u16 Dst16An))
4876 (andif (eq f-12-2 3) (eq f-14-1 0)))
4877 (getter (add Dsp-16-u16 Dst16An))
4880 (define-derived-operand
4881 (name dst16-16-8-SB-relative-Mova-HI)
4883 "m16c addressof dsp:8[sb] relative destination HI")
4887 (syntax "${Dsp-16-u8}[sb]")
4888 (base-ifield f-12-4)
4889 (encoding (+ (f-12-4 10) Dsp-16-u8))
4890 (ifield-assertion (eq f-12-4 10))
4891 (getter (add Dsp-16-u8 (reg h-sb)))
4894 (define-derived-operand
4895 (name dst16-16-16-SB-relative-Mova-HI)
4897 "m16c addressof dsp:16[sb] relative destination HI")
4901 (syntax "${Dsp-16-u16}[sb]")
4902 (base-ifield f-12-4)
4903 (encoding (+ (f-12-4 14) Dsp-16-u16))
4904 (ifield-assertion (eq f-12-4 14))
4905 (getter (add Dsp-16-u16 (reg h-sb)))
4908 (define-derived-operand
4909 (name dst16-16-8-FB-relative-Mova-HI)
4911 "m16c addressof dsp:8[fb] relative destination HI")
4915 (syntax "${Dsp-16-s8}[fb]")
4916 (base-ifield f-12-4)
4917 (encoding (+ (f-12-4 11) Dsp-16-s8))
4918 (ifield-assertion (eq f-12-4 11))
4919 (getter (add Dsp-16-s8 (reg h-fb)))
4922 (define-derived-operand
4923 (name dst16-16-16-absolute-Mova-HI)
4924 (comment "m16c addressof absolute address HI")
4928 (syntax "${Dsp-16-u16}")
4929 (base-ifield f-12-4)
4930 (encoding (+ (f-12-4 15) Dsp-16-u16))
4931 (ifield-assertion (eq f-12-4 15))
4936 (define-anyof-operand
4937 (name dst16-16-Mova-HI)
4938 (comment "m16c addressof destination operand of size HI with additional fields at offset 16")
4939 (attrs (machine 16))
4942 dst16-An-indirect-Mova-HI
4943 dst16-16-8-An-relative-Mova-HI
4944 dst16-16-16-An-relative-Mova-HI
4945 dst16-16-8-SB-relative-Mova-HI
4946 dst16-16-16-SB-relative-Mova-HI
4947 dst16-16-8-FB-relative-Mova-HI
4948 dst16-16-16-absolute-Mova-HI
4952 (define-derived-operand
4953 (name dst32-An-indirect-Unprefixed-Mova-SI)
4954 (comment "m32c addressof An indirect destination SI")
4957 (args (Dst32AnUnprefixed))
4958 (syntax "[$Dst32AnUnprefixed]")
4961 (+ (f-4-3 0) (f-8-1 0) Dst32AnUnprefixed))
4963 (andif (eq f-4-3 0) (eq f-8-1 0)))
4964 (getter Dst32AnUnprefixed)
4968 (define-derived-operand
4969 (name dst32-16-8-An-relative-Unprefixed-Mova-SI)
4970 (comment "m32c addressof dsp:8[An] relative destination SI")
4973 (args (Dst32AnUnprefixed Dsp-16-u8))
4974 (syntax "${Dsp-16-u8}[$Dst32AnUnprefixed]")
4982 (andif (eq f-4-3 1) (eq f-8-1 0)))
4983 (getter (add Dsp-16-u8 Dst32AnUnprefixed))
4987 (define-derived-operand
4988 (name dst32-16-16-An-relative-Unprefixed-Mova-SI)
4990 "m32c addressof dsp:16[An] relative destination SI")
4993 (args (Dst32AnUnprefixed Dsp-16-u16))
4994 (syntax "${Dsp-16-u16}[$Dst32AnUnprefixed]")
5002 (andif (eq f-4-3 2) (eq f-8-1 0)))
5003 (getter (add Dsp-16-u16 Dst32AnUnprefixed))
5007 (define-derived-operand
5008 (name dst32-16-24-An-relative-Unprefixed-Mova-SI)
5009 (comment "addressof m32c dsp:16[An] relative destination SI")
5012 (args (Dst32AnUnprefixed Dsp-16-u24))
5013 (syntax "${Dsp-16-u24}[$Dst32AnUnprefixed]")
5021 (andif (eq f-4-3 3) (eq f-8-1 0)))
5022 (getter (add Dsp-16-u24 Dst32AnUnprefixed))
5026 (define-derived-operand
5027 (name dst32-16-8-SB-relative-Unprefixed-Mova-SI)
5028 (comment "m32c addressof dsp:8[sb] relative destination SI")
5032 (syntax "${Dsp-16-u8}[sb]")
5034 (encoding (+ (f-4-3 1) (f-8-2 2) Dsp-16-u8))
5036 (andif (eq f-4-3 1) (eq f-8-2 2)))
5037 (getter (add Dsp-16-u8 (reg h-sb)))
5041 (define-derived-operand
5042 (name dst32-16-16-SB-relative-Unprefixed-Mova-SI)
5043 (comment "m32c addressof dsp:16[sb] relative destination SI")
5047 (syntax "${Dsp-16-u16}[sb]")
5049 (encoding (+ (f-4-3 2) (f-8-2 2) Dsp-16-u16))
5051 (andif (eq f-4-3 2) (eq f-8-2 2)))
5052 (getter (add Dsp-16-u16 (reg h-sb)))
5056 (define-derived-operand
5057 (name dst32-16-8-FB-relative-Unprefixed-Mova-SI)
5058 (comment "m32c addressof dsp:8[fb] relative destination SI")
5062 (syntax "${Dsp-16-s8}[fb]")
5064 (encoding (+ (f-4-3 1) (f-8-2 3) Dsp-16-s8))
5066 (andif (eq f-4-3 1) (eq f-8-2 3)))
5067 (getter (add Dsp-16-s8 (reg h-fb)))
5071 (define-derived-operand
5072 (name dst32-16-16-FB-relative-Unprefixed-Mova-SI)
5073 (comment "m32c addressof dsp:16[fb] relative destination SI")
5077 (syntax "${Dsp-16-s16}[fb]")
5079 (encoding (+ (f-4-3 2) (f-8-2 3) Dsp-16-s16))
5081 (andif (eq f-4-3 2) (eq f-8-2 3)))
5082 (getter (add Dsp-16-s16 (reg h-fb)))
5086 (define-derived-operand
5087 (name dst32-16-16-absolute-Unprefixed-Mova-SI)
5088 (comment "m32c addressof absolute address SI") (attrs (ISA m32c))
5091 (syntax "${Dsp-16-u16}")
5093 (encoding (+ (f-4-3 3) (f-8-2 3) Dsp-16-u16))
5095 (andif (eq f-4-3 3) (eq f-8-2 3)))
5100 (define-derived-operand
5101 (name dst32-16-24-absolute-Unprefixed-Mova-SI)
5102 (comment "m32c addressof absolute address SI") (attrs (ISA m32c))
5105 (syntax "${Dsp-16-u24}")
5107 (encoding (+ (f-4-3 3) (f-8-2 2) Dsp-16-u24))
5109 (andif (eq f-4-3 3) (eq f-8-2 2)))
5114 (define-anyof-operand
5115 (name dst32-16-Unprefixed-Mova-SI)
5117 "m32c addressof destination operand of size SI with additional fields at offset 16")
5121 dst32-An-indirect-Unprefixed-Mova-SI
5122 dst32-16-8-An-relative-Unprefixed-Mova-SI
5123 dst32-16-16-An-relative-Unprefixed-Mova-SI
5124 dst32-16-24-An-relative-Unprefixed-Mova-SI
5125 dst32-16-8-SB-relative-Unprefixed-Mova-SI
5126 dst32-16-16-SB-relative-Unprefixed-Mova-SI
5127 dst32-16-8-FB-relative-Unprefixed-Mova-SI
5128 dst32-16-16-FB-relative-Unprefixed-Mova-SI
5129 dst32-16-16-absolute-Unprefixed-Mova-SI
5130 dst32-16-24-absolute-Unprefixed-Mova-SI))
5132 (define-pmacro (dst32-16-operand xmode)
5134 (define-anyof-operand
5135 (name (.sym dst32-16-Unprefixed- xmode))
5136 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5137 (attrs (machine 32))
5140 (.sym dst32-Rn-direct-Unprefixed- xmode)
5141 (.sym dst32-An-direct-Unprefixed- xmode)
5142 (.sym dst32-An-indirect-Unprefixed- xmode)
5143 (.sym dst32-16-8-An-relative-Unprefixed- xmode)
5144 (.sym dst32-16-16-An-relative-Unprefixed- xmode)
5145 (.sym dst32-16-24-An-relative-Unprefixed- xmode)
5146 (.sym dst32-16-8-SB-relative-Unprefixed- xmode)
5147 (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
5148 (.sym dst32-16-8-FB-relative-Unprefixed- xmode)
5149 (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
5150 (.sym dst32-16-16-absolute-Unprefixed- xmode)
5151 (.sym dst32-16-24-absolute-Unprefixed- xmode)
5154 (define-anyof-operand
5155 (name (.sym dst32-16-8-Unprefixed- xmode))
5156 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5157 (attrs (machine 32))
5160 (.sym dst32-16-8-An-relative-Unprefixed- xmode)
5161 (.sym dst32-16-8-SB-relative-Unprefixed- xmode)
5162 (.sym dst32-16-8-FB-relative-Unprefixed- xmode)
5165 (define-anyof-operand
5166 (name (.sym dst32-16-16-Unprefixed- xmode))
5167 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5168 (attrs (machine 32))
5171 (.sym dst32-16-16-An-relative-Unprefixed- xmode)
5172 (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
5173 (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
5174 (.sym dst32-16-16-absolute-Unprefixed- xmode)
5177 (define-anyof-operand
5178 (name (.sym dst32-16-16sa-Unprefixed- xmode))
5179 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5180 (attrs (machine 32))
5183 (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
5184 (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
5185 (.sym dst32-16-16-absolute-Unprefixed- xmode)
5188 (define-anyof-operand
5189 (name (.sym dst32-16-24-Unprefixed- xmode))
5190 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5191 (attrs (machine 32))
5194 (.sym dst32-16-24-An-relative-Unprefixed- xmode)
5195 (.sym dst32-16-24-absolute-Unprefixed- xmode)
5201 (dst32-16-operand QI)
5202 (dst32-16-operand HI)
5203 (dst32-16-operand SI)
5205 (define-pmacro (dst32-16-Ext-operand smode dmode)
5207 (define-anyof-operand
5208 (name (.sym dst32-16-ExtUnprefixed- smode))
5209 (comment (.str "m32c destination operand of size " smode " with additional fields at offset 16"))
5210 (attrs (machine 32))
5213 (.sym dst32-Rn-direct-ExtUnprefixed- smode)
5214 (.sym dst32-An-direct-Unprefixed- dmode) ; ExtUnprefixed mode not required for this operand -- use the normal dmode version
5215 (.sym dst32-An-indirect-ExtUnprefixed- smode)
5216 (.sym dst32-16-8-An-relative-ExtUnprefixed- smode)
5217 (.sym dst32-16-16-An-relative-ExtUnprefixed- smode)
5218 (.sym dst32-16-24-An-relative-ExtUnprefixed- smode)
5219 (.sym dst32-16-8-SB-relative-ExtUnprefixed- smode)
5220 (.sym dst32-16-16-SB-relative-ExtUnprefixed- smode)
5221 (.sym dst32-16-8-FB-relative-ExtUnprefixed- smode)
5222 (.sym dst32-16-16-FB-relative-ExtUnprefixed- smode)
5223 (.sym dst32-16-16-absolute-ExtUnprefixed- smode)
5224 (.sym dst32-16-24-absolute-ExtUnprefixed- smode)
5230 (dst32-16-Ext-operand QI HI)
5231 (dst32-16-Ext-operand HI SI)
5233 (define-anyof-operand
5234 (name dst32-16-Unprefixed-Mulex-HI)
5235 (comment "m32c destination operand of size HI with additional fields at offset 16")
5236 (attrs (machine 32))
5239 dst32-R3-direct-Unprefixed-HI
5240 dst32-An-direct-Unprefixed-HI
5241 dst32-An-indirect-Unprefixed-HI
5242 dst32-16-8-An-relative-Unprefixed-HI
5243 dst32-16-16-An-relative-Unprefixed-HI
5244 dst32-16-24-An-relative-Unprefixed-HI
5245 dst32-16-8-SB-relative-Unprefixed-HI
5246 dst32-16-16-SB-relative-Unprefixed-HI
5247 dst32-16-8-FB-relative-Unprefixed-HI
5248 dst32-16-16-FB-relative-Unprefixed-HI
5249 dst32-16-16-absolute-Unprefixed-HI
5250 dst32-16-24-absolute-Unprefixed-HI
5253 ;-------------------------------------------------------------
5254 ; Destination operands with possible additional fields at offset 24 bits
5255 ;-------------------------------------------------------------
5257 (define-pmacro (dst16-24-operand xmode)
5259 (define-anyof-operand
5260 (name (.sym dst16-24- xmode))
5261 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 24"))
5262 (attrs (machine 16))
5265 (.sym dst16-Rn-direct- xmode)
5266 (.sym dst16-An-direct- xmode)
5267 (.sym dst16-An-indirect- xmode)
5268 (.sym dst16-24-8-An-relative- xmode)
5269 (.sym dst16-24-16-An-relative- xmode)
5270 (.sym dst16-24-8-SB-relative- xmode)
5271 (.sym dst16-24-16-SB-relative- xmode)
5272 (.sym dst16-24-8-FB-relative- xmode)
5273 (.sym dst16-24-16-absolute- xmode)
5279 (dst16-24-operand QI)
5280 (dst16-24-operand HI)
5282 (define-pmacro (dst32-24-operand xmode)
5284 (define-anyof-operand
5285 (name (.sym dst32-24-Unprefixed- xmode))
5286 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5287 (attrs (machine 32))
5290 (.sym dst32-Rn-direct-Unprefixed- xmode)
5291 (.sym dst32-An-direct-Unprefixed- xmode)
5292 (.sym dst32-An-indirect-Unprefixed- xmode)
5293 (.sym dst32-24-8-An-relative-Unprefixed- xmode)
5294 (.sym dst32-24-16-An-relative-Unprefixed- xmode)
5295 (.sym dst32-24-24-An-relative-Unprefixed- xmode)
5296 (.sym dst32-24-8-SB-relative-Unprefixed- xmode)
5297 (.sym dst32-24-16-SB-relative-Unprefixed- xmode)
5298 (.sym dst32-24-8-FB-relative-Unprefixed- xmode)
5299 (.sym dst32-24-16-FB-relative-Unprefixed- xmode)
5300 (.sym dst32-24-16-absolute-Unprefixed- xmode)
5301 (.sym dst32-24-24-absolute-Unprefixed- xmode)
5304 (define-anyof-operand
5305 (name (.sym dst32-24-Prefixed- xmode))
5306 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5307 (attrs (machine 32))
5310 (.sym dst32-Rn-direct-Prefixed- xmode)
5311 (.sym dst32-An-direct-Prefixed- xmode)
5312 (.sym dst32-An-indirect-Prefixed- xmode)
5313 (.sym dst32-24-8-An-relative-Prefixed- xmode)
5314 (.sym dst32-24-16-An-relative-Prefixed- xmode)
5315 (.sym dst32-24-24-An-relative-Prefixed- xmode)
5316 (.sym dst32-24-8-SB-relative-Prefixed- xmode)
5317 (.sym dst32-24-16-SB-relative-Prefixed- xmode)
5318 (.sym dst32-24-8-FB-relative-Prefixed- xmode)
5319 (.sym dst32-24-16-FB-relative-Prefixed- xmode)
5320 (.sym dst32-24-16-absolute-Prefixed- xmode)
5321 (.sym dst32-24-24-absolute-Prefixed- xmode)
5324 (define-anyof-operand
5325 (name (.sym dst32-24-8-Prefixed- xmode))
5326 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5327 (attrs (machine 32))
5330 (.sym dst32-24-8-An-relative-Prefixed- xmode)
5331 (.sym dst32-24-8-SB-relative-Prefixed- xmode)
5332 (.sym dst32-24-8-FB-relative-Prefixed- xmode)
5335 (define-anyof-operand
5336 (name (.sym dst32-24-16-Prefixed- xmode))
5337 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5338 (attrs (machine 32))
5341 (.sym dst32-24-16-An-relative-Prefixed- xmode)
5342 (.sym dst32-24-16-SB-relative-Prefixed- xmode)
5343 (.sym dst32-24-16-FB-relative-Prefixed- xmode)
5344 (.sym dst32-24-16-absolute-Prefixed- xmode)
5347 (define-anyof-operand
5348 (name (.sym dst32-24-24-Prefixed- xmode))
5349 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5350 (attrs (machine 32))
5353 (.sym dst32-24-24-An-relative-Prefixed- xmode)
5354 (.sym dst32-24-24-absolute-Prefixed- xmode)
5357 ; (define-anyof-operand
5358 ; (name (.sym dst32-24-indirect- xmode))
5359 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5360 ; (attrs (machine 32))
5363 ; (.sym dst32-An-indirect-indirect- xmode)
5364 ; (.sym dst32-24-8-An-relative-indirect- xmode)
5365 ; (.sym dst32-24-16-An-relative-indirect- xmode)
5366 ; (.sym dst32-24-24-An-relative-indirect- xmode)
5367 ; (.sym dst32-24-8-SB-relative-indirect- xmode)
5368 ; (.sym dst32-24-16-SB-relative-indirect- xmode)
5369 ; (.sym dst32-24-8-FB-relative-indirect- xmode)
5370 ; (.sym dst32-24-16-FB-relative-indirect- xmode)
5373 ; (define-anyof-operand
5374 ; (name (.sym dst32-basic-indirect- xmode))
5375 ; (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
5376 ; (attrs (machine 32))
5379 ; (.sym dst32-An-indirect-indirect- xmode)
5382 ; (define-anyof-operand
5383 ; (name (.sym dst32-24-8-indirect- xmode))
5384 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5385 ; (attrs (machine 32))
5388 ; (.sym dst32-24-8-An-relative-indirect- xmode)
5389 ; (.sym dst32-24-8-SB-relative-indirect- xmode)
5390 ; (.sym dst32-24-8-FB-relative-indirect- xmode)
5393 ; (define-anyof-operand
5394 ; (name (.sym dst32-24-16-indirect- xmode))
5395 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5396 ; (attrs (machine 32))
5399 ; (.sym dst32-24-16-An-relative-indirect- xmode)
5400 ; (.sym dst32-24-16-SB-relative-indirect- xmode)
5401 ; (.sym dst32-24-16-FB-relative-indirect- xmode)
5404 ; (define-anyof-operand
5405 ; (name (.sym dst32-24-24-indirect- xmode))
5406 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5407 ; (attrs (machine 32))
5410 ; (.sym dst32-24-24-An-relative-indirect- xmode)
5413 ; (define-anyof-operand
5414 ; (name (.sym dst32-24-absolute-indirect- xmode))
5415 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5416 ; (attrs (machine 32))
5419 ; (.sym dst32-24-16-absolute-indirect-derived- xmode)
5420 ; (.sym dst32-24-24-absolute-indirect-derived- xmode)
5423 ; (define-anyof-operand
5424 ; (name (.sym dst32-24-16-absolute-indirect- xmode))
5425 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5426 ; (attrs (machine 32))
5429 ; (.sym dst32-24-16-absolute-indirect-derived- xmode)
5432 ; (define-anyof-operand
5433 ; (name (.sym dst32-24-24-absolute-indirect- xmode))
5434 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5435 ; (attrs (machine 32))
5438 ; (.sym dst32-24-24-absolute-indirect-derived- xmode)
5444 (dst32-24-operand QI)
5445 (dst32-24-operand HI)
5446 (dst32-24-operand SI)
5448 ;-------------------------------------------------------------
5449 ; Destination operands with possible additional fields at offset 32 bits
5450 ;-------------------------------------------------------------
5452 (define-pmacro (dst16-32-operand xmode)
5454 (define-anyof-operand
5455 (name (.sym dst16-32- xmode))
5456 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 32"))
5457 (attrs (machine 16))
5460 (.sym dst16-Rn-direct- xmode)
5461 (.sym dst16-An-direct- xmode)
5462 (.sym dst16-An-indirect- xmode)
5463 (.sym dst16-32-8-An-relative- xmode)
5464 (.sym dst16-32-16-An-relative- xmode)
5465 (.sym dst16-32-8-SB-relative- xmode)
5466 (.sym dst16-32-16-SB-relative- xmode)
5467 (.sym dst16-32-8-FB-relative- xmode)
5468 (.sym dst16-32-16-absolute- xmode)
5473 (dst16-32-operand QI)
5474 (dst16-32-operand HI)
5476 ; This macro actually handles operands at offset 32, 40 and 48 bits
5477 (define-pmacro (dst32-32plus-operand offset xmode)
5479 (define-anyof-operand
5480 (name (.sym dst32- offset -Unprefixed- xmode))
5481 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5482 (attrs (machine 32))
5485 (.sym dst32-Rn-direct-Unprefixed- xmode)
5486 (.sym dst32-An-direct-Unprefixed- xmode)
5487 (.sym dst32-An-indirect-Unprefixed- xmode)
5488 (.sym dst32- offset -8-An-relative-Unprefixed- xmode)
5489 (.sym dst32- offset -16-An-relative-Unprefixed- xmode)
5490 (.sym dst32- offset -24-An-relative-Unprefixed- xmode)
5491 (.sym dst32- offset -8-SB-relative-Unprefixed- xmode)
5492 (.sym dst32- offset -16-SB-relative-Unprefixed- xmode)
5493 (.sym dst32- offset -8-FB-relative-Unprefixed- xmode)
5494 (.sym dst32- offset -16-FB-relative-Unprefixed- xmode)
5495 (.sym dst32- offset -16-absolute-Unprefixed- xmode)
5496 (.sym dst32- offset -24-absolute-Unprefixed- xmode)
5499 (define-anyof-operand
5500 (name (.sym dst32- offset -Prefixed- xmode))
5501 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5502 (attrs (machine 32))
5505 (.sym dst32-Rn-direct-Prefixed- xmode)
5506 (.sym dst32-An-direct-Prefixed- xmode)
5507 (.sym dst32-An-indirect-Prefixed- xmode)
5508 (.sym dst32- offset -8-An-relative-Prefixed- xmode)
5509 (.sym dst32- offset -16-An-relative-Prefixed- xmode)
5510 (.sym dst32- offset -24-An-relative-Prefixed- xmode)
5511 (.sym dst32- offset -8-SB-relative-Prefixed- xmode)
5512 (.sym dst32- offset -16-SB-relative-Prefixed- xmode)
5513 (.sym dst32- offset -8-FB-relative-Prefixed- xmode)
5514 (.sym dst32- offset -16-FB-relative-Prefixed- xmode)
5515 (.sym dst32- offset -16-absolute-Prefixed- xmode)
5516 (.sym dst32- offset -24-absolute-Prefixed- xmode)
5519 ; (define-anyof-operand
5520 ; (name (.sym dst32- offset -indirect- xmode))
5521 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5522 ; (attrs (machine 32))
5525 ; (.sym dst32-An-indirect-indirect- xmode)
5526 ; (.sym dst32- offset -8-An-relative-indirect- xmode)
5527 ; (.sym dst32- offset -16-An-relative-indirect- xmode)
5528 ; (.sym dst32- offset -24-An-relative-indirect- xmode)
5529 ; (.sym dst32- offset -8-SB-relative-indirect- xmode)
5530 ; (.sym dst32- offset -16-SB-relative-indirect- xmode)
5531 ; (.sym dst32- offset -8-FB-relative-indirect- xmode)
5532 ; (.sym dst32- offset -16-FB-relative-indirect- xmode)
5535 ; (define-anyof-operand
5536 ; (name (.sym dst32- offset -absolute-indirect- xmode))
5537 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5538 ; (attrs (machine 32))
5541 ; (.sym dst32- offset -16-absolute-indirect-derived- xmode)
5542 ; (.sym dst32- offset -24-absolute-indirect-derived- xmode)
5548 (dst32-32plus-operand 32 QI)
5549 (dst32-32plus-operand 32 HI)
5550 (dst32-32plus-operand 32 SI)
5551 (dst32-32plus-operand 40 QI)
5552 (dst32-32plus-operand 40 HI)
5553 (dst32-32plus-operand 40 SI)
5555 ;-------------------------------------------------------------
5556 ; Destination operands with possible additional fields at offset 48 bits
5557 ;-------------------------------------------------------------
5559 (define-pmacro (dst32-48-operand offset xmode)
5561 (define-anyof-operand
5562 (name (.sym dst32- offset -Prefixed- xmode))
5563 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5564 (attrs (machine 32))
5567 (.sym dst32-Rn-direct-Prefixed- xmode)
5568 (.sym dst32-An-direct-Prefixed- xmode)
5569 (.sym dst32-An-indirect-Prefixed- xmode)
5570 (.sym dst32- offset -8-An-relative-Prefixed- xmode)
5571 (.sym dst32- offset -16-An-relative-Prefixed- xmode)
5572 (.sym dst32- offset -24-An-relative-Prefixed- xmode)
5573 (.sym dst32- offset -8-SB-relative-Prefixed- xmode)
5574 (.sym dst32- offset -16-SB-relative-Prefixed- xmode)
5575 (.sym dst32- offset -8-FB-relative-Prefixed- xmode)
5576 (.sym dst32- offset -16-FB-relative-Prefixed- xmode)
5577 (.sym dst32- offset -16-absolute-Prefixed- xmode)
5578 (.sym dst32- offset -24-absolute-Prefixed- xmode)
5581 ; (define-anyof-operand
5582 ; (name (.sym dst32- offset -indirect- xmode))
5583 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5584 ; (attrs (machine 32))
5587 ; (.sym dst32-An-indirect-indirect- xmode)
5588 ; (.sym dst32- offset -8-An-relative-indirect- xmode)
5589 ; (.sym dst32- offset -16-An-relative-indirect- xmode)
5590 ; (.sym dst32- offset -24-An-relative-indirect- xmode)
5591 ; (.sym dst32- offset -8-SB-relative-indirect- xmode)
5592 ; (.sym dst32- offset -16-SB-relative-indirect- xmode)
5593 ; (.sym dst32- offset -8-FB-relative-indirect- xmode)
5594 ; (.sym dst32- offset -16-FB-relative-indirect- xmode)
5597 ; (define-anyof-operand
5598 ; (name (.sym dst32- offset -absolute-indirect- xmode))
5599 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5600 ; (attrs (machine 32))
5603 ; (.sym dst32- offset -16-absolute-indirect-derived- xmode)
5604 ; (.sym dst32- offset -24-absolute-indirect-derived- xmode)
5610 (dst32-48-operand 48 QI)
5611 (dst32-48-operand 48 HI)
5612 (dst32-48-operand 48 SI)
5614 ;-------------------------------------------------------------
5615 ; Bit operands for m16c
5616 ;-------------------------------------------------------------
5618 (define-pmacro (bit16-operand offset)
5620 (define-anyof-operand
5621 (name (.sym bit16- offset))
5622 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5623 (attrs (machine 16))
5629 (.sym bit16- offset -8-An-relative)
5630 (.sym bit16- offset -16-An-relative)
5631 (.sym bit16- offset -8-SB-relative)
5632 (.sym bit16- offset -16-SB-relative)
5633 (.sym bit16- offset -8-FB-relative)
5634 (.sym bit16- offset -16-absolute)
5637 (define-anyof-operand
5638 (name (.sym bit16- offset -basic))
5639 (comment (.str "m16c bit operand with no additional fields"))
5640 (attrs (machine 16))
5646 (define-anyof-operand
5647 (name (.sym bit16- offset -8))
5648 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5649 (attrs (machine 16))
5654 (.sym bit16- offset -8-An-relative)
5655 (.sym bit16- offset -8-SB-relative)
5656 (.sym bit16- offset -8-FB-relative)
5659 (define-anyof-operand
5660 (name (.sym bit16- offset -16))
5661 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5662 (attrs (machine 16))
5665 (.sym bit16- offset -16-An-relative)
5666 (.sym bit16- offset -16-SB-relative)
5667 (.sym bit16- offset -16-absolute)
5675 ;-------------------------------------------------------------
5676 ; Bit operands for m32c
5677 ;-------------------------------------------------------------
5679 (define-pmacro (bit32-operand offset group)
5681 (define-anyof-operand
5682 (name (.sym bit32- offset - group))
5683 (comment (.str "m32c bit operand with possible additional fields at offset 24"))
5684 (attrs (machine 32))
5687 (.sym bit32-Rn-direct- group)
5688 (.sym bit32-An-direct- group)
5689 (.sym bit32-An-indirect- group)
5690 (.sym bit32- offset -11-An-relative- group)
5691 (.sym bit32- offset -19-An-relative- group)
5692 (.sym bit32- offset -27-An-relative- group)
5693 (.sym bit32- offset -11-SB-relative- group)
5694 (.sym bit32- offset -19-SB-relative- group)
5695 (.sym bit32- offset -11-FB-relative- group)
5696 (.sym bit32- offset -19-FB-relative- group)
5697 (.sym bit32- offset -19-absolute- group)
5698 (.sym bit32- offset -27-absolute- group)
5704 (bit32-operand 16 Unprefixed)
5705 (bit32-operand 24 Prefixed)
5707 (define-anyof-operand
5708 (name bit32-basic-Unprefixed)
5709 (comment "m32c bit operand with no additional fields")
5710 (attrs (machine 32))
5713 bit32-Rn-direct-Unprefixed
5714 bit32-An-direct-Unprefixed
5715 bit32-An-indirect-Unprefixed
5719 (define-anyof-operand
5720 (name bit32-16-8-Unprefixed)
5721 (comment "m32c bit operand with 8 bit additional fields")
5722 (attrs (machine 32))
5725 bit32-16-11-An-relative-Unprefixed
5726 bit32-16-11-SB-relative-Unprefixed
5727 bit32-16-11-FB-relative-Unprefixed
5731 (define-anyof-operand
5732 (name bit32-16-16-Unprefixed)
5733 (comment "m32c bit operand with 16 bit additional fields")
5734 (attrs (machine 32))
5737 bit32-16-19-An-relative-Unprefixed
5738 bit32-16-19-SB-relative-Unprefixed
5739 bit32-16-19-FB-relative-Unprefixed
5740 bit32-16-19-absolute-Unprefixed
5744 (define-anyof-operand
5745 (name bit32-16-24-Unprefixed)
5746 (comment "m32c bit operand with 24 bit additional fields")
5747 (attrs (machine 32))
5750 bit32-16-27-An-relative-Unprefixed
5751 bit32-16-27-absolute-Unprefixed
5755 ;-------------------------------------------------------------
5756 ; Operands for short format binary insns
5757 ;-------------------------------------------------------------
5759 (define-anyof-operand
5761 (comment "m16c source operand of size QI for short format insns")
5762 (attrs (machine 16))
5765 src16-2-S-8-SB-relative-QI
5766 src16-2-S-8-FB-relative-QI
5767 src16-2-S-16-absolute-QI
5771 (define-anyof-operand
5773 (comment "m32c source operand of size QI for short format insns")
5774 (attrs (machine 32))
5777 src32-2-S-8-SB-relative-QI
5778 src32-2-S-8-FB-relative-QI
5779 src32-2-S-16-absolute-QI
5783 (define-anyof-operand
5785 (comment "m32c source operand of size QI for short format insns")
5786 (attrs (machine 32))
5789 src32-2-S-8-SB-relative-HI
5790 src32-2-S-8-FB-relative-HI
5791 src32-2-S-16-absolute-HI
5795 (define-anyof-operand
5797 (comment "m16c destination operand of size QI for short format insns")
5798 (attrs (machine 16))
5801 dst16-3-S-R0l-direct-QI
5802 dst16-3-S-R0h-direct-QI
5803 dst16-3-S-8-8-SB-relative-QI
5804 dst16-3-S-8-8-FB-relative-QI
5805 dst16-3-S-8-16-absolute-QI
5809 (define-anyof-operand
5811 (comment "m16c destination operand of size QI for short format insns")
5812 (attrs (machine 16))
5815 dst16-3-S-R0l-direct-QI
5816 dst16-3-S-R0h-direct-QI
5817 dst16-3-S-16-8-SB-relative-QI
5818 dst16-3-S-16-8-FB-relative-QI
5819 dst16-3-S-16-16-absolute-QI
5823 (define-anyof-operand
5824 (name srcdst16-r0l-r0h-S)
5825 (comment "m16c r0l/r0h operand of size QI for short format insns")
5826 (attrs (machine 16))
5829 srcdst16-r0l-r0h-S-derived
5833 (define-anyof-operand
5834 (name dst32-2-S-basic-QI)
5835 (comment "m32c r0l operand of size QI for short format binary insns")
5836 (attrs (machine 32))
5839 dst32-2-S-R0l-direct-QI
5843 (define-anyof-operand
5844 (name dst32-2-S-basic-HI)
5845 (comment "m32c r0 operand of size HI for short format binary insns")
5846 (attrs (machine 32))
5849 dst32-2-S-R0-direct-HI
5853 (define-pmacro (dst32-2-S-operands xmode)
5855 (define-anyof-operand
5856 (name (.sym dst32-2-S-8- xmode))
5857 (comment "m32c operand of size " xmode " for short format binary insns")
5858 (attrs (machine 32))
5861 (.sym dst32-2-S-8-SB-relative- xmode)
5862 (.sym dst32-2-S-8-FB-relative- xmode)
5865 (define-anyof-operand
5866 (name (.sym dst32-2-S-16- xmode))
5867 (comment "m32c operand of size " xmode " for short format binary insns")
5868 (attrs (machine 32))
5871 (.sym dst32-2-S-16-absolute- xmode)
5874 ; (define-anyof-operand
5875 ; (name (.sym dst32-2-S-8-indirect- xmode))
5876 ; (comment "m32c operand of size " xmode " for short format binary insns")
5877 ; (attrs (machine 32))
5880 ; (.sym dst32-2-S-8-SB-relative-indirect- xmode)
5881 ; (.sym dst32-2-S-8-FB-relative-indirect- xmode)
5884 ; (define-anyof-operand
5885 ; (name (.sym dst32-2-S-absolute-indirect- xmode))
5886 ; (comment "m32c operand of size " xmode " for short format binary insns")
5887 ; (attrs (machine 32))
5890 ; (.sym dst32-2-S-16-absolute-indirect- xmode)
5896 (dst32-2-S-operands QI)
5897 (dst32-2-S-operands HI)
5898 (dst32-2-S-operands SI)
5900 (define-anyof-operand
5902 (comment "m32c An operand for short format binary insns")
5903 (attrs (machine 32))
5906 dst32-1-S-A0-direct-HI
5907 dst32-1-S-A1-direct-HI
5911 (define-anyof-operand
5913 (comment "m16c bit operand for short format insns")
5914 (attrs (machine 16))
5917 bit16-11-SB-relative-S
5921 (define-anyof-operand
5922 (name Rn16-push-S-anyof)
5923 (comment "m16c bit operand for short format insns")
5924 (attrs (machine 16))
5931 (define-anyof-operand
5932 (name An16-push-S-anyof)
5933 (comment "m16c bit operand for short format insns")
5934 (attrs (machine 16))
5941 ;=============================================================
5942 ; Common macros for instruction definitions
5944 (define-pmacro (set-z x)
5946 (set zbit (zflag x)))
5950 (define-pmacro (set-s x)
5952 (set sbit (nflag x)))
5955 (define-pmacro (set-z-and-s x)
5961 ;=============================================================
5963 ;-------------------------------------------------------------
5965 (define-pmacro (unary-insn-defn-g mach group mode wstr op encoding sem opg)
5966 (dni (.sym op mach wstr - group)
5967 (.str op wstr opg " dst" mach "-" group "-" mode)
5968 ((machine mach) RL_1ADDR)
5969 (.str op wstr opg " ${dst" mach "-" group "-" mode "}")
5971 (sem mode (.sym dst mach - group - mode))
5975 (define-pmacro (unary-insn-defn mach group mode wstr op encoding sem)
5976 (unary-insn-defn-g mach group mode wstr op encoding sem "")
5980 (define-pmacro (unary16-defn-g mode wstr wbit op opc1 opc2 opc3 sem opg)
5981 (unary-insn-defn-g 16 16 mode wstr op
5982 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16- mode))
5985 (define-pmacro (unary16-defn mode wstr wbit op opc1 opc2 opc3 sem)
5986 (unary-16-defn-g mode wstr wbit op opc1 opc2 opc3 sem "")
5989 (define-pmacro (unary32-defn-g mode wstr wbit op opc1 opc2 opc3 sem opg)
5991 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
5992 ; define the absolute-indirect insns first in order to prevent them from being selected
5993 ; when the mode is register-indirect
5994 ; (unary-insn-defn 32 24-absolute-indirect mode wstr op
5995 ; (+ (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))
5997 (unary-insn-defn-g 32 16-Unprefixed mode wstr op
5998 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3))
6000 ; (unary-insn-defn 32 24-indirect mode wstr op
6001 ; (+ (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))
6005 (define-pmacro (unary32-defn mode wstr wbit op opc1 opc2 opc3 sem)
6006 (unary32-defn-g mode wstr wbit op opc1 opc2 opc3 sem "")
6009 (define-pmacro (unary-insn-mach-g mach op opc1 opc2 opc3 sem opg)
6011 (.apply (.sym unary mach -defn-g) (QI .b 0 op opc1 opc2 opc3 sem opg))
6012 (.apply (.sym unary mach -defn-g) (HI .w 1 op opc1 opc2 opc3 sem opg))
6015 (define-pmacro (unary-insn-mach mach op opc1 opc2 opc3 sem)
6016 (unary-insn-mach-g mach op opc1 opc2 opc3 sem "")
6019 (define-pmacro (unary-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6021 (unary-insn-mach-g 16 op opc16-1 opc16-2 opc16-3 sem "")
6022 (unary-insn-mach-g 32 op opc32-1 opc32-2 opc32-3 sem "")
6026 (define-pmacro (unary-insn-g op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6028 (unary-insn-mach-g 16 op opc16-1 opc16-2 opc16-3 sem "$G")
6029 (unary-insn-mach-g 32 op opc32-1 opc32-2 opc32-3 sem "$G")
6033 ;-------------------------------------------------------------
6034 ; Sign/zero extension macros
6035 ;-------------------------------------------------------------
6037 (define-pmacro (ext-insn-defn mach group smode dmode wstr op encoding sem)
6038 (dni (.sym op mach wstr - group)
6039 (.str op wstr " dst" mach "-" group "-" smode)
6041 (.str op wstr " ${dst" mach "-" group "-" smode "}")
6043 (sem smode dmode (.sym dst mach - group - smode) (.sym dst mach - group - smode))
6047 (define-pmacro (ext16-defn smode dmode wstr wbit op opc1 opc2 opc3 sem)
6048 (ext-insn-defn 16 16-Ext smode dmode wstr op
6049 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-Ext- smode))
6053 (define-pmacro (ext32-defn smode dmode wstr wbit op opc1 opc2 opc3 sem)
6054 (ext-insn-defn 32 16-ExtUnprefixed smode dmode wstr op
6055 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst32-16-ExtUnprefixed- smode))
6059 (define-pmacro (ext32-binary-insn src-group dst-group op wstr encoding sem)
6060 (dni (.sym op 32 wstr - src-group - dst-group)
6061 (.str op 32 wstr " src32-" src-group "-QI,dst32-" dst-group "-HI")
6063 (.str op wstr " ${src32-" src-group "-QI},${dst32-" dst-group "-HI}")
6065 (sem QI HI (.sym src32- src-group -QI) (.sym dst32 - dst-group -HI))
6069 (define-pmacro (ext32-binary-defn op wstr opc1 opc2 sem)
6071 (ext32-binary-insn basic-ExtPrefixed 24-Prefixed op wstr
6072 (+ (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))
6074 (ext32-binary-insn 24-24-Prefixed 48-Prefixed op wstr
6075 (+ (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))
6077 (ext32-binary-insn 24-16-Prefixed 40-Prefixed op wstr
6078 (+ (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))
6080 (ext32-binary-insn 24-8-Prefixed 32-Prefixed op wstr
6081 (+ (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))
6086 ;=============================================================
6087 ; Binary Arithmetic macros
6089 ;-------------------------------------------------------------
6090 ;<arith>.size:S src2,r0[l] -- for m32c
6091 ;-------------------------------------------------------------
6093 (define-pmacro (binary-arith32-S-src2 op xmode wstr wbit opc1 opc2 sem)
6094 (dni (.sym op 32 wstr .S-src2-r0- xmode)
6095 (.str op 32 wstr ":S src2,r0[l]")
6097 (.str op wstr"$S ${src32-2-S-" xmode "},${Dst32R0" xmode "-S}")
6098 (+ opc1 opc2 (.sym src32-2-S- xmode) (f-7-1 wbit))
6099 (sem xmode (.sym src32-2-S- xmode) (.sym Dst32R0 xmode -S))
6103 ;-------------------------------------------------------------
6104 ;<arith>.b:S src2,r0l/r0h -- for m16c
6105 ;-------------------------------------------------------------
6107 (define-pmacro (binary-arith16-b-S-src2 op opc1 opc2 sem)
6109 (dni (.sym op 16 .b.S-src2)
6110 (.str op ".b:S src2,r0[lh]")
6112 (.str op ".b$S ${src16-2-S},${Dst16RnQI-S}")
6113 (+ opc1 opc2 Dst16RnQI-S src16-2-S)
6114 (sem QI src16-2-S Dst16RnQI-S)
6116 (dni (.sym op 16 .b.S-r0l-r0h)
6117 (.str op ".b:S r0l/r0h")
6119 (.str op ".b$S ${srcdst16-r0l-r0h-S}")
6120 (+ opc1 opc2 srcdst16-r0l-r0h-S)
6121 (if (eq srcdst16-r0l-r0h-S 0)
6128 ;-------------------------------------------------------------
6129 ;<arith>.b:S #imm8,dst3 -- for m16c
6130 ;-------------------------------------------------------------
6132 (define-pmacro (binary-arith16-b-S-imm8-dst3 op sz opc1 opc2 sem)
6133 (dni (.sym op 16 .b.S-imm8-dst3)
6134 (.str op sz ":S imm8,dst3")
6136 (.str op sz "$S #${Imm-8-QI},${Dst16-3-S-16}")
6137 (+ opc1 opc2 Dst16-3-S-16 Imm-8-QI)
6138 (sem QI Imm-8-QI Dst16-3-S-16)
6142 ;-------------------------------------------------------------
6143 ;<arith>.size:Q #imm4,sp -- for m16c
6144 ;-------------------------------------------------------------
6146 (define-pmacro (binary-arith16-Q-sp op opc1 opc2 opc3 sem)
6147 (dni (.sym op 16 -wQ-sp)
6148 (.str op ".w:q #imm4,sp")
6150 (.str op ".w$Q #${Imm-12-s4},sp")
6151 (+ opc1 opc2 opc3 Imm-12-s4)
6152 (sem QI Imm-12-s4 sp)
6156 ;-------------------------------------------------------------
6157 ;<arith>.size:G #imm,sp -- for m16c
6158 ;-------------------------------------------------------------
6160 (define-pmacro (binary-arith16-G-sp-defn mode wstr wbit op opc1 opc2 opc3 opc4 sem)
6161 (dni (.sym op 16 wstr - G-sp)
6162 (.str op wstr " imm-sp " mode)
6164 (.str op wstr "$G #${Imm-16-" mode "},sp")
6165 (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16- mode))
6166 (sem mode (.sym Imm-16- mode) sp)
6170 (define-pmacro (binary-arith16-G-sp op opc1 opc2 opc3 opc4 sem)
6172 (binary-arith16-G-sp-defn QI .b 0 op opc1 opc2 opc3 opc4 sem)
6173 (binary-arith16-G-sp-defn HI .w 1 op opc1 opc2 opc3 opc4 sem)
6177 ;-------------------------------------------------------------
6178 ;<arith>.size:G #imm,dst -- for m16c and m32c
6179 ;-------------------------------------------------------------
6181 (define-pmacro (binary-arith-imm-dst-defn mach src dstgroup dmode wstr op suffix encoding sem)
6182 (dni (.sym op mach wstr - imm-G - dstgroup)
6183 (.str op wstr " " mach "-imm-G-" dstgroup "-" dmode)
6184 ((machine mach) RL_1ADDR)
6185 (.str op wstr "$"suffix " #${" src "},${dst" mach "-" dstgroup "-" dmode "}")
6187 (sem dmode src (.sym dst mach - dstgroup - dmode))
6192 (define-pmacro (binary-arith16-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6194 (binary-arith-imm-dst-defn 16 (.sym Imm-32- smode) 16-16 dmode wstr op suffix
6195 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- dmode) (.sym Imm-32- smode))
6197 (binary-arith-imm-dst-defn 16 (.sym Imm-24- smode) 16-8 dmode wstr op suffix
6198 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- dmode) (.sym Imm-24- smode))
6200 (binary-arith-imm-dst-defn 16 (.sym Imm-16- smode) basic dmode wstr op suffix
6201 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- dmode) (.sym Imm-16- smode))
6206 ; m32c Unprefixed variants
6207 (define-pmacro (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6209 (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 16-24-Unprefixed dmode wstr op suffix
6210 (+ (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))
6212 (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 16-16-Unprefixed dmode wstr op suffix
6213 (+ (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))
6215 (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) 16-8-Unprefixed dmode wstr op suffix
6216 (+ (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))
6218 (binary-arith-imm-dst-defn 32 (.sym Imm-16- smode) basic-Unprefixed dmode wstr op suffix
6219 (+ (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))
6224 ; m32c Prefixed variants
6225 (define-pmacro (binary-arith32-imm-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6227 (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-Prefixed dmode wstr op suffix
6228 (+ (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))
6230 (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-Prefixed dmode wstr op suffix
6231 (+ (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))
6233 (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-Prefixed dmode wstr op suffix
6234 (+ (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))
6236 (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-Prefixed dmode wstr op suffix
6237 (+ (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))
6243 (define-pmacro (binary-arith32-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6245 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6246 ; define the absolute-indirect insns first in order to prevent them from being selected
6247 ; when the mode is register-indirect
6248 ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-absolute-indirect dmode wstr op suffix
6249 ; (+ (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))
6251 ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-absolute-indirect dmode wstr op suffix
6252 ; (+ (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))
6254 ; Unprefixed modes next
6255 (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6257 ; Remaining indirect modes
6258 ; (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-indirect dmode wstr op suffix
6259 ; (+ (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))
6261 ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-indirect dmode wstr op suffix
6262 ; (+ (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))
6264 ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-indirect dmode wstr op suffix
6265 ; (+ (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))
6267 ; (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-indirect dmode wstr op suffix
6268 ; (+ (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))
6273 (define-pmacro (binary-arith-imm-dst-mach mach op suffix opc1 opc2 opc3 sem)
6275 (.apply (.sym binary-arith mach -imm-dst-defn) (QI QI .b 0 op suffix opc1 opc2 opc3 sem))
6276 (.apply (.sym binary-arith mach -imm-dst-defn) (HI HI .w 1 op suffix opc1 opc2 opc3 sem))
6280 (define-pmacro (binary-arith-imm-dst op suffix opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6282 (binary-arith-imm-dst-mach 16 op suffix opc16-1 opc16-2 opc16-3 sem)
6283 (binary-arith-imm-dst-mach 32 op suffix opc32-1 opc32-2 opc32-3 sem)
6287 ;-------------------------------------------------------------
6288 ;<arith>.size:Q #imm4,dst -- for m16c and m32c
6289 ;-------------------------------------------------------------
6291 (define-pmacro (binary-arith-imm4-dst-defn mach src dstgroup mode wstr op encoding sem)
6292 (dni (.sym op mach wstr - imm4-Q - dstgroup)
6293 (.str op wstr " " mach "-imm4-Q-" dstgroup "-" mode)
6294 ((machine mach) RL_1ADDR)
6295 (.str op wstr "$Q #${" src "},${dst" mach "-" dstgroup "-" mode "}")
6297 (sem mode src (.sym dst mach - dstgroup - mode))
6302 (define-pmacro (binary-arith16-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6303 (binary-arith-imm4-dst-defn 16 Imm-8-s4 16 mode wstr op
6304 (+ opc1 opc2 (f-7-1 wbit2) Imm-8-s4 (.sym dst16-16- mode))
6308 (define-pmacro (binary-arith16-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6309 (binary-arith-imm4-dst-defn 16 Imm-sh-8-s4 16 mode wstr op
6310 (+ opc1 opc2 (f-7-1 wbit2) Imm-sh-8-s4 (.sym dst16-16- mode))
6315 (define-pmacro (binary-arith32-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6317 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6318 ; define the absolute-indirect insns first in order to prevent them from being selected
6319 ; when the mode is register-indirect
6320 ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-absolute-indirect mode wstr op
6321 ; (+ (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)
6323 (binary-arith-imm4-dst-defn 32 Imm-12-s4 16-Unprefixed mode wstr op
6324 (+ (f-0-3 opc1) (f-3-1 wbit1) (f-7-1 wbit2) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) Imm-12-s4)
6326 ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-indirect mode wstr op
6327 ; (+ (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)
6332 (define-pmacro (binary-arith32-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6334 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6335 ; define the absolute-indirect insns first in order to prevent them from being selected
6336 ; when the mode is register-indirect
6337 ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-absolute-indirect mode wstr op
6338 ; (+ (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)
6340 (binary-arith-imm4-dst-defn 32 Imm-sh-12-s4 16-Unprefixed mode wstr op
6341 (+ (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)
6343 ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-indirect mode wstr op
6344 ; (+ (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)
6349 (define-pmacro (binary-arith-imm4-dst-mach mach op opc1 opc2 sem)
6351 (.apply (.sym binary-arith mach -imm4-dst-defn) (QI .b 0 0 op opc1 opc2 sem))
6352 (.apply (.sym binary-arith mach -imm4-dst-defn) (HI .w 0 1 op opc1 opc2 sem))
6356 (define-pmacro (binary-arith-imm4-dst op opc16-1 opc16-2 opc32-1 opc32-2 sem)
6358 (binary-arith-imm4-dst-mach 16 op opc16-1 opc16-2 sem)
6359 (binary-arith-imm4-dst-mach 32 op opc32-1 opc32-2 sem)
6363 ;-------------------------------------------------------------
6364 ;<arith>.size:G src,dst -- for m16c and m32c
6365 ;-------------------------------------------------------------
6367 (define-pmacro (binary-arith-src-dst-defn mach srcgroup dstgroup smode dmode wstr op suffix encoding sem)
6368 (dni (.sym op mach wstr - srcgroup - dstgroup)
6369 (.str op wstr " dst" mach "-" srcgroup "-" dstgroup "-" dmode)
6370 ((machine mach) RL_2ADDR)
6371 (.str op wstr "$" suffix " ${src" mach "-" srcgroup "-" smode "},${dst" mach "-" dstgroup "-" dmode "}")
6373 (sem dmode (.sym src mach - srcgroup - smode) (.sym dst mach - dstgroup - dmode))
6378 (define-pmacro (binary-arith16-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem)
6380 (binary-arith-src-dst-defn 16 basic 16 smode dmode wstr op suffix
6381 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-basic- smode) (.sym dst16-16- dmode))
6383 (binary-arith-src-dst-defn 16 16-16 32 smode dmode wstr op suffix
6384 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-16- smode) (.sym dst16-32- dmode))
6386 (binary-arith-src-dst-defn 16 16-8 24 smode dmode wstr op suffix
6387 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-8- smode) (.sym dst16-24- dmode))
6392 ; m32c Prefixed variants
6393 (define-pmacro (binary-arith32-src-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 sem)
6395 (binary-arith-src-dst-defn 32 basic-Prefixed 24-Prefixed smode dmode wstr op suffix
6396 (+ (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))
6398 (binary-arith-src-dst-defn 32 24-24-Prefixed 48-Prefixed smode dmode wstr op suffix
6399 (+ (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))
6401 (binary-arith-src-dst-defn 32 24-16-Prefixed 40-Prefixed smode dmode wstr op suffix
6402 (+ (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))
6404 (binary-arith-src-dst-defn 32 24-8-Prefixed 32-Prefixed smode dmode wstr op suffix
6405 (+ (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))
6411 (define-pmacro (binary-arith32-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem)
6413 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6414 ; define the absolute-indirect insns first in order to prevent them from being selected
6415 ; when the mode is register-indirect
6416 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-absolute-indirect smode dmode wstr op suffix
6417 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6418 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6420 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-absolute-indirect smode dmode wstr op suffix
6421 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6422 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6424 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-Prefixed smode dmode wstr op suffix
6425 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6426 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
6428 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-Prefixed smode dmode wstr op suffix
6429 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6430 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
6432 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-indirect smode dmode wstr op suffix
6433 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6434 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6436 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-indirect smode dmode wstr op suffix
6437 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6438 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6440 ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-absolute-indirect smode dmode wstr op suffix
6441 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6442 ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2))
6444 ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-absolute-indirect smode dmode wstr op suffix
6445 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6446 ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6448 ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-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-24-16-Prefixed- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6452 ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-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-8-Prefixed- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2))
6456 ; (binary-arith-src-dst-defn 32 basic-indirect 24-absolute-indirect smode dmode wstr op suffix
6457 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6458 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2))
6460 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-absolute-indirect smode dmode wstr op suffix
6461 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6462 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6464 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-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-24-16-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6468 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-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-8-indirect- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2))
6472 (binary-arith-src-dst-defn 32 basic-Unprefixed 16-Unprefixed smode dmode wstr op suffix
6473 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-basic-Unprefixed- smode) (.sym dst32-16-Unprefixed- dmode) (f-12-4 opc2))
6475 (binary-arith-src-dst-defn 32 16-24-Unprefixed 40-Unprefixed smode dmode wstr op suffix
6476 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-24-Unprefixed- smode) (.sym dst32-40-Unprefixed- dmode) (f-12-4 opc2))
6478 (binary-arith-src-dst-defn 32 16-16-Unprefixed 32-Unprefixed smode dmode wstr op suffix
6479 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-16-Unprefixed- smode) (.sym dst32-32-Unprefixed- dmode) (f-12-4 opc2))
6481 (binary-arith-src-dst-defn 32 16-8-Unprefixed 24-Unprefixed smode dmode wstr op suffix
6482 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-8-Unprefixed- smode) (.sym dst32-24-Unprefixed- dmode) (f-12-4 opc2))
6484 ; (binary-arith-src-dst-defn 32 basic-indirect 24-Prefixed smode dmode wstr op suffix
6485 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6486 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-Prefixed- dmode) (f-20-4 opc2))
6488 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-Prefixed smode dmode wstr op suffix
6489 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6490 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
6492 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-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-24-16-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
6496 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-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-8-indirect- smode) (.sym dst32-32-Prefixed- dmode) (f-20-4 opc2))
6500 ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-indirect smode dmode wstr op suffix
6501 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6502 ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2))
6504 ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-indirect smode dmode wstr op suffix
6505 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6506 ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6508 ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-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-24-16-Prefixed- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6512 ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-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-8-Prefixed- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2))
6516 ; (binary-arith-src-dst-defn 32 basic-indirect 24-indirect smode dmode wstr op suffix
6517 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6518 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2))
6520 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-indirect smode dmode wstr op suffix
6521 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6522 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6524 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-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-24-16-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6528 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-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-8-indirect- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2))
6535 (define-pmacro (binary-arith-src-dst-mach mach op suffix opc1 opc2 sem)
6537 (.apply (.sym binary-arith mach -src-dst-defn) (QI QI .b 0 op suffix opc1 opc2 sem))
6538 (.apply (.sym binary-arith mach -src-dst-defn) (HI HI .w 1 op suffix opc1 opc2 sem))
6542 (define-pmacro (binary-arith-src-dst op suffix opc16-1 opc16-2 opc32-1 opc32-2 sem)
6544 (binary-arith-src-dst-mach 16 op suffix opc16-1 opc16-2 sem)
6545 (binary-arith-src-dst-mach 32 op suffix opc32-1 opc32-2 sem)
6549 ;-------------------------------------------------------------
6550 ;<arith>.size:S #imm,dst -- for m32c
6551 ;-------------------------------------------------------------
6553 (define-pmacro (binary-arith32-s-imm-dst-defn src dstgroup mode wstr op encoding sem)
6554 (dni (.sym op 32 wstr - imm-S - dstgroup)
6555 (.str op wstr " 32-imm-S-" dstgroup "-" mode)
6557 (.str op wstr "$S #${" src "},${dst32-" dstgroup "-" mode "}")
6559 (sem mode src (.sym dst32- dstgroup - mode))
6563 (define-pmacro (binary-arith32-z-imm-dst-defn src dstgroup mode wstr op encoding sem)
6564 (dni (.sym op 32 wstr - imm-Z - dstgroup)
6565 (.str op wstr " 32-imm-Z-" dstgroup "-" mode)
6567 (.str op wstr "$Z #0,${dst32-" dstgroup "-" mode "}")
6569 (sem mode (const 0) (.sym dst32- dstgroup - mode))
6573 (define-pmacro (binary-arith32-s-imm-dst mode wstr wbit op opc1 opc2 sem)
6575 ; (binary-arith32-s-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op
6576 ; (+ (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))
6578 (binary-arith32-s-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op
6579 (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-8- mode))
6581 (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op
6582 (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-24- mode))
6584 (binary-arith32-s-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op
6585 (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-16- mode))
6587 ; (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op
6588 ; (+ (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))
6593 (define-pmacro (binary-arith32-z-imm-dst mode wstr wbit op opc1 opc2 sem)
6595 ; (binary-arith32-z-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op
6596 ; (+ (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))
6598 (binary-arith32-z-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op
6599 (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit))
6601 (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op
6602 (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit))
6604 (binary-arith32-z-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op
6605 (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit))
6607 ; (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op
6608 ; (+ (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))
6613 ;-------------------------------------------------------------
6614 ;<arith>.L:S #imm1,An -- for m32c
6615 ;-------------------------------------------------------------
6617 (define-pmacro (binary-arith32-l-s-imm1-an op opc1 opc2 sem)
6619 (dni (.sym op 32.l-s-imm1-S-an)
6620 (.str op ".l 32-imm1-S-an")
6622 (.str op ".l$S #${Imm1-S},${dst32-an-S}")
6623 (+ opc1 Imm1-S opc2 dst32-an-S)
6624 (sem SI Imm1-S dst32-an-S)
6629 ;-------------------------------------------------------------
6630 ;<arith>.L:Q #imm3,sp -- for m32c
6631 ;-------------------------------------------------------------
6633 (define-pmacro (binary-arith32-l-q-imm3-sp op opc1 opc2 sem)
6635 (dni (.sym op 32.l-imm3-Q)
6636 (.str op ".l 32-imm3-Q")
6638 (.str op ".l$Q #${Imm3-S},sp")
6639 (+ opc1 Imm3-S opc2)
6645 ;-------------------------------------------------------------
6646 ;<arith>.L:S #imm8,sp -- for m32c
6647 ;-------------------------------------------------------------
6649 (define-pmacro (binary-arith32-l-s-imm8-sp op opc1 opc2 opc3 opc4 sem)
6651 (dni (.sym op 32.l-imm8-S)
6652 (.str op ".l 32-imm8-S")
6654 (.str op ".l$S #${Imm-16-QI},sp")
6655 (+ opc1 opc2 opc3 opc4 Imm-16-QI)
6656 (sem SI Imm-16-QI sp)
6661 ;-------------------------------------------------------------
6662 ;<arith>.L:G #imm16,sp -- for m32c
6663 ;-------------------------------------------------------------
6665 (define-pmacro (binary-arith32-l-g-imm16-sp op opc1 opc2 opc3 opc4 sem)
6667 (dni (.sym op 32.l-imm16-G)
6668 (.str op ".l 32-imm16-G")
6670 (.str op ".l$G #${Imm-16-HI},sp")
6671 (+ opc1 opc2 opc3 opc4 Imm-16-HI)
6672 (sem SI Imm-16-HI sp)
6677 ;-------------------------------------------------------------
6678 ;<arith>jnz.size #imm4,dst,label -- for m16c and m32c
6679 ;-------------------------------------------------------------
6681 (define-pmacro (arith-jnz-imm4-dst-defn mach src dstgroup label mode wstr op encoding sem)
6682 (dni (.sym op mach wstr - imm4 - dstgroup)
6683 (.str op wstr " " mach "-imm4-" dstgroup "-" label "-" mode)
6685 (.str op wstr " #${" src "},${dst" mach "-" dstgroup "-" mode "},${" label "}")
6687 (sem mode src (.sym dst mach - dstgroup - mode) label)
6692 (define-pmacro (arith-jnz16-imm4-dst-defn mode wstr wbit op i4n opc1 opc2 sem)
6694 (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) basic Lab-16-8 mode wstr op
6695 (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-basic- mode) Lab-16-8)
6697 (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) 16-16 Lab-32-8 mode wstr op
6698 (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-16-16- mode) Lab-16-8)
6700 (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) 16-8 Lab-24-8 mode wstr op
6701 (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-16-8- mode) Lab-16-8)
6707 (define-pmacro (arith-jnz32-imm4-dst-defn mode wstr wbit op i4n opc1 opc2 sem)
6709 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) basic-Unprefixed Lab-16-8 mode wstr op
6710 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-16-8)
6712 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-24-Unprefixed Lab-40-8 mode wstr op
6713 (+ (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)
6715 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-16-Unprefixed Lab-32-8 mode wstr op
6716 (+ (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)
6718 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-8-Unprefixed Lab-24-8 mode wstr op
6719 (+ (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)
6724 (define-pmacro (arith-jnz-imm4-dst-mach mach op i4n opc1 opc2 sem)
6726 (.apply (.sym arith-jnz mach -imm4-dst-defn) (QI .b 0 op i4n opc1 opc2 sem))
6727 (.apply (.sym arith-jnz mach -imm4-dst-defn) (HI .w 1 op i4n opc1 opc2 sem))
6731 (define-pmacro (arith-jnz-imm4-dst op i4n opc16-1 opc16-2 opc32-1 opc32-2 sem)
6733 (arith-jnz-imm4-dst-mach 16 op i4n opc16-1 opc16-2 sem)
6734 (arith-jnz-imm4-dst-mach 32 op i4n opc32-1 opc32-2 sem)
6738 ;-------------------------------------------------------------
6739 ;mov.size dsp8[sp],dst -- for m16c and m32c
6740 ;-------------------------------------------------------------
6741 (define-pmacro (mov-dspsp-dst-defn mach dstgroup dsp mode wstr op encoding sem)
6742 (dni (.sym op mach wstr -dspsp-dst- dstgroup)
6743 (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
6745 (.str op wstr "$G ${" dsp "}[sp],${dst" mach "-" dstgroup "-" mode "}")
6747 (sem mach mode dsp (.sym dst mach - dstgroup - mode))
6750 (define-pmacro (mov-src-dspsp-defn mach dstgroup dsp mode wstr op encoding sem)
6751 (dni (.sym op mach wstr -dst-dspsp- dstgroup)
6752 (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
6754 (.str op wstr "$G ${dst" mach "-" dstgroup "-" mode "},${" dsp "}[sp]")
6756 (sem mach mode (.sym dst mach - dstgroup - mode) dsp)
6761 (define-pmacro (mov16-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem)
6763 (mov-dspsp-dst-defn 16 basic Dsp-16-s8 mode wstr op
6764 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-s8)
6766 (mov-dspsp-dst-defn 16 16-16 Dsp-32-s8 mode wstr op
6767 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-s8)
6769 (mov-dspsp-dst-defn 16 16-8 Dsp-24-s8 mode wstr op
6770 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-s8)
6775 (define-pmacro (mov16-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem)
6777 (mov-src-dspsp-defn 16 basic Dsp-16-s8 mode wstr op
6778 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-s8)
6780 (mov-src-dspsp-defn 16 16-16 Dsp-32-s8 mode wstr op
6781 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-s8)
6783 (mov-src-dspsp-defn 16 16-8 Dsp-24-s8 mode wstr op
6784 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-s8)
6790 (define-pmacro (mov32-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem)
6792 (mov-dspsp-dst-defn 32 basic-Unprefixed Dsp-16-s8 mode wstr op
6793 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-s8)
6795 (mov-dspsp-dst-defn 32 16-24-Unprefixed Dsp-40-s8 mode wstr op
6796 (+ (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)
6798 (mov-dspsp-dst-defn 32 16-16-Unprefixed Dsp-32-s8 mode wstr op
6799 (+ (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)
6801 (mov-dspsp-dst-defn 32 16-8-Unprefixed Dsp-24-s8 mode wstr op
6802 (+ (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)
6806 (define-pmacro (mov32-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem)
6808 (mov-src-dspsp-defn 32 basic-Unprefixed Dsp-16-s8 mode wstr op
6809 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-s8)
6811 (mov-src-dspsp-defn 32 16-24-Unprefixed Dsp-40-s8 mode wstr op
6812 (+ (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)
6814 (mov-src-dspsp-defn 32 16-16-Unprefixed Dsp-32-s8 mode wstr op
6815 (+ (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)
6817 (mov-src-dspsp-defn 32 16-8-Unprefixed Dsp-24-s8 mode wstr op
6818 (+ (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)
6823 (define-pmacro (mov-src-dspsp-mach mach op opc1 opc2 opc3 sem)
6825 (.apply (.sym mov mach -src-dspsp-defn) (QI .b 0 op opc1 opc2 opc3 sem))
6826 (.apply (.sym mov mach -src-dspsp-defn) (HI .w 1 op opc1 opc2 opc3 sem))
6830 (define-pmacro (mov-dspsp-dst-mach mach op opc1 opc2 opc3 sem)
6832 (.apply (.sym mov mach -dspsp-dst-defn) (QI .b 0 op opc1 opc2 opc3 sem))
6833 (.apply (.sym mov mach -dspsp-dst-defn) (HI .w 1 op opc1 opc2 opc3 sem))
6837 (define-pmacro (mov-dspsp-dst op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6839 (mov-dspsp-dst-mach 16 op opc16-1 opc16-2 opc16-3 sem)
6840 (mov-dspsp-dst-mach 32 op opc32-1 opc32-2 opc32-3 sem)
6843 (define-pmacro (mov-src-dspsp op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6845 (mov-src-dspsp-mach 16 op opc16-1 opc16-2 opc16-3 sem)
6846 (mov-src-dspsp-mach 32 op opc32-1 opc32-2 opc32-3 sem)
6850 ;-------------------------------------------------------------
6851 ; lde dsp24,dst -- for m16c
6852 ;-------------------------------------------------------------
6854 (define-pmacro (lde-dst-dsp mode wstr wbit dstgroup srcdisp)
6857 (dni (.sym lde wstr - dstgroup -u20)
6858 (.str "lde" wstr "-" dstgroup "-u20")
6860 (.str "lde" wstr " ${" srcdisp "},${dst16-" dstgroup "-" mode "}")
6861 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x8)
6862 (.sym dst16- dstgroup - mode) srcdisp)
6866 (dni (.sym lde wstr - dstgroup -u20a0)
6867 (.str "lde" wstr "-" dstgroup "-u20a0")
6869 (.str "lde" wstr " ${" srcdisp "}[a0],${dst16-" dstgroup "-" mode "}")
6870 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x9)
6871 (.sym dst16- dstgroup - mode) srcdisp)
6875 (dni (.sym lde wstr - dstgroup -a1a0)
6876 (.str "lde" wstr "-" dstgroup "-a1a0")
6878 (.str "lde" wstr " [a1a0],${dst16-" dstgroup "-" mode "}")
6879 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #xa)
6880 (.sym dst16- dstgroup - mode))
6886 (define-pmacro (lde-dst mode wstr wbit)
6889 (lde-dst-dsp mode wstr wbit basic Dsp-16-u20)
6890 (lde-dst-dsp mode wstr wbit 16-8 Dsp-24-u20)
6891 (lde-dst-dsp mode wstr wbit 16-16 Dsp-32-u20)
6895 ;-------------------------------------------------------------
6896 ; ste dst,dsp24 -- for m16c
6897 ;-------------------------------------------------------------
6899 (define-pmacro (ste-dst-dsp mode wstr wbit dstgroup srcdisp)
6902 (dni (.sym ste wstr - dstgroup -u20)
6903 (.str "ste" wstr "-" dstgroup "-u20")
6905 (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},${" srcdisp "}")
6906 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x0)
6907 (.sym dst16- dstgroup - mode) srcdisp)
6911 (dni (.sym ste wstr - dstgroup -u20a0)
6912 (.str "ste" wstr "-" dstgroup "-u20a0")
6914 (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},${" srcdisp "}[a0]")
6915 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x1)
6916 (.sym dst16- dstgroup - mode) srcdisp)
6920 (dni (.sym ste wstr - dstgroup -a1a0)
6921 (.str "ste" wstr "-" dstgroup "-a1a0")
6923 (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},[a1a0]")
6924 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x2)
6925 (.sym dst16- dstgroup - mode))
6931 (define-pmacro (ste-dst mode wstr wbit)
6934 (ste-dst-dsp mode wstr wbit basic Dsp-16-u20)
6935 (ste-dst-dsp mode wstr wbit 16-8 Dsp-24-u20)
6936 (ste-dst-dsp mode wstr wbit 16-16 Dsp-32-u20)
6940 ;=============================================================
6942 ;-------------------------------------------------------------
6944 (define-pmacro (div-sem divop modop opmode reg src quot rem max min)
6947 (set obit (const BI 1))
6948 (sequence ((opmode quot-result) (opmode rem-result))
6949 (set quot-result (divop opmode (ext opmode reg) src))
6950 (set rem-result (modop opmode (ext opmode reg) src))
6951 (set obit (orif (gt opmode quot-result max)
6952 (lt opmode quot-result min)))
6953 (set quot quot-result)
6954 (set rem rem-result))))
6957 ;<divop>.size #imm -- for m16c and m32c
6958 (define-pmacro (div-imm-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem)
6959 (dni (.sym op mach wstr - src)
6960 (.str op mach wstr "-" src)
6962 (.str op wstr " #${" src "}")
6964 (sem divop modop opmode reg src quot rem max min)
6967 (define-pmacro (div16-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem)
6968 (div-imm-defn 16 wstr op (.sym Imm-16 - smode)
6969 (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16 - smode))
6970 divop modop opmode reg quot rem max min
6973 (define-pmacro (div32-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem)
6974 (div-imm-defn 32 wstr op (.sym Imm-16 - smode)
6975 (+ (f-0-4 opc1) (f-4-4 opc2) (f-8-3 opc3) (f-11-1 wbit) (f-12-4 opc4) (.sym Imm-16 - smode))
6976 divop modop opmode reg quot rem max min
6979 (define-pmacro (div-imm-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 opc4 sem)
6981 (.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))
6982 (.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))
6985 (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)
6987 (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)
6988 (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)
6992 ;<divop>.size src -- for m16c and m32c
6993 (define-pmacro (div-src-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem)
6994 (dni (.sym op mach wstr - src)
6995 (.str op mach wstr "-" src)
6997 (.str op wstr " ${" src "}")
6999 (sem divop modop opmode reg src quot rem max min)
7002 (define-pmacro (div16-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem)
7003 (div-src-defn 16 wstr op (.sym dst16-16 - smode)
7004 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16 - smode))
7005 divop modop opmode reg quot rem max min
7008 (define-pmacro (div32-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem)
7010 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
7011 ; define the absolute-indirect insns first in order to prevent them from being selected
7012 ; when the mode is register-indirect
7013 ; (div-src-defn 32 wstr op (.sym dst32-24-absolute-indirect- smode)
7014 ; (+ (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))
7015 ; divop modop opmode reg quot rem max min
7017 (div-src-defn 32 wstr op (.sym dst32-16-Unprefixed- smode)
7018 (+ (f-0-4 opc1) (f-7-1 wbit) (f-10-2 opc2) (f-12-4 opc3) (.sym dst32-16-Unprefixed- smode))
7019 divop modop opmode reg quot rem max min
7021 ; (div-src-defn 32 wstr op (.sym dst32-24-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-indirect - smode))
7023 ; divop modop opmode reg quot rem max min
7027 (define-pmacro (div-src-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 sem)
7029 (.apply (.sym div mach -src-defn) (QI .b 0 op divop modop opmode R0 R0l R0h max-QI min-QI opc1 opc2 opc3 sem))
7030 (.apply (.sym div mach -src-defn) (HI .w 1 op divop modop opmode R2R0 R0 R2 max-HI min-HI opc1 opc2 opc3 sem))
7033 (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)
7035 (div-src-mach 16 op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 sem)
7036 (div-src-mach 32 op divop modop opmode max-QI min-QI max-HI min-HI opc32-1 opc32-2 opc32-3 sem)
7040 ;=============================================================
7043 (define-pmacro (bit-insn-defn mach op suffix opnd encoding sem)
7044 (dni (.sym op mach - suffix - opnd)
7045 (.str op mach ":" suffix " " opnd)
7047 (.str op "$" suffix " ${" opnd "}")
7053 (define-pmacro (bitsrc16-defn op opc1 opc2 opc3 sem)
7054 (bit-insn-defn 16 op X bit16-16
7055 (+ opc1 opc2 opc3 bit16-16)
7059 (define-pmacro (bitsrc32-defn op opc1 opc2 opc3 sem)
7061 (bit-insn-defn 32 op X bit32-24-Prefixed
7062 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) bit32-24-Prefixed (f-15-1 opc2) (f-18-3 opc3))
7067 (define-pmacro (bitsrc-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
7069 (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem)
7070 (bitsrc32-defn op opc32-1 opc32-2 opc32-3 sem)
7074 (define-pmacro (bitdst16-defn op opc1 opc2 opc3 opc4 opc5 opc6 sem)
7076 (bit-insn-defn 16 op G bit16-16-basic (+ opc1 opc2 opc3 bit16-16-basic) sem)
7077 (bit-insn-defn 16 op G bit16-16-16 (+ opc1 opc2 opc3 bit16-16-16) sem)
7078 (bit-insn-defn 16 op S bit16-11-S (+ opc4 opc5 opc6 bit16-11-S) sem)
7079 (bit-insn-defn 16 op G bit16-16-8 (+ opc1 opc2 opc3 bit16-16-8) sem)
7083 (define-pmacro (bitdst32-defn op opc1 opc2 opc3 sem)
7085 (bit-insn-defn 32 op X bit32-16-Unprefixed
7086 (+ (f-0-4 opc1) bit32-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3))
7091 (define-pmacro (bitdstnos-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
7093 (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem)
7094 (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem)
7098 (define-pmacro (bitdst-insn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 opc32-1 opc32-2 opc32-3 sem)
7100 (bitdst16-defn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 sem)
7101 (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem)
7105 ;=============================================================
7108 (define-pmacro (bitcond-insn-defn mach op bit-opnd cond-opnd encoding sem)
7109 (dni (.sym op mach - bit-opnd - cond-opnd)
7110 (.str op mach " " bit-opnd " " cond-opnd)
7112 (.str op "${" cond-opnd "} ${" bit-opnd "}")
7114 (sem mach bit-opnd cond-opnd)
7118 (define-pmacro (bitcond16-defn op opc1 opc2 opc3 sem)
7120 (bitcond-insn-defn 16 op bit16-16-basic cond16-16 (+ opc1 opc2 opc3 bit16-16-basic cond16-16) sem)
7121 (bitcond-insn-defn 16 op bit16-16-16 cond16-32 (+ opc1 opc2 opc3 bit16-16-16 cond16-32) sem)
7122 (bitcond-insn-defn 16 op bit16-16-8 cond16-24 (+ opc1 opc2 opc3 bit16-16-8 cond16-24) sem)
7126 (define-pmacro (bitcond32-defn op opc1 opc2 opc3 sem)
7128 (bitcond-insn-defn 32 op bit32-16-24-Unprefixed cond32-40
7129 (+ (f-0-4 opc1) bit32-16-24-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-40)
7131 (bitcond-insn-defn 32 op bit32-16-16-Unprefixed cond32-32
7132 (+ (f-0-4 opc1) bit32-16-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-32)
7134 (bitcond-insn-defn 32 op bit32-16-8-Unprefixed cond32-24
7135 (+ (f-0-4 opc1) bit32-16-8-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-24)
7137 (bitcond-insn-defn 32 op bit32-basic-Unprefixed cond32-16
7138 (+ (f-0-4 opc1) bit32-basic-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-16)
7143 (define-pmacro (bitcond-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
7145 (bitcond16-defn op opc16-1 opc16-2 opc16-3 sem)
7146 (bitcond32-defn op opc32-1 opc32-2 opc32-3 sem)
7150 ;=============================================================
7151 ;<insn>.size #imm1,#imm2,dst -- for m32c
7153 (define-pmacro (insn-imm1-imm2-dst-defn src1 src2 dstgroup xmode wstr op encoding sem)
7154 (dni (.sym op 32 wstr - src1 - src2 - dstgroup)
7155 (.str op 32 wstr "-" src1 "-" src2 "-" dstgroup "-" xmode)
7157 (.str op wstr " #${" src1 "},#${" src2 "},${dst32-" dstgroup "-" xmode "}")
7159 (sem xmode src1 src2 (.sym dst32- dstgroup - xmode))
7163 ; m32c Prefixed variants
7164 (define-pmacro (insn32-imm1-imm2-dst-Prefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem)
7166 (insn-imm1-imm2-dst-defn (.sym Imm-48- xmode) (.sym Imm- base4 - xmode) 24-24-Prefixed xmode wstr op
7167 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
7168 (.sym dst32-24-24-Prefixed- xmode) (.sym Imm-48- xmode) (.sym Imm- base4 - xmode))
7170 (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base3 - xmode) 24-16-Prefixed xmode wstr op
7171 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
7172 (.sym dst32-24-16-Prefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base3 - xmode))
7174 (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base2 - xmode) 24-8-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-8-Prefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base2 - xmode))
7178 (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base1 - xmode) basic-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-basic-Prefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base1 - xmode))
7185 ; m32c Unprefixed variants
7186 (define-pmacro (insn32-imm1-imm2-dst-Unprefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem)
7188 (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base4 - xmode) 16-24-Unprefixed xmode wstr op
7189 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7190 (.sym dst32-16-24-Unprefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base4 - xmode))
7192 (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base3 - xmode) 16-16-Unprefixed xmode wstr op
7193 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7194 (.sym dst32-16-16-Unprefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base3 - xmode))
7196 (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base2 - xmode) 16-8-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-8-Unprefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base2 - xmode))
7200 (insn-imm1-imm2-dst-defn (.sym Imm-16- xmode) (.sym Imm- base1 - xmode) basic-Unprefixed xmode wstr op
7201 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7202 (.sym dst32-basic-Unprefixed- xmode) (.sym Imm-16- xmode) (.sym Imm- base1 - xmode))
7207 (define-pmacro (insn-imm1-imm2-dst-Prefixed op opc32-1 opc32-2 opc32-3 sem)
7209 (insn32-imm1-imm2-dst-Prefixed-defn QI .b 0 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem)
7210 (insn32-imm1-imm2-dst-Prefixed-defn HI .w 1 40 48 56 64 op opc32-1 opc32-2 opc32-3 sem)
7213 (define-pmacro (insn-imm1-imm2-dst-Unprefixed op opc32-1 opc32-2 opc32-3 sem)
7215 (insn32-imm1-imm2-dst-Unprefixed-defn QI .b 0 24 32 40 48 op opc32-1 opc32-2 opc32-3 sem)
7216 (insn32-imm1-imm2-dst-Unprefixed-defn HI .w 1 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem)
7220 ;=============================================================
7222 ;-------------------------------------------------------------
7224 ;-------------------------------------------------------------
7226 (define-pmacro (abs-sem mode dst)
7227 (sequence ((mode result))
7228 (set result (abs mode dst))
7229 (set obit (eq result dst))
7230 (set-z-and-s result)
7233 (unary-insn abs (f-0-4 7) (f-4-3 3) (f-8-4 #xF) #xA #x1 #xF abs-sem)
7235 ;-------------------------------------------------------------
7236 ; adcf - addition carry flag
7237 ;-------------------------------------------------------------
7239 (define-pmacro (adcf-sem mode dst)
7240 (sequence ((mode result))
7241 (set result (addc mode dst 0 cbit))
7242 (set obit (add-oflag mode dst 0 cbit))
7243 (set cbit (add-cflag mode dst 0 cbit))
7244 (set-z-and-s result)
7247 (unary-insn adcf (f-0-4 7) (f-4-3 3) (f-8-4 #xE) #xB #x1 #xE adcf-sem)
7249 ;-------------------------------------------------------------
7250 ; add - binary addition
7251 ;-------------------------------------------------------------
7253 (define-pmacro (add-sem mode src1 dst)
7254 (sequence ((mode result))
7255 (set result (add mode src1 dst))
7256 (set obit (add-oflag mode src1 dst 0))
7257 (set cbit (add-cflag mode src1 dst 0))
7258 (set-z-and-s result)
7262 ; add.L:G #imm32,dst (m32 #2)
7263 (binary-arith32-imm-dst-defn SI SI .l 0 add G #x8 #x3 #x1 add-sem)
7264 ; add.size:G #imm,dst (m16 #1 m32 #1)
7265 (binary-arith-imm-dst add G (f-0-4 7) (f-4-3 3) (f-8-4 4) #x8 #x2 #xE add-sem)
7266 ; add.size:Q #imm4,dst (m16 #2 m32 #3)
7267 (binary-arith-imm4-dst add (f-0-4 #xC) (f-4-3 4) #x7 #x3 add-sem)
7268 (binary-arith32-imm4-dst-defn SI .l 1 0 add #x7 #x3 add-sem)
7269 ; add.b:S #imm8,dst3 (m16 #3)
7270 (binary-arith16-b-S-imm8-dst3 add ".b" (f-0-4 8) (f-4-1 0) add-sem)
7271 ; add.BW:Q #imm4,sp (m16 #7)
7272 (binary-arith16-Q-sp add (f-0-4 7) (f-4-4 #xD) (f-8-4 #xB) add-sem)
7273 (dnmi add16-bQ-sp "add16-bQ-sp" ()
7274 "add.b:q #${Imm-12-s4},sp"
7275 (emit add16-wQ-sp Imm-12-s4))
7276 ; add.BW:G #imm,sp (m16 #6)
7277 (binary-arith16-G-sp add (f-0-4 7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #xB) add-sem)
7278 ; add.BW:G src,dst (m16 #4 m32 #6)
7279 (binary-arith-src-dst add G (f-0-4 #xA) (f-4-3 0) #x1 #x8 add-sem)
7280 ; add.B.S src2,r0l/r0h (m16 #5)
7281 (binary-arith16-b-S-src2 add (f-0-4 2) (f-4-1 0) add-sem)
7282 ; add.L:G src,dst (m32 #7)
7283 (binary-arith32-src-dst-defn SI SI .l 1 add G #x1 #x2 add-sem)
7284 ; add.L:S #imm{1,2},A0/A1 (m32 #5)
7285 (binary-arith32-l-s-imm1-an add (f-0-2 2) (f-3-4 6) add-sem)
7286 ; add.L:Q #imm3,sp (m32 #9)
7287 (binary-arith32-l-q-imm3-sp add (f-0-2 1) (f-4-3 1) add-sem)
7288 ; add.L:S #imm8,sp (m32 #10)
7289 (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)
7290 ; add.L:G #imm16,sp (m32 #8)
7291 (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)
7292 ; add.BW:S #imm,dst2 (m32 #4)
7293 (binary-arith32-s-imm-dst QI .b 0 add #x0 #x3 add-sem)
7294 (binary-arith32-s-imm-dst HI .w 1 add #x0 #x3 add-sem)
7296 ;-------------------------------------------------------------
7297 ; adc - binary add with carry
7298 ;-------------------------------------------------------------
7300 (define-pmacro (addc-sem mode src dst)
7301 (sequence ((mode result))
7302 (set result (addc mode src dst cbit))
7303 (set obit (add-oflag mode src dst cbit))
7304 (set cbit (add-cflag mode src dst cbit))
7305 (set-z-and-s result)
7309 ; adc.size:G #imm,dst
7310 (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)
7311 (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)
7312 (binary-arith32-imm-dst-Prefixed QI QI .b 0 adc X #x8 #x2 #xE addc-sem)
7313 (binary-arith32-imm-dst-Prefixed HI HI .w 1 adc X #x8 #x2 #xE addc-sem)
7316 (binary-arith16-src-dst-defn QI QI .b 0 adc X (f-0-4 #xB) (f-4-3 0) addc-sem)
7317 (binary-arith16-src-dst-defn HI HI .w 1 adc X (f-0-4 #xB) (f-4-3 0) addc-sem)
7318 (binary-arith32-src-dst-Prefixed QI QI .b 0 adc X #x1 #x4 addc-sem)
7319 (binary-arith32-src-dst-Prefixed HI HI .w 1 adc X #x1 #x4 addc-sem)
7321 ;-------------------------------------------------------------
7322 ; dadc - decimal add with carry
7323 ; dadd - decimal addition
7324 ;-------------------------------------------------------------
7326 (define-pmacro (dadc-sem mode src dst)
7327 (sequence ((mode result))
7328 (set result (subc mode dst src (not cbit)))
7329 (set cbit (sub-cflag mode dst src (not cbit)))
7330 (set-z-and-s result)
7334 (define-pmacro (decimal-subtraction16-insn op opc1 opc2)
7337 (dni (.sym op 16.b-imm8)
7338 (.str op ".b #imm8")
7340 (.str op ".b #${Imm-16-QI},r0l")
7341 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc1) Imm-16-QI)
7342 ((.sym op -sem) QI Imm-16-QI R0l)
7345 (dni (.sym op 16.w-imm16)
7346 (.str op ".b #imm16")
7348 (.str op ".w #${Imm-16-HI},r0")
7349 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc1) Imm-16-HI)
7350 ((.sym op -sem) HI Imm-16-HI R0)
7353 (dni (.sym op 16.b-r0h-r0l)
7354 (.str op ".b r0h,r0l")
7356 (.str op ".b r0h,r0l")
7357 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc2))
7358 ((.sym op -sem) QI R0h R0l)
7361 (dni (.sym op 16.w-r1-r0)
7362 (.str op ".b r1,r0")
7364 (.str op ".w r1,r0")
7365 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc2))
7366 ((.sym op -sem) HI R1 R0)
7372 (decimal-subtraction16-insn dadc #xE #x6 )
7374 ; dadc.size #imm,dst
7375 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadc X #x8 #x0 #xE dadc-sem)
7376 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadc X #x8 #x0 #xE dadc-sem)
7378 (binary-arith32-src-dst-Prefixed QI QI .b 0 dadc X #x1 #x8 dadc-sem)
7379 (binary-arith32-src-dst-Prefixed HI HI .w 1 dadc X #x1 #x8 dadc-sem)
7381 (define-pmacro (dadd-sem mode src dst)
7382 (sequence ((mode result))
7383 (set result (subc mode dst src 0))
7384 (set cbit (sub-cflag mode dst src 0))
7385 (set-z-and-s result)
7390 (decimal-subtraction16-insn dadd #xC #x4)
7392 ; dadd.size #imm,dst
7393 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadd X #x8 #x1 #xE dadd-sem)
7394 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadd X #x8 #x1 #xE dadd-sem)
7396 (binary-arith32-src-dst-Prefixed QI QI .b 0 dadd X #x1 #x0 dadd-sem)
7397 (binary-arith32-src-dst-Prefixed HI HI .w 1 dadd X #x1 #x0 dadd-sem)
7399 ;-------------------------------------------------------------;
7400 ; addx - Add extend sign with no carry
7401 ;-------------------------------------------------------------;
7403 (define-pmacro (addx-sem mode src dst)
7404 (sequence ((SI source) (SI result))
7405 (set source (zext SI (trunc QI src)))
7406 (set result (add SI source dst))
7407 (set obit (add-oflag SI source dst 0))
7408 (set cbit (add-cflag SI source dst 0))
7409 (set-z-and-s result)
7414 (binary-arith32-imm-dst-defn QI SI "" 0 addx X #x8 #x1 #x1 addx-sem)
7416 (binary-arith32-src-dst-defn QI SI "" 0 addx X #x1 #x2 addx-sem)
7418 ;-------------------------------------------------------------
7419 ; adjnz - Add/Sub and branch if not zero
7420 ;-------------------------------------------------------------
7422 (define-pmacro (arith-jnz-sem mode src dst label)
7423 (sequence ((mode result))
7424 (set result (add mode src dst))
7430 ; adjnz.size #imm4,dst,label
7431 (arith-jnz-imm4-dst adjnz s4 (f-0-4 #xF) (f-4-3 4) #xf #x1 arith-jnz-sem)
7433 ;-------------------------------------------------------------
7435 ;-------------------------------------------------------------
7437 (define-pmacro (and-sem mode src1 dst)
7438 (sequence ((mode result))
7439 (set result (and mode src1 dst))
7440 (set-z-and-s result)
7444 ; and.size:G #imm,dst (m16 #1 m32 #1)
7445 (binary-arith-imm-dst and G (f-0-4 7) (f-4-3 3) (f-8-4 2) #x8 #x3 #xF and-sem)
7446 ; and.b:S #imm8,dst3 (m16 #2)
7447 (binary-arith16-b-S-imm8-dst3 and ".b" (f-0-4 9) (f-4-1 0) and-sem)
7448 ; and.BW:G src,dst (m16 #3 m32 #3)
7449 (binary-arith-src-dst and G (f-0-4 #x9) (f-4-3 0) #x1 #xD and-sem)
7450 ; and.B.S src2,r0l/r0h (m16 #4)
7451 (binary-arith16-b-S-src2 and (f-0-4 1) (f-4-1 0) and-sem)
7452 ; and.BW:S #imm,dst2 (m32 #2)
7453 (binary-arith32-s-imm-dst QI .b 0 and #x1 #x6 and-sem)
7454 (binary-arith32-s-imm-dst HI .w 1 and #x1 #x6 and-sem)
7456 ;-------------------------------------------------------------
7458 ;-------------------------------------------------------------
7460 (define-pmacro (band-sem src)
7461 (set cbit (and src cbit))
7463 (bitsrc-insn band (f-0-4 7) (f-4-4 #xE) (f-8-4 4) #xD #x0 #x1 band-sem)
7465 ;-------------------------------------------------------------
7467 ;-------------------------------------------------------------
7469 (define-pmacro (bclr-sem dst)
7472 (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)
7474 ;-------------------------------------------------------------
7475 ; bitindex - bit index
7476 ;-------------------------------------------------------------
7478 (define-pmacro (bitindex-sem mode dst)
7481 (unary-insn-defn 32 16-Unprefixed QI .b bitindex
7482 (+ (f-0-4 #xC) (f-7-1 0) dst32-16-Unprefixed-QI (f-10-2 #x2) (f-12-4 #xE))
7484 (unary-insn-defn 32 16-Unprefixed HI .w bitindex
7485 (+ (f-0-4 #xC) (f-7-1 1) dst32-16-Unprefixed-HI (f-10-2 #x2) (f-12-4 #xE))
7488 ;-------------------------------------------------------------
7489 ; bmCnd - bit move condition
7490 ;-------------------------------------------------------------
7492 (define-pmacro (test-condition16 cond)
7494 ((#x00) (trunc BI cbit))
7495 ((#x01) (not (or cbit zbit)))
7496 ((#x02) (trunc BI zbit))
7497 ((#x03) (trunc BI sbit))
7498 ((#x04) (or zbit (xor sbit obit)))
7499 ((#x05) (trunc BI obit))
7500 ((#x06) (xor sbit obit))
7502 ((#xf9) (or cbit zbit))
7505 ((#xfc) (not (or zbit (xor sbit obit))))
7507 ((#xfe) (not (xor sbit obit)))
7512 (define-pmacro (test-condition32 cond)
7515 ((#x01) (or cbit zbit))
7519 ((#x05) (not (or zbit (xor sbit obit))))
7520 ((#x06) (not (xor sbit obit)))
7521 ((#x08) (trunc BI cbit))
7522 ((#x09) (not (or cbit zbit)))
7523 ((#x0a) (trunc BI zbit))
7524 ((#x0b) (trunc BI sbit))
7525 ((#x0c) (trunc BI obit))
7526 ((#x0d) (or zbit (xor sbit obit)))
7527 ((#x0e) (xor sbit obit))
7532 (define-pmacro (bitcond-sem mach op cond)
7533 (if ((.sym test-condition mach) cond)
7537 (bitcond-insn bm (f-0-4 7) (f-4-4 #xE) (f-8-4 2) #xD #x0 #x2 bitcond-sem)
7543 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xD) cond16c)
7544 (bitcond-sem 16 cbit cond16c)
7551 (+ (f-0-4 #xD) (f-4-4 #x9) (f-8-1 0) (f-10-3 5) cond32)
7552 (bitcond-sem 32 cbit cond32)
7555 ;-------------------------------------------------------------
7557 ;-------------------------------------------------------------
7559 (define-pmacro (bnand-sem src)
7560 (set cbit (and (inv src) cbit))
7562 (bitsrc-insn bnand (f-0-4 7) (f-4-4 #xE) (f-8-4 5) #xD #x0 #x3 bnand-sem)
7564 ;-------------------------------------------------------------
7566 ;-------------------------------------------------------------
7568 (define-pmacro (bnor-sem src)
7569 (set cbit (or (inv src) cbit))
7571 (bitsrc-insn bnor (f-0-4 7) (f-4-4 #xE) (f-8-4 7) #xD #x0 #x6 bnor-sem)
7573 ;-------------------------------------------------------------
7575 ;-------------------------------------------------------------
7577 (define-pmacro (bnot-sem dst)
7580 (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)
7582 ;-------------------------------------------------------------
7584 ;-------------------------------------------------------------
7586 (define-pmacro (bntst-sem src)
7587 (set cbit (inv src))
7588 (set zbit (inv src))
7590 (bitsrc-insn bntst (f-0-4 7) (f-4-4 #xE) (f-8-4 3) #xD #x0 #x0 bntst-sem)
7592 ;-------------------------------------------------------------
7594 ;-------------------------------------------------------------
7596 (define-pmacro (bnxor-sem src)
7597 (set cbit (xor (inv src) cbit))
7599 (bitsrc-insn bnxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xD) #xD #x0 #x7 bnxor-sem)
7601 ;-------------------------------------------------------------
7603 ;-------------------------------------------------------------
7605 (define-pmacro (bor-sem src)
7606 (set cbit (or src cbit))
7608 (bitsrc-insn bor (f-0-4 7) (f-4-4 #xE) (f-8-4 #x6) #xD #x0 #x4 bor-sem)
7610 ;-------------------------------------------------------------
7612 ;-------------------------------------------------------------
7618 (+ (f-0-4 #x0) (f-4-4 #x0))
7626 (+ (f-0-4 #x0) (f-4-4 #x0))
7630 ;-------------------------------------------------------------
7632 ;-------------------------------------------------------------
7638 (+ (f-0-4 #x0) (f-4-4 #x8))
7642 ;-------------------------------------------------------------
7644 ;-------------------------------------------------------------
7646 (define-pmacro (bset-sem dst)
7649 (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)
7651 ;-------------------------------------------------------------
7653 ;-------------------------------------------------------------
7655 (define-pmacro (btst-sem dst)
7656 (set zbit (inv dst))
7659 (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)
7661 (bit-insn-defn 32 btst G bit32-16-Unprefixed
7662 (+ (f-0-4 #xD) bit32-16-Unprefixed (f-7-1 #x0) (f-10-3 #x0))
7665 (dni btst.s "btst:s" ((machine 32))
7666 "btst:s ${Bit3-S},${Dsp-8-u16}"
7667 (+ (f-0-2 #x0) (f-4-3 #x5) Bit3-S Dsp-8-u16)
7670 ;-------------------------------------------------------------
7672 ;-------------------------------------------------------------
7674 (define-pmacro (btstc-sem dst)
7675 (set zbit (inv dst))
7679 (bitdstnos-insn btstc (f-0-4 7) (f-4-4 #xE) (f-8-4 #x0) #xD #x0 #x4 btstc-sem)
7681 ;-------------------------------------------------------------
7683 ;-------------------------------------------------------------
7685 (define-pmacro (btsts-sem dst)
7686 (set zbit (inv dst))
7690 (bitdstnos-insn btsts (f-0-4 7) (f-4-4 #xE) (f-8-4 #x1) #xD #x0 #x5 btsts-sem)
7692 ;-------------------------------------------------------------
7694 ;-------------------------------------------------------------
7696 (define-pmacro (bxor-sem src)
7697 (set cbit (xor src cbit))
7699 (bitsrc-insn bxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xC) #xD #x0 #x5 bxor-sem)
7701 ;-------------------------------------------------------------
7703 ;-------------------------------------------------------------
7705 (define-pmacro (clip-sem mode imm1 imm2 dest)
7707 (if (gt mode imm1 dest)
7709 (if (lt mode imm2 dest)
7713 (insn-imm1-imm2-dst-Prefixed clip #x8 #x3 #xE clip-sem)
7715 ;-------------------------------------------------------------
7716 ; cmp - binary compare
7717 ;-------------------------------------------------------------
7719 (define-pmacro (cmp-sem mode src1 dst)
7720 (sequence ((mode result))
7721 (set result (sub mode dst src1))
7722 (set obit (sub-oflag mode dst src1 0))
7723 (set cbit (not (sub-cflag mode dst src1 0)))
7724 (set-z-and-s result))
7727 ; cmp.L:G #imm32,dst (m32 #2)
7728 (binary-arith32-imm-dst-defn SI SI .l 0 cmp G #xA #x3 #x1 cmp-sem)
7729 ; cmp.size:G #imm,dst (m16 #1 m32 #1)
7730 (binary-arith-imm-dst cmp G (f-0-4 7) (f-4-3 3) (f-8-4 8) #x9 #x2 #xE cmp-sem)
7731 ; cmp.size:Q #imm4,dst (m16 #2 m32 #3)
7732 (binary-arith-imm4-dst cmp (f-0-4 #xD) (f-4-3 0) #x7 #x1 cmp-sem)
7733 ; cmp.b:S #imm8,dst3 (m16 #3)
7734 (binary-arith16-b-S-imm8-dst3 cmp ".b" (f-0-4 #xE) (f-4-1 0) cmp-sem)
7735 ; cmp.BW:G src,dst (m16 #4 m32 #5)
7736 (binary-arith-src-dst cmp G (f-0-4 #xC) (f-4-3 0) #x1 #x6 cmp-sem)
7737 ; cmp.B.S src2,r0l/r0h (m16 #5)
7738 (binary-arith16-b-S-src2 cmp (f-0-4 3) (f-4-1 1) cmp-sem)
7739 ; cmp.L:G src,dst (m32 #6)
7740 (binary-arith32-src-dst-defn SI SI .l 1 cmp G #x1 #x1 cmp-sem)
7741 ; cmp.BW:S #imm,dst2 (m32 #4)
7742 (binary-arith32-s-imm-dst QI .b 0 cmp #x1 #x3 cmp-sem)
7743 (binary-arith32-s-imm-dst HI .w 1 cmp #x1 #x3 cmp-sem)
7744 ; cmp.BW:s src2,r0[l] (m32 #7)
7745 (binary-arith32-S-src2 cmp QI .b 0 (f-0-2 1) (f-4-3 0) cmp-sem)
7746 (binary-arith32-S-src2 cmp HI .w 1 (f-0-2 1) (f-4-3 0) cmp-sem)
7748 ;-------------------------------------------------------------
7749 ; cmpx - binary compare extend sign
7750 ;-------------------------------------------------------------
7752 (define-pmacro (cmpx-sem mode src1 dst)
7753 (sequence ((mode result))
7754 (set result (sub mode dst (ext mode src1)))
7755 (set obit (sub-oflag mode dst (ext mode src1) 0))
7756 (set cbit (sub-cflag mode dst (ext mode src1) 0))
7757 (set-z-and-s result))
7760 (binary-arith32-imm-dst-defn QI SI "" 0 cmpx X #xA #x1 #x1 cmpx-sem)
7762 ;-------------------------------------------------------------
7764 ;-------------------------------------------------------------
7766 (define-pmacro (dec-sem mode dest)
7767 (sequence ((mode result))
7768 (set result (sub mode dest 1))
7769 (set-z-and-s result)
7776 "dec.b ${Dst16-3-S-8}"
7777 (+ (f-0-4 #xA) (f-4-1 #x1) Dst16-3-S-8)
7778 (dec-sem QI Dst16-3-S-8)
7784 "dec.w ${Dst16An-S}"
7785 (+ (f-0-4 #xF) (f-5-3 #x2) Dst16An-S)
7786 (dec-sem HI Dst16An-S)
7789 (unary32-defn QI .b 0 dec #xB #x0 #xE dec-sem)
7790 (unary32-defn HI .w 1 dec #xB #x0 #xE dec-sem)
7792 ;-------------------------------------------------------------
7794 ; divu - divide unsigned
7795 ; divx - divide extension
7796 ;-------------------------------------------------------------
7799 (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)
7800 (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)
7801 (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)
7803 (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)
7804 (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)
7805 (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)
7807 (div-src-defn 32 .l div dst32-24-Prefixed-SI
7808 (+ (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)
7809 div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000)
7811 (div-src-defn 32 .l divu dst32-24-Prefixed-SI
7812 (+ (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)
7813 udiv umod USI R2R0 R2R0 NoRemainder #x80000000 0
7815 (div-src-defn 32 .l divx dst32-24-Prefixed-SI
7816 (+ (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)
7817 div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000)
7820 ;-------------------------------------------------------------
7821 ; dsbb - decimal subtraction with borrow
7822 ; dsub - decimal subtraction
7823 ;-------------------------------------------------------------
7825 (define-pmacro (dsbb-sem mode src dst)
7826 (sequence ((mode result))
7827 (set result (subc mode dst src (not cbit)))
7828 (set cbit (sub-cflag mode dst src (not cbit)))
7829 (set-z-and-s result)
7834 (decimal-subtraction16-insn dsbb #xF #x7)
7836 ; dsbb.size #imm,dst
7837 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsbb X #x9 #x0 #xE dsbb-sem)
7838 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsbb X #x9 #x0 #xE dsbb-sem)
7840 (binary-arith32-src-dst-Prefixed QI QI .b 0 dsbb X #x1 #xA dsbb-sem)
7841 (binary-arith32-src-dst-Prefixed HI HI .w 1 dsbb X #x1 #xA dsbb-sem)
7843 (define-pmacro (dsub-sem mode src dst)
7844 (sequence ((mode result))
7845 (set result (subc mode dst src 0))
7846 (set cbit (sub-cflag mode dst src 0))
7847 (set-z-and-s result)
7852 (decimal-subtraction16-insn dsub #xD #x5)
7854 ; dsub.size #imm,dst
7855 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsub X #x9 #x1 #xE dsub-sem)
7856 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsub X #x9 #x1 #xE dsub-sem)
7858 (binary-arith32-src-dst-Prefixed QI QI .b 0 dsub X #x1 #x2 dsub-sem)
7859 (binary-arith32-src-dst-Prefixed HI HI .w 1 dsub X #x1 #x2 dsub-sem)
7861 ;-------------------------------------------------------------
7862 ; sub - binary subtraction
7863 ;-------------------------------------------------------------
7865 (define-pmacro (sub-sem mode src1 dst)
7866 (sequence ((mode result))
7867 (set result (sub mode dst src1))
7868 (set obit (sub-oflag mode dst src1 0))
7869 (set cbit (sub-cflag mode dst src1 0))
7871 (set-z-and-s result)))
7873 ; sub.size:G #imm,dst (m16 #1 m32 #1)
7874 (binary-arith-imm-dst sub G (f-0-4 7) (f-4-3 3) (f-8-4 5) #x8 #x3 #xE sub-sem)
7875 ; sub.b:S #imm8,dst3 (m16 #2)
7876 (binary-arith16-b-S-imm8-dst3 sub ".b" (f-0-4 8) (f-4-1 1) sub-sem)
7877 ; sub.BW:G src,dst (m16 #3 m32 #4)
7878 (binary-arith-src-dst sub G (f-0-4 #xA) (f-4-3 4) #x1 #xA sub-sem)
7879 ; sub.B.S src2,r0l/r0h (m16 #4)
7880 (binary-arith16-b-S-src2 sub (f-0-4 2) (f-4-1 1) sub-sem)
7881 ; sub.L:G #imm32,dst (m32 #2)
7882 (binary-arith32-imm-dst-defn SI SI .l 0 sub G #x9 #x3 #x1 sub-sem)
7883 ; sub.BW:S #imm,dst2 (m32 #3)
7884 (binary-arith32-s-imm-dst QI .b 0 sub #x0 #x7 sub-sem)
7885 (binary-arith32-s-imm-dst HI .w 1 sub #x0 #x7 sub-sem)
7886 ; sub.L:G src,dst (m32 #5)
7887 (binary-arith32-src-dst-defn SI SI .l 1 sub G #x1 #x0 sub-sem)
7889 ;-------------------------------------------------------------
7890 ; enter - enter function
7891 ; exitd - exit and deallocate stack frame
7892 ;-------------------------------------------------------------
7894 (define-pmacro (enter16-sem mach amt)
7896 (set (reg h-sp) (sub (reg h-sp) 2))
7897 (set (mem16 HI (reg h-sp)) (reg h-fb))
7898 (set (reg h-fb) (reg h-sp))
7899 (set (reg h-sp) (sub (reg h-sp) amt))))
7901 (define-pmacro (exit16-sem mach)
7902 (sequence ((SI newpc))
7903 (set (reg h-sp) (reg h-fb))
7904 (set (reg h-fb) (mem16 HI (reg h-sp)))
7905 (set (reg h-sp) (add (reg h-sp) 2))
7906 (set newpc (mem16 HI (reg h-sp)))
7907 (set (reg h-sp) (add (reg h-sp) 2))
7908 (set newpc (or newpc (sll (mem16 QI (reg h-sp)) (const 16))))
7909 (set (reg h-sp) (add (reg h-sp) 1))
7912 (define-pmacro (enter32-sem mach amt)
7914 (set (reg h-sp) (sub (reg h-sp) 4))
7915 (set (mem32 SI (reg h-sp)) (reg h-fb))
7916 (set (reg h-fb) (reg h-sp))
7917 (set (reg h-sp) (sub (reg h-sp) amt))))
7919 (define-pmacro (exit32-sem mach)
7920 (sequence ((SI newpc))
7921 (set (reg h-sp) (reg h-fb))
7922 (set (reg h-fb) (mem32 SI (reg h-sp)))
7923 (set (reg h-sp) (add (reg h-sp) 4))
7924 (set newpc (mem32 SI (reg h-sp)))
7925 (set (reg h-sp) (add (reg h-sp) 4))
7928 (dni enter16 "enter #Imm-16-QI" ((machine 16))
7929 ("enter #${Dsp-16-u8}")
7930 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 2) Dsp-16-u8)
7931 (enter16-sem 16 Dsp-16-u8)
7934 (dni exitd16 "exitd" ((machine 16))
7936 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 2))
7940 (dni enter32 "enter #Imm-8-QI" ((machine 32))
7941 ("enter #${Dsp-8-u8}")
7942 (+ (f-0-4 #xE) (f-4-4 #xC) Dsp-8-u8)
7943 (enter32-sem 32 Dsp-8-u8)
7946 (dni exitd32 "exitd" ((machine 32))
7948 (+ (f-0-4 #xF) (f-4-4 #xC))
7952 ;-------------------------------------------------------------
7953 ; fclr - flag register clear
7954 ; fset - flag register set
7955 ;-------------------------------------------------------------
7957 (define-pmacro (set-flags-sem flag)
7958 (sequence ((SI tmp))
7960 ((#x0) (set cbit 1))
7961 ((#x1) (set dbit 1))
7962 ((#x2) (set zbit 1))
7963 ((#x3) (set sbit 1))
7964 ((#x4) (set bbit 1))
7965 ((#x5) (set obit 1))
7966 ((#x6) (set ibit 1))
7967 ((#x7) (set ubit 1)))
7971 (define-pmacro (clear-flags-sem flag)
7972 (sequence ((SI tmp))
7974 ((#x0) (set cbit 0))
7975 ((#x1) (set dbit 0))
7976 ((#x2) (set zbit 0))
7977 ((#x3) (set sbit 0))
7978 ((#x4) (set bbit 0))
7979 ((#x5) (set obit 0))
7980 ((#x6) (set ibit 0))
7981 ((#x7) (set ubit 0)))
7985 (dni fclr16 "fclr flag" ((machine 16))
7987 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 5))
7988 (clear-flags-sem flags16)
7991 (dni fset16 "fset flag" ((machine 16))
7993 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 4))
7994 (set-flags-sem flags16)
7997 (dni fclr "fclr" ((machine 32))
7999 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xE) (f-12-1 1) flags32)
8000 (clear-flags-sem flags32)
8003 (dni fset "fset" ((machine 32))
8005 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xE) (f-12-1 1) flags32)
8006 (set-flags-sem flags32)
8009 ;-------------------------------------------------------------
8011 ;-------------------------------------------------------------
8013 (define-pmacro (inc-sem mode dest)
8014 (sequence ((mode result))
8015 (set result (add mode dest 1))
8016 (set-z-and-s result)
8023 "inc.b ${Dst16-3-S-8}"
8024 (+ (f-0-4 #xA) (f-4-1 #x0) Dst16-3-S-8)
8025 (inc-sem QI Dst16-3-S-8)
8031 "inc.w ${Dst16An-S}"
8032 (+ (f-0-4 #xB) (f-5-3 #x2) Dst16An-S)
8033 (inc-sem HI Dst16An-S)
8036 (unary32-defn QI .b 0 inc #xA #x0 #xE inc-sem)
8037 (unary32-defn HI .w 1 inc #xA #x0 #xE inc-sem)
8039 ;-------------------------------------------------------------
8040 ; freit - fast return from interrupt (m32)
8042 ; into - interrupt on overflow
8043 ;-------------------------------------------------------------
8046 (dni freit32 "FREIT" ((machine 32))
8048 (+ (f-0-4 9) (f-4-4 #xF))
8052 (dni int16 "int Dsp-10-u6" ((machine 16))
8053 ("int #${Dsp-10-u6}")
8054 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-2 3) Dsp-10-u6)
8055 (c-call VOID "do_int" pc Dsp-10-u6)
8058 (dni into16 "into" ((machine 16))
8060 (+ (f-0-4 #xF) (f-4-4 6))
8064 (dni int32 "int Dsp-8-u6" ((machine 32))
8065 ("int #${Dsp-8-u6}")
8066 (+ (f-0-4 #xB) (f-4-4 #xE) Dsp-8-u6 (f-14-2 0))
8067 (c-call VOID "do_int" pc Dsp-8-u6)
8070 (dni into32 "into" ((machine 32))
8072 (+ (f-0-4 #xB) (f-4-4 #xF))
8076 ;-------------------------------------------------------------
8078 ;-------------------------------------------------------------
8080 ; TODO add support to insns allowing index
8081 (define-pmacro (indexb-sem mode d) (set SrcIndex d) (set DstIndex d))
8082 (define-pmacro (indexbd-sem mode d) (set SrcIndex (const 0)) (set DstIndex d))
8083 (define-pmacro (indexbs-sem mode d) (set SrcIndex d) (set DstIndex (const 0)))
8084 (define-pmacro (indexw-sem mode d)
8085 (set SrcIndex (sll d (const 2))) (set DstIndex (sll d (const 2))))
8086 (define-pmacro (indexwd-sem mode d)
8087 (set SrcIndex (const 0)) (set DstIndex (sll d (const 2))))
8088 (define-pmacro (indexws-sem mode d)
8089 (set SrcIndex (sll d (const 2))) (set DstIndex (const 0)))
8090 (define-pmacro (indexl-sem mode d)
8091 (set SrcIndex d) (set DstIndex (sll d (const 2))))
8092 (define-pmacro (indexld-sem mode d)
8093 (set SrcIndex (const 0)) (set DstIndex (sll d (const 2))))
8094 (define-pmacro (indexls-sem mode d)
8095 (set SrcIndex (sll d (const 2))) (set DstIndex (const 0)))
8097 ; Note that "wbit" not where the size bit goes here, hence, it's
8098 ; always 0 in these calls but op2 differs instead.
8100 ; indexb src (index byte)
8101 (unary32-defn QI .b 0 indexb #x8 0 #x3 indexb-sem)
8102 (unary32-defn HI .w 0 indexb #x8 1 #x3 indexb-sem)
8103 ; indexbd src (index byte dest)
8104 (unary32-defn QI .b 0 indexbd #xA 0 3 indexbd-sem)
8105 (unary32-defn HI .w 0 indexbd #xA 1 3 indexbd-sem)
8106 ; indexbs src (index byte src)
8107 (unary32-defn QI .b 0 indexbs #xC 0 3 indexbs-sem)
8108 (unary32-defn HI .w 0 indexbs #xC 1 3 indexbs-sem)
8109 ; indexl src (index long)
8110 (unary32-defn QI .b 0 indexl 9 2 3 indexl-sem)
8111 (unary32-defn HI .w 0 indexl 9 3 3 indexl-sem)
8112 ; indexld src (index long dest)
8113 (unary32-defn QI .b 0 indexld #xB 2 3 indexld-sem)
8114 (unary32-defn HI .w 0 indexld #xB 3 3 indexld-sem)
8115 ; indexls src (index long src)
8116 (unary32-defn QI .b 0 indexls 9 0 3 indexls-sem)
8117 (unary32-defn HI .w 0 indexls 9 1 3 indexls-sem)
8118 ; indexw src (index word)
8119 (unary32-defn QI .b 0 indexw 8 2 3 indexw-sem)
8120 (unary32-defn HI .w 0 indexw 8 3 3 indexw-sem)
8121 ; indexwd src (index word dest)
8122 (unary32-defn QI .b 0 indexwd #xA 2 3 indexwd-sem)
8123 (unary32-defn HI .w 0 indexwd #xA 3 3 indexwd-sem)
8124 ; indexws (index word src)
8125 (unary32-defn QI .b 0 indexws #xC 2 3 indexws-sem)
8126 (unary32-defn HI .w 0 indexws #xC 3 3 indexws-sem)
8128 ;-------------------------------------------------------------
8129 ; jcc - jump on condition
8130 ;-------------------------------------------------------------
8132 (define-pmacro (jcnd32-sem cnd label)
8135 ((#x00) (if (not cbit) (set pc label))) ;ltu nc
8136 ((#x01) (if (not (and cbit (not zbit))) (set pc label))) ;leu
8137 ((#x02) (if (not zbit) (set pc label))) ;ne nz
8138 ((#x03) (if (not sbit) (set pc label))) ;pz
8139 ((#x04) (if (not obit) (set pc label))) ;no
8140 ((#x05) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt
8141 ((#x06) (if (not (xor sbit obit)) (set pc label))) ;ge
8142 ((#x08) (if (trunc BI cbit) (set pc label))) ;geu c
8143 ((#x09) (if (and cbit (not zbit)) (set pc label))) ;gtu
8144 ((#x0a) (if (trunc BI zbit) (set pc label))) ;eq z
8145 ((#x0b) (if (trunc BI sbit) (set pc label))) ;n
8146 ((#x0c) (if (trunc BI obit) (set pc label))) ;o
8147 ((#x0d) (if (or zbit (xor sbit obit)) (set pc label))) ;le
8148 ((#x0e) (if (xor sbit obit) (set pc label))) ;lt
8153 (define-pmacro (jcnd16-sem cnd label)
8156 ((#x00) (if (trunc BI cbit) (set pc label))) ;geu c
8157 ((#x01) (if (and cbit (not zbit)) (set pc label))) ;gtu
8158 ((#x02) (if (trunc BI zbit) (set pc label))) ;eq z
8159 ((#x03) (if (trunc BI sbit) (set pc label))) ;n
8160 ((#x04) (if (not cbit) (set pc label))) ;ltu nc
8161 ((#x05) (if (not (and cbit (not zbit))) (set pc label))) ;leu
8162 ((#x06) (if (not zbit) (set pc label))) ;ne nz
8163 ((#x07) (if (not sbit) (set pc label))) ;pz
8164 ((#x08) (if (or zbit (xor sbit obit)) (set pc label))) ;le
8165 ((#x09) (if (trunc BI obit) (set pc label))) ;o
8166 ((#x0a) (if (not (xor sbit obit)) (set pc label))) ;ge
8167 ((#x0c) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt
8168 ((#x0d) (if (not obit) (set pc label))) ;no
8169 ((#x0e) (if (xor sbit obit) (set pc label))) ;lt
8176 (RL_JUMP RELAXABLE (machine 16))
8177 "j$cond16j5 ${Lab-8-8}"
8178 (+ (f-0-4 #x6) (f-4-1 1) cond16j5 Lab-8-8)
8179 (jcnd16-sem cond16j5 Lab-8-8)
8185 (RL_JUMP RELAXABLE (machine 16))
8186 "j$cond16j ${Lab-16-8}"
8187 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xC) cond16j Lab-16-8)
8188 (jcnd16-sem cond16j Lab-16-8)
8194 (RL_JUMP RELAXABLE (machine 32))
8195 "j$cond32j ${Lab-8-8}"
8196 (+ (f-0-1 1) (f-4-3 5) cond32j Lab-8-8)
8197 (jcnd32-sem cond32j Lab-8-8)
8201 ;-------------------------------------------------------------
8203 ;-------------------------------------------------------------
8205 ; jmp.s label3 (m16 #1)
8206 (dni jmp16.s "jmp.s Lab-5-3" (RL_JUMP RELAXABLE (machine 16))
8207 ("jmp.s ${Lab-5-3}")
8208 (+ (f-0-4 6) (f-4-1 0) Lab-5-3)
8209 (sequence () (set pc Lab-5-3))
8211 ; jmp.b label8 (m16 #2)
8212 (dni jmp16.b "jmp.b Lab-8-8" (RL_JUMP RELAXABLE (machine 16))
8213 ("jmp.b ${Lab-8-8}")
8214 (+ (f-0-4 #xF) (f-4-4 #xE) Lab-8-8)
8215 (sequence () (set pc Lab-8-8))
8217 ; jmp.w label16 (m16 #3)
8218 (dni jmp16.w "jmp.w Lab-8-16" (RL_JUMP RELAXABLE (machine 16))
8219 ("jmp.w ${Lab-8-16}")
8220 (+ (f-0-4 #xF) (f-4-4 4) Lab-8-16)
8221 (sequence () (set pc Lab-8-16))
8223 ; jmp.a label24 (m16 #4)
8224 (dni jmp16.a "jmp.a Lab-8-24" (RL_JUMP RELAXABLE (machine 16))
8225 ("jmp.a ${Lab-8-24}")
8226 (+ (f-0-4 #xF) (f-4-4 #xC) Lab-8-24)
8227 (sequence () (set pc Lab-8-24))
8230 (define-pmacro (jmp16-sem mode dst)
8231 (set pc (and dst #xfffff))
8233 (define-pmacro (jmp32-sem mode dst)
8236 ; jmpi.w dst (m16 #1 m32 #2)
8237 (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)
8238 (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)
8239 ; jmpi.a dst (m16 #2 m32 #2)
8240 (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)
8241 (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)
8242 ; jmps imm8 (m16 #1)
8243 (dni jmps16 "jmps Imm-8-QI" ((machine 16))
8244 ("jmps #${Imm-8-QI}")
8245 (+ (f-0-4 #xE) (f-4-4 #xE) Imm-8-QI)
8246 (sequence () (set pc Imm-8-QI))
8248 ; jmp.s label3 (m32 #1)
8251 (RL_JUMP RELAXABLE (machine 32))
8252 "jmp.s ${Lab32-jmp-s}"
8253 (+ (f-0-2 1) (f-4-3 5) Lab32-jmp-s)
8254 (set pc Lab32-jmp-s)
8257 ; jmp.b label8 (m32 #2)
8258 (dni jmp32.b "jmp.b Lab-8-8" (RL_JUMP RELAXABLE (machine 32))
8259 ("jmp.b ${Lab-8-8}")
8260 (+ (f-0-4 #xB) (f-4-4 #xB) Lab-8-8)
8263 ; jmp.w label16 (m32 #3)
8264 (dni jmp32.w "jmp.w Lab-8-16" (RL_JUMP RELAXABLE (machine 32))
8265 ("jmp.w ${Lab-8-16}")
8266 (+ (f-0-4 #xC) (f-4-4 #xE) Lab-8-16)
8269 ; jmp.a label24 (m32 #4)
8270 (dni jmp32.a "jmp.a Lab-8-24" (RL_JUMP RELAXABLE (machine 32))
8271 ("jmp.a ${Lab-8-24}")
8272 (+ (f-0-4 #xC) (f-4-4 #xC) Lab-8-24)
8275 ; jmp.s imm8 (m32 #1)
8276 (dni jmps32 "jmps Imm-8-QI" (RL_JUMP (machine 32))
8277 ("jmps #${Imm-8-QI}")
8278 (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI)
8282 ;-------------------------------------------------------------
8283 ; jsr jump subroutine
8284 ;-------------------------------------------------------------
8286 (define-pmacro (jsr16-sem length dst)
8287 (sequence ((SI tpc))
8288 (set tpc (add pc length))
8289 (set (reg h-sp) (sub (reg h-sp) 2))
8290 (set (mem16 HI (reg h-sp)) (srl (and tpc #xffff00) 8))
8291 (set (reg h-sp) (sub (reg h-sp) 1))
8292 (set (mem16 QI (reg h-sp)) (and tpc #xff))
8296 (define-pmacro (jsr32-sem length dst)
8297 (sequence ((SI tpc))
8298 (set tpc (add pc length))
8299 (set (reg h-sp) (sub (reg h-sp) 2))
8300 (set (mem32 HI (reg h-sp)) (srl (and tpc #xffff0000) 16))
8301 (set (reg h-sp) (sub (reg h-sp) 2))
8302 (set (mem32 HI (reg h-sp)) (and tpc #xffff))
8307 ; jsr.w label16 (m16 #1)
8308 (dni jsr16.w "jsr.w Lab-8-16" (RL_JUMP RELAXABLE (machine 16))
8309 ("jsr.w ${Lab-8-16}")
8310 (+ (f-0-4 #xF) (f-4-4 5) Lab-8-16)
8311 (jsr16-sem 3 Lab-8-16)
8313 ; jsr.a label24 (m16 #2)
8314 (dni jsr16.a "jsr.a Lab-8-24" (RL_JUMP RELAXABLE (machine 16))
8315 ("jsr.a ${Lab-8-24}")
8316 (+ (f-0-4 #xF) (f-4-4 #xD) Lab-8-24)
8317 (jsr16-sem 4 Lab-8-24)
8319 (define-pmacro (jsri-defn mode op16 op16-1 op16-2 op16-3 op16-sem
8320 op32 op32-1 op32-2 op32-3 op32-4 op32-sem len)
8322 (dni (.sym jsri16 mode - op16)
8323 (.str "jsri." mode " " op16)
8324 (RL_1ADDR (machine 16))
8325 (.str "jsri." mode " ${" op16 "}")
8326 (+ op16-1 op16-2 op16-3 op16)
8329 (dni (.sym jsri32 mode - op32)
8330 (.str "jsri." mode " " op32)
8331 (RL_1ADDR (machine 32))
8332 (.str "jsri." mode " ${" op32 "}")
8333 (+ op32-1 op32-2 op32-3 op32-4 op32)
8338 ; jsri.w dst (m16 #1 m32 #1))
8339 (jsri-defn w dst16-16-20ar-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8340 dst32-16-24-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 4)
8341 (jsri-defn w dst16-16-16sa-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8342 dst32-16-16sa-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 4)
8343 (jsri-defn w dst16-16-8-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8344 dst32-16-8-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 3)
8345 (jsri-defn w dst16-basic-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8346 dst32-basic-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 2)
8348 ; jsri.a (m16 #2 m32 #2)
8349 (jsri-defn a dst16-16-20ar-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8350 dst32-16-24-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 4)
8351 (jsri-defn a dst16-16-8-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8352 dst32-16-8-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 3)
8353 (jsri-defn a dst16-16-16sa-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8354 dst32-16-16sa-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 4)
8355 (jsri-defn a dst16-basic-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8356 dst32-basic-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 2)
8358 (dni jsri32.a "jsr.w dst32-16-24-Unprefixed-HI" (RL_1ADDR (machine 32))
8359 ("jsri.a ${dst32-16-24-Unprefixed-SI}")
8360 (+ (f-0-4 #x9) (f-7-1 0) dst32-16-24-Unprefixed-SI (f-10-2 #x0) (f-12-4 #x1))
8361 (jsr32-sem 6 dst32-16-24-Unprefixed-SI)
8363 ; jsr.w label16 (m32 #1)
8364 (dni jsr32.w "jsr.w label" (RL_JUMP RELAXABLE (machine 32))
8365 ("jsr.w ${Lab-8-16}")
8366 (+ (f-0-4 #xC) (f-4-4 #xF) Lab-8-16)
8367 (jsr32-sem 3 Lab-8-16)
8369 ; jsr.a label16 (m32 #2)
8370 (dni jsr32.a "jsr.a label" (RL_JUMP (machine 32))
8371 ("jsr.a ${Lab-8-24}")
8372 (+ (f-0-4 #xC) (f-4-4 #xD) Lab-8-24)
8373 (jsr32-sem 4 Lab-8-24)
8375 ; jsrs imm8 (m16 #1)
8376 (dni jsrs16 "jsrs Imm-8-QI" ((machine 16))
8377 ("jsrs #${Imm-8-QI}")
8378 (+ (f-0-4 #xE) (f-4-4 #xF) Imm-8-QI)
8379 (jsr16-sem 2 Imm-8-QI)
8381 ; jsrs imm8 (m32 #1)
8382 (dni jsrs "jsrs #Imm-8-QI" ((machine 32))
8383 ("jsrs #${Imm-8-QI}")
8384 (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI)
8385 (jsr32-sem 2 Imm-8-QI)
8388 ;-------------------------------------------------------------
8389 ; ldc - load control register
8390 ; stc - store control register
8391 ;-------------------------------------------------------------
8393 (define-pmacro (ldc32-cr1-sem src dst)
8396 ((#x0) (set (reg h-dct0) src))
8397 ((#x1) (set (reg h-dct1) src))
8398 ((#x2) (sequence ((HI tflag))
8400 (if (and tflag #x1) (set cbit 1))
8401 (if (and tflag #x2) (set dbit 1))
8402 (if (and tflag #x4) (set zbit 1))
8403 (if (and tflag #x8) (set sbit 1))
8404 (if (and tflag #x10) (set bbit 1))
8405 (if (and tflag #x20) (set obit 1))
8406 (if (and tflag #x40) (set ibit 1))
8407 (if (and tflag #x80) (set ubit 1))))
8408 ((#x3) (set (reg h-svf) src))
8409 ((#x4) (set (reg h-drc0) src))
8410 ((#x5) (set (reg h-drc1) src))
8411 ((#x6) (set (reg h-dmd0) src))
8412 ((#x7) (set (reg h-dmd1) src))
8416 (define-pmacro (ldc32-cr2-sem src dst)
8419 ((#x0) (set (reg h-intb) src))
8420 ((#x1) (set (reg h-sp) src))
8421 ((#x2) (set (reg h-sb) src))
8422 ((#x3) (set (reg h-fb) src))
8423 ((#x4) (set (reg h-svp) src))
8424 ((#x5) (set (reg h-vct) src))
8425 ((#x7) (set (reg h-isp) src))
8429 (define-pmacro (ldc32-cr3-sem src dst)
8432 ((#x2) (set (reg h-dma0) src))
8433 ((#x3) (set (reg h-dma1) src))
8434 ((#x4) (set (reg h-dra0) src))
8435 ((#x5) (set (reg h-dra1) src))
8436 ((#x6) (set (reg h-dsa0) src))
8437 ((#x7) (set (reg h-dsa1) src))
8441 (define-pmacro (ldc16-sem src dst)
8444 ((#x1) (set (reg h-intb) src))
8445 ((#x2) (set (reg h-intb) (or (reg h-intb) (sll src (const 16)))))
8446 ((#x3) (sequence ((HI tflag))
8448 (if (and tflag #x1) (set cbit 1))
8449 (if (and tflag #x2) (set dbit 1))
8450 (if (and tflag #x4) (set zbit 1))
8451 (if (and tflag #x8) (set sbit 1))
8452 (if (and tflag #x10) (set bbit 1))
8453 (if (and tflag #x20) (set obit 1))
8454 (if (and tflag #x40) (set ibit 1))
8455 (if (and tflag #x80) (set ubit 1))))
8456 ((#x4) (set (reg h-isp) src))
8457 ((#x5) (set (reg h-sp) src))
8458 ((#x6) (set (reg h-sb) src))
8459 ((#x7) (set (reg h-fb) src))
8464 (define-pmacro (stc32-cr1-sem src dst)
8467 ((#x0) (set dst (reg h-dct0)))
8468 ((#x1) (set dst (reg h-dct1)))
8469 ((#x2) (sequence ((HI tflag))
8471 (if (eq cbit 1) (set tflag (or tflag #x1)))
8472 (if (eq dbit 1) (set tflag (or tflag #x2)))
8473 (if (eq zbit 1) (set tflag (or tflag #x4)))
8474 (if (eq sbit 1) (set tflag (or tflag #x8)))
8475 (if (eq bbit 1) (set tflag (or tflag #x10)))
8476 (if (eq obit 1) (set tflag (or tflag #x20)))
8477 (if (eq ibit 1) (set tflag (or tflag #x40)))
8478 (if (eq ubit 1) (set tflag (or tflag #x80)))
8480 ((#x3) (set dst (reg h-svf)))
8481 ((#x4) (set dst (reg h-drc0)))
8482 ((#x5) (set dst (reg h-drc1)))
8483 ((#x6) (set dst (reg h-dmd0)))
8484 ((#x7) (set dst (reg h-dmd1)))
8488 (define-pmacro (stc32-cr2-sem src dst)
8491 ((#x0) (set dst (reg h-intb)))
8492 ((#x1) (set dst (reg h-sp)))
8493 ((#x2) (set dst (reg h-sb)))
8494 ((#x3) (set dst (reg h-fb)))
8495 ((#x4) (set dst (reg h-svp)))
8496 ((#x5) (set dst (reg h-vct)))
8497 ((#x7) (set dst (reg h-isp)))
8501 (define-pmacro (stc32-cr3-sem src dst)
8504 ((#x2) (set dst (reg h-dma0)))
8505 ((#x3) (set dst (reg h-dma1)))
8506 ((#x4) (set dst (reg h-dra0)))
8507 ((#x5) (set dst (reg h-dra1)))
8508 ((#x6) (set dst (reg h-dsa0)))
8509 ((#x7) (set dst (reg h-dsa1)))
8513 (define-pmacro (stc16-sem src dst)
8516 ((#x1) (set dst (and (reg h-intb) (const #xffff))))
8517 ((#x2) (set dst (srl (reg h-intb) (const 16))))
8518 ((#x3) (sequence ((HI tflag))
8520 (if (eq cbit 1) (set tflag (or tflag #x1)))
8521 (if (eq dbit 1) (set tflag (or tflag #x2)))
8522 (if (eq zbit 1) (set tflag (or tflag #x4)))
8523 (if (eq sbit 1) (set tflag (or tflag #x8)))
8524 (if (eq bbit 1) (set tflag (or tflag #x10)))
8525 (if (eq obit 1) (set tflag (or tflag #x20)))
8526 (if (eq ibit 1) (set tflag (or tflag #x40)))
8527 (if (eq ubit 1) (set tflag (or tflag #x80)))
8529 ((#x4) (set dst (reg h-isp)))
8530 ((#x5) (set dst (reg h-sp)))
8531 ((#x6) (set dst (reg h-sb)))
8532 ((#x7) (set dst (reg h-fb)))
8537 (dni ldc16.imm16 "ldc #imm,dst" ((machine 16))
8538 ("ldc #${Imm-16-HI},${cr16}")
8539 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 0) cr16 Imm-16-HI)
8540 (ldc16-sem Imm-16-HI cr16)
8543 (dni ldc16.dst "ldc src,dest" ((machine 16))
8544 ("ldc ${dst16-16-HI},${cr16}")
8545 (+ (f-0-4 7) (f-4-4 #xA) (f-8-1 1) cr16 dst16-16-HI)
8546 (ldc16-sem dst16-16-HI cr16)
8548 ; ldc src,dest (m32c #4)
8549 (dni ldc32.src-cr1 "ldc src,dst" ((machine 32))
8550 ("ldc ${dst32-24-Prefixed-HI},${cr1-Prefixed-32}")
8551 (+ (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)
8552 (ldc32-cr1-sem dst32-24-Prefixed-HI cr1-Prefixed-32)
8554 ; ldc src,dest (m32c #5)
8555 (dni ldc32.src-cr2 "ldc src,dest" ((machine 32))
8556 ("ldc ${dst32-16-Unprefixed-SI},${cr2-32}")
8557 (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 0) cr2-32)
8558 (ldc32-cr2-sem dst32-16-Unprefixed-SI cr2-32)
8560 ; ldc src,dest (m32c #6)
8561 (dni ldc32.src-cr3 "ldc src,dst" ((machine 32))
8562 ("ldc ${dst32-24-Prefixed-SI},${cr3-Prefixed-32}")
8563 (+ (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)
8564 (ldc32-cr3-sem dst32-24-Prefixed-SI cr3-Prefixed-32)
8566 ; ldc src,dest (m32c #1)
8567 (dni ldc32.imm16-cr1 "ldc #imm,dst" ((machine 32))
8568 ("ldc #${Imm-16-HI},${cr1-Unprefixed-32}")
8569 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32 Imm-16-HI)
8570 (ldc32-cr1-sem Imm-16-HI cr1-Unprefixed-32)
8572 ; ldc src,dest (m32c #2)
8573 (dni ldc32.imm16-cr2 "ldc #imm,dst" ((machine 32))
8574 ("ldc #${Dsp-16-u24},${cr2-32}")
8575 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 2) (f-12-1 1) cr2-32 Dsp-16-u24)
8576 (ldc32-cr2-sem Dsp-16-u24 cr2-32)
8578 ; ldc src,dest (m32c #3)
8579 (dni ldc32.imm16-cr3 "ldc #imm,dst" ((machine 32))
8580 ("ldc #${Dsp-16-u24},${cr3-Unprefixed-32}")
8581 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 6) (f-12-1 1) cr3-Unprefixed-32 Dsp-16-u24)
8582 (ldc32-cr3-sem Dsp-16-u24 cr3-Unprefixed-32)
8585 (dni stc16.src "stc src,dest" ((machine 16))
8586 ("stc ${cr16},${dst16-16-HI}")
8587 (+ (f-0-4 7) (f-4-4 #xB) (f-8-1 1) cr16 dst16-16-HI)
8588 (stc16-sem cr16 dst16-16-HI )
8591 (dni stc16.pc "stc pc,dest" ((machine 16))
8592 ("stc pc,${dst16-16-HI}")
8593 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xC) dst16-16-HI)
8594 (sequence () (set dst16-16-HI (reg h-pc)))
8597 (dni stc32.src-cr1 "stc src,dst" ((machine 32))
8598 ("stc ${cr1-Prefixed-32},${dst32-24-Prefixed-HI}")
8599 (+ (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)
8600 (stc32-cr1-sem cr1-Prefixed-32 dst32-24-Prefixed-HI )
8603 (dni stc32.src-cr2 "stc src,dest" ((machine 32))
8604 ("stc ${cr2-32},${dst32-16-Unprefixed-SI}")
8605 (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 2) cr2-32)
8606 (stc32-cr2-sem cr2-32 dst32-16-Unprefixed-SI )
8609 (dni stc32.src-cr3 "stc src,dst" ((machine 32))
8610 ("stc ${cr3-Prefixed-32},${dst32-24-Prefixed-SI}")
8611 (+ (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)
8612 (stc32-cr3-sem cr3-Prefixed-32 dst32-24-Prefixed-SI )
8615 ;-------------------------------------------------------------
8616 ; ldctx - load context
8617 ; stctx - store context
8618 ;-------------------------------------------------------------
8621 (dni ldctx16 "ldctx abs16,abs24" ((machine 16))
8622 ("ldctx ${Dsp-16-u16},${Dsp-32-u24}")
8623 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24)
8626 (dni ldctx32 "ldctx abs16,abs24" ((machine 32))
8627 ("ldctx ${Dsp-16-u16},${Dsp-32-u24}")
8628 (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xC) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24)
8631 (dni stctx16 "stctx abs16,abs24" ((machine 16))
8632 ("stctx ${Dsp-16-u16},${Dsp-32-u24}")
8633 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24)
8636 (dni stctx32 "stctx abs16,abs24" ((machine 32))
8637 ("stctx ${Dsp-16-u16},${Dsp-32-u24}")
8638 (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xD) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24)
8642 ;-------------------------------------------------------------
8643 ; lde - load from extra far data area (m16)
8644 ; ste - store to extra far data area (m16)
8645 ;-------------------------------------------------------------
8653 ;-------------------------------------------------------------
8654 ; ldipl - load interrupt permission level
8655 ;-------------------------------------------------------------
8658 ; ldintb <==> ldc #imm,intbh ; ldc #imm,intbl
8660 (dni ldipl16.imm "ldipl #imm" ((machine 16))
8661 ("ldipl #${Imm-13-u3}")
8662 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xA) (f-12-1 0) Imm-13-u3)
8665 (dni ldipl32.imm "ldipl #imm" ((machine 32))
8666 ("ldipl #${Imm-13-u3}")
8667 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xE) (f-12-1 1) Imm-13-u3)
8672 ;-------------------------------------------------------------
8673 ; max - maximum value
8674 ;-------------------------------------------------------------
8676 ; TODO check semantics for min -1,0
8677 (define-pmacro (max-sem mode src dst)
8679 (if (gt mode src dst)
8680 (set mode dst src)))
8683 ; max.size:G #imm,dst
8684 (binary-arith32-imm-dst-Prefixed QI QI .b 0 max X #x8 #x3 #xF max-sem)
8685 (binary-arith32-imm-dst-Prefixed HI HI .w 1 max X #x8 #x3 #xF max-sem)
8688 (binary-arith32-src-dst-Prefixed QI QI .b 0 max X #x1 #xD max-sem)
8689 (binary-arith32-src-dst-Prefixed HI HI .w 1 max X #x1 #xD max-sem)
8691 ;-------------------------------------------------------------
8692 ; min - minimum value
8693 ;-------------------------------------------------------------
8695 (define-pmacro (min-sem mode src dst)
8697 (if (lt mode src dst)
8698 (set mode dst src)))
8701 ; min.size:G #imm,dst
8702 (binary-arith32-imm-dst-Prefixed QI QI .b 0 min X #x8 #x2 #xF min-sem)
8703 (binary-arith32-imm-dst-Prefixed HI HI .w 1 min X #x8 #x2 #xF min-sem)
8706 (binary-arith32-src-dst-Prefixed QI QI .b 0 min X #x1 #xC min-sem)
8707 (binary-arith32-src-dst-Prefixed HI HI .w 1 min X #x1 #xC min-sem)
8709 ;-------------------------------------------------------------
8711 ;-------------------------------------------------------------
8713 (define-pmacro (mov-sem mode src1 dst)
8714 (sequence ((mode result))
8716 (set-z-and-s result)
8717 (set mode dst src1))
8720 (define-pmacro (mov-dspsp-dst-sem mach mode src1 dst)
8721 (set dst (mem-mach mach mode (add sp src1)))
8724 (define-pmacro (mov-src-dspsp-sem mach mode src dst1)
8725 (set (mem-mach mach mode (add sp dst1)) src)
8728 (define-pmacro (mov16-imm-an-defn size mode imm regn op1 op2)
8729 (dni (.sym mov16. size .S-imm- regn)
8730 (.str "mov." size ":S " imm "," regn)
8732 (.str "mov." size "$S #${" imm "}," regn)
8734 (mov-sem mode imm (reg (.sym h- regn)))
8737 ; mov.size:G #imm,dst (m16 #1 m32 #1)
8738 (binary-arith-imm-dst mov G (f-0-4 7) (f-4-3 2) (f-8-4 #xC) #x9 #x2 #xF mov-sem)
8739 ; mov.L:G #imm32,dst (m32 #2)
8740 (binary-arith32-imm-dst-defn SI SI .l 0 mov G #xB #x3 #x1 mov-sem)
8741 ; mov.BW:S #imm,dst2 (m32 #4)
8742 (binary-arith32-s-imm-dst QI .b 0 mov #x0 #x2 mov-sem)
8743 (binary-arith32-s-imm-dst HI .w 1 mov #x0 #x2 mov-sem)
8744 ; mov.b:S #imm8,dst3 (m16 #3)
8745 (binary-arith16-b-S-imm8-dst3 mov ".b" (f-0-4 #xC) (f-4-1 0) mov-sem)
8746 ; mov.b:S #imm8,aN (m16 #4)
8747 (mov16-imm-an-defn b QI Imm-8-QI a0 (f-0-4 #xE) (f-4-4 2))
8748 (mov16-imm-an-defn b QI Imm-8-QI a1 (f-0-4 #xE) (f-4-4 #xA))
8749 (mov16-imm-an-defn w HI Imm-8-HI a0 (f-0-4 #xA) (f-4-4 2))
8750 (mov16-imm-an-defn w HI Imm-8-HI a1 (f-0-4 #xA) (f-4-4 #xA))
8751 ; mov.WL:S #imm,A0/A1 (m32 #5)
8752 (define-pmacro (mov32-wl-s-defn mode sz op1 imm regn op2)
8753 (dni (.sym mov32- sz - regn)
8754 (.str "mov." sz ":s" imm "," regn)
8756 (.str "mov." sz "$S #${" imm "}," regn)
8757 (+ (f-0-4 op1) (f-4-4 op2) imm)
8758 (mov-sem mode imm (reg (.sym h- regn)))
8761 (mov32-wl-s-defn HI w #x9 Imm-8-HI a0 #xC)
8762 (mov32-wl-s-defn HI w #x9 Imm-8-HI a1 #xD)
8763 (mov32-wl-s-defn SI l #xB Dsp-8-s24 a0 #xC)
8764 (mov32-wl-s-defn SI l #xB Dsp-8-s24 a1 #xD)
8766 ; mov.size:Q #imm4,dst (m16 #2 m32 #3)
8767 (binary-arith16-imm4-dst-defn QI .b 0 0 mov (f-0-4 #xD) (f-4-3 4) mov-sem)
8768 (binary-arith16-imm4-dst-defn HI .w 0 1 mov (f-0-4 #xD) (f-4-3 4) mov-sem)
8769 (binary-arith32-imm4-dst-defn QI .b 1 0 mov #x7 #x2 mov-sem)
8770 (binary-arith32-imm4-dst-defn HI .w 1 1 mov #x7 #x2 mov-sem)
8772 ; mov.BW:Z #0,dst (m16 #5 m32 #6)
8773 (dni mov16.b-Z-imm8-dst3
8774 "mov.b:Z #0,Dst16-3-S-8"
8776 "mov.b$Z #0,${Dst16-3-S-8}"
8777 (+ (f-0-4 #xB) (f-4-1 #x0) Dst16-3-S-8)
8778 (mov-sem QI (const 0) Dst16-3-S-8)
8780 ; (binary-arith16-b-Z-imm8-dst3 mov ".b" (f-0-4 #xB) (f-4-1 0) mov-sem)
8781 (binary-arith32-z-imm-dst QI .b 0 mov #x0 #x1 mov-sem)
8782 (binary-arith32-z-imm-dst HI .w 1 mov #x0 #x1 mov-sem)
8783 ; mov.BW:G src,dst (m16 #6 m32 #7)
8784 (binary-arith-src-dst mov G (f-0-4 #x7) (f-4-3 1) #x1 #xB mov-sem)
8785 ; mov.B:S src2,a0/a1 (m16 #7)
8786 (dni (.sym mov 16 .b.S-An)
8787 (.str mov ".b:S src2,a[01]")
8789 (.str mov ".b$S ${src16-2-S},${Dst16AnQI-S}")
8790 (+ (f-0-4 #x3) (f-4-1 0) Dst16AnQI-S src16-2-S)
8791 (mov-sem QI src16-2-S Dst16AnQI-S)
8793 (define-pmacro (mov16-b-s-an-defn op1 op2 op2c)
8794 (dni (.sym mov16.b.S- op1 - op2)
8795 (.str mov ".b:S " op1 "," op2)
8797 (.str mov ".b$S " op1 "," op2)
8798 (+ (f-0-4 #x3) op2c)
8799 (mov-sem QI (reg (.sym h- op1)) (reg (.sym h- op2)))
8802 (mov16-b-s-an-defn r0l a1 (f-4-4 #x4))
8803 (mov16-b-s-an-defn r0h a0 (f-4-4 #x0))
8805 ; mov.L:G src,dst (m32 #8)
8806 (binary-arith32-src-dst-defn SI SI .l 1 mov G #x1 #x3 mov-sem)
8807 ; mov.B:S r0l/r0h,dst2 (m16 #8)
8808 (dni (.sym mov 16 .b.S-Rn-An)
8809 (.str mov ".b:S r0[lh],src2")
8811 (.str mov ".b$S ${Dst16RnQI-S},${src16-2-S}")
8812 (+ (f-0-4 #x0) (f-4-1 0) Dst16RnQI-S src16-2-S)
8813 (mov-sem QI src16-2-S Dst16RnQI-S)
8816 ; mov.B.S src2,r0l/r0h (m16 #9)
8817 (binary-arith16-b-S-src2 mov (f-0-4 0) (f-4-1 1) mov-sem)
8819 ; mov.BW:S src2,r0l/r0 (m32 #9)
8820 ; mov.BW:S src2,r1l/r1 (m32 #10)
8821 (define-pmacro (mov32-src-r sz szcode mode src dst opc1 opc2)
8823 (dni (.sym mov32. sz - src - dst)
8824 (.str "mov." sz "src," dst)
8826 (.str "mov." sz "$S ${" (.sym src - mode) "}," dst)
8827 (+ (f-0-2 opc1) (.sym src - mode) (f-4-3 opc2) (f-7-1 szcode))
8828 (mov-sem mode (.sym src - mode) (reg (.sym h- dst)))
8832 (mov32-src-r b 0 QI dst32-2-S-16 r0l 0 4)
8833 (mov32-src-r w 1 HI dst32-2-S-16 r0 0 4)
8834 (mov32-src-r b 0 QI dst32-2-S-8 r0l 0 4)
8835 (mov32-src-r w 1 HI dst32-2-S-8 r0 0 4)
8836 (mov32-src-r b 0 QI dst32-2-S-basic r1l 1 7)
8837 (mov32-src-r w 1 HI dst32-2-S-basic r1 1 7)
8838 (mov32-src-r b 0 QI dst32-2-S-16 r1l 1 7)
8839 (mov32-src-r w 1 HI dst32-2-S-16 r1 1 7)
8840 (mov32-src-r b 0 QI dst32-2-S-8 r1l 1 7)
8841 (mov32-src-r w 1 HI dst32-2-S-8 r1 1 7)
8843 ; mov.BW:S r0l/r0,dst2 (m32 #11)
8844 (define-pmacro (mov32-r-dest sz szcode mode src dst opc1 opc2)
8846 (dni (.sym mov32. sz - src - dst)
8847 (.str "mov." sz "src," dst)
8849 (.str "mov." sz "$S " src ",${" (.sym dst - mode) "}")
8850 (+ (f-0-2 opc1) (.sym dst - mode) (f-4-3 opc2) (f-7-1 szcode))
8851 (mov-sem mode (reg (.sym h- src)) (.sym dst - mode))
8855 (mov32-r-dest b 0 QI r0l dst32-2-S-16 0 0)
8856 (mov32-r-dest w 1 HI r0 dst32-2-S-16 0 0)
8857 (mov32-r-dest b 0 QI r0l dst32-2-S-8 0 0)
8858 (mov32-r-dest w 1 HI r0 dst32-2-S-8 0 0)
8860 ; mov.L:S src,A0/A1 (m32 #12)
8861 (define-pmacro (mov32-src-a src dst dstcode opc1 opc2)
8863 (dni (.sym mov32. sz - src - dst)
8864 (.str "mov." sz "src," dst)
8866 (.str "mov.l" "$S ${" (.sym src - SI) "}," dst)
8867 (+ (f-0-2 opc1) (.sym src - SI) (f-4-3 opc2) (f-7-1 dstcode))
8868 (mov-sem SI (.sym src - SI) (reg (.sym h- dst)))
8872 (mov32-src-a dst32-2-S-16 a0 0 1 4)
8873 (mov32-src-a dst32-2-S-16 a1 1 1 4)
8874 (mov32-src-a dst32-2-S-8 a0 0 1 4)
8875 (mov32-src-a dst32-2-S-8 a1 1 1 4)
8877 ; mov.BW:G dsp8[sp],dst (m16 #10 m32 #13)
8878 ; mov.BW:G src,dsp8[sp] (m16 #11 m32 #14)
8879 (mov-dspsp-dst mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #xB) #xB #x0 #xF mov-dspsp-dst-sem)
8880 (mov-src-dspsp mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #x3) #xA #x0 #xF mov-src-dspsp-sem)
8882 ;-------------------------------------------------------------
8883 ; mova - move effective address
8884 ;-------------------------------------------------------------
8886 (define-pmacro (mov16a-defn dst dstop dstcode)
8887 (dni (.sym mova16. src - dst)
8888 (.str "mova src," dst)
8890 (.str "mova ${dst16-16-Mova-HI}," dst)
8891 (+ (f-0-4 #xE) (f-4-4 #xB) dst16-16-Mova-HI (f-8-4 dstcode))
8892 (sequence () (set HI (reg dstop) dst16-16-Mova-HI))
8895 (mov16a-defn r0 h-r0 0)
8896 (mov16a-defn r1 h-r1 1)
8897 (mov16a-defn r2 h-r2 2)
8898 (mov16a-defn r3 h-r3 3)
8899 (mov16a-defn a0 h-a0 4)
8900 (mov16a-defn a1 h-a1 5)
8902 (define-pmacro (mov32a-defn dst dstop dstcode)
8903 (dni (.sym mova32. src - dst)
8904 (.str "mova src," dst)
8906 (.str "mova ${dst32-16-Unprefixed-Mova-SI}," dst)
8907 (+ (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))
8908 (sequence () (set SI (reg dstop) dst32-16-Unprefixed-Mova-SI))
8911 (mov32a-defn r2r0 h-r2r0 0)
8912 (mov32a-defn r3r1 h-r3r1 1)
8913 (mov32a-defn a0 h-a0 2)
8914 (mov32a-defn a1 h-a1 3)
8916 ;-------------------------------------------------------------
8917 ; movDir - move nibble
8918 ;-------------------------------------------------------------
8920 (define-pmacro (movdir-sem nib src dst)
8921 (sequence ((SI tmp))
8923 ((0) (set dst (or (and dst #xf0) (and src #xf))))
8924 ((1) (set dst (or (and dst #x0f) (sll (and src #xf) 4))))
8925 ((2) (set dst (or (and dst #xf0) (srl (and src #xf0) 4))))
8926 ((3) (set dst (or (and dst #x0f) (and src #xf0))))
8931 (define-pmacro (mov16dir-1-defn nib dircode dir)
8932 (dni (.sym mov nib 16 ".r0l-dst")
8933 (.str "mov" nib " r0l,dst")
8935 (.str "mov" nib " r0l,${dst16-16-QI}")
8936 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI)
8937 (movdir-sem dircode (reg h-r0l) dst16-16-QI)
8940 (mov16dir-1-defn ll 0 8)
8941 (mov16dir-1-defn lh 1 #xA)
8942 (mov16dir-1-defn hl 2 9)
8943 (mov16dir-1-defn hh 3 #xB)
8944 (define-pmacro (mov16dir-2-defn nib dircode dir)
8945 (dni (.sym mov nib 16 ".src-r0l")
8946 (.str "mov" nib " src,r0l")
8948 (.str "mov" nib " ${dst16-16-QI},r0l")
8949 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI)
8950 (movdir-sem dircode dst16-16-QI (reg h-r0l))
8953 (mov16dir-2-defn ll 0 0)
8954 (mov16dir-2-defn lh 1 2)
8955 (mov16dir-2-defn hl 2 1)
8956 (mov16dir-2-defn hh 3 3)
8958 (define-pmacro (mov32dir-1-defn nib o1o0)
8959 (dni (.sym mov nib 32 ".r0l-dst")
8960 (.str "mov" nib " r0l,dst")
8962 (.str "mov" nib " r0l,${dst32-24-Prefixed-QI}")
8963 (+ (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))
8964 (movdir-sem o1o0 (reg h-r0l) dst32-24-Prefixed-QI)
8967 (mov32dir-1-defn ll 0)
8968 (mov32dir-1-defn lh 1)
8969 (mov32dir-1-defn hl 2)
8970 (mov32dir-1-defn hh 3)
8971 (define-pmacro (mov32dir-2-defn nib o1o0)
8972 (dni (.sym mov nib 32 ".src-r0l")
8973 (.str "mov" nib " src,r0l")
8975 (.str "mov" nib " ${dst32-24-Prefixed-QI},r0l")
8976 (+ (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))
8977 (movdir-sem o1o0 dst32-24-Prefixed-QI (reg h-r0l))
8980 (mov32dir-2-defn ll 0)
8981 (mov32dir-2-defn lh 1)
8982 (mov32dir-2-defn hl 2)
8983 (mov32dir-2-defn hh 3)
8985 ;-------------------------------------------------------------
8986 ; movx - move extend sign (m32)
8987 ;-------------------------------------------------------------
8989 (define-pmacro (movx-sem mode src dst)
8990 (sequence ((SI source) (SI result))
8992 (set-z-and-s result)
8997 (binary-arith32-imm-dst-defn QI SI "" 0 movx X #xB #x1 #x1 movx-sem)
8999 ;-------------------------------------------------------------
9001 ;-------------------------------------------------------------
9003 (define-pmacro (mul-sem mode src1 dst)
9004 (sequence ((mode result))
9005 (set obit (add-oflag mode src1 dst 0))
9006 (set result (mul mode src1 dst))
9011 (binary-arith-imm-dst mul G (f-0-4 7) (f-4-3 6) (f-8-4 5) #x8 #x1 #xF mul-sem)
9013 (binary-arith-src-dst mul G (f-0-4 #x7) (f-4-3 4) #x1 #xC mul-sem)
9015 (dni mul_l "mul.l src,r2r0" ((machine 32))
9016 ("mul.l ${dst32-24-Prefixed-SI},r2r0")
9017 (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #x8) (f-15-1 #x1) (f-18-2 #x1) (f-20-4 #xf)
9018 dst32-24-Prefixed-SI)
9021 (dni mulu_l "mulu.l src,r2r0" ((machine 32))
9022 ("mulu.l ${dst32-24-Prefixed-SI},r2r0")
9023 (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #x8) (f-15-1 #x1) (f-18-2 #x0) (f-20-4 #xf)
9024 dst32-24-Prefixed-SI)
9026 ;-------------------------------------------------------------
9027 ; mulex - multiple extend sign (m32)
9028 ;-------------------------------------------------------------
9031 ; (dni mulex-absolute-indirect "mulex [src]" ((machine 32))
9032 ; ("mulex ${dst32-24-absolute-indirect-HI}")
9033 ; (+ (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))
9034 ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-absolute-indirect-HI)))
9036 (dni mulex "mulex src" ((machine 32))
9037 ("mulex ${dst32-16-Unprefixed-Mulex-HI}")
9038 (+ (f-0-4 #xC) dst32-16-Unprefixed-Mulex-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
9039 (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-16-Unprefixed-Mulex-HI)))
9041 ; (dni mulex-indirect "mulex [src]" ((machine 32))
9042 ; ("mulex ${dst32-24-indirect-HI}")
9043 ; (+ (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))
9044 ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-indirect-HI)))
9047 ;-------------------------------------------------------------
9048 ; mulu - multiply unsigned
9049 ;-------------------------------------------------------------
9051 (define-pmacro (mulu-sem mode src1 dst)
9052 (sequence ((mode result))
9053 (set obit (add-oflag mode src1 dst 0))
9054 (set result (mul mode src1 dst))
9059 (binary-arith-imm-dst mulu G (f-0-4 7) (f-4-3 6) (f-8-4 4) #x8 #x0 #xF mulu-sem)
9061 (binary-arith-src-dst mulu G (f-0-4 #x7) (f-4-3 0) #x1 #x4 mulu-sem)
9063 ;-------------------------------------------------------------
9064 ; neg - twos complement
9065 ;-------------------------------------------------------------
9067 (define-pmacro (neg-sem mode dst)
9068 (sequence ((mode result))
9069 (set result (neg mode dst))
9070 (set-z-and-s result)
9075 (unary-insn neg (f-0-4 7) (f-4-3 2) (f-8-4 #x5) #xA #x2 #xF neg-sem)
9077 ;-------------------------------------------------------------
9078 ; not - twos complement
9079 ;-------------------------------------------------------------
9081 (define-pmacro (not-sem mode dst)
9082 (sequence ((mode result))
9083 (set result (not mode dst))
9084 (set-z-and-s result)
9089 (unary-insn-g not (f-0-4 7) (f-4-3 2) (f-8-4 #x7) #xA #x1 #xE not-sem)
9092 "not.b:s Dst16-3-S-8"
9094 "not.b:s ${Dst16-3-S-8}"
9095 (+ (f-0-4 #xb) (f-4-1 #x1) Dst16-3-S-8)
9096 (not-sem QI Dst16-3-S-8)
9099 ;-------------------------------------------------------------
9101 ;-------------------------------------------------------------
9107 (+ (f-0-4 #x0) (f-4-4 #x4))
9115 (+ (f-0-4 #xD) (f-4-4 #xE))
9119 ;-------------------------------------------------------------
9121 ;-------------------------------------------------------------
9123 (define-pmacro (or-sem mode src1 dst)
9124 (sequence ((mode result))
9125 (set result (or mode src1 dst))
9126 (set-z-and-s result)
9130 ; or.BW #imm,dst (m16 #1 m32 #1)
9131 (binary-arith-imm-dst or G (f-0-4 7) (f-4-3 3) (f-8-4 3) #x8 #x2 #xF or-sem)
9132 ; or.b:S #imm8,dst3 (m16 #2 m32 #2)
9133 (binary-arith16-b-S-imm8-dst3 or ".b" (f-0-4 9) (f-4-1 1) or-sem)
9134 (binary-arith32-s-imm-dst QI .b 0 or #x1 #x2 or-sem)
9135 (binary-arith32-s-imm-dst HI .w 1 or #x1 #x2 or-sem)
9136 ; or.BW src,dst (m16 #3 m32 #3)
9137 (binary-arith-src-dst or G (f-0-4 #x9) (f-4-3 4) #x1 #x5 or-sem)
9138 ; or.b:S src,r0[lh] (m16)
9139 (binary-arith16-b-S-src2 or (f-0-4 1) (f-4-1 1) or-sem)
9141 ;-------------------------------------------------------------
9142 ; pop - restore register/memory
9143 ;-------------------------------------------------------------
9145 ; TODO future: split this into .b and .w semantics
9146 (define-pmacro (pop-sem-mach mach mode dst)
9147 (sequence ((mode b_or_w) (SI length))
9149 (set b_or_w (srl b_or_w #x8))
9152 (set length 2)) ; .w
9155 ((1) (set dst (mem-mach mach QI (reg h-sp))))
9156 ((2) (set dst (mem-mach mach HI (reg h-sp)))))
9157 (set (reg h-sp) (add (reg h-sp) length))
9161 (define-pmacro (pop-sem16 mode dest) (pop-sem-mach 16 mode dest))
9162 (define-pmacro (pop-sem32 mode dest) (pop-sem-mach 32 mode dest))
9165 (unary-insn-mach-g 16 pop (f-0-4 7) (f-4-3 2) (f-8-4 #xD) pop-sem16 $G)
9167 (unary-insn-mach 32 pop #xB #x2 #xF pop-sem32)
9170 (dni pop16.b-s-rn "pop.b:S r0[lh]" ((machine 16))
9171 "pop.b$S ${Rn16-push-S-anyof}"
9172 (+ (f-0-4 #x9) Rn16-push-S-anyof (f-5-3 #x2))
9173 (pop-sem16 QI Rn16-push-S-anyof)
9176 (dni pop16.b-s-an "pop.w:S a[01]" ((machine 16))
9177 "pop.w$S ${An16-push-S-anyof}"
9178 (+ (f-0-4 #xD) An16-push-S-anyof (f-5-3 #x2))
9179 (pop-sem16 HI An16-push-S-anyof)
9182 ;-------------------------------------------------------------
9183 ; popc - pop control register
9184 ; pushc - push control register
9185 ;-------------------------------------------------------------
9187 (define-pmacro (popc32-cr1-sem mode dst)
9190 ((#x0) (set (reg h-dct0) (mem32 mode (reg h-sp))))
9191 ((#x1) (set (reg h-dct1) (mem32 mode (reg h-sp))))
9192 ((#x2) (sequence ((HI tflag))
9193 (set tflag (mem32 mode (reg h-sp)))
9194 (if (and tflag #x1) (set cbit 1))
9195 (if (and tflag #x2) (set dbit 1))
9196 (if (and tflag #x4) (set zbit 1))
9197 (if (and tflag #x8) (set sbit 1))
9198 (if (and tflag #x10) (set bbit 1))
9199 (if (and tflag #x20) (set obit 1))
9200 (if (and tflag #x40) (set ibit 1))
9201 (if (and tflag #x80) (set ubit 1))))
9202 ((#x3) (set (reg h-svf) (mem32 mode (reg h-sp))))
9203 ((#x4) (set (reg h-drc0) (mem32 mode (reg h-sp))))
9204 ((#x5) (set (reg h-drc1) (mem32 mode (reg h-sp))))
9205 ((#x6) (set (reg h-dmd0) (mem32 mode (reg h-sp))))
9206 ((#x7) (set (reg h-dmd1) (mem32 mode (reg h-sp))))
9208 (set (reg h-sp) (add (reg h-sp) 2))
9211 (define-pmacro (popc32-cr2-sem mode dst)
9214 ((#x0) (set (reg h-intb) (mem32 mode (reg h-sp))))
9215 ((#x1) (set (reg h-sp) (mem32 mode (reg h-sp))))
9216 ((#x2) (set (reg h-sb) (mem32 mode (reg h-sp))))
9217 ((#x3) (set (reg h-fb) (mem32 mode (reg h-sp))))
9218 ((#x7) (set (reg h-isp) (mem32 mode (reg h-sp))))
9220 (set (reg h-sp) (add (reg h-sp) 4))
9223 (define-pmacro (popc16-sem mode dst)
9226 ((#x1) (set (reg h-intb) (or (and (reg h-intb) #x0000)
9227 (mem16 mode (reg h-sp)))))
9228 ((#x2) (set (reg h-intb) (or (and (reg h-intb) #xffff0000)
9229 (mem16 mode (reg h-sp)))))
9230 ((#x3) (sequence ((HI tflag))
9231 (set tflag (mem16 mode (reg h-sp)))
9232 (if (and tflag #x1) (set cbit 1))
9233 (if (and tflag #x2) (set dbit 1))
9234 (if (and tflag #x4) (set zbit 1))
9235 (if (and tflag #x8) (set sbit 1))
9236 (if (and tflag #x10) (set bbit 1))
9237 (if (and tflag #x20) (set obit 1))
9238 (if (and tflag #x40) (set ibit 1))
9239 (if (and tflag #x80) (set ubit 1))))
9240 ((#x4) (set (reg h-isp) (mem16 mode (reg h-sp))))
9241 ((#x5) (set (reg h-sp) (mem16 mode (reg h-sp))))
9242 ((#x6) (set (reg h-sb) (mem16 mode (reg h-sp))))
9243 ((#x7) (set (reg h-fb) (mem16 mode (reg h-sp))))
9245 (set (reg h-sp) (add (reg h-sp) 2))
9248 ; popc dest (m16c #1)
9249 (dni popc16.imm16 "popc dst" ((machine 16))
9251 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 3) cr16)
9252 (popc16-sem HI cr16)
9254 ; popc dest (m32c #1)
9255 (dni popc32.imm16-cr1 "popc dst" ((machine 32))
9256 ("popc ${cr1-Unprefixed-32}")
9257 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32)
9258 (popc32-cr1-sem HI cr1-Unprefixed-32)
9260 ; popc dest (m32c #2)
9261 (dni popc32.imm16-cr2 "popc dst" ((machine 32))
9263 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 2) (f-12-1 1) cr2-32)
9264 (popc32-cr2-sem SI cr2-32)
9267 (define-pmacro (pushc32-cr1-sem mode dst)
9269 (set (reg h-sp) (sub (reg h-sp) 2))
9271 ((#x0) (set (mem32 mode (reg h-sp)) (reg h-dct0)))
9272 ((#x1) (set (mem32 mode (reg h-sp)) (reg h-dct1)))
9273 ((#x2) (sequence ((HI tflag))
9275 (if (eq cbit 1) (set tflag (or tflag #x1)))
9276 (if (eq dbit 1) (set tflag (or tflag #x2)))
9277 (if (eq zbit 1) (set tflag (or tflag #x4)))
9278 (if (eq sbit 1) (set tflag (or tflag #x8)))
9279 (if (eq bbit 1) (set tflag (or tflag #x10)))
9280 (if (eq obit 1) (set tflag (or tflag #x20)))
9281 (if (eq ibit 1) (set tflag (or tflag #x40)))
9282 (if (eq ubit 1) (set tflag (or tflag #x80)))
9283 (set (mem32 mode (reg h-sp)) tflag)))
9284 ((#x3) (set (mem32 mode (reg h-sp)) (reg h-svf)))
9285 ((#x4) (set (mem32 mode (reg h-sp)) (reg h-drc0)))
9286 ((#x5) (set (mem32 mode (reg h-sp)) (reg h-drc1)))
9287 ((#x6) (set (mem32 mode (reg h-sp)) (reg h-dmd0)))
9288 ((#x7) (set (mem32 mode (reg h-sp)) (reg h-dmd1)))
9292 (define-pmacro (pushc32-cr2-sem mode dst)
9294 (set (reg h-sp) (sub (reg h-sp) 4))
9296 ((#x0) (set (mem32 mode (reg h-sp)) (reg h-intb)))
9297 ((#x1) (set (mem32 mode (reg h-sp)) (reg h-sp)))
9298 ((#x2) (set (mem32 mode (reg h-sp)) (reg h-sb)))
9299 ((#x3) (set (mem32 mode (reg h-sp)) (reg h-fb)))
9300 ((#x7) (set (mem32 mode (reg h-sp)) (reg h-isp)))
9304 (define-pmacro (pushc16-sem mode dst)
9306 (set (reg h-sp) (sub (reg h-sp) 2))
9308 ((#x1) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff)))
9309 ((#x2) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff0000)))
9310 ((#x3) (sequence ((HI tflag))
9311 (if (eq cbit 1) (set tflag (or tflag #x1)))
9312 (if (eq dbit 1) (set tflag (or tflag #x2)))
9313 (if (eq zbit 1) (set tflag (or tflag #x4)))
9314 (if (eq sbit 1) (set tflag (or tflag #x8)))
9315 (if (eq bbit 1) (set tflag (or tflag #x10)))
9316 (if (eq obit 1) (set tflag (or tflag #x20)))
9317 (if (eq ibit 1) (set tflag (or tflag #x40)))
9318 (if (eq ubit 1) (set tflag (or tflag #x80)))
9319 (set (mem16 mode (reg h-sp)) tflag)))
9321 ((#x4) (set (mem16 mode (reg h-sp)) (reg h-isp)))
9322 ((#x5) (set (mem16 mode (reg h-sp)) (reg h-sp)))
9323 ((#x6) (set (mem16 mode (reg h-sp)) (reg h-sb)))
9324 ((#x7) (set (mem16 mode (reg h-sp)) (reg h-fb)))
9329 (dni pushc16.imm16 "pushc dst" ((machine 16))
9331 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 2) cr16)
9332 (pushc16-sem HI cr16)
9334 ; pushc src (m32c #1)
9335 (dni pushc32.imm16-cr1 "pushc dst" ((machine 32))
9336 ("pushc ${cr1-Unprefixed-32}")
9337 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32)
9338 (pushc32-cr1-sem HI cr1-Unprefixed-32)
9340 ; pushc src (m32c #2)
9341 (dni pushc32.imm16-cr2 "pushc dst" ((machine 32))
9343 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 2) (f-12-1 1) cr2-32)
9344 (pushc32-cr2-sem SI cr2-32)
9347 ;-------------------------------------------------------------
9348 ; popm - pop multiple
9349 ; pushm - push multiple
9350 ;-------------------------------------------------------------
9352 (define-pmacro (popm-sem machine dst)
9353 (sequence ((SI addrlen))
9358 (sequence () (set R0 (mem-mach machine HI (reg h-sp)))
9359 (set (reg h-sp) (add (reg h-sp) 2))))
9361 (sequence () (set R1 (mem-mach machine HI (reg h-sp)))
9362 (set (reg h-sp) (add (reg h-sp) 2))))
9364 (sequence () (set R2 (mem-mach machine HI (reg h-sp)))
9365 (set (reg h-sp) (add (reg h-sp) 2))))
9367 (sequence () (set R3 (mem-mach machine HI (reg h-sp)))
9368 (set (reg h-sp) (add (reg h-sp) 2))))
9370 (sequence () (set A0 (mem-mach machine HI (reg h-sp)))
9371 (set (reg h-sp) (add (reg h-sp) addrlen))))
9373 (sequence () (set A1 (mem-mach machine HI (reg h-sp)))
9374 (set (reg h-sp) (add (reg h-sp) addrlen))))
9376 (sequence () (set (reg h-sb) (mem-mach machine HI (reg h-sp)))
9377 (set (reg h-sp) (add (reg h-sp) addrlen))))
9379 (sequence () (set (reg h-fb) (mem-mach machine HI (reg h-sp)))
9380 (set (reg h-sp) (add (reg h-sp) addrlen))))
9384 (define-pmacro (pushm-sem machine dst)
9385 (sequence ((SI count) (SI addrlen))
9390 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9391 (set (mem-mach machine HI (reg h-sp)) (reg h-fb))))
9393 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9394 (set (mem-mach machine HI (reg h-sp)) (reg h-sb))))
9396 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9397 (set (mem-mach machine HI (reg h-sp)) A1)))
9399 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9400 (set (mem-mach machine HI (reg h-sp)) A0)))
9402 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9403 (set (mem-mach machine HI (reg h-sp)) R3)))
9405 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9406 (set (mem-mach machine HI (reg h-sp)) R2)))
9408 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9409 (set (mem-mach machine HI (reg h-sp)) R1)))
9411 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9412 (set (mem-mach machine HI (reg h-sp)) R0)))
9416 (dni popm16 "popm regs" ((machine 16))
9417 ("popm ${Regsetpop}")
9418 (+ (f-0-4 #xE) (f-4-4 #xD) Regsetpop)
9419 (popm-sem 16 Regsetpop)
9421 (dni pushm16 "pushm regs" ((machine 16))
9422 ("pushm ${Regsetpush}")
9423 (+ (f-0-4 #xE) (f-4-4 #xC) Regsetpush)
9424 (pushm-sem 16 Regsetpush)
9426 (dni popm "popm regs" ((machine 32))
9427 ("popm ${Regsetpop}")
9428 (+ (f-0-4 #x8) (f-4-4 #xE) Regsetpop)
9429 (popm-sem 32 Regsetpop)
9431 (dni pushm "pushm regs" ((machine 32))
9432 ("pushm ${Regsetpush}")
9433 (+ (f-0-4 #x8) (f-4-4 #xF) Regsetpush)
9434 (pushm-sem 32 Regsetpush)
9437 ;-------------------------------------------------------------
9438 ; push - Save register/memory/immediate data
9439 ;-------------------------------------------------------------
9441 ; TODO future: split this into .b and .w semantics
9442 (define-pmacro (push-sem-mach mach mode dst)
9443 (sequence ((mode b_or_w) (SI length))
9445 (set b_or_w (srl b_or_w #x8))
9448 (if (eq b_or_w #xff)
9450 (set length 4))) ; .l
9451 (set (reg h-sp) (sub (reg h-sp) length))
9453 ((1) (set (mem-mach mach QI (reg h-sp)) dst))
9454 ((2) (set (mem-mach mach HI (reg h-sp)) dst))
9455 ((4) (set (mem-mach mach SI (reg h-sp)) dst)))
9459 (define-pmacro (push-sem16 mode dst) (push-sem-mach 16 mode dst))
9460 (define-pmacro (push-sem32 mode dst) (push-sem-mach 32 mode dst))
9462 ; push.BW:G imm (m16 #1 m32 #1)
9463 (dni push16.b.G-imm "push.b:G #Imm-16-QI" ((machine 16))
9464 ("push.b$G #${Imm-16-QI}")
9465 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 2) Imm-16-QI)
9466 (push-sem16 QI Imm-16-QI)
9469 (dni push16.w.G-imm "push.w:G #Imm-16-HI" ((machine 16))
9470 ("push.w$G #${Imm-16-HI}")
9471 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 2) Imm-16-HI)
9472 (push-sem16 HI Imm-16-HI)
9475 (dni push32.b.imm "push.b #Imm-8-QI" ((machine 32))
9476 ("push.b #${Imm-8-QI}")
9477 (+ (f-0-4 #xA) (f-4-4 #xE) Imm-8-QI)
9478 (push-sem32 QI Imm-8-QI)
9481 (dni push32.w.imm "push.w #Imm-8-HI" ((machine 32))
9482 ("push.w #${Imm-8-HI}")
9483 (+ (f-0-4 #xA) (f-4-4 #xF) Imm-8-HI)
9484 (push-sem32 HI Imm-8-HI)
9487 ; push.BW:G src (m16 #2)
9488 (unary-insn-mach-g 16 push (f-0-4 7) (f-4-3 2) (f-8-4 #x4) push-sem16 $G)
9489 ; push.BW:G src (m32 #2)
9490 (unary-insn-mach 32 push #xC #x0 #xE push-sem32)
9493 ; push.b:S r0l/r0h (m16 #3)
9494 (dni push16.b-s-rn "push.b:S r0[lh]" ((machine 16))
9495 "push.b$S ${Rn16-push-S-anyof}"
9496 (+ (f-0-4 #x8) Rn16-push-S-anyof (f-5-3 #x2))
9497 (push-sem16 QI Rn16-push-S-anyof)
9499 ; push.w:S a0/a1 (m16 #4)
9500 (dni push16.b-s-an "push.w:S a[01]" ((machine 16))
9501 "push.w$S ${An16-push-S-anyof}"
9502 (+ (f-0-4 #xC) An16-push-S-anyof (f-5-3 #x2))
9503 (push-sem16 HI An16-push-S-anyof)
9506 ; push.l imm32 (m32 #3)
9507 (dni push32.l.imm "push.l #Imm-16-SI" ((machine 32))
9508 ("push.l #${Imm-16-SI}")
9509 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 5) (f-12-4 3) Imm-16-SI)
9510 (push-sem32 SI Imm-16-SI)
9512 ; push.l src (m32 #4)
9513 (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)
9515 ;-------------------------------------------------------------
9516 ; pusha - push effective address
9517 ;------------------------------------------------------------
9519 (define-pmacro (push16a-sem mode dst)
9521 (set (reg h-sp) (sub (reg h-sp) 2))
9522 (set (mem16 HI (reg h-sp)) dst))
9524 (define-pmacro (push32a-sem mode dst)
9526 (set (reg h-sp) (sub (reg h-sp) 4))
9527 (set (mem32 SI (reg h-sp)) dst))
9529 (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)
9530 (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)
9532 ;-------------------------------------------------------------
9533 ; reit - return from interrupt
9534 ;-------------------------------------------------------------
9537 (dni reit16 "REIT" ((machine 16))
9539 (+ (f-0-4 #xF) (f-4-4 #xB))
9542 (dni reit32 "REIT" ((machine 32))
9544 (+ (f-0-4 9) (f-4-4 #xE))
9548 ;-------------------------------------------------------------
9549 ; rmpa - repeat multiple and addition
9550 ;-------------------------------------------------------------
9553 (dni rmpa16.b "rmpa.size" ((machine 16))
9555 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 1))
9558 (dni rmpa16.w "rmpa.size" ((machine 16))
9560 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 1))
9563 (dni rmpa32.b "rmpa.size" ((machine 32))
9565 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 4) (f-12-4 3))
9569 (dni rmpa32.w "rmpa.size" ((machine 32))
9571 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 5) (f-12-4 3))
9575 ;-------------------------------------------------------------
9576 ; rolc - rotate left with carry
9577 ;-------------------------------------------------------------
9579 ; TODO check semantics
9580 ; TODO future: split this into .b and .w semantics
9581 (define-pmacro (rolc-sem mode dst)
9582 (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask))
9584 (set b_or_w (srl b_or_w #x8))
9586 (set mask #x8000) ; .b
9587 (set mask #x80000000)) ; .w
9589 (set cbit (and dst mask))
9590 (set result (sll mode dst 1))
9591 (set result (or result ocbit))
9592 (set-z-and-s result)
9596 (unary-insn rolc (f-0-4 7) (f-4-3 3) (f-8-4 #xA) #xB #x2 #xE rolc-sem)
9598 ;-------------------------------------------------------------
9599 ; rorc - rotate right with carry
9600 ;-------------------------------------------------------------
9602 ; TODO check semantics
9603 ; TODO future: split this into .b and .w semantics
9604 (define-pmacro (rorc-sem mode dst)
9605 (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask) (SI shamt))
9607 (set b_or_w (srl b_or_w #x8))
9609 (sequence () (set mask #x7fff) (set shamt 15)) ; .b
9610 (sequence () (set mask #x7fffffff) (set shamt 31))) ; .w
9612 (set cbit (and dst #x1))
9613 (set result (srl mode dst (const 1)))
9614 (set result (or (and result mask) (sll ocbit shamt)))
9615 (set-z-and-s result)
9619 (unary-insn rorc (f-0-4 7) (f-4-3 3) (f-8-4 #xB) #xA #x2 #xE rorc-sem)
9621 ;-------------------------------------------------------------
9623 ;-------------------------------------------------------------
9625 ; TODO future: split this into .b and .w semantics
9626 (define-pmacro (rot-1-sem mode src1 dst)
9627 (sequence ((mode tmp) (mode b_or_w) (USI mask) (SI shift))
9629 ((#x0) (set shift 1))
9630 ((#x1) (set shift 2))
9631 ((#x2) (set shift 3))
9632 ((#x3) (set shift 4))
9633 ((#x4) (set shift 5))
9634 ((#x5) (set shift 6))
9635 ((#x6) (set shift 7))
9636 ((#x7) (set shift 8))
9637 ((-8) (set shift -1))
9638 ((-7) (set shift -2))
9639 ((-6) (set shift -3))
9640 ((-5) (set shift -4))
9641 ((-4) (set shift -5))
9642 ((-3) (set shift -6))
9643 ((-2) (set shift -7))
9644 ((-1) (set shift -8))
9645 (else (set shift 0))
9648 (set b_or_w (srl b_or_w #x8))
9650 (set mask #x7fff) ; .b
9651 (set mask #x7fffffff)) ; .w
9653 (if (gt mode shift 0)
9655 (set tmp (rol mode tmp shift))
9656 (set cbit (and tmp #x1)))
9658 (set tmp (ror mode tmp (mul shift -1)))
9659 (set cbit (and tmp mask))))
9663 (define-pmacro (rot-2-sem mode dst)
9664 (sequence ((mode tmp) (mode b_or_w) (USI mask))
9666 (set b_or_w (srl b_or_w #x8))
9668 (set mask #x7fff) ; .b
9669 (set mask #x7fffffff)) ; .w
9671 (if (gt mode (reg h-r1h) 0)
9673 (set tmp (rol mode tmp (reg h-r1h)))
9674 (set cbit (and tmp #x1)))
9676 (set tmp (ror mode tmp (reg h-r1h)))
9677 (set cbit (and tmp mask))))
9683 (binary-arith16-shimm4-dst-defn QI .b 0 0 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem)
9684 (binary-arith16-shimm4-dst-defn HI .w 0 1 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem)
9685 (binary-arith32-shimm4-dst-defn QI .b 0 0 rot #x7 #x2 rot-1-sem)
9686 (binary-arith32-shimm4-dst-defn HI .w 0 1 rot #x7 #x2 rot-1-sem)
9689 (dni rot16.b-dst "rot r1h,dest" ((machine 16))
9690 ("rot.b r1h,${dst16-16-QI}")
9691 (+ (f-0-4 7) (f-4-4 #x4) (f-8-4 #x6) dst16-16-QI)
9692 (rot-2-sem QI dst16-16-QI)
9694 (dni rot16.w-dst "rot r1h,dest" ((machine 16))
9695 ("rot.w r1h,${dst16-16-HI}")
9696 (+ (f-0-4 7) (f-4-4 #x5) (f-8-4 #x6) dst16-16-HI)
9697 (rot-2-sem HI dst16-16-HI)
9700 (dni rot32.b-dst "rot r1h,dest" ((machine 32))
9701 ("rot.b r1h,${dst32-16-Unprefixed-QI}")
9702 (+ (f-0-4 #xA) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xF))
9703 (rot-2-sem QI dst32-16-Unprefixed-QI)
9705 (dni rot32.w-dst "rot r1h,dest" ((machine 32))
9706 ("rot.w r1h,${dst32-16-Unprefixed-HI}")
9707 (+ (f-0-4 #xA) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xF))
9708 (rot-2-sem HI dst32-16-Unprefixed-HI)
9711 ;-------------------------------------------------------------
9712 ; rts - return from subroutine
9713 ;-------------------------------------------------------------
9715 (define-pmacro (rts16-sem)
9716 (sequence ((SI tpc))
9717 (set tpc (mem16 HI (reg h-sp)))
9718 (set (reg h-sp) (add (reg h-sp) 2))
9719 (set tpc (or tpc (sll (mem16 QI (reg h-sp)) 16)))
9720 (set (reg h-sp) (add (reg h-sp) 1))
9724 (define-pmacro (rts32-sem)
9725 (sequence ((SI tpc))
9726 (set tpc (mem32 HI (reg h-sp)))
9727 (set (reg h-sp) (add (reg h-sp) 2))
9728 (set tpc (or tpc (sll (mem32 HI (reg h-sp)) 16)))
9729 (set (reg h-sp) (add (reg h-sp) 2))
9734 (dni rts16 "rts" ((machine 16))
9736 (+ (f-0-4 #xF) (f-4-4 3))
9740 (dni rts32 "rts" ((machine 32))
9742 (+ (f-0-4 #xD) (f-4-4 #xF))
9746 ;-------------------------------------------------------------
9747 ; sbb - subtract with borrow
9748 ;-------------------------------------------------------------
9750 (define-pmacro (sbb-sem mode src dst)
9751 (sequence ((mode result))
9752 (set result (subc mode dst src cbit))
9753 (set obit (add-oflag mode dst src cbit))
9754 (set cbit (add-oflag mode dst src cbit))
9755 (set-z-and-s result)
9759 ; sbb.size:G #imm,dst
9760 (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)
9761 (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)
9762 (binary-arith32-imm-dst-Prefixed QI QI .b 0 sbb X #x9 #x2 #xE sbb-sem)
9763 (binary-arith32-imm-dst-Prefixed HI HI .w 1 sbb X #x9 #x2 #xE sbb-sem)
9766 (binary-arith16-src-dst-defn QI QI .b 0 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem)
9767 (binary-arith16-src-dst-defn HI HI .w 1 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem)
9768 (binary-arith32-src-dst-Prefixed QI QI .b 0 sbb X #x1 #x6 sbb-sem)
9769 (binary-arith32-src-dst-Prefixed HI HI .w 1 sbb X #x1 #x6 sbb-sem)
9771 ;-------------------------------------------------------------
9772 ; sbjnz - subtract then jump on not zero
9773 ;-------------------------------------------------------------
9775 (define-pmacro (sub-jnz-sem mode src dst label)
9776 (sequence ((mode result))
9777 (set result (sub mode dst src))
9783 ; sbjnz.size #imm4,dst,label
9784 (arith-jnz-imm4-dst sbjnz s4n (f-0-4 #xF) (f-4-3 4) #xf #x1 sub-jnz-sem)
9786 ;-------------------------------------------------------------
9787 ; sccnd - store condition on condition (m32)
9788 ;-------------------------------------------------------------
9790 (define-pmacro (sccnd-sem cnd dst)
9794 ((#x00) (if (not cbit) (set dst 1))) ;ltu nc
9795 ((#x01) (if (or cbit zbit) (set dst 1))) ;leu
9796 ((#x02) (if (not zbit) (set dst 1))) ;ne nz
9797 ((#x03) (if (not sbit) (set dst 1))) ;pz
9798 ((#x04) (if (not obit) (set dst 1))) ;no
9799 ((#x05) (if (not (or zbit (xor sbit obit))) (set dst 1))) ;gt
9800 ((#x06) (if (xor sbit obit) (set dst 1))) ;ge
9801 ((#x08) (if (trunc BI cbit) (set dst 1))) ;geu c
9802 ((#x09) (if (not (or cbit zbit)) (set dst 1))) ;gtu
9803 ((#x0a) (if (trunc BI zbit) (set dst 1))) ;eq z
9804 ((#x0b) (if (trunc BI sbit) (set dst 1))) ;n
9805 ((#x0c) (if (trunc BI obit) (set dst 1))) ;o
9806 ((#x0d) (if (or zbit (xor sbit obit)) (set dst 1))) ;le
9807 ((#x0e) (if (xor sbit obit) (set dst 1))) ;lt
9816 "sc$sccond32 ${dst32-16-Unprefixed-HI}"
9817 (+ (f-0-4 #xD) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) sccond32)
9818 (sccnd-sem sccond32 dst32-16-Unprefixed-HI)
9821 ;-------------------------------------------------------------
9822 ; scmpu - string compare unequal (m32)
9823 ;-------------------------------------------------------------
9826 (dni scmpu.b "scmpu.b" ((machine 32))
9828 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xC) (f-12-4 3))
9829 (c-call VOID "scmpu_QI_semantics")
9832 (dni scmpu.w "scmpu.w" ((machine 32))
9834 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xD) (f-12-4 3))
9835 (c-call VOID "scmpu_HI_semantics")
9838 ;-------------------------------------------------------------
9839 ; sha - shift arithmetic
9840 ;-------------------------------------------------------------
9842 ; TODO future: split this into .b and .w semantics
9843 (define-pmacro (sha-sem mode src1 dst)
9844 (sequence ((mode result)(mode shift)(mode shmode))
9846 ((#x0) (set shift 1))
9847 ((#x1) (set shift 2))
9848 ((#x2) (set shift 3))
9849 ((#x3) (set shift 4))
9850 ((#x4) (set shift 5))
9851 ((#x5) (set shift 6))
9852 ((#x6) (set shift 7))
9853 ((#x7) (set shift 8))
9854 ((-8) (set shift -1))
9855 ((-7) (set shift -2))
9856 ((-6) (set shift -3))
9857 ((-5) (set shift -4))
9858 ((-4) (set shift -5))
9859 ((-3) (set shift -6))
9860 ((-2) (set shift -7))
9861 ((-1) (set shift -8))
9862 (else (set shift 0))
9865 (set shmode (srl shmode #x8))
9866 (if (lt mode shift #x0) (set result (sra mode dst (mul shift -1))))
9867 (if (gt mode shift 0) (set result (sll mode dst shift)))
9868 (if (eq shmode #x0) ; QI
9871 (if (lt mode shift #x0)
9872 (set cbitamt (sub #x8 shift)) ; sra
9873 (set cbitamt (sub shift 1))) ; sll
9874 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9875 (set obit (ne (and dst #x80) (and result #x80)))
9877 (if (eq shmode #xff) ; HI
9880 (if (lt mode shift #x0)
9881 (set cbitamt (sub 16 shift)) ; sra
9882 (set cbitamt (sub shift 1))) ; sll
9883 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9884 (set obit (ne (and dst #x8000) (and result #x8000)))
9886 (set-z-and-s result)
9889 (define-pmacro (shar1h-sem mode dst)
9890 (sequence ((mode result)(mode shmode))
9892 (set shmode (srl shmode #x8))
9893 (if (lt mode (reg h-r1h) 0) (set result (sra mode dst (reg h-r1h))))
9894 (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h))))
9895 (if (eq shmode #x0) ; QI
9898 (if (lt mode (reg h-r1h) #x0)
9899 (set cbitamt (sub #x8 (reg h-r1h))) ; sra
9900 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9901 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9902 (set obit (ne (and dst #x80) (and result #x80)))
9904 (if (eq shmode #xff) ; HI
9907 (if (lt mode (reg h-r1h) #x0)
9908 (set cbitamt (sub 16 (reg h-r1h))) ; sra
9909 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9910 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9911 (set obit (ne (and dst #x8000) (and result #x8000)))
9913 (set-z-and-s result)
9916 ; sha.BW #imm4,dst (m16 #1 m32 #1)
9917 (binary-arith16-shimm4-dst-defn QI .b 0 0 sha (f-0-4 #xF) (f-4-3 0) sha-sem)
9918 (binary-arith16-shimm4-dst-defn HI .w 0 1 sha (f-0-4 #xF) (f-4-3 0) sha-sem)
9919 (binary-arith32-shimm4-dst-defn QI .b 1 0 sha #x7 #x0 sha-sem)
9920 (binary-arith32-shimm4-dst-defn HI .w 1 1 sha #x7 #x0 sha-sem)
9921 ; sha.BW r1h,dst (m16 #2 m32 #3)
9922 (dni sha16.b-dst "sha.b r1h,dest" ((machine 16))
9923 ("sha.b r1h,${dst16-16-QI}")
9924 (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xF) dst16-16-QI)
9925 (shar1h-sem HI dst16-16-QI)
9927 (dni sha16.w-dst "sha.w r1h,dest" ((machine 16))
9928 ("sha.w r1h,${dst16-16-HI}")
9929 (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xF) dst16-16-HI)
9930 (shar1h-sem HI dst16-16-HI)
9932 (dni sha32.b-dst "sha.b r1h,dest" ((machine 32))
9933 ("sha.b r1h,${dst32-16-Unprefixed-QI}")
9934 (+ (f-0-4 #xB) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE))
9935 (shar1h-sem QI dst32-16-Unprefixed-QI)
9937 (dni sha32.w-dst "sha.w r1h,dest" ((machine 32))
9938 ("sha.w r1h,${dst32-16-Unprefixed-HI}")
9939 (+ (f-0-4 #xB) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
9940 (shar1h-sem HI dst32-16-Unprefixed-HI)
9942 ; sha.L #imm,dst (m16 #3)
9943 (dni sha16-L-imm-r2r0 "sha.L #Imm-sh-12-s4,r2r0" ((machine 16))
9944 "sha.l #${Imm-sh-12-s4},r2r0"
9945 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xA) Imm-sh-12-s4)
9946 (sha-sem SI Imm-sh-12-s4 (reg h-r2r0))
9948 (dni sha16-L-imm-r3r1 "sha.L #Imm-sh-12-s4,r3r1" ((machine 16))
9949 "sha.l #${Imm-sh-12-s4},r3r1"
9950 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xB) Imm-sh-12-s4)
9951 (sha-sem SI Imm-sh-12-s4 (reg h-r3r1))
9953 ; sha.L r1h,dst (m16 #4)
9954 (dni sha16-L-r1h-r2r0 "sha.L r1h,r2r0" ((machine 16))
9956 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 2) (f-12-4 1))
9957 (sha-sem SI (reg h-r1h) (reg h-r2r0))
9959 (dni sha16-L-r1h-r3r1 "sha.L r1h,r3r1" ((machine 16))
9961 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 3) (f-12-4 1))
9962 (sha-sem SI (reg h-r1h) (reg h-r3r1))
9964 ; sha.L #imm8,dst (m32 #2)
9965 (binary-arith32-imm-dst-defn QI SI .l 0 sha X #xA #x2 #x1 sha-sem)
9966 ; sha.L r1h,dst (m32 #4)
9967 (dni sha32.l-dst "sha.l r1h,dest" ((machine 32))
9968 ("sha.l r1h,${dst32-16-Unprefixed-SI}")
9969 (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 1) (f-12-4 1))
9970 (shar1h-sem QI dst32-16-Unprefixed-SI)
9973 ;-------------------------------------------------------------
9974 ; shanc - shift arithmetic non carry (m32)
9975 ;-------------------------------------------------------------
9977 ; TODO check semantics
9979 (binary-arith32-imm-dst-defn QI SI .l 0 shanc X #xC #x2 #x1 sha-sem)
9981 ;-------------------------------------------------------------
9982 ; shl - shift logical
9983 ;-------------------------------------------------------------
9985 ; TODO future: split this into .b and .w semantics
9986 (define-pmacro (shl-sem mode src1 dst)
9987 (sequence ((mode result)(mode shift)(mode shmode))
9989 ((#x0) (set shift 1))
9990 ((#x1) (set shift 2))
9991 ((#x2) (set shift 3))
9992 ((#x3) (set shift 4))
9993 ((#x4) (set shift 5))
9994 ((#x5) (set shift 6))
9995 ((#x6) (set shift 7))
9996 ((#x7) (set shift 8))
9997 ((-8) (set shift -1))
9998 ((-7) (set shift -2))
9999 ((-6) (set shift -3))
10000 ((-5) (set shift -4))
10001 ((-4) (set shift -5))
10002 ((-3) (set shift -6))
10003 ((-2) (set shift -7))
10004 ((-1) (set shift -8))
10005 (else (set shift 0))
10008 (set shmode (srl shmode #x8))
10009 (if (lt mode shift #x0) (set result (srl mode dst (mul shift -1))))
10010 (if (gt mode shift 0) (set result (sll mode dst shift)))
10011 (if (eq shmode #x0) ; QI
10014 (if (lt mode shift #x0)
10015 (set cbitamt (sub #x8 shift)); srl
10016 (set cbitamt (sub shift 1))) ; sll
10017 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
10018 (set obit (ne (and dst #x80) (and result #x80)))
10020 (if (eq shmode #xff) ; HI
10023 (if (lt mode shift #x0)
10024 (set cbitamt (sub 16 shift)) ; srl
10025 (set cbitamt (sub shift 1))) ; sll
10026 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
10027 (set obit (ne (and dst #x8000) (and result #x8000)))
10029 (set-z-and-s result)
10032 (define-pmacro (shlr1h-sem mode dst)
10033 (sequence ((mode result)(mode shmode))
10035 (set shmode (srl shmode #x8))
10036 (if (lt mode (reg h-r1h) 0) (set result (srl mode dst (reg h-r1h))))
10037 (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h))))
10038 (if (eq shmode #x0) ; QI
10041 (if (lt mode (reg h-r1h) #x0)
10042 (set cbitamt (sub #x8 (reg h-r1h))) ; srl
10043 (set cbitamt (sub (reg h-r1h) 1))) ; sll
10044 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
10045 (set obit (ne (and dst #x80) (and result #x80)))
10047 (if (eq shmode #xff) ; HI
10050 (if (lt mode (reg h-r1h) #x0)
10051 (set cbitamt (sub 16 (reg h-r1h))) ; srl
10052 (set cbitamt (sub (reg h-r1h) 1))) ; sll
10053 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
10054 (set obit (ne (and dst #x8000) (and result #x8000)))
10056 (set-z-and-s result)
10059 ; shl.BW #imm4,dst (m16 #1 m32 #1)
10060 (binary-arith16-shimm4-dst-defn QI .b 0 0 shl (f-0-4 #xE) (f-4-3 4) shl-sem)
10061 (binary-arith16-shimm4-dst-defn HI .w 0 1 shl (f-0-4 #xE) (f-4-3 4) shl-sem)
10062 (binary-arith32-shimm4-dst-defn QI .b 0 0 shl #x7 #x0 shl-sem)
10063 (binary-arith32-shimm4-dst-defn HI .w 0 1 shl #x7 #x0 shl-sem)
10064 ; shl.BW r1h,dst (m16 #2 m32 #3)
10065 (dni shl16.b-dst "shl.b r1h,dest" ((machine 16))
10066 ("shl.b r1h,${dst16-16-QI}")
10067 (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xE) dst16-16-QI)
10068 (shlr1h-sem HI dst16-16-QI)
10070 (dni shl16.w-dst "shl.w r1h,dest" ((machine 16))
10071 ("shl.w r1h,${dst16-16-HI}")
10072 (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xE) dst16-16-HI)
10073 (shlr1h-sem HI dst16-16-HI)
10075 (dni shl32.b-dst "shl.b r1h,dest" ((machine 32))
10076 ("shl.b r1h,${dst32-16-Unprefixed-QI}")
10077 (+ (f-0-4 #xA) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE))
10078 (shlr1h-sem QI dst32-16-Unprefixed-QI)
10080 (dni shl32.w-dst "shl.w r1h,dest" ((machine 32))
10081 ("shl.w r1h,${dst32-16-Unprefixed-HI}")
10082 (+ (f-0-4 #xA) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
10083 (shlr1h-sem HI dst32-16-Unprefixed-HI)
10085 ; shl.L #imm,dst (m16 #3)
10086 (dni shl16-L-imm-r2r0 "shl.L #Imm-sh-12-s4,r2r0" ((machine 16))
10087 "shl.l #${Imm-sh-12-s4},r2r0"
10088 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x8) Imm-sh-12-s4)
10089 (shl-sem SI Imm-sh-12-s4 (reg h-r2r0))
10091 (dni shl16-L-imm-r3r1 "shl.L #Imm-sh-12-s4,r3r1" ((machine 16))
10092 "shl.l #${Imm-sh-12-s4},r3r1"
10093 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x9) Imm-sh-12-s4)
10094 (shl-sem SI Imm-sh-12-s4 (reg h-r3r1))
10096 ; shl.L r1h,dst (m16 #4)
10097 (dni shl16-L-r1h-r2r0 "shl.L r1h,r2r0" ((machine 16))
10099 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 0) (f-12-4 1))
10100 (shl-sem SI (reg h-r1h) (reg h-r2r0))
10102 (dni shl16-L-r1h-r3r1 "shl.L r1h,r3r1" ((machine 16))
10104 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 1) (f-12-4 1))
10105 (shl-sem SI (reg h-r1h) (reg h-r3r1))
10107 ; shl.L #imm8,dst (m32 #2)
10108 (binary-arith32-imm-dst-defn QI SI .l 0 shl X #x9 #x2 #x1 shl-sem)
10109 ; shl.L r1h,dst (m32 #4)
10110 (dni shl32.l-dst "shl.l r1h,dest" ((machine 32))
10111 ("shl.l r1h,${dst32-16-Unprefixed-SI}")
10112 (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 0) (f-12-4 1))
10113 (shlr1h-sem QI dst32-16-Unprefixed-SI)
10116 ;-------------------------------------------------------------
10117 ; shlnc - shift logical non carry
10118 ;-------------------------------------------------------------
10120 ; TODO check semantics
10121 ; shlnc.L #imm8,dst
10122 (binary-arith32-imm-dst-defn QI SI .l 0 shlnc X #x8 #x2 #x1 shl-sem)
10124 ;-------------------------------------------------------------
10125 ; sin - string input (m32)
10126 ;-------------------------------------------------------------
10129 (dni sin32.b "sin" ((machine 32))
10131 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 8) (f-12-4 3))
10132 (c-call VOID "sin_QI_semantics")
10135 (dni sin32.w "sin" ((machine 32))
10137 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 9) (f-12-4 3))
10138 (c-call VOID "sin_HI_semantics")
10141 ;-------------------------------------------------------------
10142 ; smovb - string move backward
10143 ;-------------------------------------------------------------
10146 (dni smovb16.b "smovb.b" ((machine 16))
10148 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 9))
10149 (c-call VOID "smovb_QI_semantics")
10152 (dni smovb16.w "smovb.w" ((machine 16))
10154 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 9))
10155 (c-call VOID "smovb_HI_semantics")
10158 (dni smovb32.b "smovb.b" ((machine 32))
10160 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 8) (f-12-4 3))
10161 (c-call VOID "smovb_QI_semantics")
10164 (dni smovb32.w "smovb.w" ((machine 32))
10166 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 9) (f-12-4 3))
10167 (c-call VOID "smovb_HI_semantics")
10170 ;-------------------------------------------------------------
10171 ; smovf - string move forward (m32)
10172 ;-------------------------------------------------------------
10175 (dni smovf16.b "smovf.b" ((machine 16))
10177 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 8))
10178 (c-call VOID "smovf_QI_semantics")
10181 (dni smovf16.w "smovf.w" ((machine 16))
10183 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 8))
10184 (c-call VOID "smovf_HI_semantics")
10187 (dni smovf32.b "smovf.b" ((machine 32))
10189 (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 8) (f-12-4 3))
10190 (c-call VOID "smovf_QI_semantics")
10193 (dni smovf32.w "smovf.w" ((machine 32))
10195 (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 9) (f-12-4 3))
10196 (c-call VOID "smovf_HI_semantics")
10199 ;-------------------------------------------------------------
10200 ; smovu - string move unequal (m32)
10201 ;-------------------------------------------------------------
10204 (dni smovu.b "smovu.b" ((machine 32))
10206 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 8) (f-12-4 3))
10207 (c-call VOID "smovu_QI_semantics")
10210 (dni smovu.w "smovu.w" ((machine 32))
10212 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 9) (f-12-4 3))
10213 (c-call VOID "smovu_HI_semantics")
10216 ;-------------------------------------------------------------
10217 ; sout - string output (m32)
10218 ;-------------------------------------------------------------
10221 (dni sout.b "sout.b" ((machine 32))
10223 (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 8) (f-12-4 3))
10224 (c-call VOID "sout_QI_semantics")
10227 (dni sout.w "sout" ((machine 32))
10229 (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 9) (f-12-4 3))
10230 (c-call VOID "sout_HI_semantics")
10233 ;-------------------------------------------------------------
10234 ; sstr - string store
10235 ;-------------------------------------------------------------
10238 (dni sstr16.b "sstr.b" ((machine 16))
10240 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 #xA))
10241 (c-call VOID "sstr_QI_semantics")
10244 (dni sstr16.w "sstr.w" ((machine 16))
10246 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 #xA))
10247 (c-call VOID "sstr_HI_semantics")
10250 (dni sstr.b "sstr" ((machine 32))
10252 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 0) (f-12-4 3))
10253 (c-call VOID "sstr_QI_semantics")
10256 (dni sstr.w "sstr" ((machine 32))
10258 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 1) (f-12-4 3))
10259 (c-call VOID "sstr_HI_semantics")
10262 ;-------------------------------------------------------------
10263 ; stnz - store on not zero
10264 ;-------------------------------------------------------------
10266 (define-pmacro (stnz-sem mode src dst)
10268 (if (ne zbit (const 1))
10271 ; stnz #imm8,dst3 (m16)
10272 (binary-arith16-b-S-imm8-dst3 stnz "" (f-0-4 #xD) (f-4-1 0) stnz-sem)
10273 ; stnz.BW #imm,dst (m32)
10274 (binary-arith32-imm-dst-defn QI QI .b 0 stnz X #x9 #x1 #xF stnz-sem)
10275 (binary-arith32-imm-dst-defn HI HI .w 1 stnz X #x9 #x1 #xF stnz-sem)
10277 ;-------------------------------------------------------------
10278 ; stz - store on zero
10279 ;-------------------------------------------------------------
10281 (define-pmacro (stz-sem mode src dst)
10283 (if (eq zbit (const 1))
10286 ; stz #imm8,dst3 (m16)
10287 (binary-arith16-b-S-imm8-dst3 stz "" (f-0-4 #xC) (f-4-1 1) stz-sem)
10288 ; stz.BW #imm,dst (m32)
10289 (binary-arith32-imm-dst-defn QI QI .b 0 stz X #x9 #x0 #xF stz-sem)
10290 (binary-arith32-imm-dst-defn HI HI .w 1 stz X #x9 #x0 #xF stz-sem)
10292 ;-------------------------------------------------------------
10293 ; stzx - store on zero extention
10294 ;-------------------------------------------------------------
10296 (define-pmacro (stzx-sem mode src1 src2 dst)
10298 (if (eq zbit (const 1))
10302 ; stzx #imm8,dst3 (m16)
10303 (dni stzx16-imm8-imm8-r0h "stzx #Imm8,#Imm8,r0h" ((machine 16))
10304 ("stzx #${Imm-8-QI},#${Imm-16-QI},r0h")
10305 (+ (f-0-4 #xD) (f-4-4 #xB) Imm-8-QI Imm-16-QI)
10306 (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0h))
10308 (dni stzx16-imm8-imm8-r0l "stzx #Imm8,#Imm8,r0l" ((machine 16))
10309 ("stzx #${Imm-8-QI},#${Imm-16-QI},r0l")
10310 (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI Imm-16-QI)
10311 (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0l))
10313 (dni stzx16-imm8-imm8-dsp8sb "stzx #Imm8,#Imm8,dsp8[sb]" ((machine 16))
10314 ("stzx #${Imm-8-QI},#${Imm-24-QI},${Dsp-16-u8}[sb]")
10315 (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI Dsp-16-u8 Imm-24-QI)
10316 (stzx-sem QI Imm-8-QI Imm-16-QI (mem16 QI (add (reg h-sb) Dsp-24-u8)))
10318 (dni stzx16-imm8-imm8-dsp8fb "stzx #Imm8,#Imm8,dsp8[fb]" ((machine 16))
10319 ("stzx #${Imm-8-QI},#${Imm-24-QI},${Dsp-16-s8}[fb]")
10320 (+ (f-0-4 #xD) (f-4-4 #xE) Imm-8-QI Dsp-16-s8 Imm-24-QI)
10321 (stzx-sem QI Imm-8-QI Imm-24-QI (mem16 QI (add (reg h-fb) Dsp-16-s8)))
10323 (dni stzx16-imm8-imm8-abs16 "stzx #Imm8,#Imm8,abs16" ((machine 16))
10324 ("stzx #${Imm-8-QI},#${Imm-32-QI},${Dsp-16-u16}")
10325 (+ (f-0-4 #xD) (f-4-4 #xF) Imm-8-QI Dsp-16-u16 Imm-32-QI)
10326 (stzx-sem QI Imm-8-QI Imm-32-QI (mem16 QI Dsp-16-u16))
10328 ; stzx.BW #imm,dst (m32)
10329 (insn-imm1-imm2-dst-Unprefixed stzx #x9 #x3 #xF stzx-sem)
10331 ;-------------------------------------------------------------
10332 ; subx - subtract extend (m32)
10333 ;-------------------------------------------------------------
10335 (define-pmacro (subx-sem mode src1 dst)
10336 (sequence ((mode result))
10337 (set result (sub mode dst (ext mode src1)))
10338 (set obit (sub-oflag mode dst (ext mode src1) 0))
10339 (set cbit (sub-cflag mode dst (ext mode src1) 0))
10341 (set-z-and-s result)))
10343 (binary-arith32-imm-dst-defn QI SI "" 0 subx G #x9 #x1 #x1 subx-sem)
10345 (binary-arith32-src-dst-defn QI SI "" 0 subx G #x1 #x0 subx-sem)
10347 ;-------------------------------------------------------------
10349 ;-------------------------------------------------------------
10351 (define-pmacro (tst-sem mode src1 dst)
10352 (sequence ((mode result))
10353 (set result (and mode dst src1))
10354 (set-z-and-s result))
10357 ; tst.BW #imm,dst (m16 #1 m32 #1)
10358 (binary-arith-imm-dst tst G (f-0-4 7) (f-4-3 3) (f-8-4 0) #x9 #x3 #xE tst-sem)
10359 ; tst.BW src,dst (m16 #2 m32 #3)
10360 (binary-arith16-src-dst-defn QI QI .b 0 tst X (f-0-4 #x8) (f-4-3 0) tst-sem)
10361 (binary-arith16-src-dst-defn HI HI .w 1 tst X (f-0-4 #x8) (f-4-3 0) tst-sem)
10362 (binary-arith32-src-dst-Prefixed QI QI .b 0 tst G #x1 #x9 tst-sem)
10363 (binary-arith32-src-dst-Prefixed HI HI .w 1 tst G #x1 #x9 tst-sem)
10364 ; tst.BW:S #imm,dst2 (m32 #2)
10365 (binary-arith32-s-imm-dst QI .b 0 tst #x0 #x6 tst-sem)
10366 (binary-arith32-s-imm-dst HI .w 1 tst #x0 #x6 tst-sem)
10368 ;-------------------------------------------------------------
10370 ;-------------------------------------------------------------
10372 (dni und16 "und" ((machine 16))
10374 (+ (f-0-4 #xF) (f-4-4 #xF))
10378 (dni und32 "und" ((machine 32))
10380 (+ (f-0-4 #xF) (f-4-4 #xF))
10384 ;-------------------------------------------------------------
10386 ;-------------------------------------------------------------
10389 (dni wait16 "wait" ((machine 16))
10391 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 3))
10395 (dni wait "wait" ((machine 32))
10397 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 0) (f-12-4 3))
10401 ;-------------------------------------------------------------
10403 ;-------------------------------------------------------------
10405 (define-pmacro (xchg-sem mode src dst)
10406 (sequence ((mode result))
10411 (define-pmacro (xchg16-defn mode sz szc src srcreg)
10412 (dni (.sym xchg16 sz - srcreg)
10413 (.str "xchg" sz "-" srcreg ",dst16-16-" mode)
10415 (.str "xchg." sz " " srcreg ",${dst16-16-" mode "}")
10416 (+ (f-0-4 #x7) (f-4-3 #x5) (f-7-1 szc) (f-8-2 0) (f-10-2 src) (.sym dst16-16- mode))
10417 (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst16-16- mode))
10420 (xchg16-defn QI b 0 0 r0l)
10421 (xchg16-defn QI b 0 1 r0h)
10422 (xchg16-defn QI b 0 2 r1l)
10423 (xchg16-defn QI b 0 3 r1h)
10424 (xchg16-defn HI w 1 0 r0)
10425 (xchg16-defn HI w 1 1 r1)
10426 (xchg16-defn HI w 1 2 r2)
10427 (xchg16-defn HI w 1 3 r3)
10428 (define-pmacro (xchg32-defn mode sz szc src srcreg)
10429 (dni (.sym xchg32 sz - srcreg)
10430 (.str "xchg" sz "-" srcreg ",dst32-16-Unprefixed-" mode)
10432 (.str "xchg." sz " " srcreg ",${dst32-16-Unprefixed-" mode "}")
10433 (+ (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))
10434 (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst32-16-Unprefixed- mode))
10437 (xchg32-defn QI b 0 0 r0l)
10438 (xchg32-defn QI b 0 1 r1l)
10439 (xchg32-defn QI b 0 2 a0)
10440 (xchg32-defn QI b 0 3 a1)
10441 (xchg32-defn QI b 0 4 r0h)
10442 (xchg32-defn QI b 0 5 r1h)
10443 (xchg32-defn HI w 1 0 r0)
10444 (xchg32-defn HI w 1 1 r1)
10445 (xchg32-defn HI w 1 2 a0)
10446 (xchg32-defn HI w 1 3 a1)
10447 (xchg32-defn HI w 1 4 r2)
10448 (xchg32-defn HI w 1 5 r3)
10450 ;-------------------------------------------------------------
10451 ; xor - exclusive or
10452 ;-------------------------------------------------------------
10454 (define-pmacro (xor-sem mode src1 dst)
10455 (sequence ((mode result))
10456 (set result (xor mode src1 dst))
10457 (set-z-and-s result)
10461 ; xor.BW #imm,dst (m16 #1 m32 #1)
10462 (binary-arith-imm-dst xor G (f-0-4 7) (f-4-3 3) (f-8-4 1) #x9 #x0 #xE xor-sem)
10463 ; xor.BW src,dst (m16 #3 m32 #3)
10464 (binary-arith-src-dst xor G (f-0-4 #x8) (f-4-3 4) #x1 #x9 xor-sem)
10466 ;-------------------------------------------------------------
10468 ;-------------------------------------------------------------
10470 (define-pmacro (exts-sem smode dmode src dst)
10471 (set dst (ext dmode (trunc smode src)))
10473 (define-pmacro (extz-sem smode dmode src dst)
10474 (set dst (zext dmode (trunc smode src)))
10477 ; exts.b dst for m16c
10478 (ext16-defn QI HI .b 0 exts (f-0-4 7) (f-4-3 6) (f-8-4 6) exts-sem)
10480 ; exts.w r0 for m16c
10485 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 3))
10486 (exts-sem HI SI R0 R2R0)
10489 ; exts.size dst for m32c
10490 (ext32-defn QI HI .b 0 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem)
10491 (ext32-defn HI SI .w 1 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem)
10492 ; exts.b src,dst for m32c
10493 (ext32-binary-defn exts .b #x1 #x7 exts-sem)
10495 ; extz.b src,dst for m32c
10496 (ext32-binary-defn extz "" #x1 #xB extz-sem)
10498 ;-------------------------------------------------------------
10500 ;-------------------------------------------------------------
10503 (dni srcind "SRC-INDIRECT" ((machine 32))
10505 (+ (f-0-4 4) (f-4-4 1))
10506 (set (reg h-src-indirect) 1)
10509 (dni destind "DEST-INDIRECT" ((machine 32))
10511 (+ (f-0-4 0) (f-4-4 9))
10512 (set (reg h-dst-indirect) 1)
10515 (dni srcdestind "SRC-DEST-INDIRECT" ((machine 32))
10516 ("src-dest-indirect")
10517 (+ (f-0-4 4) (f-4-4 9))
10518 (sequence () (set (reg h-src-indirect) 1) (set (reg h-dst-indirect) 1))