1 ; Renesas M32C CPU description. -*- Scheme -*-
3 ; Copyright 2005 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)
142 ; Macros to simplify MACH attribute specification.
144 (define-pmacro all-isas () (ISA m16c,m32c))
145 (define-pmacro m16c-isa () (ISA m16c))
146 (define-pmacro m32c-isa () (ISA m32c))
148 (define-pmacro MACH16 (MACH m16c))
149 (define-pmacro MACH32 (MACH m32c))
151 (define-pmacro (machine size)
152 (MACH (.sym m size c)) (ISA (.sym m size c)))
154 ;=============================================================
156 ;-------------------------------------------------------------
159 (dnf f-0-1 "opcode" (all-isas) 0 1)
160 (dnf f-0-2 "opcode" (all-isas) 0 2)
161 (dnf f-0-3 "opcode" (all-isas) 0 3)
162 (dnf f-0-4 "opcode" (all-isas) 0 4)
163 (dnf f-1-3 "opcode" (all-isas) 1 3)
164 (dnf f-2-2 "opcode" (all-isas) 2 2)
165 (dnf f-3-4 "opcode" (all-isas) 3 4)
166 (dnf f-3-1 "opcode" (all-isas) 3 1)
167 (dnf f-4-1 "opcode" (all-isas) 4 1)
168 (dnf f-4-3 "opcode" (all-isas) 4 3)
169 (dnf f-4-4 "opcode" (all-isas) 4 4)
170 (dnf f-4-6 "opcode" (all-isas) 4 6)
171 (dnf f-5-1 "opcode" (all-isas) 5 1)
172 (dnf f-5-3 "opcode" (all-isas) 5 3)
173 (dnf f-6-2 "opcode" (all-isas) 6 2)
174 (dnf f-7-1 "opcode" (all-isas) 7 1)
175 (dnf f-8-1 "opcode" (all-isas) 8 1)
176 (dnf f-8-2 "opcode" (all-isas) 8 2)
177 (dnf f-8-3 "opcode" (all-isas) 8 3)
178 (dnf f-8-4 "opcode" (all-isas) 8 4)
179 (dnf f-8-8 "opcode" (all-isas) 8 8)
180 (dnf f-9-3 "opcode" (all-isas) 9 3)
181 (dnf f-9-1 "opcode" (all-isas) 9 1)
182 (dnf f-10-1 "opcode" (all-isas) 10 1)
183 (dnf f-10-2 "opcode" (all-isas) 10 2)
184 (dnf f-10-3 "opcode" (all-isas) 10 3)
185 (dnf f-11-1 "opcode" (all-isas) 11 1)
186 (dnf f-12-1 "opcode" (all-isas) 12 1)
187 (dnf f-12-2 "opcode" (all-isas) 12 2)
188 (dnf f-12-3 "opcode" (all-isas) 12 3)
189 (dnf f-12-4 "opcode" (all-isas) 12 4)
190 (dnf f-12-6 "opcode" (all-isas) 12 6)
191 (dnf f-13-3 "opcode" (all-isas) 13 3)
192 (dnf f-14-1 "opcode" (all-isas) 14 1)
193 (dnf f-14-2 "opcode" (all-isas) 14 2)
194 (dnf f-15-1 "opcode" (all-isas) 15 1)
195 (dnf f-16-1 "opcode" (all-isas) 16 1)
196 (dnf f-16-2 "opcode" (all-isas) 16 2)
197 (dnf f-16-4 "opcode" (all-isas) 16 4)
198 (dnf f-18-1 "opcode" (all-isas) 18 1)
199 (dnf f-18-2 "opcode" (all-isas) 18 2)
200 (dnf f-18-3 "opcode" (all-isas) 18 3)
201 (dnf f-20-1 "opcode" (all-isas) 20 1)
202 (dnf f-20-3 "opcode" (all-isas) 20 3)
203 (dnf f-20-2 "opcode" (all-isas) 20 2)
204 (dnf f-20-4 "opcode" (all-isas) 20 4)
205 (dnf f-21-3 "opcode" (all-isas) 21 3)
206 (dnf f-24-2 "opcode" (all-isas) 24 2)
208 ;-------------------------------------------------------------
210 ;-------------------------------------------------------------
212 (dnf f-src16-rn "source Rn for m16c" (MACH16 m16c-isa) 10 2)
213 (dnf f-src16-an "source An for m16c" (MACH16 m16c-isa) 11 1)
215 (dnf f-src32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 11 1)
216 (dnf f-src32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 19 1)
218 ; QI mode gr encoding for m32c is different than for m16c. The hardware
219 ; is indexed using the m16c encoding, so perform the transformation here.
221 ; ----------------------
226 (df f-src32-rn-unprefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 10 2 UINT
227 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
228 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
230 ; QI mode gr encoding for m32c is different than for m16c. The hardware
231 ; is indexed using the m16c encoding, so perform the transformation here.
233 ; ----------------------
238 (df f-src32-rn-prefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 18 2 UINT
239 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
240 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
242 ; HI mode gr encoding for m32c is different than for m16c. The hardware
243 ; is indexed using the m16c encoding, so perform the transformation here.
245 ; ----------------------
250 (df f-src32-rn-unprefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 10 2 UINT
251 ((value pc) (mod USI (add value 2) 4)) ; insert
252 ((value pc) (mod USI (add value 2) 4)) ; extract
255 ; HI mode gr encoding for m32c is different than for m16c. The hardware
256 ; is indexed using the m16c encoding, so perform the transformation here.
258 ; ----------------------
263 (df f-src32-rn-prefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 18 2 UINT
264 ((value pc) (mod USI (add value 2) 4)) ; insert
265 ((value pc) (mod USI (add value 2) 4)) ; extract
268 ; SI mode gr encoding for m32c is as follows:
269 ; register encoding index
270 ; -------------------------
273 (df f-src32-rn-unprefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 10 2 UINT
274 ((value pc) (add USI value 2)) ; insert
275 ((value pc) (sub USI value 2)) ; extract
277 (df f-src32-rn-prefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 18 2 UINT
278 ((value pc) (add USI value 2)) ; insert
279 ((value pc) (sub USI value 2)) ; extract
282 (dnf f-dst32-rn-ext-unprefixed "destination Rn for m32c" (MACH32 m32c-isa) 9 1)
284 (dnf f-dst16-rn "destination Rn for m16c" (MACH16 m16c-isa) 14 2)
285 (dnf f-dst16-rn-ext "destination Rn for m16c" (MACH16 m16c-isa) 14 1)
286 (dnf f-dst16-rn-QI-s "destination Rn for m16c" (MACH16 m16c-isa) 5 1)
288 (dnf f-dst16-an "destination An for m16c" (MACH16 m16c-isa) 15 1)
289 (dnf f-dst16-an-s "destination An for m16c" (MACH16 m16c-isa) 4 1)
291 (dnf f-dst32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 9 1)
292 (dnf f-dst32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 17 1)
294 ; QI mode gr encoding for m32c is different than for m16c. The hardware
295 ; is indexed using the m16c encoding, so perform the transformation here.
297 ; ----------------------
302 (df f-dst32-rn-unprefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 8 2 UINT
303 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
304 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
306 (df f-dst32-rn-prefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 16 2 UINT
307 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
308 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
310 ; HI mode gr encoding for m32c is different than for m16c. The hardware
311 ; is indexed using the m16c encoding, so perform the transformation here.
313 ; ----------------------
318 (df f-dst32-rn-unprefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 8 2 UINT
319 ((value pc) (mod USI (add value 2) 4)) ; insert
320 ((value pc) (mod USI (add value 2) 4)) ; extract
322 (df f-dst32-rn-prefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 16 2 UINT
323 ((value pc) (mod USI (add value 2) 4)) ; insert
324 ((value pc) (mod USI (add value 2) 4)) ; extract
326 ; SI mode gr encoding for m32c is as follows:
327 ; register encoding index
328 ; -------------------------
331 (df f-dst32-rn-unprefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 8 2 UINT
332 ((value pc) (add USI value 2)) ; insert
333 ((value pc) (sub USI value 2)) ; extract
335 (df f-dst32-rn-prefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 16 2 UINT
336 ((value pc) (add USI value 2)) ; insert
337 ((value pc) (sub USI value 2)) ; extract
340 (dnf f-dst16-1-S "destination R0[hl] for m16c" (MACH16 m16c-isa) 5 1)
342 ;-------------------------------------------------------------
343 ; Immediates embedded in the base insn
344 ;-------------------------------------------------------------
346 (df f-imm-8-s4 "4 bit signed" (all-isas) 8 4 INT #f #f)
347 (df f-imm-12-s4 "4 bit signed" (all-isas) 12 4 INT #f #f)
348 (df f-imm-13-u3 "3 bit unsigned" (all-isas) 13 3 UINT #f #f)
349 (df f-imm-20-s4 "4 bit signed" (all-isas) 20 4 INT #f #f)
351 (df f-imm1-S "1 bit immediate for short format binary insns" (MACH32 m32c-isa) 2 1 UINT
352 ((value pc) (sub USI value 1)) ; insert
353 ((value pc) (add USI value 1)) ; extract
356 (dnmf f-imm3-S "3 bit unsigned for short format insns" (all-isas) UINT
358 (sequence () ; insert
359 (set (ifield f-7-1) (and (sub (ifield f-imm3-S) 1) 1))
360 (set (ifield f-2-2) (and (srl (sub (ifield f-imm3-S) 1) 1) #x3))
362 (sequence () ; extract
363 (set (ifield f-imm3-S) (add (or (sll (ifield f-2-2) 1)
369 ;-------------------------------------------------------------
370 ; Immediates and displacements beyond the base insn
371 ;-------------------------------------------------------------
373 (df f-dsp-8-u6 "6 bit unsigned" (all-isas) 8 6 UINT #f #f)
374 (df f-dsp-8-u8 "8 bit unsigned" (all-isas) 8 8 UINT #f #f)
375 (df f-dsp-8-s8 "8 bit signed" (all-isas) 8 8 INT #f #f)
376 (df f-dsp-10-u6 "6 bit unsigned" (all-isas) 10 6 UINT #f #f)
377 (df f-dsp-16-u8 "8 bit unsigned" (all-isas) 16 8 UINT #f #f)
378 (df f-dsp-16-s8 "8 bit signed" (all-isas) 16 8 INT #f #f)
379 (df f-dsp-24-u8 "8 bit unsigned" (all-isas) 24 8 UINT #f #f)
380 (df f-dsp-24-s8 "8 bit signed" (all-isas) 24 8 INT #f #f)
381 (df f-dsp-32-u8 "8 bit unsigned" (all-isas) 32 8 UINT #f #f)
382 (df f-dsp-32-s8 "8 bit signed" (all-isas) 32 8 INT #f #f)
383 (df f-dsp-40-u8 "8 bit unsigned" (all-isas) 40 8 UINT #f #f)
384 (df f-dsp-40-s8 "8 bit signed" (all-isas) 40 8 INT #f #f)
385 (df f-dsp-48-u8 "8 bit unsigned" (all-isas) 48 8 UINT #f #f)
386 (df f-dsp-48-s8 "8 bit signed" (all-isas) 48 8 INT #f #f)
387 (df f-dsp-56-u8 "8 bit unsigned" (all-isas) 56 8 UINT #f #f)
388 (df f-dsp-56-s8 "8 bit signed" (all-isas) 56 8 INT #f #f)
389 (df f-dsp-64-u8 "8 bit unsigned" (all-isas) 64 8 UINT #f #f)
390 (df f-dsp-64-s8 "8 bit signed" (all-isas) 64 8 INT #f #f)
392 ; Insn opcode endianness is big, but the immediate fields are stored
393 ; in little endian. Handle this here at the field level for all immediate
394 ; fields longer that 1 byte.
396 ; CGEN can't handle a field which spans a 32 bit word boundary, so
397 ; handle those as multi ifields.
399 ; Take care in expressions using 'srl' or 'sll' as part of some larger
400 ; expression meant to yield sign-extended values. CGEN translates
401 ; uses of those operators into C expressions whose type is 'unsigned
402 ; int', which tends to make the whole expression 'unsigned int'.
403 ; Expressions like (set (ifield foo) X), however, just take X and
404 ; store it in some member of 'struct cgen_fields', all of whose
405 ; members are 'long'. On machines where 'long' is larger than
406 ; 'unsigned int', assigning a "sign-extended" unsigned int to a long
407 ; just produces a very large positive value. insert_normal will
408 ; range-check the field's value and produce odd error messages like
411 ; Error: operand out of range (4160684031 not between -2147483648 and 2147483647) `add.l #-265,-270[fb]'
413 ; Annoyingly, the code will work fine on machines where 'long' and
414 ; 'unsigned int' are the same size: the assignment will produce a
417 ; Just tell yourself over and over: overflow detection is expensive,
418 ; and you're glad C doesn't do it, because it never happens in real
421 (df f-dsp-8-u16 "16 bit unsigned" (all-isas) 8 16 UINT
423 (and (srl value 8) #x00ff)
424 (and (sll value 8) #xff00))) ; insert
426 (and UHI (srl UHI value 8) #x00ff)
427 (and UHI (sll UHI value 8) #xff00))) ; extract
430 (df f-dsp-8-s16 "8 bit signed" (all-isas) 8 16 INT
433 (or (and (srl value 8) #x00ff)
434 (and (sll value 8) #xff00))))) ; insert
437 (or (and (srl value 8) #x00ff)
438 (and (sll value 8) #xff00))))) ; extract
441 (df f-dsp-16-u16 "16 bit unsigned" (all-isas) 16 16 UINT
443 (and (srl value 8) #x00ff)
444 (and (sll value 8) #xff00))) ; insert
446 (and UHI (srl UHI value 8) #x00ff)
447 (and UHI (sll UHI value 8) #xff00))) ; extract
450 (df f-dsp-16-s16 "16 bit signed" (all-isas) 16 16 INT
453 (or (and (srl value 8) #x00ff)
454 (and (sll value 8) #xff00))))) ; insert
457 (or (and (srl value 8) #x00ff)
458 (and (sll value 8) #xff00))))) ; extract
461 (dnmf f-dsp-24-u16 "16 bit unsigned" (all-isas) UINT
462 (f-dsp-24-u8 f-dsp-32-u8)
463 (sequence () ; insert
464 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u16) #xff))
465 (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-24-u16) 8) #xff))
467 (sequence () ; extract
468 (set (ifield f-dsp-24-u16) (or (sll (ifield f-dsp-32-u8) 8)
469 (ifield f-dsp-24-u8)))
473 (dnmf f-dsp-24-s16 "16 bit signed" (all-isas) INT
474 (f-dsp-24-u8 f-dsp-32-u8)
475 (sequence () ; insert
476 (set (ifield f-dsp-24-u8)
477 (and (ifield f-dsp-24-s16) #xff))
478 (set (ifield f-dsp-32-u8)
479 (and (srl (ifield f-dsp-24-s16) 8) #xff))
481 (sequence () ; extract
482 (set (ifield f-dsp-24-s16)
484 (trunc HI (or (sll (ifield f-dsp-32-u8) 8)
485 (ifield f-dsp-24-u8)))))
489 (df f-dsp-32-u16 "16 bit unsigned" (all-isas) 32 16 UINT
491 (and (srl value 8) #x00ff)
492 (and (sll value 8) #xff00))) ; insert
494 (and UHI (srl UHI value 8) #x00ff)
495 (and UHI (sll UHI value 8) #xff00))) ; extract
498 (df f-dsp-32-s16 "16 bit signed" (all-isas) 32 16 INT
501 (or (and (srl value 8) #x00ff)
502 (and (sll value 8) #xff00))))) ; insert
505 (or (and (srl value 8) #x00ff)
506 (and (sll value 8) #xff00))))) ; extract
509 (df f-dsp-40-u16 "16 bit unsigned" (all-isas) 40 16 UINT
511 (and (srl value 8) #x00ff)
512 (and (sll value 8) #xff00))) ; insert
514 (and UHI (srl UHI value 8) #x00ff)
515 (and UHI (sll UHI value 8) #xff00))) ; extract
518 (df f-dsp-40-s16 "16 bit signed" (all-isas) 40 16 INT
521 (or (and (srl value 8) #x00ff)
522 (and (sll value 8) #xff00))))) ; insert
525 (or (and (srl value 8) #x00ff)
526 (and (sll value 8) #xff00))))) ; extract
529 (df f-dsp-48-u16 "16 bit unsigned" (all-isas) 48 16 UINT
531 (and (srl value 8) #x00ff)
532 (and (sll value 8) #xff00))) ; insert
534 (and UHI (srl UHI value 8) #x00ff)
535 (and UHI (sll UHI value 8) #xff00))) ; extract
538 (df f-dsp-48-s16 "16 bit signed" (all-isas) 48 16 INT
541 (or (and (srl value 8) #x00ff)
542 (and (sll value 8) #xff00))))) ; insert
545 (or (and (srl value 8) #x00ff)
546 (and (sll value 8) #xff00))))) ; extract
549 (df f-dsp-64-u16 "16 bit unsigned" (all-isas) 64 16 UINT
551 (and (srl value 8) #x00ff)
552 (and (sll value 8) #xff00))) ; insert
554 (and UHI (srl UHI value 8) #x00ff)
555 (and UHI (sll UHI value 8) #xff00))) ; extract
558 (dnmf f-dsp-16-u24 "24 bit unsigned" (all-isas) UINT
559 (f-dsp-16-u16 f-dsp-32-u8)
560 (sequence () ; insert
561 (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-u24) #xffff))
562 (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-16-u24) 16) #xff))
564 (sequence () ; extract
565 (set (ifield f-dsp-16-u24) (or (sll (ifield f-dsp-32-u8) 16)
566 (ifield f-dsp-16-u16)))
570 (dnmf f-dsp-24-u24 "24 bit unsigned" (all-isas) UINT
571 (f-dsp-24-u8 f-dsp-32-u16)
572 (sequence () ; insert
573 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u24) #xff))
574 (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-24-u24) 8) #xffff))
576 (sequence () ; extract
577 (set (ifield f-dsp-24-u24) (or (sll (ifield f-dsp-32-u16) 8)
578 (ifield f-dsp-24-u8)))
582 (df f-dsp-32-u24 "24 bit unsigned" (all-isas) 32 24 UINT
585 (and (srl value 16) #x0000ff)
586 (and value #x00ff00))
587 (and (sll value 16) #xff0000))) ; insert
590 (and USI (srl UHI value 16) #x0000ff)
591 (and USI value #x00ff00))
592 (and USI (sll UHI value 16) #xff0000))) ; extract
595 (df f-dsp-40-u24 "24 bit unsigned" (all-isas) 40 24 UINT
598 (and (srl value 16) #x0000ff)
599 (and value #x00ff00))
600 (and (sll value 16) #xff0000))) ; insert
603 (and USI (srl UHI value 16) #x0000ff)
604 (and USI value #x00ff00))
605 (and USI (sll UHI value 16) #xff0000))) ; extract
608 (dnmf f-dsp-40-s32 "32 bit signed" (all-isas) INT
609 (f-dsp-40-u24 f-dsp-64-u8)
610 (sequence () ; insert
611 (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-40-s32) 24) #xff))
612 (set (ifield f-dsp-40-u24) (and (ifield f-dsp-40-s32) #xffffff))
614 (sequence () ; extract
615 (set (ifield f-dsp-40-s32) (or (and (ifield f-dsp-40-u24) #xffffff)
616 (and (sll (ifield f-dsp-64-u8) 24) #xff000000)))
620 (dnmf f-dsp-48-u24 "24 bit unsigned" (all-isas) UINT
621 (f-dsp-48-u16 f-dsp-64-u8)
622 (sequence () ; insert
623 (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-48-u24) 16) #xff))
624 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u24) #xffff))
626 (sequence () ; extract
627 (set (ifield f-dsp-48-u24) (or (and (ifield f-dsp-48-u16) #xffff)
628 (and (sll (ifield f-dsp-64-u8) 16) #xff0000)))
632 (dnmf f-dsp-16-s32 "32 bit signed" (all-isas) INT
633 (f-dsp-16-u16 f-dsp-32-u16)
634 (sequence () ; insert
635 (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-16-s32) 16) #xffff))
636 (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-s32) #xffff))
638 (sequence () ; extract
639 (set (ifield f-dsp-16-s32) (or (and (ifield f-dsp-16-u16) #xffff)
640 (and (sll (ifield f-dsp-32-u16) 16) #xffff0000)))
644 (dnmf f-dsp-24-s32 "32 bit signed" (all-isas) INT
645 (f-dsp-24-u8 f-dsp-32-u24)
646 (sequence () ; insert
647 (set (ifield f-dsp-32-u24) (and (srl (ifield f-dsp-24-s32) 8) #xffffff))
648 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-s32) #xff))
650 (sequence () ; extract
651 (set (ifield f-dsp-24-s32) (or (and (ifield f-dsp-24-u8) #xff)
652 (and (sll (ifield f-dsp-32-u24) 8) #xffffff00)))
656 (df f-dsp-32-s32 "32 bit signed" (all-isas) 32 32 INT
663 (and (srl value 24) #x000000ff)
664 (and (srl value 8) #x0000ff00))
666 (and (sll value 8) #x00ff0000)
667 (and (sll value 24) #xff000000)))))
674 (and (srl value 24) #x000000ff)
675 (and (srl value 8) #x0000ff00))
677 (and (sll value 8) #x00ff0000)
678 (and (sll value 24) #xff000000)))))
681 (dnmf f-dsp-48-u32 "32 bit unsigned" (all-isas) UINT
682 (f-dsp-48-u16 f-dsp-64-u16)
683 (sequence () ; insert
684 (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-u32) 16) #xffff))
685 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u32) #xffff))
687 (sequence () ; extract
688 (set (ifield f-dsp-48-u32) (or (and (ifield f-dsp-48-u16) #xffff)
689 (and (sll (ifield f-dsp-64-u16) 16) #xffff0000)))
693 (dnmf f-dsp-48-s32 "32 bit signed" (all-isas) INT
694 (f-dsp-48-u16 f-dsp-64-u16)
695 (sequence () ; insert
696 (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-s32) 16) #xffff))
697 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-s32) #xffff))
699 (sequence () ; extract
700 (set (ifield f-dsp-48-s32) (or (and (ifield f-dsp-48-u16) #xffff)
701 (and (sll (ifield f-dsp-64-u16) 16) #xffff0000)))
705 (dnmf f-dsp-56-s16 "16 bit signed" (all-isas) INT
706 (f-dsp-56-u8 f-dsp-64-u8)
707 (sequence () ; insert
708 (set (ifield f-dsp-56-u8)
709 (and (ifield f-dsp-56-s16) #xff))
710 (set (ifield f-dsp-64-u8)
711 (and (srl (ifield f-dsp-56-s16) 8) #xff))
713 (sequence () ; extract
714 (set (ifield f-dsp-56-s16)
716 (trunc HI (or (sll (ifield f-dsp-64-u8) 8)
717 (ifield f-dsp-56-u8)))))
721 (df f-dsp-64-s16 " 16 bit signed" (all-isas) 64 16 INT
724 (or (and (srl value 8) #x00ff)
725 (and (sll value 8) #xff00))))) ; insert
728 (or (and (srl value 8) #x00ff)
729 (and (sll value 8) #xff00))))) ; extract
732 ;-------------------------------------------------------------
734 ;-------------------------------------------------------------
736 (dnf f-bitno16-S "bit index for m16c" (all-isas) 5 3)
737 (dnf f-bitno32-prefixed "bit index for m32c" (all-isas) 21 3)
738 (dnf f-bitno32-unprefixed "bit index for m32c" (all-isas) 13 3)
740 (dnmf f-bitbase16-u11-S "unsigned bit,base:11" (all-isas) UINT
741 (f-bitno16-S f-dsp-8-u8)
742 (sequence () ; insert
743 (set (ifield f-bitno16-S) (and f-bitbase16-u11-S #x7))
744 (set (ifield f-dsp-8-u8) (and (srl (ifield f-bitbase16-u11-S) 3) #xff))
746 (sequence () ; extract
747 (set (ifield f-bitbase16-u11-S) (or (sll (ifield f-dsp-8-u8) 3)
748 (ifield f-bitno16-S)))
752 (dnmf f-bitbase32-16-u11-unprefixed "unsigned bit,base:11" (all-isas) UINT
753 (f-bitno32-unprefixed f-dsp-16-u8)
754 (sequence () ; insert
755 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u11-unprefixed #x7))
756 (set (ifield f-dsp-16-u8) (and (srl (ifield f-bitbase32-16-u11-unprefixed) 3) #xff))
758 (sequence () ; extract
759 (set (ifield f-bitbase32-16-u11-unprefixed) (or (sll (ifield f-dsp-16-u8) 3)
760 (ifield f-bitno32-unprefixed)))
763 (dnmf f-bitbase32-16-s11-unprefixed "signed bit,base:11" (all-isas) INT
764 (f-bitno32-unprefixed f-dsp-16-s8)
765 (sequence () ; insert
766 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s11-unprefixed #x7))
767 (set (ifield f-dsp-16-s8) (sra INT (ifield f-bitbase32-16-s11-unprefixed) 3))
769 (sequence () ; extract
770 (set (ifield f-bitbase32-16-s11-unprefixed) (or (sll (ifield f-dsp-16-s8) 3)
771 (ifield f-bitno32-unprefixed)))
774 (dnmf f-bitbase32-16-u19-unprefixed "unsigned bit,base:19" (all-isas) UINT
775 (f-bitno32-unprefixed f-dsp-16-u16)
776 (sequence () ; insert
777 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u19-unprefixed #x7))
778 (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u19-unprefixed) 3) #xffff))
780 (sequence () ; extract
781 (set (ifield f-bitbase32-16-u19-unprefixed) (or (sll (ifield f-dsp-16-u16) 3)
782 (ifield f-bitno32-unprefixed)))
785 (dnmf f-bitbase32-16-s19-unprefixed "signed bit,base:11" (all-isas) INT
786 (f-bitno32-unprefixed f-dsp-16-s16)
787 (sequence () ; insert
788 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s19-unprefixed #x7))
789 (set (ifield f-dsp-16-s16) (sra INT (ifield f-bitbase32-16-s19-unprefixed) 3))
791 (sequence () ; extract
792 (set (ifield f-bitbase32-16-s19-unprefixed) (or (sll (ifield f-dsp-16-s16) 3)
793 (ifield f-bitno32-unprefixed)))
796 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
797 (dnmf f-bitbase32-16-u27-unprefixed "unsigned bit,base:27" (all-isas) UINT
798 (f-bitno32-unprefixed f-dsp-16-u16 f-dsp-32-u8)
799 (sequence () ; insert
800 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u27-unprefixed #x7))
801 (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 3) #xffff))
802 (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 19) #xff))
804 (sequence () ; extract
805 (set (ifield f-bitbase32-16-u27-unprefixed) (or (sll (ifield f-dsp-16-u16) 3)
806 (or (sll (ifield f-dsp-32-u8) 19)
807 (ifield f-bitno32-unprefixed))))
810 (dnmf f-bitbase32-24-u11-prefixed "unsigned bit,base:11" (all-isas) UINT
811 (f-bitno32-prefixed f-dsp-24-u8)
812 (sequence () ; insert
813 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u11-prefixed #x7))
814 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u11-prefixed) 3) #xff))
816 (sequence () ; extract
817 (set (ifield f-bitbase32-24-u11-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
818 (ifield f-bitno32-prefixed)))
821 (dnmf f-bitbase32-24-s11-prefixed "signed bit,base:11" (all-isas) INT
822 (f-bitno32-prefixed f-dsp-24-s8)
823 (sequence () ; insert
824 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s11-prefixed #x7))
825 (set (ifield f-dsp-24-s8) (sra INT (ifield f-bitbase32-24-s11-prefixed) 3))
827 (sequence () ; extract
828 (set (ifield f-bitbase32-24-s11-prefixed) (or (sll (ifield f-dsp-24-s8) 3)
829 (ifield f-bitno32-prefixed)))
832 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
833 (dnmf f-bitbase32-24-u19-prefixed "unsigned bit,base:19" (all-isas) UINT
834 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u8)
835 (sequence () ; insert
836 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u19-prefixed #x7))
837 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 3) #xff))
838 (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 11) #xff))
840 (sequence () ; extract
841 (set (ifield f-bitbase32-24-u19-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
842 (or (sll (ifield f-dsp-32-u8) 11)
843 (ifield f-bitno32-prefixed))))
846 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
847 (dnmf f-bitbase32-24-s19-prefixed "signed bit,base:11" (all-isas) INT
848 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-s8)
849 (sequence () ; insert
850 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s19-prefixed #x7))
851 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-s19-prefixed) 3) #xff))
852 (set (ifield f-dsp-32-s8) (sra INT (ifield f-bitbase32-24-s19-prefixed) 11))
854 (sequence () ; extract
855 (set (ifield f-bitbase32-24-s19-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
856 (or (sll (ifield f-dsp-32-s8) 11)
857 (ifield f-bitno32-prefixed))))
860 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
861 (dnmf f-bitbase32-24-u27-prefixed "unsigned bit,base:27" (all-isas) UINT
862 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u16)
863 (sequence () ; insert
864 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u27-prefixed #x7))
865 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u27-prefixed) 3) #xff))
866 (set (ifield f-dsp-32-u16) (and (srl (ifield f-bitbase32-24-u27-prefixed) 11) #xffff))
868 (sequence () ; extract
869 (set (ifield f-bitbase32-24-u27-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
870 (or (sll (ifield f-dsp-32-u16) 11)
871 (ifield f-bitno32-prefixed))))
875 ;-------------------------------------------------------------
877 ;-------------------------------------------------------------
879 (df f-lab-5-3 "3 bit pc relative signed offset" (PCREL-ADDR all-isas) 5 3 INT
880 ((value pc) (sub SI value (add SI pc 2))) ; insert
881 ((value pc) (add SI value (add SI pc 2))) ; extract
883 (dnmf f-lab32-jmp-s "unsigned 3 bit pc relative offset" (PCREL-ADDR all-isas) UINT
885 (sequence () ; insert
886 (set (ifield f-7-1) (and (sub (ifield f-lab32-jmp-s) pc) #x1))
887 (set (ifield f-2-2) (srl (sub (ifield f-lab32-jmp-s) pc) 1))
889 (sequence () ; extract
890 (set (ifield f-lab32-jmp-s) (add pc (add (or (sll (ifield f-2-2) 1)
895 (df f-lab-8-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 8 8 INT
896 ((value pc) (sub SI value (add SI pc 1))) ; insert
897 ((value pc) (add SI value (add SI pc 1))) ; extract
899 (df f-lab-8-16 "16 bit pc relative signed offset" (PCREL-ADDR SIGN-OPT all-isas) 8 16 UINT
900 ((value pc) (or SI (sll (and (sub value (add pc 1)) #xff) 8)
901 (srl (and (sub value (add pc 1)) #xffff) 8)))
902 ((value pc) (add SI (or (srl (and value #xffff) 8)
903 (sra (sll (and value #xff) 24) 16)) (add pc 1)))
905 (df f-lab-8-24 "24 bit absolute" (all-isas ABS-ADDR) 8 24 UINT
907 (or (srl value 16) (and value #xff00))
908 (sll (and value #xff) 16)))
910 (or (srl value 16) (and value #xff00))
911 (sll (and value #xff) 16)))
913 (df f-lab-16-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 16 8 INT
914 ((value pc) (sub SI value (add SI pc 2))) ; insert
915 ((value pc) (add SI value (add SI pc 2))) ; extract
917 (df f-lab-24-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 24 8 INT
918 ((value pc) (sub SI value (add SI pc 2))) ; insert
919 ((value pc) (add SI value (add SI pc 2))) ; extract
921 (df f-lab-32-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 32 8 INT
922 ((value pc) (sub SI value (add SI pc 2))) ; insert
923 ((value pc) (add SI value (add SI pc 2))) ; extract
925 (df f-lab-40-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 40 8 INT
926 ((value pc) (sub SI value (add SI pc 2))) ; insert
927 ((value pc) (add SI value (add SI pc 2))) ; extract
930 ;-------------------------------------------------------------
932 ;-------------------------------------------------------------
934 (dnf f-cond16 "condition code" (all-isas) 12 4)
935 (dnf f-cond16j-5 "condition code" (all-isas) 5 3)
937 (dnmf f-cond32 "condition code" (all-isas) UINT
939 (sequence () ; insert
940 (set (ifield f-9-1) (and (srl (ifield f-cond32) 3) 1))
941 (set (ifield f-13-3) (and (ifield f-cond32) #x7))
943 (sequence () ; extract
944 (set (ifield f-cond32) (or (sll (ifield f-9-1) 3)
949 (dnmf f-cond32j "condition code" (all-isas) UINT
951 (sequence () ; insert
952 (set (ifield f-1-3) (and (srl (ifield f-cond32j) 1) #x7))
953 (set (ifield f-7-1) (and (ifield f-cond32j) #x1))
955 (sequence () ; extract
956 (set (ifield f-cond32j) (or (sll (ifield f-1-3) 1)
961 ;=============================================================
964 (dnh h-pc "program counter" (PC all-isas) (pc USI) () () ())
966 ;-------------------------------------------------------------
968 ; The actual registers are 16 bits
969 ;-------------------------------------------------------------
973 (comment "general 16 bit registers")
974 (attrs all-isas CACHE-ADDR)
975 (type register HI (4))
976 (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3))))
978 ; Define different views of the grs as VIRTUAL with getter/setter specs
982 (comment "general 8 bit registers")
983 (attrs all-isas VIRTUAL)
984 (type register QI (4))
985 (indices keyword "" (("r0l" 0) ("r0h" 1) ("r1l" 2) ("r1h" 3)))
986 (get (index) (and (if SI (mod index 2)
987 (srl (reg h-gr (div index 2)) 8)
988 (reg h-gr (div index 2)))
990 (set (index newval) (set (reg h-gr (div index 2))
992 (or (and (reg h-gr (div index 2)) #xff)
993 (sll (and newval #xff) 8))
994 (or (and (reg h-gr (div index 2)) #xff00)
995 (and newval #xff))))))
999 (comment "general 16 bit registers")
1000 (attrs all-isas VIRTUAL)
1001 (type register HI (4))
1002 (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3)))
1003 (get (index) (reg h-gr index))
1004 (set (index newval) (set (reg h-gr index) newval)))
1008 (comment "general 32 bit registers")
1009 (attrs all-isas VIRTUAL)
1010 (type register SI (2))
1011 (indices keyword "" (("r2r0" 0) ("r3r1" 1)))
1013 (and (reg h-gr index) #xffff)
1014 (and (sll (reg h-gr (add index 2)) 16) #xffff0000)))
1015 (set (index newval) (sequence ()
1016 (set (reg h-gr index) (and newval #xffff))
1017 (set (reg h-gr (add index 2)) (srl newval 16)))))
1021 (comment "general 16 bit registers")
1022 (attrs all-isas VIRTUAL)
1023 (type register HI (2))
1024 (indices keyword "" (("r0l" 0) ("r1l" 1)))
1025 (get (index) (reg h-gr-QI (mul index 2)))
1026 (set (index newval) (set (reg h-gr (mul index 2)) newval)))
1030 (comment "general 16 bit registers")
1031 (attrs all-isas VIRTUAL)
1032 (type register SI (2))
1033 (indices keyword "" (("r0" 0) ("r1" 1)))
1034 (get (index) (reg h-gr (mul index 2)))
1035 (set (index newval) (set (reg h-gr-SI index) newval)))
1039 (comment "r0l register")
1040 (attrs all-isas VIRTUAL)
1042 (indices keyword "" (("r0l" 0)))
1043 (get () (reg h-gr-QI 0))
1044 (set (newval) (set (reg h-gr-QI 0) newval)))
1048 (comment "r0h register")
1049 (attrs all-isas VIRTUAL)
1051 (indices keyword "" (("r0h" 0)))
1052 (get () (reg h-gr-QI 1))
1053 (set (newval) (set (reg h-gr-QI 1) newval)))
1057 (comment "r1l register")
1058 (attrs all-isas VIRTUAL)
1060 (indices keyword "" (("r1l" 0)))
1061 (get () (reg h-gr-QI 2))
1062 (set (newval) (set (reg h-gr-QI 2) newval)))
1066 (comment "r1h register")
1067 (attrs all-isas VIRTUAL)
1069 (indices keyword "" (("r1h" 0)))
1070 (get () (reg h-gr-QI 3))
1071 (set (newval) (set (reg h-gr-QI 3) newval)))
1075 (comment "r0 register")
1076 (attrs all-isas VIRTUAL)
1078 (indices keyword "" (("r0" 0)))
1079 (get () (reg h-gr 0))
1080 (set (newval) (set (reg h-gr 0) newval)))
1084 (comment "r1 register")
1085 (attrs all-isas VIRTUAL)
1087 (indices keyword "" (("r1" 0)))
1088 (get () (reg h-gr 1))
1089 (set (newval) (set (reg h-gr 1) newval)))
1093 (comment "r2 register")
1094 (attrs all-isas VIRTUAL)
1096 (indices keyword "" (("r2" 0)))
1097 (get () (reg h-gr 2))
1098 (set (newval) (set (reg h-gr 2) newval)))
1102 (comment "r3 register")
1103 (attrs all-isas VIRTUAL)
1105 (indices keyword "" (("r3" 0)))
1106 (get () (reg h-gr 3))
1107 (set (newval) (set (reg h-gr 3) newval)))
1111 (comment "r0l or r0h")
1112 (attrs all-isas VIRTUAL)
1113 (type register QI (2))
1114 (indices keyword "" (("r0l" 0) ("r0h" 1)))
1115 (get (index) (reg h-gr-QI index))
1116 (set (index newval) (set (reg h-gr-QI index) newval)))
1120 (comment "r2r0 register")
1121 (attrs all-isas VIRTUAL)
1123 (indices keyword "" (("r2r0" 0)))
1124 (get () (or (sll (reg h-gr 2) 16) (reg h-gr 0)))
1127 (set (reg h-gr 0) newval)
1128 (set (reg h-gr 2) (sra newval 16)))))
1132 (comment "r3r1 register")
1133 (attrs all-isas VIRTUAL)
1135 (indices keyword "" (("r3r1" 0)))
1136 (get () (or (sll (reg h-gr 3) 16) (reg h-gr 1)))
1139 (set (reg h-gr 1) newval)
1140 (set (reg h-gr 3) (sra newval 16)))))
1144 (comment "r1r2r0 register")
1145 (attrs all-isas VIRTUAL)
1147 (indices keyword "" (("r1r2r0" 0)))
1148 (get () (or DI (sll DI (reg h-gr 1) 32) (or (sll (reg h-gr 2) 16) (reg h-gr 0))))
1151 (set (reg h-gr 0) newval)
1152 (set (reg h-gr 2) (sra newval 16))
1153 (set (reg h-gr 1) (sra newval 32)))))
1155 ;-------------------------------------------------------------
1157 ;-------------------------------------------------------------
1161 (comment "address registers")
1163 (type register USI (2))
1164 (indices keyword "" (("a0" 0) ("a1" 1)))
1165 (get (index) (c-call USI "h_ar_get_handler" index))
1166 (set (index newval) (c-call VOID "h_ar_set_handler" index newval)))
1168 ; Define different views of the ars as VIRTUAL with getter/setter specs
1171 (comment "8 bit view of address register")
1172 (attrs all-isas VIRTUAL)
1173 (type register QI (2))
1174 (indices keyword "" (("a0" 0) ("a1" 1)))
1175 (get (index) (reg h-ar index))
1176 (set (index newval) (set (reg h-ar index) newval)))
1180 (comment "16 bit view of address register")
1181 (attrs all-isas VIRTUAL)
1182 (type register HI (2))
1183 (indices keyword "" (("a0" 0) ("a1" 1)))
1184 (get (index) (reg h-ar index))
1185 (set (index newval) (set (reg h-ar index) newval)))
1189 (comment "32 bit view of address register")
1190 (attrs all-isas VIRTUAL)
1192 (indices keyword "" (("a1a0" 0)))
1193 (get () (or SI (sll SI (ext SI (reg h-ar 1)) 16) (ext SI (reg h-ar 0))))
1194 (set (newval) (sequence ()
1195 (set (reg h-ar 0) (and newval #xffff))
1196 (set (reg h-ar 1) (and (srl newval 16) #xffff)))))
1200 (comment "16 bit view of address register")
1201 (attrs all-isas VIRTUAL)
1203 (indices keyword "" (("a0" 0)))
1204 (get () (reg h-ar 0))
1205 (set (newval) (set (reg h-ar 0) newval)))
1209 (comment "16 bit view of address register")
1210 (attrs all-isas VIRTUAL)
1212 (indices keyword "" (("a1" 1)))
1213 (get () (reg h-ar 1))
1214 (set (newval) (set (reg h-ar 1) newval)))
1219 (comment "SB register")
1222 (get () (c-call USI "h_sb_get_handler"))
1223 (set (newval) (c-call VOID "h_sb_set_handler" newval))
1229 (comment "FB register")
1232 (get () (c-call USI "h_fb_get_handler"))
1233 (set (newval) (c-call VOID "h_fb_set_handler" newval))
1239 (comment "SP register")
1242 (get () (c-call USI "h_sp_get_handler"))
1243 (set (newval) (c-call VOID "h_sp_set_handler" newval))
1246 ;-------------------------------------------------------------
1247 ; condition-code bits
1248 ;-------------------------------------------------------------
1252 (comment "sign bit")
1259 (comment "zero bit")
1266 (comment "overflow bit")
1273 (comment "carry bit")
1280 (comment "stack pointer select bit")
1287 (comment "interrupt enable bit")
1294 (comment "register bank select bit")
1301 (comment "debug bit")
1308 (comment "dma transfer count 000")
1314 (comment "dma transfer count 001")
1320 (comment "save flag 011")
1326 (comment "dma transfer count reload 100")
1332 (comment "dma transfer count reload 101")
1338 (comment "dma mode 110")
1344 (comment "dma mode 111")
1350 (comment "interrupt table 000")
1356 (comment "save pc 100")
1362 (comment "vector 101")
1368 (comment "interrupt stack ptr 111")
1374 (comment "dma mem addr 010")
1380 (comment "dma mem addr 011")
1386 (comment "dma mem addr reload 100")
1392 (comment "dma mem addr reload 101")
1398 (comment "dma sfr addr 110")
1404 (comment "dma sfr addr 111")
1409 ;-------------------------------------------------------------
1410 ; Condition code operand hardware
1411 ;-------------------------------------------------------------
1415 (comment "condition code hardware for m16c")
1416 (attrs m16c-isa MACH16)
1417 (type immediate UQI)
1419 (("geu" #x00) ("c" #x00)
1421 ("eq" #x02) ("z" #x02)
1426 ("ltu" #xf8) ("nc" #xf8)
1428 ("ne" #xfa) ("nz" #xfa)
1438 (comment "condition code hardware for m16c")
1439 (attrs m16c-isa MACH16)
1440 (type immediate UQI)
1442 (("geu" #x00) ("c" #x00)
1444 ("eq" #x02) ("z" #x02)
1446 ("ltu" #x04) ("nc" #x04)
1448 ("ne" #x06) ("nz" #x06)
1461 (comment "condition code hardware for m16c")
1462 (attrs m16c-isa MACH16)
1463 (type immediate UQI)
1476 (comment "condition code hardware for m16c")
1477 (attrs m16c-isa MACH16)
1478 (type immediate UQI)
1480 (("geu" #x00) ("c" #x00)
1482 ("eq" #x02) ("z" #x02)
1484 ("ltu" #x04) ("nc" #x04)
1486 ("ne" #x06) ("nz" #x06)
1494 (comment "condition code hardware for m32c")
1495 (attrs m32c-isa MACH32)
1496 (type immediate UQI)
1498 (("ltu" #x00) ("nc" #x00)
1500 ("ne" #x02) ("nz" #x02)
1505 ("geu" #x08) ("c" #x08)
1507 ("eq" #x0a) ("z" #x0a)
1518 (comment "control registers")
1519 (attrs m32c-isa MACH32)
1520 (type immediate UQI)
1521 (values keyword "" (("dct0" 0) ("dct1" 1) ("flg" 2) ("svf" 3) ("drc0" 4)
1522 ("drc1" 5) ("dmd0" 6) ("dmd1" 7))))
1525 (comment "control registers")
1526 (attrs m32c-isa MACH32)
1527 (type immediate UQI)
1528 (values keyword "" (("intb" 0) ("sp" 1) ("sb" 2) ("fb" 3) ("svp" 4)
1529 ("vct" 5) ("isp" 7))))
1533 (comment "control registers")
1534 (attrs m32c-isa MACH32)
1535 (type immediate UQI)
1536 (values keyword "" (("dma0" 2) ("dma1" 3) ("dra0" 4)
1537 ("dra1" 5) ("dsa0" 6) ("dsa1" 7))))
1540 (comment "control registers")
1541 (attrs m16c-isa MACH16)
1542 (type immediate UQI)
1543 (values keyword "" (("intbl" 1) ("intbh" 2) ("flg" 3) ("isp" 4)
1544 ("sp" 5) ("sb" 6) ("fb" 7))))
1548 (comment "flag hardware for m32c")
1550 (type immediate UQI)
1564 ;-------------------------------------------------------------
1565 ; Misc helper hardware
1566 ;-------------------------------------------------------------
1570 (comment "shift immediate")
1572 (type immediate (INT 4))
1573 (values keyword "" (("1" 0) ("2" 1) ("3" 2) ("4" 3) ("5" 4) ("6" 5) ("7" 6)
1574 ("8" 7) ("-1" -8) ("-2" -7) ("-3" -6) ("-4" -5) ("-5" -4)
1575 ("-6" -3) ("-7" -2) ("-8" -1)
1579 (comment "bit index for the next insn")
1580 (attrs m32c-isa MACH32)
1585 (comment "source index for the next insn")
1586 (attrs m32c-isa MACH32)
1591 (comment "destination index for the next insn")
1592 (attrs m32c-isa MACH32)
1596 (name h-src-indirect)
1597 (comment "indirect src for the next insn")
1602 (name h-dst-indirect)
1603 (comment "indirect dst for the next insn")
1609 (comment "for storing unused values")
1610 (attrs m32c-isa MACH32)
1614 ;=============================================================
1616 ;-------------------------------------------------------------
1618 ;-------------------------------------------------------------
1620 (dnop Src16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-src16-rn)
1621 (dnop Src16RnHI "general register QH view" (MACH16 m16c-isa) h-gr-HI f-src16-rn)
1623 (dnop Src32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-unprefixed-QI)
1624 (dnop Src32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-unprefixed-HI)
1625 (dnop Src32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-unprefixed-SI)
1627 (dnop Src32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-prefixed-QI)
1628 (dnop Src32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-prefixed-HI)
1629 (dnop Src32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-prefixed-SI)
1631 (dnop Src16An "address register" (MACH16 m16c-isa) h-ar f-src16-an)
1632 (dnop Src16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-src16-an)
1633 (dnop Src16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-src16-an)
1635 (dnop Src32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed)
1636 (dnop Src32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-unprefixed)
1637 (dnop Src32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-unprefixed)
1638 (dnop Src32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed)
1640 (dnop Src32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-prefixed)
1641 (dnop Src32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-prefixed)
1642 (dnop Src32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-prefixed)
1643 (dnop Src32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-prefixed)
1645 ; Destination Registers
1647 (dnop Dst16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-dst16-rn)
1648 (dnop Dst16RnHI "general register HI view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn)
1649 (dnop Dst16RnSI "general register SI view" (MACH16 m16c-isa) h-gr-SI f-dst16-rn)
1650 (dnop Dst16RnExtQI "general register QI/HI view for 'ext' insns" (MACH16 m16c-isa) h-gr-ext-QI f-dst16-rn-ext)
1652 (dnop Dst32R0QI-S "general register QI view" (MACH32 m32c-isa) h-r0l f-nil)
1653 (dnop Dst32R0HI-S "general register HI view" (MACH32 m32c-isa) h-r0 f-nil)
1655 (dnop Dst32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI)
1656 (dnop Dst32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-unprefixed-HI)
1657 (dnop Dst32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-unprefixed-SI)
1658 (dnop Dst32RnExtUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-ext-QI f-dst32-rn-ext-unprefixed)
1659 (dnop Dst32RnExtUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-ext-HI f-dst32-rn-ext-unprefixed)
1661 (dnop Dst32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI)
1662 (dnop Dst32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-prefixed-HI)
1663 (dnop Dst32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-prefixed-SI)
1665 (dnop Dst16RnQI-S "general register QI view" (MACH16 m16c-isa) h-r0l-r0h f-dst16-rn-QI-s)
1667 (dnop Dst16AnQI-S "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-rn-QI-s)
1669 (dnop Bit16Rn "general register bit view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn)
1671 (dnop Bit32RnPrefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI)
1672 (dnop Bit32RnUnprefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI)
1674 (dnop R0 "r0" (all-isas) h-r0 f-nil)
1675 (dnop R1 "r1" (all-isas) h-r1 f-nil)
1676 (dnop R2 "r2" (all-isas) h-r2 f-nil)
1677 (dnop R3 "r3" (all-isas) h-r3 f-nil)
1678 (dnop R0l "r0l" (all-isas) h-r0l f-nil)
1679 (dnop R0h "r0h" (all-isas) h-r0h f-nil)
1680 (dnop R2R0 "r2r0" (all-isas) h-r2r0 f-nil)
1681 (dnop R3R1 "r3r1" (all-isas) h-r3r1 f-nil)
1682 (dnop R1R2R0 "r1r2r0" (all-isas) h-r1r2r0 f-nil)
1684 (dnop Dst16An "address register" (MACH16 m16c-isa) h-ar f-dst16-an)
1685 (dnop Dst16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-an)
1686 (dnop Dst16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an)
1687 (dnop Dst16AnSI "address register SI view" (MACH16 m16c-isa) h-ar-SI f-dst16-an)
1688 (dnop Dst16An-S "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an-s)
1690 (dnop Dst32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1691 (dnop Dst32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-unprefixed)
1692 (dnop Dst32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-unprefixed)
1693 (dnop Dst32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1695 (dnop Dst32AnExtUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1697 (dnop Dst32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1698 (dnop Dst32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-prefixed)
1699 (dnop Dst32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-prefixed)
1700 (dnop Dst32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1702 (dnop Bit16An "address register bit view" (MACH16 m16c-isa) h-ar f-dst16-an)
1704 (dnop Bit32AnPrefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1705 (dnop Bit32AnUnprefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1707 (dnop A0 "a0" (all-isas) h-a0 f-nil)
1708 (dnop A1 "a1" (all-isas) h-a1 f-nil)
1710 (dnop sb "SB register" (all-isas SEM-ONLY) h-sb f-nil)
1711 (dnop fb "FB register" (all-isas SEM-ONLY) h-fb f-nil)
1712 (dnop sp "SP register" (all-isas SEM-ONLY) h-sp f-nil)
1714 (define-full-operand SrcDst16-r0l-r0h-S-normal "r0l/r0h pair" (MACH16 m16c-isa)
1716 ((parse "r0l_r0h") (print "r0l_r0h")) () ()
1719 (define-full-operand Regsetpop "popm regset" (all-isas) h-uint
1720 DFLT f-8-8 ((parse "pop_regset") (print "pop_regset")) () ())
1721 (define-full-operand Regsetpush "pushm regset" (all-isas) h-uint
1722 DFLT f-8-8 ((parse "push_regset") (print "push_regset")) () ())
1724 (dnop Rn16-push-S "r0[lh]" (MACH16 m16c-isa) h-gr-QI f-4-1)
1725 (dnop An16-push-S "a[01]" (MACH16 m16c-isa) h-ar-HI f-4-1)
1727 ;-------------------------------------------------------------
1728 ; Offsets and absolutes
1729 ;-------------------------------------------------------------
1731 (define-full-operand Dsp-8-u6 "unsigned 6 bit displacement at offset 8 bits" (all-isas)
1732 h-uint DFLT f-dsp-8-u6
1733 ((parse "unsigned6")) () ()
1735 (define-full-operand Dsp-8-u8 "unsigned 8 bit displacement at offset 8 bits" (all-isas)
1736 h-uint DFLT f-dsp-8-u8
1737 ((parse "unsigned8")) () ()
1739 (define-full-operand Dsp-8-u16 "unsigned 16 bit displacement at offset 8 bits" (all-isas)
1740 h-uint DFLT f-dsp-8-u16
1741 ((parse "unsigned16")) () ()
1743 (define-full-operand Dsp-8-s8 "signed 8 bit displacement at offset 8 bits" (all-isas)
1744 h-sint DFLT f-dsp-8-s8
1745 ((parse "signed8")) () ()
1747 (define-full-operand Dsp-10-u6 "unsigned 6 bit displacement at offset 10 bits" (all-isas)
1748 h-uint DFLT f-dsp-10-u6
1749 ((parse "unsigned6")) () ()
1751 (define-full-operand Dsp-16-u8 "unsigned 8 bit displacement at offset 16 bits" (all-isas)
1752 h-uint DFLT f-dsp-16-u8
1753 ((parse "unsigned8")) () ()
1755 (define-full-operand Dsp-16-u16 "unsigned 16 bit displacement at offset 16 bits" (all-isas)
1756 h-uint DFLT f-dsp-16-u16
1757 ((parse "unsigned16")) () ()
1759 (define-full-operand Dsp-16-u20 "unsigned 20 bit displacement at offset 16 bits" (all-isas)
1760 h-uint DFLT f-dsp-16-u24
1761 ((parse "unsigned20")) () ()
1763 (define-full-operand Dsp-16-u24 "unsigned 24 bit displacement at offset 16 bits" (all-isas)
1764 h-uint DFLT f-dsp-16-u24
1765 ((parse "unsigned24")) () ()
1767 (define-full-operand Dsp-16-s8 "signed 8 bit displacement at offset 16 bits" (all-isas)
1768 h-sint DFLT f-dsp-16-s8
1769 ((parse "signed8")) () ()
1771 (define-full-operand Dsp-16-s16 "signed 16 bit displacement at offset 16 bits" (all-isas)
1772 h-sint DFLT f-dsp-16-s16
1773 ((parse "signed16")) () ()
1775 (define-full-operand Dsp-24-u8 "unsigned 8 bit displacement at offset 24 bits" (all-isas)
1776 h-uint DFLT f-dsp-24-u8
1777 ((parse "unsigned8")) () ()
1779 (define-full-operand Dsp-24-u16 "unsigned 16 bit displacement at offset 24 bits" (all-isas)
1780 h-uint DFLT f-dsp-24-u16
1781 ((parse "unsigned16")) () ()
1783 (define-full-operand Dsp-24-u20 "unsigned 20 bit displacement at offset 24 bits" (all-isas)
1784 h-uint DFLT f-dsp-24-u24
1785 ((parse "unsigned20")) () ()
1787 (define-full-operand Dsp-24-u24 "unsigned 24 bit displacement at offset 24 bits" (all-isas)
1788 h-uint DFLT f-dsp-24-u24
1789 ((parse "unsigned24")) () ()
1791 (define-full-operand Dsp-24-s8 "signed 8 bit displacement at offset 24 bits" (all-isas)
1792 h-sint DFLT f-dsp-24-s8
1793 ((parse "signed8")) () ()
1795 (define-full-operand Dsp-24-s16 "signed 16 bit displacement at offset 24 bits" (all-isas)
1796 h-sint DFLT f-dsp-24-s16
1797 ((parse "signed16")) () ()
1799 (define-full-operand Dsp-32-u8 "unsigned 8 bit displacement at offset 32 bits" (all-isas)
1800 h-uint DFLT f-dsp-32-u8
1801 ((parse "unsigned8")) () ()
1803 (define-full-operand Dsp-32-u16 "unsigned 16 bit displacement at offset 32 bits" (all-isas)
1804 h-uint DFLT f-dsp-32-u16
1805 ((parse "unsigned16")) () ()
1807 (define-full-operand Dsp-32-u24 "unsigned 24 bit displacement at offset 32 bits" (all-isas)
1808 h-uint DFLT f-dsp-32-u24
1809 ((parse "unsigned24")) () ()
1811 (define-full-operand Dsp-32-u20 "unsigned 20 bit displacement at offset 32 bits" (all-isas)
1812 h-uint DFLT f-dsp-32-u24
1813 ((parse "unsigned20")) () ()
1815 (define-full-operand Dsp-32-s8 "signed 8 bit displacement at offset 32 bits" (all-isas)
1816 h-sint DFLT f-dsp-32-s8
1817 ((parse "signed8")) () ()
1819 (define-full-operand Dsp-32-s16 "signed 16 bit displacement at offset 32 bits" (all-isas)
1820 h-sint DFLT f-dsp-32-s16
1821 ((parse "signed16")) () ()
1823 (define-full-operand Dsp-40-u8 "unsigned 8 bit displacement at offset 40 bits" (all-isas)
1824 h-uint DFLT f-dsp-40-u8
1825 ((parse "unsigned8")) () ()
1827 (define-full-operand Dsp-40-s8 "signed 8 bit displacement at offset 40 bits" (all-isas)
1828 h-uint DFLT f-dsp-40-s8
1829 ((parse "signed8")) () ()
1831 (define-full-operand Dsp-40-u16 "unsigned 16 bit displacement at offset 40 bits" (all-isas)
1832 h-uint DFLT f-dsp-40-u16
1833 ((parse "unsigned16")) () ()
1835 (define-full-operand Dsp-40-s16 "signed 16 bit displacement at offset 40 bits" (all-isas)
1836 h-uint DFLT f-dsp-40-s16
1837 ((parse "signed16")) () ()
1839 (define-full-operand Dsp-40-u24 "unsigned 24 bit displacement at offset 40 bits" (all-isas)
1840 h-uint DFLT f-dsp-40-u24
1841 ((parse "unsigned24")) () ()
1843 (define-full-operand Dsp-48-u8 "unsigned 8 bit displacement at offset 48 bits" (all-isas)
1844 h-uint DFLT f-dsp-48-u8
1845 ((parse "unsigned8")) () ()
1847 (define-full-operand Dsp-48-s8 "signed 8 bit displacement at offset 48 bits" (all-isas)
1848 h-uint DFLT f-dsp-48-s8
1849 ((parse "signed8")) () ()
1851 (define-full-operand Dsp-48-u16 "unsigned 16 bit displacement at offset 48 bits" (all-isas)
1852 h-uint DFLT f-dsp-48-u16
1853 ((parse "unsigned16")) () ()
1855 (define-full-operand Dsp-48-s16 "signed 16 bit displacement at offset 48 bits" (all-isas)
1856 h-uint DFLT f-dsp-48-s16
1857 ((parse "signed16")) () ()
1859 (define-full-operand Dsp-48-u24 "unsigned 24 bit displacement at offset 48 bits" (all-isas)
1860 h-uint DFLT f-dsp-48-u24
1861 ((parse "unsigned24")) () ()
1864 (define-full-operand Imm-8-s4 "signed 4 bit immediate at offset 8 bits" (all-isas)
1865 h-sint DFLT f-imm-8-s4
1866 ((parse "signed4")) () ()
1868 (define-full-operand Imm-sh-8-s4 "signed 4 bit shift immediate at offset 8 bits" (all-isas)
1869 h-shimm DFLT f-imm-8-s4
1872 (define-full-operand Imm-8-QI "signed 8 bit immediate at offset 8 bits" (all-isas)
1873 h-sint DFLT f-dsp-8-s8
1874 ((parse "signed8")) () ()
1876 (define-full-operand Imm-8-HI "signed 16 bit immediate at offset 8 bits" (all-isas)
1877 h-sint DFLT f-dsp-8-s16
1878 ((parse "signed16")) () ()
1880 (define-full-operand Imm-12-s4 "signed 4 bit immediate at offset 12 bits" (all-isas)
1881 h-sint DFLT f-imm-12-s4
1882 ((parse "signed4")) () ()
1884 (define-full-operand Imm-sh-12-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas)
1885 h-shimm DFLT f-imm-12-s4
1888 (define-full-operand Imm-13-u3 "signed 3 bit immediate at offset 13 bits" (all-isas)
1889 h-uint DFLT f-imm-13-u3
1890 ((parse "signed4")) () ()
1892 (define-full-operand Imm-20-s4 "signed 4 bit immediate at offset 20 bits" (all-isas)
1893 h-sint DFLT f-imm-20-s4
1894 ((parse "signed4")) () ()
1896 (define-full-operand Imm-sh-20-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas)
1897 h-shimm DFLT f-imm-20-s4
1900 (define-full-operand Imm-16-QI "signed 8 bit immediate at offset 16 bits" (all-isas)
1901 h-sint DFLT f-dsp-16-s8
1902 ((parse "signed8")) () ()
1904 (define-full-operand Imm-16-HI "signed 16 bit immediate at offset 16 bits" (all-isas)
1905 h-sint DFLT f-dsp-16-s16
1906 ((parse "signed16")) () ()
1908 (define-full-operand Imm-16-SI "signed 32 bit immediate at offset 16 bits" (all-isas)
1909 h-sint DFLT f-dsp-16-s32
1910 ((parse "signed32")) () ()
1912 (define-full-operand Imm-24-QI "signed 8 bit immediate at offset 24 bits" (all-isas)
1913 h-sint DFLT f-dsp-24-s8
1914 ((parse "signed8")) () ()
1916 (define-full-operand Imm-24-HI "signed 16 bit immediate at offset 24 bits" (all-isas)
1917 h-sint DFLT f-dsp-24-s16
1918 ((parse "signed16")) () ()
1920 (define-full-operand Imm-24-SI "signed 32 bit immediate at offset 24 bits" (all-isas)
1921 h-sint DFLT f-dsp-24-s32
1922 ((parse "signed32")) () ()
1924 (define-full-operand Imm-32-QI "signed 8 bit immediate at offset 32 bits" (all-isas)
1925 h-sint DFLT f-dsp-32-s8
1926 ((parse "signed8")) () ()
1928 (define-full-operand Imm-32-SI "signed 32 bit immediate at offset 32 bits" (all-isas)
1929 h-sint DFLT f-dsp-32-s32
1930 ((parse "signed32")) () ()
1932 (define-full-operand Imm-32-HI "signed 16 bit immediate at offset 32 bits" (all-isas)
1933 h-sint DFLT f-dsp-32-s16
1934 ((parse "signed16")) () ()
1936 (define-full-operand Imm-40-QI "signed 8 bit immediate at offset 40 bits" (all-isas)
1937 h-sint DFLT f-dsp-40-s8
1938 ((parse "signed8")) () ()
1940 (define-full-operand Imm-40-HI "signed 16 bit immediate at offset 40 bits" (all-isas)
1941 h-sint DFLT f-dsp-40-s16
1942 ((parse "signed16")) () ()
1944 (define-full-operand Imm-40-SI "signed 32 bit immediate at offset 40 bits" (all-isas)
1945 h-sint DFLT f-dsp-40-s32
1946 ((parse "signed32")) () ()
1948 (define-full-operand Imm-48-QI "signed 8 bit immediate at offset 48 bits" (all-isas)
1949 h-sint DFLT f-dsp-48-s8
1950 ((parse "signed8")) () ()
1952 (define-full-operand Imm-48-HI "signed 16 bit immediate at offset 48 bits" (all-isas)
1953 h-sint DFLT f-dsp-48-s16
1954 ((parse "signed16")) () ()
1956 (define-full-operand Imm-48-SI "signed 32 bit immediate at offset 48 bits" (all-isas)
1957 h-sint DFLT f-dsp-48-s32
1958 ((parse "signed32")) () ()
1960 (define-full-operand Imm-56-QI "signed 8 bit immediate at offset 56 bits" (all-isas)
1961 h-sint DFLT f-dsp-56-s8
1962 ((parse "signed8")) () ()
1964 (define-full-operand Imm-56-HI "signed 16 bit immediate at offset 56 bits" (all-isas)
1965 h-sint DFLT f-dsp-56-s16
1966 ((parse "signed16")) () ()
1968 (define-full-operand Imm-64-HI "signed 16 bit immediate at offset 64 bits" (all-isas)
1969 h-sint DFLT f-dsp-64-s16
1970 ((parse "signed16")) () ()
1972 (define-full-operand Imm1-S "signed 1 bit immediate for short format binary insns" (m32c-isa)
1973 h-sint DFLT f-imm1-S
1974 ((parse "imm1_S")) () ()
1976 (define-full-operand Imm3-S "signed 3 bit immediate for short format binary insns" (m32c-isa)
1977 h-sint DFLT f-imm3-S
1978 ((parse "imm3_S")) () ()
1981 ;-------------------------------------------------------------
1983 ;-------------------------------------------------------------
1985 (define-full-operand Bitno16R "bit number for indexing registers" (m16c-isa)
1986 h-uint DFLT f-dsp-16-u8
1987 ((parse "Bitno16R")) () ()
1989 (dnop Bitno32Prefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-prefixed)
1990 (dnop Bitno32Unprefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-unprefixed)
1992 (define-full-operand BitBase16-16-u8 "unsigned bit,base:8 at offset 16for m16c" (m16c-isa)
1993 h-uint DFLT f-dsp-16-u8
1994 ((parse "unsigned_bitbase8") (print "unsigned_bitbase")) () ()
1996 (define-full-operand BitBase16-16-s8 "signed bit,base:8 at offset 16for m16c" (m16c-isa)
1997 h-uint DFLT f-dsp-16-s8
1998 ((parse "signed_bitbase8") (print "signed_bitbase")) () ()
2000 (define-full-operand BitBase16-16-u16 "unsigned bit,base:16 at offset 16 for m16c" (m16c-isa)
2001 h-uint DFLT f-dsp-16-u16
2002 ((parse "unsigned_bitbase16") (print "unsigned_bitbase")) () ()
2004 (define-full-operand BitBase16-8-u11-S "signed bit,base:11 at offset 16 for m16c" (m16c-isa)
2005 h-sint DFLT f-bitbase16-u11-S
2006 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2009 (define-full-operand BitBase32-16-u11-Unprefixed "unsigned bit,base:11 at offset 16 for m32c" (m32c-isa)
2010 h-uint DFLT f-bitbase32-16-u11-unprefixed
2011 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2013 (define-full-operand BitBase32-16-s11-Unprefixed "signed bit,base:11 at offset 16 for m32c" (m32c-isa)
2014 h-sint DFLT f-bitbase32-16-s11-unprefixed
2015 ((parse "signed_bitbase11") (print "signed_bitbase")) () ()
2017 (define-full-operand BitBase32-16-u19-Unprefixed "unsigned bit,base:19 at offset 16 for m32c" (m32c-isa)
2018 h-uint DFLT f-bitbase32-16-u19-unprefixed
2019 ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () ()
2021 (define-full-operand BitBase32-16-s19-Unprefixed "signed bit,base:19 at offset 16 for m32c" (m32c-isa)
2022 h-sint DFLT f-bitbase32-16-s19-unprefixed
2023 ((parse "signed_bitbase19") (print "signed_bitbase")) () ()
2025 (define-full-operand BitBase32-16-u27-Unprefixed "unsigned bit,base:27 at offset 16 for m32c" (m32c-isa)
2026 h-uint DFLT f-bitbase32-16-u27-unprefixed
2027 ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () ()
2029 (define-full-operand BitBase32-24-u11-Prefixed "unsigned bit,base:11 at offset 24 for m32c" (m32c-isa)
2030 h-uint DFLT f-bitbase32-24-u11-prefixed
2031 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2033 (define-full-operand BitBase32-24-s11-Prefixed "signed bit,base:11 at offset 24 for m32c" (m32c-isa)
2034 h-sint DFLT f-bitbase32-24-s11-prefixed
2035 ((parse "signed_bitbase11") (print "signed_bitbase")) () ()
2037 (define-full-operand BitBase32-24-u19-Prefixed "unsigned bit,base:19 at offset 24 for m32c" (m32c-isa)
2038 h-uint DFLT f-bitbase32-24-u19-prefixed
2039 ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () ()
2041 (define-full-operand BitBase32-24-s19-Prefixed "signed bit,base:19 at offset 24 for m32c" (m32c-isa)
2042 h-sint DFLT f-bitbase32-24-s19-prefixed
2043 ((parse "signed_bitbase19") (print "signed_bitbase")) () ()
2045 (define-full-operand BitBase32-24-u27-Prefixed "unsigned bit,base:27 at offset 24 for m32c" (m32c-isa)
2046 h-uint DFLT f-bitbase32-24-u27-prefixed
2047 ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () ()
2049 ;-------------------------------------------------------------
2051 ;-------------------------------------------------------------
2053 (dnop Lab-5-3 "3 bit label" (all-isas) h-iaddr f-lab-5-3)
2054 (dnop Lab32-jmp-s "3 bit label" (all-isas) h-iaddr f-lab32-jmp-s)
2055 (dnop Lab-8-8 "8 bit label" (all-isas) h-iaddr f-lab-8-8)
2056 (dnop Lab-8-16 "16 bit label" (all-isas) h-iaddr f-lab-8-16)
2057 (dnop Lab-8-24 "24 bit label" (all-isas) h-iaddr f-lab-8-24)
2058 (dnop Lab-16-8 "8 bit label" (all-isas) h-iaddr f-lab-16-8)
2059 (dnop Lab-24-8 "8 bit label" (all-isas) h-iaddr f-lab-24-8)
2060 (dnop Lab-32-8 "8 bit label" (all-isas) h-iaddr f-lab-32-8)
2061 (dnop Lab-40-8 "8 bit label" (all-isas) h-iaddr f-lab-40-8)
2063 ;-------------------------------------------------------------
2064 ; Condition code bits
2065 ;-------------------------------------------------------------
2067 (dnop sbit "negative bit" (SEM-ONLY all-isas) h-sbit f-nil)
2068 (dnop obit "overflow bit" (SEM-ONLY all-isas) h-obit f-nil)
2069 (dnop zbit "zero bit" (SEM-ONLY all-isas) h-zbit f-nil)
2070 (dnop cbit "carry bit" (SEM-ONLY all-isas) h-cbit f-nil)
2071 (dnop ubit "stack ptr select bit" (SEM-ONLY all-isas) h-ubit f-nil)
2072 (dnop ibit "interrupt enable bit" (SEM-ONLY all-isas) h-ibit f-nil)
2073 (dnop bbit "reg bank select bit" (SEM-ONLY all-isas) h-bbit f-nil)
2074 (dnop dbit "debug bit" (SEM-ONLY all-isas) h-dbit f-nil)
2076 ;-------------------------------------------------------------
2077 ; Condition operands
2078 ;-------------------------------------------------------------
2080 (define-pmacro (cond-operand mach offset)
2081 (dnop (.sym cond mach - offset) "condition" ((.sym m mach c-isa)) (.sym h-cond mach) (.sym f-dsp- offset -u8))
2084 (cond-operand 16 16)
2085 (cond-operand 16 24)
2086 (cond-operand 16 32)
2087 (cond-operand 32 16)
2088 (cond-operand 32 24)
2089 (cond-operand 32 32)
2090 (cond-operand 32 40)
2092 (dnop cond16c "condition" (m16c-isa) h-cond16c f-cond16)
2093 (dnop cond16j "condition" (m16c-isa) h-cond16j f-cond16)
2094 (dnop cond16j5 "condition" (m16c-isa) h-cond16j-5 f-cond16j-5)
2095 (dnop cond32 "condition" (m32c-isa) h-cond32 f-cond32)
2096 (dnop cond32j "condition" (m32c-isa) h-cond32 f-cond32j)
2097 (dnop sccond32 "scCND condition" (m32c-isa) h-cond32 f-cond16)
2098 (dnop flags16 "flags" (m16c-isa) h-flags f-9-3)
2099 (dnop flags32 "flags" (m32c-isa) h-flags f-13-3)
2100 (dnop cr16 "control" (m16c-isa) h-cr-16 f-9-3)
2101 (dnop cr1-Unprefixed-32 "control" (m32c-isa) h-cr1-32 f-13-3)
2102 (dnop cr1-Prefixed-32 "control" (m32c-isa) h-cr1-32 f-21-3)
2103 (dnop cr2-32 "control" (m32c-isa) h-cr2-32 f-13-3)
2104 (dnop cr3-Unprefixed-32 "control" (m32c-isa) h-cr3-32 f-13-3)
2105 (dnop cr3-Prefixed-32 "control" (m32c-isa) h-cr3-32 f-21-3)
2107 ;-------------------------------------------------------------
2109 ;-------------------------------------------------------------
2111 (define-full-operand Z "Suffix for zero format insns" (all-isas)
2113 ((parse "Z") (print "Z")) () ()
2115 (define-full-operand S "Suffix for short format insns" (all-isas)
2117 ((parse "S") (print "S")) () ()
2119 (define-full-operand Q "Suffix for quick format insns" (all-isas)
2121 ((parse "Q") (print "Q")) () ()
2123 (define-full-operand G "Suffix for general format insns" (all-isas)
2125 ((parse "G") (print "G")) () ()
2127 (define-full-operand X "Empty suffix" (all-isas)
2129 ((parse "X") (print "X")) () ()
2131 (define-full-operand size "any size specifier" (all-isas)
2133 ((parse "size") (print "size")) () ()
2135 ;-------------------------------------------------------------
2137 ;-------------------------------------------------------------
2139 (dnop BitIndex "Bit Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-bit-index f-nil)
2140 (dnop SrcIndex "Source Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-src-index f-nil)
2141 (dnop DstIndex "Destination Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-dst-index f-nil)
2142 (dnop NoRemainder "Place holder for when the remainder is not kept" (SEM-ONLY MACH32 m32c-isa) h-none f-nil)
2144 ;=============================================================
2147 ; Memory reference macros that clip addresses appropriately. Refer to
2148 ; memory at ADDRESS in MODE, clipped appropriately for either the m16c
2150 (define-pmacro (mem16 mode address)
2151 (mem mode (and #xffff address)))
2153 (define-pmacro (mem32 mode address)
2154 (mem mode (and #xffffff address)))
2156 ; Like mem16 and mem32, but takes MACH as a parameter. MACH must be
2158 (define-pmacro (mem-mach mach mode address)
2159 ((.sym mem mach) mode address))
2161 ;-------------------------------------------------------------
2163 ;-------------------------------------------------------------
2165 ;-------------------------------------------------------------
2167 (define-pmacro (src16-Rn-direct-operand xmode)
2169 (define-derived-operand
2170 (name (.sym src16-Rn-direct- xmode))
2171 (comment (.str "m16c Rn direct source " xmode))
2172 (attrs (machine 16))
2174 (args ((.sym Src16Rn xmode)))
2175 (syntax (.str "$Src16Rn" xmode))
2177 (encoding (+ (f-8-2 0) (.sym Src16Rn xmode)))
2178 (ifield-assertion (eq f-8-2 0))
2179 (getter (trunc xmode (.sym Src16Rn xmode)))
2180 (setter (set (.sym Src16Rn xmode) newval))
2184 (src16-Rn-direct-operand QI)
2185 (src16-Rn-direct-operand HI)
2187 (define-pmacro (src32-Rn-direct-operand group base xmode)
2189 (define-derived-operand
2190 (name (.sym src32-Rn-direct- group - xmode))
2191 (comment (.str "m32c Rn direct source " xmode))
2192 (attrs (machine 32))
2194 (args ((.sym Src32Rn group xmode)))
2195 (syntax (.str "$Src32Rn" group xmode))
2196 (base-ifield (.sym f- base -11))
2197 (encoding (+ ((.sym f- base -3) 4) (.sym Src32Rn group xmode)))
2198 (ifield-assertion (eq (.sym f- base -3) 4))
2199 (getter (trunc xmode (.sym Src32Rn group xmode)))
2200 (setter (set (.sym Src32Rn group xmode) newval))
2205 (src32-Rn-direct-operand Unprefixed 1 QI)
2206 (src32-Rn-direct-operand Prefixed 9 QI)
2207 (src32-Rn-direct-operand Unprefixed 1 HI)
2208 (src32-Rn-direct-operand Prefixed 9 HI)
2209 (src32-Rn-direct-operand Unprefixed 1 SI)
2210 (src32-Rn-direct-operand Prefixed 9 SI)
2212 ;-------------------------------------------------------------
2214 ;-------------------------------------------------------------
2216 (define-pmacro (src16-An-direct-operand xmode)
2218 (define-derived-operand
2219 (name (.sym src16-An-direct- xmode))
2220 (comment (.str "m16c An direct destination " xmode))
2221 (attrs (machine 16))
2223 (args ((.sym Src16An xmode)))
2224 (syntax (.str "$Src16An" xmode))
2226 (encoding (+ (f-8-2 1) (f-10-1 0) (.sym Src16An xmode)))
2227 (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 0)))
2228 (getter (trunc xmode (.sym Src16An xmode)))
2229 (setter (set (.sym Src16An xmode) newval))
2233 (src16-An-direct-operand QI)
2234 (src16-An-direct-operand HI)
2236 (define-pmacro (src32-An-direct-operand group base1 base2 xmode)
2238 (define-derived-operand
2239 (name (.sym src32-An-direct- group - xmode))
2240 (comment (.str "m32c An direct destination " xmode))
2241 (attrs (machine 32))
2243 (args ((.sym Src32An group xmode)))
2244 (syntax (.str "$Src32An" group xmode))
2245 (base-ifield (.sym f- base1 -11))
2246 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Src32An group xmode)))
2247 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
2248 (getter (trunc xmode (.sym Src32An group xmode)))
2249 (setter (set (.sym Src32An group xmode) newval))
2254 (src32-An-direct-operand Unprefixed 1 10 QI)
2255 (src32-An-direct-operand Unprefixed 1 10 HI)
2256 (src32-An-direct-operand Unprefixed 1 10 SI)
2257 (src32-An-direct-operand Prefixed 9 18 QI)
2258 (src32-An-direct-operand Prefixed 9 18 HI)
2259 (src32-An-direct-operand Prefixed 9 18 SI)
2261 ;-------------------------------------------------------------
2263 ;-------------------------------------------------------------
2265 (define-pmacro (src16-An-indirect-operand xmode)
2267 (define-derived-operand
2268 (name (.sym src16-An-indirect- xmode))
2269 (comment (.str "m16c An indirect destination " xmode))
2270 (attrs (machine 16))
2273 (syntax "[$Src16An]")
2275 (encoding (+ (f-8-2 1) (f-10-1 1) Src16An))
2276 (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 1)))
2277 (getter (mem16 xmode Src16An))
2278 (setter (set (mem16 xmode Src16An) newval))
2282 (src16-An-indirect-operand QI)
2283 (src16-An-indirect-operand HI)
2285 (define-pmacro (src32-An-indirect-operand group base1 base2 xmode)
2287 (define-derived-operand
2288 (name (.sym src32-An-indirect- group - xmode))
2289 (comment (.str "m32c An indirect destination " xmode))
2290 (attrs (machine 32))
2292 (args ((.sym Src32An group)))
2293 (syntax (.str "[$Src32An" group "]"))
2294 (base-ifield (.sym f- base1 -11))
2295 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Src32An group)))
2296 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
2297 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group)
2299 (setter (c-call DFLT (.str "operand_setter_" xmode) newval
2300 (.sym Src32An group) (const 0)))
2301 ; (getter (mem32 xmode (.sym Src32An group)))
2302 ; (setter (set (mem32 xmode (.sym Src32An group)) newval))
2307 (src32-An-indirect-operand Unprefixed 1 10 QI)
2308 (src32-An-indirect-operand Unprefixed 1 10 HI)
2309 (src32-An-indirect-operand Unprefixed 1 10 SI)
2310 (src32-An-indirect-operand Prefixed 9 18 QI)
2311 (src32-An-indirect-operand Prefixed 9 18 HI)
2312 (src32-An-indirect-operand Prefixed 9 18 SI)
2314 ;-------------------------------------------------------------
2316 ;-------------------------------------------------------------
2318 (define-pmacro (src16-relative-operand xmode)
2320 (define-derived-operand
2321 (name (.sym src16-16-8-SB-relative- xmode))
2322 (comment (.str "m16c dsp:8[sb] relative destination " xmode))
2323 (attrs (machine 16))
2326 (syntax "${Dsp-16-u8}[sb]")
2328 (encoding (+ (f-8-4 #xA) Dsp-16-u8))
2329 (ifield-assertion (eq f-8-4 #xA))
2330 (getter (mem16 xmode (add Dsp-16-u8 (reg h-sb))))
2331 (setter (set (mem16 xmode (add Dsp-16-u8 (reg h-sb))) newval))
2333 (define-derived-operand
2334 (name (.sym src16-16-16-SB-relative- xmode))
2335 (comment (.str "m16c dsp:16[sb] relative destination " xmode))
2336 (attrs (machine 16))
2339 (syntax "${Dsp-16-u16}[sb]")
2341 (encoding (+ (f-8-4 #xE) Dsp-16-u16))
2342 (ifield-assertion (eq f-8-4 #xE))
2343 (getter (mem16 xmode (add Dsp-16-u16 (reg h-sb))))
2344 (setter (set (mem16 xmode (add Dsp-16-u16 (reg h-sb))) newval))
2346 (define-derived-operand
2347 (name (.sym src16-16-8-FB-relative- xmode))
2348 (comment (.str "m16c dsp:8[fb] relative destination " xmode))
2349 (attrs (machine 16))
2352 (syntax "${Dsp-16-s8}[fb]")
2354 (encoding (+ (f-8-4 #xB) Dsp-16-s8))
2355 (ifield-assertion (eq f-8-4 #xB))
2356 (getter (mem16 xmode (add Dsp-16-s8 (reg h-fb))))
2357 (setter (set (mem16 xmode (add Dsp-16-s8 (reg h-fb))) newval))
2359 (define-derived-operand
2360 (name (.sym src16-16-8-An-relative- xmode))
2361 (comment (.str "m16c dsp:8[An] relative destination " xmode))
2362 (attrs (machine 16))
2364 (args (Src16An Dsp-16-u8))
2365 (syntax "${Dsp-16-u8}[$Src16An]")
2367 (encoding (+ (f-8-2 2) (f-10-1 0) Dsp-16-u8 Src16An))
2368 (ifield-assertion (andif (eq f-8-2 2) (eq f-10-1 0)))
2369 (getter (mem16 xmode (add Dsp-16-u8 Src16An)))
2370 (setter (set (mem16 xmode (add Dsp-16-u8 Src16An)) newval))
2372 (define-derived-operand
2373 (name (.sym src16-16-16-An-relative- xmode))
2374 (comment (.str "m16c dsp:16[An] relative destination " xmode))
2375 (attrs (machine 16))
2377 (args (Src16An Dsp-16-u16))
2378 (syntax "${Dsp-16-u16}[$Src16An]")
2380 (encoding (+ (f-8-2 3) (f-10-1 0) Dsp-16-u16 Src16An))
2381 (ifield-assertion (andif (eq f-8-2 3) (eq f-10-1 0)))
2382 (getter (mem16 xmode (add Dsp-16-u16 Src16An)))
2383 (setter (set (mem16 xmode (add Dsp-16-u16 Src16An)) newval))
2388 (src16-relative-operand QI)
2389 (src16-relative-operand HI)
2391 (define-pmacro (src32-relative-operand offset group base1 base2 xmode)
2393 (define-derived-operand
2394 (name (.sym src32- offset -8-SB-relative- group - xmode))
2395 (comment (.str "m32c dsp:8[sb] relative destination " xmode))
2396 (attrs (machine 32))
2398 (args ((.sym Dsp- offset -u8)))
2399 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
2400 (base-ifield (.sym f- base1 -11))
2401 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8)))
2402 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
2403 (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u8)))
2404 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u8)))
2405 ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb))))
2406 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
2408 (define-derived-operand
2409 (name (.sym src32- offset -16-SB-relative- group - xmode))
2410 (comment (.str "m32c dsp:16[sb] relative destination " xmode))
2411 (attrs (machine 32))
2413 (args ((.sym Dsp- offset -u16)))
2414 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
2415 (base-ifield (.sym f- base1 -11))
2416 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16)))
2417 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
2418 (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u16)))
2419 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u16)))
2420 ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb))))
2421 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
2423 (define-derived-operand
2424 (name (.sym src32- offset -8-FB-relative- group - xmode))
2425 (comment (.str "m32c dsp:8[fb] relative destination " xmode))
2426 (attrs (machine 32))
2428 (args ((.sym Dsp- offset -s8)))
2429 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
2430 (base-ifield (.sym f- base1 -11))
2431 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8)))
2432 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
2433 (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s8)))
2434 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s8)))
2435 ; (getter (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb))))
2436 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
2438 (define-derived-operand
2439 (name (.sym src32- offset -16-FB-relative- group - xmode))
2440 (comment (.str "m32c dsp:16[fb] relative destination " xmode))
2441 (attrs (machine 32))
2443 (args ((.sym Dsp- offset -s16)))
2444 (syntax (.str "${Dsp-" offset "-s16}[fb]"))
2445 (base-ifield (.sym f- base1 -11))
2446 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16)))
2447 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
2448 (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s16)))
2449 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s16)))
2450 ; (getter (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb))))
2451 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval))
2453 (define-derived-operand
2454 (name (.sym src32- offset -8-An-relative- group - xmode))
2455 (comment (.str "m32c dsp:8[An] relative destination " xmode))
2456 (attrs (machine 32))
2458 (args ((.sym Src32An group) (.sym Dsp- offset -u8)))
2459 (syntax (.str "${Dsp-" offset "-u8}[$Src32An" group "]"))
2460 (base-ifield (.sym f- base1 -11))
2461 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Src32An group)))
2462 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
2463 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u8)))
2464 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u8)))
2465 ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group))))
2466 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group))) newval))
2468 (define-derived-operand
2469 (name (.sym src32- offset -16-An-relative- group - xmode))
2470 (comment (.str "m32c dsp:16[An] relative destination " xmode))
2471 (attrs (machine 32))
2473 (args ((.sym Src32An group) (.sym Dsp- offset -u16)))
2474 (syntax (.str "${Dsp-" offset "-u16}[$Src32An" group "]"))
2475 (base-ifield (.sym f- base1 -11))
2476 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Src32An group)))
2477 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
2478 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u16)))
2479 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u16)))
2480 ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group))))
2481 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group))) newval))
2483 (define-derived-operand
2484 (name (.sym src32- offset -24-An-relative- group - xmode))
2485 (comment (.str "m32c dsp:16[An] relative destination " xmode))
2486 (attrs (machine 32))
2488 (args ((.sym Src32An group) (.sym Dsp- offset -u24)))
2489 (syntax (.str "${Dsp-" offset "-u24}[$Src32An" group "]"))
2490 (base-ifield (.sym f- base1 -11))
2491 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Src32An group)))
2492 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
2493 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u24) ))
2494 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u24)))
2495 ; (getter (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group))))
2496 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group))) newval))
2501 (src32-relative-operand 16 Unprefixed 1 10 QI)
2502 (src32-relative-operand 16 Unprefixed 1 10 HI)
2503 (src32-relative-operand 16 Unprefixed 1 10 SI)
2504 (src32-relative-operand 24 Prefixed 9 18 QI)
2505 (src32-relative-operand 24 Prefixed 9 18 HI)
2506 (src32-relative-operand 24 Prefixed 9 18 SI)
2508 ;-------------------------------------------------------------
2510 ;-------------------------------------------------------------
2512 (define-pmacro (src16-absolute xmode)
2514 (define-derived-operand
2515 (name (.sym src16-16-16-absolute- xmode))
2516 (comment (.str "m16c absolute address " xmode))
2517 (attrs (machine 16))
2520 (syntax (.str "${Dsp-16-u16}"))
2522 (encoding (+ (f-8-4 #xF) Dsp-16-u16))
2523 (ifield-assertion (eq f-8-4 #xF))
2524 (getter (mem16 xmode Dsp-16-u16))
2525 (setter (set (mem16 xmode Dsp-16-u16) newval))
2533 (define-pmacro (src32-absolute offset group base1 base2 xmode)
2535 (define-derived-operand
2536 (name (.sym src32- offset -16-absolute- group - xmode))
2537 (comment (.str "m32c absolute address " xmode))
2538 (attrs (machine 32))
2540 (args ((.sym Dsp- offset -u16)))
2541 (syntax (.str "${Dsp-" offset "-u16}"))
2542 (base-ifield (.sym f- base1 -11))
2543 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
2544 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
2545 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u16)))
2546 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u16)))
2547 ; (getter (mem32 xmode (.sym Dsp- offset -u16)))
2548 ; (setter (set (mem32 xmode (.sym Dsp- offset -u16)) newval))
2550 (define-derived-operand
2551 (name (.sym src32- offset -24-absolute- group - xmode))
2552 (comment (.str "m32c absolute address " xmode))
2553 (attrs (machine 32))
2555 (args ((.sym Dsp- offset -u24)))
2556 (syntax (.str "${Dsp-" offset "-u24}"))
2557 (base-ifield (.sym f- base1 -11))
2558 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
2559 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
2560 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u24)))
2561 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u24)))
2562 ; (getter (mem32 xmode (.sym Dsp- offset -u24)))
2563 ; (setter (set (mem32 xmode (.sym Dsp- offset -u24)) newval))
2568 (src32-absolute 16 Unprefixed 1 10 QI)
2569 (src32-absolute 16 Unprefixed 1 10 HI)
2570 (src32-absolute 16 Unprefixed 1 10 SI)
2571 (src32-absolute 24 Prefixed 9 18 QI)
2572 (src32-absolute 24 Prefixed 9 18 HI)
2573 (src32-absolute 24 Prefixed 9 18 SI)
2575 ;-------------------------------------------------------------
2576 ; An indirect indirect
2578 ; Double indirect addressing uses the lower 3 bytes of the value stored
2579 ; at the address referenced by 'op' as the effective address.
2580 ;-------------------------------------------------------------
2582 (define-pmacro (indirect-addr op) (and USI (mem32 USI op) #x00ffffff))
2584 ; (define-pmacro (src-An-indirect-indirect-operand xmode)
2585 ; (define-derived-operand
2586 ; (name (.sym src32-An-indirect-indirect- xmode))
2587 ; (comment (.str "m32c An indirect indirect destination " xmode))
2588 ; (attrs (machine 32))
2590 ; (args (Src32AnPrefixed))
2591 ; (syntax (.str "[[$Src32AnPrefixed]]"))
2592 ; (base-ifield f-9-11)
2593 ; (encoding (+ (f-9-3 0) (f-18-1 0) Src32AnPrefixed))
2594 ; (ifield-assertion (andif (eq f-9-3 0) (eq f-18-1 0)))
2595 ; (getter (mem32 xmode (indirect-addr Src32AnPrefixed)))
2596 ; (setter (set (mem32 xmode (indirect-addr Src32AnPrefixed)) newval))
2600 ; (src-An-indirect-indirect-operand QI)
2601 ; (src-An-indirect-indirect-operand HI)
2602 ; (src-An-indirect-indirect-operand SI)
2604 ;-------------------------------------------------------------
2606 ;-------------------------------------------------------------
2608 (define-pmacro (src-relative-indirect-operand xmode)
2610 ; (define-derived-operand
2611 ; (name (.sym src32-24-8-SB-relative-indirect- xmode))
2612 ; (comment (.str "m32c dsp:8[sb] relative source " xmode))
2613 ; (attrs (machine 32))
2615 ; (args (Dsp-24-u8))
2616 ; (syntax "[${Dsp-24-u8}[sb]]")
2617 ; (base-ifield f-9-11)
2618 ; (encoding (+ (f-9-3 1) (f-18-2 2) Dsp-24-u8))
2619 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 2)))
2620 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb)))))
2621 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb)))) newval))
2623 ; (define-derived-operand
2624 ; (name (.sym src32-24-16-SB-relative-indirect- xmode))
2625 ; (comment (.str "m32c dsp:16[sb] relative source " xmode))
2626 ; (attrs (machine 32))
2628 ; (args (Dsp-24-u16))
2629 ; (syntax "[${Dsp-24-u16}[sb]]")
2630 ; (base-ifield f-9-11)
2631 ; (encoding (+ (f-9-3 2) (f-18-2 2) Dsp-24-u16))
2632 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 2)))
2633 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb)))))
2634 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb)))) newval))
2636 ; (define-derived-operand
2637 ; (name (.sym src32-24-8-FB-relative-indirect- xmode))
2638 ; (comment (.str "m32c dsp:8[fb] relative source " xmode))
2639 ; (attrs (machine 32))
2641 ; (args (Dsp-24-s8))
2642 ; (syntax "[${Dsp-24-s8}[fb]]")
2643 ; (base-ifield f-9-11)
2644 ; (encoding (+ (f-9-3 1) (f-18-2 3) Dsp-24-s8))
2645 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 3)))
2646 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb)))))
2647 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb)))) newval))
2649 ; (define-derived-operand
2650 ; (name (.sym src32-24-16-FB-relative-indirect- xmode))
2651 ; (comment (.str "m32c dsp:16[fb] relative source " xmode))
2652 ; (attrs (machine 32))
2654 ; (args (Dsp-24-s16))
2655 ; (syntax "[${Dsp-24-s16}[fb]]")
2656 ; (base-ifield f-9-11)
2657 ; (encoding (+ (f-9-3 2) (f-18-2 3) Dsp-24-s16))
2658 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 3)))
2659 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb)))))
2660 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb)))) newval))
2662 ; (define-derived-operand
2663 ; (name (.sym src32-24-8-An-relative-indirect- xmode))
2664 ; (comment (.str "m32c dsp:8[An] relative indirect source " xmode))
2665 ; (attrs (machine 32))
2667 ; (args (Src32AnPrefixed Dsp-24-u8))
2668 ; (syntax "[${Dsp-24-u8}[$Src32AnPrefixed]]")
2669 ; (base-ifield f-9-11)
2670 ; (encoding (+ (f-9-3 1) (f-18-1 0) Dsp-24-u8 Src32AnPrefixed))
2671 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-1 0)))
2672 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed))))
2673 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed))) newval))
2675 ; (define-derived-operand
2676 ; (name (.sym src32-24-16-An-relative-indirect- xmode))
2677 ; (comment (.str "m32c dsp:16[An] relative source " xmode))
2678 ; (attrs (machine 32))
2680 ; (args (Src32AnPrefixed Dsp-24-u16))
2681 ; (syntax "[${Dsp-24-u16}[$Src32AnPrefixed]]")
2682 ; (base-ifield f-9-11)
2683 ; (encoding (+ (f-9-3 2) (f-18-1 0) Dsp-24-u16 Src32AnPrefixed))
2684 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-1 0)))
2685 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed))))
2686 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed))) newval))
2688 ; (define-derived-operand
2689 ; (name (.sym src32-24-24-An-relative-indirect- xmode))
2690 ; (comment (.str "m32c dsp:24[An] relative source " xmode))
2691 ; (attrs (machine 32))
2693 ; (args (Src32AnPrefixed Dsp-24-u24))
2694 ; (syntax "[${Dsp-24-u24}[$Src32AnPrefixed]]")
2695 ; (base-ifield f-9-11)
2696 ; (encoding (+ (f-9-3 3) (f-18-1 0) Dsp-24-u24 Src32AnPrefixed))
2697 ; (ifield-assertion (andif (eq f-9-3 3) (eq f-18-1 0)))
2698 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed))))
2699 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed))) newval))
2704 ; (src-relative-indirect-operand QI)
2705 ; (src-relative-indirect-operand HI)
2706 ; (src-relative-indirect-operand SI)
2708 ;-------------------------------------------------------------
2709 ; Absolute Indirect address
2710 ;-------------------------------------------------------------
2712 (define-pmacro (src32-absolute-indirect offset base1 base2 xmode)
2714 ; (define-derived-operand
2715 ; (name (.sym src32- offset -16-absolute-indirect-derived- xmode))
2716 ; (comment (.str "m32c absolute indirect address " xmode))
2717 ; (attrs (machine 32))
2719 ; (args ((.sym Dsp- offset -u16)))
2720 ; (syntax (.str "[${Dsp-" offset "-u16}]"))
2721 ; (base-ifield (.sym f- base1 -11))
2722 ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
2723 ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
2724 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))))
2725 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval))
2727 ; (define-derived-operand
2728 ; (name (.sym src32- offset -24-absolute-indirect-derived- xmode))
2729 ; (comment (.str "m32c absolute indirect address " xmode))
2730 ; (attrs (machine 32))
2732 ; (args ((.sym Dsp- offset -u24)))
2733 ; (syntax (.str "[${Dsp-" offset "-u24}]"))
2734 ; (base-ifield (.sym f- base1 -11))
2735 ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
2736 ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
2737 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))))
2738 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval))
2743 (src32-absolute-indirect 24 9 18 QI)
2744 (src32-absolute-indirect 24 9 18 HI)
2745 (src32-absolute-indirect 24 9 18 SI)
2747 ;-------------------------------------------------------------
2748 ; Register relative source operands for short format insns
2749 ;-------------------------------------------------------------
2751 (define-pmacro (src-2-S-operands mach xmode base opc1 opc2 opc3)
2753 (define-derived-operand
2754 (name (.sym src mach -2-S-8-SB-relative- xmode))
2755 (comment (.str "m" mach "c SB relative address"))
2756 (attrs (machine mach))
2759 (syntax "${Dsp-8-u8}[sb]")
2760 (base-ifield (.sym f- base -2))
2761 (encoding (+ ((.sym f- base -2) opc1) Dsp-8-u8))
2762 (ifield-assertion (eq (.sym f- base -2) opc1))
2763 (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8))
2764 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8))
2765 ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8))))
2766 ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8))) newval))
2768 (define-derived-operand
2769 (name (.sym src mach -2-S-8-FB-relative- xmode))
2770 (comment (.str "m" mach "c FB relative address"))
2771 (attrs (machine mach))
2774 (syntax "${Dsp-8-s8}[fb]")
2775 (base-ifield (.sym f- base -2))
2776 (encoding (+ ((.sym f- base -2) opc2) Dsp-8-s8))
2777 (ifield-assertion (eq (.sym f- base -2) opc2))
2778 (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8))
2779 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8))
2780 ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8))))
2781 ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8))) newval))
2783 (define-derived-operand
2784 (name (.sym src mach -2-S-16-absolute- xmode))
2785 (comment (.str "m" mach "c absolute address"))
2786 (attrs (machine mach))
2789 (syntax "${Dsp-8-u16}")
2790 (base-ifield (.sym f- base -2))
2791 (encoding (+ ((.sym f- base -2) opc3) Dsp-8-u16))
2792 (ifield-assertion (eq (.sym f- base -2) opc3))
2793 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16))
2794 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16))
2795 ; (getter (mem-mach mach xmode Dsp-8-u16))
2796 ; (setter (set (mem-mach mach xmode Dsp-8-u16) newval))
2801 (src-2-S-operands 16 QI 6 1 2 3)
2802 (src-2-S-operands 32 QI 2 2 3 1)
2803 (src-2-S-operands 32 HI 2 2 3 1)
2805 ;=============================================================
2807 ;-------------------------------------------------------------
2809 ;-------------------------------------------------------------
2811 ;-------------------------------------------------------------
2813 (define-pmacro (dst16-Rn-direct-operand xmode)
2815 (define-derived-operand
2816 (name (.sym dst16-Rn-direct- xmode))
2817 (comment (.str "m16c Rn direct destination " xmode))
2818 (attrs (machine 16))
2820 (args ((.sym Dst16Rn xmode)))
2821 (syntax (.str "$Dst16Rn" xmode))
2822 (base-ifield f-12-4)
2823 (encoding (+ (f-12-2 0) (.sym Dst16Rn xmode)))
2824 (ifield-assertion (eq f-12-2 0))
2825 (getter (trunc xmode (.sym Dst16Rn xmode)))
2826 (setter (set (.sym Dst16Rn xmode) newval))
2831 (dst16-Rn-direct-operand QI)
2832 (dst16-Rn-direct-operand HI)
2833 (dst16-Rn-direct-operand SI)
2835 (define-derived-operand
2836 (name dst16-Rn-direct-Ext-QI)
2837 (comment "m16c Rn direct destination QI")
2838 (attrs (machine 16))
2840 (args (Dst16RnExtQI))
2841 (syntax "$Dst16RnExtQI")
2842 (base-ifield f-12-4)
2843 (encoding (+ (f-12-2 0) Dst16RnExtQI (f-15-1 0)))
2844 (ifield-assertion (andif (eq f-12-2 0) (eq f-15-1 0)))
2845 (getter (trunc QI (.sym Dst16RnExtQI)))
2846 (setter (set Dst16RnExtQI newval))
2849 (define-pmacro (dst32-Rn-direct-operand group base xmode)
2851 (define-derived-operand
2852 (name (.sym dst32-Rn-direct- group - xmode))
2853 (comment (.str "m32c Rn direct destination " xmode))
2854 (attrs (machine 32))
2856 (args ((.sym Dst32Rn group xmode)))
2857 (syntax (.str "$Dst32Rn" group xmode))
2858 (base-ifield (.sym f- base -6))
2859 (encoding (+ ((.sym f- base -3) 4) (.sym Dst32Rn group xmode)))
2860 (ifield-assertion (eq (.sym f- base -3) 4))
2861 (getter (trunc xmode (.sym Dst32Rn group xmode)))
2862 (setter (set (.sym Dst32Rn group xmode) newval))
2867 (dst32-Rn-direct-operand Unprefixed 4 QI)
2868 (dst32-Rn-direct-operand Prefixed 12 QI)
2869 (dst32-Rn-direct-operand Unprefixed 4 HI)
2870 (dst32-Rn-direct-operand Prefixed 12 HI)
2871 (dst32-Rn-direct-operand Unprefixed 4 SI)
2872 (dst32-Rn-direct-operand Prefixed 12 SI)
2874 (define-pmacro (dst32-Rn-direct-Ext-operand group base1 base2 smode dmode)
2876 (define-derived-operand
2877 (name (.sym dst32-Rn-direct- group - smode))
2878 (comment (.str "m32c Rn direct destination " smode))
2879 (attrs (machine 32))
2881 (args ((.sym Dst32Rn group smode)))
2882 (syntax (.str "$Dst32Rn" group smode))
2883 (base-ifield (.sym f- base1 -6))
2884 (encoding (+ ((.sym f- base1 -3) 4) ((.sym f- base2 -1) 1) (.sym Dst32Rn group smode)))
2885 (ifield-assertion (andif (eq (.sym f- base1 -3) 4) (eq (.sym f- base2 -1) 1)))
2886 (getter (trunc smode (.sym Dst32Rn group smode)))
2887 (setter (set (.sym Dst32Rn group smode) newval))
2892 (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 QI HI)
2893 (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 HI SI)
2895 (define-derived-operand
2896 (name dst32-R3-direct-Unprefixed-HI)
2897 (comment "m32c R3 direct HI")
2898 (attrs (machine 32))
2903 (encoding (+ (f-4-3 4) (f-8-2 #x1)))
2904 (ifield-assertion (andif (eq f-4-3 4) (eq f-8-2 #x1)))
2905 (getter (trunc HI R3))
2906 (setter (set R3 newval))
2908 ;-------------------------------------------------------------
2910 ;-------------------------------------------------------------
2912 (define-pmacro (dst16-An-direct-operand xmode)
2914 (define-derived-operand
2915 (name (.sym dst16-An-direct- xmode))
2916 (comment (.str "m16c An direct destination " xmode))
2917 (attrs (machine 16))
2919 (args ((.sym Dst16An xmode)))
2920 (syntax (.str "$Dst16An" xmode))
2921 (base-ifield f-12-4)
2922 (encoding (+ (f-12-2 1) (f-14-1 0) (.sym Dst16An xmode)))
2923 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0)))
2924 (getter (trunc xmode (.sym Dst16An xmode)))
2925 (setter (set (.sym Dst16An xmode) newval))
2930 (dst16-An-direct-operand QI)
2931 (dst16-An-direct-operand HI)
2932 (dst16-An-direct-operand SI)
2934 (define-pmacro (dst32-An-direct-operand group base1 base2 xmode)
2936 (define-derived-operand
2937 (name (.sym dst32-An-direct- group - xmode))
2938 (comment (.str "m32c An direct destination " xmode))
2939 (attrs (machine 32))
2941 (args ((.sym Dst32An group xmode)))
2942 (syntax (.str "$Dst32An" group xmode))
2943 (base-ifield (.sym f- base1 -6))
2944 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Dst32An group xmode)))
2945 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
2946 (getter (trunc xmode (.sym Dst32An group xmode)))
2947 (setter (set (.sym Dst32An group xmode) newval))
2952 (dst32-An-direct-operand Unprefixed 4 8 QI)
2953 (dst32-An-direct-operand Prefixed 12 16 QI)
2954 (dst32-An-direct-operand Unprefixed 4 8 HI)
2955 (dst32-An-direct-operand Prefixed 12 16 HI)
2956 (dst32-An-direct-operand Unprefixed 4 8 SI)
2957 (dst32-An-direct-operand Prefixed 12 16 SI)
2959 ;-------------------------------------------------------------
2961 ;-------------------------------------------------------------
2963 (define-pmacro (dst16-An-indirect-operand xmode)
2965 (define-derived-operand
2966 (name (.sym dst16-An-indirect- xmode))
2967 (comment (.str "m16c An indirect destination " xmode))
2968 (attrs (machine 16))
2971 (syntax "[$Dst16An]")
2972 (base-ifield f-12-4)
2973 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
2974 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
2975 (getter (mem16 xmode Dst16An))
2976 (setter (set (mem16 xmode Dst16An) newval))
2981 (dst16-An-indirect-operand QI)
2982 (dst16-An-indirect-operand HI)
2983 (dst16-An-indirect-operand SI)
2985 (define-derived-operand
2986 (name dst16-An-indirect-Ext-QI)
2987 (comment "m16c An indirect destination QI")
2988 (attrs (machine 16))
2991 (syntax "[$Dst16An]")
2992 (base-ifield f-12-4)
2993 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
2994 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
2995 (getter (mem16 QI Dst16An))
2996 (setter (set (mem16 HI Dst16An) newval))
2999 (define-pmacro (dst32-An-indirect-operand group base1 base2 smode dmode)
3001 (define-derived-operand
3002 (name (.sym dst32-An-indirect- group - smode))
3003 (comment (.str "m32c An indirect destination " smode))
3004 (attrs (machine 32))
3006 (args ((.sym Dst32An group)))
3007 (syntax (.str "[$Dst32An" group "]"))
3008 (base-ifield (.sym f- base1 -6))
3009 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Dst32An group)))
3010 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
3011 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group)
3013 (setter (c-call DFLT (.str "operand_setter_" dmode) newval
3014 (.sym Dst32An group) (const 0)))
3015 ; (getter (mem32 smode (.sym Dst32An group)))
3016 ; (setter (set (mem32 dmode (.sym Dst32An group)) newval))
3021 (dst32-An-indirect-operand Unprefixed 4 8 QI QI)
3022 (dst32-An-indirect-operand Prefixed 12 16 QI QI)
3023 (dst32-An-indirect-operand Unprefixed 4 8 HI HI)
3024 (dst32-An-indirect-operand Prefixed 12 16 HI HI)
3025 (dst32-An-indirect-operand Unprefixed 4 8 SI SI)
3026 (dst32-An-indirect-operand Prefixed 12 16 SI SI)
3027 (dst32-An-indirect-operand ExtUnprefixed 4 8 QI HI)
3028 (dst32-An-indirect-operand ExtUnprefixed 4 8 HI SI)
3030 ;-------------------------------------------------------------
3032 ;-------------------------------------------------------------
3034 (define-pmacro (dst16-relative-operand offset xmode)
3036 (define-derived-operand
3037 (name (.sym dst16- offset -8-SB-relative- xmode))
3038 (comment (.str "m16c dsp:8[sb] relative destination " xmode))
3039 (attrs (machine 16))
3041 (args ((.sym Dsp- offset -u8)))
3042 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3043 (base-ifield f-12-4)
3044 (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8)))
3045 (ifield-assertion (eq f-12-4 #xA))
3046 (getter (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb))))
3047 (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3049 (define-derived-operand
3050 (name (.sym dst16- offset -16-SB-relative- xmode))
3051 (comment (.str "m16c dsp:16[sb] relative destination " xmode))
3052 (attrs (machine 16))
3054 (args ((.sym Dsp- offset -u16)))
3055 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3056 (base-ifield f-12-4)
3057 (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16)))
3058 (ifield-assertion (eq f-12-4 #xE))
3059 (getter (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb))))
3060 (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3062 (define-derived-operand
3063 (name (.sym dst16- offset -8-FB-relative- xmode))
3064 (comment (.str "m16c dsp:8[fb] relative destination " xmode))
3065 (attrs (machine 16))
3067 (args ((.sym Dsp- offset -s8)))
3068 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3069 (base-ifield f-12-4)
3070 (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8)))
3071 (ifield-assertion (eq f-12-4 #xB))
3072 (getter (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb))))
3073 (setter (set (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3075 (define-derived-operand
3076 (name (.sym dst16- offset -8-An-relative- xmode))
3077 (comment (.str "m16c dsp:8[An] relative destination " xmode))
3078 (attrs (machine 16))
3080 (args (Dst16An (.sym Dsp- offset -u8)))
3081 (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]"))
3082 (base-ifield f-12-4)
3083 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An))
3084 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3085 (getter (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An)))
3086 (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An)) newval))
3088 (define-derived-operand
3089 (name (.sym dst16- offset -16-An-relative- xmode))
3090 (comment (.str "m16c dsp:16[An] relative destination " xmode))
3091 (attrs (machine 16))
3093 (args (Dst16An (.sym Dsp- offset -u16)))
3094 (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]"))
3095 (base-ifield f-12-4)
3096 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An))
3097 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3098 (getter (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An)))
3099 (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An)) newval))
3104 (dst16-relative-operand 16 QI)
3105 (dst16-relative-operand 24 QI)
3106 (dst16-relative-operand 32 QI)
3107 (dst16-relative-operand 40 QI)
3108 (dst16-relative-operand 48 QI)
3109 (dst16-relative-operand 16 HI)
3110 (dst16-relative-operand 24 HI)
3111 (dst16-relative-operand 32 HI)
3112 (dst16-relative-operand 40 HI)
3113 (dst16-relative-operand 48 HI)
3114 (dst16-relative-operand 16 SI)
3115 (dst16-relative-operand 24 SI)
3116 (dst16-relative-operand 32 SI)
3117 (dst16-relative-operand 40 SI)
3118 (dst16-relative-operand 48 SI)
3120 (define-pmacro (dst16-relative-Ext-operand offset smode dmode)
3122 (define-derived-operand
3123 (name (.sym dst16- offset -8-SB-relative-Ext- smode))
3124 (comment (.str "m16c dsp:8[sb] relative destination " smode))
3125 (attrs (machine 16))
3127 (args ((.sym Dsp- offset -u8)))
3128 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3129 (base-ifield f-12-4)
3130 (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8)))
3131 (ifield-assertion (eq f-12-4 #xA))
3132 (getter (mem16 smode (add (.sym Dsp- offset -u8) (reg h-sb))))
3133 (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3135 (define-derived-operand
3136 (name (.sym dst16- offset -16-SB-relative-Ext- smode))
3137 (comment (.str "m16c dsp:16[sb] relative destination " smode))
3138 (attrs (machine 16))
3140 (args ((.sym Dsp- offset -u16)))
3141 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3142 (base-ifield f-12-4)
3143 (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16)))
3144 (ifield-assertion (eq f-12-4 #xE))
3145 (getter (mem16 smode (add (.sym Dsp- offset -u16) (reg h-sb))))
3146 (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3148 (define-derived-operand
3149 (name (.sym dst16- offset -8-FB-relative-Ext- smode))
3150 (comment (.str "m16c dsp:8[fb] relative destination " smode))
3151 (attrs (machine 16))
3153 (args ((.sym Dsp- offset -s8)))
3154 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3155 (base-ifield f-12-4)
3156 (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8)))
3157 (ifield-assertion (eq f-12-4 #xB))
3158 (getter (mem16 smode (add (.sym Dsp- offset -s8) (reg h-fb))))
3159 (setter (set (mem16 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3161 (define-derived-operand
3162 (name (.sym dst16- offset -8-An-relative-Ext- smode))
3163 (comment (.str "m16c dsp:8[An] relative destination " smode))
3164 (attrs (machine 16))
3166 (args (Dst16An (.sym Dsp- offset -u8)))
3167 (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]"))
3168 (base-ifield f-12-4)
3169 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An))
3170 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3171 (getter (mem16 smode (add (.sym Dsp- offset -u8) Dst16An)))
3172 (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) Dst16An)) newval))
3174 (define-derived-operand
3175 (name (.sym dst16- offset -16-An-relative-Ext- smode))
3176 (comment (.str "m16c dsp:16[An] relative destination " smode))
3177 (attrs (machine 16))
3179 (args (Dst16An (.sym Dsp- offset -u16)))
3180 (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]"))
3181 (base-ifield f-12-4)
3182 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An))
3183 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3184 (getter (mem16 smode (add (.sym Dsp- offset -u16) Dst16An)))
3185 (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) Dst16An)) newval))
3190 (dst16-relative-Ext-operand 16 QI HI)
3192 (define-pmacro (dst32-relative-operand offset group base1 base2 smode dmode)
3194 (define-derived-operand
3195 (name (.sym dst32- offset -8-SB-relative- group - smode))
3196 (comment (.str "m32c dsp:8[sb] relative destination " smode))
3197 (attrs (machine 32))
3199 (args ((.sym Dsp- offset -u8)))
3200 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3201 (base-ifield (.sym f- base1 -6))
3202 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8)))
3203 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
3204 (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u8)))
3205 (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u8)))
3206 ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (reg h-sb))))
3207 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3209 (define-derived-operand
3210 (name (.sym dst32- offset -16-SB-relative- group - smode))
3211 (comment (.str "m32c dsp:16[sb] relative destination " smode))
3212 (attrs (machine 32))
3214 (args ((.sym Dsp- offset -u16)))
3215 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3216 (base-ifield (.sym f- base1 -6))
3217 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16)))
3218 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
3219 (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u16)))
3220 (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u16)))
3221 ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (reg h-sb))))
3222 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3224 (define-derived-operand
3225 (name (.sym dst32- offset -8-FB-relative- group - smode))
3226 (comment (.str "m32c dsp:8[fb] relative destination " smode))
3227 (attrs (machine 32))
3229 (args ((.sym Dsp- offset -s8)))
3230 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3231 (base-ifield (.sym f- base1 -6))
3232 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8)))
3233 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
3234 (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s8)))
3235 (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s8)))
3236 ; (getter (mem32 smode (add (.sym Dsp- offset -s8) (reg h-fb))))
3237 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3239 (define-derived-operand
3240 (name (.sym dst32- offset -16-FB-relative- group - smode))
3241 (comment (.str "m32c dsp:16[fb] relative destination " smode))
3242 (attrs (machine 32))
3244 (args ((.sym Dsp- offset -s16)))
3245 (syntax (.str "${Dsp-" offset "-s16}[fb]"))
3246 (base-ifield (.sym f- base1 -6))
3247 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16)))
3248 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
3249 (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s16)))
3250 (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s16)))
3251 ; (getter (mem32 smode (add (.sym Dsp- offset -s16) (reg h-fb))))
3252 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval))
3254 (define-derived-operand
3255 (name (.sym dst32- offset -8-An-relative- group - smode))
3256 (comment (.str "m32c dsp:8[An] relative destination " smode))
3257 (attrs (machine 32))
3259 (args ((.sym Dst32An group) (.sym Dsp- offset -u8)))
3260 (syntax (.str "${Dsp-" offset "-u8}[$Dst32An" group "]"))
3261 (base-ifield (.sym f- base1 -6))
3262 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Dst32An group)))
3263 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
3264 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u8)))
3265 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u8)))
3266 ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (.sym Dst32An group))))
3267 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (.sym Dst32An group))) newval))
3269 (define-derived-operand
3270 (name (.sym dst32- offset -16-An-relative- group - smode))
3271 (comment (.str "m32c dsp:16[An] relative destination " smode))
3272 (attrs (machine 32))
3274 (args ((.sym Dst32An group) (.sym Dsp- offset -u16)))
3275 (syntax (.str "${Dsp-" offset "-u16}[$Dst32An" group "]"))
3276 (base-ifield (.sym f- base1 -6))
3277 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Dst32An group)))
3278 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
3279 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u16)))
3280 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u16)))
3281 ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (.sym Dst32An group))))
3282 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (.sym Dst32An group))) newval))
3284 (define-derived-operand
3285 (name (.sym dst32- offset -24-An-relative- group - smode))
3286 (comment (.str "m32c dsp:16[An] relative destination " smode))
3287 (attrs (machine 32))
3289 (args ((.sym Dst32An group) (.sym Dsp- offset -u24)))
3290 (syntax (.str "${Dsp-" offset "-u24}[$Dst32An" group "]"))
3291 (base-ifield (.sym f- base1 -6))
3292 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Dst32An group)))
3293 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
3294 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u24)))
3295 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u24)))
3296 ; (getter (mem32 smode (add (.sym Dsp- offset -u24) (.sym Dst32An group))))
3297 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u24) (.sym Dst32An group))) newval))
3302 (dst32-relative-operand 16 Unprefixed 4 8 QI QI)
3303 (dst32-relative-operand 24 Unprefixed 4 8 QI QI)
3304 (dst32-relative-operand 32 Unprefixed 4 8 QI QI)
3305 (dst32-relative-operand 40 Unprefixed 4 8 QI QI)
3306 (dst32-relative-operand 16 Unprefixed 4 8 HI HI)
3307 (dst32-relative-operand 24 Unprefixed 4 8 HI HI)
3308 (dst32-relative-operand 32 Unprefixed 4 8 HI HI)
3309 (dst32-relative-operand 40 Unprefixed 4 8 HI HI)
3310 (dst32-relative-operand 16 Unprefixed 4 8 SI SI)
3311 (dst32-relative-operand 24 Unprefixed 4 8 SI SI)
3312 (dst32-relative-operand 32 Unprefixed 4 8 SI SI)
3313 (dst32-relative-operand 40 Unprefixed 4 8 SI SI)
3315 (dst32-relative-operand 24 Prefixed 12 16 QI QI)
3316 (dst32-relative-operand 32 Prefixed 12 16 QI QI)
3317 (dst32-relative-operand 40 Prefixed 12 16 QI QI)
3318 (dst32-relative-operand 48 Prefixed 12 16 QI QI)
3319 (dst32-relative-operand 24 Prefixed 12 16 HI HI)
3320 (dst32-relative-operand 32 Prefixed 12 16 HI HI)
3321 (dst32-relative-operand 40 Prefixed 12 16 HI HI)
3322 (dst32-relative-operand 48 Prefixed 12 16 HI HI)
3323 (dst32-relative-operand 24 Prefixed 12 16 SI SI)
3324 (dst32-relative-operand 32 Prefixed 12 16 SI SI)
3325 (dst32-relative-operand 40 Prefixed 12 16 SI SI)
3326 (dst32-relative-operand 48 Prefixed 12 16 SI SI)
3328 (dst32-relative-operand 16 ExtUnprefixed 4 8 QI HI)
3329 (dst32-relative-operand 16 ExtUnprefixed 4 8 HI SI)
3331 ;-------------------------------------------------------------
3333 ;-------------------------------------------------------------
3335 (define-pmacro (dst16-absolute offset xmode)
3337 (define-derived-operand
3338 (name (.sym dst16- offset -16-absolute- xmode))
3339 (comment (.str "m16c absolute address " xmode))
3340 (attrs (machine 16))
3342 (args ((.sym Dsp- offset -u16)))
3343 (syntax (.str "${Dsp-" offset "-u16}"))
3344 (base-ifield f-12-4)
3345 (encoding (+ (f-12-4 #xF) (.sym Dsp- offset -u16)))
3346 (ifield-assertion (eq f-12-4 #xF))
3347 (getter (mem16 xmode (.sym Dsp- offset -u16)))
3348 (setter (set (mem16 xmode (.sym Dsp- offset -u16)) newval))
3353 (dst16-absolute 16 QI)
3354 (dst16-absolute 24 QI)
3355 (dst16-absolute 32 QI)
3356 (dst16-absolute 40 QI)
3357 (dst16-absolute 48 QI)
3358 (dst16-absolute 16 HI)
3359 (dst16-absolute 24 HI)
3360 (dst16-absolute 32 HI)
3361 (dst16-absolute 40 HI)
3362 (dst16-absolute 48 HI)
3363 (dst16-absolute 16 SI)
3364 (dst16-absolute 24 SI)
3365 (dst16-absolute 32 SI)
3366 (dst16-absolute 40 SI)
3367 (dst16-absolute 48 SI)
3369 (define-derived-operand
3370 (name dst16-16-16-absolute-Ext-QI)
3371 (comment "m16c absolute address QI")
3372 (attrs (machine 16))
3375 (syntax "${Dsp-16-u16}")
3376 (base-ifield f-12-4)
3377 (encoding (+ (f-12-4 #xF) Dsp-16-u16))
3378 (ifield-assertion (eq f-12-4 #xF))
3379 (getter (mem16 QI Dsp-16-u16))
3380 (setter (set (mem16 HI Dsp-16-u16) newval))
3383 (define-pmacro (dst32-absolute offset group base1 base2 smode dmode)
3385 (define-derived-operand
3386 (name (.sym dst32- offset -16-absolute- group - smode))
3387 (comment (.str "m32c absolute address " smode))
3388 (attrs (machine 32))
3390 (args ((.sym Dsp- offset -u16)))
3391 (syntax (.str "${Dsp-" offset "-u16}"))
3392 (base-ifield (.sym f- base1 -6))
3393 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
3394 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
3395 (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u16)))
3396 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u16)))
3397 ; (getter (mem32 smode (.sym Dsp- offset -u16)))
3398 ; (setter (set (mem32 dmode (.sym Dsp- offset -u16)) newval))
3400 (define-derived-operand
3401 (name (.sym dst32- offset -24-absolute- group - smode))
3402 (comment (.str "m32c absolute address " smode))
3403 (attrs (machine 32))
3405 (args ((.sym Dsp- offset -u24)))
3406 (syntax (.str "${Dsp-" offset "-u24}"))
3407 (base-ifield (.sym f- base1 -6))
3408 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
3409 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
3410 (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u24)))
3411 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u24)))
3412 ; (getter (mem32 smode (.sym Dsp- offset -u24)))
3413 ; (setter (set (mem32 dmode (.sym Dsp- offset -u24)) newval))
3418 (dst32-absolute 16 Unprefixed 4 8 QI QI)
3419 (dst32-absolute 24 Unprefixed 4 8 QI QI)
3420 (dst32-absolute 32 Unprefixed 4 8 QI QI)
3421 (dst32-absolute 40 Unprefixed 4 8 QI QI)
3422 (dst32-absolute 16 Unprefixed 4 8 HI HI)
3423 (dst32-absolute 24 Unprefixed 4 8 HI HI)
3424 (dst32-absolute 32 Unprefixed 4 8 HI HI)
3425 (dst32-absolute 40 Unprefixed 4 8 HI HI)
3426 (dst32-absolute 16 Unprefixed 4 8 SI SI)
3427 (dst32-absolute 24 Unprefixed 4 8 SI SI)
3428 (dst32-absolute 32 Unprefixed 4 8 SI SI)
3429 (dst32-absolute 40 Unprefixed 4 8 SI SI)
3431 (dst32-absolute 24 Prefixed 12 16 QI QI)
3432 (dst32-absolute 32 Prefixed 12 16 QI QI)
3433 (dst32-absolute 40 Prefixed 12 16 QI QI)
3434 (dst32-absolute 48 Prefixed 12 16 QI QI)
3435 (dst32-absolute 24 Prefixed 12 16 HI HI)
3436 (dst32-absolute 32 Prefixed 12 16 HI HI)
3437 (dst32-absolute 40 Prefixed 12 16 HI HI)
3438 (dst32-absolute 48 Prefixed 12 16 HI HI)
3439 (dst32-absolute 24 Prefixed 12 16 SI SI)
3440 (dst32-absolute 32 Prefixed 12 16 SI SI)
3441 (dst32-absolute 40 Prefixed 12 16 SI SI)
3442 (dst32-absolute 48 Prefixed 12 16 SI SI)
3444 (dst32-absolute 16 ExtUnprefixed 4 8 QI HI)
3445 (dst32-absolute 16 ExtUnprefixed 4 8 HI SI)
3447 ;-------------------------------------------------------------
3448 ; An indirect indirect
3449 ;-------------------------------------------------------------
3451 ;(define-pmacro (dst-An-indirect-indirect-operand xmode)
3452 ; (define-derived-operand
3453 ; (name (.sym dst32-An-indirect-indirect- xmode))
3454 ; (comment (.str "m32c An indirect indirect destination " xmode))
3455 ; (attrs (machine 32))
3457 ; (args (Dst32AnPrefixed))
3458 ; (syntax (.str "[[$Dst32AnPrefixed]]"))
3459 ; (base-ifield f-12-6)
3460 ; (encoding (+ (f-12-3 0) (f-16-1 0) Dst32AnPrefixed))
3461 ; (ifield-assertion (andif (eq f-12-3 0) (eq f-16-1 0)))
3462 ; (getter (mem32 xmode (indirect-addr Dst32AnPrefixed)))
3463 ; (setter (set (mem32 xmode (indirect-addr Dst32AnPrefixed)) newval))
3467 ; (dst-An-indirect-indirect-operand QI)
3468 ; (dst-An-indirect-indirect-operand HI)
3469 ; (dst-An-indirect-indirect-operand SI)
3471 ;-------------------------------------------------------------
3473 ;-------------------------------------------------------------
3475 (define-pmacro (dst-relative-indirect-operand offset xmode)
3477 ; (define-derived-operand
3478 ; (name (.sym dst32- offset -8-SB-relative-indirect- xmode))
3479 ; (comment (.str "m32c dsp:8[sb] relative destination " xmode))
3480 ; (attrs (machine 32))
3482 ; (args ((.sym Dsp- offset -u8)))
3483 ; (syntax (.str "[${Dsp-" offset "-u8}[sb]]"))
3484 ; (base-ifield f-12-6)
3485 ; (encoding (+ (f-12-3 1) (f-16-2 2) (.sym Dsp- offset -u8)))
3486 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 2)))
3487 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb)))))
3488 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb)))) newval))
3490 ; (define-derived-operand
3491 ; (name (.sym dst32- offset -16-SB-relative-indirect- xmode))
3492 ; (comment (.str "m32c dsp:16[sb] relative destination " xmode))
3493 ; (attrs (machine 32))
3495 ; (args ((.sym Dsp- offset -u16)))
3496 ; (syntax (.str "[${Dsp-" offset "-u16}[sb]]"))
3497 ; (base-ifield f-12-6)
3498 ; (encoding (+ (f-12-3 2) (f-16-2 2) (.sym Dsp- offset -u16)))
3499 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 2)))
3500 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb)))))
3501 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb)))) newval))
3503 ; (define-derived-operand
3504 ; (name (.sym dst32- offset -8-FB-relative-indirect- xmode))
3505 ; (comment (.str "m32c dsp:8[fb] relative destination " xmode))
3506 ; (attrs (machine 32))
3508 ; (args ((.sym Dsp- offset -s8)))
3509 ; (syntax (.str "[${Dsp-" offset "-s8}[fb]]"))
3510 ; (base-ifield f-12-6)
3511 ; (encoding (+ (f-12-3 1) (f-16-2 3) (.sym Dsp- offset -s8)))
3512 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 3)))
3513 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb)))))
3514 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb)))) newval))
3516 ; (define-derived-operand
3517 ; (name (.sym dst32- offset -16-FB-relative-indirect- xmode))
3518 ; (comment (.str "m32c dsp:16[fb] relative destination " xmode))
3519 ; (attrs (machine 32))
3521 ; (args ((.sym Dsp- offset -s16)))
3522 ; (syntax (.str "[${Dsp-" offset "-s16}[fb]]"))
3523 ; (base-ifield f-12-6)
3524 ; (encoding (+ (f-12-3 2) (f-16-2 3) (.sym Dsp- offset -s16)))
3525 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 3)))
3526 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb)))))
3527 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb)))) newval))
3529 ; (define-derived-operand
3530 ; (name (.sym dst32- offset -8-An-relative-indirect- xmode))
3531 ; (comment (.str "m32c dsp:8[An] relative indirect destination " xmode))
3532 ; (attrs (machine 32))
3534 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u8)))
3535 ; (syntax (.str "[${Dsp-" offset "-u8}[$Dst32AnPrefixed]]"))
3536 ; (base-ifield f-12-6)
3537 ; (encoding (+ (f-12-3 1) (f-16-1 0) (.sym Dsp- offset -u8) Dst32AnPrefixed))
3538 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-1 0)))
3539 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed))))
3540 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed))) newval))
3542 ; (define-derived-operand
3543 ; (name (.sym dst32- offset -16-An-relative-indirect- xmode))
3544 ; (comment (.str "m32c dsp:16[An] relative destination " xmode))
3545 ; (attrs (machine 32))
3547 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u16)))
3548 ; (syntax (.str "[${Dsp-" offset "-u16}[$Dst32AnPrefixed]]"))
3549 ; (base-ifield f-12-6)
3550 ; (encoding (+ (f-12-3 2) (f-16-1 0) (.sym Dsp- offset -u16) Dst32AnPrefixed))
3551 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-1 0)))
3552 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed))))
3553 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed))) newval))
3555 ; (define-derived-operand
3556 ; (name (.sym dst32- offset -24-An-relative-indirect- xmode))
3557 ; (comment (.str "m32c dsp:24[An] relative destination " xmode))
3558 ; (attrs (machine 32))
3560 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u24)))
3561 ; (syntax (.str "[${Dsp-" offset "-u24}[$Dst32AnPrefixed]]"))
3562 ; (base-ifield f-12-6)
3563 ; (encoding (+ (f-12-3 3) (f-16-1 0) (.sym Dsp- offset -u24) Dst32AnPrefixed))
3564 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-1 0)))
3565 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed))))
3566 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed))) newval))
3571 ; (dst-relative-indirect-operand 24 QI)
3572 ; (dst-relative-indirect-operand 32 QI)
3573 ; (dst-relative-indirect-operand 40 QI)
3574 ; (dst-relative-indirect-operand 48 QI)
3575 ; (dst-relative-indirect-operand 24 HI)
3576 ; (dst-relative-indirect-operand 32 HI)
3577 ; (dst-relative-indirect-operand 40 HI)
3578 ; (dst-relative-indirect-operand 48 HI)
3579 ; (dst-relative-indirect-operand 24 SI)
3580 ; (dst-relative-indirect-operand 32 SI)
3581 ; (dst-relative-indirect-operand 40 SI)
3582 ; (dst-relative-indirect-operand 48 SI)
3584 ;-------------------------------------------------------------
3586 ;-------------------------------------------------------------
3588 (define-pmacro (dst-absolute-indirect offset xmode)
3590 ; (define-derived-operand
3591 ; (name (.sym dst32- offset -16-absolute-indirect-derived- xmode))
3592 ; (comment (.str "m32c absolute indirect address " xmode))
3593 ; (attrs (machine 32))
3595 ; (args ((.sym Dsp- offset -u16)))
3596 ; (syntax (.str "[${Dsp-" offset "-u16}]"))
3597 ; (base-ifield f-12-6)
3598 ; (encoding (+ (f-12-3 3) (f-16-2 3) (.sym Dsp- offset -u16)))
3599 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 3)))
3600 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))))
3601 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval))
3603 ; (define-derived-operand
3604 ; (name (.sym dst32- offset -24-absolute-indirect-derived- xmode))
3605 ; (comment (.str "m32c absolute indirect address " xmode))
3606 ; (attrs (machine 32))
3608 ; (args ((.sym Dsp- offset -u24)))
3609 ; (syntax (.str "[${Dsp-" offset "-u24}]"))
3610 ; (base-ifield f-12-6)
3611 ; (encoding (+ (f-12-3 3) (f-16-2 2) (.sym Dsp- offset -u24)))
3612 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 2)))
3613 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))))
3614 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval))
3619 (dst-absolute-indirect 24 QI)
3620 (dst-absolute-indirect 32 QI)
3621 (dst-absolute-indirect 40 QI)
3622 (dst-absolute-indirect 48 QI)
3623 (dst-absolute-indirect 24 HI)
3624 (dst-absolute-indirect 32 HI)
3625 (dst-absolute-indirect 40 HI)
3626 (dst-absolute-indirect 48 HI)
3627 (dst-absolute-indirect 24 SI)
3628 (dst-absolute-indirect 32 SI)
3629 (dst-absolute-indirect 40 SI)
3630 (dst-absolute-indirect 48 SI)
3632 ;-------------------------------------------------------------
3634 ;-------------------------------------------------------------
3635 (define-pmacro (get-register-bit reg bitno)
3636 (and (srl reg bitno) 1)
3639 (define-pmacro (set-register-bit reg bitno value)
3640 (set reg (or (and reg (inv (sll 1 bitno)))
3641 (sll (and QI value 1) bitno)))
3644 (define-pmacro (get-memory-bit mach base bitno)
3645 (and (srl (mem-mach mach QI (add base (div bitno 8)))
3650 (define-pmacro (set-memory-bit mach base bitno value)
3651 (sequence ((USI addr))
3652 (set addr (add base (div bitno 8)))
3653 (set (mem-mach mach QI addr)
3654 (or (and (mem-mach mach QI addr)
3655 (inv (sll 1 (mod bitno 8))))
3656 (sll (and QI value 1) (mod bitno 8)))))
3659 ;-------------------------------------------------------------
3661 ;-------------------------------------------------------------
3663 (define-derived-operand
3664 (name bit16-Rn-direct)
3665 (comment "m16c Rn direct bit")
3666 (attrs (machine 16))
3668 (args (Bitno16R Bit16Rn))
3669 (syntax "$Bitno16R,$Bit16Rn")
3670 (base-ifield f-12-4)
3671 (encoding (+ (f-12-2 0) Bit16Rn Bitno16R))
3672 (ifield-assertion (eq f-12-2 0))
3673 (getter (get-register-bit Bit16Rn Bitno16R))
3674 (setter (set-register-bit Bit16Rn Bitno16R newval))
3677 (define-pmacro (bit32-Rn-direct-operand group base)
3679 (define-derived-operand
3680 (name (.sym bit32-Rn-direct- group))
3681 (comment "m32c Rn direct bit")
3682 (attrs (machine 32))
3684 (args ((.sym Bitno32 group) (.sym Bit32Rn group)))
3685 (syntax (.str "$Bitno32" group ",$Bit32Rn" group))
3686 (base-ifield (.sym f- base -6))
3687 (encoding (+ ((.sym f- base -3) 4) (.sym Bit32Rn group) (.sym Bitno32 group)))
3688 (ifield-assertion (eq (.sym f- base -3) 4))
3689 (getter (get-register-bit (.sym Bit32Rn group) (.sym Bitno32 group)))
3690 (setter (set-register-bit (.sym Bit32Rn group) (.sym Bitno32 group) newval))
3695 (bit32-Rn-direct-operand Unprefixed 4)
3696 (bit32-Rn-direct-operand Prefixed 12)
3698 ;-------------------------------------------------------------
3700 ;-------------------------------------------------------------
3702 (define-derived-operand
3703 (name bit16-An-direct)
3704 (comment "m16c An direct bit")
3705 (attrs (machine 16))
3707 (args (Bitno16R Bit16An))
3708 (syntax "$Bitno16R,$Bit16An")
3709 (base-ifield f-12-4)
3710 (encoding (+ (f-12-2 1) (f-14-1 0) Bit16An Bitno16R))
3711 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0)))
3712 (getter (get-register-bit Bit16An Bitno16R))
3713 (setter (set-register-bit Bit16An Bitno16R newval))
3716 (define-pmacro (bit32-An-direct-operand group base1 base2)
3718 (define-derived-operand
3719 (name (.sym bit32-An-direct- group))
3720 (comment "m32c An direct bit")
3721 (attrs (machine 32))
3723 (args ((.sym Bitno32 group) (.sym Bit32An group)))
3724 (syntax (.str "$Bitno32" group ",$Bit32An" group))
3725 (base-ifield (.sym f- base1 -6))
3726 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Bit32An group) (.sym Bitno32 group)))
3727 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
3728 (getter (get-register-bit (.sym Bit32An group) (.sym Bitno32 group)))
3729 (setter (set-register-bit (.sym Bit32An group) (.sym Bitno32 group) newval))
3734 (bit32-An-direct-operand Unprefixed 4 8)
3735 (bit32-An-direct-operand Prefixed 12 16)
3737 ;-------------------------------------------------------------
3739 ;-------------------------------------------------------------
3741 (define-derived-operand
3742 (name bit16-An-indirect)
3743 (comment "m16c An indirect bit")
3744 (attrs (machine 16))
3747 (syntax "[$Bit16An]")
3748 (base-ifield f-12-4)
3749 (encoding (+ (f-12-2 1) (f-14-1 1) Bit16An))
3750 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
3751 (getter (get-memory-bit 16 0 Bit16An))
3752 (setter (set-memory-bit 16 0 Bit16An newval))
3755 (define-pmacro (bit32-An-indirect-operand group base1 base2)
3757 (define-derived-operand
3758 (name (.sym bit32-An-indirect- group))
3759 (comment "m32c An indirect destination ")
3760 (attrs (machine 32))
3762 (args ((.sym Bitno32 group) (.sym Bit32An group)))
3763 (syntax (.str "$Bitno32" group ",[$Bit32An" group "]"))
3764 (base-ifield (.sym f- base1 -6))
3765 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Bit32An group) (.sym Bitno32 group)))
3766 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
3767 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group)))
3768 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group) newval))
3773 (bit32-An-indirect-operand Unprefixed 4 8)
3774 (bit32-An-indirect-operand Prefixed 12 16)
3776 ;-------------------------------------------------------------
3778 ;-------------------------------------------------------------
3780 (define-pmacro (bit16-relative-operand offset)
3782 (define-derived-operand
3783 (name (.sym bit16- offset -8-SB-relative))
3784 (comment (.str "m16c dsp:8[sb] relative bit " xmode))
3785 (attrs (machine 16))
3787 (args ((.sym BitBase16- offset -u8)))
3788 (syntax (.str "${BitBase16-" offset "-u8}[sb]"))
3789 (base-ifield f-12-4)
3790 (encoding (+ (f-12-4 #xA) (.sym BitBase16- offset -u8)))
3791 (ifield-assertion (eq f-12-4 #xA))
3792 (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8)))
3793 (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8) newval))
3795 (define-derived-operand
3796 (name (.sym bit16- offset -16-SB-relative))
3797 (comment (.str "m16c dsp:16[sb] relative bit " xmode))
3798 (attrs (machine 16))
3800 (args ((.sym BitBase16- offset -u16)))
3801 (syntax (.str "${BitBase16-" offset "-u16}[sb]"))
3802 (base-ifield f-12-4)
3803 (encoding (+ (f-12-4 #xE) (.sym BitBase16- offset -u16)))
3804 (ifield-assertion (eq f-12-4 #xE))
3805 (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16)))
3806 (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16) newval))
3808 (define-derived-operand
3809 (name (.sym bit16- offset -8-FB-relative))
3810 (comment (.str "m16c dsp:8[fb] relative bit " xmode))
3811 (attrs (machine 16))
3813 (args ((.sym BitBase16- offset -s8)))
3814 (syntax (.str "${BitBase16-" offset "-s8}[fb]"))
3815 (base-ifield f-12-4)
3816 (encoding (+ (f-12-4 #xB) (.sym BitBase16- offset -s8)))
3817 (ifield-assertion (eq f-12-4 #xB))
3818 (getter (get-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8)))
3819 (setter (set-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8) newval))
3821 (define-derived-operand
3822 (name (.sym bit16- offset -8-An-relative))
3823 (comment (.str "m16c dsp:8[An] relative bit " xmode))
3824 (attrs (machine 16))
3826 (args (Bit16An (.sym Dsp- offset -u8)))
3827 (syntax (.str "${Dsp-" offset "-u8}[$Bit16An]"))
3828 (base-ifield f-12-4)
3829 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Bit16An))
3830 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3831 (getter (get-memory-bit 16 (.sym Dsp- offset -u8) Bit16An))
3832 (setter (set-memory-bit 16 (.sym Dsp- offset -u8) Bit16An newval))
3834 (define-derived-operand
3835 (name (.sym bit16- offset -16-An-relative))
3836 (comment (.str "m16c dsp:16[An] relative bit " xmode))
3837 (attrs (machine 16))
3839 (args (Bit16An (.sym Dsp- offset -u16)))
3840 (syntax (.str "${Dsp-" offset "-u16}[$Bit16An]"))
3841 (base-ifield f-12-4)
3842 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Bit16An))
3843 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3844 (getter (get-memory-bit 16 (.sym Dsp- offset -u16) Bit16An))
3845 (setter (set-memory-bit 16 (.sym Dsp- offset -u16) Bit16An newval))
3850 (bit16-relative-operand 16)
3852 (define-pmacro (bit32-relative-operand offset group base1 base2)
3854 (define-derived-operand
3855 (name (.sym bit32- offset -11-SB-relative- group))
3856 (comment "m32c bit,base:11[sb] relative bit")
3857 (attrs (machine 32))
3859 (args ((.sym BitBase32- offset -u11- group)))
3860 (syntax (.str "${BitBase32-" offset "-u11-" group "}[sb]"))
3861 (base-ifield (.sym f- base1 -12))
3862 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u11- group)))
3863 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
3864 (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group)))
3865 (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group) newval))
3867 (define-derived-operand
3868 (name (.sym bit32- offset -19-SB-relative- group))
3869 (comment "m32c bit,base:19[sb] relative bit")
3870 (attrs (machine 32))
3872 (args ((.sym BitBase32- offset -u19- group)))
3873 (syntax (.str "${BitBase32-" offset "-u19-" group "}[sb]"))
3874 (base-ifield (.sym f- base1 -12))
3875 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u19- group)))
3876 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
3877 (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group)))
3878 (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group) newval))
3880 (define-derived-operand
3881 (name (.sym bit32- offset -11-FB-relative- group))
3882 (comment "m32c bit,base:11[fb] relative bit")
3883 (attrs (machine 32))
3885 (args ((.sym BitBase32- offset -s11- group)))
3886 (syntax (.str "${BitBase32-" offset "-s11-" group "}[fb]"))
3887 (base-ifield (.sym f- base1 -12))
3888 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s11- group)))
3889 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
3890 (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group)))
3891 (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group) newval))
3893 (define-derived-operand
3894 (name (.sym bit32- offset -19-FB-relative- group))
3895 (comment "m32c bit,base:19[fb] relative bit")
3896 (attrs (machine 32))
3898 (args ((.sym BitBase32- offset -s19- group)))
3899 (syntax (.str "${BitBase32-" offset "-s19-" group "}[fb]"))
3900 (base-ifield (.sym f- base1 -12))
3901 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s19- group)))
3902 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
3903 (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group)))
3904 (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group) newval))
3906 (define-derived-operand
3907 (name (.sym bit32- offset -11-An-relative- group))
3908 (comment "m32c bit,base:11[An] relative bit")
3909 (attrs (machine 32))
3911 (args ((.sym BitBase32- offset -u11- group) (.sym Bit32An group)))
3912 (syntax (.str "${BitBase32-" offset "-u11-" group "}[$Bit32An" group "]"))
3913 (base-ifield (.sym f- base1 -12))
3914 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u11- group) (.sym Bit32An group)))
3915 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
3916 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group)))
3917 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group) newval))
3919 (define-derived-operand
3920 (name (.sym bit32- offset -19-An-relative- group))
3921 (comment "m32c bit,base:19[An] relative bit")
3922 (attrs (machine 32))
3924 (args ((.sym BitBase32- offset -u19- group) (.sym Bit32An group)))
3925 (syntax (.str "${BitBase32-" offset "-u19-" group "}[$Bit32An" group "]"))
3926 (base-ifield (.sym f- base1 -12))
3927 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u19- group) (.sym Bit32An group)))
3928 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
3929 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group)))
3930 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group) newval))
3932 (define-derived-operand
3933 (name (.sym bit32- offset -27-An-relative- group))
3934 (comment "m32c bit,base:27[An] relative bit")
3935 (attrs (machine 32))
3937 (args ((.sym BitBase32- offset -u27- group) (.sym Bit32An group)))
3938 (syntax (.str "${BitBase32-" offset "-u27-" group "}[$Bit32An" group "]"))
3939 (base-ifield (.sym f- base1 -12))
3940 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u27- group) (.sym Bit32An group)))
3941 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
3942 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group)))
3943 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group) newval))
3948 (bit32-relative-operand 16 Unprefixed 4 8)
3949 (bit32-relative-operand 24 Prefixed 12 16)
3951 (define-derived-operand
3952 (name bit16-11-SB-relative-S)
3953 (comment "m16c bit,base:11[sb] relative bit")
3954 (attrs (machine 16))
3956 (args (BitBase16-8-u11-S))
3957 (syntax "${BitBase16-8-u11-S}[sb]")
3958 (base-ifield (.sym f-5-3))
3959 (encoding (+ BitBase16-8-u11-S))
3960 ; (ifield-assertion (#t))
3961 (getter (get-memory-bit 16 (reg h-sb) BitBase16-8-u11-S))
3962 (setter (set-memory-bit 16 (reg h-sb) BitBase16-8-u11-S newval))
3965 (define-derived-operand
3966 (name Rn16-push-S-derived)
3967 (comment "m16c r0[lh] for push,pop short version")
3968 (attrs (machine 16))
3970 (args (Rn16-push-S))
3971 (syntax "${Rn16-push-S}")
3972 (base-ifield (.sym f-4-1))
3973 (encoding (+ Rn16-push-S))
3974 ; (ifield-assertion (#t))
3975 (getter (trunc QI Rn16-push-S))
3976 (setter (set Rn16-push-S newval))
3979 (define-derived-operand
3980 (name An16-push-S-derived)
3981 (comment "m16c r0[lh] for push,pop short version")
3982 (attrs (machine 16))
3984 (args (An16-push-S))
3985 (syntax "${An16-push-S}")
3986 (base-ifield (.sym f-4-1))
3987 (encoding (+ An16-push-S))
3988 ; (ifield-assertion (#t))
3989 (getter (trunc QI An16-push-S))
3990 (setter (set An16-push-S newval))
3993 ;-------------------------------------------------------------
3995 ;-------------------------------------------------------------
3997 (define-pmacro (bit16-absolute offset)
3999 (define-derived-operand
4000 (name (.sym bit16- offset -16-absolute))
4001 (comment "m16c absolute address")
4002 (attrs (machine 16))
4004 (args ((.sym BitBase16- offset -u16)))
4005 (syntax (.str "${BitBase16-" offset "-u16}"))
4006 (base-ifield f-12-4)
4007 (encoding (+ (f-12-4 #xF) (.sym BitBase16- offset -u16)))
4008 (ifield-assertion (eq f-12-4 #xF))
4009 (getter (get-memory-bit 16 0 (.sym BitBase16- offset -u16)))
4010 (setter (set-memory-bit 16 0 (.sym BitBase16- offset -u16) newval))
4017 (define-pmacro (bit32-absolute offset group base1 base2)
4019 (define-derived-operand
4020 (name (.sym bit32- offset -19-absolute- group))
4021 (comment "m32c absolute address bit")
4022 (attrs (machine 32))
4024 (args ((.sym BitBase32- offset -u19- group)))
4025 (syntax (.str "${BitBase32-" offset "-u19-" group "}"))
4026 (base-ifield (.sym f- base1 -12))
4027 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -u19- group)))
4028 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
4029 (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u19- group)))
4030 (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u19- group) newval))
4032 (define-derived-operand
4033 (name (.sym bit32- offset -27-absolute- group))
4034 (comment "m32c absolute address bit")
4035 (attrs (machine 32))
4037 (args ((.sym BitBase32- offset -u27- group)))
4038 (syntax (.str "${BitBase32-" offset "-u27-" group "}"))
4039 (base-ifield (.sym f- base1 -12))
4040 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u27- group)))
4041 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
4042 (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u27- group)))
4043 (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u27- group) newval))
4048 (bit32-absolute 16 Unprefixed 4 8)
4049 (bit32-absolute 24 Prefixed 12 16)
4051 ;-------------------------------------------------------------
4052 ; Destination operands for short fomat insns
4053 ;-------------------------------------------------------------
4055 (define-derived-operand
4056 (name dst16-3-S-R0l-direct-QI)
4057 (comment "m16c R0l direct QI")
4058 (attrs (machine 16))
4063 (encoding (+ (f-5-3 4)))
4064 (ifield-assertion (eq f-5-3 4))
4065 (getter (trunc QI R0l))
4066 (setter (set R0l newval))
4068 (define-derived-operand
4069 (name dst16-3-S-R0h-direct-QI)
4070 (comment "m16c R0h direct QI")
4071 (attrs (machine 16))
4076 (encoding (+ (f-5-3 3)))
4077 (ifield-assertion (eq f-5-3 3))
4078 (getter (trunc QI R0h))
4079 (setter (set R0h newval))
4081 (define-derived-operand
4082 (name dst16-3-S-8-8-SB-relative-QI)
4083 (comment "m16c SB relative QI")
4084 (attrs (machine 16))
4087 (syntax "${Dsp-8-u8}[sb]")
4089 (encoding (+ (f-5-3 5) Dsp-8-u8))
4090 (ifield-assertion (eq f-5-3 5))
4091 (getter (mem16 QI (add Dsp-8-u8 (reg h-sb))))
4092 (setter (set (mem16 QI (add Dsp-8-u8 (reg h-sb))) newval))
4094 (define-derived-operand
4095 (name dst16-3-S-8-8-FB-relative-QI)
4096 (comment "m16c FB relative QI")
4097 (attrs (machine 16))
4100 (syntax "${Dsp-8-s8}[fb]")
4102 (encoding (+ (f-5-3 6) Dsp-8-s8))
4103 (ifield-assertion (eq f-5-3 6))
4104 (getter (mem16 QI (add Dsp-8-s8 (reg h-fb))))
4105 (setter (set (mem16 QI (add Dsp-8-s8 (reg h-fb))) newval))
4107 (define-derived-operand
4108 (name dst16-3-S-8-16-absolute-QI)
4109 (comment "m16c absolute address QI")
4110 (attrs (machine 16))
4113 (syntax "${Dsp-8-u16}")
4115 (encoding (+ (f-5-3 7) Dsp-8-u16))
4116 (ifield-assertion (eq f-5-3 7))
4117 (getter (mem16 QI Dsp-8-u16))
4118 (setter (set (mem16 QI Dsp-8-u16) newval))
4120 (define-derived-operand
4121 (name dst16-3-S-16-8-SB-relative-QI)
4122 (comment "m16c SB relative QI")
4123 (attrs (machine 16))
4126 (syntax "${Dsp-16-u8}[sb]")
4128 (encoding (+ (f-5-3 5) Dsp-16-u8))
4129 (ifield-assertion (eq f-5-3 5))
4130 (getter (mem16 QI (add Dsp-16-u8 (reg h-sb))))
4131 (setter (set (mem16 QI (add Dsp-16-u8 (reg h-sb))) newval))
4133 (define-derived-operand
4134 (name dst16-3-S-16-8-FB-relative-QI)
4135 (comment "m16c FB relative QI")
4136 (attrs (machine 16))
4139 (syntax "${Dsp-16-s8}[fb]")
4141 (encoding (+ (f-5-3 6) Dsp-16-s8))
4142 (ifield-assertion (eq f-5-3 6))
4143 (getter (mem16 QI (add Dsp-16-s8 (reg h-fb))))
4144 (setter (set (mem16 QI (add Dsp-16-s8 (reg h-fb))) newval))
4146 (define-derived-operand
4147 (name dst16-3-S-16-16-absolute-QI)
4148 (comment "m16c absolute address QI")
4149 (attrs (machine 16))
4152 (syntax "${Dsp-16-u16}")
4154 (encoding (+ (f-5-3 7) Dsp-16-u16))
4155 (ifield-assertion (eq f-5-3 7))
4156 (getter (mem16 QI Dsp-16-u16))
4157 (setter (set (mem16 QI Dsp-16-u16) newval))
4159 (define-derived-operand
4160 (name srcdst16-r0l-r0h-S-derived)
4161 (comment "m16c r0l/r0h operand for short format insns")
4162 (attrs (machine 16))
4164 (args (SrcDst16-r0l-r0h-S-normal))
4165 (syntax "${SrcDst16-r0l-r0h-S-normal}")
4167 (encoding (+ (f-6-2 0) SrcDst16-r0l-r0h-S-normal))
4168 (ifield-assertion (eq f-6-2 0))
4169 (getter (trunc SI SrcDst16-r0l-r0h-S-normal))
4170 (setter ()) ; no setter
4172 (define-derived-operand
4173 (name dst32-2-S-R0l-direct-QI)
4174 (comment "m32c R0l direct QI")
4175 (attrs (machine 32))
4180 (encoding (+ (f-2-2 0)))
4181 (ifield-assertion (eq f-2-2 0))
4182 (getter (trunc QI R0l))
4183 (setter (set R0l newval))
4185 (define-derived-operand
4186 (name dst32-2-S-R0-direct-HI)
4187 (comment "m32c R0 direct HI")
4188 (attrs (machine 32))
4193 (encoding (+ (f-2-2 0)))
4194 (ifield-assertion (eq f-2-2 0))
4195 (getter (trunc HI R0))
4196 (setter (set R0 newval))
4198 (define-derived-operand
4199 (name dst32-1-S-A0-direct-HI)
4200 (comment "m32c A0 direct HI")
4201 (attrs (machine 32))
4206 (encoding (+ (f-7-1 0)))
4207 (ifield-assertion (eq f-7-1 0))
4208 (getter (trunc HI A0))
4209 (setter (set A0 newval))
4211 (define-derived-operand
4212 (name dst32-1-S-A1-direct-HI)
4213 (comment "m32c A1 direct HI")
4214 (attrs (machine 32))
4219 (encoding (+ (f-7-1 1)))
4220 (ifield-assertion (eq f-7-1 1))
4221 (getter (trunc HI A1))
4222 (setter (set A1 newval))
4224 (define-pmacro (dst32-2-S-operands xmode)
4226 (define-derived-operand
4227 (name (.sym dst32-2-S-8-SB-relative- xmode))
4228 (comment "m32c SB relative for short binary insns")
4229 (attrs (machine 32))
4232 (syntax "${Dsp-8-u8}[sb]")
4234 (encoding (+ (f-2-2 2) Dsp-8-u8))
4235 (ifield-assertion (eq f-2-2 2))
4236 (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8))
4237 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8))
4238 ; (getter (mem32 xmode (add Dsp-8-u8 (reg h-sb))))
4239 ; (setter (set (mem32 xmode (add Dsp-8-u8 (reg h-sb))) newval))
4241 (define-derived-operand
4242 (name (.sym dst32-2-S-8-FB-relative- xmode))
4243 (comment "m32c FB relative for short binary insns")
4244 (attrs (machine 32))
4247 (syntax "${Dsp-8-s8}[fb]")
4249 (encoding (+ (f-2-2 3) Dsp-8-s8))
4250 (ifield-assertion (eq f-2-2 3))
4251 (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8))
4252 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8))
4253 ; (getter (mem32 xmode (add Dsp-8-s8 (reg h-fb))))
4254 ; (setter (set (mem32 xmode (add Dsp-8-s8 (reg h-fb))) newval))
4256 (define-derived-operand
4257 (name (.sym dst32-2-S-16-absolute- xmode))
4258 (comment "m32c absolute address for short binary insns")
4259 (attrs (machine 32))
4262 (syntax "${Dsp-8-u16}")
4264 (encoding (+ (f-2-2 1) Dsp-8-u16))
4265 (ifield-assertion (eq f-2-2 1))
4266 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16))
4267 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16))
4268 ; (getter (mem32 xmode Dsp-8-u16))
4269 ; (setter (set (mem32 xmode Dsp-8-u16) newval))
4271 ; (define-derived-operand
4272 ; (name (.sym dst32-2-S-8-SB-relative-indirect- xmode))
4273 ; (comment "m32c SB relative for short binary insns")
4274 ; (attrs (machine 32))
4276 ; (args (Dsp-16-u8))
4277 ; (syntax "[${Dsp-16-u8}[sb]]")
4278 ; (base-ifield f-10-2)
4279 ; (encoding (+ (f-10-2 2) Dsp-16-u8))
4280 ; (ifield-assertion (eq f-10-2 2))
4281 ; (getter (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb)))))
4282 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb)))) newval))
4284 ; (define-derived-operand
4285 ; (name (.sym dst32-2-S-8-FB-relative-indirect- xmode))
4286 ; (comment "m32c FB relative for short binary insns")
4287 ; (attrs (machine 32))
4289 ; (args (Dsp-16-s8))
4290 ; (syntax "[${Dsp-16-s8}[fb]]")
4291 ; (base-ifield f-10-2)
4292 ; (encoding (+ (f-10-2 3) Dsp-16-s8))
4293 ; (ifield-assertion (eq f-10-2 3))
4294 ; (getter (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb)))))
4295 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb)))) newval))
4297 ; (define-derived-operand
4298 ; (name (.sym dst32-2-S-16-absolute-indirect- xmode))
4299 ; (comment "m32c absolute address for short binary insns")
4300 ; (attrs (machine 32))
4302 ; (args (Dsp-16-u16))
4303 ; (syntax "[${Dsp-16-u16}]")
4304 ; (base-ifield f-10-2)
4305 ; (encoding (+ (f-10-2 1) Dsp-16-u16))
4306 ; (ifield-assertion (eq f-10-2 1))
4307 ; (getter (mem32 xmode (indirect-addr Dsp-16-u16)))
4308 ; (setter (set (mem32 xmode (indirect-addr Dsp-16-u16)) newval))
4313 (dst32-2-S-operands QI)
4314 (dst32-2-S-operands HI)
4315 (dst32-2-S-operands SI)
4317 ;=============================================================
4319 ;-------------------------------------------------------------
4320 ; Source operands with no additional fields
4321 ;-------------------------------------------------------------
4323 (define-pmacro (src16-basic-operand xmode)
4325 (define-anyof-operand
4326 (name (.sym src16-basic- xmode))
4327 (comment (.str "m16c source operand of size " xmode " with no additional fields"))
4328 (attrs (machine 16))
4331 (.sym src16-Rn-direct- xmode)
4332 (.sym src16-An-direct- xmode)
4333 (.sym src16-An-indirect- xmode)
4338 (src16-basic-operand QI)
4339 (src16-basic-operand HI)
4341 (define-pmacro (src32-basic-operand xmode)
4343 (define-anyof-operand
4344 (name (.sym src32-basic-Unprefixed- xmode))
4345 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4346 (attrs (machine 32))
4349 (.sym src32-Rn-direct-Unprefixed- xmode)
4350 (.sym src32-An-direct-Unprefixed- xmode)
4351 (.sym src32-An-indirect-Unprefixed- xmode)
4354 (define-anyof-operand
4355 (name (.sym src32-basic-Prefixed- xmode))
4356 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4357 (attrs (machine 32))
4360 (.sym src32-Rn-direct-Prefixed- xmode)
4361 (.sym src32-An-direct-Prefixed- xmode)
4362 (.sym src32-An-indirect-Prefixed- xmode)
4365 ; (define-anyof-operand
4366 ; (name (.sym src32-basic-indirect- xmode))
4367 ; (comment (.str "m32c destination operand of size " xmode " indirect with no additional fields"))
4368 ; (attrs (machine 32))
4371 ; (.sym src32-An-indirect-indirect- xmode)
4377 (src32-basic-operand QI)
4378 (src32-basic-operand HI)
4379 (src32-basic-operand SI)
4381 (define-anyof-operand
4382 (name src32-basic-ExtPrefixed-QI)
4383 (comment "m32c source operand of size QI with no additional fields")
4384 (attrs (machine 32))
4387 src32-Rn-direct-Prefixed-QI
4388 src32-An-indirect-Prefixed-QI
4392 ;-------------------------------------------------------------
4393 ; Source operands with additional fields at offset 16 bits
4394 ;-------------------------------------------------------------
4396 (define-pmacro (src16-16-operand xmode)
4398 (define-anyof-operand
4399 (name (.sym src16-16-8- xmode))
4400 (comment (.str "m16c source operand of size " xmode " with additional 8 bit fields at offset 16"))
4401 (attrs (machine 16))
4404 (.sym src16-16-8-An-relative- xmode)
4405 (.sym src16-16-8-SB-relative- xmode)
4406 (.sym src16-16-8-FB-relative- xmode)
4409 (define-anyof-operand
4410 (name (.sym src16-16-16- xmode))
4411 (comment (.str "m16c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4412 (attrs (machine 16))
4415 (.sym src16-16-16-An-relative- xmode)
4416 (.sym src16-16-16-SB-relative- xmode)
4417 (.sym src16-16-16-absolute- xmode)
4422 (src16-16-operand QI)
4423 (src16-16-operand HI)
4425 (define-pmacro (src32-16-operand xmode)
4427 (define-anyof-operand
4428 (name (.sym src32-16-8-Unprefixed- xmode))
4429 (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 16"))
4430 (attrs (machine 32))
4433 (.sym src32-16-8-An-relative-Unprefixed- xmode)
4434 (.sym src32-16-8-SB-relative-Unprefixed- xmode)
4435 (.sym src32-16-8-FB-relative-Unprefixed- xmode)
4438 (define-anyof-operand
4439 (name (.sym src32-16-16-Unprefixed- xmode))
4440 (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4441 (attrs (machine 32))
4444 (.sym src32-16-16-An-relative-Unprefixed- xmode)
4445 (.sym src32-16-16-SB-relative-Unprefixed- xmode)
4446 (.sym src32-16-16-FB-relative-Unprefixed- xmode)
4447 (.sym src32-16-16-absolute-Unprefixed- xmode)
4450 (define-anyof-operand
4451 (name (.sym src32-16-24-Unprefixed- xmode))
4452 (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16"))
4453 (attrs (machine 32))
4456 (.sym src32-16-24-An-relative-Unprefixed- xmode)
4457 (.sym src32-16-24-absolute-Unprefixed- xmode)
4463 (src32-16-operand QI)
4464 (src32-16-operand HI)
4465 (src32-16-operand SI)
4467 ;-------------------------------------------------------------
4468 ; Source operands with additional fields at offset 24 bits
4469 ;-------------------------------------------------------------
4471 (define-pmacro (src-24-operand group xmode)
4473 (define-anyof-operand
4474 (name (.sym src32-24-8- group - xmode))
4475 (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 24"))
4476 (attrs (machine 32))
4479 (.sym src32-24-8-An-relative- group - xmode)
4480 (.sym src32-24-8-SB-relative- group - xmode)
4481 (.sym src32-24-8-FB-relative- group - xmode)
4484 (define-anyof-operand
4485 (name (.sym src32-24-16- group - xmode))
4486 (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4487 (attrs (machine 32))
4490 (.sym src32-24-16-An-relative- group - xmode)
4491 (.sym src32-24-16-SB-relative- group - xmode)
4492 (.sym src32-24-16-FB-relative- group - xmode)
4493 (.sym src32-24-16-absolute- group - xmode)
4496 (define-anyof-operand
4497 (name (.sym src32-24-24- group - xmode))
4498 (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16"))
4499 (attrs (machine 32))
4502 (.sym src32-24-24-An-relative- group - xmode)
4503 (.sym src32-24-24-absolute- group - xmode)
4509 (src-24-operand Prefixed QI)
4510 (src-24-operand Prefixed HI)
4511 (src-24-operand Prefixed SI)
4513 (define-pmacro (src-24-indirect-operand xmode)
4515 ; (define-anyof-operand
4516 ; (name (.sym src32-24-8-indirect- xmode))
4517 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4518 ; (attrs (machine 32))
4521 ; (.sym src32-24-8-An-relative-indirect- xmode)
4522 ; (.sym src32-24-8-SB-relative-indirect- xmode)
4523 ; (.sym src32-24-8-FB-relative-indirect- xmode)
4526 ; (define-anyof-operand
4527 ; (name (.sym src32-24-16-indirect- xmode))
4528 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4529 ; (attrs (machine 32))
4532 ; (.sym src32-24-16-An-relative-indirect- xmode)
4533 ; (.sym src32-24-16-SB-relative-indirect- xmode)
4534 ; (.sym src32-24-16-FB-relative-indirect- xmode)
4537 ; (define-anyof-operand
4538 ; (name (.sym src32-24-24-indirect- xmode))
4539 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4540 ; (attrs (machine 32))
4543 ; (.sym src32-24-24-An-relative-indirect- xmode)
4546 ; (define-anyof-operand
4547 ; (name (.sym src32-24-16-absolute-indirect- xmode))
4548 ; (comment (.str "m32c source operand of size " xmode " 16 bit absolute indirect"))
4549 ; (attrs (machine 32))
4552 ; (.sym src32-24-16-absolute-indirect-derived- xmode)
4555 ; (define-anyof-operand
4556 ; (name (.sym src32-24-24-absolute-indirect- xmode))
4557 ; (comment (.str "m32c source operand of size " xmode " 24 bit absolute indirect"))
4558 ; (attrs (machine 32))
4561 ; (.sym src32-24-24-absolute-indirect-derived- xmode)
4567 ; (src-24-indirect-operand QI)
4568 ; (src-24-indirect-operand HI)
4569 ; (src-24-indirect-operand SI)
4571 ;-------------------------------------------------------------
4572 ; Destination operands with no additional fields
4573 ;-------------------------------------------------------------
4575 (define-pmacro (dst16-basic-operand xmode)
4577 (define-anyof-operand
4578 (name (.sym dst16-basic- xmode))
4579 (comment (.str "m16c destination operand of size " xmode " with no additional fields"))
4580 (attrs (machine 16))
4583 (.sym dst16-Rn-direct- xmode)
4584 (.sym dst16-An-direct- xmode)
4585 (.sym dst16-An-indirect- xmode)
4591 (dst16-basic-operand QI)
4592 (dst16-basic-operand HI)
4593 (dst16-basic-operand SI)
4595 (define-pmacro (dst32-basic-operand xmode)
4597 (define-anyof-operand
4598 (name (.sym dst32-basic-Unprefixed- xmode))
4599 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4600 (attrs (machine 32))
4603 (.sym dst32-Rn-direct-Unprefixed- xmode)
4604 (.sym dst32-An-direct-Unprefixed- xmode)
4605 (.sym dst32-An-indirect-Unprefixed- xmode)
4608 (define-anyof-operand
4609 (name (.sym dst32-basic-Prefixed- xmode))
4610 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4611 (attrs (machine 32))
4614 (.sym dst32-Rn-direct-Prefixed- xmode)
4615 (.sym dst32-An-direct-Prefixed- xmode)
4616 (.sym dst32-An-indirect-Prefixed- xmode)
4622 (dst32-basic-operand QI)
4623 (dst32-basic-operand HI)
4624 (dst32-basic-operand SI)
4626 ;-------------------------------------------------------------
4627 ; Destination operands with possible additional fields at offset 16 bits
4628 ;-------------------------------------------------------------
4630 (define-pmacro (dst16-16-operand xmode)
4632 (define-anyof-operand
4633 (name (.sym dst16-16- xmode))
4634 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4635 (attrs (machine 16))
4638 (.sym dst16-Rn-direct- xmode)
4639 (.sym dst16-An-direct- xmode)
4640 (.sym dst16-An-indirect- xmode)
4641 (.sym dst16-16-8-An-relative- xmode)
4642 (.sym dst16-16-16-An-relative- xmode)
4643 (.sym dst16-16-8-SB-relative- xmode)
4644 (.sym dst16-16-16-SB-relative- xmode)
4645 (.sym dst16-16-8-FB-relative- xmode)
4646 (.sym dst16-16-16-absolute- xmode)
4649 (define-anyof-operand
4650 (name (.sym dst16-16-8- xmode))
4651 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4652 (attrs (machine 16))
4655 (.sym dst16-16-8-An-relative- xmode)
4656 (.sym dst16-16-8-SB-relative- xmode)
4657 (.sym dst16-16-8-FB-relative- xmode)
4660 (define-anyof-operand
4661 (name (.sym dst16-16-16- xmode))
4662 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4663 (attrs (machine 16))
4666 (.sym dst16-16-16-An-relative- xmode)
4667 (.sym dst16-16-16-SB-relative- xmode)
4668 (.sym dst16-16-16-absolute- xmode)
4674 (dst16-16-operand QI)
4675 (dst16-16-operand HI)
4676 (dst16-16-operand SI)
4678 (define-anyof-operand
4679 (name dst16-16-Ext-QI)
4680 (comment "m16c destination operand of size QI for 'ext' insns with additional fields at offset 16")
4681 (attrs (machine 16))
4684 dst16-Rn-direct-Ext-QI
4685 dst16-An-indirect-Ext-QI
4686 dst16-16-8-An-relative-Ext-QI
4687 dst16-16-16-An-relative-Ext-QI
4688 dst16-16-8-SB-relative-Ext-QI
4689 dst16-16-16-SB-relative-Ext-QI
4690 dst16-16-8-FB-relative-Ext-QI
4691 dst16-16-16-absolute-Ext-QI
4695 (define-derived-operand
4696 (name dst16-An-indirect-Mova-HI)
4697 (comment "m16c addressof An indirect destination HI")
4701 (syntax "[$Dst16An]")
4702 (base-ifield f-12-4)
4703 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
4705 (andif (eq f-12-2 1) (eq f-14-1 1)))
4710 (define-derived-operand
4711 (name dst16-16-8-An-relative-Mova-HI)
4713 "m16c addressof dsp:8[An] relative destination HI")
4716 (args (Dst16An Dsp-16-u8))
4717 (syntax "${Dsp-16-u8}[$Dst16An]")
4718 (base-ifield f-12-4)
4720 (+ (f-12-2 2) (f-14-1 0) Dsp-16-u8 Dst16An))
4722 (andif (eq f-12-2 2) (eq f-14-1 0)))
4723 (getter (add Dsp-16-u8 Dst16An))
4726 (define-derived-operand
4727 (name dst16-16-16-An-relative-Mova-HI)
4729 "m16c addressof dsp:16[An] relative destination HI")
4732 (args (Dst16An Dsp-16-u16))
4733 (syntax "${Dsp-16-u16}[$Dst16An]")
4734 (base-ifield f-12-4)
4736 (+ (f-12-2 3) (f-14-1 0) Dsp-16-u16 Dst16An))
4738 (andif (eq f-12-2 3) (eq f-14-1 0)))
4739 (getter (add Dsp-16-u16 Dst16An))
4742 (define-derived-operand
4743 (name dst16-16-8-SB-relative-Mova-HI)
4745 "m16c addressof dsp:8[sb] relative destination HI")
4749 (syntax "${Dsp-16-u8}[sb]")
4750 (base-ifield f-12-4)
4751 (encoding (+ (f-12-4 10) Dsp-16-u8))
4752 (ifield-assertion (eq f-12-4 10))
4753 (getter (add Dsp-16-u8 (reg h-sb)))
4756 (define-derived-operand
4757 (name dst16-16-16-SB-relative-Mova-HI)
4759 "m16c addressof dsp:16[sb] relative destination HI")
4763 (syntax "${Dsp-16-u16}[sb]")
4764 (base-ifield f-12-4)
4765 (encoding (+ (f-12-4 14) Dsp-16-u16))
4766 (ifield-assertion (eq f-12-4 14))
4767 (getter (add Dsp-16-u16 (reg h-sb)))
4770 (define-derived-operand
4771 (name dst16-16-8-FB-relative-Mova-HI)
4773 "m16c addressof dsp:8[fb] relative destination HI")
4777 (syntax "${Dsp-16-s8}[fb]")
4778 (base-ifield f-12-4)
4779 (encoding (+ (f-12-4 11) Dsp-16-s8))
4780 (ifield-assertion (eq f-12-4 11))
4781 (getter (add Dsp-16-s8 (reg h-fb)))
4784 (define-derived-operand
4785 (name dst16-16-16-absolute-Mova-HI)
4786 (comment "m16c addressof absolute address HI")
4790 (syntax "${Dsp-16-u16}")
4791 (base-ifield f-12-4)
4792 (encoding (+ (f-12-4 15) Dsp-16-u16))
4793 (ifield-assertion (eq f-12-4 15))
4798 (define-anyof-operand
4799 (name dst16-16-Mova-HI)
4800 (comment "m16c addressof destination operand of size HI with additional fields at offset 16")
4801 (attrs (machine 16))
4804 dst16-An-indirect-Mova-HI
4805 dst16-16-8-An-relative-Mova-HI
4806 dst16-16-16-An-relative-Mova-HI
4807 dst16-16-8-SB-relative-Mova-HI
4808 dst16-16-16-SB-relative-Mova-HI
4809 dst16-16-8-FB-relative-Mova-HI
4810 dst16-16-16-absolute-Mova-HI
4814 (define-derived-operand
4815 (name dst32-An-indirect-Unprefixed-Mova-SI)
4816 (comment "m32c addressof An indirect destination SI")
4819 (args (Dst32AnUnprefixed))
4820 (syntax "[$Dst32AnUnprefixed]")
4823 (+ (f-4-3 0) (f-8-1 0) Dst32AnUnprefixed))
4825 (andif (eq f-4-3 0) (eq f-8-1 0)))
4826 (getter Dst32AnUnprefixed)
4830 (define-derived-operand
4831 (name dst32-16-8-An-relative-Unprefixed-Mova-SI)
4832 (comment "m32c addressof dsp:8[An] relative destination SI")
4835 (args (Dst32AnUnprefixed Dsp-16-u8))
4836 (syntax "${Dsp-16-u8}[$Dst32AnUnprefixed]")
4844 (andif (eq f-4-3 1) (eq f-8-1 0)))
4845 (getter (add Dsp-16-u8 Dst32AnUnprefixed))
4849 (define-derived-operand
4850 (name dst32-16-16-An-relative-Unprefixed-Mova-SI)
4852 "m32c addressof dsp:16[An] relative destination SI")
4855 (args (Dst32AnUnprefixed Dsp-16-u16))
4856 (syntax "${Dsp-16-u16}[$Dst32AnUnprefixed]")
4864 (andif (eq f-4-3 2) (eq f-8-1 0)))
4865 (getter (add Dsp-16-u16 Dst32AnUnprefixed))
4869 (define-derived-operand
4870 (name dst32-16-24-An-relative-Unprefixed-Mova-SI)
4871 (comment "addressof m32c dsp:16[An] relative destination SI")
4874 (args (Dst32AnUnprefixed Dsp-16-u24))
4875 (syntax "${Dsp-16-u24}[$Dst32AnUnprefixed]")
4883 (andif (eq f-4-3 3) (eq f-8-1 0)))
4884 (getter (add Dsp-16-u24 Dst32AnUnprefixed))
4888 (define-derived-operand
4889 (name dst32-16-8-SB-relative-Unprefixed-Mova-SI)
4890 (comment "m32c addressof dsp:8[sb] relative destination SI")
4894 (syntax "${Dsp-16-u8}[sb]")
4896 (encoding (+ (f-4-3 1) (f-8-2 2) Dsp-16-u8))
4898 (andif (eq f-4-3 1) (eq f-8-2 2)))
4899 (getter (add Dsp-16-u8 (reg h-sb)))
4903 (define-derived-operand
4904 (name dst32-16-16-SB-relative-Unprefixed-Mova-SI)
4905 (comment "m32c addressof dsp:16[sb] relative destination SI")
4909 (syntax "${Dsp-16-u16}[sb]")
4911 (encoding (+ (f-4-3 2) (f-8-2 2) Dsp-16-u16))
4913 (andif (eq f-4-3 2) (eq f-8-2 2)))
4914 (getter (add Dsp-16-u16 (reg h-sb)))
4918 (define-derived-operand
4919 (name dst32-16-8-FB-relative-Unprefixed-Mova-SI)
4920 (comment "m32c addressof dsp:8[fb] relative destination SI")
4924 (syntax "${Dsp-16-s8}[fb]")
4926 (encoding (+ (f-4-3 1) (f-8-2 3) Dsp-16-s8))
4928 (andif (eq f-4-3 1) (eq f-8-2 3)))
4929 (getter (add Dsp-16-s8 (reg h-fb)))
4933 (define-derived-operand
4934 (name dst32-16-16-FB-relative-Unprefixed-Mova-SI)
4935 (comment "m32c addressof dsp:16[fb] relative destination SI")
4939 (syntax "${Dsp-16-s16}[fb]")
4941 (encoding (+ (f-4-3 2) (f-8-2 3) Dsp-16-s16))
4943 (andif (eq f-4-3 2) (eq f-8-2 3)))
4944 (getter (add Dsp-16-s16 (reg h-fb)))
4948 (define-derived-operand
4949 (name dst32-16-16-absolute-Unprefixed-Mova-SI)
4950 (comment "m32c addressof absolute address SI") (attrs (ISA m32c))
4953 (syntax "${Dsp-16-u16}")
4955 (encoding (+ (f-4-3 3) (f-8-2 3) Dsp-16-u16))
4957 (andif (eq f-4-3 3) (eq f-8-2 3)))
4962 (define-derived-operand
4963 (name dst32-16-24-absolute-Unprefixed-Mova-SI)
4964 (comment "m32c addressof absolute address SI") (attrs (ISA m32c))
4967 (syntax "${Dsp-16-u24}")
4969 (encoding (+ (f-4-3 3) (f-8-2 2) Dsp-16-u24))
4971 (andif (eq f-4-3 3) (eq f-8-2 2)))
4976 (define-anyof-operand
4977 (name dst32-16-Unprefixed-Mova-SI)
4979 "m32c addressof destination operand of size SI with additional fields at offset 16")
4983 dst32-An-indirect-Unprefixed-Mova-SI
4984 dst32-16-8-An-relative-Unprefixed-Mova-SI
4985 dst32-16-16-An-relative-Unprefixed-Mova-SI
4986 dst32-16-24-An-relative-Unprefixed-Mova-SI
4987 dst32-16-8-SB-relative-Unprefixed-Mova-SI
4988 dst32-16-16-SB-relative-Unprefixed-Mova-SI
4989 dst32-16-8-FB-relative-Unprefixed-Mova-SI
4990 dst32-16-16-FB-relative-Unprefixed-Mova-SI
4991 dst32-16-16-absolute-Unprefixed-Mova-SI
4992 dst32-16-24-absolute-Unprefixed-Mova-SI))
4994 (define-pmacro (dst32-16-operand xmode)
4996 (define-anyof-operand
4997 (name (.sym dst32-16-Unprefixed- xmode))
4998 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
4999 (attrs (machine 32))
5002 (.sym dst32-Rn-direct-Unprefixed- xmode)
5003 (.sym dst32-An-direct-Unprefixed- xmode)
5004 (.sym dst32-An-indirect-Unprefixed- xmode)
5005 (.sym dst32-16-8-An-relative-Unprefixed- xmode)
5006 (.sym dst32-16-16-An-relative-Unprefixed- xmode)
5007 (.sym dst32-16-24-An-relative-Unprefixed- xmode)
5008 (.sym dst32-16-8-SB-relative-Unprefixed- xmode)
5009 (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
5010 (.sym dst32-16-8-FB-relative-Unprefixed- xmode)
5011 (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
5012 (.sym dst32-16-16-absolute-Unprefixed- xmode)
5013 (.sym dst32-16-24-absolute-Unprefixed- xmode)
5016 (define-anyof-operand
5017 (name (.sym dst32-16-8-Unprefixed- xmode))
5018 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5019 (attrs (machine 32))
5022 (.sym dst32-16-8-An-relative-Unprefixed- xmode)
5023 (.sym dst32-16-8-SB-relative-Unprefixed- xmode)
5024 (.sym dst32-16-8-FB-relative-Unprefixed- xmode)
5027 (define-anyof-operand
5028 (name (.sym dst32-16-16-Unprefixed- xmode))
5029 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5030 (attrs (machine 32))
5033 (.sym dst32-16-16-An-relative-Unprefixed- xmode)
5034 (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
5035 (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
5036 (.sym dst32-16-16-absolute-Unprefixed- xmode)
5039 (define-anyof-operand
5040 (name (.sym dst32-16-24-Unprefixed- xmode))
5041 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5042 (attrs (machine 32))
5045 (.sym dst32-16-24-An-relative-Unprefixed- xmode)
5046 (.sym dst32-16-24-absolute-Unprefixed- xmode)
5052 (dst32-16-operand QI)
5053 (dst32-16-operand HI)
5054 (dst32-16-operand SI)
5056 (define-pmacro (dst32-16-Ext-operand smode dmode)
5058 (define-anyof-operand
5059 (name (.sym dst32-16-ExtUnprefixed- smode))
5060 (comment (.str "m32c destination operand of size " smode " with additional fields at offset 16"))
5061 (attrs (machine 32))
5064 (.sym dst32-Rn-direct-ExtUnprefixed- smode)
5065 (.sym dst32-An-direct-Unprefixed- dmode) ; ExtUnprefixed mode not required for this operand -- use the normal dmode version
5066 (.sym dst32-An-indirect-ExtUnprefixed- smode)
5067 (.sym dst32-16-8-An-relative-ExtUnprefixed- smode)
5068 (.sym dst32-16-16-An-relative-ExtUnprefixed- smode)
5069 (.sym dst32-16-24-An-relative-ExtUnprefixed- smode)
5070 (.sym dst32-16-8-SB-relative-ExtUnprefixed- smode)
5071 (.sym dst32-16-16-SB-relative-ExtUnprefixed- smode)
5072 (.sym dst32-16-8-FB-relative-ExtUnprefixed- smode)
5073 (.sym dst32-16-16-FB-relative-ExtUnprefixed- smode)
5074 (.sym dst32-16-16-absolute-ExtUnprefixed- smode)
5075 (.sym dst32-16-24-absolute-ExtUnprefixed- smode)
5081 (dst32-16-Ext-operand QI HI)
5082 (dst32-16-Ext-operand HI SI)
5084 (define-anyof-operand
5085 (name dst32-16-Unprefixed-Mulex-HI)
5086 (comment "m32c destination operand of size HI with additional fields at offset 16")
5087 (attrs (machine 32))
5090 dst32-R3-direct-Unprefixed-HI
5091 dst32-An-direct-Unprefixed-HI
5092 dst32-An-indirect-Unprefixed-HI
5093 dst32-16-8-An-relative-Unprefixed-HI
5094 dst32-16-16-An-relative-Unprefixed-HI
5095 dst32-16-24-An-relative-Unprefixed-HI
5096 dst32-16-8-SB-relative-Unprefixed-HI
5097 dst32-16-16-SB-relative-Unprefixed-HI
5098 dst32-16-8-FB-relative-Unprefixed-HI
5099 dst32-16-16-FB-relative-Unprefixed-HI
5100 dst32-16-16-absolute-Unprefixed-HI
5101 dst32-16-24-absolute-Unprefixed-HI
5104 ;-------------------------------------------------------------
5105 ; Destination operands with possible additional fields at offset 24 bits
5106 ;-------------------------------------------------------------
5108 (define-pmacro (dst16-24-operand xmode)
5110 (define-anyof-operand
5111 (name (.sym dst16-24- xmode))
5112 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 24"))
5113 (attrs (machine 16))
5116 (.sym dst16-Rn-direct- xmode)
5117 (.sym dst16-An-direct- xmode)
5118 (.sym dst16-An-indirect- xmode)
5119 (.sym dst16-24-8-An-relative- xmode)
5120 (.sym dst16-24-16-An-relative- xmode)
5121 (.sym dst16-24-8-SB-relative- xmode)
5122 (.sym dst16-24-16-SB-relative- xmode)
5123 (.sym dst16-24-8-FB-relative- xmode)
5124 (.sym dst16-24-16-absolute- xmode)
5130 (dst16-24-operand QI)
5131 (dst16-24-operand HI)
5133 (define-pmacro (dst32-24-operand xmode)
5135 (define-anyof-operand
5136 (name (.sym dst32-24-Unprefixed- xmode))
5137 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5138 (attrs (machine 32))
5141 (.sym dst32-Rn-direct-Unprefixed- xmode)
5142 (.sym dst32-An-direct-Unprefixed- xmode)
5143 (.sym dst32-An-indirect-Unprefixed- xmode)
5144 (.sym dst32-24-8-An-relative-Unprefixed- xmode)
5145 (.sym dst32-24-16-An-relative-Unprefixed- xmode)
5146 (.sym dst32-24-24-An-relative-Unprefixed- xmode)
5147 (.sym dst32-24-8-SB-relative-Unprefixed- xmode)
5148 (.sym dst32-24-16-SB-relative-Unprefixed- xmode)
5149 (.sym dst32-24-8-FB-relative-Unprefixed- xmode)
5150 (.sym dst32-24-16-FB-relative-Unprefixed- xmode)
5151 (.sym dst32-24-16-absolute-Unprefixed- xmode)
5152 (.sym dst32-24-24-absolute-Unprefixed- xmode)
5155 (define-anyof-operand
5156 (name (.sym dst32-24-Prefixed- xmode))
5157 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5158 (attrs (machine 32))
5161 (.sym dst32-Rn-direct-Prefixed- xmode)
5162 (.sym dst32-An-direct-Prefixed- xmode)
5163 (.sym dst32-An-indirect-Prefixed- xmode)
5164 (.sym dst32-24-8-An-relative-Prefixed- xmode)
5165 (.sym dst32-24-16-An-relative-Prefixed- xmode)
5166 (.sym dst32-24-24-An-relative-Prefixed- xmode)
5167 (.sym dst32-24-8-SB-relative-Prefixed- xmode)
5168 (.sym dst32-24-16-SB-relative-Prefixed- xmode)
5169 (.sym dst32-24-8-FB-relative-Prefixed- xmode)
5170 (.sym dst32-24-16-FB-relative-Prefixed- xmode)
5171 (.sym dst32-24-16-absolute-Prefixed- xmode)
5172 (.sym dst32-24-24-absolute-Prefixed- xmode)
5175 (define-anyof-operand
5176 (name (.sym dst32-24-8-Prefixed- xmode))
5177 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5178 (attrs (machine 32))
5181 (.sym dst32-24-8-An-relative-Prefixed- xmode)
5182 (.sym dst32-24-8-SB-relative-Prefixed- xmode)
5183 (.sym dst32-24-8-FB-relative-Prefixed- xmode)
5186 (define-anyof-operand
5187 (name (.sym dst32-24-16-Prefixed- xmode))
5188 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5189 (attrs (machine 32))
5192 (.sym dst32-24-16-An-relative-Prefixed- xmode)
5193 (.sym dst32-24-16-SB-relative-Prefixed- xmode)
5194 (.sym dst32-24-16-FB-relative-Prefixed- xmode)
5195 (.sym dst32-24-16-absolute-Prefixed- xmode)
5198 (define-anyof-operand
5199 (name (.sym dst32-24-24-Prefixed- xmode))
5200 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5201 (attrs (machine 32))
5204 (.sym dst32-24-24-An-relative-Prefixed- xmode)
5205 (.sym dst32-24-24-absolute-Prefixed- xmode)
5208 ; (define-anyof-operand
5209 ; (name (.sym dst32-24-indirect- xmode))
5210 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5211 ; (attrs (machine 32))
5214 ; (.sym dst32-An-indirect-indirect- xmode)
5215 ; (.sym dst32-24-8-An-relative-indirect- xmode)
5216 ; (.sym dst32-24-16-An-relative-indirect- xmode)
5217 ; (.sym dst32-24-24-An-relative-indirect- xmode)
5218 ; (.sym dst32-24-8-SB-relative-indirect- xmode)
5219 ; (.sym dst32-24-16-SB-relative-indirect- xmode)
5220 ; (.sym dst32-24-8-FB-relative-indirect- xmode)
5221 ; (.sym dst32-24-16-FB-relative-indirect- xmode)
5224 ; (define-anyof-operand
5225 ; (name (.sym dst32-basic-indirect- xmode))
5226 ; (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
5227 ; (attrs (machine 32))
5230 ; (.sym dst32-An-indirect-indirect- xmode)
5233 ; (define-anyof-operand
5234 ; (name (.sym dst32-24-8-indirect- xmode))
5235 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5236 ; (attrs (machine 32))
5239 ; (.sym dst32-24-8-An-relative-indirect- xmode)
5240 ; (.sym dst32-24-8-SB-relative-indirect- xmode)
5241 ; (.sym dst32-24-8-FB-relative-indirect- xmode)
5244 ; (define-anyof-operand
5245 ; (name (.sym dst32-24-16-indirect- xmode))
5246 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5247 ; (attrs (machine 32))
5250 ; (.sym dst32-24-16-An-relative-indirect- xmode)
5251 ; (.sym dst32-24-16-SB-relative-indirect- xmode)
5252 ; (.sym dst32-24-16-FB-relative-indirect- xmode)
5255 ; (define-anyof-operand
5256 ; (name (.sym dst32-24-24-indirect- xmode))
5257 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5258 ; (attrs (machine 32))
5261 ; (.sym dst32-24-24-An-relative-indirect- xmode)
5264 ; (define-anyof-operand
5265 ; (name (.sym dst32-24-absolute-indirect- xmode))
5266 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5267 ; (attrs (machine 32))
5270 ; (.sym dst32-24-16-absolute-indirect-derived- xmode)
5271 ; (.sym dst32-24-24-absolute-indirect-derived- xmode)
5274 ; (define-anyof-operand
5275 ; (name (.sym dst32-24-16-absolute-indirect- xmode))
5276 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5277 ; (attrs (machine 32))
5280 ; (.sym dst32-24-16-absolute-indirect-derived- xmode)
5283 ; (define-anyof-operand
5284 ; (name (.sym dst32-24-24-absolute-indirect- xmode))
5285 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5286 ; (attrs (machine 32))
5289 ; (.sym dst32-24-24-absolute-indirect-derived- xmode)
5295 (dst32-24-operand QI)
5296 (dst32-24-operand HI)
5297 (dst32-24-operand SI)
5299 ;-------------------------------------------------------------
5300 ; Destination operands with possible additional fields at offset 32 bits
5301 ;-------------------------------------------------------------
5303 (define-pmacro (dst16-32-operand xmode)
5305 (define-anyof-operand
5306 (name (.sym dst16-32- xmode))
5307 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 32"))
5308 (attrs (machine 16))
5311 (.sym dst16-Rn-direct- xmode)
5312 (.sym dst16-An-direct- xmode)
5313 (.sym dst16-An-indirect- xmode)
5314 (.sym dst16-32-8-An-relative- xmode)
5315 (.sym dst16-32-16-An-relative- xmode)
5316 (.sym dst16-32-8-SB-relative- xmode)
5317 (.sym dst16-32-16-SB-relative- xmode)
5318 (.sym dst16-32-8-FB-relative- xmode)
5319 (.sym dst16-32-16-absolute- xmode)
5324 (dst16-32-operand QI)
5325 (dst16-32-operand HI)
5327 ; This macro actually handles operands at offset 32, 40 and 48 bits
5328 (define-pmacro (dst32-32plus-operand offset xmode)
5330 (define-anyof-operand
5331 (name (.sym dst32- offset -Unprefixed- xmode))
5332 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5333 (attrs (machine 32))
5336 (.sym dst32-Rn-direct-Unprefixed- xmode)
5337 (.sym dst32-An-direct-Unprefixed- xmode)
5338 (.sym dst32-An-indirect-Unprefixed- xmode)
5339 (.sym dst32- offset -8-An-relative-Unprefixed- xmode)
5340 (.sym dst32- offset -16-An-relative-Unprefixed- xmode)
5341 (.sym dst32- offset -24-An-relative-Unprefixed- xmode)
5342 (.sym dst32- offset -8-SB-relative-Unprefixed- xmode)
5343 (.sym dst32- offset -16-SB-relative-Unprefixed- xmode)
5344 (.sym dst32- offset -8-FB-relative-Unprefixed- xmode)
5345 (.sym dst32- offset -16-FB-relative-Unprefixed- xmode)
5346 (.sym dst32- offset -16-absolute-Unprefixed- xmode)
5347 (.sym dst32- offset -24-absolute-Unprefixed- xmode)
5350 (define-anyof-operand
5351 (name (.sym dst32- offset -Prefixed- xmode))
5352 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5353 (attrs (machine 32))
5356 (.sym dst32-Rn-direct-Prefixed- xmode)
5357 (.sym dst32-An-direct-Prefixed- xmode)
5358 (.sym dst32-An-indirect-Prefixed- xmode)
5359 (.sym dst32- offset -8-An-relative-Prefixed- xmode)
5360 (.sym dst32- offset -16-An-relative-Prefixed- xmode)
5361 (.sym dst32- offset -24-An-relative-Prefixed- xmode)
5362 (.sym dst32- offset -8-SB-relative-Prefixed- xmode)
5363 (.sym dst32- offset -16-SB-relative-Prefixed- xmode)
5364 (.sym dst32- offset -8-FB-relative-Prefixed- xmode)
5365 (.sym dst32- offset -16-FB-relative-Prefixed- xmode)
5366 (.sym dst32- offset -16-absolute-Prefixed- xmode)
5367 (.sym dst32- offset -24-absolute-Prefixed- xmode)
5370 ; (define-anyof-operand
5371 ; (name (.sym dst32- offset -indirect- xmode))
5372 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5373 ; (attrs (machine 32))
5376 ; (.sym dst32-An-indirect-indirect- xmode)
5377 ; (.sym dst32- offset -8-An-relative-indirect- xmode)
5378 ; (.sym dst32- offset -16-An-relative-indirect- xmode)
5379 ; (.sym dst32- offset -24-An-relative-indirect- xmode)
5380 ; (.sym dst32- offset -8-SB-relative-indirect- xmode)
5381 ; (.sym dst32- offset -16-SB-relative-indirect- xmode)
5382 ; (.sym dst32- offset -8-FB-relative-indirect- xmode)
5383 ; (.sym dst32- offset -16-FB-relative-indirect- xmode)
5386 ; (define-anyof-operand
5387 ; (name (.sym dst32- offset -absolute-indirect- xmode))
5388 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5389 ; (attrs (machine 32))
5392 ; (.sym dst32- offset -16-absolute-indirect-derived- xmode)
5393 ; (.sym dst32- offset -24-absolute-indirect-derived- xmode)
5399 (dst32-32plus-operand 32 QI)
5400 (dst32-32plus-operand 32 HI)
5401 (dst32-32plus-operand 32 SI)
5402 (dst32-32plus-operand 40 QI)
5403 (dst32-32plus-operand 40 HI)
5404 (dst32-32plus-operand 40 SI)
5406 ;-------------------------------------------------------------
5407 ; Destination operands with possible additional fields at offset 48 bits
5408 ;-------------------------------------------------------------
5410 (define-pmacro (dst32-48-operand offset xmode)
5412 (define-anyof-operand
5413 (name (.sym dst32- offset -Prefixed- xmode))
5414 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5415 (attrs (machine 32))
5418 (.sym dst32-Rn-direct-Prefixed- xmode)
5419 (.sym dst32-An-direct-Prefixed- xmode)
5420 (.sym dst32-An-indirect-Prefixed- xmode)
5421 (.sym dst32- offset -8-An-relative-Prefixed- xmode)
5422 (.sym dst32- offset -16-An-relative-Prefixed- xmode)
5423 (.sym dst32- offset -24-An-relative-Prefixed- xmode)
5424 (.sym dst32- offset -8-SB-relative-Prefixed- xmode)
5425 (.sym dst32- offset -16-SB-relative-Prefixed- xmode)
5426 (.sym dst32- offset -8-FB-relative-Prefixed- xmode)
5427 (.sym dst32- offset -16-FB-relative-Prefixed- xmode)
5428 (.sym dst32- offset -16-absolute-Prefixed- xmode)
5429 (.sym dst32- offset -24-absolute-Prefixed- xmode)
5432 ; (define-anyof-operand
5433 ; (name (.sym dst32- offset -indirect- xmode))
5434 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5435 ; (attrs (machine 32))
5438 ; (.sym dst32-An-indirect-indirect- xmode)
5439 ; (.sym dst32- offset -8-An-relative-indirect- xmode)
5440 ; (.sym dst32- offset -16-An-relative-indirect- xmode)
5441 ; (.sym dst32- offset -24-An-relative-indirect- xmode)
5442 ; (.sym dst32- offset -8-SB-relative-indirect- xmode)
5443 ; (.sym dst32- offset -16-SB-relative-indirect- xmode)
5444 ; (.sym dst32- offset -8-FB-relative-indirect- xmode)
5445 ; (.sym dst32- offset -16-FB-relative-indirect- xmode)
5448 ; (define-anyof-operand
5449 ; (name (.sym dst32- offset -absolute-indirect- xmode))
5450 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5451 ; (attrs (machine 32))
5454 ; (.sym dst32- offset -16-absolute-indirect-derived- xmode)
5455 ; (.sym dst32- offset -24-absolute-indirect-derived- xmode)
5461 (dst32-48-operand 48 QI)
5462 (dst32-48-operand 48 HI)
5463 (dst32-48-operand 48 SI)
5465 ;-------------------------------------------------------------
5466 ; Bit operands for m16c
5467 ;-------------------------------------------------------------
5469 (define-pmacro (bit16-operand offset)
5471 (define-anyof-operand
5472 (name (.sym bit16- offset))
5473 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5474 (attrs (machine 16))
5480 (.sym bit16- offset -8-An-relative)
5481 (.sym bit16- offset -16-An-relative)
5482 (.sym bit16- offset -8-SB-relative)
5483 (.sym bit16- offset -16-SB-relative)
5484 (.sym bit16- offset -8-FB-relative)
5485 (.sym bit16- offset -16-absolute)
5488 (define-anyof-operand
5489 (name (.sym bit16- offset -basic))
5490 (comment (.str "m16c bit operand with no additional fields"))
5491 (attrs (machine 16))
5497 (define-anyof-operand
5498 (name (.sym bit16- offset -8))
5499 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5500 (attrs (machine 16))
5505 (.sym bit16- offset -8-An-relative)
5506 (.sym bit16- offset -8-SB-relative)
5507 (.sym bit16- offset -8-FB-relative)
5510 (define-anyof-operand
5511 (name (.sym bit16- offset -16))
5512 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5513 (attrs (machine 16))
5516 (.sym bit16- offset -16-An-relative)
5517 (.sym bit16- offset -16-SB-relative)
5518 (.sym bit16- offset -16-absolute)
5526 ;-------------------------------------------------------------
5527 ; Bit operands for m32c
5528 ;-------------------------------------------------------------
5530 (define-pmacro (bit32-operand offset group)
5532 (define-anyof-operand
5533 (name (.sym bit32- offset - group))
5534 (comment (.str "m32c bit operand with possible additional fields at offset 24"))
5535 (attrs (machine 32))
5538 (.sym bit32-Rn-direct- group)
5539 (.sym bit32-An-direct- group)
5540 (.sym bit32-An-indirect- group)
5541 (.sym bit32- offset -11-An-relative- group)
5542 (.sym bit32- offset -19-An-relative- group)
5543 (.sym bit32- offset -27-An-relative- group)
5544 (.sym bit32- offset -11-SB-relative- group)
5545 (.sym bit32- offset -19-SB-relative- group)
5546 (.sym bit32- offset -11-FB-relative- group)
5547 (.sym bit32- offset -19-FB-relative- group)
5548 (.sym bit32- offset -19-absolute- group)
5549 (.sym bit32- offset -27-absolute- group)
5555 (bit32-operand 16 Unprefixed)
5556 (bit32-operand 24 Prefixed)
5558 (define-anyof-operand
5559 (name bit32-basic-Unprefixed)
5560 (comment "m32c bit operand with no additional fields")
5561 (attrs (machine 32))
5564 bit32-Rn-direct-Unprefixed
5565 bit32-An-direct-Unprefixed
5566 bit32-An-indirect-Unprefixed
5570 (define-anyof-operand
5571 (name bit32-16-8-Unprefixed)
5572 (comment "m32c bit operand with 8 bit additional fields")
5573 (attrs (machine 32))
5576 bit32-16-11-An-relative-Unprefixed
5577 bit32-16-11-SB-relative-Unprefixed
5578 bit32-16-11-FB-relative-Unprefixed
5582 (define-anyof-operand
5583 (name bit32-16-16-Unprefixed)
5584 (comment "m32c bit operand with 16 bit additional fields")
5585 (attrs (machine 32))
5588 bit32-16-19-An-relative-Unprefixed
5589 bit32-16-19-SB-relative-Unprefixed
5590 bit32-16-19-FB-relative-Unprefixed
5591 bit32-16-19-absolute-Unprefixed
5595 (define-anyof-operand
5596 (name bit32-16-24-Unprefixed)
5597 (comment "m32c bit operand with 24 bit additional fields")
5598 (attrs (machine 32))
5601 bit32-16-27-An-relative-Unprefixed
5602 bit32-16-27-absolute-Unprefixed
5606 ;-------------------------------------------------------------
5607 ; Operands for short format binary insns
5608 ;-------------------------------------------------------------
5610 (define-anyof-operand
5612 (comment "m16c source operand of size QI for short format insns")
5613 (attrs (machine 16))
5616 src16-2-S-8-SB-relative-QI
5617 src16-2-S-8-FB-relative-QI
5618 src16-2-S-16-absolute-QI
5622 (define-anyof-operand
5624 (comment "m32c source operand of size QI for short format insns")
5625 (attrs (machine 32))
5628 src32-2-S-8-SB-relative-QI
5629 src32-2-S-8-FB-relative-QI
5630 src32-2-S-16-absolute-QI
5634 (define-anyof-operand
5636 (comment "m32c source operand of size QI for short format insns")
5637 (attrs (machine 32))
5640 src32-2-S-8-SB-relative-HI
5641 src32-2-S-8-FB-relative-HI
5642 src32-2-S-16-absolute-HI
5646 (define-anyof-operand
5648 (comment "m16c destination operand of size QI for short format insns")
5649 (attrs (machine 16))
5652 dst16-3-S-R0l-direct-QI
5653 dst16-3-S-R0h-direct-QI
5654 dst16-3-S-8-8-SB-relative-QI
5655 dst16-3-S-8-8-FB-relative-QI
5656 dst16-3-S-8-16-absolute-QI
5660 (define-anyof-operand
5662 (comment "m16c destination operand of size QI for short format insns")
5663 (attrs (machine 16))
5666 dst16-3-S-R0l-direct-QI
5667 dst16-3-S-R0h-direct-QI
5668 dst16-3-S-16-8-SB-relative-QI
5669 dst16-3-S-16-8-FB-relative-QI
5670 dst16-3-S-16-16-absolute-QI
5674 (define-anyof-operand
5675 (name srcdst16-r0l-r0h-S)
5676 (comment "m16c r0l/r0h operand of size QI for short format insns")
5677 (attrs (machine 16))
5680 srcdst16-r0l-r0h-S-derived
5684 (define-anyof-operand
5685 (name dst32-2-S-basic-QI)
5686 (comment "m32c r0l operand of size QI for short format binary insns")
5687 (attrs (machine 32))
5690 dst32-2-S-R0l-direct-QI
5694 (define-anyof-operand
5695 (name dst32-2-S-basic-HI)
5696 (comment "m32c r0 operand of size HI for short format binary insns")
5697 (attrs (machine 32))
5700 dst32-2-S-R0-direct-HI
5704 (define-pmacro (dst32-2-S-operands xmode)
5706 (define-anyof-operand
5707 (name (.sym dst32-2-S-8- xmode))
5708 (comment "m32c operand of size " xmode " for short format binary insns")
5709 (attrs (machine 32))
5712 (.sym dst32-2-S-8-SB-relative- xmode)
5713 (.sym dst32-2-S-8-FB-relative- xmode)
5716 (define-anyof-operand
5717 (name (.sym dst32-2-S-16- xmode))
5718 (comment "m32c operand of size " xmode " for short format binary insns")
5719 (attrs (machine 32))
5722 (.sym dst32-2-S-16-absolute- xmode)
5725 ; (define-anyof-operand
5726 ; (name (.sym dst32-2-S-8-indirect- xmode))
5727 ; (comment "m32c operand of size " xmode " for short format binary insns")
5728 ; (attrs (machine 32))
5731 ; (.sym dst32-2-S-8-SB-relative-indirect- xmode)
5732 ; (.sym dst32-2-S-8-FB-relative-indirect- xmode)
5735 ; (define-anyof-operand
5736 ; (name (.sym dst32-2-S-absolute-indirect- xmode))
5737 ; (comment "m32c operand of size " xmode " for short format binary insns")
5738 ; (attrs (machine 32))
5741 ; (.sym dst32-2-S-16-absolute-indirect- xmode)
5747 (dst32-2-S-operands QI)
5748 (dst32-2-S-operands HI)
5749 (dst32-2-S-operands SI)
5751 (define-anyof-operand
5753 (comment "m32c An operand for short format binary insns")
5754 (attrs (machine 32))
5757 dst32-1-S-A0-direct-HI
5758 dst32-1-S-A1-direct-HI
5762 (define-anyof-operand
5764 (comment "m16c bit operand for short format insns")
5765 (attrs (machine 16))
5768 bit16-11-SB-relative-S
5772 (define-anyof-operand
5773 (name Rn16-push-S-anyof)
5774 (comment "m16c bit operand for short format insns")
5775 (attrs (machine 16))
5782 (define-anyof-operand
5783 (name An16-push-S-anyof)
5784 (comment "m16c bit operand for short format insns")
5785 (attrs (machine 16))
5792 ;=============================================================
5793 ; Common macros for instruction definitions
5795 (define-pmacro (set-z x)
5797 (set zbit (zflag x)))
5801 (define-pmacro (set-s x)
5803 (set sbit (nflag x)))
5806 (define-pmacro (set-z-and-s x)
5812 ;=============================================================
5814 ;-------------------------------------------------------------
5816 (define-pmacro (unary-insn-defn mach group mode wstr op encoding sem)
5817 (dni (.sym op mach wstr - group)
5818 (.str op wstr " dst" mach "-" group "-" mode)
5820 (.str op wstr " ${dst" mach "-" group "-" mode "}")
5822 (sem mode (.sym dst mach - group - mode))
5827 (define-pmacro (unary16-defn mode wstr wbit op opc1 opc2 opc3 sem)
5828 (unary-insn-defn 16 16 mode wstr op
5829 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16- mode))
5833 (define-pmacro (unary32-defn mode wstr wbit op opc1 opc2 opc3 sem)
5835 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
5836 ; define the absolute-indirect insns first in order to prevent them from being selected
5837 ; when the mode is register-indirect
5838 ; (unary-insn-defn 32 24-absolute-indirect mode wstr op
5839 ; (+ (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))
5841 (unary-insn-defn 32 16-Unprefixed mode wstr op
5842 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3))
5844 ; (unary-insn-defn 32 24-indirect mode wstr op
5845 ; (+ (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))
5850 (define-pmacro (unary-insn-mach mach op opc1 opc2 opc3 sem)
5852 (.apply (.sym unary mach -defn) (QI .b 0 op opc1 opc2 opc3 sem))
5853 (.apply (.sym unary mach -defn) (HI .w 1 op opc1 opc2 opc3 sem))
5857 (define-pmacro (unary-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
5859 (unary-insn-mach 16 op opc16-1 opc16-2 opc16-3 sem)
5860 (unary-insn-mach 32 op opc32-1 opc32-2 opc32-3 sem)
5864 ;-------------------------------------------------------------
5865 ; Sign/zero extension macros
5866 ;-------------------------------------------------------------
5868 (define-pmacro (ext-insn-defn mach group smode dmode wstr op encoding sem)
5869 (dni (.sym op mach wstr - group)
5870 (.str op wstr " dst" mach "-" group "-" smode)
5872 (.str op wstr " ${dst" mach "-" group "-" smode "}")
5874 (sem smode dmode (.sym dst mach - group - smode) (.sym dst mach - group - smode))
5878 (define-pmacro (ext16-defn smode dmode wstr wbit op opc1 opc2 opc3 sem)
5879 (ext-insn-defn 16 16-Ext smode dmode wstr op
5880 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-Ext- smode))
5884 (define-pmacro (ext32-defn smode dmode wstr wbit op opc1 opc2 opc3 sem)
5885 (ext-insn-defn 32 16-ExtUnprefixed smode dmode wstr op
5886 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst32-16-ExtUnprefixed- smode))
5890 (define-pmacro (ext32-binary-insn src-group dst-group op wstr encoding sem)
5891 (dni (.sym op 32 wstr - src-group - dst-group)
5892 (.str op 32 wstr " src32-" src-group "-QI,dst32-" dst-group "-HI")
5894 (.str op wstr " ${src32-" src-group "-QI},${dst32-" dst-group "-HI}")
5896 (sem QI HI (.sym src32- src-group -QI) (.sym dst32 - dst-group -HI))
5900 (define-pmacro (ext32-binary-defn op wstr opc1 opc2 sem)
5902 (ext32-binary-insn basic-ExtPrefixed 24-Prefixed op wstr
5903 (+ (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))
5905 (ext32-binary-insn 24-24-Prefixed 48-Prefixed op wstr
5906 (+ (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))
5908 (ext32-binary-insn 24-16-Prefixed 40-Prefixed op wstr
5909 (+ (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))
5911 (ext32-binary-insn 24-8-Prefixed 32-Prefixed op wstr
5912 (+ (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))
5917 ;=============================================================
5918 ; Binary Arithmetic macros
5920 ;-------------------------------------------------------------
5921 ;<arith>.size:S src2,r0[l] -- for m32c
5922 ;-------------------------------------------------------------
5924 (define-pmacro (binary-arith32-S-src2 op xmode wstr wbit opc1 opc2 sem)
5925 (dni (.sym op 32 wstr .S-src2-r0- xmode)
5926 (.str op 32 wstr ":S src2,r0[l]")
5928 (.str op wstr"$S ${src32-2-S-" xmode "},${Dst32R0" xmode "-S}")
5929 (+ opc1 opc2 (.sym src32-2-S- xmode) (f-7-1 wbit))
5930 (sem xmode (.sym src32-2-S- xmode) (.sym Dst32R0 xmode -S))
5934 ;-------------------------------------------------------------
5935 ;<arith>.b:S src2,r0l/r0h -- for m16c
5936 ;-------------------------------------------------------------
5938 (define-pmacro (binary-arith16-b-S-src2 op opc1 opc2 sem)
5940 (dni (.sym op 16 .b.S-src2)
5941 (.str op ".b:S src2,r0[lh]")
5943 (.str op ".b$S ${src16-2-S},${Dst16RnQI-S}")
5944 (+ opc1 opc2 Dst16RnQI-S src16-2-S)
5945 (sem QI src16-2-S Dst16RnQI-S)
5947 (dni (.sym op 16 .b.S-r0l-r0h)
5948 (.str op ".b:S r0l/r0h")
5950 (.str op ".b$S ${srcdst16-r0l-r0h-S}")
5951 (+ opc1 opc2 srcdst16-r0l-r0h-S)
5952 (if (eq srcdst16-r0l-r0h-S 0)
5959 ;-------------------------------------------------------------
5960 ;<arith>.b:S #imm8,dst3 -- for m16c
5961 ;-------------------------------------------------------------
5963 (define-pmacro (binary-arith16-b-S-imm8-dst3 op sz opc1 opc2 sem)
5964 (dni (.sym op 16 .b.S-imm8-dst3)
5965 (.str op sz ":S imm8,dst3")
5967 (.str op sz "$S #${Imm-8-QI},${Dst16-3-S-16}")
5968 (+ opc1 opc2 Dst16-3-S-16 Imm-8-QI)
5969 (sem QI Imm-8-QI Dst16-3-S-16)
5973 ;-------------------------------------------------------------
5974 ;<arith>.size:Q #imm4,sp -- for m16c
5975 ;-------------------------------------------------------------
5977 (define-pmacro (binary-arith16-Q-sp op opc1 opc2 opc3 sem)
5978 (dni (.sym op 16 -Q-sp)
5979 (.str op ":Q #imm4,sp")
5981 (.str op "${size}$Q #${Imm-12-s4},sp")
5982 (+ opc1 opc2 opc3 Imm-12-s4)
5983 (sem QI Imm-12-s4 sp)
5987 ;-------------------------------------------------------------
5988 ;<arith>.size:G #imm,sp -- for m16c
5989 ;-------------------------------------------------------------
5991 (define-pmacro (binary-arith16-G-sp-defn mode wstr wbit op opc1 opc2 opc3 opc4 sem)
5992 (dni (.sym op 16 wstr - G-sp)
5993 (.str op wstr " imm-sp " mode)
5995 (.str op wstr "$G #${Imm-16-" mode "},sp")
5996 (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16- mode))
5997 (sem mode (.sym Imm-16- mode) sp)
6001 (define-pmacro (binary-arith16-G-sp op opc1 opc2 opc3 opc4 sem)
6003 (binary-arith16-G-sp-defn QI .b 0 op opc1 opc2 opc3 opc4 sem)
6004 (binary-arith16-G-sp-defn HI .w 1 op opc1 opc2 opc3 opc4 sem)
6008 ;-------------------------------------------------------------
6009 ;<arith>.size:G #imm,dst -- for m16c and m32c
6010 ;-------------------------------------------------------------
6012 (define-pmacro (binary-arith-imm-dst-defn mach src dstgroup dmode wstr op suffix encoding sem)
6013 (dni (.sym op mach wstr - imm-G - dstgroup)
6014 (.str op wstr " " mach "-imm-G-" dstgroup "-" dmode)
6016 (.str op wstr "$"suffix " #${" src "},${dst" mach "-" dstgroup "-" dmode "}")
6018 (sem dmode src (.sym dst mach - dstgroup - dmode))
6023 (define-pmacro (binary-arith16-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6025 (binary-arith-imm-dst-defn 16 (.sym Imm-32- smode) 16-16 dmode wstr op suffix
6026 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- dmode) (.sym Imm-32- smode))
6028 (binary-arith-imm-dst-defn 16 (.sym Imm-24- smode) 16-8 dmode wstr op suffix
6029 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- dmode) (.sym Imm-24- smode))
6031 (binary-arith-imm-dst-defn 16 (.sym Imm-16- smode) basic dmode wstr op suffix
6032 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- dmode) (.sym Imm-16- smode))
6037 ; m32c Unprefixed variants
6038 (define-pmacro (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6040 (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 16-24-Unprefixed dmode wstr op suffix
6041 (+ (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))
6043 (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 16-16-Unprefixed dmode wstr op suffix
6044 (+ (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))
6046 (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) 16-8-Unprefixed dmode wstr op suffix
6047 (+ (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))
6049 (binary-arith-imm-dst-defn 32 (.sym Imm-16- smode) basic-Unprefixed dmode wstr op suffix
6050 (+ (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))
6055 ; m32c Prefixed variants
6056 (define-pmacro (binary-arith32-imm-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6058 (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-Prefixed dmode wstr op suffix
6059 (+ (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))
6061 (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-Prefixed dmode wstr op suffix
6062 (+ (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))
6064 (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-Prefixed dmode wstr op suffix
6065 (+ (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))
6067 (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-Prefixed dmode wstr op suffix
6068 (+ (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))
6074 (define-pmacro (binary-arith32-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6076 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6077 ; define the absolute-indirect insns first in order to prevent them from being selected
6078 ; when the mode is register-indirect
6079 ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-absolute-indirect dmode wstr op suffix
6080 ; (+ (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))
6082 ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-absolute-indirect dmode wstr op suffix
6083 ; (+ (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))
6085 ; Unprefixed modes next
6086 (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6088 ; Remaining indirect modes
6089 ; (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-indirect dmode wstr op suffix
6090 ; (+ (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))
6092 ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-indirect dmode wstr op suffix
6093 ; (+ (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))
6095 ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-indirect dmode wstr op suffix
6096 ; (+ (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))
6098 ; (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-indirect dmode wstr op suffix
6099 ; (+ (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))
6104 (define-pmacro (binary-arith-imm-dst-mach mach op suffix opc1 opc2 opc3 sem)
6106 (.apply (.sym binary-arith mach -imm-dst-defn) (QI QI .b 0 op suffix opc1 opc2 opc3 sem))
6107 (.apply (.sym binary-arith mach -imm-dst-defn) (HI HI .w 1 op suffix opc1 opc2 opc3 sem))
6111 (define-pmacro (binary-arith-imm-dst op suffix opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6113 (binary-arith-imm-dst-mach 16 op suffix opc16-1 opc16-2 opc16-3 sem)
6114 (binary-arith-imm-dst-mach 32 op suffix opc32-1 opc32-2 opc32-3 sem)
6118 ;-------------------------------------------------------------
6119 ;<arith>.size:Q #imm4,dst -- for m16c and m32c
6120 ;-------------------------------------------------------------
6122 (define-pmacro (binary-arith-imm4-dst-defn mach src dstgroup mode wstr op encoding sem)
6123 (dni (.sym op mach wstr - imm4-Q - dstgroup)
6124 (.str op wstr " " mach "-imm4-Q-" dstgroup "-" mode)
6126 (.str op wstr "$Q #${" src "},${dst" mach "-" dstgroup "-" mode "}")
6128 (sem mode src (.sym dst mach - dstgroup - mode))
6133 (define-pmacro (binary-arith16-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6134 (binary-arith-imm4-dst-defn 16 Imm-8-s4 16 mode wstr op
6135 (+ opc1 opc2 (f-7-1 wbit2) Imm-8-s4 (.sym dst16-16- mode))
6139 (define-pmacro (binary-arith16-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6140 (binary-arith-imm4-dst-defn 16 Imm-sh-8-s4 16 mode wstr op
6141 (+ opc1 opc2 (f-7-1 wbit2) Imm-sh-8-s4 (.sym dst16-16- mode))
6146 (define-pmacro (binary-arith32-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6148 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6149 ; define the absolute-indirect insns first in order to prevent them from being selected
6150 ; when the mode is register-indirect
6151 ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-absolute-indirect mode wstr op
6152 ; (+ (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)
6154 (binary-arith-imm4-dst-defn 32 Imm-12-s4 16-Unprefixed mode wstr op
6155 (+ (f-0-3 opc1) (f-3-1 wbit1) (f-7-1 wbit2) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) Imm-12-s4)
6157 ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-indirect mode wstr op
6158 ; (+ (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)
6163 (define-pmacro (binary-arith32-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6165 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6166 ; define the absolute-indirect insns first in order to prevent them from being selected
6167 ; when the mode is register-indirect
6168 ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-absolute-indirect mode wstr op
6169 ; (+ (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)
6171 (binary-arith-imm4-dst-defn 32 Imm-sh-12-s4 16-Unprefixed mode wstr op
6172 (+ (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)
6174 ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-indirect mode wstr op
6175 ; (+ (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)
6180 (define-pmacro (binary-arith-imm4-dst-mach mach op opc1 opc2 sem)
6182 (.apply (.sym binary-arith mach -imm4-dst-defn) (QI .b 0 0 op opc1 opc2 sem))
6183 (.apply (.sym binary-arith mach -imm4-dst-defn) (HI .w 0 1 op opc1 opc2 sem))
6187 (define-pmacro (binary-arith-imm4-dst op opc16-1 opc16-2 opc32-1 opc32-2 sem)
6189 (binary-arith-imm4-dst-mach 16 op opc16-1 opc16-2 sem)
6190 (binary-arith-imm4-dst-mach 32 op opc32-1 opc32-2 sem)
6194 ;-------------------------------------------------------------
6195 ;<arith>.size:G src,dst -- for m16c and m32c
6196 ;-------------------------------------------------------------
6198 (define-pmacro (binary-arith-src-dst-defn mach srcgroup dstgroup smode dmode wstr op suffix encoding sem)
6199 (dni (.sym op mach wstr - srcgroup - dstgroup)
6200 (.str op wstr " dst" mach "-" srcgroup "-" dstgroup "-" dmode)
6202 (.str op wstr "$" suffix " ${src" mach "-" srcgroup "-" smode "},${dst" mach "-" dstgroup "-" dmode "}")
6204 (sem dmode (.sym src mach - srcgroup - smode) (.sym dst mach - dstgroup - dmode))
6209 (define-pmacro (binary-arith16-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem)
6211 (binary-arith-src-dst-defn 16 basic 16 smode dmode wstr op suffix
6212 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-basic- smode) (.sym dst16-16- dmode))
6214 (binary-arith-src-dst-defn 16 16-16 32 smode dmode wstr op suffix
6215 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-16- smode) (.sym dst16-32- dmode))
6217 (binary-arith-src-dst-defn 16 16-8 24 smode dmode wstr op suffix
6218 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-8- smode) (.sym dst16-24- dmode))
6223 ; m32c Prefixed variants
6224 (define-pmacro (binary-arith32-src-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 sem)
6226 (binary-arith-src-dst-defn 32 basic-Prefixed 24-Prefixed smode dmode wstr op suffix
6227 (+ (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))
6229 (binary-arith-src-dst-defn 32 24-24-Prefixed 48-Prefixed smode dmode wstr op suffix
6230 (+ (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))
6232 (binary-arith-src-dst-defn 32 24-16-Prefixed 40-Prefixed smode dmode wstr op suffix
6233 (+ (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))
6235 (binary-arith-src-dst-defn 32 24-8-Prefixed 32-Prefixed smode dmode wstr op suffix
6236 (+ (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))
6242 (define-pmacro (binary-arith32-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem)
6244 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6245 ; define the absolute-indirect insns first in order to prevent them from being selected
6246 ; when the mode is register-indirect
6247 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-absolute-indirect smode dmode wstr op suffix
6248 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6249 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6251 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-absolute-indirect smode dmode wstr op suffix
6252 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6253 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6255 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-Prefixed smode dmode wstr op suffix
6256 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6257 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
6259 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-Prefixed smode dmode wstr op suffix
6260 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6261 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
6263 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-indirect smode dmode wstr op suffix
6264 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6265 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6267 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-indirect smode dmode wstr op suffix
6268 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6269 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6271 ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-absolute-indirect smode dmode wstr op suffix
6272 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6273 ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2))
6275 ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-absolute-indirect smode dmode wstr op suffix
6276 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6277 ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6279 ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-absolute-indirect smode dmode wstr op suffix
6280 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6281 ; (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6283 ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-absolute-indirect smode dmode wstr op suffix
6284 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6285 ; (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2))
6287 ; (binary-arith-src-dst-defn 32 basic-indirect 24-absolute-indirect smode dmode wstr op suffix
6288 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6289 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2))
6291 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-absolute-indirect smode dmode wstr op suffix
6292 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6293 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6295 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-absolute-indirect smode dmode wstr op suffix
6296 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6297 ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6299 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-absolute-indirect smode dmode wstr op suffix
6300 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6301 ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2))
6303 (binary-arith-src-dst-defn 32 basic-Unprefixed 16-Unprefixed smode dmode wstr op suffix
6304 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-basic-Unprefixed- smode) (.sym dst32-16-Unprefixed- dmode) (f-12-4 opc2))
6306 (binary-arith-src-dst-defn 32 16-24-Unprefixed 40-Unprefixed smode dmode wstr op suffix
6307 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-24-Unprefixed- smode) (.sym dst32-40-Unprefixed- dmode) (f-12-4 opc2))
6309 (binary-arith-src-dst-defn 32 16-16-Unprefixed 32-Unprefixed smode dmode wstr op suffix
6310 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-16-Unprefixed- smode) (.sym dst32-32-Unprefixed- dmode) (f-12-4 opc2))
6312 (binary-arith-src-dst-defn 32 16-8-Unprefixed 24-Unprefixed smode dmode wstr op suffix
6313 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-8-Unprefixed- smode) (.sym dst32-24-Unprefixed- dmode) (f-12-4 opc2))
6315 ; (binary-arith-src-dst-defn 32 basic-indirect 24-Prefixed smode dmode wstr op suffix
6316 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6317 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-Prefixed- dmode) (f-20-4 opc2))
6319 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-Prefixed smode dmode wstr op suffix
6320 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6321 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
6323 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-Prefixed smode dmode wstr op suffix
6324 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6325 ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
6327 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-Prefixed smode dmode wstr op suffix
6328 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6329 ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-Prefixed- dmode) (f-20-4 opc2))
6331 ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-indirect smode dmode wstr op suffix
6332 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6333 ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2))
6335 ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-indirect smode dmode wstr op suffix
6336 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6337 ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6339 ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-indirect smode dmode wstr op suffix
6340 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6341 ; (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6343 ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-indirect smode dmode wstr op suffix
6344 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6345 ; (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2))
6347 ; (binary-arith-src-dst-defn 32 basic-indirect 24-indirect smode dmode wstr op suffix
6348 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6349 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2))
6351 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-indirect smode dmode wstr op suffix
6352 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6353 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6355 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-indirect smode dmode wstr op suffix
6356 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6357 ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6359 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-indirect smode dmode wstr op suffix
6360 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6361 ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2))
6366 (define-pmacro (binary-arith-src-dst-mach mach op suffix opc1 opc2 sem)
6368 (.apply (.sym binary-arith mach -src-dst-defn) (QI QI .b 0 op suffix opc1 opc2 sem))
6369 (.apply (.sym binary-arith mach -src-dst-defn) (HI HI .w 1 op suffix opc1 opc2 sem))
6373 (define-pmacro (binary-arith-src-dst op suffix opc16-1 opc16-2 opc32-1 opc32-2 sem)
6375 (binary-arith-src-dst-mach 16 op suffix opc16-1 opc16-2 sem)
6376 (binary-arith-src-dst-mach 32 op suffix opc32-1 opc32-2 sem)
6380 ;-------------------------------------------------------------
6381 ;<arith>.size:S #imm,dst -- for m32c
6382 ;-------------------------------------------------------------
6384 (define-pmacro (binary-arith32-s-imm-dst-defn src dstgroup mode wstr op encoding sem)
6385 (dni (.sym op 32 wstr - imm-S - dstgroup)
6386 (.str op wstr " 32-imm-S-" dstgroup "-" mode)
6388 (.str op wstr "$S #${" src "},${dst32-" dstgroup "-" mode "}")
6390 (sem mode src (.sym dst32- dstgroup - mode))
6394 (define-pmacro (binary-arith32-z-imm-dst-defn src dstgroup mode wstr op encoding sem)
6395 (dni (.sym op 32 wstr - imm-Z - dstgroup)
6396 (.str op wstr " 32-imm-Z-" dstgroup "-" mode)
6398 (.str op wstr "$Z #0,${dst32-" dstgroup "-" mode "}")
6400 (sem mode (const 0) (.sym dst32- dstgroup - mode))
6404 (define-pmacro (binary-arith32-s-imm-dst mode wstr wbit op opc1 opc2 sem)
6406 ; (binary-arith32-s-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op
6407 ; (+ (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))
6409 (binary-arith32-s-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op
6410 (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-8- mode))
6412 (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op
6413 (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-24- mode))
6415 (binary-arith32-s-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op
6416 (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-16- mode))
6418 ; (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op
6419 ; (+ (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))
6424 (define-pmacro (binary-arith32-z-imm-dst mode wstr wbit op opc1 opc2 sem)
6426 ; (binary-arith32-z-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op
6427 ; (+ (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))
6429 (binary-arith32-z-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op
6430 (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit))
6432 (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op
6433 (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit))
6435 (binary-arith32-z-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op
6436 (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit))
6438 ; (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op
6439 ; (+ (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))
6444 ;-------------------------------------------------------------
6445 ;<arith>.L:S #imm1,An -- for m32c
6446 ;-------------------------------------------------------------
6448 (define-pmacro (binary-arith32-l-s-imm1-an op opc1 opc2 sem)
6450 (dni (.sym op 32.l-s-imm1-S-an)
6451 (.str op ".l 32-imm1-S-an")
6453 (.str op ".l$S #${Imm1-S},${dst32-an-S}")
6454 (+ opc1 Imm1-S opc2 dst32-an-S)
6455 (sem SI Imm1-S dst32-an-S)
6460 ;-------------------------------------------------------------
6461 ;<arith>.L:Q #imm3,sp -- for m32c
6462 ;-------------------------------------------------------------
6464 (define-pmacro (binary-arith32-l-q-imm3-sp op opc1 opc2 sem)
6466 (dni (.sym op 32.l-imm3-Q)
6467 (.str op ".l 32-imm3-Q")
6469 (.str op ".l$Q #${Imm3-S},sp")
6470 (+ opc1 Imm3-S opc2)
6476 ;-------------------------------------------------------------
6477 ;<arith>.L:S #imm8,sp -- for m32c
6478 ;-------------------------------------------------------------
6480 (define-pmacro (binary-arith32-l-s-imm8-sp op opc1 opc2 opc3 opc4 sem)
6482 (dni (.sym op 32.l-imm8-S)
6483 (.str op ".l 32-imm8-S")
6485 (.str op ".l$S #${Imm-16-QI},sp")
6486 (+ opc1 opc2 opc3 opc4 Imm-16-QI)
6487 (sem SI Imm-16-QI sp)
6492 ;-------------------------------------------------------------
6493 ;<arith>.L:G #imm16,sp -- for m32c
6494 ;-------------------------------------------------------------
6496 (define-pmacro (binary-arith32-l-g-imm16-sp op opc1 opc2 opc3 opc4 sem)
6498 (dni (.sym op 32.l-imm16-G)
6499 (.str op ".l 32-imm16-G")
6501 (.str op ".l$G #${Imm-16-HI},sp")
6502 (+ opc1 opc2 opc3 opc4 Imm-16-HI)
6503 (sem SI Imm-16-HI sp)
6508 ;-------------------------------------------------------------
6509 ;<arith>jnz.size #imm4,dst,label -- for m16c and m32c
6510 ;-------------------------------------------------------------
6512 (define-pmacro (arith-jnz-imm4-dst-defn mach src dstgroup label mode wstr op encoding sem)
6513 (dni (.sym op mach wstr - imm4 - dstgroup)
6514 (.str op wstr " " mach "-imm4-" dstgroup "-" label "-" mode)
6516 (.str op wstr " #${" src "},${dst" mach "-" dstgroup "-" mode "},${" label "}")
6518 (sem mode src (.sym dst mach - dstgroup - mode) label)
6523 (define-pmacro (arith-jnz16-imm4-dst-defn mode wstr wbit op opc1 opc2 sem)
6525 (arith-jnz-imm4-dst-defn 16 Imm-8-s4 basic Lab-16-8 mode wstr op
6526 (+ opc1 opc2 (f-7-1 wbit) Imm-8-s4 (.sym dst16-basic- mode) Lab-16-8)
6528 (arith-jnz-imm4-dst-defn 16 Imm-8-s4 16-16 Lab-32-8 mode wstr op
6529 (+ opc1 opc2 (f-7-1 wbit) Imm-8-s4 (.sym dst16-16-16- mode) Lab-16-8)
6531 (arith-jnz-imm4-dst-defn 16 Imm-8-s4 16-8 Lab-24-8 mode wstr op
6532 (+ opc1 opc2 (f-7-1 wbit) Imm-8-s4 (.sym dst16-16-8- mode) Lab-16-8)
6538 (define-pmacro (arith-jnz32-imm4-dst-defn mode wstr wbit op opc1 opc2 sem)
6540 (arith-jnz-imm4-dst-defn 32 Imm-12-s4 basic-Unprefixed Lab-16-8 mode wstr op
6541 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) Imm-12-s4 Lab-16-8)
6543 (arith-jnz-imm4-dst-defn 32 Imm-12-s4 16-24-Unprefixed Lab-40-8 mode wstr op
6544 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) Imm-12-s4 Lab-40-8)
6546 (arith-jnz-imm4-dst-defn 32 Imm-12-s4 16-16-Unprefixed Lab-32-8 mode wstr op
6547 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) Imm-12-s4 Lab-32-8)
6549 (arith-jnz-imm4-dst-defn 32 Imm-12-s4 16-8-Unprefixed Lab-24-8 mode wstr op
6550 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) Imm-12-s4 Lab-24-8)
6555 (define-pmacro (arith-jnz-imm4-dst-mach mach op opc1 opc2 sem)
6557 (.apply (.sym arith-jnz mach -imm4-dst-defn) (QI .b 0 op opc1 opc2 sem))
6558 (.apply (.sym arith-jnz mach -imm4-dst-defn) (HI .w 1 op opc1 opc2 sem))
6562 (define-pmacro (arith-jnz-imm4-dst op opc16-1 opc16-2 opc32-1 opc32-2 sem)
6564 (arith-jnz-imm4-dst-mach 16 op opc16-1 opc16-2 sem)
6565 (arith-jnz-imm4-dst-mach 32 op opc32-1 opc32-2 sem)
6569 ;-------------------------------------------------------------
6570 ;mov.size dsp8[sp],dst -- for m16c and m32c
6571 ;-------------------------------------------------------------
6572 (define-pmacro (mov-dspsp-dst-defn mach dstgroup dsp mode wstr op encoding sem)
6573 (dni (.sym op mach wstr -dspsp-dst- dstgroup)
6574 (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
6576 (.str op wstr " ${" dsp "}[sp],${dst" mach "-" dstgroup "-" mode "}")
6578 (sem mach mode dsp (.sym dst mach - dstgroup - mode))
6581 (define-pmacro (mov-src-dspsp-defn mach dstgroup dsp mode wstr op encoding sem)
6582 (dni (.sym op mach wstr -dst-dspsp- dstgroup)
6583 (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
6585 (.str op wstr " ${dst" mach "-" dstgroup "-" mode "},${" dsp "}[sp]")
6587 (sem mach mode (.sym dst mach - dstgroup - mode) dsp)
6592 (define-pmacro (mov16-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem)
6594 (mov-dspsp-dst-defn 16 basic Dsp-16-u8 mode wstr op
6595 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-u8)
6597 (mov-dspsp-dst-defn 16 16-16 Dsp-32-u8 mode wstr op
6598 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-u8)
6600 (mov-dspsp-dst-defn 16 16-8 Dsp-24-u8 mode wstr op
6601 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-u8)
6606 (define-pmacro (mov16-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem)
6608 (mov-src-dspsp-defn 16 basic Dsp-16-u8 mode wstr op
6609 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-u8)
6611 (mov-src-dspsp-defn 16 16-16 Dsp-32-u8 mode wstr op
6612 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-u8)
6614 (mov-src-dspsp-defn 16 16-8 Dsp-24-u8 mode wstr op
6615 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-u8)
6621 (define-pmacro (mov32-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem)
6623 (mov-dspsp-dst-defn 32 basic-Unprefixed Dsp-16-u8 mode wstr op
6624 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-u8)
6626 (mov-dspsp-dst-defn 32 16-24-Unprefixed Dsp-40-u8 mode wstr op
6627 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-40-u8)
6629 (mov-dspsp-dst-defn 32 16-16-Unprefixed Dsp-32-u8 mode wstr op
6630 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-32-u8)
6632 (mov-dspsp-dst-defn 32 16-8-Unprefixed Dsp-24-u8 mode wstr op
6633 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-24-u8)
6637 (define-pmacro (mov32-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem)
6639 (mov-src-dspsp-defn 32 basic-Unprefixed Dsp-16-u8 mode wstr op
6640 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-u8)
6642 (mov-src-dspsp-defn 32 16-24-Unprefixed Dsp-40-u8 mode wstr op
6643 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-40-u8)
6645 (mov-src-dspsp-defn 32 16-16-Unprefixed Dsp-32-u8 mode wstr op
6646 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-32-u8)
6648 (mov-src-dspsp-defn 32 16-8-Unprefixed Dsp-24-u8 mode wstr op
6649 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-24-u8)
6654 (define-pmacro (mov-src-dspsp-mach mach op opc1 opc2 opc3 sem)
6656 (.apply (.sym mov mach -src-dspsp-defn) (QI .b 0 op opc1 opc2 opc3 sem))
6657 (.apply (.sym mov mach -src-dspsp-defn) (HI .w 1 op opc1 opc2 opc3 sem))
6661 (define-pmacro (mov-dspsp-dst-mach mach op opc1 opc2 opc3 sem)
6663 (.apply (.sym mov mach -dspsp-dst-defn) (QI .b 0 op opc1 opc2 opc3 sem))
6664 (.apply (.sym mov mach -dspsp-dst-defn) (HI .w 1 op opc1 opc2 opc3 sem))
6668 (define-pmacro (mov-dspsp-dst op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6670 (mov-dspsp-dst-mach 16 op opc16-1 opc16-2 opc16-3 sem)
6671 (mov-dspsp-dst-mach 32 op opc32-1 opc32-2 opc32-3 sem)
6674 (define-pmacro (mov-src-dspsp op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6676 (mov-src-dspsp-mach 16 op opc16-1 opc16-2 opc16-3 sem)
6677 (mov-src-dspsp-mach 32 op opc32-1 opc32-2 opc32-3 sem)
6681 ;-------------------------------------------------------------
6682 ; lde dsp24,dst -- for m16c
6683 ; TODO abs20[a0], [a0a1] for dsp24
6684 ;-------------------------------------------------------------
6686 (define-pmacro (lde-defn mach dstgroup dsp mode wstr op encoding sem)
6687 (dni (.sym op mach wstr -dst-dspsp- dstgroup)
6688 (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
6690 (.str op wstr " ${" dsp "},${dst" mach "-" dstgroup "-" mode "}")
6692 (sem mode (.sym dst mach - dstgroup - mode) dsp)
6696 (define-pmacro (lde-dst mode wstr wbit op opc1 opc2 opc3 sem)
6698 (lde-defn 16 basic Dsp-16-u20 mode wstr op
6699 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-u20)
6701 (lde-defn 16 16-16 Dsp-32-u20 mode wstr op
6702 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-u20)
6704 (lde-defn 16 16-8 Dsp-24-u20 mode wstr op
6705 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-u20)
6710 ;-------------------------------------------------------------
6711 ; ste src,dsp24 -- for m16c
6712 ; TODO abs20[a0], [a0a1] for dsp24
6713 ;-------------------------------------------------------------
6715 (define-pmacro (ste-defn mach dstgroup dsp mode wstr op encoding sem)
6716 (dni (.sym op mach wstr -dst-dspsp- dstgroup)
6717 (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
6719 (.str op wstr " ${dst" mach "-" dstgroup "-" mode "},${" dsp "}")
6721 (sem mode (.sym dst mach - dstgroup - mode) dsp)
6725 (define-pmacro (ste-dst mode wstr wbit op opc1 opc2 opc3 sem)
6727 (ste-defn 16 basic Dsp-16-u20 mode wstr op
6728 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-u20)
6730 (ste-defn 16 16-16 Dsp-32-u20 mode wstr op
6731 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-u20)
6733 (ste-defn 16 16-8 Dsp-24-u20 mode wstr op
6734 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-u20)
6739 ;=============================================================
6741 ;-------------------------------------------------------------
6743 (define-pmacro (div-sem divop modop opmode reg src quot rem max min)
6746 (set obit (const BI 1))
6747 (sequence ((opmode quot-result) (opmode rem-result))
6748 (set quot-result (divop opmode (ext opmode reg) src))
6749 (set rem-result (modop opmode (ext opmode reg) src))
6750 (set obit (orif (gt opmode quot-result max)
6751 (lt opmode quot-result min)))
6752 (set quot quot-result)
6753 (set rem rem-result))))
6756 ;<divop>.size #imm -- for m16c and m32c
6757 (define-pmacro (div-imm-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem)
6758 (dni (.sym op mach wstr - src)
6759 (.str op mach wstr "-" src)
6761 (.str op wstr " #${" src "}")
6763 (sem divop modop opmode reg src quot rem max min)
6766 (define-pmacro (div16-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem)
6767 (div-imm-defn 16 wstr op (.sym Imm-16 - smode)
6768 (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16 - smode))
6769 divop modop opmode reg quot rem max min
6772 (define-pmacro (div32-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem)
6773 (div-imm-defn 32 wstr op (.sym Imm-16 - smode)
6774 (+ (f-0-4 opc1) (f-4-4 opc2) (f-8-3 opc3) (f-11-1 wbit) (f-12-4 opc4) (.sym Imm-16 - smode))
6775 divop modop opmode reg quot rem max min
6778 (define-pmacro (div-imm-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 opc4 sem)
6780 (.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))
6781 (.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))
6784 (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)
6786 (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)
6787 (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)
6791 ;<divop>.size src -- for m16c and m32c
6792 (define-pmacro (div-src-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem)
6793 (dni (.sym op mach wstr - src)
6794 (.str op mach wstr "-" src)
6796 (.str op wstr " ${" src "}")
6798 (sem divop modop opmode reg src quot rem max min)
6801 (define-pmacro (div16-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem)
6802 (div-src-defn 16 wstr op (.sym dst16-16 - smode)
6803 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16 - smode))
6804 divop modop opmode reg quot rem max min
6807 (define-pmacro (div32-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem)
6809 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6810 ; define the absolute-indirect insns first in order to prevent them from being selected
6811 ; when the mode is register-indirect
6812 ; (div-src-defn 32 wstr op (.sym dst32-24-absolute-indirect- smode)
6813 ; (+ (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))
6814 ; divop modop opmode reg quot rem max min
6816 (div-src-defn 32 wstr op (.sym dst32-16-Unprefixed- smode)
6817 (+ (f-0-4 opc1) (f-7-1 wbit) (f-10-2 opc2) (f-12-4 opc3) (.sym dst32-16-Unprefixed- smode))
6818 divop modop opmode reg quot rem max min
6820 ; (div-src-defn 32 wstr op (.sym dst32-24-indirect- smode)
6821 ; (+ (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))
6822 ; divop modop opmode reg quot rem max min
6826 (define-pmacro (div-src-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 sem)
6828 (.apply (.sym div mach -src-defn) (QI .b 0 op divop modop opmode R0 R0l R0h max-QI min-QI opc1 opc2 opc3 sem))
6829 (.apply (.sym div mach -src-defn) (HI .w 1 op divop modop opmode R2R0 R0 R2 max-HI min-HI opc1 opc2 opc3 sem))
6832 (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)
6834 (div-src-mach 16 op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 sem)
6835 (div-src-mach 32 op divop modop opmode max-QI min-QI max-HI min-HI opc32-1 opc32-2 opc32-3 sem)
6839 ;=============================================================
6842 (define-pmacro (bit-insn-defn mach op suffix opnd encoding sem)
6843 (dni (.sym op mach - suffix - opnd)
6844 (.str op mach ":" suffix " " opnd)
6846 (.str op "$" suffix " ${" opnd "}")
6852 (define-pmacro (bitsrc16-defn op opc1 opc2 opc3 sem)
6853 (bit-insn-defn 16 op X bit16-16
6854 (+ opc1 opc2 opc3 bit16-16)
6858 (define-pmacro (bitsrc32-defn op opc1 opc2 opc3 sem)
6860 (bit-insn-defn 32 op X bit32-24-Prefixed
6861 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) bit32-24-Prefixed (f-15-1 opc2) (f-18-3 opc3))
6866 (define-pmacro (bitsrc-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6868 (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem)
6869 (bitsrc32-defn op opc32-1 opc32-2 opc32-3 sem)
6873 (define-pmacro (bitdst16-defn op opc1 opc2 opc3 opc4 opc5 opc6 sem)
6875 (bit-insn-defn 16 op G bit16-16-basic (+ opc1 opc2 opc3 bit16-16-basic) sem)
6876 (bit-insn-defn 16 op G bit16-16-16 (+ opc1 opc2 opc3 bit16-16-16) sem)
6877 (bit-insn-defn 16 op S bit16-11-S (+ opc4 opc5 opc6 bit16-11-S) sem)
6878 (bit-insn-defn 16 op G bit16-16-8 (+ opc1 opc2 opc3 bit16-16-8) sem)
6882 (define-pmacro (bitdst32-defn op opc1 opc2 opc3 sem)
6884 (bit-insn-defn 32 op X bit32-16-Unprefixed
6885 (+ (f-0-4 opc1) bit32-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3))
6890 (define-pmacro (bitdstnos-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6892 (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem)
6893 (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem)
6897 (define-pmacro (bitdst-insn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 opc32-1 opc32-2 opc32-3 sem)
6899 (bitdst16-defn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 sem)
6900 (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem)
6904 ;=============================================================
6907 (define-pmacro (bitcond-insn-defn mach op bit-opnd cond-opnd encoding sem)
6908 (dni (.sym op mach - bit-opnd - cond-opnd)
6909 (.str op mach " " bit-opnd " " cond-opnd)
6911 (.str op "${" cond-opnd "} ${" bit-opnd "}")
6913 (sem mach bit-opnd cond-opnd)
6917 (define-pmacro (bitcond16-defn op opc1 opc2 opc3 sem)
6919 (bitcond-insn-defn 16 op bit16-16-basic cond16-16 (+ opc1 opc2 opc3 bit16-16-basic cond16-16) sem)
6920 (bitcond-insn-defn 16 op bit16-16-16 cond16-32 (+ opc1 opc2 opc3 bit16-16-16 cond16-32) sem)
6921 (bitcond-insn-defn 16 op bit16-16-8 cond16-24 (+ opc1 opc2 opc3 bit16-16-8 cond16-24) sem)
6925 (define-pmacro (bitcond32-defn op opc1 opc2 opc3 sem)
6927 (bitcond-insn-defn 32 op bit32-16-24-Unprefixed cond32-40
6928 (+ (f-0-4 opc1) bit32-16-24-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-40)
6930 (bitcond-insn-defn 32 op bit32-16-16-Unprefixed cond32-32
6931 (+ (f-0-4 opc1) bit32-16-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-32)
6933 (bitcond-insn-defn 32 op bit32-16-8-Unprefixed cond32-24
6934 (+ (f-0-4 opc1) bit32-16-8-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-24)
6936 (bitcond-insn-defn 32 op bit32-basic-Unprefixed cond32-16
6937 (+ (f-0-4 opc1) bit32-basic-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-16)
6942 (define-pmacro (bitcond-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6944 (bitcond16-defn op opc16-1 opc16-2 opc16-3 sem)
6945 (bitcond32-defn op opc32-1 opc32-2 opc32-3 sem)
6949 ;=============================================================
6950 ;<insn>.size #imm1,#imm2,dst -- for m32c
6952 (define-pmacro (insn-imm1-imm2-dst-defn src1 src2 dstgroup xmode wstr op encoding sem)
6953 (dni (.sym op 32 wstr - src1 - src2 - dstgroup)
6954 (.str op 32 wstr "-" src1 "-" src2 "-" dstgroup "-" xmode)
6956 (.str op wstr " #${" src1 "},#${" src2 "},${dst32-" dstgroup "-" xmode "}")
6958 (sem xmode src1 src2 (.sym dst32- dstgroup - xmode))
6962 ; m32c Prefixed variants
6963 (define-pmacro (insn32-imm1-imm2-dst-Prefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem)
6965 (insn-imm1-imm2-dst-defn (.sym Imm-48- xmode) (.sym Imm- base4 - xmode) 24-24-Prefixed xmode wstr op
6966 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
6967 (.sym dst32-24-24-Prefixed- xmode) (.sym Imm-48- xmode) (.sym Imm- base4 - xmode))
6969 (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base3 - xmode) 24-16-Prefixed xmode wstr op
6970 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
6971 (.sym dst32-24-16-Prefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base3 - xmode))
6973 (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base2 - xmode) 24-8-Prefixed xmode wstr op
6974 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
6975 (.sym dst32-24-8-Prefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base2 - xmode))
6977 (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base1 - xmode) basic-Prefixed xmode wstr op
6978 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
6979 (.sym dst32-basic-Prefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base1 - xmode))
6984 ; m32c Unprefixed variants
6985 (define-pmacro (insn32-imm1-imm2-dst-Unprefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem)
6987 (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base4 - xmode) 16-24-Unprefixed xmode wstr op
6988 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
6989 (.sym dst32-16-24-Unprefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base4 - xmode))
6991 (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base3 - xmode) 16-16-Unprefixed xmode wstr op
6992 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
6993 (.sym dst32-16-16-Unprefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base3 - xmode))
6995 (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base2 - xmode) 16-8-Unprefixed xmode wstr op
6996 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
6997 (.sym dst32-16-8-Unprefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base2 - xmode))
6999 (insn-imm1-imm2-dst-defn (.sym Imm-16- xmode) (.sym Imm- base1 - xmode) basic-Unprefixed xmode wstr op
7000 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7001 (.sym dst32-basic-Unprefixed- xmode) (.sym Imm-16- xmode) (.sym Imm- base1 - xmode))
7006 (define-pmacro (insn-imm1-imm2-dst-Prefixed op opc32-1 opc32-2 opc32-3 sem)
7008 (insn32-imm1-imm2-dst-Prefixed-defn QI .b 0 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem)
7009 (insn32-imm1-imm2-dst-Prefixed-defn HI .w 1 40 48 56 64 op opc32-1 opc32-2 opc32-3 sem)
7012 (define-pmacro (insn-imm1-imm2-dst-Unprefixed op opc32-1 opc32-2 opc32-3 sem)
7014 (insn32-imm1-imm2-dst-Unprefixed-defn QI .b 0 24 32 40 48 op opc32-1 opc32-2 opc32-3 sem)
7015 (insn32-imm1-imm2-dst-Unprefixed-defn HI .w 1 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem)
7019 ;=============================================================
7021 ;-------------------------------------------------------------
7023 ;-------------------------------------------------------------
7025 (define-pmacro (abs-sem mode dst)
7026 (sequence ((mode result))
7027 (set result (abs mode dst))
7028 (set obit (eq result dst))
7029 (set-z-and-s result)
7032 (unary-insn abs (f-0-4 7) (f-4-3 3) (f-8-4 #xF) #xA #x1 #xF abs-sem)
7034 ;-------------------------------------------------------------
7035 ; adcf - addition carry flag
7036 ;-------------------------------------------------------------
7038 (define-pmacro (adcf-sem mode dst)
7039 (sequence ((mode result))
7040 (set result (addc mode dst 0 cbit))
7041 (set obit (add-oflag mode dst 0 cbit))
7042 (set cbit (add-cflag mode dst 0 cbit))
7043 (set-z-and-s result)
7046 (unary-insn adcf (f-0-4 7) (f-4-3 3) (f-8-4 #xE) #xB #x1 #xE adcf-sem)
7048 ;-------------------------------------------------------------
7049 ; add - binary addition
7050 ;-------------------------------------------------------------
7052 (define-pmacro (add-sem mode src1 dst)
7053 (sequence ((mode result))
7054 (set result (add mode src1 dst))
7055 (set obit (add-oflag mode src1 dst 0))
7056 (set cbit (add-cflag mode src1 dst 0))
7057 (set-z-and-s result)
7061 ; add.L:G #imm32,dst (m32 #2)
7062 (binary-arith32-imm-dst-defn SI SI .l 0 add G #x8 #x3 #x1 add-sem)
7063 ; add.size:G #imm,dst (m16 #1 m32 #1)
7064 (binary-arith-imm-dst add G (f-0-4 7) (f-4-3 3) (f-8-4 4) #x8 #x2 #xE add-sem)
7065 ; add.size:Q #imm4,dst (m16 #2 m32 #3)
7066 (binary-arith-imm4-dst add (f-0-4 #xC) (f-4-3 4) #x7 #x3 add-sem)
7067 (binary-arith32-imm4-dst-defn SI .l 1 0 add #x7 #x3 add-sem)
7068 ; add.b:S #imm8,dst3 (m16 #3)
7069 (binary-arith16-b-S-imm8-dst3 add ".b" (f-0-4 8) (f-4-1 0) add-sem)
7070 ; add.BW:Q #imm4,sp (m16 #7)
7071 (binary-arith16-Q-sp add (f-0-4 7) (f-4-4 #xD) (f-8-4 #xB) add-sem)
7072 ; add.BW:G #imm,sp (m16 #6)
7073 (binary-arith16-G-sp add (f-0-4 7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #xB) add-sem)
7074 ; add.BW:G src,dst (m16 #4 m32 #6)
7075 (binary-arith-src-dst add G (f-0-4 #xA) (f-4-3 0) #x1 #x8 add-sem)
7076 ; add.B.S src2,r0l/r0h (m16 #5)
7077 (binary-arith16-b-S-src2 add (f-0-4 2) (f-4-1 0) add-sem)
7078 ; add.L:G src,dst (m32 #7)
7079 (binary-arith32-src-dst-defn SI SI .l 1 add G #x1 #x2 add-sem)
7080 ; add.L:S #imm{1,2},A0/A1 (m32 #5)
7081 (binary-arith32-l-s-imm1-an add (f-0-2 2) (f-3-4 6) add-sem)
7082 ; add.L:Q #imm3,sp (m32 #9)
7083 (binary-arith32-l-q-imm3-sp add (f-0-2 1) (f-4-3 1) add-sem)
7084 ; add.L:S #imm8,sp (m32 #10)
7085 (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)
7086 ; add.L:G #imm16,sp (m32 #8)
7087 (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)
7088 ; add.BW:S #imm,dst2 (m32 #4)
7089 (binary-arith32-s-imm-dst QI .b 0 add #x0 #x3 add-sem)
7090 (binary-arith32-s-imm-dst HI .w 1 add #x0 #x3 add-sem)
7092 ;-------------------------------------------------------------
7093 ; adc - binary add with carry
7094 ;-------------------------------------------------------------
7096 (define-pmacro (addc-sem mode src dst)
7097 (sequence ((mode result))
7098 (set result (addc mode src dst cbit))
7099 (set obit (add-oflag mode src dst cbit))
7100 (set cbit (add-cflag mode src dst cbit))
7101 (set-z-and-s result)
7105 ; adc.size:G #imm,dst
7106 (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)
7107 (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)
7108 (binary-arith32-imm-dst-Prefixed QI QI .b 0 adc X #x8 #x2 #xE addc-sem)
7109 (binary-arith32-imm-dst-Prefixed HI HI .w 1 adc X #x8 #x2 #xE addc-sem)
7112 (binary-arith16-src-dst-defn QI QI .b 0 adc X (f-0-4 #xB) (f-4-3 0) addc-sem)
7113 (binary-arith16-src-dst-defn HI HI .w 1 adc X (f-0-4 #xB) (f-4-3 0) addc-sem)
7114 (binary-arith32-src-dst-Prefixed QI QI .b 0 adc X #x1 #x4 addc-sem)
7115 (binary-arith32-src-dst-Prefixed HI HI .w 1 adc X #x1 #x4 addc-sem)
7117 ;-------------------------------------------------------------
7118 ; dadc - decimal add with carry
7119 ; dadd - decimal addition
7120 ;-------------------------------------------------------------
7122 (define-pmacro (dadc-sem mode src dst)
7123 (sequence ((mode result))
7124 (set result (subc mode dst src (not cbit)))
7125 (set cbit (sub-cflag mode dst src (not cbit)))
7126 (set-z-and-s result)
7130 (define-pmacro (decimal-subtraction16-insn op opc1 opc2)
7133 (dni (.sym op 16.b-imm8)
7134 (.str op ".b #imm8")
7136 (.str op ".b #${Imm-16-QI}")
7137 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc1) Imm-16-QI)
7138 ((.sym op -sem) QI Imm-16-QI R0l)
7141 (dni (.sym op 16.w-imm16)
7142 (.str op ".b #imm16")
7144 (.str op ".w #${Imm-16-HI}")
7145 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc1) Imm-16-HI)
7146 ((.sym op -sem) HI Imm-16-HI R0)
7149 (dni (.sym op 16.b-r0h-r0l)
7150 (.str op ".b r0h,r0l")
7152 (.str op ".b r0h,r0l")
7153 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc2))
7154 ((.sym op -sem) QI R0h R0l)
7157 (dni (.sym op 16.w-r1-r0)
7158 (.str op ".b r1,r0")
7160 (.str op ".w r1,r0")
7161 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc2))
7162 ((.sym op -sem) HI R1 R0)
7168 (decimal-subtraction16-insn dadc #xE #x6 )
7170 ; dadc.size #imm,dst
7171 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadc X #x8 #x0 #xE dadc-sem)
7172 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadc X #x8 #x0 #xE dadc-sem)
7174 (binary-arith32-src-dst-Prefixed QI QI .b 0 dadc X #x1 #x8 dadc-sem)
7175 (binary-arith32-src-dst-Prefixed HI HI .w 1 dadc X #x1 #x8 dadc-sem)
7177 (define-pmacro (dadd-sem mode src dst)
7178 (sequence ((mode result))
7179 (set result (subc mode dst src 0))
7180 (set cbit (sub-cflag mode dst src 0))
7181 (set-z-and-s result)
7186 (decimal-subtraction16-insn dadd #xC #x4)
7188 ; dadd.size #imm,dst
7189 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadd X #x8 #x1 #xE dadd-sem)
7190 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadd X #x8 #x1 #xE dadd-sem)
7192 (binary-arith32-src-dst-Prefixed QI QI .b 0 dadd X #x1 #x0 dadd-sem)
7193 (binary-arith32-src-dst-Prefixed HI HI .w 1 dadd X #x1 #x0 dadd-sem)
7195 ;-------------------------------------------------------------;
7196 ; addx - Add extend sign with no carry
7197 ;-------------------------------------------------------------;
7199 (define-pmacro (addx-sem mode src dst)
7200 (sequence ((SI source) (SI result))
7201 (set source (zext SI (trunc QI src)))
7202 (set result (add SI source dst))
7203 (set obit (add-oflag SI source dst 0))
7204 (set cbit (add-cflag SI source dst 0))
7205 (set-z-and-s result)
7210 (binary-arith32-imm-dst-defn QI SI "" 0 addx X #x8 #x1 #x1 addx-sem)
7212 (binary-arith32-src-dst-defn QI SI "" 0 addx X #x1 #x2 addx-sem)
7214 ;-------------------------------------------------------------
7215 ; adjnz - Add/Sub and branch if not zero
7216 ;-------------------------------------------------------------
7218 (define-pmacro (arith-jnz-sem mode src dst label)
7219 (sequence ((mode result))
7220 (set result (add mode src dst))
7226 ; adjnz.size #imm4,dst,label
7227 (arith-jnz-imm4-dst adjnz (f-0-4 #xF) (f-4-3 4) #xf #x1 arith-jnz-sem)
7229 ;-------------------------------------------------------------
7231 ;-------------------------------------------------------------
7233 (define-pmacro (and-sem mode src1 dst)
7234 (sequence ((mode result))
7235 (set result (and mode src1 dst))
7236 (set-z-and-s result)
7240 ; and.size:G #imm,dst (m16 #1 m32 #1)
7241 (binary-arith-imm-dst and G (f-0-4 7) (f-4-3 3) (f-8-4 2) #x8 #x3 #xF and-sem)
7242 ; and.b:S #imm8,dst3 (m16 #2)
7243 (binary-arith16-b-S-imm8-dst3 and ".b" (f-0-4 9) (f-4-1 0) and-sem)
7244 ; and.BW:G src,dst (m16 #3 m32 #3)
7245 (binary-arith-src-dst and G (f-0-4 #x9) (f-4-3 0) #x1 #xD and-sem)
7246 ; and.B.S src2,r0l/r0h (m16 #4)
7247 (binary-arith16-b-S-src2 and (f-0-4 1) (f-4-1 0) and-sem)
7248 ; and.BW:S #imm,dst2 (m32 #2)
7249 (binary-arith32-s-imm-dst QI .b 0 and #x1 #x6 and-sem)
7250 (binary-arith32-s-imm-dst HI .w 1 and #x1 #x6 and-sem)
7252 ;-------------------------------------------------------------
7254 ;-------------------------------------------------------------
7256 (define-pmacro (band-sem src)
7257 (set cbit (and src cbit))
7259 (bitsrc-insn band (f-0-4 7) (f-4-4 #xE) (f-8-4 4) #xD #x0 #x1 band-sem)
7261 ;-------------------------------------------------------------
7263 ;-------------------------------------------------------------
7265 (define-pmacro (bclr-sem dst)
7268 (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)
7270 ;-------------------------------------------------------------
7271 ; bitindex - bit index
7272 ;-------------------------------------------------------------
7274 (define-pmacro (bitindex-sem mode dst)
7277 (unary-insn-defn 32 16-Unprefixed QI .b bitindex
7278 (+ (f-0-4 #xC) (f-7-1 0) dst32-16-Unprefixed-QI (f-10-2 #x2) (f-12-4 #xE))
7280 (unary-insn-defn 32 16-Unprefixed HI .w bitindex
7281 (+ (f-0-4 #xC) (f-7-1 1) dst32-16-Unprefixed-HI (f-10-2 #x2) (f-12-4 #xE))
7284 ;-------------------------------------------------------------
7285 ; bmCnd - bit move condition
7286 ;-------------------------------------------------------------
7288 (define-pmacro (test-condition16 cond)
7290 ((#x00) (trunc BI cbit))
7291 ((#x01) (not (or cbit zbit)))
7292 ((#x02) (trunc BI zbit))
7293 ((#x03) (trunc BI sbit))
7294 ((#x04) (or zbit (xor sbit obit)))
7295 ((#x05) (trunc BI obit))
7296 ((#x06) (xor sbit obit))
7298 ((#xf9) (or cbit zbit))
7301 ((#xfc) (not (or zbit (xor sbit obit))))
7303 ((#xfe) (not (xor sbit obit)))
7308 (define-pmacro (test-condition32 cond)
7311 ((#x01) (or cbit zbit))
7315 ((#x05) (not (or zbit (xor sbit obit))))
7316 ((#x06) (not (xor sbit obit)))
7317 ((#x08) (trunc BI cbit))
7318 ((#x09) (not (or cbit zbit)))
7319 ((#x0a) (trunc BI zbit))
7320 ((#x0b) (trunc BI sbit))
7321 ((#x0c) (trunc BI obit))
7322 ((#x0d) (or zbit (xor sbit obit)))
7323 ((#x0e) (xor sbit obit))
7328 (define-pmacro (bitcond-sem mach op cond)
7329 (if ((.sym test-condition mach) cond)
7333 (bitcond-insn bm (f-0-4 7) (f-4-4 #xE) (f-8-4 2) #xD #x0 #x2 bitcond-sem)
7339 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xD) cond16c)
7340 (bitcond-sem 16 cbit cond16c)
7347 (+ (f-0-4 #xD) (f-4-4 #x9) (f-8-1 0) (f-10-3 5) cond32)
7348 (bitcond-sem 32 cbit cond32)
7351 ;-------------------------------------------------------------
7353 ;-------------------------------------------------------------
7355 (define-pmacro (bnand-sem src)
7356 (set cbit (and (inv src) cbit))
7358 (bitsrc-insn bnand (f-0-4 7) (f-4-4 #xE) (f-8-4 5) #xD #x0 #x3 bnand-sem)
7360 ;-------------------------------------------------------------
7362 ;-------------------------------------------------------------
7364 (define-pmacro (bnor-sem src)
7365 (set cbit (or (inv src) cbit))
7367 (bitsrc-insn bnor (f-0-4 7) (f-4-4 #xE) (f-8-4 7) #xD #x0 #x6 bnor-sem)
7369 ;-------------------------------------------------------------
7371 ;-------------------------------------------------------------
7373 (define-pmacro (bnot-sem dst)
7376 (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)
7378 ;-------------------------------------------------------------
7380 ;-------------------------------------------------------------
7382 (define-pmacro (bntst-sem src)
7383 (set cbit (inv src))
7384 (set zbit (inv src))
7386 (bitsrc-insn bntst (f-0-4 7) (f-4-4 #xE) (f-8-4 3) #xD #x0 #x0 bntst-sem)
7388 ;-------------------------------------------------------------
7390 ;-------------------------------------------------------------
7392 (define-pmacro (bnxor-sem src)
7393 (set cbit (xor (inv src) cbit))
7395 (bitsrc-insn bnxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xD) #xD #x0 #x7 bnxor-sem)
7397 ;-------------------------------------------------------------
7399 ;-------------------------------------------------------------
7401 (define-pmacro (bor-sem src)
7402 (set cbit (or src cbit))
7404 (bitsrc-insn bor (f-0-4 7) (f-4-4 #xE) (f-8-4 #x6) #xD #x0 #x4 bor-sem)
7406 ;-------------------------------------------------------------
7408 ;-------------------------------------------------------------
7414 (+ (f-0-4 #x0) (f-4-4 #x0))
7422 (+ (f-0-4 #x0) (f-4-4 #x0))
7426 ;-------------------------------------------------------------
7428 ;-------------------------------------------------------------
7434 (+ (f-0-4 #x0) (f-4-4 #x8))
7438 ;-------------------------------------------------------------
7440 ;-------------------------------------------------------------
7442 (define-pmacro (bset-sem dst)
7445 (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)
7447 ;-------------------------------------------------------------
7449 ;-------------------------------------------------------------
7451 (define-pmacro (btst-sem dst)
7452 (set zbit (inv dst))
7455 (bitdst-insn btst (f-0-4 7) (f-4-4 #xE) (f-8-4 #xB) (f-0-2 1) (f-2-2 1) (f-4-1 1) #xD #x0 #x0 btst-sem)
7457 ;-------------------------------------------------------------
7459 ;-------------------------------------------------------------
7461 (define-pmacro (btstc-sem dst)
7462 (set zbit (inv dst))
7466 (bitdstnos-insn btstc (f-0-4 7) (f-4-4 #xE) (f-8-4 #x0) #xD #x0 #x4 btstc-sem)
7468 ;-------------------------------------------------------------
7470 ;-------------------------------------------------------------
7472 (define-pmacro (btsts-sem dst)
7473 (set zbit (inv dst))
7477 (bitdstnos-insn btsts (f-0-4 7) (f-4-4 #xE) (f-8-4 #x1) #xD #x0 #x5 btsts-sem)
7479 ;-------------------------------------------------------------
7481 ;-------------------------------------------------------------
7483 (define-pmacro (bxor-sem src)
7484 (set cbit (xor src cbit))
7486 (bitsrc-insn bxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xC) #xD #x0 #x5 bxor-sem)
7488 ;-------------------------------------------------------------
7490 ;-------------------------------------------------------------
7492 (define-pmacro (clip-sem mode imm1 imm2 dest)
7494 (if (gt mode imm1 dest)
7496 (if (lt mode imm2 dest)
7500 (insn-imm1-imm2-dst-Prefixed clip #x8 #x3 #xE clip-sem)
7502 ;-------------------------------------------------------------
7503 ; cmp - binary compare
7504 ;-------------------------------------------------------------
7506 (define-pmacro (cmp-sem mode src1 dst)
7507 (sequence ((mode result))
7508 (set result (sub mode dst src1))
7509 (set obit (sub-oflag mode dst src1 0))
7510 (set cbit (not (sub-cflag mode dst src1 0)))
7511 (set-z-and-s result))
7514 ; cmp.L:G #imm32,dst (m32 #2)
7515 (binary-arith32-imm-dst-defn SI SI .l 0 cmp G #xA #x3 #x1 cmp-sem)
7516 ; cmp.size:G #imm,dst (m16 #1 m32 #1)
7517 (binary-arith-imm-dst cmp G (f-0-4 7) (f-4-3 3) (f-8-4 8) #x9 #x2 #xE cmp-sem)
7518 ; cmp.size:Q #imm4,dst (m16 #2 m32 #3)
7519 (binary-arith-imm4-dst cmp (f-0-4 #xD) (f-4-3 0) #x7 #x1 cmp-sem)
7520 ; cmp.b:S #imm8,dst3 (m16 #3)
7521 (binary-arith16-b-S-imm8-dst3 cmp ".b" (f-0-4 #xE) (f-4-1 0) cmp-sem)
7522 ; cmp.BW:G src,dst (m16 #4 m32 #5)
7523 (binary-arith-src-dst cmp G (f-0-4 #xC) (f-4-3 0) #x1 #x6 cmp-sem)
7524 ; cmp.B.S src2,r0l/r0h (m16 #5)
7525 (binary-arith16-b-S-src2 cmp (f-0-4 3) (f-4-1 1) cmp-sem)
7526 ; cmp.L:G src,dst (m32 #6)
7527 (binary-arith32-src-dst-defn SI SI .l 1 cmp G #x1 #x1 cmp-sem)
7528 ; cmp.BW:S #imm,dst2 (m32 #4)
7529 (binary-arith32-s-imm-dst QI .b 0 cmp #x1 #x3 cmp-sem)
7530 (binary-arith32-s-imm-dst HI .w 1 cmp #x1 #x3 cmp-sem)
7531 ; cmp.BW:s src2,r0[l] (m32 #7)
7532 (binary-arith32-S-src2 cmp QI .b 0 (f-0-2 1) (f-4-3 0) cmp-sem)
7533 (binary-arith32-S-src2 cmp HI .w 1 (f-0-2 1) (f-4-3 0) cmp-sem)
7535 ;-------------------------------------------------------------
7536 ; cmpx - binary compare extend sign
7537 ;-------------------------------------------------------------
7539 (define-pmacro (cmpx-sem mode src1 dst)
7540 (sequence ((mode result))
7541 (set result (sub mode dst (ext mode src1)))
7542 (set obit (sub-oflag mode dst (ext mode src1) 0))
7543 (set cbit (sub-cflag mode dst (ext mode src1) 0))
7544 (set-z-and-s result))
7547 (binary-arith32-imm-dst-defn QI SI "" 0 cmpx X #xA #x1 #x1 cmpx-sem)
7549 ;-------------------------------------------------------------
7551 ;-------------------------------------------------------------
7553 (define-pmacro (dec-sem mode dest)
7554 (sequence ((mode result))
7555 (set result (sub mode dest 1))
7556 (set-z-and-s result)
7563 "dec.b ${Dst16-3-S-8}"
7564 (+ (f-0-4 #xA) (f-4-1 #x1) Dst16-3-S-8)
7565 (dec-sem QI Dst16-3-S-8)
7571 "dec.w ${Dst16An-S}"
7572 (+ (f-0-4 #xF) (f-5-3 #x2) Dst16An-S)
7573 (dec-sem HI Dst16An-S)
7576 (unary32-defn QI .b 0 dec #xB #x0 #xE dec-sem)
7577 (unary32-defn HI .w 1 dec #xB #x0 #xE dec-sem)
7579 ;-------------------------------------------------------------
7581 ; divu - divide unsigned
7582 ; divx - divide extension
7583 ;-------------------------------------------------------------
7586 (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)
7587 (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)
7588 (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)
7590 (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)
7591 (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)
7592 (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)
7594 (div-src-defn 32 .l div dst32-24-Prefixed-SI
7595 (+ (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)
7596 div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000)
7598 (div-src-defn 32 .l divu dst32-24-Prefixed-SI
7599 (+ (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)
7600 udiv umod USI R2R0 R2R0 NoRemainder #x80000000 0
7602 (div-src-defn 32 .l divx dst32-24-Prefixed-SI
7603 (+ (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)
7604 div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000)
7607 ;-------------------------------------------------------------
7608 ; dsbb - decimal subtraction with borrow
7609 ; dsub - decimal subtraction
7610 ;-------------------------------------------------------------
7612 (define-pmacro (dsbb-sem mode src dst)
7613 (sequence ((mode result))
7614 (set result (subc mode dst src (not cbit)))
7615 (set cbit (sub-cflag mode dst src (not cbit)))
7616 (set-z-and-s result)
7621 (decimal-subtraction16-insn dsbb #xF #x7)
7623 ; dsbb.size #imm,dst
7624 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsbb X #x9 #x0 #xE dsbb-sem)
7625 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsbb X #x9 #x0 #xE dsbb-sem)
7627 (binary-arith32-src-dst-Prefixed QI QI .b 0 dsbb X #x1 #xA dsbb-sem)
7628 (binary-arith32-src-dst-Prefixed HI HI .w 1 dsbb X #x1 #xA dsbb-sem)
7630 (define-pmacro (dsub-sem mode src dst)
7631 (sequence ((mode result))
7632 (set result (subc mode dst src 0))
7633 (set cbit (sub-cflag mode dst src 0))
7634 (set-z-and-s result)
7639 (decimal-subtraction16-insn dsub #xD #x5)
7641 ; dsub.size #imm,dst
7642 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsub X #x9 #x1 #xE dsub-sem)
7643 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsub X #x9 #x1 #xE dsub-sem)
7645 (binary-arith32-src-dst-Prefixed QI QI .b 0 dsub X #x1 #x2 dsub-sem)
7646 (binary-arith32-src-dst-Prefixed HI HI .w 1 dsub X #x1 #x2 dsub-sem)
7648 ;-------------------------------------------------------------
7649 ; sub - binary subtraction
7650 ;-------------------------------------------------------------
7652 (define-pmacro (sub-sem mode src1 dst)
7653 (sequence ((mode result))
7654 (set result (sub mode dst src1))
7655 (set obit (sub-oflag mode dst src1 0))
7656 (set cbit (sub-cflag mode dst src1 0))
7658 (set-z-and-s result)))
7660 ; sub.size:G #imm,dst (m16 #1 m32 #1)
7661 (binary-arith-imm-dst sub G (f-0-4 7) (f-4-3 3) (f-8-4 5) #x8 #x3 #xE sub-sem)
7662 ; sub.b:S #imm8,dst3 (m16 #2)
7663 (binary-arith16-b-S-imm8-dst3 sub ".b" (f-0-4 8) (f-4-1 1) sub-sem)
7664 ; sub.BW:G src,dst (m16 #3 m32 #4)
7665 (binary-arith-src-dst sub G (f-0-4 #xA) (f-4-3 4) #x1 #xA sub-sem)
7666 ; sub.B.S src2,r0l/r0h (m16 #4)
7667 (binary-arith16-b-S-src2 sub (f-0-4 2) (f-4-1 1) sub-sem)
7668 ; sub.L:G #imm32,dst (m32 #2)
7669 (binary-arith32-imm-dst-defn SI SI .l 0 sub G #x9 #x3 #x1 sub-sem)
7670 ; sub.BW:S #imm,dst2 (m32 #3)
7671 (binary-arith32-s-imm-dst QI .b 0 sub #x0 #x7 sub-sem)
7672 (binary-arith32-s-imm-dst HI .w 1 sub #x0 #x7 sub-sem)
7673 ; sub.L:G src,dst (m32 #5)
7674 (binary-arith32-src-dst-defn SI SI .l 1 sub G #x1 #x0 sub-sem)
7676 ;-------------------------------------------------------------
7677 ; enter - enter function
7678 ; exitd - exit and deallocate stack frame
7679 ;-------------------------------------------------------------
7681 (define-pmacro (enter16-sem mach amt)
7683 (set (reg h-sp) (sub (reg h-sp) 2))
7684 (set (mem16 HI (reg h-sp)) (reg h-fb))
7685 (set (reg h-fb) (reg h-sp))
7686 (set (reg h-sp) (sub (reg h-sp) amt))))
7688 (define-pmacro (exit16-sem mach)
7689 (sequence ((SI newpc))
7690 (set (reg h-sp) (reg h-fb))
7691 (set (reg h-fb) (mem16 HI (reg h-sp)))
7692 (set (reg h-sp) (add (reg h-sp) 2))
7693 (set newpc (mem16 HI (reg h-sp)))
7694 (set (reg h-sp) (add (reg h-sp) 2))
7695 (set newpc (or newpc (sll (mem16 QI (reg h-sp)) (const 16))))
7696 (set (reg h-sp) (add (reg h-sp) 1))
7699 (define-pmacro (enter32-sem mach amt)
7701 (set (reg h-sp) (sub (reg h-sp) 4))
7702 (set (mem32 SI (reg h-sp)) (reg h-fb))
7703 (set (reg h-fb) (reg h-sp))
7704 (set (reg h-sp) (sub (reg h-sp) amt))))
7706 (define-pmacro (exit32-sem mach)
7707 (sequence ((SI newpc))
7708 (set (reg h-sp) (reg h-fb))
7709 (set (reg h-fb) (mem32 SI (reg h-sp)))
7710 (set (reg h-sp) (add (reg h-sp) 4))
7711 (set newpc (mem32 SI (reg h-sp)))
7712 (set (reg h-sp) (add (reg h-sp) 4))
7715 (dni enter16 "enter #Imm-16-QI" ((machine 16))
7716 ("enter #${Dsp-16-u8}")
7717 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 2) Dsp-16-u8)
7718 (enter16-sem 16 Dsp-16-u8)
7721 (dni exitd16 "exitd" ((machine 16))
7723 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 2))
7727 (dni enter32 "enter #Imm-8-QI" ((machine 32))
7728 ("enter #${Dsp-8-u8}")
7729 (+ (f-0-4 #xE) (f-4-4 #xC) Dsp-8-u8)
7730 (enter32-sem 32 Dsp-8-u8)
7733 (dni exitd32 "exitd" ((machine 32))
7735 (+ (f-0-4 #xF) (f-4-4 #xC))
7739 ;-------------------------------------------------------------
7740 ; fclr - flag register clear
7741 ; fset - flag register set
7742 ;-------------------------------------------------------------
7744 (define-pmacro (set-flags-sem flag)
7745 (sequence ((SI tmp))
7747 ((#x0) (set cbit 1))
7748 ((#x1) (set dbit 1))
7749 ((#x2) (set zbit 1))
7750 ((#x3) (set sbit 1))
7751 ((#x4) (set bbit 1))
7752 ((#x5) (set obit 1))
7753 ((#x6) (set ibit 1))
7754 ((#x7) (set ubit 1)))
7758 (define-pmacro (clear-flags-sem flag)
7759 (sequence ((SI tmp))
7761 ((#x0) (set cbit 0))
7762 ((#x1) (set dbit 0))
7763 ((#x2) (set zbit 0))
7764 ((#x3) (set sbit 0))
7765 ((#x4) (set bbit 0))
7766 ((#x5) (set obit 0))
7767 ((#x6) (set ibit 0))
7768 ((#x7) (set ubit 0)))
7772 (dni fclr16 "fclr flag" ((machine 16))
7774 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 5))
7775 (clear-flags-sem flags16)
7778 (dni fset16 "fset flag" ((machine 16))
7780 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 4))
7781 (set-flags-sem flags16)
7784 (dni fclr "fclr" ((machine 32))
7786 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xE) (f-12-1 1) flags32)
7787 (clear-flags-sem flags32)
7790 (dni fset "fset" ((machine 32))
7792 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xE) (f-12-1 1) flags32)
7793 (set-flags-sem flags32)
7796 ;-------------------------------------------------------------
7798 ;-------------------------------------------------------------
7800 (define-pmacro (inc-sem mode dest)
7801 (sequence ((mode result))
7802 (set result (add mode dest 1))
7803 (set-z-and-s result)
7810 "inc.b ${Dst16-3-S-8}"
7811 (+ (f-0-4 #xA) (f-4-1 #x0) Dst16-3-S-8)
7812 (inc-sem QI Dst16-3-S-8)
7818 "inc.w ${Dst16An-S}"
7819 (+ (f-0-4 #xB) (f-5-3 #x2) Dst16An-S)
7820 (inc-sem HI Dst16An-S)
7823 (unary32-defn QI .b 0 inc #xA #x0 #xE inc-sem)
7824 (unary32-defn HI .w 1 inc #xA #x0 #xE inc-sem)
7826 ;-------------------------------------------------------------
7827 ; freit - fast return from interrupt (m32)
7829 ; into - interrupt on overflow
7830 ;-------------------------------------------------------------
7833 (dni freit32 "FREIT" ((machine 32))
7835 (+ (f-0-4 9) (f-4-4 #xF))
7839 (dni int16 "int Dsp-10-u6" ((machine 16))
7840 ("int #${Dsp-10-u6}")
7841 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-2 3) Dsp-10-u6)
7842 (c-call VOID "do_int" pc Dsp-10-u6)
7845 (dni into16 "into" ((machine 16))
7847 (+ (f-0-4 #xF) (f-4-4 6))
7851 (dni int32 "int Dsp-8-u6" ((machine 32))
7852 ("int #${Dsp-8-u6}")
7853 (+ (f-0-4 #xB) (f-4-4 #xE) Dsp-8-u6 (f-14-2 0))
7854 (c-call VOID "do_int" pc Dsp-8-u6)
7857 (dni into32 "into" ((machine 32))
7859 (+ (f-0-4 #xB) (f-4-4 #xF))
7863 ;-------------------------------------------------------------
7865 ;-------------------------------------------------------------
7867 ; TODO add support to insns allowing index
7868 (define-pmacro (indexb-sem mode d) (set SrcIndex d) (set DstIndex d))
7869 (define-pmacro (indexbd-sem mode d) (set SrcIndex (const 0)) (set DstIndex d))
7870 (define-pmacro (indexbs-sem mode d) (set SrcIndex d) (set DstIndex (const 0)))
7871 (define-pmacro (indexw-sem mode d)
7872 (set SrcIndex (sll d (const 2))) (set DstIndex (sll d (const 2))))
7873 (define-pmacro (indexwd-sem mode d)
7874 (set SrcIndex (const 0)) (set DstIndex (sll d (const 2))))
7875 (define-pmacro (indexws-sem mode d)
7876 (set SrcIndex (sll d (const 2))) (set DstIndex (const 0)))
7877 (define-pmacro (indexl-sem mode d)
7878 (set SrcIndex d) (set DstIndex (sll d (const 2))))
7879 (define-pmacro (indexld-sem mode d)
7880 (set SrcIndex (const 0)) (set DstIndex (sll d (const 2))))
7881 (define-pmacro (indexls-sem mode d)
7882 (set SrcIndex (sll d (const 2))) (set DstIndex (const 0)))
7884 ; indexb src (index byte)
7885 (unary32-defn QI .b 0 indexb #x8 0 #x3 indexb-sem)
7886 (unary32-defn HI .w 0 indexb #x8 1 #x3 indexb-sem)
7887 ; indexbd src (index byte dest)
7888 (unary32-defn QI .b 0 indexbd #xA 0 3 indexbd-sem)
7889 (unary32-defn HI .w 0 indexbd #xA 1 3 indexbd-sem)
7890 ; indexbs src (index byte src)
7891 (unary32-defn QI .b 0 indexbs #xC 0 3 indexbs-sem)
7892 (unary32-defn HI .w 0 indexbs #xC 1 3 indexbs-sem)
7893 ; indexl src (index long)
7894 (unary32-defn QI .b 0 indexl 9 2 3 indexl-sem)
7895 (unary32-defn HI .w 0 indexl 9 3 3 indexl-sem)
7896 ; indexld src (index long dest)
7897 (unary32-defn QI .b 0 indexld #xB 2 3 indexld-sem)
7898 (unary32-defn HI .w 0 indexld #xB 3 3 indexld-sem)
7899 ; indexls src (index long src)
7900 (unary32-defn QI .b 0 indexls 9 0 3 indexls-sem)
7901 (unary32-defn HI .w 0 indexls 9 1 3 indexls-sem)
7902 ; indexw src (index word)
7903 (unary32-defn QI .b 0 indexw 8 2 3 indexw-sem)
7904 (unary32-defn HI .w 0 indexw 8 3 3 indexw-sem)
7905 ; indexwd src (index word dest)
7906 (unary32-defn QI .b 0 indexwd #xA 2 3 indexwd-sem)
7907 (unary32-defn HI .w 0 indexwd #xA 3 3 indexwd-sem)
7908 ; indexws (index word src)
7909 (unary32-defn QI .b 0 indexws #xC 2 3 indexws-sem)
7910 (unary32-defn HI .w 0 indexws #xC 3 3 indexws-sem)
7912 ;-------------------------------------------------------------
7913 ; jcc - jump on condition
7914 ;-------------------------------------------------------------
7916 (define-pmacro (jcnd32-sem cnd label)
7919 ((#x00) (if (not cbit) (set pc label))) ;ltu nc
7920 ((#x01) (if (not (and cbit (not zbit))) (set pc label))) ;leu
7921 ((#x02) (if (not zbit) (set pc label))) ;ne nz
7922 ((#x03) (if (not sbit) (set pc label))) ;pz
7923 ((#x04) (if (not obit) (set pc label))) ;no
7924 ((#x05) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt
7925 ((#x06) (if (not (xor sbit obit)) (set pc label))) ;ge
7926 ((#x08) (if (trunc BI cbit) (set pc label))) ;geu c
7927 ((#x09) (if (and cbit (not zbit)) (set pc label))) ;gtu
7928 ((#x0a) (if (trunc BI zbit) (set pc label))) ;eq z
7929 ((#x0b) (if (trunc BI sbit) (set pc label))) ;n
7930 ((#x0c) (if (trunc BI obit) (set pc label))) ;o
7931 ((#x0d) (if (or zbit (xor sbit obit)) (set pc label))) ;le
7932 ((#x0e) (if (xor sbit obit) (set pc label))) ;lt
7937 (define-pmacro (jcnd16-sem cnd label)
7940 ((#x00) (if (trunc BI cbit) (set pc label))) ;geu c
7941 ((#x01) (if (and cbit (not zbit)) (set pc label))) ;gtu
7942 ((#x02) (if (trunc BI zbit) (set pc label))) ;eq z
7943 ((#x03) (if (trunc BI sbit) (set pc label))) ;n
7944 ((#x04) (if (not cbit) (set pc label))) ;ltu nc
7945 ((#x05) (if (not (and cbit (not zbit))) (set pc label))) ;leu
7946 ((#x06) (if (not zbit) (set pc label))) ;ne nz
7947 ((#x07) (if (not sbit) (set pc label))) ;pz
7948 ((#x08) (if (or zbit (xor sbit obit)) (set pc label))) ;le
7949 ((#x09) (if (trunc BI obit) (set pc label))) ;o
7950 ((#x0a) (if (not (xor sbit obit)) (set pc label))) ;ge
7951 ((#x0c) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt
7952 ((#x0d) (if (not obit) (set pc label))) ;no
7953 ((#x0e) (if (xor sbit obit) (set pc label))) ;lt
7961 "j$cond16j5 ${Lab-8-8}"
7962 (+ (f-0-4 #x6) (f-4-1 1) cond16j5 Lab-8-8)
7963 (jcnd16-sem cond16j5 Lab-8-8)
7970 "j$cond16j ${Lab-16-8}"
7971 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xC) cond16j Lab-16-8)
7972 (jcnd16-sem cond16j Lab-16-8)
7979 "j$cond32j ${Lab-8-8}"
7980 (+ (f-0-1 1) (f-4-3 5) cond32j Lab-8-8)
7981 (jcnd32-sem cond32j Lab-8-8)
7985 ;-------------------------------------------------------------
7987 ;-------------------------------------------------------------
7989 ; jmp.s label3 (m16 #1)
7990 (dni jmp16.s "jmp.s Lab-5-3" ((machine 16))
7991 ("jmp.s ${Lab-5-3}")
7992 (+ (f-0-4 6) (f-4-1 0) Lab-5-3)
7993 (sequence () (set pc Lab-5-3))
7995 ; jmp.b label8 (m16 #2)
7996 (dni jmp16.b "jmp.b Lab-8-8" ((machine 16))
7997 ("jmp.b ${Lab-8-8}")
7998 (+ (f-0-4 #xF) (f-4-4 #xE) Lab-8-8)
7999 (sequence () (set pc Lab-8-8))
8001 ; jmp.w label16 (m16 #3)
8002 (dni jmp16.w "jmp.w Lab-8-16" ((machine 16))
8003 ("jmp.w ${Lab-8-16}")
8004 (+ (f-0-4 #xF) (f-4-4 4) Lab-8-16)
8005 (sequence () (set pc Lab-8-16))
8007 ; jmp.a label24 (m16 #4)
8008 (dni jmp16.a "jmp.a Lab-8-24" ((machine 16))
8009 ("jmp.a ${Lab-8-24}")
8010 (+ (f-0-4 #xF) (f-4-4 #xC) Lab-8-24)
8011 (sequence () (set pc Lab-8-24))
8014 (define-pmacro (jmp16-sem mode dst)
8015 (set pc (and dst #xfffff))
8017 (define-pmacro (jmp32-sem mode dst)
8020 ; jmpi.w dst (m16 #1 m32 #2)
8021 (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)
8022 (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)
8023 ; jmpi.a dst (m16 #2 m32 #2)
8024 (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)
8025 (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)
8026 ; jmps imm8 (m16 #1)
8027 (dni jmps16 "jmps Imm-8-QI" ((machine 16))
8028 ("jmps #${Imm-8-QI}")
8029 (+ (f-0-4 #xE) (f-4-4 #xE) Imm-8-QI)
8030 (sequence () (set pc Imm-8-QI))
8032 ; jmp.s label3 (m32 #1)
8036 "jmp.s ${Lab32-jmp-s}"
8037 (+ (f-0-2 1) (f-4-3 5) Lab32-jmp-s)
8038 (set pc Lab32-jmp-s)
8041 ; jmp.b label8 (m32 #2)
8042 (dni jmp32.b "jmp.b Lab-8-8" ((machine 32))
8043 ("jmp.b ${Lab-8-8}")
8044 (+ (f-0-4 #xB) (f-4-4 #xB) Lab-8-8)
8047 ; jmp.w label16 (m32 #3)
8048 (dni jmp32.w "jmp.w Lab-8-16" ((machine 32))
8049 ("jmp.w ${Lab-8-16}")
8050 (+ (f-0-4 #xC) (f-4-4 #xE) Lab-8-16)
8053 ; jmp.a label24 (m32 #4)
8054 (dni jmp32.a "jmp.a Lab-8-24" ((machine 32))
8055 ("jmp.a ${Lab-8-24}")
8056 (+ (f-0-4 #xC) (f-4-4 #xC) Lab-8-24)
8059 ; jmp.s imm8 (m32 #1)
8060 (dni jmps32 "jmps Imm-8-QI" ((machine 32))
8061 ("jmps #${Imm-8-QI}")
8062 (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI)
8066 ;-------------------------------------------------------------
8067 ; jsr jump subroutine
8068 ;-------------------------------------------------------------
8070 (define-pmacro (jsr16-sem length dst)
8071 (sequence ((SI tpc))
8072 (set tpc (add pc length))
8073 (set (reg h-sp) (sub (reg h-sp) 2))
8074 (set (mem16 HI (reg h-sp)) (srl (and tpc #xffff00) 8))
8075 (set (reg h-sp) (sub (reg h-sp) 1))
8076 (set (mem16 QI (reg h-sp)) (and tpc #xff))
8080 (define-pmacro (jsr32-sem length dst)
8081 (sequence ((SI tpc))
8082 (set tpc (add pc length))
8083 (set (reg h-sp) (sub (reg h-sp) 2))
8084 (set (mem32 HI (reg h-sp)) (srl (and tpc #xffff0000) 16))
8085 (set (reg h-sp) (sub (reg h-sp) 2))
8086 (set (mem32 HI (reg h-sp)) (and tpc #xffff))
8091 ; jsr.w label16 (m16 #1)
8092 (dni jsr16.w "jsr.w Lab-8-16" ((machine 16))
8093 ("jsr.w ${Lab-8-16}")
8094 (+ (f-0-4 #xF) (f-4-4 5) Lab-8-16)
8095 (jsr16-sem 3 Lab-8-16)
8097 ; jsr.a label24 (m16 #2)
8098 (dni jsr16.a "jsr.a Lab-8-24" ((machine 16))
8099 ("jsr.a ${Lab-8-24}")
8100 (+ (f-0-4 #xF) (f-4-4 #xD) Lab-8-24)
8101 (jsr16-sem 4 Lab-8-24)
8103 (define-pmacro (jsri-defn mode op16 op16-1 op16-2 op16-3 op16-sem
8104 op32 op32-1 op32-2 op32-3 op32-4 op32-sem len)
8106 (dni (.sym jsri16 mode - op16)
8107 (.str "jsri." mode " " op16)
8109 (.str "jsri." mode " ${" op16 "}")
8110 (+ op16-1 op16-2 op16-3 op16)
8113 (dni (.sym jsri32 mode - op32)
8114 (.str "jsri." mode " " op32)
8116 (.str "jsri." mode " ${" op32 "}")
8117 (+ op32-1 op32-2 op32-3 op32-4 op32)
8122 ; jsri.w dst (m16 #1 m32 #1))
8123 (jsri-defn w dst16-basic-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8124 dst32-basic-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 2)
8125 (jsri-defn w dst16-16-8-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8126 dst32-16-8-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 3)
8127 (jsri-defn w dst16-16-16-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8128 dst32-16-16-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 4)
8129 (dni jsri32.w "jsr.w dst32-16-24-Unprefixed-HI" ((machine 32))
8130 ("jsri.w ${dst32-16-24-Unprefixed-HI}")
8131 (+ (f-0-4 #xC) (f-7-1 1) dst32-16-24-Unprefixed-HI (f-10-2 #x1) (f-12-4 #xF))
8132 (jsr32-sem 6 dst32-16-24-Unprefixed-HI)
8135 ; jsri.a (m16 #2 m32 #2)
8136 (jsri-defn a dst16-basic-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8137 dst32-basic-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 2)
8138 (jsri-defn a dst16-16-8-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8139 dst32-16-8-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 3)
8140 (jsri-defn a dst16-16-16-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8141 dst32-16-16-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 4)
8142 (dni jsri32.a "jsr.w dst32-16-24-Unprefixed-HI" ((machine 32))
8143 ("jsri.w ${dst32-16-24-Unprefixed-SI}")
8144 (+ (f-0-4 #x9) (f-7-1 0) dst32-16-24-Unprefixed-SI (f-10-2 #x0) (f-12-4 #x1))
8145 (jsr32-sem 6 dst32-16-24-Unprefixed-SI)
8147 ; jsr.w label16 (m32 #1)
8148 (dni jsr32.w "jsr.w label" ((machine 32))
8149 ("jsr.w ${Lab-8-16}")
8150 (+ (f-0-4 #xC) (f-4-4 #xF) Lab-8-16)
8151 (jsr32-sem 3 Lab-8-16)
8153 ; jsr.a label16 (m32 #2)
8154 (dni jsr32.a "jsr.a label" ((machine 32))
8155 ("jsr.a ${Lab-8-24}")
8156 (+ (f-0-4 #xC) (f-4-4 #xD) Lab-8-24)
8157 (jsr32-sem 4 Lab-8-24)
8159 ; jsrs imm8 (m16 #1)
8160 (dni jsrs16 "jsrs Imm-8-QI" ((machine 16))
8161 ("jsrs #${Imm-8-QI}")
8162 (+ (f-0-4 #xE) (f-4-4 #xF) Imm-8-QI)
8163 (jsr16-sem 2 Imm-8-QI)
8165 ; jsrs imm8 (m32 #1)
8166 (dni jsrs "jsrs #Imm-8-QI" ((machine 32))
8167 ("jsrs #${Imm-8-QI}")
8168 (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI)
8169 (jsr32-sem 2 Imm-8-QI)
8172 ;-------------------------------------------------------------
8173 ; ldc - load control register
8174 ; stc - store control register
8175 ;-------------------------------------------------------------
8177 (define-pmacro (ldc32-cr1-sem src dst)
8180 ((#x0) (set (reg h-dct0) src))
8181 ((#x1) (set (reg h-dct1) src))
8182 ((#x2) (sequence ((HI tflag))
8184 (if (and tflag #x1) (set cbit 1))
8185 (if (and tflag #x2) (set dbit 1))
8186 (if (and tflag #x4) (set zbit 1))
8187 (if (and tflag #x8) (set sbit 1))
8188 (if (and tflag #x10) (set bbit 1))
8189 (if (and tflag #x20) (set obit 1))
8190 (if (and tflag #x40) (set ibit 1))
8191 (if (and tflag #x80) (set ubit 1))))
8192 ((#x3) (set (reg h-svf) src))
8193 ((#x4) (set (reg h-drc0) src))
8194 ((#x5) (set (reg h-drc1) src))
8195 ((#x6) (set (reg h-dmd0) src))
8196 ((#x7) (set (reg h-dmd1) src))
8200 (define-pmacro (ldc32-cr2-sem src dst)
8203 ((#x0) (set (reg h-intb) src))
8204 ((#x1) (set (reg h-sp) src))
8205 ((#x2) (set (reg h-sb) src))
8206 ((#x3) (set (reg h-fb) src))
8207 ((#x4) (set (reg h-svp) src))
8208 ((#x5) (set (reg h-vct) src))
8209 ((#x7) (set (reg h-isp) src))
8213 (define-pmacro (ldc32-cr3-sem src dst)
8216 ((#x2) (set (reg h-dma0) src))
8217 ((#x3) (set (reg h-dma1) src))
8218 ((#x4) (set (reg h-dra0) src))
8219 ((#x5) (set (reg h-dra1) src))
8220 ((#x6) (set (reg h-dsa0) src))
8221 ((#x7) (set (reg h-dsa1) src))
8225 (define-pmacro (ldc16-sem src dst)
8228 ((#x1) (set (reg h-intb) src))
8229 ((#x2) (set (reg h-intb) (or (reg h-intb) (sll src (const 16)))))
8230 ((#x3) (sequence ((HI tflag))
8232 (if (and tflag #x1) (set cbit 1))
8233 (if (and tflag #x2) (set dbit 1))
8234 (if (and tflag #x4) (set zbit 1))
8235 (if (and tflag #x8) (set sbit 1))
8236 (if (and tflag #x10) (set bbit 1))
8237 (if (and tflag #x20) (set obit 1))
8238 (if (and tflag #x40) (set ibit 1))
8239 (if (and tflag #x80) (set ubit 1))))
8240 ((#x4) (set (reg h-isp) src))
8241 ((#x5) (set (reg h-sp) src))
8242 ((#x6) (set (reg h-sb) src))
8243 ((#x7) (set (reg h-fb) src))
8248 (define-pmacro (stc32-cr1-sem src dst)
8251 ((#x0) (set dst (reg h-dct0)))
8252 ((#x1) (set dst (reg h-dct1)))
8253 ((#x2) (sequence ((HI tflag))
8255 (if (eq cbit 1) (set tflag (or tflag #x1)))
8256 (if (eq dbit 1) (set tflag (or tflag #x2)))
8257 (if (eq zbit 1) (set tflag (or tflag #x4)))
8258 (if (eq sbit 1) (set tflag (or tflag #x8)))
8259 (if (eq bbit 1) (set tflag (or tflag #x10)))
8260 (if (eq obit 1) (set tflag (or tflag #x20)))
8261 (if (eq ibit 1) (set tflag (or tflag #x40)))
8262 (if (eq ubit 1) (set tflag (or tflag #x80)))
8264 ((#x3) (set dst (reg h-svf)))
8265 ((#x4) (set dst (reg h-drc0)))
8266 ((#x5) (set dst (reg h-drc1)))
8267 ((#x6) (set dst (reg h-dmd0)))
8268 ((#x7) (set dst (reg h-dmd1)))
8272 (define-pmacro (stc32-cr2-sem src dst)
8275 ((#x0) (set dst (reg h-intb)))
8276 ((#x1) (set dst (reg h-sp)))
8277 ((#x2) (set dst (reg h-sb)))
8278 ((#x3) (set dst (reg h-fb)))
8279 ((#x4) (set dst (reg h-svp)))
8280 ((#x5) (set dst (reg h-vct)))
8281 ((#x7) (set dst (reg h-isp)))
8285 (define-pmacro (stc32-cr3-sem src dst)
8288 ((#x2) (set dst (reg h-dma0)))
8289 ((#x3) (set dst (reg h-dma1)))
8290 ((#x4) (set dst (reg h-dra0)))
8291 ((#x5) (set dst (reg h-dra1)))
8292 ((#x6) (set dst (reg h-dsa0)))
8293 ((#x7) (set dst (reg h-dsa1)))
8297 (define-pmacro (stc16-sem src dst)
8300 ((#x1) (set dst (and (reg h-intb) (const #xffff))))
8301 ((#x2) (set dst (srl (reg h-intb) (const 16))))
8302 ((#x3) (sequence ((HI tflag))
8304 (if (eq cbit 1) (set tflag (or tflag #x1)))
8305 (if (eq dbit 1) (set tflag (or tflag #x2)))
8306 (if (eq zbit 1) (set tflag (or tflag #x4)))
8307 (if (eq sbit 1) (set tflag (or tflag #x8)))
8308 (if (eq bbit 1) (set tflag (or tflag #x10)))
8309 (if (eq obit 1) (set tflag (or tflag #x20)))
8310 (if (eq ibit 1) (set tflag (or tflag #x40)))
8311 (if (eq ubit 1) (set tflag (or tflag #x80)))
8313 ((#x4) (set dst (reg h-isp)))
8314 ((#x5) (set dst (reg h-sp)))
8315 ((#x6) (set dst (reg h-sb)))
8316 ((#x7) (set dst (reg h-fb)))
8321 (dni ldc16.imm16 "ldc #imm,dst" ((machine 16))
8322 ("ldc #${Imm-16-HI},${cr16}")
8323 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 0) cr16 Imm-16-HI)
8324 (ldc16-sem Imm-16-HI cr16)
8327 (dni ldc16.dst "ldc src,dest" ((machine 16))
8328 ("ldc ${dst16-16-HI},${cr16}")
8329 (+ (f-0-4 7) (f-4-4 #xA) (f-8-1 1) cr16 dst16-16-HI)
8330 (ldc16-sem dst16-16-HI cr16)
8332 ; ldc src,dest (m32c #4)
8333 (dni ldc32.src-cr1 "ldc src,dst" ((machine 32))
8334 ("ldc ${dst32-24-Prefixed-HI},${cr1-Prefixed-32}")
8335 (+ (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)
8336 (ldc32-cr1-sem dst32-24-Prefixed-HI cr1-Prefixed-32)
8338 ; ldc src,dest (m32c #5)
8339 (dni ldc32.src-cr2 "ldc src,dest" ((machine 32))
8340 ("ldc ${dst32-16-Unprefixed-SI},${cr2-32}")
8341 (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 0) cr2-32)
8342 (ldc32-cr2-sem dst32-16-Unprefixed-SI cr2-32)
8344 ; ldc src,dest (m32c #6)
8345 (dni ldc32.src-cr3 "ldc src,dst" ((machine 32))
8346 ("ldc ${dst32-24-Prefixed-SI},${cr3-Prefixed-32}")
8347 (+ (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)
8348 (ldc32-cr3-sem dst32-24-Prefixed-SI cr3-Prefixed-32)
8350 ; ldc src,dest (m32c #1)
8351 (dni ldc32.imm16-cr1 "ldc #imm,dst" ((machine 32))
8352 ("ldc #${Imm-16-HI},${cr1-Unprefixed-32}")
8353 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32 Imm-16-HI)
8354 (ldc32-cr1-sem Imm-16-HI cr1-Unprefixed-32)
8356 ; ldc src,dest (m32c #2)
8357 (dni ldc32.imm16-cr2 "ldc #imm,dst" ((machine 32))
8358 ("ldc #${Dsp-16-u24},${cr2-32}")
8359 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 2) (f-12-1 1) cr2-32 Dsp-16-u24)
8360 (ldc32-cr2-sem Dsp-16-u24 cr2-32)
8362 ; ldc src,dest (m32c #3)
8363 (dni ldc32.imm16-cr3 "ldc #imm,dst" ((machine 32))
8364 ("ldc #${Dsp-16-u24},${cr3-Unprefixed-32}")
8365 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 6) (f-12-1 1) cr3-Unprefixed-32 Dsp-16-u24)
8366 (ldc32-cr3-sem Dsp-16-u24 cr3-Unprefixed-32)
8369 (dni stc16.src "stc src,dest" ((machine 16))
8370 ("stc ${cr16},${dst16-16-HI}")
8371 (+ (f-0-4 7) (f-4-4 #xB) (f-8-1 1) cr16 dst16-16-HI)
8372 (stc16-sem cr16 dst16-16-HI )
8375 (dni stc16.pc "stc pc,dest" ((machine 16))
8376 ("stc pc,${dst16-16-HI}")
8377 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xC) dst16-16-HI)
8378 (sequence () (set dst16-16-HI (reg h-pc)))
8381 (dni stc32.src-cr1 "stc src,dst" ((machine 32))
8382 ("stc ${cr1-Prefixed-32},${dst32-24-Prefixed-HI}")
8383 (+ (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)
8384 (stc32-cr1-sem cr1-Prefixed-32 dst32-24-Prefixed-HI )
8387 (dni stc32.src-cr2 "stc src,dest" ((machine 32))
8388 ("stc ${cr2-32},${dst32-16-Unprefixed-SI}")
8389 (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 2) cr2-32)
8390 (stc32-cr2-sem cr2-32 dst32-16-Unprefixed-SI )
8393 (dni stc32.src-cr3 "stc src,dst" ((machine 32))
8394 ("stc ${cr3-Prefixed-32},${dst32-24-Prefixed-SI}")
8395 (+ (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)
8396 (stc32-cr3-sem cr3-Prefixed-32 dst32-24-Prefixed-SI )
8399 ;-------------------------------------------------------------
8400 ; ldctx - load context
8401 ; stctx - store context
8402 ;-------------------------------------------------------------
8405 (dni ldctx16 "ldctx abs16,abs24" ((machine 16))
8406 ("ldctx ${Dsp-16-u16},${Dsp-32-u24}")
8407 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24)
8410 (dni ldctx32 "ldctx abs16,abs24" ((machine 32))
8411 ("ldctx ${Dsp-16-u16},${Dsp-32-u24}")
8412 (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xC) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24)
8415 (dni stctx16 "stctx abs16,abs24" ((machine 16))
8416 ("stctx ${Dsp-16-u16},${Dsp-32-u24}")
8417 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24)
8420 (dni stctx32 "stctx abs16,abs24" ((machine 32))
8421 ("stctx ${Dsp-16-u16},${Dsp-32-u24}")
8422 (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xD) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24)
8426 ;-------------------------------------------------------------
8427 ; lde - load from extra far data area (m16)
8428 ; ste - store to extra far data area (m16)
8429 ;-------------------------------------------------------------
8431 ; A special variant of mem16 for lde and ste
8432 (define-pmacro (extra-mem16 mode address)
8433 (mem mode (and #xfffff address)))
8435 (define-pmacro (lde-sem mode src1 dst)
8436 (set mode src1 (extra-mem16 mode dst))
8438 (lde-dst QI .b 0 lde (f-0-4 #x7) (f-4-3 2) (f-8-4 #x8) lde-sem)
8439 (lde-dst HI .w 1 lde (f-0-4 #x7) (f-4-3 2) (f-8-4 #x8) lde-sem)
8441 (define-pmacro (ste-sem mode src1 dst)
8442 (set (extra-mem16 mode dst) src1)
8444 (ste-dst QI .b 0 ste (f-0-4 #x7) (f-4-3 2) (f-8-4 #x0) ste-sem)
8445 (ste-dst HI .w 1 ste (f-0-4 #x7) (f-4-3 2) (f-8-4 #x0) ste-sem)
8447 ;-------------------------------------------------------------
8448 ; ldipl - load interrupt permission level
8449 ;-------------------------------------------------------------
8452 ; ldintb <==> ldc #imm,intbh ; ldc #imm,intbl
8453 (dni ldipl16.imm "ldipl #imm" ((machine 16))
8454 ("ldipl #${Imm-13-u3}")
8455 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xA) (f-12-1 0) Imm-13-u3)
8458 (dni ldipl32.imm "ldipl #imm" ((machine 32))
8459 ("ldipl #${Imm-13-u3}")
8460 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xE) (f-12-1 1) Imm-13-u3)
8465 ;-------------------------------------------------------------
8466 ; max - maximum value
8467 ;-------------------------------------------------------------
8469 ; TODO check semantics for min -1,0
8470 (define-pmacro (max-sem mode src dst)
8472 (if (gt mode src dst)
8473 (set mode dst src)))
8476 ; max.size:G #imm,dst
8477 (binary-arith32-imm-dst-Prefixed QI QI .b 0 max X #x8 #x3 #xF max-sem)
8478 (binary-arith32-imm-dst-Prefixed HI HI .w 1 max X #x8 #x3 #xF max-sem)
8481 (binary-arith32-src-dst-Prefixed QI QI .b 0 max X #x1 #xD max-sem)
8482 (binary-arith32-src-dst-Prefixed HI HI .w 1 max X #x1 #xD max-sem)
8484 ;-------------------------------------------------------------
8485 ; min - minimum value
8486 ;-------------------------------------------------------------
8488 (define-pmacro (min-sem mode src dst)
8490 (if (lt mode src dst)
8491 (set mode dst src)))
8494 ; min.size:G #imm,dst
8495 (binary-arith32-imm-dst-Prefixed QI QI .b 0 min X #x8 #x2 #xF min-sem)
8496 (binary-arith32-imm-dst-Prefixed HI HI .w 1 min X #x8 #x2 #xF min-sem)
8499 (binary-arith32-src-dst-Prefixed QI QI .b 0 min X #x1 #xC min-sem)
8500 (binary-arith32-src-dst-Prefixed HI HI .w 1 min X #x1 #xC min-sem)
8502 ;-------------------------------------------------------------
8504 ;-------------------------------------------------------------
8506 (define-pmacro (mov-sem mode src1 dst)
8507 (sequence ((mode result))
8509 (set-z-and-s result)
8510 (set mode dst src1))
8513 (define-pmacro (mov-dspsp-dst-sem mach mode src1 dst)
8514 (set dst (mem-mach mach mode (add sp src1)))
8517 (define-pmacro (mov-src-dspsp-sem mach mode src dst1)
8518 (set (mem-mach mach mode (add sp dst1)) src)
8521 (define-pmacro (mov16-imm-an-defn size mode imm regn op1 op2)
8522 (dni (.sym mov16. size .S-imm- regn)
8523 (.str "mov." size ":S " imm "," regn)
8525 (.str "mov." size "$S #${" imm "}," regn)
8527 (mov-sem mode imm (reg (.sym h- regn)))
8530 ; mov.size:G #imm,dst (m16 #1 m32 #1)
8531 (binary-arith-imm-dst mov G (f-0-4 7) (f-4-3 2) (f-8-4 #xC) #x9 #x2 #xF mov-sem)
8532 ; mov.L:G #imm32,dst (m32 #2)
8533 (binary-arith32-imm-dst-defn SI SI .l 0 mov G #xB #x3 #x1 mov-sem)
8534 ; mov.size:Q #imm4,dst (m16 #2 m32 #3)
8535 (binary-arith16-imm4-dst-defn QI .b 0 0 mov (f-0-4 #xD) (f-4-3 4) mov-sem)
8536 (binary-arith16-imm4-dst-defn QI .w 0 1 mov (f-0-4 #xD) (f-4-3 4) mov-sem)
8537 (binary-arith32-imm4-dst-defn QI .b 1 0 mov #x7 #x2 mov-sem)
8538 (binary-arith32-imm4-dst-defn HI .w 1 1 mov #x7 #x2 mov-sem)
8539 ; mov.BW:S #imm,dst2 (m32 #4)
8540 (binary-arith32-s-imm-dst QI .b 0 mov #x0 #x2 mov-sem)
8541 (binary-arith32-s-imm-dst HI .w 1 mov #x0 #x2 mov-sem)
8542 ; mov.b:S #imm8,dst3 (m16 #3)
8543 (binary-arith16-b-S-imm8-dst3 mov ".b" (f-0-4 #xC) (f-4-1 0) mov-sem)
8544 ; mov.b:S #imm8,aN (m16 #4)
8545 (mov16-imm-an-defn b QI Imm-8-QI a0 (f-0-4 #xE) (f-4-4 2))
8546 (mov16-imm-an-defn b QI Imm-8-QI a1 (f-0-4 #xE) (f-4-4 #xA))
8547 (mov16-imm-an-defn w HI Imm-8-HI a0 (f-0-4 #xA) (f-4-4 2))
8548 (mov16-imm-an-defn w HI Imm-8-HI a1 (f-0-4 #xA) (f-4-4 #xA))
8549 ; mov.WL:S #imm,A0/A1 (m32 #5)
8550 (define-pmacro (mov32-wl-s-defn mode sz op1 imm regn op2)
8551 (dni (.sym mov32- sz - regn)
8552 (.str "mov." sz ":s" imm "," regn)
8554 (.str "mov." sz "$S #${" imm "}," regn)
8555 (+ (f-0-4 op1) (f-4-4 op2) imm)
8556 (mov-sem mode imm (reg (.sym h- regn)))
8559 (mov32-wl-s-defn HI w #x9 Imm-8-HI a0 #xC)
8560 (mov32-wl-s-defn HI w #x9 Imm-8-HI a1 #xD)
8561 (mov32-wl-s-defn SI l #xB Dsp-16-u24 a0 #xC)
8562 (mov32-wl-s-defn SI l #xB Dsp-16-u24 a1 #xD)
8564 ; mov.BW:Z #0,dst (m16 #5 m32 #6)
8565 (dni mov16.b-Z-imm8-dst3
8566 "mov.b:Z #0,Dst16-3-S-8"
8568 "mov.b$Z #0,${Dst16-3-S-8}"
8569 (+ (f-0-4 #xB) (f-4-1 #x0) Dst16-3-S-8)
8570 (mov-sem QI (const 0) Dst16-3-S-8)
8572 ; (binary-arith16-b-Z-imm8-dst3 mov ".b" (f-0-4 #xB) (f-4-1 0) mov-sem)
8573 (binary-arith32-z-imm-dst QI .b 0 mov #x0 #x1 mov-sem)
8574 (binary-arith32-z-imm-dst HI .w 1 mov #x0 #x1 mov-sem)
8575 ; mov.BW:G src,dst (m16 #6 m32 #7)
8576 (binary-arith-src-dst mov G (f-0-4 #x7) (f-4-3 1) #x1 #xB mov-sem)
8577 ; mov.B:S src2,a0/a1 (m16 #7)
8578 (dni (.sym mov 16 .b.S-An)
8579 (.str mov ".b:S src2,a[01]")
8581 (.str mov ".b$S ${src16-2-S},${Dst16AnQI-S}")
8582 (+ (f-0-4 #x3) (f-4-1 0) Dst16AnQI-S src16-2-S)
8583 (mov-sem QI src16-2-S Dst16AnQI-S)
8585 (define-pmacro (mov16-b-s-an-defn op1 op2 op2c)
8586 (dni (.sym mov16.b.S- op1 - op2)
8587 (.str mov ".b:S " op1 "," op2)
8589 (.str mov ".b$S " op1 "," op2)
8590 (+ (f-0-4 #x3) op2c)
8591 (mov-sem QI (reg (.sym h- op1)) (reg (.sym h- op2)))
8594 (mov16-b-s-an-defn r0l a1 (f-4-4 #x4))
8595 (mov16-b-s-an-defn r0h a0 (f-4-4 #x0))
8597 ; mov.L:G src,dst (m32 #8)
8598 (binary-arith32-src-dst-defn SI SI .l 1 mov G #x1 #x3 mov-sem)
8599 ; mov.B:S r0l/r0h,dst2 (m16 #8)
8600 (dni (.sym mov 16 .b.S-Rn-An)
8601 (.str mov ".b:S r0[lh],src2")
8603 (.str mov ".b$S ${Dst16RnQI-S},${src16-2-S}")
8604 (+ (f-0-4 #x0) (f-4-1 0) Dst16RnQI-S src16-2-S)
8605 (mov-sem QI src16-2-S Dst16RnQI-S)
8608 ; mov.B.S src2,r0l/r0h (m16 #9)
8609 (binary-arith16-b-S-src2 mov (f-0-4 0) (f-4-1 1) mov-sem)
8611 ; mov.BW:S src2,r0l/r0 (m32 #9)
8612 ; mov.BW:S src2,r1l/r1 (m32 #10)
8613 (define-pmacro (mov32-src-r sz szcode mode src dst opc1 opc2)
8615 (dni (.sym mov32. sz - src - dst)
8616 (.str "mov." sz "src," dst)
8618 (.str "mov." sz "$S ${" (.sym src - mode) "}," dst)
8619 (+ (f-0-2 opc1) (.sym src - mode) (f-4-3 opc2) (f-7-1 szcode))
8620 (mov-sem mode (.sym src - mode) (reg (.sym h- dst)))
8624 (mov32-src-r b 0 QI dst32-2-S-16 r0l 0 4)
8625 (mov32-src-r w 1 HI dst32-2-S-16 r0 0 4)
8626 (mov32-src-r b 0 QI dst32-2-S-8 r0l 0 4)
8627 (mov32-src-r w 1 HI dst32-2-S-8 r0 0 4)
8628 (mov32-src-r b 0 QI dst32-2-S-basic r1l 1 7)
8629 (mov32-src-r w 1 HI dst32-2-S-basic r1l 1 7)
8630 (mov32-src-r b 0 QI dst32-2-S-16 r1l 1 7)
8631 (mov32-src-r w 1 HI dst32-2-S-16 r1 1 7)
8632 (mov32-src-r b 0 QI dst32-2-S-8 r1l 1 7)
8633 (mov32-src-r w 1 HI dst32-2-S-8 r1 1 7)
8635 ; mov.BW:S r0l/r0,dst2 (m32 #11)
8636 (define-pmacro (mov32-r-dest sz szcode mode src dst opc1 opc2)
8638 (dni (.sym mov32. sz - src - dst)
8639 (.str "mov." sz "src," dst)
8641 (.str "mov." sz "$S " src ",${" (.sym dst - mode) "}")
8642 (+ (f-0-2 opc1) (.sym dst - mode) (f-4-3 opc2) (f-7-1 szcode))
8643 (mov-sem mode (reg (.sym h- src)) (.sym dst - mode))
8647 (mov32-r-dest b 0 QI r0l dst32-2-S-16 0 0)
8648 (mov32-r-dest w 1 HI r0 dst32-2-S-16 0 0)
8649 (mov32-r-dest b 0 QI r0l dst32-2-S-8 0 0)
8650 (mov32-r-dest w 1 HI r0 dst32-2-S-8 0 0)
8652 ; mov.L:S src,A0/A1 (m32 #12)
8653 (define-pmacro (mov32-src-a src dst dstcode opc1 opc2)
8655 (dni (.sym mov32. sz - src - dst)
8656 (.str "mov." sz "src," dst)
8658 (.str "mov.l" "$S ${" (.sym src - SI) "}," dst)
8659 (+ (f-0-2 opc1) (.sym src - SI) (f-4-3 opc2) (f-7-1 dstcode))
8660 (mov-sem SI (.sym src - SI) (reg (.sym h- dst)))
8664 (mov32-src-a dst32-2-S-16 a0 0 1 4)
8665 (mov32-src-a dst32-2-S-16 a1 1 1 4)
8666 (mov32-src-a dst32-2-S-8 a0 0 1 4)
8667 (mov32-src-a dst32-2-S-8 a1 1 1 4)
8669 ; mov.BW:G dsp8[sp],dst (m16 #10 m32 #13)
8670 ; mov.BW:G src,dsp8[sp] (m16 #11 m32 #14)
8671 (mov-dspsp-dst mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #xB) #xB #x0 #xF mov-dspsp-dst-sem)
8672 (mov-src-dspsp mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #x3) #xA #x0 #xF mov-src-dspsp-sem)
8674 ;-------------------------------------------------------------
8675 ; mova - move effective address
8676 ;-------------------------------------------------------------
8678 (define-pmacro (mov16a-defn dst dstop dstcode)
8679 (dni (.sym mova16. src - dst)
8680 (.str "mova src," dst)
8682 (.str "mova ${dst16-16-Mova-HI}," dst)
8683 (+ (f-0-4 #xE) (f-4-4 #xB) dst16-16-Mova-HI (f-8-4 dstcode))
8684 (sequence () (set HI (reg dstop) dst16-16-Mova-HI))
8687 (mov16a-defn r0 h-r0 0)
8688 (mov16a-defn r1 h-r1 1)
8689 (mov16a-defn r2 h-r2 2)
8690 (mov16a-defn r3 h-r3 3)
8691 (mov16a-defn a0 h-a0 4)
8692 (mov16a-defn a1 h-a1 5)
8694 (define-pmacro (mov32a-defn dst dstop dstcode)
8695 (dni (.sym mova32. src - dst)
8696 (.str "mova src," dst)
8698 (.str "mova ${dst32-16-Unprefixed-Mova-SI}," dst)
8699 (+ (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))
8700 (sequence () (set SI (reg dstop) dst32-16-Unprefixed-Mova-SI))
8703 (mov32a-defn r2r0 h-r2r0 0)
8704 (mov32a-defn r3r1 h-r3r1 1)
8705 (mov32a-defn a0 h-a0 2)
8706 (mov32a-defn a1 h-a1 3)
8708 ;-------------------------------------------------------------
8709 ; movDir - move nibble
8710 ;-------------------------------------------------------------
8712 (define-pmacro (movdir-sem nib src dst)
8713 (sequence ((SI tmp))
8715 ((0) (set dst (or (and dst #xf0) (and src #xf))))
8716 ((1) (set dst (or (and dst #x0f) (sll (and src #xf) 4))))
8717 ((2) (set dst (or (and dst #xf0) (srl (and src #xf0) 4))))
8718 ((3) (set dst (or (and dst #x0f) (and src #xf0))))
8723 (define-pmacro (mov16dir-1-defn nib dircode dir)
8724 (dni (.sym mov nib 16 ".r0l-dst")
8725 (.str "mov" nib " r0l,dst")
8727 (.str "mov" nib " r0l,${dst16-16-QI}")
8728 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI)
8729 (movdir-sem dircode (reg h-r0l) dst16-16-QI)
8732 (mov16dir-1-defn ll 0 8)
8733 (mov16dir-1-defn lh 1 #xA)
8734 (mov16dir-1-defn hl 2 9)
8735 (mov16dir-1-defn hh 3 #xB)
8736 (define-pmacro (mov16dir-2-defn nib dircode dir)
8737 (dni (.sym mov nib 16 ".src-r0l")
8738 (.str "mov" nib " src,r0l")
8740 (.str "mov" nib " ${dst16-16-QI},r0l")
8741 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI)
8742 (movdir-sem dircode dst16-16-QI (reg h-r0l))
8745 (mov16dir-2-defn ll 0 0)
8746 (mov16dir-2-defn lh 1 2)
8747 (mov16dir-2-defn hl 2 1)
8748 (mov16dir-2-defn hh 3 3)
8750 (define-pmacro (mov32dir-1-defn nib o1o0)
8751 (dni (.sym mov nib 32 ".r0l-dst")
8752 (.str "mov" nib " r0l,dst")
8754 (.str "mov" nib " r0l,${dst32-24-Prefixed-QI}")
8755 (+ (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))
8756 (movdir-sem o1o0 (reg h-r0l) dst32-24-Prefixed-QI)
8759 (mov32dir-1-defn ll 0)
8760 (mov32dir-1-defn lh 1)
8761 (mov32dir-1-defn hl 2)
8762 (mov32dir-1-defn hh 3)
8763 (define-pmacro (mov32dir-2-defn nib o1o0)
8764 (dni (.sym mov nib 32 ".src-r0l")
8765 (.str "mov" nib " src,r0l")
8767 (.str "mov" nib " ${dst32-24-Prefixed-QI},r0l")
8768 (+ (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))
8769 (movdir-sem o1o0 dst32-24-Prefixed-QI (reg h-r0l))
8772 (mov32dir-2-defn ll 0)
8773 (mov32dir-2-defn lh 1)
8774 (mov32dir-2-defn hl 2)
8775 (mov32dir-2-defn hh 3)
8777 ;-------------------------------------------------------------
8778 ; movx - move extend sign (m32)
8779 ;-------------------------------------------------------------
8781 (define-pmacro (movx-sem mode src dst)
8782 (sequence ((SI source) (SI result))
8784 (set-z-and-s result)
8789 (binary-arith32-imm-dst-defn QI SI "" 0 movx X #xB #x1 #x1 movx-sem)
8791 ;-------------------------------------------------------------
8793 ;-------------------------------------------------------------
8795 (define-pmacro (mul-sem mode src1 dst)
8796 (sequence ((mode result))
8797 (set obit (add-oflag mode src1 dst 0))
8798 (set result (mul mode src1 dst))
8803 (binary-arith-imm-dst mul G (f-0-4 7) (f-4-3 6) (f-8-4 5) #x8 #x1 #xF mul-sem)
8805 (binary-arith-src-dst mul G (f-0-4 #x7) (f-4-3 4) #x1 #xC mul-sem)
8807 ;-------------------------------------------------------------
8808 ; mulex - multiple extend sign (m32)
8809 ;-------------------------------------------------------------
8812 ; (dni mulex-absolute-indirect "mulex [src]" ((machine 32))
8813 ; ("mulex ${dst32-24-absolute-indirect-HI}")
8814 ; (+ (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))
8815 ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-absolute-indirect-HI)))
8817 (dni mulex "mulex src" ((machine 32))
8818 ("mulex ${dst32-16-Unprefixed-Mulex-HI}")
8819 (+ (f-0-4 #xC) dst32-16-Unprefixed-Mulex-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
8820 (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-16-Unprefixed-Mulex-HI)))
8822 ; (dni mulex-indirect "mulex [src]" ((machine 32))
8823 ; ("mulex ${dst32-24-indirect-HI}")
8824 ; (+ (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))
8825 ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-indirect-HI)))
8828 ;-------------------------------------------------------------
8829 ; mulu - multiply unsigned
8830 ;-------------------------------------------------------------
8832 (define-pmacro (mulu-sem mode src1 dst)
8833 (sequence ((mode result))
8834 (set obit (add-oflag mode src1 dst 0))
8835 (set result (mul mode src1 dst))
8840 (binary-arith-imm-dst mulu G (f-0-4 7) (f-4-3 6) (f-8-4 4) #x8 #x0 #xF mulu-sem)
8842 (binary-arith-src-dst mulu G (f-0-4 #x7) (f-4-3 0) #x1 #x4 mulu-sem)
8844 ;-------------------------------------------------------------
8845 ; neg - twos complement
8846 ;-------------------------------------------------------------
8848 (define-pmacro (neg-sem mode dst)
8849 (sequence ((mode result))
8850 (set result (neg mode dst))
8851 (set-z-and-s result)
8856 (unary-insn neg (f-0-4 7) (f-4-3 2) (f-8-4 #x5) #xA #x2 #xF neg-sem)
8858 ;-------------------------------------------------------------
8859 ; not - twos complement
8860 ;-------------------------------------------------------------
8862 (define-pmacro (not-sem mode dst)
8863 (sequence ((mode result))
8864 (set result (not mode dst))
8865 (set-z-and-s result)
8870 (unary-insn not (f-0-4 7) (f-4-3 2) (f-8-4 #x7) #xA #x1 #xE not-sem)
8872 ;-------------------------------------------------------------
8874 ;-------------------------------------------------------------
8880 (+ (f-0-4 #x0) (f-4-4 #x4))
8888 (+ (f-0-4 #xD) (f-4-4 #xE))
8892 ;-------------------------------------------------------------
8894 ;-------------------------------------------------------------
8896 (define-pmacro (or-sem mode src1 dst)
8897 (sequence ((mode result))
8898 (set result (or mode src1 dst))
8899 (set-z-and-s result)
8903 ; or.BW #imm,dst (m16 #1 m32 #1)
8904 (binary-arith-imm-dst or G (f-0-4 7) (f-4-3 3) (f-8-4 3) #x8 #x2 #xF or-sem)
8905 ; or.b:S #imm8,dst3 (m16 #2 m32 #2)
8906 (binary-arith16-b-S-imm8-dst3 or ".b" (f-0-4 9) (f-4-1 1) or-sem)
8907 (binary-arith32-s-imm-dst QI .b 0 or #x1 #x2 or-sem)
8908 (binary-arith32-s-imm-dst HI .w 1 or #x1 #x2 or-sem)
8909 ; or.BW src,dst (m16 #3 m32 #3)
8910 (binary-arith-src-dst or G (f-0-4 #x9) (f-4-3 4) #x1 #x5 or-sem)
8912 ;-------------------------------------------------------------
8913 ; pop - restore register/memory
8914 ;-------------------------------------------------------------
8916 ; TODO future: split this into .b and .w semantics
8917 (define-pmacro (pop-sem-mach mach mode dst)
8918 (sequence ((mode b_or_w) (SI length))
8920 (set b_or_w (srl b_or_w #x8))
8923 (set length 2)) ; .w
8926 ((1) (set dst (mem-mach mach QI (reg h-sp))))
8927 ((2) (set dst (mem-mach mach HI (reg h-sp)))))
8928 (set (reg h-sp) (add (reg h-sp) length))
8932 (define-pmacro (pop-sem16 mode dest) (pop-sem-mach 16 mode dest))
8933 (define-pmacro (pop-sem32 mode dest) (pop-sem-mach 32 mode dest))
8936 (unary-insn-mach 16 pop (f-0-4 7) (f-4-3 2) (f-8-4 #xD) pop-sem16)
8938 (unary-insn-mach 32 pop #xB #x2 #xF pop-sem32)
8941 (dni pop16.b-s-rn "pop.b:S r0[lh]" ((machine 16))
8942 "pop.b$S ${Rn16-push-S-anyof}"
8943 (+ (f-0-4 #x9) Rn16-push-S-anyof (f-5-3 #x2))
8944 (pop-sem16 QI Rn16-push-S-anyof)
8947 (dni pop16.b-s-an "pop.w:S a[01]" ((machine 16))
8948 "pop.w$S ${An16-push-S-anyof}"
8949 (+ (f-0-4 #xD) An16-push-S-anyof (f-5-3 #x2))
8950 (pop-sem16 HI An16-push-S-anyof)
8953 ;-------------------------------------------------------------
8954 ; popc - pop control register
8955 ; pushc - push control register
8956 ;-------------------------------------------------------------
8958 (define-pmacro (popc32-cr1-sem mode dst)
8961 ((#x0) (set (reg h-dct0) (mem32 mode (reg h-sp))))
8962 ((#x1) (set (reg h-dct1) (mem32 mode (reg h-sp))))
8963 ((#x2) (sequence ((HI tflag))
8964 (set tflag (mem32 mode (reg h-sp)))
8965 (if (and tflag #x1) (set cbit 1))
8966 (if (and tflag #x2) (set dbit 1))
8967 (if (and tflag #x4) (set zbit 1))
8968 (if (and tflag #x8) (set sbit 1))
8969 (if (and tflag #x10) (set bbit 1))
8970 (if (and tflag #x20) (set obit 1))
8971 (if (and tflag #x40) (set ibit 1))
8972 (if (and tflag #x80) (set ubit 1))))
8973 ((#x3) (set (reg h-svf) (mem32 mode (reg h-sp))))
8974 ((#x4) (set (reg h-drc0) (mem32 mode (reg h-sp))))
8975 ((#x5) (set (reg h-drc1) (mem32 mode (reg h-sp))))
8976 ((#x6) (set (reg h-dmd0) (mem32 mode (reg h-sp))))
8977 ((#x7) (set (reg h-dmd1) (mem32 mode (reg h-sp))))
8979 (set (reg h-sp) (add (reg h-sp) 2))
8982 (define-pmacro (popc32-cr2-sem mode dst)
8985 ((#x0) (set (reg h-intb) (mem32 mode (reg h-sp))))
8986 ((#x1) (set (reg h-sp) (mem32 mode (reg h-sp))))
8987 ((#x2) (set (reg h-sb) (mem32 mode (reg h-sp))))
8988 ((#x3) (set (reg h-fb) (mem32 mode (reg h-sp))))
8989 ((#x7) (set (reg h-isp) (mem32 mode (reg h-sp))))
8991 (set (reg h-sp) (add (reg h-sp) 4))
8994 (define-pmacro (popc16-sem mode dst)
8997 ((#x1) (set (reg h-intb) (or (and (reg h-intb) #x0000)
8998 (mem16 mode (reg h-sp)))))
8999 ((#x2) (set (reg h-intb) (or (and (reg h-intb) #xffff0000)
9000 (mem16 mode (reg h-sp)))))
9001 ((#x3) (sequence ((HI tflag))
9002 (set tflag (mem16 mode (reg h-sp)))
9003 (if (and tflag #x1) (set cbit 1))
9004 (if (and tflag #x2) (set dbit 1))
9005 (if (and tflag #x4) (set zbit 1))
9006 (if (and tflag #x8) (set sbit 1))
9007 (if (and tflag #x10) (set bbit 1))
9008 (if (and tflag #x20) (set obit 1))
9009 (if (and tflag #x40) (set ibit 1))
9010 (if (and tflag #x80) (set ubit 1))))
9011 ((#x4) (set (reg h-isp) (mem16 mode (reg h-sp))))
9012 ((#x5) (set (reg h-sp) (mem16 mode (reg h-sp))))
9013 ((#x6) (set (reg h-sb) (mem16 mode (reg h-sp))))
9014 ((#x7) (set (reg h-fb) (mem16 mode (reg h-sp))))
9016 (set (reg h-sp) (add (reg h-sp) 2))
9019 ; popc dest (m16c #1)
9020 (dni popc16.imm16 "popc dst" ((machine 16))
9022 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 3) cr16)
9023 (popc16-sem HI cr16)
9025 ; popc dest (m32c #1)
9026 (dni popc32.imm16-cr1 "popc dst" ((machine 32))
9027 ("popc ${cr1-Unprefixed-32}")
9028 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32)
9029 (popc32-cr1-sem HI cr1-Unprefixed-32)
9031 ; popc dest (m32c #2)
9032 (dni popc32.imm16-cr2 "popc dst" ((machine 32))
9034 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 2) (f-12-1 1) cr2-32)
9035 (popc32-cr2-sem SI cr2-32)
9038 (define-pmacro (pushc32-cr1-sem mode dst)
9040 (set (reg h-sp) (sub (reg h-sp) 2))
9042 ((#x0) (set (mem32 mode (reg h-sp)) (reg h-dct0)))
9043 ((#x1) (set (mem32 mode (reg h-sp)) (reg h-dct1)))
9044 ((#x2) (sequence ((HI tflag))
9046 (if (eq cbit 1) (set tflag (or tflag #x1)))
9047 (if (eq dbit 1) (set tflag (or tflag #x2)))
9048 (if (eq zbit 1) (set tflag (or tflag #x4)))
9049 (if (eq sbit 1) (set tflag (or tflag #x8)))
9050 (if (eq bbit 1) (set tflag (or tflag #x10)))
9051 (if (eq obit 1) (set tflag (or tflag #x20)))
9052 (if (eq ibit 1) (set tflag (or tflag #x40)))
9053 (if (eq ubit 1) (set tflag (or tflag #x80)))
9054 (set (mem32 mode (reg h-sp)) tflag)))
9055 ((#x3) (set (mem32 mode (reg h-sp)) (reg h-svf)))
9056 ((#x4) (set (mem32 mode (reg h-sp)) (reg h-drc0)))
9057 ((#x5) (set (mem32 mode (reg h-sp)) (reg h-drc1)))
9058 ((#x6) (set (mem32 mode (reg h-sp)) (reg h-dmd0)))
9059 ((#x7) (set (mem32 mode (reg h-sp)) (reg h-dmd1)))
9063 (define-pmacro (pushc32-cr2-sem mode dst)
9065 (set (reg h-sp) (sub (reg h-sp) 4))
9067 ((#x0) (set (mem32 mode (reg h-sp)) (reg h-intb)))
9068 ((#x1) (set (mem32 mode (reg h-sp)) (reg h-sp)))
9069 ((#x2) (set (mem32 mode (reg h-sp)) (reg h-sb)))
9070 ((#x3) (set (mem32 mode (reg h-sp)) (reg h-fb)))
9071 ((#x7) (set (mem32 mode (reg h-sp)) (reg h-isp)))
9075 (define-pmacro (pushc16-sem mode dst)
9077 (set (reg h-sp) (sub (reg h-sp) 2))
9079 ((#x1) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff)))
9080 ((#x2) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff0000)))
9081 ((#x3) (sequence ((HI tflag))
9082 (if (eq cbit 1) (set tflag (or tflag #x1)))
9083 (if (eq dbit 1) (set tflag (or tflag #x2)))
9084 (if (eq zbit 1) (set tflag (or tflag #x4)))
9085 (if (eq sbit 1) (set tflag (or tflag #x8)))
9086 (if (eq bbit 1) (set tflag (or tflag #x10)))
9087 (if (eq obit 1) (set tflag (or tflag #x20)))
9088 (if (eq ibit 1) (set tflag (or tflag #x40)))
9089 (if (eq ubit 1) (set tflag (or tflag #x80)))
9090 (set (mem16 mode (reg h-sp)) tflag)))
9092 ((#x4) (set (mem16 mode (reg h-sp)) (reg h-isp)))
9093 ((#x5) (set (mem16 mode (reg h-sp)) (reg h-sp)))
9094 ((#x6) (set (mem16 mode (reg h-sp)) (reg h-sb)))
9095 ((#x7) (set (mem16 mode (reg h-sp)) (reg h-fb)))
9100 (dni pushc16.imm16 "pushc dst" ((machine 16))
9102 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 2) cr16)
9103 (pushc16-sem HI cr16)
9105 ; pushc src (m32c #1)
9106 (dni pushc32.imm16-cr1 "pushc dst" ((machine 32))
9107 ("pushc ${cr1-Unprefixed-32}")
9108 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32)
9109 (pushc32-cr1-sem HI cr1-Unprefixed-32)
9111 ; pushc src (m32c #2)
9112 (dni pushc32.imm16-cr2 "pushc dst" ((machine 32))
9114 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 2) (f-12-1 1) cr2-32)
9115 (pushc32-cr2-sem SI cr2-32)
9118 ;-------------------------------------------------------------
9119 ; popm - pop multiple
9120 ; pushm - push multiple
9121 ;-------------------------------------------------------------
9123 (define-pmacro (popm-sem machine dst)
9124 (sequence ((SI addrlen))
9129 (sequence () (set R0 (mem-mach machine HI (reg h-sp)))
9130 (set (reg h-sp) (add (reg h-sp) 2))))
9132 (sequence () (set R1 (mem-mach machine HI (reg h-sp)))
9133 (set (reg h-sp) (add (reg h-sp) 2))))
9135 (sequence () (set R2 (mem-mach machine HI (reg h-sp)))
9136 (set (reg h-sp) (add (reg h-sp) 2))))
9138 (sequence () (set R3 (mem-mach machine HI (reg h-sp)))
9139 (set (reg h-sp) (add (reg h-sp) 2))))
9141 (sequence () (set A0 (mem-mach machine HI (reg h-sp)))
9142 (set (reg h-sp) (add (reg h-sp) addrlen))))
9144 (sequence () (set A1 (mem-mach machine HI (reg h-sp)))
9145 (set (reg h-sp) (add (reg h-sp) addrlen))))
9147 (sequence () (set (reg h-sb) (mem-mach machine HI (reg h-sp)))
9148 (set (reg h-sp) (add (reg h-sp) addrlen))))
9150 (sequence () (set (reg h-fb) (mem-mach machine HI (reg h-sp)))
9151 (set (reg h-sp) (add (reg h-sp) addrlen))))
9155 (define-pmacro (pushm-sem machine dst)
9156 (sequence ((SI count) (SI addrlen))
9161 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9162 (set (mem-mach machine HI (reg h-sp)) (reg h-fb))))
9164 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9165 (set (mem-mach machine HI (reg h-sp)) (reg h-sb))))
9167 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9168 (set (mem-mach machine HI (reg h-sp)) A1)))
9170 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9171 (set (mem-mach machine HI (reg h-sp)) A0)))
9173 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9174 (set (mem-mach machine HI (reg h-sp)) R3)))
9176 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9177 (set (mem-mach machine HI (reg h-sp)) R2)))
9179 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9180 (set (mem-mach machine HI (reg h-sp)) R1)))
9182 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9183 (set (mem-mach machine HI (reg h-sp)) R0)))
9187 (dni popm16 "popm regs" ((machine 16))
9188 ("popm ${Regsetpop}")
9189 (+ (f-0-4 #xE) (f-4-4 #xD) Regsetpop)
9190 (popm-sem 16 Regsetpop)
9192 (dni pushm16 "pushm regs" ((machine 16))
9193 ("pushm ${Regsetpush}")
9194 (+ (f-0-4 #xE) (f-4-4 #xC) Regsetpush)
9195 (pushm-sem 16 Regsetpush)
9197 (dni popm "popm regs" ((machine 32))
9198 ("popm ${Regsetpop}")
9199 (+ (f-0-4 #x8) (f-4-4 #xE) Regsetpop)
9200 (popm-sem 32 Regsetpop)
9202 (dni pushm "pushm regs" ((machine 32))
9203 ("pushm ${Regsetpush}")
9204 (+ (f-0-4 #x8) (f-4-4 #xF) Regsetpush)
9205 (pushm-sem 32 Regsetpush)
9208 ;-------------------------------------------------------------
9209 ; push - Save register/memory/immediate data
9210 ;-------------------------------------------------------------
9212 ; TODO future: split this into .b and .w semantics
9213 (define-pmacro (push-sem-mach mach mode dst)
9214 (sequence ((mode b_or_w) (SI length))
9216 (set b_or_w (srl b_or_w #x8))
9219 (if (eq b_or_w #xff)
9221 (set length 4))) ; .l
9222 (set (reg h-sp) (sub (reg h-sp) length))
9224 ((1) (set (mem-mach mach QI (reg h-sp)) dst))
9225 ((2) (set (mem-mach mach HI (reg h-sp)) dst))
9226 ((4) (set (mem-mach mach SI (reg h-sp)) dst)))
9230 (define-pmacro (push-sem16 mode dst) (push-sem-mach 16 mode dst))
9231 (define-pmacro (push-sem32 mode dst) (push-sem-mach 32 mode dst))
9233 ; push.BW:G imm (m16 #1 m32 #1)
9234 (dni push16.b.G-imm "push.b:G #Imm-16-QI" ((machine 16))
9235 ("push.b$G #${Imm-16-QI}")
9236 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 2) Imm-16-QI)
9237 (push-sem16 QI Imm-16-QI)
9240 (dni push16.w.G-imm "push.w:G #Imm-16-HI" ((machine 16))
9241 ("push.w$G #${Imm-16-HI}")
9242 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 2) Imm-16-HI)
9243 (push-sem16 HI Imm-16-HI)
9246 (dni push32.b.imm "push.w #Imm-8-QI" ((machine 32))
9247 ("push.b #Imm-8-QI")
9248 (+ (f-0-4 #xA) (f-4-4 #xE) Imm-8-QI)
9249 (push-sem32 QI Imm-8-QI)
9252 (dni push32.w.imm "push.w #Imm-8-HI" ((machine 32))
9253 ("push.w #${Imm-8-HI}")
9254 (+ (f-0-4 #xA) (f-4-4 #xF) Imm-8-HI)
9255 (push-sem32 HI Imm-8-HI)
9258 ; push.BW:G src (m16 #2)
9259 (unary-insn-mach 16 push (f-0-4 7) (f-4-3 2) (f-8-4 #x4) push-sem16)
9260 ; push.BW:G src (m32 #2)
9261 (unary-insn-mach 32 push #xC #x0 #xE push-sem32)
9264 ; push.b:S r0l/r0h (m16 #3)
9265 (dni push16.b-s-rn "push.b:S r0[lh]" ((machine 16))
9266 "push.b$S ${Rn16-push-S-anyof}"
9267 (+ (f-0-4 #x8) Rn16-push-S-anyof (f-5-3 #x2))
9268 (push-sem16 QI Rn16-push-S-anyof)
9270 ; push.w:S a0/a1 (m16 #4)
9271 (dni push16.b-s-an "push.w:S a[01]" ((machine 16))
9272 "push.w$S ${An16-push-S-anyof}"
9273 (+ (f-0-4 #xC) An16-push-S-anyof (f-5-3 #x2))
9274 (push-sem16 HI An16-push-S-anyof)
9277 ; push.l imm32 (m32 #3)
9278 (dni push32.l.imm "push.l #Imm-16-SI" ((machine 32))
9279 ("push.l #${Imm-16-SI}")
9280 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 5) (f-12-4 3) Imm-16-SI)
9281 (push-sem32 SI Imm-16-SI)
9283 ; push.l src (m32 #4)
9284 (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)
9286 ;-------------------------------------------------------------
9287 ; pusha - push effective address
9288 ;------------------------------------------------------------
9290 (define-pmacro (push16a-sem mode dst)
9292 (set (reg h-sp) (sub (reg h-sp) 2))
9293 (set (mem16 HI (reg h-sp)) dst))
9295 (define-pmacro (push32a-sem mode dst)
9297 (set (reg h-sp) (sub (reg h-sp) 4))
9298 (set (mem32 SI (reg h-sp)) dst))
9300 (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)
9301 (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)
9303 ;-------------------------------------------------------------
9304 ; reit - return from interrupt
9305 ;-------------------------------------------------------------
9308 (dni reit16 "REIT" ((machine 16))
9310 (+ (f-0-4 #xF) (f-4-4 #xB))
9313 (dni reit32 "REIT" ((machine 32))
9315 (+ (f-0-4 9) (f-4-4 #xE))
9319 ;-------------------------------------------------------------
9320 ; rmpa - repeat multiple and addition
9321 ;-------------------------------------------------------------
9324 (dni rmpa16.b "rmpa.size" ((machine 16))
9326 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 1))
9329 (dni rmpa16.w "rmpa.size" ((machine 16))
9331 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 1))
9334 (dni rmpa32.b "rmpa.size" ((machine 32))
9336 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 4) (f-12-4 3))
9340 (dni rmpa32.w "rmpa.size" ((machine 32))
9342 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 5) (f-12-4 3))
9346 ;-------------------------------------------------------------
9347 ; rolc - rotate left with carry
9348 ;-------------------------------------------------------------
9350 ; TODO check semantics
9351 ; TODO future: split this into .b and .w semantics
9352 (define-pmacro (rolc-sem mode dst)
9353 (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask))
9355 (set b_or_w (srl b_or_w #x8))
9357 (set mask #x8000) ; .b
9358 (set mask #x80000000)) ; .w
9360 (set cbit (and dst mask))
9361 (set result (sll mode dst 1))
9362 (set result (or result ocbit))
9363 (set-z-and-s result)
9367 (unary-insn rolc (f-0-4 7) (f-4-3 3) (f-8-4 #xA) #xB #x2 #xE rolc-sem)
9369 ;-------------------------------------------------------------
9370 ; rorc - rotate right with carry
9371 ;-------------------------------------------------------------
9373 ; TODO check semantics
9374 ; TODO future: split this into .b and .w semantics
9375 (define-pmacro (rorc-sem mode dst)
9376 (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask) (SI shamt))
9378 (set b_or_w (srl b_or_w #x8))
9380 (sequence () (set mask #x7fff) (set shamt 15)) ; .b
9381 (sequence () (set mask #x7fffffff) (set shamt 31))) ; .w
9383 (set cbit (and dst #x1))
9384 (set result (srl mode dst (const 1)))
9385 (set result (or (and result mask) (sll ocbit shamt)))
9386 (set-z-and-s result)
9390 (unary-insn rorc (f-0-4 7) (f-4-3 3) (f-8-4 #xB) #xA #x2 #xE rorc-sem)
9392 ;-------------------------------------------------------------
9394 ;-------------------------------------------------------------
9396 ; TODO future: split this into .b and .w semantics
9397 (define-pmacro (rot-1-sem mode src1 dst)
9398 (sequence ((mode tmp) (mode b_or_w) (USI mask) (SI shift))
9400 ((#x0) (set shift 1))
9401 ((#x1) (set shift 2))
9402 ((#x2) (set shift 3))
9403 ((#x3) (set shift 4))
9404 ((#x4) (set shift 5))
9405 ((#x5) (set shift 6))
9406 ((#x6) (set shift 7))
9407 ((#x7) (set shift 8))
9408 ((-8) (set shift -1))
9409 ((-7) (set shift -2))
9410 ((-6) (set shift -3))
9411 ((-5) (set shift -4))
9412 ((-4) (set shift -5))
9413 ((-3) (set shift -6))
9414 ((-2) (set shift -7))
9415 ((-1) (set shift -8))
9416 (else (set shift 0))
9419 (set b_or_w (srl b_or_w #x8))
9421 (set mask #x7fff) ; .b
9422 (set mask #x7fffffff)) ; .w
9424 (if (gt mode shift 0)
9426 (set tmp (rol mode tmp shift))
9427 (set cbit (and tmp #x1)))
9429 (set tmp (ror mode tmp (mul shift -1)))
9430 (set cbit (and tmp mask))))
9434 (define-pmacro (rot-2-sem mode dst)
9435 (sequence ((mode tmp) (mode b_or_w) (USI mask))
9437 (set b_or_w (srl b_or_w #x8))
9439 (set mask #x7fff) ; .b
9440 (set mask #x7fffffff)) ; .w
9442 (if (gt mode (reg h-r1h) 0)
9444 (set tmp (rol mode tmp (reg h-r1h)))
9445 (set cbit (and tmp #x1)))
9447 (set tmp (ror mode tmp (reg h-r1h)))
9448 (set cbit (and tmp mask))))
9454 (binary-arith16-shimm4-dst-defn QI .b 0 0 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem)
9455 (binary-arith16-shimm4-dst-defn HI .w 0 1 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem)
9456 (binary-arith32-shimm4-dst-defn QI .b 0 0 rot #x7 #x2 rot-1-sem)
9457 (binary-arith32-shimm4-dst-defn HI .w 0 1 rot #x7 #x2 rot-1-sem)
9460 (dni rot16.b-dst "rot r1h,dest" ((machine 16))
9461 ("rot.b r1h,${dst16-16-HI}")
9462 (+ (f-0-4 7) (f-4-4 #x4) (f-8-4 #x6) dst16-16-HI)
9463 (rot-2-sem QI dst16-16-HI)
9465 (dni rot16.w-dst "rot r1h,dest" ((machine 16))
9466 ("rot.w r1h,${dst16-16-HI}")
9467 (+ (f-0-4 7) (f-4-4 #x5) (f-8-4 #x6) dst16-16-HI)
9468 (rot-2-sem HI dst16-16-HI)
9471 (dni rot32.b-dst "rot r1h,dest" ((machine 32))
9472 ("rot.b r1h,${dst32-16-Unprefixed-SI}")
9473 (+ (f-0-4 #xA) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 3) (f-12-4 #xF))
9474 (rot-2-sem QI dst32-16-Unprefixed-SI)
9476 (dni rot32.w-dst "rot r1h,dest" ((machine 32))
9477 ("rot.w r1h,${dst32-16-Unprefixed-SI}")
9478 (+ (f-0-4 #xA) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 3) (f-12-4 #xF))
9479 (rot-2-sem HI dst32-16-Unprefixed-SI)
9482 ;-------------------------------------------------------------
9483 ; rts - return from subroutine
9484 ;-------------------------------------------------------------
9486 (define-pmacro (rts16-sem)
9487 (sequence ((SI tpc))
9488 (set tpc (mem16 HI (reg h-sp)))
9489 (set (reg h-sp) (add (reg h-sp) 2))
9490 (set tpc (or tpc (sll (mem16 QI (reg h-sp)) 16)))
9491 (set (reg h-sp) (add (reg h-sp) 1))
9495 (define-pmacro (rts32-sem)
9496 (sequence ((SI tpc))
9497 (set tpc (mem32 HI (reg h-sp)))
9498 (set (reg h-sp) (add (reg h-sp) 2))
9499 (set tpc (or tpc (sll (mem32 HI (reg h-sp)) 16)))
9500 (set (reg h-sp) (add (reg h-sp) 2))
9505 (dni rts16 "rts" ((machine 16))
9507 (+ (f-0-4 #xF) (f-4-4 3))
9511 (dni rts32 "rts" ((machine 32))
9513 (+ (f-0-4 #xD) (f-4-4 #xF))
9517 ;-------------------------------------------------------------
9518 ; sbb - subtract with borrow
9519 ;-------------------------------------------------------------
9521 (define-pmacro (sbb-sem mode src dst)
9522 (sequence ((mode result))
9523 (set result (subc mode dst src cbit))
9524 (set obit (add-oflag mode dst src cbit))
9525 (set cbit (add-oflag mode dst src cbit))
9526 (set-z-and-s result)
9530 ; sbb.size:G #imm,dst
9531 (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)
9532 (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)
9533 (binary-arith32-imm-dst-Prefixed QI QI .b 0 sbb X #x9 #x2 #xE sbb-sem)
9534 (binary-arith32-imm-dst-Prefixed HI HI .w 1 sbb X #x9 #x2 #xE sbb-sem)
9537 (binary-arith16-src-dst-defn QI QI .b 0 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem)
9538 (binary-arith16-src-dst-defn HI HI .w 1 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem)
9539 (binary-arith32-src-dst-Prefixed QI QI .b 0 sbb X #x1 #x6 sbb-sem)
9540 (binary-arith32-src-dst-Prefixed HI HI .w 1 sbb X #x1 #x6 sbb-sem)
9542 ;-------------------------------------------------------------
9543 ; sbjnz - subtract then jump on not zero
9544 ;-------------------------------------------------------------
9546 (define-pmacro (sub-jnz-sem mode src dst label)
9547 (sequence ((mode result))
9548 (set result (sub mode dst src))
9554 ; sbjnz.size #imm4,dst,label
9555 (arith-jnz-imm4-dst sbjnz (f-0-4 #xF) (f-4-3 4) #xf #x1 sub-jnz-sem)
9557 ;-------------------------------------------------------------
9558 ; sccnd - store condition on condition (m32)
9559 ;-------------------------------------------------------------
9561 (define-pmacro (sccnd-sem cnd dst)
9565 ((#x00) (if (not cbit) (set dst 1))) ;ltu nc
9566 ((#x01) (if (or cbit zbit) (set dst 1))) ;leu
9567 ((#x02) (if (not zbit) (set dst 1))) ;ne nz
9568 ((#x03) (if (not sbit) (set dst 1))) ;pz
9569 ((#x04) (if (not obit) (set dst 1))) ;no
9570 ((#x05) (if (not (or zbit (xor sbit obit))) (set dst 1))) ;gt
9571 ((#x06) (if (xor sbit obit) (set dst 1))) ;ge
9572 ((#x08) (if (trunc BI cbit) (set dst 1))) ;geu c
9573 ((#x09) (if (not (or cbit zbit)) (set dst 1))) ;gtu
9574 ((#x0a) (if (trunc BI zbit) (set dst 1))) ;eq z
9575 ((#x0b) (if (trunc BI sbit) (set dst 1))) ;n
9576 ((#x0c) (if (trunc BI obit) (set dst 1))) ;o
9577 ((#x0d) (if (or zbit (xor sbit obit)) (set dst 1))) ;le
9578 ((#x0e) (if (xor sbit obit) (set dst 1))) ;lt
9587 "sc$sccond32 ${dst32-16-Unprefixed-HI}"
9588 (+ (f-0-4 #xD) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) sccond32)
9589 (sccnd-sem sccond32 dst32-16-Unprefixed-HI)
9592 ;-------------------------------------------------------------
9593 ; scmpu - string compare unequal (m32)
9594 ;-------------------------------------------------------------
9597 (dni scmpu.b "scmpu.b" ((machine 32))
9599 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xC) (f-12-4 3))
9600 (c-call VOID "scmpu_QI_semantics")
9603 (dni scmpu.w "scmpu.w" ((machine 32))
9605 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xD) (f-12-4 3))
9606 (c-call VOID "scmpu_HI_semantics")
9609 ;-------------------------------------------------------------
9610 ; sha - shift arithmetic
9611 ;-------------------------------------------------------------
9613 ; TODO future: split this into .b and .w semantics
9614 (define-pmacro (sha-sem mode src1 dst)
9615 (sequence ((mode result)(mode shift)(mode shmode))
9617 ((#x0) (set shift 1))
9618 ((#x1) (set shift 2))
9619 ((#x2) (set shift 3))
9620 ((#x3) (set shift 4))
9621 ((#x4) (set shift 5))
9622 ((#x5) (set shift 6))
9623 ((#x6) (set shift 7))
9624 ((#x7) (set shift 8))
9625 ((-8) (set shift -1))
9626 ((-7) (set shift -2))
9627 ((-6) (set shift -3))
9628 ((-5) (set shift -4))
9629 ((-4) (set shift -5))
9630 ((-3) (set shift -6))
9631 ((-2) (set shift -7))
9632 ((-1) (set shift -8))
9633 (else (set shift 0))
9636 (set shmode (srl shmode #x8))
9637 (if (lt mode shift #x0) (set result (sra mode dst (mul shift -1))))
9638 (if (gt mode shift 0) (set result (sll mode dst shift)))
9639 (if (eq shmode #x0) ; QI
9642 (if (lt mode shift #x0)
9643 (set cbitamt (sub #x8 shift)) ; sra
9644 (set cbitamt (sub shift 1))) ; sll
9645 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9646 (set obit (ne (and dst #x80) (and result #x80)))
9648 (if (eq shmode #xff) ; HI
9651 (if (lt mode shift #x0)
9652 (set cbitamt (sub 16 shift)) ; sra
9653 (set cbitamt (sub shift 1))) ; sll
9654 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9655 (set obit (ne (and dst #x8000) (and result #x8000)))
9657 (set-z-and-s result)
9660 (define-pmacro (shar1h-sem mode dst)
9661 (sequence ((mode result)(mode shmode))
9663 (set shmode (srl shmode #x8))
9664 (if (lt mode (reg h-r1h) 0) (set result (sra mode dst (reg h-r1h))))
9665 (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h))))
9666 (if (eq shmode #x0) ; QI
9669 (if (lt mode (reg h-r1h) #x0)
9670 (set cbitamt (sub #x8 (reg h-r1h))) ; sra
9671 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9672 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9673 (set obit (ne (and dst #x80) (and result #x80)))
9675 (if (eq shmode #xff) ; HI
9678 (if (lt mode (reg h-r1h) #x0)
9679 (set cbitamt (sub 16 (reg h-r1h))) ; sra
9680 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9681 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9682 (set obit (ne (and dst #x8000) (and result #x8000)))
9684 (set-z-and-s result)
9687 ; sha.BW #imm4,dst (m16 #1 m32 #1)
9688 (binary-arith16-shimm4-dst-defn QI .b 0 0 sha (f-0-4 #xF) (f-4-3 0) sha-sem)
9689 (binary-arith16-shimm4-dst-defn HI .w 0 1 sha (f-0-4 #xF) (f-4-3 0) sha-sem)
9690 (binary-arith32-shimm4-dst-defn QI .b 1 0 sha #x7 #x0 sha-sem)
9691 (binary-arith32-shimm4-dst-defn HI .w 1 1 sha #x7 #x0 sha-sem)
9692 ; sha.BW r1h,dst (m16 #2 m32 #3)
9693 (dni sha16.b-dst "sha.b r1h,dest" ((machine 16))
9694 ("sha.b r1h,${dst16-16-QI}")
9695 (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xF) dst16-16-QI)
9696 (shar1h-sem HI dst16-16-QI)
9698 (dni sha16.w-dst "sha.w r1h,dest" ((machine 16))
9699 ("sha.w r1h,${dst16-16-HI}")
9700 (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xF) dst16-16-HI)
9701 (shar1h-sem HI dst16-16-HI)
9703 (dni sha32.b-dst "sha.b r1h,dest" ((machine 32))
9704 ("sha.b r1h,${dst32-16-Unprefixed-QI}")
9705 (+ (f-0-4 #xB) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE))
9706 (shar1h-sem QI dst32-16-Unprefixed-QI)
9708 (dni sha32.w-dst "sha.w r1h,dest" ((machine 32))
9709 ("sha.w r1h,${dst32-16-Unprefixed-HI}")
9710 (+ (f-0-4 #xB) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
9711 (shar1h-sem HI dst32-16-Unprefixed-HI)
9713 ; sha.L #imm,dst (m16 #3)
9714 (dni sha16-L-imm-r2r0 "sha.L #Imm-sh-12-s4,r2r0" ((machine 16))
9715 "sha.l #${Imm-sh-12-s4},r2r0"
9716 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xA) Imm-sh-12-s4)
9717 (sha-sem SI Imm-sh-12-s4 (reg h-r2r0))
9719 (dni sha16-L-imm-r3r1 "sha.L #Imm-sh-12-s4,r3r1" ((machine 16))
9720 "sha.l #${Imm-sh-12-s4},r3r1"
9721 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xB) Imm-sh-12-s4)
9722 (sha-sem SI Imm-sh-12-s4 (reg h-r3r1))
9724 ; sha.L r1h,dst (m16 #4)
9725 (dni sha16-L-r1h-r2r0 "sha.L r1h,r2r0" ((machine 16))
9727 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 2) (f-12-4 1))
9728 (sha-sem SI (reg h-r1h) (reg h-r2r0))
9730 (dni sha16-L-r1h-r3r1 "sha.L r1h,r3r1" ((machine 16))
9732 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 3) (f-12-4 1))
9733 (sha-sem SI (reg h-r1h) (reg h-r3r1))
9735 ; sha.L #imm8,dst (m32 #2)
9736 (binary-arith32-imm-dst-defn QI SI .l 0 sha X #xA #x2 #x1 sha-sem)
9737 ; sha.L r1h,dst (m32 #4)
9738 (dni sha32.l-dst "sha.l r1h,dest" ((machine 32))
9739 ("sha.l r1h,${dst32-16-Unprefixed-SI}")
9740 (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 1) (f-12-4 1))
9741 (shar1h-sem QI dst32-16-Unprefixed-SI)
9744 ;-------------------------------------------------------------
9745 ; shanc - shift arithmetic non carry (m32)
9746 ;-------------------------------------------------------------
9748 ; TODO check semantics
9750 (binary-arith32-imm-dst-defn QI SI .l 0 shanc X #xC #x2 #x1 sha-sem)
9752 ;-------------------------------------------------------------
9753 ; shl - shift logical
9754 ;-------------------------------------------------------------
9756 ; TODO future: split this into .b and .w semantics
9757 (define-pmacro (shl-sem mode src1 dst)
9758 (sequence ((mode result)(mode shift)(mode shmode))
9760 ((#x0) (set shift 1))
9761 ((#x1) (set shift 2))
9762 ((#x2) (set shift 3))
9763 ((#x3) (set shift 4))
9764 ((#x4) (set shift 5))
9765 ((#x5) (set shift 6))
9766 ((#x6) (set shift 7))
9767 ((#x7) (set shift 8))
9768 ((-8) (set shift -1))
9769 ((-7) (set shift -2))
9770 ((-6) (set shift -3))
9771 ((-5) (set shift -4))
9772 ((-4) (set shift -5))
9773 ((-3) (set shift -6))
9774 ((-2) (set shift -7))
9775 ((-1) (set shift -8))
9776 (else (set shift 0))
9779 (set shmode (srl shmode #x8))
9780 (if (lt mode shift #x0) (set result (srl mode dst (mul shift -1))))
9781 (if (gt mode shift 0) (set result (sll mode dst shift)))
9782 (if (eq shmode #x0) ; QI
9785 (if (lt mode shift #x0)
9786 (set cbitamt (sub #x8 shift)); srl
9787 (set cbitamt (sub shift 1))) ; sll
9788 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9789 (set obit (ne (and dst #x80) (and result #x80)))
9791 (if (eq shmode #xff) ; HI
9794 (if (lt mode shift #x0)
9795 (set cbitamt (sub 16 shift)) ; srl
9796 (set cbitamt (sub shift 1))) ; sll
9797 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9798 (set obit (ne (and dst #x8000) (and result #x8000)))
9800 (set-z-and-s result)
9803 (define-pmacro (shlr1h-sem mode dst)
9804 (sequence ((mode result)(mode shmode))
9806 (set shmode (srl shmode #x8))
9807 (if (lt mode (reg h-r1h) 0) (set result (srl mode dst (reg h-r1h))))
9808 (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h))))
9809 (if (eq shmode #x0) ; QI
9812 (if (lt mode (reg h-r1h) #x0)
9813 (set cbitamt (sub #x8 (reg h-r1h))) ; srl
9814 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9815 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9816 (set obit (ne (and dst #x80) (and result #x80)))
9818 (if (eq shmode #xff) ; HI
9821 (if (lt mode (reg h-r1h) #x0)
9822 (set cbitamt (sub 16 (reg h-r1h))) ; srl
9823 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9824 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9825 (set obit (ne (and dst #x8000) (and result #x8000)))
9827 (set-z-and-s result)
9830 ; shl.BW #imm4,dst (m16 #1 m32 #1)
9831 (binary-arith16-shimm4-dst-defn QI .b 0 0 shl (f-0-4 #xE) (f-4-3 4) shl-sem)
9832 (binary-arith16-shimm4-dst-defn HI .w 0 1 shl (f-0-4 #xE) (f-4-3 4) shl-sem)
9833 (binary-arith32-shimm4-dst-defn QI .b 0 0 shl #x7 #x0 shl-sem)
9834 (binary-arith32-shimm4-dst-defn HI .w 0 1 shl #x7 #x0 shl-sem)
9835 ; shl.BW r1h,dst (m16 #2 m32 #3)
9836 (dni shl16.b-dst "shl.b r1h,dest" ((machine 16))
9837 ("shl.b r1h,${dst16-16-QI}")
9838 (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xE) dst16-16-QI)
9839 (shlr1h-sem HI dst16-16-QI)
9841 (dni shl16.w-dst "shl.w r1h,dest" ((machine 16))
9842 ("shl.w r1h,${dst16-16-HI}")
9843 (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xE) dst16-16-HI)
9844 (shlr1h-sem HI dst16-16-HI)
9846 (dni shl32.b-dst "shl.b r1h,dest" ((machine 32))
9847 ("shl.b r1h,${dst32-16-Unprefixed-QI}")
9848 (+ (f-0-4 #xA) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE))
9849 (shlr1h-sem QI dst32-16-Unprefixed-QI)
9851 (dni shl32.w-dst "shl.w r1h,dest" ((machine 32))
9852 ("shl.w r1h,${dst32-16-Unprefixed-HI}")
9853 (+ (f-0-4 #xA) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
9854 (shlr1h-sem HI dst32-16-Unprefixed-HI)
9856 ; shl.L #imm,dst (m16 #3)
9857 (dni shl16-L-imm-r2r0 "shl.L #Imm-sh-12-s4,r2r0" ((machine 16))
9858 "shl.l #${Imm-sh-12-s4},r2r0"
9859 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x8) Imm-sh-12-s4)
9860 (shl-sem SI Imm-sh-12-s4 (reg h-r2r0))
9862 (dni shl16-L-imm-r3r1 "shl.L #Imm-sh-12-s4,r3r1" ((machine 16))
9863 "shl.l #${Imm-sh-12-s4},r3r1"
9864 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x9) Imm-sh-12-s4)
9865 (shl-sem SI Imm-sh-12-s4 (reg h-r3r1))
9867 ; shl.L r1h,dst (m16 #4)
9868 (dni shl16-L-r1h-r2r0 "shl.L r1h,r2r0" ((machine 16))
9870 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 0) (f-12-4 1))
9871 (shl-sem SI (reg h-r1h) (reg h-r2r0))
9873 (dni shl16-L-r1h-r3r1 "shl.L r1h,r3r1" ((machine 16))
9875 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 1) (f-12-4 1))
9876 (shl-sem SI (reg h-r1h) (reg h-r3r1))
9878 ; shl.L #imm8,dst (m32 #2)
9879 (binary-arith32-imm-dst-defn QI SI .l 0 shl X #x9 #x2 #x1 shl-sem)
9880 ; shl.L r1h,dst (m32 #4)
9881 (dni shl32.l-dst "shl.l r1h,dest" ((machine 32))
9882 ("shl.l r1h,${dst32-16-Unprefixed-SI}")
9883 (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 0) (f-12-4 1))
9884 (shlr1h-sem QI dst32-16-Unprefixed-SI)
9887 ;-------------------------------------------------------------
9888 ; shlnc - shift logical non carry
9889 ;-------------------------------------------------------------
9891 ; TODO check semantics
9893 (binary-arith32-imm-dst-defn QI SI .l 0 shlnc X #x8 #x2 #x1 shl-sem)
9895 ;-------------------------------------------------------------
9896 ; sin - string input (m32)
9897 ;-------------------------------------------------------------
9900 (dni sin32.b "sin" ((machine 32))
9902 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 8) (f-12-4 3))
9903 (c-call VOID "sin_QI_semantics")
9906 (dni sin32.w "sin" ((machine 32))
9908 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 9) (f-12-4 3))
9909 (c-call VOID "sin_HI_semantics")
9912 ;-------------------------------------------------------------
9913 ; smovb - string move backward
9914 ;-------------------------------------------------------------
9917 (dni smovb16.b "smovb.b" ((machine 16))
9919 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 9))
9920 (c-call VOID "smovb_QI_semantics")
9923 (dni smovb16.w "smovb.w" ((machine 16))
9925 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 9))
9926 (c-call VOID "smovb_HI_semantics")
9929 (dni smovb32.b "smovb.b" ((machine 32))
9931 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 8) (f-12-4 3))
9932 (c-call VOID "smovb_QI_semantics")
9935 (dni smovb32.w "smovb.w" ((machine 32))
9937 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 9) (f-12-4 3))
9938 (c-call VOID "smovb_HI_semantics")
9941 ;-------------------------------------------------------------
9942 ; smovf - string move forward (m32)
9943 ;-------------------------------------------------------------
9946 (dni smovf16.b "smovf.b" ((machine 16))
9948 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 8))
9949 (c-call VOID "smovf_QI_semantics")
9952 (dni smovf16.w "smovf.w" ((machine 16))
9954 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 8))
9955 (c-call VOID "smovf_HI_semantics")
9958 (dni smovf32.b "smovf.b" ((machine 32))
9960 (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 8) (f-12-4 3))
9961 (c-call VOID "smovf_QI_semantics")
9964 (dni smovf32.w "smovf.w" ((machine 32))
9966 (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 9) (f-12-4 3))
9967 (c-call VOID "smovf_HI_semantics")
9970 ;-------------------------------------------------------------
9971 ; smovu - string move unequal (m32)
9972 ;-------------------------------------------------------------
9975 (dni smovu.b "smovu.b" ((machine 32))
9977 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 8) (f-12-4 3))
9978 (c-call VOID "smovu_QI_semantics")
9981 (dni smovu.w "smovu.w" ((machine 32))
9983 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 9) (f-12-4 3))
9984 (c-call VOID "smovu_HI_semantics")
9987 ;-------------------------------------------------------------
9988 ; sout - string output (m32)
9989 ;-------------------------------------------------------------
9992 (dni sout.b "sout.b" ((machine 32))
9994 (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 8) (f-12-4 3))
9995 (c-call VOID "sout_QI_semantics")
9998 (dni sout.w "sout" ((machine 32))
10000 (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 9) (f-12-4 3))
10001 (c-call VOID "sout_HI_semantics")
10004 ;-------------------------------------------------------------
10005 ; sstr - string store
10006 ;-------------------------------------------------------------
10009 (dni sstr16.b "sstr.b" ((machine 16))
10011 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 #xA))
10012 (c-call VOID "sstr_QI_semantics")
10015 (dni sstr16.w "sstr.w" ((machine 16))
10017 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 #xA))
10018 (c-call VOID "sstr_HI_semantics")
10021 (dni sstr.b "sstr" ((machine 32))
10023 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 0) (f-12-4 3))
10024 (c-call VOID "sstr_QI_semantics")
10027 (dni sstr.w "sstr" ((machine 32))
10029 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 1) (f-12-4 3))
10030 (c-call VOID "sstr_HI_semantics")
10033 ;-------------------------------------------------------------
10034 ; stnz - store on not zero
10035 ;-------------------------------------------------------------
10037 (define-pmacro (stnz-sem mode src dst)
10039 (if (ne zbit (const 1))
10042 ; stnz #imm8,dst3 (m16)
10043 (binary-arith16-b-S-imm8-dst3 stnz "" (f-0-4 #xD) (f-4-1 0) stnz-sem)
10044 ; stnz.BW #imm,dst (m32)
10045 (binary-arith32-imm-dst-defn QI QI .b 0 stnz X #x9 #x1 #xF stnz-sem)
10046 (binary-arith32-imm-dst-defn HI HI .w 1 stnz X #x9 #x1 #xF stnz-sem)
10048 ;-------------------------------------------------------------
10049 ; stz - store on zero
10050 ;-------------------------------------------------------------
10052 (define-pmacro (stz-sem mode src dst)
10054 (if (eq zbit (const 1))
10057 ; stz #imm8,dst3 (m16)
10058 (binary-arith16-b-S-imm8-dst3 stz "" (f-0-4 #xC) (f-4-1 1) stz-sem)
10059 ; stz.BW #imm,dst (m32)
10060 (binary-arith32-imm-dst-defn QI QI .b 0 stz X #x9 #x0 #xF stz-sem)
10061 (binary-arith32-imm-dst-defn HI HI .w 1 stz X #x9 #x0 #xF stz-sem)
10063 ;-------------------------------------------------------------
10064 ; stzx - store on zero extention
10065 ;-------------------------------------------------------------
10067 (define-pmacro (stzx-sem mode src1 src2 dst)
10069 (if (eq zbit (const 1))
10073 ; stzx #imm8,dst3 (m16)
10074 (dni stzx16-imm8-imm8-r0h "stzx #Imm8,#Imm8,r0h" ((machine 16))
10075 ("stzx #${Imm-8-QI},#${Imm-16-QI},r0h")
10076 (+ (f-0-4 #xD) (f-4-4 #xB) Imm-8-QI Imm-16-QI)
10077 (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0h))
10079 (dni stzx16-imm8-imm8-r0l "stzx #Imm8,#Imm8,r0l" ((machine 16))
10080 ("stzx #${Imm-8-QI},#${Imm-16-QI},r0l")
10081 (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI Imm-16-QI)
10082 (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0l))
10084 (dni stzx16-imm8-imm8-dsp8sb "stzx #Imm8,#Imm8,dsp8[sb]" ((machine 16))
10085 ("stzx #${Imm-8-QI},#${Imm-16-QI},Dsp-24-u8[sb]")
10086 (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI Dsp-16-u8 Imm-24-QI)
10087 (stzx-sem QI Imm-8-QI Imm-16-QI (mem16 QI (add (reg h-sb) Dsp-24-u8)))
10089 (dni stzx16-imm8-imm8-dsp8fb "stzx #Imm8,#Imm8,dsp8[fb]" ((machine 16))
10090 ("stzx #${Imm-8-QI},#${Imm-16-QI},Dsp-24-u8[fb]")
10091 (+ (f-0-4 #xD) (f-4-4 #xE) Imm-8-QI Dsp-16-u8 Imm-24-QI)
10092 (stzx-sem QI Imm-8-QI Imm-16-QI (mem16 QI (add (reg h-fb) Dsp-24-u8)))
10094 (dni stzx16-imm8-imm8-abs16 "stzx #Imm8,#Imm8,abs16" ((machine 16))
10095 ("stzx #${Imm-8-QI},#${Imm-16-QI},Dsp-24-u16")
10096 (+ (f-0-4 #xD) (f-4-4 #xE) Imm-8-QI Dsp-16-u16 Imm-32-QI)
10097 (stzx-sem QI Imm-8-QI Imm-32-QI (mem16 QI Dsp-16-u16))
10099 ; stzx.BW #imm,dst (m32)
10100 (insn-imm1-imm2-dst-Unprefixed stzx #x9 #x3 #xF stzx-sem)
10102 ;-------------------------------------------------------------
10103 ; subx - subtract extend (m32)
10104 ;-------------------------------------------------------------
10106 (define-pmacro (subx-sem mode src1 dst)
10107 (sequence ((mode result))
10108 (set result (sub mode dst (ext mode src1)))
10109 (set obit (sub-oflag mode dst (ext mode src1) 0))
10110 (set cbit (sub-cflag mode dst (ext mode src1) 0))
10112 (set-z-and-s result)))
10114 (binary-arith32-imm-dst-defn QI SI "" 0 subx G #x9 #x1 #x1 subx-sem)
10116 (binary-arith32-src-dst-defn QI SI "" 0 subx G #x1 #x0 subx-sem)
10118 ;-------------------------------------------------------------
10120 ;-------------------------------------------------------------
10122 (define-pmacro (tst-sem mode src1 dst)
10123 (sequence ((mode result))
10124 (set result (and mode dst src1))
10125 (set-z-and-s result))
10128 ; tst.BW #imm,dst (m16 #1 m32 #1)
10129 (binary-arith-imm-dst tst X (f-0-4 7) (f-4-3 3) (f-8-4 0) #x9 #x3 #xE tst-sem)
10130 ; tst.BW src,dst (m16 #2 m32 #3)
10131 (binary-arith16-src-dst-defn QI QI .b 0 tst X (f-0-4 #x8) (f-4-3 0) tst-sem)
10132 (binary-arith16-src-dst-defn HI HI .w 1 tst X (f-0-4 #x8) (f-4-3 0) tst-sem)
10133 (binary-arith32-src-dst-Prefixed QI QI .b 0 tst X #x1 #x9 tst-sem)
10134 (binary-arith32-src-dst-Prefixed HI HI .w 1 tst X #x1 #x9 tst-sem)
10135 ; tst.BW:S #imm,dst2 (m32 #2)
10136 (binary-arith32-s-imm-dst QI .b 0 tst #x0 #x6 tst-sem)
10137 (binary-arith32-s-imm-dst HI .w 1 tst #x0 #x6 tst-sem)
10139 ;-------------------------------------------------------------
10141 ;-------------------------------------------------------------
10143 (dni und16 "und" ((machine 16))
10145 (+ (f-0-4 #xF) (f-4-4 #xF))
10149 (dni und32 "und" ((machine 32))
10151 (+ (f-0-4 #xF) (f-4-4 #xF))
10155 ;-------------------------------------------------------------
10157 ;-------------------------------------------------------------
10160 (dni wait16 "wait" ((machine 16))
10162 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 3))
10166 (dni wait "wait" ((machine 32))
10168 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 0) (f-12-4 3))
10172 ;-------------------------------------------------------------
10174 ;-------------------------------------------------------------
10176 (define-pmacro (xchg-sem mode src dst)
10177 (sequence ((mode result))
10182 (define-pmacro (xchg16-defn mode sz szc src srcreg)
10183 (dni (.sym xchg16 sz - srcreg)
10184 (.str "xchg" sz "-" srcreg ",dst16-16-" mode)
10186 (.str "xchg." sz " " srcreg ",${dst16-16-" mode "}")
10187 (+ (f-0-4 #x7) (f-4-3 #x5) (f-7-1 szc) (f-8-2 0) (f-10-2 src) (.sym dst16-16- mode))
10188 (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst16-16- mode))
10191 (xchg16-defn QI b 0 0 r0l)
10192 (xchg16-defn QI b 0 1 r0h)
10193 (xchg16-defn QI b 0 2 r1l)
10194 (xchg16-defn QI b 0 3 r1h)
10195 (xchg16-defn QI w 1 0 r0)
10196 (xchg16-defn HI w 1 1 r1)
10197 (xchg16-defn HI w 1 2 r2)
10198 (xchg16-defn HI w 1 3 r3)
10199 (define-pmacro (xchg32-defn mode sz szc src srcreg)
10200 (dni (.sym xchg32 sz - srcreg)
10201 (.str "xchg" sz "-" srcreg ",dst32-16-Unprefixed-" mode)
10203 (.str "xchg." sz " " srcreg ",${dst32-16-Unprefixed-" mode "}")
10204 (+ (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))
10205 (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst32-16-Unprefixed- mode))
10208 (xchg32-defn QI b 0 0 r0l)
10209 (xchg32-defn QI b 0 1 r1l)
10210 (xchg32-defn QI b 0 2 a0)
10211 (xchg32-defn QI b 0 3 a1)
10212 (xchg32-defn QI b 0 4 r0h)
10213 (xchg32-defn QI b 0 5 r1h)
10214 (xchg32-defn HI w 1 0 r0)
10215 (xchg32-defn HI w 1 1 r1)
10216 (xchg32-defn HI w 1 2 a0)
10217 (xchg32-defn HI w 1 3 a1)
10218 (xchg32-defn HI w 1 4 r2)
10219 (xchg32-defn HI w 1 5 r3)
10221 ;-------------------------------------------------------------
10222 ; xor - exclusive or
10223 ;-------------------------------------------------------------
10225 (define-pmacro (xor-sem mode src1 dst)
10226 (sequence ((mode result))
10227 (set result (xor mode src1 dst))
10228 (set-z-and-s result)
10232 ; xor.BW #imm,dst (m16 #1 m32 #1)
10233 (binary-arith-imm-dst xor G (f-0-4 7) (f-4-3 3) (f-8-4 1) #x9 #x0 #xE xor-sem)
10234 ; xor.BW src,dst (m16 #3 m32 #3)
10235 (binary-arith-src-dst xor G (f-0-4 #x8) (f-4-3 4) #x1 #x9 xor-sem)
10237 ;-------------------------------------------------------------
10239 ;-------------------------------------------------------------
10241 (define-pmacro (exts-sem smode dmode src dst)
10242 (set dst (ext dmode (trunc smode src)))
10244 (define-pmacro (extz-sem smode dmode src dst)
10245 (set dst (zext dmode (trunc smode src)))
10248 ; exts.b dst for m16c
10249 (ext16-defn QI HI .b 0 exts (f-0-4 7) (f-4-3 6) (f-8-4 6) exts-sem)
10251 ; exts.w r0 for m16c
10256 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 3))
10257 (exts-sem HI SI R0 R2R0)
10260 ; exts.size dst for m32c
10261 (ext32-defn QI HI .b 0 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem)
10262 (ext32-defn HI SI .w 1 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem)
10263 ; exts.b src,dst for m32c
10264 (ext32-binary-defn exts .b #x1 #x7 exts-sem)
10266 ; extz.b src,dst for m32c
10267 (ext32-binary-defn extz "" #x1 #xB extz-sem)
10269 ;-------------------------------------------------------------
10271 ;-------------------------------------------------------------
10274 (dni srcind "SRC-INDIRECT" ((machine 32))
10276 (+ (f-0-4 4) (f-4-4 1))
10277 (set (reg h-src-indirect) 1)
10280 (dni destind "DEST-INDIRECT" ((machine 32))
10282 (+ (f-0-4 0) (f-4-4 9))
10283 (set (reg h-dst-indirect) 1)
10286 (dni srcdestind "SRC-DEST-INDIRECT" ((machine 32))
10287 ("src-dest-indirect")
10288 (+ (f-0-4 4) (f-4-4 9))
10289 (sequence () (set (reg h-src-indirect) 1) (set (reg h-dst-indirect) 1))