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-16-8 "opcode" (all-isas) 16 8)
199 (dnf f-18-1 "opcode" (all-isas) 18 1)
200 (dnf f-18-2 "opcode" (all-isas) 18 2)
201 (dnf f-18-3 "opcode" (all-isas) 18 3)
202 (dnf f-20-1 "opcode" (all-isas) 20 1)
203 (dnf f-20-3 "opcode" (all-isas) 20 3)
204 (dnf f-20-2 "opcode" (all-isas) 20 2)
205 (dnf f-20-4 "opcode" (all-isas) 20 4)
206 (dnf f-21-3 "opcode" (all-isas) 21 3)
207 (dnf f-24-2 "opcode" (all-isas) 24 2)
208 (dnf f-24-8 "opcode" (all-isas) 24 8)
209 (dnf f-32-16 "opcode" (all-isas) 32 16)
211 ;-------------------------------------------------------------
213 ;-------------------------------------------------------------
215 (dnf f-src16-rn "source Rn for m16c" (MACH16 m16c-isa) 10 2)
216 (dnf f-src16-an "source An for m16c" (MACH16 m16c-isa) 11 1)
218 (dnf f-src32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 11 1)
219 (dnf f-src32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 19 1)
221 ; QI mode gr encoding for m32c is different than for m16c. The hardware
222 ; is indexed using the m16c encoding, so perform the transformation here.
224 ; ----------------------
229 (df f-src32-rn-unprefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 10 2 UINT
230 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
231 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
233 ; QI mode gr encoding for m32c is different than for m16c. The hardware
234 ; is indexed using the m16c encoding, so perform the transformation here.
236 ; ----------------------
241 (df f-src32-rn-prefixed-QI "source Rn QI for m32c" (MACH32 m32c-isa) 18 2 UINT
242 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
243 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
245 ; HI mode gr encoding for m32c is different than for m16c. The hardware
246 ; is indexed using the m16c encoding, so perform the transformation here.
248 ; ----------------------
253 (df f-src32-rn-unprefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 10 2 UINT
254 ((value pc) (mod USI (add value 2) 4)) ; insert
255 ((value pc) (mod USI (add value 2) 4)) ; extract
258 ; HI mode gr encoding for m32c is different than for m16c. The hardware
259 ; is indexed using the m16c encoding, so perform the transformation here.
261 ; ----------------------
266 (df f-src32-rn-prefixed-HI "source Rn HI for m32c" (MACH32 m32c-isa) 18 2 UINT
267 ((value pc) (mod USI (add value 2) 4)) ; insert
268 ((value pc) (mod USI (add value 2) 4)) ; extract
271 ; SI mode gr encoding for m32c is as follows:
272 ; register encoding index
273 ; -------------------------
276 (df f-src32-rn-unprefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 10 2 UINT
277 ((value pc) (add USI value 2)) ; insert
278 ((value pc) (sub USI value 2)) ; extract
280 (df f-src32-rn-prefixed-SI "source Rn SI for m32c" (MACH32 m32c-isa) 18 2 UINT
281 ((value pc) (add USI value 2)) ; insert
282 ((value pc) (sub USI value 2)) ; extract
285 (dnf f-dst32-rn-ext-unprefixed "destination Rn for m32c" (MACH32 m32c-isa) 9 1)
287 (dnf f-dst16-rn "destination Rn for m16c" (MACH16 m16c-isa) 14 2)
288 (dnf f-dst16-rn-ext "destination Rn for m16c" (MACH16 m16c-isa) 14 1)
289 (dnf f-dst16-rn-QI-s "destination Rn for m16c" (MACH16 m16c-isa) 5 1)
291 (dnf f-dst16-an "destination An for m16c" (MACH16 m16c-isa) 15 1)
292 (dnf f-dst16-an-s "destination An for m16c" (MACH16 m16c-isa) 4 1)
294 (dnf f-dst32-an-unprefixed "destination An for m32c" (MACH32 m32c-isa) 9 1)
295 (dnf f-dst32-an-prefixed "destination An for m32c" (MACH32 m32c-isa) 17 1)
297 ; QI mode gr encoding for m32c is different than for m16c. The hardware
298 ; is indexed using the m16c encoding, so perform the transformation here.
300 ; ----------------------
305 (df f-dst32-rn-unprefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 8 2 UINT
306 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
307 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
309 (df f-dst32-rn-prefixed-QI "destination Rn QI for m32c" (MACH32 m32c-isa) 16 2 UINT
310 ((value pc) (or USI (and (sll (inv value) 1) 2) (and (srl value 1) 1))) ; insert
311 ((value pc) (or USI (and (inv (srl value 1)) 1) (and (sll value 1) 2))) ; extract
313 ; HI mode gr encoding for m32c is different than for m16c. The hardware
314 ; is indexed using the m16c encoding, so perform the transformation here.
316 ; ----------------------
321 (df f-dst32-rn-unprefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 8 2 UINT
322 ((value pc) (mod USI (add value 2) 4)) ; insert
323 ((value pc) (mod USI (add value 2) 4)) ; extract
325 (df f-dst32-rn-prefixed-HI "destination Rn HI for m32c" (MACH32 m32c-isa) 16 2 UINT
326 ((value pc) (mod USI (add value 2) 4)) ; insert
327 ((value pc) (mod USI (add value 2) 4)) ; extract
329 ; SI mode gr encoding for m32c is as follows:
330 ; register encoding index
331 ; -------------------------
334 (df f-dst32-rn-unprefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 8 2 UINT
335 ((value pc) (add USI value 2)) ; insert
336 ((value pc) (sub USI value 2)) ; extract
338 (df f-dst32-rn-prefixed-SI "destination Rn SI for m32c" (MACH32 m32c-isa) 16 2 UINT
339 ((value pc) (add USI value 2)) ; insert
340 ((value pc) (sub USI value 2)) ; extract
343 (dnf f-dst16-1-S "destination R0[hl] for m16c" (MACH16 m16c-isa) 5 1)
345 ;-------------------------------------------------------------
346 ; Immediates embedded in the base insn
347 ;-------------------------------------------------------------
349 (df f-imm-8-s4 "4 bit signed" (all-isas) 8 4 INT #f #f)
350 (df f-imm-12-s4 "4 bit signed" (all-isas) 12 4 INT #f #f)
351 (df f-imm-13-u3 "3 bit unsigned" (all-isas) 13 3 UINT #f #f)
352 (df f-imm-20-s4 "4 bit signed" (all-isas) 20 4 INT #f #f)
354 (df f-imm1-S "1 bit immediate for short format binary insns" (MACH32 m32c-isa) 2 1 UINT
355 ((value pc) (sub USI value 1)) ; insert
356 ((value pc) (add USI value 1)) ; extract
359 (dnmf f-imm3-S "3 bit unsigned for short format insns" (all-isas) UINT
361 (sequence () ; insert
362 (set (ifield f-7-1) (and (sub (ifield f-imm3-S) 1) 1))
363 (set (ifield f-2-2) (and (srl (sub (ifield f-imm3-S) 1) 1) #x3))
365 (sequence () ; extract
366 (set (ifield f-imm3-S) (add (or (sll (ifield f-2-2) 1)
372 ;-------------------------------------------------------------
373 ; Immediates and displacements beyond the base insn
374 ;-------------------------------------------------------------
376 (df f-dsp-8-u6 "6 bit unsigned" (all-isas) 8 6 UINT #f #f)
377 (df f-dsp-8-u8 "8 bit unsigned" (all-isas) 8 8 UINT #f #f)
378 (df f-dsp-8-s8 "8 bit signed" (all-isas) 8 8 INT #f #f)
379 (df f-dsp-10-u6 "6 bit unsigned" (all-isas) 10 6 UINT #f #f)
380 (df f-dsp-16-u8 "8 bit unsigned" (all-isas) 16 8 UINT #f #f)
381 (df f-dsp-16-s8 "8 bit signed" (all-isas) 16 8 INT #f #f)
382 (df f-dsp-24-u8 "8 bit unsigned" (all-isas) 24 8 UINT #f #f)
383 (df f-dsp-24-s8 "8 bit signed" (all-isas) 24 8 INT #f #f)
384 (df f-dsp-32-u8 "8 bit unsigned" (all-isas) 32 8 UINT #f #f)
385 (df f-dsp-32-s8 "8 bit signed" (all-isas) 32 8 INT #f #f)
386 (df f-dsp-40-u8 "8 bit unsigned" (all-isas) 40 8 UINT #f #f)
387 (df f-dsp-40-s8 "8 bit signed" (all-isas) 40 8 INT #f #f)
388 (df f-dsp-48-u8 "8 bit unsigned" (all-isas) 48 8 UINT #f #f)
389 (df f-dsp-48-s8 "8 bit signed" (all-isas) 48 8 INT #f #f)
390 (df f-dsp-56-u8 "8 bit unsigned" (all-isas) 56 8 UINT #f #f)
391 (df f-dsp-56-s8 "8 bit signed" (all-isas) 56 8 INT #f #f)
392 (df f-dsp-64-u8 "8 bit unsigned" (all-isas) 64 8 UINT #f #f)
393 (df f-dsp-64-s8 "8 bit signed" (all-isas) 64 8 INT #f #f)
395 ; Insn opcode endianness is big, but the immediate fields are stored
396 ; in little endian. Handle this here at the field level for all immediate
397 ; fields longer that 1 byte.
399 ; CGEN can't handle a field which spans a 32 bit word boundary, so
400 ; handle those as multi ifields.
402 ; Take care in expressions using 'srl' or 'sll' as part of some larger
403 ; expression meant to yield sign-extended values. CGEN translates
404 ; uses of those operators into C expressions whose type is 'unsigned
405 ; int', which tends to make the whole expression 'unsigned int'.
406 ; Expressions like (set (ifield foo) X), however, just take X and
407 ; store it in some member of 'struct cgen_fields', all of whose
408 ; members are 'long'. On machines where 'long' is larger than
409 ; 'unsigned int', assigning a "sign-extended" unsigned int to a long
410 ; just produces a very large positive value. insert_normal will
411 ; range-check the field's value and produce odd error messages like
414 ; Error: operand out of range (4160684031 not between -2147483648 and 2147483647) `add.l #-265,-270[fb]'
416 ; Annoyingly, the code will work fine on machines where 'long' and
417 ; 'unsigned int' are the same size: the assignment will produce a
420 ; Just tell yourself over and over: overflow detection is expensive,
421 ; and you're glad C doesn't do it, because it never happens in real
424 (df f-dsp-8-u16 "16 bit unsigned" (all-isas) 8 16 UINT
426 (and (srl value 8) #x00ff)
427 (and (sll value 8) #xff00))) ; insert
429 (and UHI (srl UHI value 8) #x00ff)
430 (and UHI (sll UHI value 8) #xff00))) ; extract
433 (df f-dsp-8-s16 "8 bit signed" (all-isas) 8 16 INT
436 (or (and (srl value 8) #x00ff)
437 (and (sll value 8) #xff00))))) ; insert
440 (or (and (srl value 8) #x00ff)
441 (and (sll value 8) #xff00))))) ; extract
444 (df f-dsp-16-u16 "16 bit unsigned" (all-isas) 16 16 UINT
446 (and (srl value 8) #x00ff)
447 (and (sll value 8) #xff00))) ; insert
449 (and UHI (srl UHI value 8) #x00ff)
450 (and UHI (sll UHI value 8) #xff00))) ; extract
453 (df f-dsp-16-s16 "16 bit signed" (all-isas) 16 16 INT
456 (or (and (srl value 8) #x00ff)
457 (and (sll value 8) #xff00))))) ; insert
460 (or (and (srl value 8) #x00ff)
461 (and (sll value 8) #xff00))))) ; extract
464 (dnmf f-dsp-24-u16 "16 bit unsigned" (all-isas) UINT
465 (f-dsp-24-u8 f-dsp-32-u8)
466 (sequence () ; insert
467 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u16) #xff))
468 (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-24-u16) 8) #xff))
470 (sequence () ; extract
471 (set (ifield f-dsp-24-u16) (or (sll (ifield f-dsp-32-u8) 8)
472 (ifield f-dsp-24-u8)))
476 (dnmf f-dsp-24-s16 "16 bit signed" (all-isas) INT
477 (f-dsp-24-u8 f-dsp-32-u8)
478 (sequence () ; insert
479 (set (ifield f-dsp-24-u8)
480 (and (ifield f-dsp-24-s16) #xff))
481 (set (ifield f-dsp-32-u8)
482 (and (srl (ifield f-dsp-24-s16) 8) #xff))
484 (sequence () ; extract
485 (set (ifield f-dsp-24-s16)
487 (trunc HI (or (sll (ifield f-dsp-32-u8) 8)
488 (ifield f-dsp-24-u8)))))
492 (df f-dsp-32-u16 "16 bit unsigned" (all-isas) 32 16 UINT
494 (and (srl value 8) #x00ff)
495 (and (sll value 8) #xff00))) ; insert
497 (and UHI (srl UHI value 8) #x00ff)
498 (and UHI (sll UHI value 8) #xff00))) ; extract
501 (df f-dsp-32-s16 "16 bit signed" (all-isas) 32 16 INT
504 (or (and (srl value 8) #x00ff)
505 (and (sll value 8) #xff00))))) ; insert
508 (or (and (srl value 8) #x00ff)
509 (and (sll value 8) #xff00))))) ; extract
512 (df f-dsp-40-u16 "16 bit unsigned" (all-isas) 40 16 UINT
514 (and (srl value 8) #x00ff)
515 (and (sll value 8) #xff00))) ; insert
517 (and UHI (srl UHI value 8) #x00ff)
518 (and UHI (sll UHI value 8) #xff00))) ; extract
521 (df f-dsp-40-s16 "16 bit signed" (all-isas) 40 16 INT
524 (or (and (srl value 8) #x00ff)
525 (and (sll value 8) #xff00))))) ; insert
528 (or (and (srl value 8) #x00ff)
529 (and (sll value 8) #xff00))))) ; extract
532 (df f-dsp-48-u16 "16 bit unsigned" (all-isas) 48 16 UINT
534 (and (srl value 8) #x00ff)
535 (and (sll value 8) #xff00))) ; insert
537 (and UHI (srl UHI value 8) #x00ff)
538 (and UHI (sll UHI value 8) #xff00))) ; extract
541 (df f-dsp-48-s16 "16 bit signed" (all-isas) 48 16 INT
544 (or (and (srl value 8) #x00ff)
545 (and (sll value 8) #xff00))))) ; insert
548 (or (and (srl value 8) #x00ff)
549 (and (sll value 8) #xff00))))) ; extract
552 (df f-dsp-64-u16 "16 bit unsigned" (all-isas) 64 16 UINT
554 (and (srl value 8) #x00ff)
555 (and (sll value 8) #xff00))) ; insert
557 (and UHI (srl UHI value 8) #x00ff)
558 (and UHI (sll UHI value 8) #xff00))) ; extract
560 (df f-dsp-8-s24 "24 bit signed" (all-isas) 8 24 INT
562 (or (srl value 16) (and value #xff00))
563 (sll (ext INT (trunc QI (and value #xff))) 16)))
565 (or (srl value 16) (and value #xff00))
566 (sll (ext INT (trunc QI (and value #xff))) 16)))
569 (df f-dsp-8-u24 "24 bit unsigned" (all-isas) 8 24 UINT
571 (or (srl value 16) (and value #xff00))
572 (sll (and value #xff) 16)))
574 (or (srl value 16) (and value #xff00))
575 (sll (and value #xff) 16)))
578 (dnmf f-dsp-16-u24 "24 bit unsigned" (all-isas) UINT
579 (f-dsp-16-u16 f-dsp-32-u8)
580 (sequence () ; insert
581 (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-u24) #xffff))
582 (set (ifield f-dsp-32-u8) (and (srl (ifield f-dsp-16-u24) 16) #xff))
584 (sequence () ; extract
585 (set (ifield f-dsp-16-u24) (or (sll (ifield f-dsp-32-u8) 16)
586 (ifield f-dsp-16-u16)))
590 (dnmf f-dsp-24-u24 "24 bit unsigned" (all-isas) UINT
591 (f-dsp-24-u8 f-dsp-32-u16)
592 (sequence () ; insert
593 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-u24) #xff))
594 (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-24-u24) 8) #xffff))
596 (sequence () ; extract
597 (set (ifield f-dsp-24-u24) (or (sll (ifield f-dsp-32-u16) 8)
598 (ifield f-dsp-24-u8)))
602 (df f-dsp-32-u24 "24 bit unsigned" (all-isas) 32 24 UINT
605 (and (srl value 16) #x0000ff)
606 (and value #x00ff00))
607 (and (sll value 16) #xff0000))) ; insert
610 (and USI (srl UHI value 16) #x0000ff)
611 (and USI value #x00ff00))
612 (and USI (sll UHI value 16) #xff0000))) ; extract
615 (df f-dsp-40-u24 "24 bit unsigned" (all-isas) 40 24 UINT
618 (and (srl value 16) #x0000ff)
619 (and value #x00ff00))
620 (and (sll value 16) #xff0000))) ; insert
623 (and USI (srl UHI value 16) #x0000ff)
624 (and USI value #x00ff00))
625 (and USI (sll UHI value 16) #xff0000))) ; extract
628 (dnmf f-dsp-40-s32 "32 bit signed" (all-isas) INT
629 (f-dsp-40-u24 f-dsp-64-u8)
630 (sequence () ; insert
631 (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-40-s32) 24) #xff))
632 (set (ifield f-dsp-40-u24) (and (ifield f-dsp-40-s32) #xffffff))
634 (sequence () ; extract
635 (set (ifield f-dsp-40-s32) (or (and (ifield f-dsp-40-u24) #xffffff)
636 (and (sll (ifield f-dsp-64-u8) 24) #xff000000)))
640 (dnmf f-dsp-48-u24 "24 bit unsigned" (all-isas) UINT
641 (f-dsp-48-u16 f-dsp-64-u8)
642 (sequence () ; insert
643 (set (ifield f-dsp-64-u8) (and (srl (ifield f-dsp-48-u24) 16) #xff))
644 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u24) #xffff))
646 (sequence () ; extract
647 (set (ifield f-dsp-48-u24) (or (and (ifield f-dsp-48-u16) #xffff)
648 (and (sll (ifield f-dsp-64-u8) 16) #xff0000)))
652 (dnmf f-dsp-16-s32 "32 bit signed" (all-isas) INT
653 (f-dsp-16-u16 f-dsp-32-u16)
654 (sequence () ; insert
655 (set (ifield f-dsp-32-u16) (and (srl (ifield f-dsp-16-s32) 16) #xffff))
656 (set (ifield f-dsp-16-u16) (and (ifield f-dsp-16-s32) #xffff))
658 (sequence () ; extract
659 (set (ifield f-dsp-16-s32) (or (and (ifield f-dsp-16-u16) #xffff)
660 (and (sll (ifield f-dsp-32-u16) 16) #xffff0000)))
664 (dnmf f-dsp-24-s32 "32 bit signed" (all-isas) INT
665 (f-dsp-24-u8 f-dsp-32-u24)
666 (sequence () ; insert
667 (set (ifield f-dsp-32-u24) (and (srl (ifield f-dsp-24-s32) 8) #xffffff))
668 (set (ifield f-dsp-24-u8) (and (ifield f-dsp-24-s32) #xff))
670 (sequence () ; extract
671 (set (ifield f-dsp-24-s32) (or (and (ifield f-dsp-24-u8) #xff)
672 (and (sll (ifield f-dsp-32-u24) 8) #xffffff00)))
676 (df f-dsp-32-s32 "32 bit signed" (all-isas) 32 32 INT
683 (and (srl value 24) #x000000ff)
684 (and (srl value 8) #x0000ff00))
686 (and (sll value 8) #x00ff0000)
687 (and (sll value 24) #xff000000)))))
694 (and (srl value 24) #x000000ff)
695 (and (srl value 8) #x0000ff00))
697 (and (sll value 8) #x00ff0000)
698 (and (sll value 24) #xff000000)))))
701 (dnmf f-dsp-48-u32 "32 bit unsigned" (all-isas) UINT
702 (f-dsp-48-u16 f-dsp-64-u16)
703 (sequence () ; insert
704 (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-u32) 16) #xffff))
705 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-u32) #xffff))
707 (sequence () ; extract
708 (set (ifield f-dsp-48-u32) (or (and (ifield f-dsp-48-u16) #xffff)
709 (and (sll (ifield f-dsp-64-u16) 16) #xffff0000)))
713 (dnmf f-dsp-48-s32 "32 bit signed" (all-isas) INT
714 (f-dsp-48-u16 f-dsp-64-u16)
715 (sequence () ; insert
716 (set (ifield f-dsp-64-u16) (and (srl (ifield f-dsp-48-s32) 16) #xffff))
717 (set (ifield f-dsp-48-u16) (and (ifield f-dsp-48-s32) #xffff))
719 (sequence () ; extract
720 (set (ifield f-dsp-48-s32) (or (and (ifield f-dsp-48-u16) #xffff)
721 (and (sll (ifield f-dsp-64-u16) 16) #xffff0000)))
725 (dnmf f-dsp-56-s16 "16 bit signed" (all-isas) INT
726 (f-dsp-56-u8 f-dsp-64-u8)
727 (sequence () ; insert
728 (set (ifield f-dsp-56-u8)
729 (and (ifield f-dsp-56-s16) #xff))
730 (set (ifield f-dsp-64-u8)
731 (and (srl (ifield f-dsp-56-s16) 8) #xff))
733 (sequence () ; extract
734 (set (ifield f-dsp-56-s16)
736 (trunc HI (or (sll (ifield f-dsp-64-u8) 8)
737 (ifield f-dsp-56-u8)))))
741 (df f-dsp-64-s16 " 16 bit signed" (all-isas) 64 16 INT
744 (or (and (srl value 8) #x00ff)
745 (and (sll value 8) #xff00))))) ; insert
748 (or (and (srl value 8) #x00ff)
749 (and (sll value 8) #xff00))))) ; extract
752 ;-------------------------------------------------------------
754 ;-------------------------------------------------------------
756 (dnf f-bitno16-S "bit index for m16c" (all-isas) 5 3)
757 (dnf f-bitno32-prefixed "bit index for m32c" (all-isas) 21 3)
758 (dnf f-bitno32-unprefixed "bit index for m32c" (all-isas) 13 3)
760 (dnmf f-bitbase16-u11-S "unsigned bit,base:11" (all-isas) UINT
761 (f-bitno16-S f-dsp-8-u8)
762 (sequence () ; insert
763 (set (ifield f-bitno16-S) (and f-bitbase16-u11-S #x7))
764 (set (ifield f-dsp-8-u8) (and (srl (ifield f-bitbase16-u11-S) 3) #xff))
766 (sequence () ; extract
767 (set (ifield f-bitbase16-u11-S) (or (sll (ifield f-dsp-8-u8) 3)
768 (ifield f-bitno16-S)))
772 (dnmf f-bitbase32-16-u11-unprefixed "unsigned bit,base:11" (all-isas) UINT
773 (f-bitno32-unprefixed f-dsp-16-u8)
774 (sequence () ; insert
775 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u11-unprefixed #x7))
776 (set (ifield f-dsp-16-u8) (and (srl (ifield f-bitbase32-16-u11-unprefixed) 3) #xff))
778 (sequence () ; extract
779 (set (ifield f-bitbase32-16-u11-unprefixed) (or (sll (ifield f-dsp-16-u8) 3)
780 (ifield f-bitno32-unprefixed)))
783 (dnmf f-bitbase32-16-s11-unprefixed "signed bit,base:11" (all-isas) INT
784 (f-bitno32-unprefixed f-dsp-16-s8)
785 (sequence () ; insert
786 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s11-unprefixed #x7))
787 (set (ifield f-dsp-16-s8) (sra INT (ifield f-bitbase32-16-s11-unprefixed) 3))
789 (sequence () ; extract
790 (set (ifield f-bitbase32-16-s11-unprefixed) (or (sll (ifield f-dsp-16-s8) 3)
791 (ifield f-bitno32-unprefixed)))
794 (dnmf f-bitbase32-16-u19-unprefixed "unsigned bit,base:19" (all-isas) UINT
795 (f-bitno32-unprefixed f-dsp-16-u16)
796 (sequence () ; insert
797 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u19-unprefixed #x7))
798 (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u19-unprefixed) 3) #xffff))
800 (sequence () ; extract
801 (set (ifield f-bitbase32-16-u19-unprefixed) (or (sll (ifield f-dsp-16-u16) 3)
802 (ifield f-bitno32-unprefixed)))
805 (dnmf f-bitbase32-16-s19-unprefixed "signed bit,base:11" (all-isas) INT
806 (f-bitno32-unprefixed f-dsp-16-s16)
807 (sequence () ; insert
808 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-s19-unprefixed #x7))
809 (set (ifield f-dsp-16-s16) (sra INT (ifield f-bitbase32-16-s19-unprefixed) 3))
811 (sequence () ; extract
812 (set (ifield f-bitbase32-16-s19-unprefixed) (or (sll (ifield f-dsp-16-s16) 3)
813 (ifield f-bitno32-unprefixed)))
816 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
817 (dnmf f-bitbase32-16-u27-unprefixed "unsigned bit,base:27" (all-isas) UINT
818 (f-bitno32-unprefixed f-dsp-16-u16 f-dsp-32-u8)
819 (sequence () ; insert
820 (set (ifield f-bitno32-unprefixed) (and f-bitbase32-16-u27-unprefixed #x7))
821 (set (ifield f-dsp-16-u16) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 3) #xffff))
822 (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-16-u27-unprefixed) 19) #xff))
824 (sequence () ; extract
825 (set (ifield f-bitbase32-16-u27-unprefixed) (or (sll (ifield f-dsp-16-u16) 3)
826 (or (sll (ifield f-dsp-32-u8) 19)
827 (ifield f-bitno32-unprefixed))))
830 (dnmf f-bitbase32-24-u11-prefixed "unsigned bit,base:11" (all-isas) UINT
831 (f-bitno32-prefixed f-dsp-24-u8)
832 (sequence () ; insert
833 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u11-prefixed #x7))
834 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u11-prefixed) 3) #xff))
836 (sequence () ; extract
837 (set (ifield f-bitbase32-24-u11-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
838 (ifield f-bitno32-prefixed)))
841 (dnmf f-bitbase32-24-s11-prefixed "signed bit,base:11" (all-isas) INT
842 (f-bitno32-prefixed f-dsp-24-s8)
843 (sequence () ; insert
844 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s11-prefixed #x7))
845 (set (ifield f-dsp-24-s8) (sra INT (ifield f-bitbase32-24-s11-prefixed) 3))
847 (sequence () ; extract
848 (set (ifield f-bitbase32-24-s11-prefixed) (or (sll (ifield f-dsp-24-s8) 3)
849 (ifield f-bitno32-prefixed)))
852 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
853 (dnmf f-bitbase32-24-u19-prefixed "unsigned bit,base:19" (all-isas) UINT
854 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u8)
855 (sequence () ; insert
856 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u19-prefixed #x7))
857 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 3) #xff))
858 (set (ifield f-dsp-32-u8) (and (srl (ifield f-bitbase32-24-u19-prefixed) 11) #xff))
860 (sequence () ; extract
861 (set (ifield f-bitbase32-24-u19-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
862 (or (sll (ifield f-dsp-32-u8) 11)
863 (ifield f-bitno32-prefixed))))
866 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
867 (dnmf f-bitbase32-24-s19-prefixed "signed bit,base:11" (all-isas) INT
868 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-s8)
869 (sequence () ; insert
870 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-s19-prefixed #x7))
871 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-s19-prefixed) 3) #xff))
872 (set (ifield f-dsp-32-s8) (sra INT (ifield f-bitbase32-24-s19-prefixed) 11))
874 (sequence () ; extract
875 (set (ifield f-bitbase32-24-s19-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
876 (or (sll (ifield f-dsp-32-s8) 11)
877 (ifield f-bitno32-prefixed))))
880 ; SID decoder doesn't handle multi-ifield referencing another multi-ifield :-(
881 (dnmf f-bitbase32-24-u27-prefixed "unsigned bit,base:27" (all-isas) UINT
882 (f-bitno32-prefixed f-dsp-24-u8 f-dsp-32-u16)
883 (sequence () ; insert
884 (set (ifield f-bitno32-prefixed) (and f-bitbase32-24-u27-prefixed #x7))
885 (set (ifield f-dsp-24-u8) (and (srl (ifield f-bitbase32-24-u27-prefixed) 3) #xff))
886 (set (ifield f-dsp-32-u16) (and (srl (ifield f-bitbase32-24-u27-prefixed) 11) #xffff))
888 (sequence () ; extract
889 (set (ifield f-bitbase32-24-u27-prefixed) (or (sll (ifield f-dsp-24-u8) 3)
890 (or (sll (ifield f-dsp-32-u16) 11)
891 (ifield f-bitno32-prefixed))))
895 ;-------------------------------------------------------------
897 ;-------------------------------------------------------------
899 (df f-lab-5-3 "3 bit pc relative unsigned offset" (PCREL-ADDR all-isas) 5 3 UINT
900 ((value pc) (sub SI value (add SI pc 2))) ; insert
901 ((value pc) (add SI value (add SI pc 2))) ; extract
903 (dnmf f-lab32-jmp-s "unsigned 3 bit pc relative offset" (PCREL-ADDR all-isas) UINT
905 (sequence ((SI val)) ; insert
906 (set val (sub (sub (ifield f-lab32-jmp-s) pc) 2))
907 (set (ifield f-7-1) (and val #x1))
908 (set (ifield f-2-2) (srl val 1))
910 (sequence () ; extract
911 (set (ifield f-lab32-jmp-s) (add pc (add (or (sll (ifield f-2-2) 1)
916 (df f-lab-8-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 8 8 INT
917 ((value pc) (sub SI value (add SI pc 1))) ; insert
918 ((value pc) (add SI value (add SI pc 1))) ; extract
920 (df f-lab-8-16 "16 bit pc relative signed offset" (PCREL-ADDR SIGN-OPT all-isas) 8 16 UINT
921 ((value pc) (or SI (sll (and (sub value (add pc 1)) #xff) 8)
922 (srl (and (sub value (add pc 1)) #xffff) 8)))
923 ((value pc) (add SI (or (srl (and value #xffff) 8)
924 (sra (sll (and value #xff) 24) 16)) (add pc 1)))
926 (df f-lab-8-24 "24 bit absolute" (all-isas ABS-ADDR) 8 24 UINT
928 (or (srl value 16) (and value #xff00))
929 (sll (and value #xff) 16)))
931 (or (srl value 16) (and value #xff00))
932 (sll (and value #xff) 16)))
934 (df f-lab-16-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 16 8 INT
935 ((value pc) (sub SI value (add SI pc 2))) ; insert
936 ((value pc) (add SI value (add SI pc 2))) ; extract
938 (df f-lab-24-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 24 8 INT
939 ((value pc) (sub SI value (add SI pc 2))) ; insert
940 ((value pc) (add SI value (add SI pc 2))) ; extract
942 (df f-lab-32-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 32 8 INT
943 ((value pc) (sub SI value (add SI pc 2))) ; insert
944 ((value pc) (add SI value (add SI pc 2))) ; extract
946 (df f-lab-40-8 "8 bit pc relative signed offset" (PCREL-ADDR all-isas) 40 8 INT
947 ((value pc) (sub SI value (add SI pc 2))) ; insert
948 ((value pc) (add SI value (add SI pc 2))) ; extract
951 ;-------------------------------------------------------------
953 ;-------------------------------------------------------------
955 (dnf f-cond16 "condition code" (all-isas) 12 4)
956 (dnf f-cond16j-5 "condition code" (all-isas) 5 3)
958 (dnmf f-cond32 "condition code" (all-isas) UINT
960 (sequence () ; insert
961 (set (ifield f-9-1) (and (srl (ifield f-cond32) 3) 1))
962 (set (ifield f-13-3) (and (ifield f-cond32) #x7))
964 (sequence () ; extract
965 (set (ifield f-cond32) (or (sll (ifield f-9-1) 3)
970 (dnmf f-cond32j "condition code" (all-isas) UINT
972 (sequence () ; insert
973 (set (ifield f-1-3) (and (srl (ifield f-cond32j) 1) #x7))
974 (set (ifield f-7-1) (and (ifield f-cond32j) #x1))
976 (sequence () ; extract
977 (set (ifield f-cond32j) (or (sll (ifield f-1-3) 1)
982 ;=============================================================
985 (dnh h-pc "program counter" (PC all-isas) (pc USI) () () ())
987 ;-------------------------------------------------------------
989 ; The actual registers are 16 bits
990 ;-------------------------------------------------------------
994 (comment "general 16 bit registers")
995 (attrs all-isas CACHE-ADDR)
996 (type register HI (4))
997 (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3))))
999 ; Define different views of the grs as VIRTUAL with getter/setter specs
1003 (comment "general 8 bit registers")
1004 (attrs all-isas VIRTUAL)
1005 (type register QI (4))
1006 (indices keyword "" (("r0l" 0) ("r0h" 1) ("r1l" 2) ("r1h" 3)))
1007 (get (index) (and (if SI (mod index 2)
1008 (srl (reg h-gr (div index 2)) 8)
1009 (reg h-gr (div index 2)))
1011 (set (index newval) (set (reg h-gr (div index 2))
1012 (if SI (mod index 2)
1013 (or (and (reg h-gr (div index 2)) #xff)
1014 (sll (and newval #xff) 8))
1015 (or (and (reg h-gr (div index 2)) #xff00)
1016 (and newval #xff))))))
1020 (comment "general 16 bit registers")
1021 (attrs all-isas VIRTUAL)
1022 (type register HI (4))
1023 (indices keyword "" (("r0" 0) ("r1" 1) ("r2" 2) ("r3" 3)))
1024 (get (index) (reg h-gr index))
1025 (set (index newval) (set (reg h-gr index) newval)))
1029 (comment "general 32 bit registers")
1030 (attrs all-isas VIRTUAL)
1031 (type register SI (2))
1032 (indices keyword "" (("r2r0" 0) ("r3r1" 1)))
1034 (and (reg h-gr index) #xffff)
1035 (and (sll (reg h-gr (add index 2)) 16) #xffff0000)))
1036 (set (index newval) (sequence ()
1037 (set (reg h-gr index) (and newval #xffff))
1038 (set (reg h-gr (add index 2)) (srl newval 16)))))
1042 (comment "general 16 bit registers")
1043 (attrs all-isas VIRTUAL)
1044 (type register HI (2))
1045 (indices keyword "" (("r0l" 0) ("r1l" 1)))
1046 (get (index) (reg h-gr-QI (mul index 2)))
1047 (set (index newval) (set (reg h-gr (mul index 2)) newval)))
1051 (comment "general 16 bit registers")
1052 (attrs all-isas VIRTUAL)
1053 (type register SI (2))
1054 (indices keyword "" (("r0" 0) ("r1" 1)))
1055 (get (index) (reg h-gr (mul index 2)))
1056 (set (index newval) (set (reg h-gr-SI index) newval)))
1060 (comment "r0l register")
1061 (attrs all-isas VIRTUAL)
1063 (indices keyword "" (("r0l" 0)))
1064 (get () (reg h-gr-QI 0))
1065 (set (newval) (set (reg h-gr-QI 0) newval)))
1069 (comment "r0h register")
1070 (attrs all-isas VIRTUAL)
1072 (indices keyword "" (("r0h" 0)))
1073 (get () (reg h-gr-QI 1))
1074 (set (newval) (set (reg h-gr-QI 1) newval)))
1078 (comment "r1l register")
1079 (attrs all-isas VIRTUAL)
1081 (indices keyword "" (("r1l" 0)))
1082 (get () (reg h-gr-QI 2))
1083 (set (newval) (set (reg h-gr-QI 2) newval)))
1087 (comment "r1h register")
1088 (attrs all-isas VIRTUAL)
1090 (indices keyword "" (("r1h" 0)))
1091 (get () (reg h-gr-QI 3))
1092 (set (newval) (set (reg h-gr-QI 3) newval)))
1096 (comment "r0 register")
1097 (attrs all-isas VIRTUAL)
1099 (indices keyword "" (("r0" 0)))
1100 (get () (reg h-gr 0))
1101 (set (newval) (set (reg h-gr 0) newval)))
1105 (comment "r1 register")
1106 (attrs all-isas VIRTUAL)
1108 (indices keyword "" (("r1" 0)))
1109 (get () (reg h-gr 1))
1110 (set (newval) (set (reg h-gr 1) newval)))
1114 (comment "r2 register")
1115 (attrs all-isas VIRTUAL)
1117 (indices keyword "" (("r2" 0)))
1118 (get () (reg h-gr 2))
1119 (set (newval) (set (reg h-gr 2) newval)))
1123 (comment "r3 register")
1124 (attrs all-isas VIRTUAL)
1126 (indices keyword "" (("r3" 0)))
1127 (get () (reg h-gr 3))
1128 (set (newval) (set (reg h-gr 3) newval)))
1132 (comment "r0l or r0h")
1133 (attrs all-isas VIRTUAL)
1134 (type register QI (2))
1135 (indices keyword "" (("r0l" 0) ("r0h" 1)))
1136 (get (index) (reg h-gr-QI index))
1137 (set (index newval) (set (reg h-gr-QI index) newval)))
1141 (comment "r2r0 register")
1142 (attrs all-isas VIRTUAL)
1144 (indices keyword "" (("r2r0" 0)))
1145 (get () (or (sll (reg h-gr 2) 16) (reg h-gr 0)))
1148 (set (reg h-gr 0) newval)
1149 (set (reg h-gr 2) (sra newval 16)))))
1153 (comment "r3r1 register")
1154 (attrs all-isas VIRTUAL)
1156 (indices keyword "" (("r3r1" 0)))
1157 (get () (or (sll (reg h-gr 3) 16) (reg h-gr 1)))
1160 (set (reg h-gr 1) newval)
1161 (set (reg h-gr 3) (sra newval 16)))))
1165 (comment "r1r2r0 register")
1166 (attrs all-isas VIRTUAL)
1168 (indices keyword "" (("r1r2r0" 0)))
1169 (get () (or DI (sll DI (reg h-gr 1) 32) (or (sll (reg h-gr 2) 16) (reg h-gr 0))))
1172 (set (reg h-gr 0) newval)
1173 (set (reg h-gr 2) (sra newval 16))
1174 (set (reg h-gr 1) (sra newval 32)))))
1176 ;-------------------------------------------------------------
1178 ;-------------------------------------------------------------
1182 (comment "address registers")
1184 (type register USI (2))
1185 (indices keyword "" (("a0" 0) ("a1" 1)))
1186 (get (index) (c-call USI "h_ar_get_handler" index))
1187 (set (index newval) (c-call VOID "h_ar_set_handler" index newval)))
1189 ; Define different views of the ars as VIRTUAL with getter/setter specs
1192 (comment "8 bit view of address register")
1193 (attrs all-isas VIRTUAL)
1194 (type register QI (2))
1195 (indices keyword "" (("a0" 0) ("a1" 1)))
1196 (get (index) (reg h-ar index))
1197 (set (index newval) (set (reg h-ar index) newval)))
1201 (comment "16 bit view of address register")
1202 (attrs all-isas VIRTUAL)
1203 (type register HI (2))
1204 (indices keyword "" (("a0" 0) ("a1" 1)))
1205 (get (index) (reg h-ar index))
1206 (set (index newval) (set (reg h-ar index) newval)))
1210 (comment "32 bit view of address register")
1211 (attrs all-isas VIRTUAL)
1213 (indices keyword "" (("a1a0" 0)))
1214 (get () (or SI (sll SI (ext SI (reg h-ar 1)) 16) (ext SI (reg h-ar 0))))
1215 (set (newval) (sequence ()
1216 (set (reg h-ar 0) (and newval #xffff))
1217 (set (reg h-ar 1) (and (srl newval 16) #xffff)))))
1221 (comment "16 bit view of address register")
1222 (attrs all-isas VIRTUAL)
1224 (indices keyword "" (("a0" 0)))
1225 (get () (reg h-ar 0))
1226 (set (newval) (set (reg h-ar 0) newval)))
1230 (comment "16 bit view of address register")
1231 (attrs all-isas VIRTUAL)
1233 (indices keyword "" (("a1" 1)))
1234 (get () (reg h-ar 1))
1235 (set (newval) (set (reg h-ar 1) newval)))
1240 (comment "SB register")
1243 (get () (c-call USI "h_sb_get_handler"))
1244 (set (newval) (c-call VOID "h_sb_set_handler" newval))
1250 (comment "FB register")
1253 (get () (c-call USI "h_fb_get_handler"))
1254 (set (newval) (c-call VOID "h_fb_set_handler" newval))
1260 (comment "SP register")
1263 (get () (c-call USI "h_sp_get_handler"))
1264 (set (newval) (c-call VOID "h_sp_set_handler" newval))
1267 ;-------------------------------------------------------------
1268 ; condition-code bits
1269 ;-------------------------------------------------------------
1273 (comment "sign bit")
1280 (comment "zero bit")
1287 (comment "overflow bit")
1294 (comment "carry bit")
1301 (comment "stack pointer select bit")
1308 (comment "interrupt enable bit")
1315 (comment "register bank select bit")
1322 (comment "debug bit")
1329 (comment "dma transfer count 000")
1335 (comment "dma transfer count 001")
1341 (comment "save flag 011")
1347 (comment "dma transfer count reload 100")
1353 (comment "dma transfer count reload 101")
1359 (comment "dma mode 110")
1365 (comment "dma mode 111")
1371 (comment "interrupt table 000")
1377 (comment "save pc 100")
1383 (comment "vector 101")
1389 (comment "interrupt stack ptr 111")
1395 (comment "dma mem addr 010")
1401 (comment "dma mem addr 011")
1407 (comment "dma mem addr reload 100")
1413 (comment "dma mem addr reload 101")
1419 (comment "dma sfr addr 110")
1425 (comment "dma sfr addr 111")
1430 ;-------------------------------------------------------------
1431 ; Condition code operand hardware
1432 ;-------------------------------------------------------------
1436 (comment "condition code hardware for m16c")
1437 (attrs m16c-isa MACH16)
1438 (type immediate UQI)
1440 (("geu" #x00) ("c" #x00)
1442 ("eq" #x02) ("z" #x02)
1447 ("ltu" #xf8) ("nc" #xf8)
1449 ("ne" #xfa) ("nz" #xfa)
1459 (comment "condition code hardware for m16c")
1460 (attrs m16c-isa MACH16)
1461 (type immediate UQI)
1463 (("geu" #x00) ("c" #x00)
1465 ("eq" #x02) ("z" #x02)
1467 ("ltu" #x04) ("nc" #x04)
1469 ("ne" #x06) ("nz" #x06)
1482 (comment "condition code hardware for m16c")
1483 (attrs m16c-isa MACH16)
1484 (type immediate UQI)
1497 (comment "condition code hardware for m16c")
1498 (attrs m16c-isa MACH16)
1499 (type immediate UQI)
1501 (("geu" #x00) ("c" #x00)
1503 ("eq" #x02) ("z" #x02)
1505 ("ltu" #x04) ("nc" #x04)
1507 ("ne" #x06) ("nz" #x06)
1515 (comment "condition code hardware for m32c")
1516 (attrs m32c-isa MACH32)
1517 (type immediate UQI)
1519 (("ltu" #x00) ("nc" #x00)
1521 ("ne" #x02) ("nz" #x02)
1526 ("geu" #x08) ("c" #x08)
1528 ("eq" #x0a) ("z" #x0a)
1539 (comment "control registers")
1540 (attrs m32c-isa MACH32)
1541 (type immediate UQI)
1542 (values keyword "" (("dct0" 0) ("dct1" 1) ("flg" 2) ("svf" 3) ("drc0" 4)
1543 ("drc1" 5) ("dmd0" 6) ("dmd1" 7))))
1546 (comment "control registers")
1547 (attrs m32c-isa MACH32)
1548 (type immediate UQI)
1549 (values keyword "" (("intb" 0) ("sp" 1) ("sb" 2) ("fb" 3) ("svp" 4)
1550 ("vct" 5) ("isp" 7))))
1554 (comment "control registers")
1555 (attrs m32c-isa MACH32)
1556 (type immediate UQI)
1557 (values keyword "" (("dma0" 2) ("dma1" 3) ("dra0" 4)
1558 ("dra1" 5) ("dsa0" 6) ("dsa1" 7))))
1561 (comment "control registers")
1562 (attrs m16c-isa MACH16)
1563 (type immediate UQI)
1564 (values keyword "" (("intbl" 1) ("intbh" 2) ("flg" 3) ("isp" 4)
1565 ("sp" 5) ("sb" 6) ("fb" 7))))
1569 (comment "flag hardware for m32c")
1571 (type immediate UQI)
1585 ;-------------------------------------------------------------
1586 ; Misc helper hardware
1587 ;-------------------------------------------------------------
1591 (comment "shift immediate")
1593 (type immediate (INT 4))
1594 (values keyword "" (("1" 0) ("2" 1) ("3" 2) ("4" 3) ("5" 4) ("6" 5) ("7" 6)
1595 ("8" 7) ("-1" -8) ("-2" -7) ("-3" -6) ("-4" -5) ("-5" -4)
1596 ("-6" -3) ("-7" -2) ("-8" -1)
1600 (comment "bit index for the next insn")
1601 (attrs m32c-isa MACH32)
1606 (comment "source index for the next insn")
1607 (attrs m32c-isa MACH32)
1612 (comment "destination index for the next insn")
1613 (attrs m32c-isa MACH32)
1617 (name h-src-indirect)
1618 (comment "indirect src for the next insn")
1623 (name h-dst-indirect)
1624 (comment "indirect dst for the next insn")
1630 (comment "for storing unused values")
1631 (attrs m32c-isa MACH32)
1635 ;=============================================================
1637 ;-------------------------------------------------------------
1639 ;-------------------------------------------------------------
1641 (dnop Src16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-src16-rn)
1642 (dnop Src16RnHI "general register QH view" (MACH16 m16c-isa) h-gr-HI f-src16-rn)
1644 (dnop Src32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-unprefixed-QI)
1645 (dnop Src32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-unprefixed-HI)
1646 (dnop Src32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-unprefixed-SI)
1648 (dnop Src32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-src32-rn-prefixed-QI)
1649 (dnop Src32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-src32-rn-prefixed-HI)
1650 (dnop Src32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-src32-rn-prefixed-SI)
1652 (dnop Src16An "address register" (MACH16 m16c-isa) h-ar f-src16-an)
1653 (dnop Src16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-src16-an)
1654 (dnop Src16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-src16-an)
1656 (dnop Src32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed)
1657 (dnop Src32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-unprefixed)
1658 (dnop Src32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-unprefixed)
1659 (dnop Src32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-unprefixed)
1661 (dnop Src32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-src32-an-prefixed)
1662 (dnop Src32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-src32-an-prefixed)
1663 (dnop Src32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-src32-an-prefixed)
1664 (dnop Src32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-src32-an-prefixed)
1666 ; Destination Registers
1668 (dnop Dst16RnQI "general register QI view" (MACH16 m16c-isa) h-gr-QI f-dst16-rn)
1669 (dnop Dst16RnHI "general register HI view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn)
1670 (dnop Dst16RnSI "general register SI view" (MACH16 m16c-isa) h-gr-SI f-dst16-rn)
1671 (dnop Dst16RnExtQI "general register QI/HI view for 'ext' insns" (MACH16 m16c-isa) h-gr-ext-QI f-dst16-rn-ext)
1673 (dnop Dst32R0QI-S "general register QI view" (MACH32 m32c-isa) h-r0l f-nil)
1674 (dnop Dst32R0HI-S "general register HI view" (MACH32 m32c-isa) h-r0 f-nil)
1676 (dnop Dst32RnUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI)
1677 (dnop Dst32RnUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-unprefixed-HI)
1678 (dnop Dst32RnUnprefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-unprefixed-SI)
1679 (dnop Dst32RnExtUnprefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-ext-QI f-dst32-rn-ext-unprefixed)
1680 (dnop Dst32RnExtUnprefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-ext-HI f-dst32-rn-ext-unprefixed)
1682 (dnop Dst32RnPrefixedQI "general register QI view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI)
1683 (dnop Dst32RnPrefixedHI "general register HI view" (MACH32 m32c-isa) h-gr-HI f-dst32-rn-prefixed-HI)
1684 (dnop Dst32RnPrefixedSI "general register SI view" (MACH32 m32c-isa) h-gr-SI f-dst32-rn-prefixed-SI)
1686 (dnop Dst16RnQI-S "general register QI view" (MACH16 m16c-isa) h-r0l-r0h f-dst16-rn-QI-s)
1688 (dnop Dst16AnQI-S "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-rn-QI-s)
1690 (dnop Bit16Rn "general register bit view" (MACH16 m16c-isa) h-gr-HI f-dst16-rn)
1692 (dnop Bit32RnPrefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-prefixed-QI)
1693 (dnop Bit32RnUnprefixed "general register bit view" (MACH32 m32c-isa) h-gr-QI f-dst32-rn-unprefixed-QI)
1695 (dnop R0 "r0" (all-isas) h-r0 f-nil)
1696 (dnop R1 "r1" (all-isas) h-r1 f-nil)
1697 (dnop R2 "r2" (all-isas) h-r2 f-nil)
1698 (dnop R3 "r3" (all-isas) h-r3 f-nil)
1699 (dnop R0l "r0l" (all-isas) h-r0l f-nil)
1700 (dnop R0h "r0h" (all-isas) h-r0h f-nil)
1701 (dnop R2R0 "r2r0" (all-isas) h-r2r0 f-nil)
1702 (dnop R3R1 "r3r1" (all-isas) h-r3r1 f-nil)
1703 (dnop R1R2R0 "r1r2r0" (all-isas) h-r1r2r0 f-nil)
1705 (dnop Dst16An "address register" (MACH16 m16c-isa) h-ar f-dst16-an)
1706 (dnop Dst16AnQI "address register QI view" (MACH16 m16c-isa) h-ar-QI f-dst16-an)
1707 (dnop Dst16AnHI "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an)
1708 (dnop Dst16AnSI "address register SI view" (MACH16 m16c-isa) h-ar-SI f-dst16-an)
1709 (dnop Dst16An-S "address register HI view" (MACH16 m16c-isa) h-ar-HI f-dst16-an-s)
1711 (dnop Dst32AnUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1712 (dnop Dst32AnUnprefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-unprefixed)
1713 (dnop Dst32AnUnprefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-unprefixed)
1714 (dnop Dst32AnUnprefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1716 (dnop Dst32AnExtUnprefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1718 (dnop Dst32AnPrefixed "address register" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1719 (dnop Dst32AnPrefixedQI "address register QI view" (MACH32 m32c-isa) h-ar-QI f-dst32-an-prefixed)
1720 (dnop Dst32AnPrefixedHI "address register HI view" (MACH32 m32c-isa) h-ar-HI f-dst32-an-prefixed)
1721 (dnop Dst32AnPrefixedSI "address register SI view" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1723 (dnop Bit16An "address register bit view" (MACH16 m16c-isa) h-ar f-dst16-an)
1725 (dnop Bit32AnPrefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-prefixed)
1726 (dnop Bit32AnUnprefixed "address register bit" (MACH32 m32c-isa) h-ar f-dst32-an-unprefixed)
1728 (dnop A0 "a0" (all-isas) h-a0 f-nil)
1729 (dnop A1 "a1" (all-isas) h-a1 f-nil)
1731 (dnop sb "SB register" (all-isas SEM-ONLY) h-sb f-nil)
1732 (dnop fb "FB register" (all-isas SEM-ONLY) h-fb f-nil)
1733 (dnop sp "SP register" (all-isas SEM-ONLY) h-sp f-nil)
1735 (define-full-operand SrcDst16-r0l-r0h-S-normal "r0l/r0h pair" (MACH16 m16c-isa)
1737 ((parse "r0l_r0h") (print "r0l_r0h")) () ()
1740 (define-full-operand Regsetpop "popm regset" (all-isas) h-uint
1741 DFLT f-8-8 ((parse "pop_regset") (print "pop_regset")) () ())
1742 (define-full-operand Regsetpush "pushm regset" (all-isas) h-uint
1743 DFLT f-8-8 ((parse "push_regset") (print "push_regset")) () ())
1745 (dnop Rn16-push-S "r0[lh]" (MACH16 m16c-isa) h-gr-QI f-4-1)
1746 (dnop An16-push-S "a[01]" (MACH16 m16c-isa) h-ar-HI f-4-1)
1748 ;-------------------------------------------------------------
1749 ; Offsets and absolutes
1750 ;-------------------------------------------------------------
1752 (define-full-operand Dsp-8-u6 "unsigned 6 bit displacement at offset 8 bits" (all-isas)
1753 h-uint DFLT f-dsp-8-u6
1754 ((parse "unsigned6")) () ()
1756 (define-full-operand Dsp-8-u8 "unsigned 8 bit displacement at offset 8 bits" (all-isas)
1757 h-uint DFLT f-dsp-8-u8
1758 ((parse "unsigned8")) () ()
1760 (define-full-operand Dsp-8-u16 "unsigned 16 bit displacement at offset 8 bits" (all-isas)
1761 h-uint DFLT f-dsp-8-u16
1762 ((parse "unsigned16")) () ()
1764 (define-full-operand Dsp-8-s8 "signed 8 bit displacement at offset 8 bits" (all-isas)
1765 h-sint DFLT f-dsp-8-s8
1766 ((parse "signed8")) () ()
1768 (define-full-operand Dsp-8-s24 "signed 24 bit displacement at offset 8 bits" (all-isas)
1769 h-sint DFLT f-dsp-8-s24
1770 ((parse "signed24")) () ()
1772 (define-full-operand Dsp-8-u24 "unsigned 24 bit displacement at offset 8 bits" (all-isas)
1773 h-uint DFLT f-dsp-8-u24
1774 ((parse "unsigned24")) () ()
1776 (define-full-operand Dsp-10-u6 "unsigned 6 bit displacement at offset 10 bits" (all-isas)
1777 h-uint DFLT f-dsp-10-u6
1778 ((parse "unsigned6")) () ()
1780 (define-full-operand Dsp-16-u8 "unsigned 8 bit displacement at offset 16 bits" (all-isas)
1781 h-uint DFLT f-dsp-16-u8
1782 ((parse "unsigned8")) () ()
1784 (define-full-operand Dsp-16-u16 "unsigned 16 bit displacement at offset 16 bits" (all-isas)
1785 h-uint DFLT f-dsp-16-u16
1786 ((parse "unsigned16")) () ()
1788 (define-full-operand Dsp-16-u20 "unsigned 20 bit displacement at offset 16 bits" (all-isas)
1789 h-uint DFLT f-dsp-16-u24
1790 ((parse "unsigned20")) () ()
1792 (define-full-operand Dsp-16-u24 "unsigned 24 bit displacement at offset 16 bits" (all-isas)
1793 h-uint DFLT f-dsp-16-u24
1794 ((parse "unsigned24")) () ()
1796 (define-full-operand Dsp-16-s8 "signed 8 bit displacement at offset 16 bits" (all-isas)
1797 h-sint DFLT f-dsp-16-s8
1798 ((parse "signed8")) () ()
1800 (define-full-operand Dsp-16-s16 "signed 16 bit displacement at offset 16 bits" (all-isas)
1801 h-sint DFLT f-dsp-16-s16
1802 ((parse "signed16")) () ()
1804 (define-full-operand Dsp-24-u8 "unsigned 8 bit displacement at offset 24 bits" (all-isas)
1805 h-uint DFLT f-dsp-24-u8
1806 ((parse "unsigned8")) () ()
1808 (define-full-operand Dsp-24-u16 "unsigned 16 bit displacement at offset 24 bits" (all-isas)
1809 h-uint DFLT f-dsp-24-u16
1810 ((parse "unsigned16")) () ()
1812 (define-full-operand Dsp-24-u20 "unsigned 20 bit displacement at offset 24 bits" (all-isas)
1813 h-uint DFLT f-dsp-24-u24
1814 ((parse "unsigned20")) () ()
1816 (define-full-operand Dsp-24-u24 "unsigned 24 bit displacement at offset 24 bits" (all-isas)
1817 h-uint DFLT f-dsp-24-u24
1818 ((parse "unsigned24")) () ()
1820 (define-full-operand Dsp-24-s8 "signed 8 bit displacement at offset 24 bits" (all-isas)
1821 h-sint DFLT f-dsp-24-s8
1822 ((parse "signed8")) () ()
1824 (define-full-operand Dsp-24-s16 "signed 16 bit displacement at offset 24 bits" (all-isas)
1825 h-sint DFLT f-dsp-24-s16
1826 ((parse "signed16")) () ()
1828 (define-full-operand Dsp-32-u8 "unsigned 8 bit displacement at offset 32 bits" (all-isas)
1829 h-uint DFLT f-dsp-32-u8
1830 ((parse "unsigned8")) () ()
1832 (define-full-operand Dsp-32-u16 "unsigned 16 bit displacement at offset 32 bits" (all-isas)
1833 h-uint DFLT f-dsp-32-u16
1834 ((parse "unsigned16")) () ()
1836 (define-full-operand Dsp-32-u24 "unsigned 24 bit displacement at offset 32 bits" (all-isas)
1837 h-uint DFLT f-dsp-32-u24
1838 ((parse "unsigned24")) () ()
1840 (define-full-operand Dsp-32-u20 "unsigned 20 bit displacement at offset 32 bits" (all-isas)
1841 h-uint DFLT f-dsp-32-u24
1842 ((parse "unsigned20")) () ()
1844 (define-full-operand Dsp-32-s8 "signed 8 bit displacement at offset 32 bits" (all-isas)
1845 h-sint DFLT f-dsp-32-s8
1846 ((parse "signed8")) () ()
1848 (define-full-operand Dsp-32-s16 "signed 16 bit displacement at offset 32 bits" (all-isas)
1849 h-sint DFLT f-dsp-32-s16
1850 ((parse "signed16")) () ()
1852 (define-full-operand Dsp-40-u8 "unsigned 8 bit displacement at offset 40 bits" (all-isas)
1853 h-uint DFLT f-dsp-40-u8
1854 ((parse "unsigned8")) () ()
1856 (define-full-operand Dsp-40-s8 "signed 8 bit displacement at offset 40 bits" (all-isas)
1857 h-sint DFLT f-dsp-40-s8
1858 ((parse "signed8")) () ()
1860 (define-full-operand Dsp-40-u16 "unsigned 16 bit displacement at offset 40 bits" (all-isas)
1861 h-uint DFLT f-dsp-40-u16
1862 ((parse "unsigned16")) () ()
1864 (define-full-operand Dsp-40-s16 "signed 16 bit displacement at offset 40 bits" (all-isas)
1865 h-sint DFLT f-dsp-40-s16
1866 ((parse "signed16")) () ()
1868 (define-full-operand Dsp-40-u24 "unsigned 24 bit displacement at offset 40 bits" (all-isas)
1869 h-uint DFLT f-dsp-40-u24
1870 ((parse "unsigned24")) () ()
1872 (define-full-operand Dsp-48-u8 "unsigned 8 bit displacement at offset 48 bits" (all-isas)
1873 h-uint DFLT f-dsp-48-u8
1874 ((parse "unsigned8")) () ()
1876 (define-full-operand Dsp-48-s8 "signed 8 bit displacement at offset 48 bits" (all-isas)
1877 h-sint DFLT f-dsp-48-s8
1878 ((parse "signed8")) () ()
1880 (define-full-operand Dsp-48-u16 "unsigned 16 bit displacement at offset 48 bits" (all-isas)
1881 h-uint DFLT f-dsp-48-u16
1882 ((parse "unsigned16")) () ()
1884 (define-full-operand Dsp-48-s16 "signed 16 bit displacement at offset 48 bits" (all-isas)
1885 h-sint DFLT f-dsp-48-s16
1886 ((parse "signed16")) () ()
1888 (define-full-operand Dsp-48-u24 "unsigned 24 bit displacement at offset 48 bits" (all-isas)
1889 h-uint DFLT f-dsp-48-u24
1890 ((parse "unsigned24")) () ()
1893 (define-full-operand Imm-8-s4 "signed 4 bit immediate at offset 8 bits" (all-isas)
1894 h-sint DFLT f-imm-8-s4
1895 ((parse "signed4")) () ()
1897 (define-full-operand Imm-8-s4n "negated 4 bit immediate at offset 8 bits" (all-isas)
1898 h-sint DFLT f-imm-8-s4
1899 ((parse "signed4n")) () ()
1901 (define-full-operand Imm-sh-8-s4 "signed 4 bit shift immediate at offset 8 bits" (all-isas)
1902 h-shimm DFLT f-imm-8-s4
1905 (define-full-operand Imm-8-QI "signed 8 bit immediate at offset 8 bits" (all-isas)
1906 h-sint DFLT f-dsp-8-s8
1907 ((parse "signed8")) () ()
1909 (define-full-operand Imm-8-HI "signed 16 bit immediate at offset 8 bits" (all-isas)
1910 h-sint DFLT f-dsp-8-s16
1911 ((parse "signed16")) () ()
1913 (define-full-operand Imm-12-s4 "signed 4 bit immediate at offset 12 bits" (all-isas)
1914 h-sint DFLT f-imm-12-s4
1915 ((parse "signed4")) () ()
1917 (define-full-operand Imm-12-s4n "negated 4 bit immediate at offset 12 bits" (all-isas)
1918 h-sint DFLT f-imm-12-s4
1919 ((parse "signed4n") (print "signed4n")) () ()
1921 (define-full-operand Imm-sh-12-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas)
1922 h-shimm DFLT f-imm-12-s4
1925 (define-full-operand Imm-13-u3 "signed 3 bit immediate at offset 13 bits" (all-isas)
1926 h-sint DFLT f-imm-13-u3
1927 ((parse "signed4")) () ()
1929 (define-full-operand Imm-20-s4 "signed 4 bit immediate at offset 20 bits" (all-isas)
1930 h-sint DFLT f-imm-20-s4
1931 ((parse "signed4")) () ()
1933 (define-full-operand Imm-sh-20-s4 "signed 4 bit shift immediate at offset 12 bits" (all-isas)
1934 h-shimm DFLT f-imm-20-s4
1937 (define-full-operand Imm-16-QI "signed 8 bit immediate at offset 16 bits" (all-isas)
1938 h-sint DFLT f-dsp-16-s8
1939 ((parse "signed8")) () ()
1941 (define-full-operand Imm-16-HI "signed 16 bit immediate at offset 16 bits" (all-isas)
1942 h-sint DFLT f-dsp-16-s16
1943 ((parse "signed16")) () ()
1945 (define-full-operand Imm-16-SI "signed 32 bit immediate at offset 16 bits" (all-isas)
1946 h-sint DFLT f-dsp-16-s32
1947 ((parse "signed32")) () ()
1949 (define-full-operand Imm-24-QI "signed 8 bit immediate at offset 24 bits" (all-isas)
1950 h-sint DFLT f-dsp-24-s8
1951 ((parse "signed8")) () ()
1953 (define-full-operand Imm-24-HI "signed 16 bit immediate at offset 24 bits" (all-isas)
1954 h-sint DFLT f-dsp-24-s16
1955 ((parse "signed16")) () ()
1957 (define-full-operand Imm-24-SI "signed 32 bit immediate at offset 24 bits" (all-isas)
1958 h-sint DFLT f-dsp-24-s32
1959 ((parse "signed32")) () ()
1961 (define-full-operand Imm-32-QI "signed 8 bit immediate at offset 32 bits" (all-isas)
1962 h-sint DFLT f-dsp-32-s8
1963 ((parse "signed8")) () ()
1965 (define-full-operand Imm-32-SI "signed 32 bit immediate at offset 32 bits" (all-isas)
1966 h-sint DFLT f-dsp-32-s32
1967 ((parse "signed32")) () ()
1969 (define-full-operand Imm-32-HI "signed 16 bit immediate at offset 32 bits" (all-isas)
1970 h-sint DFLT f-dsp-32-s16
1971 ((parse "signed16")) () ()
1973 (define-full-operand Imm-40-QI "signed 8 bit immediate at offset 40 bits" (all-isas)
1974 h-sint DFLT f-dsp-40-s8
1975 ((parse "signed8")) () ()
1977 (define-full-operand Imm-40-HI "signed 16 bit immediate at offset 40 bits" (all-isas)
1978 h-sint DFLT f-dsp-40-s16
1979 ((parse "signed16")) () ()
1981 (define-full-operand Imm-40-SI "signed 32 bit immediate at offset 40 bits" (all-isas)
1982 h-sint DFLT f-dsp-40-s32
1983 ((parse "signed32")) () ()
1985 (define-full-operand Imm-48-QI "signed 8 bit immediate at offset 48 bits" (all-isas)
1986 h-sint DFLT f-dsp-48-s8
1987 ((parse "signed8")) () ()
1989 (define-full-operand Imm-48-HI "signed 16 bit immediate at offset 48 bits" (all-isas)
1990 h-sint DFLT f-dsp-48-s16
1991 ((parse "signed16")) () ()
1993 (define-full-operand Imm-48-SI "signed 32 bit immediate at offset 48 bits" (all-isas)
1994 h-sint DFLT f-dsp-48-s32
1995 ((parse "signed32")) () ()
1997 (define-full-operand Imm-56-QI "signed 8 bit immediate at offset 56 bits" (all-isas)
1998 h-sint DFLT f-dsp-56-s8
1999 ((parse "signed8")) () ()
2001 (define-full-operand Imm-56-HI "signed 16 bit immediate at offset 56 bits" (all-isas)
2002 h-sint DFLT f-dsp-56-s16
2003 ((parse "signed16")) () ()
2005 (define-full-operand Imm-64-HI "signed 16 bit immediate at offset 64 bits" (all-isas)
2006 h-sint DFLT f-dsp-64-s16
2007 ((parse "signed16")) () ()
2009 (define-full-operand Imm1-S "signed 1 bit immediate for short format binary insns" (m32c-isa)
2010 h-sint DFLT f-imm1-S
2011 ((parse "imm1_S")) () ()
2013 (define-full-operand Imm3-S "signed 3 bit immediate for short format binary insns" (m32c-isa)
2014 h-sint DFLT f-imm3-S
2015 ((parse "imm3_S")) () ()
2018 ;-------------------------------------------------------------
2020 ;-------------------------------------------------------------
2022 (define-full-operand Bitno16R "bit number for indexing registers" (m16c-isa)
2023 h-uint DFLT f-dsp-16-u8
2024 ((parse "Bitno16R")) () ()
2026 (dnop Bitno32Prefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-prefixed)
2027 (dnop Bitno32Unprefixed "bit number for indexing objects" (m32c-isa) h-uint f-bitno32-unprefixed)
2029 (define-full-operand BitBase16-16-u8 "unsigned bit,base:8 at offset 16for m16c" (m16c-isa)
2030 h-uint DFLT f-dsp-16-u8
2031 ((parse "unsigned_bitbase8") (print "unsigned_bitbase")) () ()
2033 (define-full-operand BitBase16-16-s8 "signed bit,base:8 at offset 16for m16c" (m16c-isa)
2034 h-sint DFLT f-dsp-16-s8
2035 ((parse "signed_bitbase8") (print "signed_bitbase")) () ()
2037 (define-full-operand BitBase16-16-u16 "unsigned bit,base:16 at offset 16 for m16c" (m16c-isa)
2038 h-uint DFLT f-dsp-16-u16
2039 ((parse "unsigned_bitbase16") (print "unsigned_bitbase")) () ()
2041 (define-full-operand BitBase16-8-u11-S "signed bit,base:11 at offset 16 for m16c" (m16c-isa)
2042 h-uint DFLT f-bitbase16-u11-S
2043 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2046 (define-full-operand BitBase32-16-u11-Unprefixed "unsigned bit,base:11 at offset 16 for m32c" (m32c-isa)
2047 h-uint DFLT f-bitbase32-16-u11-unprefixed
2048 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2050 (define-full-operand BitBase32-16-s11-Unprefixed "signed bit,base:11 at offset 16 for m32c" (m32c-isa)
2051 h-sint DFLT f-bitbase32-16-s11-unprefixed
2052 ((parse "signed_bitbase11") (print "signed_bitbase")) () ()
2054 (define-full-operand BitBase32-16-u19-Unprefixed "unsigned bit,base:19 at offset 16 for m32c" (m32c-isa)
2055 h-uint DFLT f-bitbase32-16-u19-unprefixed
2056 ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () ()
2058 (define-full-operand BitBase32-16-s19-Unprefixed "signed bit,base:19 at offset 16 for m32c" (m32c-isa)
2059 h-sint DFLT f-bitbase32-16-s19-unprefixed
2060 ((parse "signed_bitbase19") (print "signed_bitbase")) () ()
2062 (define-full-operand BitBase32-16-u27-Unprefixed "unsigned bit,base:27 at offset 16 for m32c" (m32c-isa)
2063 h-uint DFLT f-bitbase32-16-u27-unprefixed
2064 ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () ()
2066 (define-full-operand BitBase32-24-u11-Prefixed "unsigned bit,base:11 at offset 24 for m32c" (m32c-isa)
2067 h-uint DFLT f-bitbase32-24-u11-prefixed
2068 ((parse "unsigned_bitbase11") (print "unsigned_bitbase")) () ()
2070 (define-full-operand BitBase32-24-s11-Prefixed "signed bit,base:11 at offset 24 for m32c" (m32c-isa)
2071 h-sint DFLT f-bitbase32-24-s11-prefixed
2072 ((parse "signed_bitbase11") (print "signed_bitbase")) () ()
2074 (define-full-operand BitBase32-24-u19-Prefixed "unsigned bit,base:19 at offset 24 for m32c" (m32c-isa)
2075 h-uint DFLT f-bitbase32-24-u19-prefixed
2076 ((parse "unsigned_bitbase19") (print "unsigned_bitbase")) () ()
2078 (define-full-operand BitBase32-24-s19-Prefixed "signed bit,base:19 at offset 24 for m32c" (m32c-isa)
2079 h-sint DFLT f-bitbase32-24-s19-prefixed
2080 ((parse "signed_bitbase19") (print "signed_bitbase")) () ()
2082 (define-full-operand BitBase32-24-u27-Prefixed "unsigned bit,base:27 at offset 24 for m32c" (m32c-isa)
2083 h-uint DFLT f-bitbase32-24-u27-prefixed
2084 ((parse "unsigned_bitbase27") (print "unsigned_bitbase")) () ()
2086 ;-------------------------------------------------------------
2088 ;-------------------------------------------------------------
2090 (define-full-operand Lab-5-3 "3 bit label" (all-isas RELAX)
2091 h-iaddr DFLT f-lab-5-3
2092 ((parse "lab_5_3")) () () )
2094 (define-full-operand Lab32-jmp-s "3 bit label" (all-isas RELAX)
2095 h-iaddr DFLT f-lab32-jmp-s
2096 ((parse "lab_5_3")) () () )
2098 (dnop Lab-8-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-8-8)
2099 (dnop Lab-8-16 "16 bit label" (all-isas RELAX) h-iaddr f-lab-8-16)
2100 (dnop Lab-8-24 "24 bit label" (all-isas) h-iaddr f-lab-8-24)
2101 (dnop Lab-16-8 "8 bit label" (all-isas RELAX) h-iaddr f-lab-16-8)
2102 (dnop Lab-24-8 "8 bit label" (all-isas) h-iaddr f-lab-24-8)
2103 (dnop Lab-32-8 "8 bit label" (all-isas) h-iaddr f-lab-32-8)
2104 (dnop Lab-40-8 "8 bit label" (all-isas) h-iaddr f-lab-40-8)
2106 ;-------------------------------------------------------------
2107 ; Condition code bits
2108 ;-------------------------------------------------------------
2110 (dnop sbit "negative bit" (SEM-ONLY all-isas) h-sbit f-nil)
2111 (dnop obit "overflow bit" (SEM-ONLY all-isas) h-obit f-nil)
2112 (dnop zbit "zero bit" (SEM-ONLY all-isas) h-zbit f-nil)
2113 (dnop cbit "carry bit" (SEM-ONLY all-isas) h-cbit f-nil)
2114 (dnop ubit "stack ptr select bit" (SEM-ONLY all-isas) h-ubit f-nil)
2115 (dnop ibit "interrupt enable bit" (SEM-ONLY all-isas) h-ibit f-nil)
2116 (dnop bbit "reg bank select bit" (SEM-ONLY all-isas) h-bbit f-nil)
2117 (dnop dbit "debug bit" (SEM-ONLY all-isas) h-dbit f-nil)
2119 ;-------------------------------------------------------------
2120 ; Condition operands
2121 ;-------------------------------------------------------------
2123 (define-pmacro (cond-operand mach offset)
2124 (dnop (.sym cond mach - offset) "condition" ((.sym m mach c-isa)) (.sym h-cond mach) (.sym f-dsp- offset -u8))
2127 (cond-operand 16 16)
2128 (cond-operand 16 24)
2129 (cond-operand 16 32)
2130 (cond-operand 32 16)
2131 (cond-operand 32 24)
2132 (cond-operand 32 32)
2133 (cond-operand 32 40)
2135 (dnop cond16c "condition" (m16c-isa) h-cond16c f-cond16)
2136 (dnop cond16j "condition" (m16c-isa) h-cond16j f-cond16)
2137 (dnop cond16j5 "condition" (m16c-isa) h-cond16j-5 f-cond16j-5)
2138 (dnop cond32 "condition" (m32c-isa) h-cond32 f-cond32)
2139 (dnop cond32j "condition" (m32c-isa) h-cond32 f-cond32j)
2140 (dnop sccond32 "scCND condition" (m32c-isa) h-cond32 f-cond16)
2141 (dnop flags16 "flags" (m16c-isa) h-flags f-9-3)
2142 (dnop flags32 "flags" (m32c-isa) h-flags f-13-3)
2143 (dnop cr16 "control" (m16c-isa) h-cr-16 f-9-3)
2144 (dnop cr1-Unprefixed-32 "control" (m32c-isa) h-cr1-32 f-13-3)
2145 (dnop cr1-Prefixed-32 "control" (m32c-isa) h-cr1-32 f-21-3)
2146 (dnop cr2-32 "control" (m32c-isa) h-cr2-32 f-13-3)
2147 (dnop cr3-Unprefixed-32 "control" (m32c-isa) h-cr3-32 f-13-3)
2148 (dnop cr3-Prefixed-32 "control" (m32c-isa) h-cr3-32 f-21-3)
2150 ;-------------------------------------------------------------
2152 ;-------------------------------------------------------------
2154 (define-full-operand Z "Suffix for zero format insns" (all-isas)
2156 ((parse "Z") (print "Z")) () ()
2158 (define-full-operand S "Suffix for short format insns" (all-isas)
2160 ((parse "S") (print "S")) () ()
2162 (define-full-operand Q "Suffix for quick format insns" (all-isas)
2164 ((parse "Q") (print "Q")) () ()
2166 (define-full-operand G "Suffix for general format insns" (all-isas)
2168 ((parse "G") (print "G")) () ()
2170 (define-full-operand X "Empty suffix" (all-isas)
2172 ((parse "X") (print "X")) () ()
2174 (define-full-operand size "any size specifier" (all-isas)
2176 ((parse "size") (print "size")) () ()
2178 ;-------------------------------------------------------------
2180 ;-------------------------------------------------------------
2182 (dnop BitIndex "Bit Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-bit-index f-nil)
2183 (dnop SrcIndex "Source Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-src-index f-nil)
2184 (dnop DstIndex "Destination Index for the next insn" (SEM-ONLY MACH32 m32c-isa) h-dst-index f-nil)
2185 (dnop NoRemainder "Place holder for when the remainder is not kept" (SEM-ONLY MACH32 m32c-isa) h-none f-nil)
2187 ;=============================================================
2190 ; Memory reference macros that clip addresses appropriately. Refer to
2191 ; memory at ADDRESS in MODE, clipped appropriately for either the m16c
2193 (define-pmacro (mem16 mode address)
2194 (mem mode (and #xffff address)))
2196 (define-pmacro (mem32 mode address)
2197 (mem mode (and #xffffff address)))
2199 ; Like mem16 and mem32, but takes MACH as a parameter. MACH must be
2201 (define-pmacro (mem-mach mach mode address)
2202 ((.sym mem mach) mode address))
2204 ;-------------------------------------------------------------
2206 ;-------------------------------------------------------------
2208 ;-------------------------------------------------------------
2210 (define-pmacro (src16-Rn-direct-operand xmode)
2212 (define-derived-operand
2213 (name (.sym src16-Rn-direct- xmode))
2214 (comment (.str "m16c Rn direct source " xmode))
2215 (attrs (machine 16))
2217 (args ((.sym Src16Rn xmode)))
2218 (syntax (.str "$Src16Rn" xmode))
2220 (encoding (+ (f-8-2 0) (.sym Src16Rn xmode)))
2221 (ifield-assertion (eq f-8-2 0))
2222 (getter (trunc xmode (.sym Src16Rn xmode)))
2223 (setter (set (.sym Src16Rn xmode) newval))
2227 (src16-Rn-direct-operand QI)
2228 (src16-Rn-direct-operand HI)
2230 (define-pmacro (src32-Rn-direct-operand group base xmode)
2232 (define-derived-operand
2233 (name (.sym src32-Rn-direct- group - xmode))
2234 (comment (.str "m32c Rn direct source " xmode))
2235 (attrs (machine 32))
2237 (args ((.sym Src32Rn group xmode)))
2238 (syntax (.str "$Src32Rn" group xmode))
2239 (base-ifield (.sym f- base -11))
2240 (encoding (+ ((.sym f- base -3) 4) (.sym Src32Rn group xmode)))
2241 (ifield-assertion (eq (.sym f- base -3) 4))
2242 (getter (trunc xmode (.sym Src32Rn group xmode)))
2243 (setter (set (.sym Src32Rn group xmode) newval))
2248 (src32-Rn-direct-operand Unprefixed 1 QI)
2249 (src32-Rn-direct-operand Prefixed 9 QI)
2250 (src32-Rn-direct-operand Unprefixed 1 HI)
2251 (src32-Rn-direct-operand Prefixed 9 HI)
2252 (src32-Rn-direct-operand Unprefixed 1 SI)
2253 (src32-Rn-direct-operand Prefixed 9 SI)
2255 ;-------------------------------------------------------------
2257 ;-------------------------------------------------------------
2259 (define-pmacro (src16-An-direct-operand xmode)
2261 (define-derived-operand
2262 (name (.sym src16-An-direct- xmode))
2263 (comment (.str "m16c An direct destination " xmode))
2264 (attrs (machine 16))
2266 (args ((.sym Src16An xmode)))
2267 (syntax (.str "$Src16An" xmode))
2269 (encoding (+ (f-8-2 1) (f-10-1 0) (.sym Src16An xmode)))
2270 (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 0)))
2271 (getter (trunc xmode (.sym Src16An xmode)))
2272 (setter (set (.sym Src16An xmode) newval))
2276 (src16-An-direct-operand QI)
2277 (src16-An-direct-operand HI)
2279 (define-pmacro (src32-An-direct-operand group base1 base2 xmode)
2281 (define-derived-operand
2282 (name (.sym src32-An-direct- group - xmode))
2283 (comment (.str "m32c An direct destination " xmode))
2284 (attrs (machine 32))
2286 (args ((.sym Src32An group xmode)))
2287 (syntax (.str "$Src32An" group xmode))
2288 (base-ifield (.sym f- base1 -11))
2289 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Src32An group xmode)))
2290 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
2291 (getter (trunc xmode (.sym Src32An group xmode)))
2292 (setter (set (.sym Src32An group xmode) newval))
2297 (src32-An-direct-operand Unprefixed 1 10 QI)
2298 (src32-An-direct-operand Unprefixed 1 10 HI)
2299 (src32-An-direct-operand Unprefixed 1 10 SI)
2300 (src32-An-direct-operand Prefixed 9 18 QI)
2301 (src32-An-direct-operand Prefixed 9 18 HI)
2302 (src32-An-direct-operand Prefixed 9 18 SI)
2304 ;-------------------------------------------------------------
2306 ;-------------------------------------------------------------
2308 (define-pmacro (src16-An-indirect-operand xmode)
2310 (define-derived-operand
2311 (name (.sym src16-An-indirect- xmode))
2312 (comment (.str "m16c An indirect destination " xmode))
2313 (attrs (machine 16))
2316 (syntax "[$Src16An]")
2318 (encoding (+ (f-8-2 1) (f-10-1 1) Src16An))
2319 (ifield-assertion (andif (eq f-8-2 1) (eq f-10-1 1)))
2320 (getter (mem16 xmode Src16An))
2321 (setter (set (mem16 xmode Src16An) newval))
2325 (src16-An-indirect-operand QI)
2326 (src16-An-indirect-operand HI)
2328 (define-pmacro (src32-An-indirect-operand group base1 base2 xmode)
2330 (define-derived-operand
2331 (name (.sym src32-An-indirect- group - xmode))
2332 (comment (.str "m32c An indirect destination " xmode))
2333 (attrs (machine 32))
2335 (args ((.sym Src32An group)))
2336 (syntax (.str "[$Src32An" group "]"))
2337 (base-ifield (.sym f- base1 -11))
2338 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Src32An group)))
2339 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
2340 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group)
2342 (setter (c-call DFLT (.str "operand_setter_" xmode) newval
2343 (.sym Src32An group) (const 0)))
2344 ; (getter (mem32 xmode (.sym Src32An group)))
2345 ; (setter (set (mem32 xmode (.sym Src32An group)) newval))
2350 (src32-An-indirect-operand Unprefixed 1 10 QI)
2351 (src32-An-indirect-operand Unprefixed 1 10 HI)
2352 (src32-An-indirect-operand Unprefixed 1 10 SI)
2353 (src32-An-indirect-operand Prefixed 9 18 QI)
2354 (src32-An-indirect-operand Prefixed 9 18 HI)
2355 (src32-An-indirect-operand Prefixed 9 18 SI)
2357 ;-------------------------------------------------------------
2359 ;-------------------------------------------------------------
2361 (define-pmacro (src16-relative-operand xmode)
2363 (define-derived-operand
2364 (name (.sym src16-16-8-SB-relative- xmode))
2365 (comment (.str "m16c dsp:8[sb] relative destination " xmode))
2366 (attrs (machine 16))
2369 (syntax "${Dsp-16-u8}[sb]")
2371 (encoding (+ (f-8-4 #xA) Dsp-16-u8))
2372 (ifield-assertion (eq f-8-4 #xA))
2373 (getter (mem16 xmode (add Dsp-16-u8 (reg h-sb))))
2374 (setter (set (mem16 xmode (add Dsp-16-u8 (reg h-sb))) newval))
2376 (define-derived-operand
2377 (name (.sym src16-16-16-SB-relative- xmode))
2378 (comment (.str "m16c dsp:16[sb] relative destination " xmode))
2379 (attrs (machine 16))
2382 (syntax "${Dsp-16-u16}[sb]")
2384 (encoding (+ (f-8-4 #xE) Dsp-16-u16))
2385 (ifield-assertion (eq f-8-4 #xE))
2386 (getter (mem16 xmode (add Dsp-16-u16 (reg h-sb))))
2387 (setter (set (mem16 xmode (add Dsp-16-u16 (reg h-sb))) newval))
2389 (define-derived-operand
2390 (name (.sym src16-16-8-FB-relative- xmode))
2391 (comment (.str "m16c dsp:8[fb] relative destination " xmode))
2392 (attrs (machine 16))
2395 (syntax "${Dsp-16-s8}[fb]")
2397 (encoding (+ (f-8-4 #xB) Dsp-16-s8))
2398 (ifield-assertion (eq f-8-4 #xB))
2399 (getter (mem16 xmode (add Dsp-16-s8 (reg h-fb))))
2400 (setter (set (mem16 xmode (add Dsp-16-s8 (reg h-fb))) newval))
2402 (define-derived-operand
2403 (name (.sym src16-16-8-An-relative- xmode))
2404 (comment (.str "m16c dsp:8[An] relative destination " xmode))
2405 (attrs (machine 16))
2407 (args (Src16An Dsp-16-u8))
2408 (syntax "${Dsp-16-u8}[$Src16An]")
2410 (encoding (+ (f-8-2 2) (f-10-1 0) Dsp-16-u8 Src16An))
2411 (ifield-assertion (andif (eq f-8-2 2) (eq f-10-1 0)))
2412 (getter (mem16 xmode (add Dsp-16-u8 Src16An)))
2413 (setter (set (mem16 xmode (add Dsp-16-u8 Src16An)) newval))
2415 (define-derived-operand
2416 (name (.sym src16-16-16-An-relative- xmode))
2417 (comment (.str "m16c dsp:16[An] relative destination " xmode))
2418 (attrs (machine 16))
2420 (args (Src16An Dsp-16-u16))
2421 (syntax "${Dsp-16-u16}[$Src16An]")
2423 (encoding (+ (f-8-2 3) (f-10-1 0) Dsp-16-u16 Src16An))
2424 (ifield-assertion (andif (eq f-8-2 3) (eq f-10-1 0)))
2425 (getter (mem16 xmode (add Dsp-16-u16 Src16An)))
2426 (setter (set (mem16 xmode (add Dsp-16-u16 Src16An)) newval))
2431 (src16-relative-operand QI)
2432 (src16-relative-operand HI)
2434 (define-pmacro (src32-relative-operand offset group base1 base2 xmode)
2436 (define-derived-operand
2437 (name (.sym src32- offset -8-SB-relative- group - xmode))
2438 (comment (.str "m32c dsp:8[sb] relative destination " xmode))
2439 (attrs (machine 32))
2441 (args ((.sym Dsp- offset -u8)))
2442 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
2443 (base-ifield (.sym f- base1 -11))
2444 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8)))
2445 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
2446 (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u8)))
2447 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u8)))
2448 ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb))))
2449 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
2451 (define-derived-operand
2452 (name (.sym src32- offset -16-SB-relative- group - xmode))
2453 (comment (.str "m32c dsp:16[sb] relative destination " xmode))
2454 (attrs (machine 32))
2456 (args ((.sym Dsp- offset -u16)))
2457 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
2458 (base-ifield (.sym f- base1 -11))
2459 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16)))
2460 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
2461 (getter (c-call xmode (.str "operand_getter_" xmode) sb (.sym Dsp- offset -u16)))
2462 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb (.sym Dsp- offset -u16)))
2463 ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb))))
2464 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
2466 (define-derived-operand
2467 (name (.sym src32- offset -8-FB-relative- group - xmode))
2468 (comment (.str "m32c dsp:8[fb] relative destination " xmode))
2469 (attrs (machine 32))
2471 (args ((.sym Dsp- offset -s8)))
2472 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
2473 (base-ifield (.sym f- base1 -11))
2474 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8)))
2475 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
2476 (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s8)))
2477 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s8)))
2478 ; (getter (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb))))
2479 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
2481 (define-derived-operand
2482 (name (.sym src32- offset -16-FB-relative- group - xmode))
2483 (comment (.str "m32c dsp:16[fb] relative destination " xmode))
2484 (attrs (machine 32))
2486 (args ((.sym Dsp- offset -s16)))
2487 (syntax (.str "${Dsp-" offset "-s16}[fb]"))
2488 (base-ifield (.sym f- base1 -11))
2489 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16)))
2490 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
2491 (getter (c-call xmode (.str "operand_getter_" xmode) fb (.sym Dsp- offset -s16)))
2492 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb (.sym Dsp- offset -s16)))
2493 ; (getter (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb))))
2494 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval))
2496 (define-derived-operand
2497 (name (.sym src32- offset -8-An-relative- group - xmode))
2498 (comment (.str "m32c dsp:8[An] relative destination " xmode))
2499 (attrs (machine 32))
2501 (args ((.sym Src32An group) (.sym Dsp- offset -u8)))
2502 (syntax (.str "${Dsp-" offset "-u8}[$Src32An" group "]"))
2503 (base-ifield (.sym f- base1 -11))
2504 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Src32An group)))
2505 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
2506 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u8)))
2507 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u8)))
2508 ; (getter (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group))))
2509 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u8) (.sym Src32An group))) newval))
2511 (define-derived-operand
2512 (name (.sym src32- offset -16-An-relative- group - xmode))
2513 (comment (.str "m32c dsp:16[An] relative destination " xmode))
2514 (attrs (machine 32))
2516 (args ((.sym Src32An group) (.sym Dsp- offset -u16)))
2517 (syntax (.str "${Dsp-" offset "-u16}[$Src32An" group "]"))
2518 (base-ifield (.sym f- base1 -11))
2519 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Src32An group)))
2520 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
2521 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u16)))
2522 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u16)))
2523 ; (getter (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group))))
2524 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u16) (.sym Src32An group))) newval))
2526 (define-derived-operand
2527 (name (.sym src32- offset -24-An-relative- group - xmode))
2528 (comment (.str "m32c dsp:16[An] relative destination " xmode))
2529 (attrs (machine 32))
2531 (args ((.sym Src32An group) (.sym Dsp- offset -u24)))
2532 (syntax (.str "${Dsp-" offset "-u24}[$Src32An" group "]"))
2533 (base-ifield (.sym f- base1 -11))
2534 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Src32An group)))
2535 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
2536 (getter (c-call xmode (.str "operand_getter_" xmode) (.sym Src32An group) (.sym Dsp- offset -u24) ))
2537 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (.sym Src32An group) (.sym Dsp- offset -u24)))
2538 ; (getter (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group))))
2539 ; (setter (set (mem32 xmode (add (.sym Dsp- offset -u24) (.sym Src32An group))) newval))
2544 (src32-relative-operand 16 Unprefixed 1 10 QI)
2545 (src32-relative-operand 16 Unprefixed 1 10 HI)
2546 (src32-relative-operand 16 Unprefixed 1 10 SI)
2547 (src32-relative-operand 24 Prefixed 9 18 QI)
2548 (src32-relative-operand 24 Prefixed 9 18 HI)
2549 (src32-relative-operand 24 Prefixed 9 18 SI)
2551 ;-------------------------------------------------------------
2553 ;-------------------------------------------------------------
2555 (define-pmacro (src16-absolute xmode)
2557 (define-derived-operand
2558 (name (.sym src16-16-16-absolute- xmode))
2559 (comment (.str "m16c absolute address " xmode))
2560 (attrs (machine 16))
2563 (syntax (.str "${Dsp-16-u16}"))
2565 (encoding (+ (f-8-4 #xF) Dsp-16-u16))
2566 (ifield-assertion (eq f-8-4 #xF))
2567 (getter (mem16 xmode Dsp-16-u16))
2568 (setter (set (mem16 xmode Dsp-16-u16) newval))
2576 (define-pmacro (src32-absolute offset group base1 base2 xmode)
2578 (define-derived-operand
2579 (name (.sym src32- offset -16-absolute- group - xmode))
2580 (comment (.str "m32c absolute address " xmode))
2581 (attrs (machine 32))
2583 (args ((.sym Dsp- offset -u16)))
2584 (syntax (.str "${Dsp-" offset "-u16}"))
2585 (base-ifield (.sym f- base1 -11))
2586 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
2587 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
2588 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u16)))
2589 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u16)))
2590 ; (getter (mem32 xmode (.sym Dsp- offset -u16)))
2591 ; (setter (set (mem32 xmode (.sym Dsp- offset -u16)) newval))
2593 (define-derived-operand
2594 (name (.sym src32- offset -24-absolute- group - xmode))
2595 (comment (.str "m32c absolute address " xmode))
2596 (attrs (machine 32))
2598 (args ((.sym Dsp- offset -u24)))
2599 (syntax (.str "${Dsp-" offset "-u24}"))
2600 (base-ifield (.sym f- base1 -11))
2601 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
2602 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
2603 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) (.sym Dsp- offset -u24)))
2604 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) (.sym Dsp- offset -u24)))
2605 ; (getter (mem32 xmode (.sym Dsp- offset -u24)))
2606 ; (setter (set (mem32 xmode (.sym Dsp- offset -u24)) newval))
2611 (src32-absolute 16 Unprefixed 1 10 QI)
2612 (src32-absolute 16 Unprefixed 1 10 HI)
2613 (src32-absolute 16 Unprefixed 1 10 SI)
2614 (src32-absolute 24 Prefixed 9 18 QI)
2615 (src32-absolute 24 Prefixed 9 18 HI)
2616 (src32-absolute 24 Prefixed 9 18 SI)
2618 ;-------------------------------------------------------------
2619 ; An indirect indirect
2621 ; Double indirect addressing uses the lower 3 bytes of the value stored
2622 ; at the address referenced by 'op' as the effective address.
2623 ;-------------------------------------------------------------
2625 (define-pmacro (indirect-addr op) (and USI (mem32 USI op) #x00ffffff))
2627 ; (define-pmacro (src-An-indirect-indirect-operand xmode)
2628 ; (define-derived-operand
2629 ; (name (.sym src32-An-indirect-indirect- xmode))
2630 ; (comment (.str "m32c An indirect indirect destination " xmode))
2631 ; (attrs (machine 32))
2633 ; (args (Src32AnPrefixed))
2634 ; (syntax (.str "[[$Src32AnPrefixed]]"))
2635 ; (base-ifield f-9-11)
2636 ; (encoding (+ (f-9-3 0) (f-18-1 0) Src32AnPrefixed))
2637 ; (ifield-assertion (andif (eq f-9-3 0) (eq f-18-1 0)))
2638 ; (getter (mem32 xmode (indirect-addr Src32AnPrefixed)))
2639 ; (setter (set (mem32 xmode (indirect-addr Src32AnPrefixed)) newval))
2643 ; (src-An-indirect-indirect-operand QI)
2644 ; (src-An-indirect-indirect-operand HI)
2645 ; (src-An-indirect-indirect-operand SI)
2647 ;-------------------------------------------------------------
2649 ;-------------------------------------------------------------
2651 (define-pmacro (src-relative-indirect-operand xmode)
2653 ; (define-derived-operand
2654 ; (name (.sym src32-24-8-SB-relative-indirect- xmode))
2655 ; (comment (.str "m32c dsp:8[sb] relative source " xmode))
2656 ; (attrs (machine 32))
2658 ; (args (Dsp-24-u8))
2659 ; (syntax "[${Dsp-24-u8}[sb]]")
2660 ; (base-ifield f-9-11)
2661 ; (encoding (+ (f-9-3 1) (f-18-2 2) Dsp-24-u8))
2662 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 2)))
2663 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb)))))
2664 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 (reg h-sb)))) newval))
2666 ; (define-derived-operand
2667 ; (name (.sym src32-24-16-SB-relative-indirect- xmode))
2668 ; (comment (.str "m32c dsp:16[sb] relative source " xmode))
2669 ; (attrs (machine 32))
2671 ; (args (Dsp-24-u16))
2672 ; (syntax "[${Dsp-24-u16}[sb]]")
2673 ; (base-ifield f-9-11)
2674 ; (encoding (+ (f-9-3 2) (f-18-2 2) Dsp-24-u16))
2675 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 2)))
2676 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb)))))
2677 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 (reg h-sb)))) newval))
2679 ; (define-derived-operand
2680 ; (name (.sym src32-24-8-FB-relative-indirect- xmode))
2681 ; (comment (.str "m32c dsp:8[fb] relative source " xmode))
2682 ; (attrs (machine 32))
2684 ; (args (Dsp-24-s8))
2685 ; (syntax "[${Dsp-24-s8}[fb]]")
2686 ; (base-ifield f-9-11)
2687 ; (encoding (+ (f-9-3 1) (f-18-2 3) Dsp-24-s8))
2688 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-2 3)))
2689 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb)))))
2690 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s8 (reg h-fb)))) newval))
2692 ; (define-derived-operand
2693 ; (name (.sym src32-24-16-FB-relative-indirect- xmode))
2694 ; (comment (.str "m32c dsp:16[fb] relative source " xmode))
2695 ; (attrs (machine 32))
2697 ; (args (Dsp-24-s16))
2698 ; (syntax "[${Dsp-24-s16}[fb]]")
2699 ; (base-ifield f-9-11)
2700 ; (encoding (+ (f-9-3 2) (f-18-2 3) Dsp-24-s16))
2701 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-2 3)))
2702 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb)))))
2703 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-s16 (reg h-fb)))) newval))
2705 ; (define-derived-operand
2706 ; (name (.sym src32-24-8-An-relative-indirect- xmode))
2707 ; (comment (.str "m32c dsp:8[An] relative indirect source " xmode))
2708 ; (attrs (machine 32))
2710 ; (args (Src32AnPrefixed Dsp-24-u8))
2711 ; (syntax "[${Dsp-24-u8}[$Src32AnPrefixed]]")
2712 ; (base-ifield f-9-11)
2713 ; (encoding (+ (f-9-3 1) (f-18-1 0) Dsp-24-u8 Src32AnPrefixed))
2714 ; (ifield-assertion (andif (eq f-9-3 1) (eq f-18-1 0)))
2715 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed))))
2716 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u8 Src32AnPrefixed))) newval))
2718 ; (define-derived-operand
2719 ; (name (.sym src32-24-16-An-relative-indirect- xmode))
2720 ; (comment (.str "m32c dsp:16[An] relative source " xmode))
2721 ; (attrs (machine 32))
2723 ; (args (Src32AnPrefixed Dsp-24-u16))
2724 ; (syntax "[${Dsp-24-u16}[$Src32AnPrefixed]]")
2725 ; (base-ifield f-9-11)
2726 ; (encoding (+ (f-9-3 2) (f-18-1 0) Dsp-24-u16 Src32AnPrefixed))
2727 ; (ifield-assertion (andif (eq f-9-3 2) (eq f-18-1 0)))
2728 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed))))
2729 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u16 Src32AnPrefixed))) newval))
2731 ; (define-derived-operand
2732 ; (name (.sym src32-24-24-An-relative-indirect- xmode))
2733 ; (comment (.str "m32c dsp:24[An] relative source " xmode))
2734 ; (attrs (machine 32))
2736 ; (args (Src32AnPrefixed Dsp-24-u24))
2737 ; (syntax "[${Dsp-24-u24}[$Src32AnPrefixed]]")
2738 ; (base-ifield f-9-11)
2739 ; (encoding (+ (f-9-3 3) (f-18-1 0) Dsp-24-u24 Src32AnPrefixed))
2740 ; (ifield-assertion (andif (eq f-9-3 3) (eq f-18-1 0)))
2741 ; (getter (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed))))
2742 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-24-u24 Src32AnPrefixed))) newval))
2747 ; (src-relative-indirect-operand QI)
2748 ; (src-relative-indirect-operand HI)
2749 ; (src-relative-indirect-operand SI)
2751 ;-------------------------------------------------------------
2752 ; Absolute Indirect address
2753 ;-------------------------------------------------------------
2755 (define-pmacro (src32-absolute-indirect offset base1 base2 xmode)
2757 ; (define-derived-operand
2758 ; (name (.sym src32- offset -16-absolute-indirect-derived- xmode))
2759 ; (comment (.str "m32c absolute indirect address " xmode))
2760 ; (attrs (machine 32))
2762 ; (args ((.sym Dsp- offset -u16)))
2763 ; (syntax (.str "[${Dsp-" offset "-u16}]"))
2764 ; (base-ifield (.sym f- base1 -11))
2765 ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
2766 ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
2767 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))))
2768 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval))
2770 ; (define-derived-operand
2771 ; (name (.sym src32- offset -24-absolute-indirect-derived- xmode))
2772 ; (comment (.str "m32c absolute indirect address " xmode))
2773 ; (attrs (machine 32))
2775 ; (args ((.sym Dsp- offset -u24)))
2776 ; (syntax (.str "[${Dsp-" offset "-u24}]"))
2777 ; (base-ifield (.sym f- base1 -11))
2778 ; (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
2779 ; (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
2780 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))))
2781 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval))
2786 (src32-absolute-indirect 24 9 18 QI)
2787 (src32-absolute-indirect 24 9 18 HI)
2788 (src32-absolute-indirect 24 9 18 SI)
2790 ;-------------------------------------------------------------
2791 ; Register relative source operands for short format insns
2792 ;-------------------------------------------------------------
2794 (define-pmacro (src-2-S-operands mach xmode base opc1 opc2 opc3)
2796 (define-derived-operand
2797 (name (.sym src mach -2-S-8-SB-relative- xmode))
2798 (comment (.str "m" mach "c SB relative address"))
2799 (attrs (machine mach))
2802 (syntax "${Dsp-8-u8}[sb]")
2803 (base-ifield (.sym f- base -2))
2804 (encoding (+ ((.sym f- base -2) opc1) Dsp-8-u8))
2805 (ifield-assertion (eq (.sym f- base -2) opc1))
2806 (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8))
2807 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8))
2808 ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8))))
2809 ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-sb) Dsp-8-u8))) newval))
2811 (define-derived-operand
2812 (name (.sym src mach -2-S-8-FB-relative- xmode))
2813 (comment (.str "m" mach "c FB relative address"))
2814 (attrs (machine mach))
2817 (syntax "${Dsp-8-s8}[fb]")
2818 (base-ifield (.sym f- base -2))
2819 (encoding (+ ((.sym f- base -2) opc2) Dsp-8-s8))
2820 (ifield-assertion (eq (.sym f- base -2) opc2))
2821 (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8))
2822 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8))
2823 ; (getter (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8))))
2824 ; (setter (set (mem-mach mach xmode (indirect-addr (add (reg h-fb) Dsp-8-s8))) newval))
2826 (define-derived-operand
2827 (name (.sym src mach -2-S-16-absolute- xmode))
2828 (comment (.str "m" mach "c absolute address"))
2829 (attrs (machine mach))
2832 (syntax "${Dsp-8-u16}")
2833 (base-ifield (.sym f- base -2))
2834 (encoding (+ ((.sym f- base -2) opc3) Dsp-8-u16))
2835 (ifield-assertion (eq (.sym f- base -2) opc3))
2836 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16))
2837 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16))
2838 ; (getter (mem-mach mach xmode Dsp-8-u16))
2839 ; (setter (set (mem-mach mach xmode Dsp-8-u16) newval))
2844 (src-2-S-operands 16 QI 6 1 2 3)
2845 (src-2-S-operands 32 QI 2 2 3 1)
2846 (src-2-S-operands 32 HI 2 2 3 1)
2848 ;=============================================================
2850 ;-------------------------------------------------------------
2852 ;-------------------------------------------------------------
2854 ;-------------------------------------------------------------
2856 (define-pmacro (dst16-Rn-direct-operand xmode)
2858 (define-derived-operand
2859 (name (.sym dst16-Rn-direct- xmode))
2860 (comment (.str "m16c Rn direct destination " xmode))
2861 (attrs (machine 16))
2863 (args ((.sym Dst16Rn xmode)))
2864 (syntax (.str "$Dst16Rn" xmode))
2865 (base-ifield f-12-4)
2866 (encoding (+ (f-12-2 0) (.sym Dst16Rn xmode)))
2867 (ifield-assertion (eq f-12-2 0))
2868 (getter (trunc xmode (.sym Dst16Rn xmode)))
2869 (setter (set (.sym Dst16Rn xmode) newval))
2874 (dst16-Rn-direct-operand QI)
2875 (dst16-Rn-direct-operand HI)
2876 (dst16-Rn-direct-operand SI)
2878 (define-derived-operand
2879 (name dst16-Rn-direct-Ext-QI)
2880 (comment "m16c Rn direct destination QI")
2881 (attrs (machine 16))
2883 (args (Dst16RnExtQI))
2884 (syntax "$Dst16RnExtQI")
2885 (base-ifield f-12-4)
2886 (encoding (+ (f-12-2 0) Dst16RnExtQI (f-15-1 0)))
2887 (ifield-assertion (andif (eq f-12-2 0) (eq f-15-1 0)))
2888 (getter (trunc QI (.sym Dst16RnExtQI)))
2889 (setter (set Dst16RnExtQI newval))
2892 (define-pmacro (dst32-Rn-direct-operand group base xmode)
2894 (define-derived-operand
2895 (name (.sym dst32-Rn-direct- group - xmode))
2896 (comment (.str "m32c Rn direct destination " xmode))
2897 (attrs (machine 32))
2899 (args ((.sym Dst32Rn group xmode)))
2900 (syntax (.str "$Dst32Rn" group xmode))
2901 (base-ifield (.sym f- base -6))
2902 (encoding (+ ((.sym f- base -3) 4) (.sym Dst32Rn group xmode)))
2903 (ifield-assertion (eq (.sym f- base -3) 4))
2904 (getter (trunc xmode (.sym Dst32Rn group xmode)))
2905 (setter (set (.sym Dst32Rn group xmode) newval))
2910 (dst32-Rn-direct-operand Unprefixed 4 QI)
2911 (dst32-Rn-direct-operand Prefixed 12 QI)
2912 (dst32-Rn-direct-operand Unprefixed 4 HI)
2913 (dst32-Rn-direct-operand Prefixed 12 HI)
2914 (dst32-Rn-direct-operand Unprefixed 4 SI)
2915 (dst32-Rn-direct-operand Prefixed 12 SI)
2917 (define-pmacro (dst32-Rn-direct-Ext-operand group base1 base2 smode dmode)
2919 (define-derived-operand
2920 (name (.sym dst32-Rn-direct- group - smode))
2921 (comment (.str "m32c Rn direct destination " smode))
2922 (attrs (machine 32))
2924 (args ((.sym Dst32Rn group smode)))
2925 (syntax (.str "$Dst32Rn" group smode))
2926 (base-ifield (.sym f- base1 -6))
2927 (encoding (+ ((.sym f- base1 -3) 4) ((.sym f- base2 -1) 1) (.sym Dst32Rn group smode)))
2928 (ifield-assertion (andif (eq (.sym f- base1 -3) 4) (eq (.sym f- base2 -1) 1)))
2929 (getter (trunc smode (.sym Dst32Rn group smode)))
2930 (setter (set (.sym Dst32Rn group smode) newval))
2935 (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 QI HI)
2936 (dst32-Rn-direct-Ext-operand ExtUnprefixed 4 8 HI SI)
2938 (define-derived-operand
2939 (name dst32-R3-direct-Unprefixed-HI)
2940 (comment "m32c R3 direct HI")
2941 (attrs (machine 32))
2946 (encoding (+ (f-4-3 4) (f-8-2 #x1)))
2947 (ifield-assertion (andif (eq f-4-3 4) (eq f-8-2 #x1)))
2948 (getter (trunc HI R3))
2949 (setter (set R3 newval))
2951 ;-------------------------------------------------------------
2953 ;-------------------------------------------------------------
2955 (define-pmacro (dst16-An-direct-operand xmode)
2957 (define-derived-operand
2958 (name (.sym dst16-An-direct- xmode))
2959 (comment (.str "m16c An direct destination " xmode))
2960 (attrs (machine 16))
2962 (args ((.sym Dst16An xmode)))
2963 (syntax (.str "$Dst16An" xmode))
2964 (base-ifield f-12-4)
2965 (encoding (+ (f-12-2 1) (f-14-1 0) (.sym Dst16An xmode)))
2966 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0)))
2967 (getter (trunc xmode (.sym Dst16An xmode)))
2968 (setter (set (.sym Dst16An xmode) newval))
2973 (dst16-An-direct-operand QI)
2974 (dst16-An-direct-operand HI)
2975 (dst16-An-direct-operand SI)
2977 (define-pmacro (dst32-An-direct-operand group base1 base2 xmode)
2979 (define-derived-operand
2980 (name (.sym dst32-An-direct- group - xmode))
2981 (comment (.str "m32c An direct destination " xmode))
2982 (attrs (machine 32))
2984 (args ((.sym Dst32An group xmode)))
2985 (syntax (.str "$Dst32An" group xmode))
2986 (base-ifield (.sym f- base1 -6))
2987 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Dst32An group xmode)))
2988 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
2989 (getter (trunc xmode (.sym Dst32An group xmode)))
2990 (setter (set (.sym Dst32An group xmode) newval))
2995 (dst32-An-direct-operand Unprefixed 4 8 QI)
2996 (dst32-An-direct-operand Prefixed 12 16 QI)
2997 (dst32-An-direct-operand Unprefixed 4 8 HI)
2998 (dst32-An-direct-operand Prefixed 12 16 HI)
2999 (dst32-An-direct-operand Unprefixed 4 8 SI)
3000 (dst32-An-direct-operand Prefixed 12 16 SI)
3002 ;-------------------------------------------------------------
3004 ;-------------------------------------------------------------
3006 (define-pmacro (dst16-An-indirect-operand xmode)
3008 (define-derived-operand
3009 (name (.sym dst16-An-indirect- xmode))
3010 (comment (.str "m16c An indirect destination " xmode))
3011 (attrs (machine 16))
3014 (syntax "[$Dst16An]")
3015 (base-ifield f-12-4)
3016 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
3017 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
3018 (getter (mem16 xmode Dst16An))
3019 (setter (set (mem16 xmode Dst16An) newval))
3024 (dst16-An-indirect-operand QI)
3025 (dst16-An-indirect-operand HI)
3026 (dst16-An-indirect-operand SI)
3028 (define-derived-operand
3029 (name dst16-An-indirect-Ext-QI)
3030 (comment "m16c An indirect destination QI")
3031 (attrs (machine 16))
3034 (syntax "[$Dst16An]")
3035 (base-ifield f-12-4)
3036 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
3037 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
3038 (getter (mem16 QI Dst16An))
3039 (setter (set (mem16 HI Dst16An) newval))
3042 (define-pmacro (dst32-An-indirect-operand group base1 base2 smode dmode)
3044 (define-derived-operand
3045 (name (.sym dst32-An-indirect- group - smode))
3046 (comment (.str "m32c An indirect destination " smode))
3047 (attrs (machine 32))
3049 (args ((.sym Dst32An group)))
3050 (syntax (.str "[$Dst32An" group "]"))
3051 (base-ifield (.sym f- base1 -6))
3052 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Dst32An group)))
3053 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
3054 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group)
3056 (setter (c-call DFLT (.str "operand_setter_" dmode) newval
3057 (.sym Dst32An group) (const 0)))
3058 ; (getter (mem32 smode (.sym Dst32An group)))
3059 ; (setter (set (mem32 dmode (.sym Dst32An group)) newval))
3064 (dst32-An-indirect-operand Unprefixed 4 8 QI QI)
3065 (dst32-An-indirect-operand Prefixed 12 16 QI QI)
3066 (dst32-An-indirect-operand Unprefixed 4 8 HI HI)
3067 (dst32-An-indirect-operand Prefixed 12 16 HI HI)
3068 (dst32-An-indirect-operand Unprefixed 4 8 SI SI)
3069 (dst32-An-indirect-operand Prefixed 12 16 SI SI)
3070 (dst32-An-indirect-operand ExtUnprefixed 4 8 QI HI)
3071 (dst32-An-indirect-operand ExtUnprefixed 4 8 HI SI)
3073 ;-------------------------------------------------------------
3075 ;-------------------------------------------------------------
3077 (define-pmacro (dst16-relative-operand offset xmode)
3079 (define-derived-operand
3080 (name (.sym dst16- offset -8-SB-relative- xmode))
3081 (comment (.str "m16c dsp:8[sb] relative destination " xmode))
3082 (attrs (machine 16))
3084 (args ((.sym Dsp- offset -u8)))
3085 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3086 (base-ifield f-12-4)
3087 (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8)))
3088 (ifield-assertion (eq f-12-4 #xA))
3089 (getter (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb))))
3090 (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3092 (define-derived-operand
3093 (name (.sym dst16- offset -16-SB-relative- xmode))
3094 (comment (.str "m16c dsp:16[sb] relative destination " xmode))
3095 (attrs (machine 16))
3097 (args ((.sym Dsp- offset -u16)))
3098 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3099 (base-ifield f-12-4)
3100 (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16)))
3101 (ifield-assertion (eq f-12-4 #xE))
3102 (getter (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb))))
3103 (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3105 (define-derived-operand
3106 (name (.sym dst16- offset -8-FB-relative- xmode))
3107 (comment (.str "m16c dsp:8[fb] relative destination " xmode))
3108 (attrs (machine 16))
3110 (args ((.sym Dsp- offset -s8)))
3111 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3112 (base-ifield f-12-4)
3113 (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8)))
3114 (ifield-assertion (eq f-12-4 #xB))
3115 (getter (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb))))
3116 (setter (set (mem16 xmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3118 (define-derived-operand
3119 (name (.sym dst16- offset -8-An-relative- xmode))
3120 (comment (.str "m16c dsp:8[An] relative destination " xmode))
3121 (attrs (machine 16))
3123 (args (Dst16An (.sym Dsp- offset -u8)))
3124 (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]"))
3125 (base-ifield f-12-4)
3126 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An))
3127 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3128 (getter (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An)))
3129 (setter (set (mem16 xmode (add (.sym Dsp- offset -u8) Dst16An)) newval))
3131 (define-derived-operand
3132 (name (.sym dst16- offset -16-An-relative- xmode))
3133 (comment (.str "m16c dsp:16[An] relative destination " xmode))
3134 (attrs (machine 16))
3136 (args (Dst16An (.sym Dsp- offset -u16)))
3137 (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]"))
3138 (base-ifield f-12-4)
3139 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An))
3140 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3141 (getter (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An)))
3142 (setter (set (mem16 xmode (add (.sym Dsp- offset -u16) Dst16An)) newval))
3147 (dst16-relative-operand 16 QI)
3148 (dst16-relative-operand 24 QI)
3149 (dst16-relative-operand 32 QI)
3150 (dst16-relative-operand 40 QI)
3151 (dst16-relative-operand 48 QI)
3152 (dst16-relative-operand 16 HI)
3153 (dst16-relative-operand 24 HI)
3154 (dst16-relative-operand 32 HI)
3155 (dst16-relative-operand 40 HI)
3156 (dst16-relative-operand 48 HI)
3157 (dst16-relative-operand 16 SI)
3158 (dst16-relative-operand 24 SI)
3159 (dst16-relative-operand 32 SI)
3160 (dst16-relative-operand 40 SI)
3161 (dst16-relative-operand 48 SI)
3163 (define-pmacro (dst16-relative-Ext-operand offset smode dmode)
3165 (define-derived-operand
3166 (name (.sym dst16- offset -8-SB-relative-Ext- smode))
3167 (comment (.str "m16c dsp:8[sb] relative destination " smode))
3168 (attrs (machine 16))
3170 (args ((.sym Dsp- offset -u8)))
3171 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3172 (base-ifield f-12-4)
3173 (encoding (+ (f-12-4 #xA) (.sym Dsp- offset -u8)))
3174 (ifield-assertion (eq f-12-4 #xA))
3175 (getter (mem16 smode (add (.sym Dsp- offset -u8) (reg h-sb))))
3176 (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3178 (define-derived-operand
3179 (name (.sym dst16- offset -16-SB-relative-Ext- smode))
3180 (comment (.str "m16c dsp:16[sb] relative destination " smode))
3181 (attrs (machine 16))
3183 (args ((.sym Dsp- offset -u16)))
3184 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3185 (base-ifield f-12-4)
3186 (encoding (+ (f-12-4 #xE) (.sym Dsp- offset -u16)))
3187 (ifield-assertion (eq f-12-4 #xE))
3188 (getter (mem16 smode (add (.sym Dsp- offset -u16) (reg h-sb))))
3189 (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3191 (define-derived-operand
3192 (name (.sym dst16- offset -8-FB-relative-Ext- smode))
3193 (comment (.str "m16c dsp:8[fb] relative destination " smode))
3194 (attrs (machine 16))
3196 (args ((.sym Dsp- offset -s8)))
3197 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3198 (base-ifield f-12-4)
3199 (encoding (+ (f-12-4 #xB) (.sym Dsp- offset -s8)))
3200 (ifield-assertion (eq f-12-4 #xB))
3201 (getter (mem16 smode (add (.sym Dsp- offset -s8) (reg h-fb))))
3202 (setter (set (mem16 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3204 (define-derived-operand
3205 (name (.sym dst16- offset -8-An-relative-Ext- smode))
3206 (comment (.str "m16c dsp:8[An] relative destination " smode))
3207 (attrs (machine 16))
3209 (args (Dst16An (.sym Dsp- offset -u8)))
3210 (syntax (.str "${Dsp-" offset "-u8}[$Dst16An]"))
3211 (base-ifield f-12-4)
3212 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Dst16An))
3213 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3214 (getter (mem16 smode (add (.sym Dsp- offset -u8) Dst16An)))
3215 (setter (set (mem16 dmode (add (.sym Dsp- offset -u8) Dst16An)) newval))
3217 (define-derived-operand
3218 (name (.sym dst16- offset -16-An-relative-Ext- smode))
3219 (comment (.str "m16c dsp:16[An] relative destination " smode))
3220 (attrs (machine 16))
3222 (args (Dst16An (.sym Dsp- offset -u16)))
3223 (syntax (.str "${Dsp-" offset "-u16}[$Dst16An]"))
3224 (base-ifield f-12-4)
3225 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Dst16An))
3226 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3227 (getter (mem16 smode (add (.sym Dsp- offset -u16) Dst16An)))
3228 (setter (set (mem16 dmode (add (.sym Dsp- offset -u16) Dst16An)) newval))
3233 (dst16-relative-Ext-operand 16 QI HI)
3235 (define-pmacro (dst32-relative-operand offset group base1 base2 smode dmode)
3237 (define-derived-operand
3238 (name (.sym dst32- offset -8-SB-relative- group - smode))
3239 (comment (.str "m32c dsp:8[sb] relative destination " smode))
3240 (attrs (machine 32))
3242 (args ((.sym Dsp- offset -u8)))
3243 (syntax (.str "${Dsp-" offset "-u8}[sb]"))
3244 (base-ifield (.sym f- base1 -6))
3245 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u8)))
3246 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
3247 (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u8)))
3248 (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u8)))
3249 ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (reg h-sb))))
3250 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (reg h-sb))) newval))
3252 (define-derived-operand
3253 (name (.sym dst32- offset -16-SB-relative- group - smode))
3254 (comment (.str "m32c dsp:16[sb] relative destination " smode))
3255 (attrs (machine 32))
3257 (args ((.sym Dsp- offset -u16)))
3258 (syntax (.str "${Dsp-" offset "-u16}[sb]"))
3259 (base-ifield (.sym f- base1 -6))
3260 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u16)))
3261 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
3262 (getter (c-call dmode (.str "operand_getter_" dmode) sb (.sym Dsp- offset -u16)))
3263 (setter (c-call DFLT (.str "operand_setter_" dmode) newval sb (.sym Dsp- offset -u16)))
3264 ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (reg h-sb))))
3265 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (reg h-sb))) newval))
3267 (define-derived-operand
3268 (name (.sym dst32- offset -8-FB-relative- group - smode))
3269 (comment (.str "m32c dsp:8[fb] relative destination " smode))
3270 (attrs (machine 32))
3272 (args ((.sym Dsp- offset -s8)))
3273 (syntax (.str "${Dsp-" offset "-s8}[fb]"))
3274 (base-ifield (.sym f- base1 -6))
3275 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s8)))
3276 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
3277 (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s8)))
3278 (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s8)))
3279 ; (getter (mem32 smode (add (.sym Dsp- offset -s8) (reg h-fb))))
3280 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s8) (reg h-fb))) newval))
3282 (define-derived-operand
3283 (name (.sym dst32- offset -16-FB-relative- group - smode))
3284 (comment (.str "m32c dsp:16[fb] relative destination " smode))
3285 (attrs (machine 32))
3287 (args ((.sym Dsp- offset -s16)))
3288 (syntax (.str "${Dsp-" offset "-s16}[fb]"))
3289 (base-ifield (.sym f- base1 -6))
3290 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym Dsp- offset -s16)))
3291 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
3292 (getter (c-call dmode (.str "operand_getter_" dmode) fb (.sym Dsp- offset -s16)))
3293 (setter (c-call DFLT (.str "operand_setter_" dmode) newval fb (.sym Dsp- offset -s16)))
3294 ; (getter (mem32 smode (add (.sym Dsp- offset -s16) (reg h-fb))))
3295 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -s16) (reg h-fb))) newval))
3297 (define-derived-operand
3298 (name (.sym dst32- offset -8-An-relative- group - smode))
3299 (comment (.str "m32c dsp:8[An] relative destination " smode))
3300 (attrs (machine 32))
3302 (args ((.sym Dst32An group) (.sym Dsp- offset -u8)))
3303 (syntax (.str "${Dsp-" offset "-u8}[$Dst32An" group "]"))
3304 (base-ifield (.sym f- base1 -6))
3305 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u8) (.sym Dst32An group)))
3306 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
3307 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u8)))
3308 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u8)))
3309 ; (getter (mem32 smode (add (.sym Dsp- offset -u8) (.sym Dst32An group))))
3310 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u8) (.sym Dst32An group))) newval))
3312 (define-derived-operand
3313 (name (.sym dst32- offset -16-An-relative- group - smode))
3314 (comment (.str "m32c dsp:16[An] relative destination " smode))
3315 (attrs (machine 32))
3317 (args ((.sym Dst32An group) (.sym Dsp- offset -u16)))
3318 (syntax (.str "${Dsp-" offset "-u16}[$Dst32An" group "]"))
3319 (base-ifield (.sym f- base1 -6))
3320 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u16) (.sym Dst32An group)))
3321 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
3322 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u16)))
3323 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u16)))
3324 ; (getter (mem32 smode (add (.sym Dsp- offset -u16) (.sym Dst32An group))))
3325 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u16) (.sym Dst32An group))) newval))
3327 (define-derived-operand
3328 (name (.sym dst32- offset -24-An-relative- group - smode))
3329 (comment (.str "m32c dsp:16[An] relative destination " smode))
3330 (attrs (machine 32))
3332 (args ((.sym Dst32An group) (.sym Dsp- offset -u24)))
3333 (syntax (.str "${Dsp-" offset "-u24}[$Dst32An" group "]"))
3334 (base-ifield (.sym f- base1 -6))
3335 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym Dsp- offset -u24) (.sym Dst32An group)))
3336 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
3337 (getter (c-call dmode (.str "operand_getter_" dmode) (.sym Dst32An group) (.sym Dsp- offset -u24)))
3338 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (.sym Dst32An group) (.sym Dsp- offset -u24)))
3339 ; (getter (mem32 smode (add (.sym Dsp- offset -u24) (.sym Dst32An group))))
3340 ; (setter (set (mem32 dmode (add (.sym Dsp- offset -u24) (.sym Dst32An group))) newval))
3345 (dst32-relative-operand 16 Unprefixed 4 8 QI QI)
3346 (dst32-relative-operand 24 Unprefixed 4 8 QI QI)
3347 (dst32-relative-operand 32 Unprefixed 4 8 QI QI)
3348 (dst32-relative-operand 40 Unprefixed 4 8 QI QI)
3349 (dst32-relative-operand 16 Unprefixed 4 8 HI HI)
3350 (dst32-relative-operand 24 Unprefixed 4 8 HI HI)
3351 (dst32-relative-operand 32 Unprefixed 4 8 HI HI)
3352 (dst32-relative-operand 40 Unprefixed 4 8 HI HI)
3353 (dst32-relative-operand 16 Unprefixed 4 8 SI SI)
3354 (dst32-relative-operand 24 Unprefixed 4 8 SI SI)
3355 (dst32-relative-operand 32 Unprefixed 4 8 SI SI)
3356 (dst32-relative-operand 40 Unprefixed 4 8 SI SI)
3358 (dst32-relative-operand 24 Prefixed 12 16 QI QI)
3359 (dst32-relative-operand 32 Prefixed 12 16 QI QI)
3360 (dst32-relative-operand 40 Prefixed 12 16 QI QI)
3361 (dst32-relative-operand 48 Prefixed 12 16 QI QI)
3362 (dst32-relative-operand 24 Prefixed 12 16 HI HI)
3363 (dst32-relative-operand 32 Prefixed 12 16 HI HI)
3364 (dst32-relative-operand 40 Prefixed 12 16 HI HI)
3365 (dst32-relative-operand 48 Prefixed 12 16 HI HI)
3366 (dst32-relative-operand 24 Prefixed 12 16 SI SI)
3367 (dst32-relative-operand 32 Prefixed 12 16 SI SI)
3368 (dst32-relative-operand 40 Prefixed 12 16 SI SI)
3369 (dst32-relative-operand 48 Prefixed 12 16 SI SI)
3371 (dst32-relative-operand 16 ExtUnprefixed 4 8 QI HI)
3372 (dst32-relative-operand 16 ExtUnprefixed 4 8 HI SI)
3374 ;-------------------------------------------------------------
3376 ;-------------------------------------------------------------
3378 (define-pmacro (dst16-absolute offset xmode)
3380 (define-derived-operand
3381 (name (.sym dst16- offset -16-absolute- xmode))
3382 (comment (.str "m16c absolute address " xmode))
3383 (attrs (machine 16))
3385 (args ((.sym Dsp- offset -u16)))
3386 (syntax (.str "${Dsp-" offset "-u16}"))
3387 (base-ifield f-12-4)
3388 (encoding (+ (f-12-4 #xF) (.sym Dsp- offset -u16)))
3389 (ifield-assertion (eq f-12-4 #xF))
3390 (getter (mem16 xmode (.sym Dsp- offset -u16)))
3391 (setter (set (mem16 xmode (.sym Dsp- offset -u16)) newval))
3396 (dst16-absolute 16 QI)
3397 (dst16-absolute 24 QI)
3398 (dst16-absolute 32 QI)
3399 (dst16-absolute 40 QI)
3400 (dst16-absolute 48 QI)
3401 (dst16-absolute 16 HI)
3402 (dst16-absolute 24 HI)
3403 (dst16-absolute 32 HI)
3404 (dst16-absolute 40 HI)
3405 (dst16-absolute 48 HI)
3406 (dst16-absolute 16 SI)
3407 (dst16-absolute 24 SI)
3408 (dst16-absolute 32 SI)
3409 (dst16-absolute 40 SI)
3410 (dst16-absolute 48 SI)
3412 (define-derived-operand
3413 (name dst16-16-16-absolute-Ext-QI)
3414 (comment "m16c absolute address QI")
3415 (attrs (machine 16))
3418 (syntax "${Dsp-16-u16}")
3419 (base-ifield f-12-4)
3420 (encoding (+ (f-12-4 #xF) Dsp-16-u16))
3421 (ifield-assertion (eq f-12-4 #xF))
3422 (getter (mem16 QI Dsp-16-u16))
3423 (setter (set (mem16 HI Dsp-16-u16) newval))
3426 (define-pmacro (dst32-absolute offset group base1 base2 smode dmode)
3428 (define-derived-operand
3429 (name (.sym dst32- offset -16-absolute- group - smode))
3430 (comment (.str "m32c absolute address " smode))
3431 (attrs (machine 32))
3433 (args ((.sym Dsp- offset -u16)))
3434 (syntax (.str "${Dsp-" offset "-u16}"))
3435 (base-ifield (.sym f- base1 -6))
3436 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym Dsp- offset -u16)))
3437 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
3438 (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u16)))
3439 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u16)))
3440 ; (getter (mem32 smode (.sym Dsp- offset -u16)))
3441 ; (setter (set (mem32 dmode (.sym Dsp- offset -u16)) newval))
3443 (define-derived-operand
3444 (name (.sym dst32- offset -24-absolute- group - smode))
3445 (comment (.str "m32c absolute address " smode))
3446 (attrs (machine 32))
3448 (args ((.sym Dsp- offset -u24)))
3449 (syntax (.str "${Dsp-" offset "-u24}"))
3450 (base-ifield (.sym f- base1 -6))
3451 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym Dsp- offset -u24)))
3452 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
3453 (getter (c-call smode (.str "operand_getter_" smode) (const 0) (.sym Dsp- offset -u24)))
3454 (setter (c-call DFLT (.str "operand_setter_" dmode) newval (const 0) (.sym Dsp- offset -u24)))
3455 ; (getter (mem32 smode (.sym Dsp- offset -u24)))
3456 ; (setter (set (mem32 dmode (.sym Dsp- offset -u24)) newval))
3461 (dst32-absolute 16 Unprefixed 4 8 QI QI)
3462 (dst32-absolute 24 Unprefixed 4 8 QI QI)
3463 (dst32-absolute 32 Unprefixed 4 8 QI QI)
3464 (dst32-absolute 40 Unprefixed 4 8 QI QI)
3465 (dst32-absolute 16 Unprefixed 4 8 HI HI)
3466 (dst32-absolute 24 Unprefixed 4 8 HI HI)
3467 (dst32-absolute 32 Unprefixed 4 8 HI HI)
3468 (dst32-absolute 40 Unprefixed 4 8 HI HI)
3469 (dst32-absolute 16 Unprefixed 4 8 SI SI)
3470 (dst32-absolute 24 Unprefixed 4 8 SI SI)
3471 (dst32-absolute 32 Unprefixed 4 8 SI SI)
3472 (dst32-absolute 40 Unprefixed 4 8 SI SI)
3474 (dst32-absolute 24 Prefixed 12 16 QI QI)
3475 (dst32-absolute 32 Prefixed 12 16 QI QI)
3476 (dst32-absolute 40 Prefixed 12 16 QI QI)
3477 (dst32-absolute 48 Prefixed 12 16 QI QI)
3478 (dst32-absolute 24 Prefixed 12 16 HI HI)
3479 (dst32-absolute 32 Prefixed 12 16 HI HI)
3480 (dst32-absolute 40 Prefixed 12 16 HI HI)
3481 (dst32-absolute 48 Prefixed 12 16 HI HI)
3482 (dst32-absolute 24 Prefixed 12 16 SI SI)
3483 (dst32-absolute 32 Prefixed 12 16 SI SI)
3484 (dst32-absolute 40 Prefixed 12 16 SI SI)
3485 (dst32-absolute 48 Prefixed 12 16 SI SI)
3487 (dst32-absolute 16 ExtUnprefixed 4 8 QI HI)
3488 (dst32-absolute 16 ExtUnprefixed 4 8 HI SI)
3490 ;-------------------------------------------------------------
3491 ; An indirect indirect
3492 ;-------------------------------------------------------------
3494 ;(define-pmacro (dst-An-indirect-indirect-operand xmode)
3495 ; (define-derived-operand
3496 ; (name (.sym dst32-An-indirect-indirect- xmode))
3497 ; (comment (.str "m32c An indirect indirect destination " xmode))
3498 ; (attrs (machine 32))
3500 ; (args (Dst32AnPrefixed))
3501 ; (syntax (.str "[[$Dst32AnPrefixed]]"))
3502 ; (base-ifield f-12-6)
3503 ; (encoding (+ (f-12-3 0) (f-16-1 0) Dst32AnPrefixed))
3504 ; (ifield-assertion (andif (eq f-12-3 0) (eq f-16-1 0)))
3505 ; (getter (mem32 xmode (indirect-addr Dst32AnPrefixed)))
3506 ; (setter (set (mem32 xmode (indirect-addr Dst32AnPrefixed)) newval))
3510 ; (dst-An-indirect-indirect-operand QI)
3511 ; (dst-An-indirect-indirect-operand HI)
3512 ; (dst-An-indirect-indirect-operand SI)
3514 ;-------------------------------------------------------------
3516 ;-------------------------------------------------------------
3518 (define-pmacro (dst-relative-indirect-operand offset xmode)
3520 ; (define-derived-operand
3521 ; (name (.sym dst32- offset -8-SB-relative-indirect- xmode))
3522 ; (comment (.str "m32c dsp:8[sb] relative destination " xmode))
3523 ; (attrs (machine 32))
3525 ; (args ((.sym Dsp- offset -u8)))
3526 ; (syntax (.str "[${Dsp-" offset "-u8}[sb]]"))
3527 ; (base-ifield f-12-6)
3528 ; (encoding (+ (f-12-3 1) (f-16-2 2) (.sym Dsp- offset -u8)))
3529 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 2)))
3530 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb)))))
3531 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) (reg h-sb)))) newval))
3533 ; (define-derived-operand
3534 ; (name (.sym dst32- offset -16-SB-relative-indirect- xmode))
3535 ; (comment (.str "m32c dsp:16[sb] relative destination " xmode))
3536 ; (attrs (machine 32))
3538 ; (args ((.sym Dsp- offset -u16)))
3539 ; (syntax (.str "[${Dsp-" offset "-u16}[sb]]"))
3540 ; (base-ifield f-12-6)
3541 ; (encoding (+ (f-12-3 2) (f-16-2 2) (.sym Dsp- offset -u16)))
3542 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 2)))
3543 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb)))))
3544 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) (reg h-sb)))) newval))
3546 ; (define-derived-operand
3547 ; (name (.sym dst32- offset -8-FB-relative-indirect- xmode))
3548 ; (comment (.str "m32c dsp:8[fb] relative destination " xmode))
3549 ; (attrs (machine 32))
3551 ; (args ((.sym Dsp- offset -s8)))
3552 ; (syntax (.str "[${Dsp-" offset "-s8}[fb]]"))
3553 ; (base-ifield f-12-6)
3554 ; (encoding (+ (f-12-3 1) (f-16-2 3) (.sym Dsp- offset -s8)))
3555 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-2 3)))
3556 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb)))))
3557 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s8) (reg h-fb)))) newval))
3559 ; (define-derived-operand
3560 ; (name (.sym dst32- offset -16-FB-relative-indirect- xmode))
3561 ; (comment (.str "m32c dsp:16[fb] relative destination " xmode))
3562 ; (attrs (machine 32))
3564 ; (args ((.sym Dsp- offset -s16)))
3565 ; (syntax (.str "[${Dsp-" offset "-s16}[fb]]"))
3566 ; (base-ifield f-12-6)
3567 ; (encoding (+ (f-12-3 2) (f-16-2 3) (.sym Dsp- offset -s16)))
3568 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-2 3)))
3569 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb)))))
3570 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -s16) (reg h-fb)))) newval))
3572 ; (define-derived-operand
3573 ; (name (.sym dst32- offset -8-An-relative-indirect- xmode))
3574 ; (comment (.str "m32c dsp:8[An] relative indirect destination " xmode))
3575 ; (attrs (machine 32))
3577 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u8)))
3578 ; (syntax (.str "[${Dsp-" offset "-u8}[$Dst32AnPrefixed]]"))
3579 ; (base-ifield f-12-6)
3580 ; (encoding (+ (f-12-3 1) (f-16-1 0) (.sym Dsp- offset -u8) Dst32AnPrefixed))
3581 ; (ifield-assertion (andif (eq f-12-3 1) (eq f-16-1 0)))
3582 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed))))
3583 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u8) Dst32AnPrefixed))) newval))
3585 ; (define-derived-operand
3586 ; (name (.sym dst32- offset -16-An-relative-indirect- xmode))
3587 ; (comment (.str "m32c dsp:16[An] relative destination " xmode))
3588 ; (attrs (machine 32))
3590 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u16)))
3591 ; (syntax (.str "[${Dsp-" offset "-u16}[$Dst32AnPrefixed]]"))
3592 ; (base-ifield f-12-6)
3593 ; (encoding (+ (f-12-3 2) (f-16-1 0) (.sym Dsp- offset -u16) Dst32AnPrefixed))
3594 ; (ifield-assertion (andif (eq f-12-3 2) (eq f-16-1 0)))
3595 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed))))
3596 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u16) Dst32AnPrefixed))) newval))
3598 ; (define-derived-operand
3599 ; (name (.sym dst32- offset -24-An-relative-indirect- xmode))
3600 ; (comment (.str "m32c dsp:24[An] relative destination " xmode))
3601 ; (attrs (machine 32))
3603 ; (args (Dst32AnPrefixed (.sym Dsp- offset -u24)))
3604 ; (syntax (.str "[${Dsp-" offset "-u24}[$Dst32AnPrefixed]]"))
3605 ; (base-ifield f-12-6)
3606 ; (encoding (+ (f-12-3 3) (f-16-1 0) (.sym Dsp- offset -u24) Dst32AnPrefixed))
3607 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-1 0)))
3608 ; (getter (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed))))
3609 ; (setter (set (mem32 xmode (indirect-addr (add (.sym Dsp- offset -u24) Dst32AnPrefixed))) newval))
3614 ; (dst-relative-indirect-operand 24 QI)
3615 ; (dst-relative-indirect-operand 32 QI)
3616 ; (dst-relative-indirect-operand 40 QI)
3617 ; (dst-relative-indirect-operand 48 QI)
3618 ; (dst-relative-indirect-operand 24 HI)
3619 ; (dst-relative-indirect-operand 32 HI)
3620 ; (dst-relative-indirect-operand 40 HI)
3621 ; (dst-relative-indirect-operand 48 HI)
3622 ; (dst-relative-indirect-operand 24 SI)
3623 ; (dst-relative-indirect-operand 32 SI)
3624 ; (dst-relative-indirect-operand 40 SI)
3625 ; (dst-relative-indirect-operand 48 SI)
3627 ;-------------------------------------------------------------
3629 ;-------------------------------------------------------------
3631 (define-pmacro (dst-absolute-indirect offset xmode)
3633 ; (define-derived-operand
3634 ; (name (.sym dst32- offset -16-absolute-indirect-derived- xmode))
3635 ; (comment (.str "m32c absolute indirect address " xmode))
3636 ; (attrs (machine 32))
3638 ; (args ((.sym Dsp- offset -u16)))
3639 ; (syntax (.str "[${Dsp-" offset "-u16}]"))
3640 ; (base-ifield f-12-6)
3641 ; (encoding (+ (f-12-3 3) (f-16-2 3) (.sym Dsp- offset -u16)))
3642 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 3)))
3643 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))))
3644 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u16))) newval))
3646 ; (define-derived-operand
3647 ; (name (.sym dst32- offset -24-absolute-indirect-derived- xmode))
3648 ; (comment (.str "m32c absolute indirect address " xmode))
3649 ; (attrs (machine 32))
3651 ; (args ((.sym Dsp- offset -u24)))
3652 ; (syntax (.str "[${Dsp-" offset "-u24}]"))
3653 ; (base-ifield f-12-6)
3654 ; (encoding (+ (f-12-3 3) (f-16-2 2) (.sym Dsp- offset -u24)))
3655 ; (ifield-assertion (andif (eq f-12-3 3) (eq f-16-2 2)))
3656 ; (getter (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))))
3657 ; (setter (set (mem32 xmode (indirect-addr (.sym Dsp- offset -u24))) newval))
3662 (dst-absolute-indirect 24 QI)
3663 (dst-absolute-indirect 32 QI)
3664 (dst-absolute-indirect 40 QI)
3665 (dst-absolute-indirect 48 QI)
3666 (dst-absolute-indirect 24 HI)
3667 (dst-absolute-indirect 32 HI)
3668 (dst-absolute-indirect 40 HI)
3669 (dst-absolute-indirect 48 HI)
3670 (dst-absolute-indirect 24 SI)
3671 (dst-absolute-indirect 32 SI)
3672 (dst-absolute-indirect 40 SI)
3673 (dst-absolute-indirect 48 SI)
3675 ;-------------------------------------------------------------
3677 ;-------------------------------------------------------------
3678 (define-pmacro (get-register-bit reg bitno)
3679 (and (srl reg bitno) 1)
3682 (define-pmacro (set-register-bit reg bitno value)
3683 (set reg (or (and reg (inv (sll 1 bitno)))
3684 (sll (and QI value 1) bitno)))
3687 (define-pmacro (get-memory-bit mach base bitno)
3688 (and (srl (mem-mach mach QI (add base (div bitno 8)))
3693 (define-pmacro (set-memory-bit mach base bitno value)
3694 (sequence ((USI addr))
3695 (set addr (add base (div bitno 8)))
3696 (set (mem-mach mach QI addr)
3697 (or (and (mem-mach mach QI addr)
3698 (inv (sll 1 (mod bitno 8))))
3699 (sll (and QI value 1) (mod bitno 8)))))
3702 ;-------------------------------------------------------------
3704 ;-------------------------------------------------------------
3706 (define-derived-operand
3707 (name bit16-Rn-direct)
3708 (comment "m16c Rn direct bit")
3709 (attrs (machine 16))
3711 (args (Bitno16R Bit16Rn))
3712 (syntax "$Bitno16R,$Bit16Rn")
3713 (base-ifield f-12-4)
3714 (encoding (+ (f-12-2 0) Bit16Rn Bitno16R))
3715 (ifield-assertion (eq f-12-2 0))
3716 (getter (get-register-bit Bit16Rn Bitno16R))
3717 (setter (set-register-bit Bit16Rn Bitno16R newval))
3720 (define-pmacro (bit32-Rn-direct-operand group base)
3722 (define-derived-operand
3723 (name (.sym bit32-Rn-direct- group))
3724 (comment "m32c Rn direct bit")
3725 (attrs (machine 32))
3727 (args ((.sym Bitno32 group) (.sym Bit32Rn group)))
3728 (syntax (.str "$Bitno32" group ",$Bit32Rn" group))
3729 (base-ifield (.sym f- base -6))
3730 (encoding (+ ((.sym f- base -3) 4) (.sym Bit32Rn group) (.sym Bitno32 group)))
3731 (ifield-assertion (eq (.sym f- base -3) 4))
3732 (getter (get-register-bit (.sym Bit32Rn group) (.sym Bitno32 group)))
3733 (setter (set-register-bit (.sym Bit32Rn group) (.sym Bitno32 group) newval))
3738 (bit32-Rn-direct-operand Unprefixed 4)
3739 (bit32-Rn-direct-operand Prefixed 12)
3741 ;-------------------------------------------------------------
3743 ;-------------------------------------------------------------
3745 (define-derived-operand
3746 (name bit16-An-direct)
3747 (comment "m16c An direct bit")
3748 (attrs (machine 16))
3750 (args (Bitno16R Bit16An))
3751 (syntax "$Bitno16R,$Bit16An")
3752 (base-ifield f-12-4)
3753 (encoding (+ (f-12-2 1) (f-14-1 0) Bit16An Bitno16R))
3754 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 0)))
3755 (getter (get-register-bit Bit16An Bitno16R))
3756 (setter (set-register-bit Bit16An Bitno16R newval))
3759 (define-pmacro (bit32-An-direct-operand group base1 base2)
3761 (define-derived-operand
3762 (name (.sym bit32-An-direct- group))
3763 (comment "m32c An direct bit")
3764 (attrs (machine 32))
3766 (args ((.sym Bitno32 group) (.sym Bit32An group)))
3767 (syntax (.str "$Bitno32" group ",$Bit32An" group))
3768 (base-ifield (.sym f- base1 -6))
3769 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 1) (.sym Bit32An group) (.sym Bitno32 group)))
3770 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 1)))
3771 (getter (get-register-bit (.sym Bit32An group) (.sym Bitno32 group)))
3772 (setter (set-register-bit (.sym Bit32An group) (.sym Bitno32 group) newval))
3777 (bit32-An-direct-operand Unprefixed 4 8)
3778 (bit32-An-direct-operand Prefixed 12 16)
3780 ;-------------------------------------------------------------
3782 ;-------------------------------------------------------------
3784 (define-derived-operand
3785 (name bit16-An-indirect)
3786 (comment "m16c An indirect bit")
3787 (attrs (machine 16))
3790 (syntax "[$Bit16An]")
3791 (base-ifield f-12-4)
3792 (encoding (+ (f-12-2 1) (f-14-1 1) Bit16An))
3793 (ifield-assertion (andif (eq f-12-2 1) (eq f-14-1 1)))
3794 (getter (get-memory-bit 16 0 Bit16An))
3795 (setter (set-memory-bit 16 0 Bit16An newval))
3798 (define-pmacro (bit32-An-indirect-operand group base1 base2)
3800 (define-derived-operand
3801 (name (.sym bit32-An-indirect- group))
3802 (comment "m32c An indirect destination ")
3803 (attrs (machine 32))
3805 (args ((.sym Bitno32 group) (.sym Bit32An group)))
3806 (syntax (.str "$Bitno32" group ",[$Bit32An" group "]"))
3807 (base-ifield (.sym f- base1 -6))
3808 (encoding (+ ((.sym f- base1 -3) 0) ((.sym f- base2 -1) 0) (.sym Bit32An group) (.sym Bitno32 group)))
3809 (ifield-assertion (andif (eq (.sym f- base1 -3) 0) (eq (.sym f- base2 -1) 0)))
3810 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group)))
3811 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym Bitno32 group) newval))
3816 (bit32-An-indirect-operand Unprefixed 4 8)
3817 (bit32-An-indirect-operand Prefixed 12 16)
3819 ;-------------------------------------------------------------
3821 ;-------------------------------------------------------------
3823 (define-pmacro (bit16-relative-operand offset)
3825 (define-derived-operand
3826 (name (.sym bit16- offset -8-SB-relative))
3827 (comment (.str "m16c dsp:8[sb] relative bit " xmode))
3828 (attrs (machine 16))
3830 (args ((.sym BitBase16- offset -u8)))
3831 (syntax (.str "${BitBase16-" offset "-u8}[sb]"))
3832 (base-ifield f-12-4)
3833 (encoding (+ (f-12-4 #xA) (.sym BitBase16- offset -u8)))
3834 (ifield-assertion (eq f-12-4 #xA))
3835 (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8)))
3836 (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u8) newval))
3838 (define-derived-operand
3839 (name (.sym bit16- offset -16-SB-relative))
3840 (comment (.str "m16c dsp:16[sb] relative bit " xmode))
3841 (attrs (machine 16))
3843 (args ((.sym BitBase16- offset -u16)))
3844 (syntax (.str "${BitBase16-" offset "-u16}[sb]"))
3845 (base-ifield f-12-4)
3846 (encoding (+ (f-12-4 #xE) (.sym BitBase16- offset -u16)))
3847 (ifield-assertion (eq f-12-4 #xE))
3848 (getter (get-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16)))
3849 (setter (set-memory-bit 16 (reg h-sb) (.sym BitBase16- offset -u16) newval))
3851 (define-derived-operand
3852 (name (.sym bit16- offset -8-FB-relative))
3853 (comment (.str "m16c dsp:8[fb] relative bit " xmode))
3854 (attrs (machine 16))
3856 (args ((.sym BitBase16- offset -s8)))
3857 (syntax (.str "${BitBase16-" offset "-s8}[fb]"))
3858 (base-ifield f-12-4)
3859 (encoding (+ (f-12-4 #xB) (.sym BitBase16- offset -s8)))
3860 (ifield-assertion (eq f-12-4 #xB))
3861 (getter (get-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8)))
3862 (setter (set-memory-bit 16 (reg h-fb) (.sym BitBase16- offset -s8) newval))
3864 (define-derived-operand
3865 (name (.sym bit16- offset -8-An-relative))
3866 (comment (.str "m16c dsp:8[An] relative bit " xmode))
3867 (attrs (machine 16))
3869 (args (Bit16An (.sym Dsp- offset -u8)))
3870 (syntax (.str "${Dsp-" offset "-u8}[$Bit16An]"))
3871 (base-ifield f-12-4)
3872 (encoding (+ (f-12-2 2) (f-14-1 0) (.sym Dsp- offset -u8) Bit16An))
3873 (ifield-assertion (andif (eq f-12-2 2) (eq f-14-1 0)))
3874 (getter (get-memory-bit 16 (.sym Dsp- offset -u8) Bit16An))
3875 (setter (set-memory-bit 16 (.sym Dsp- offset -u8) Bit16An newval))
3877 (define-derived-operand
3878 (name (.sym bit16- offset -16-An-relative))
3879 (comment (.str "m16c dsp:16[An] relative bit " xmode))
3880 (attrs (machine 16))
3882 (args (Bit16An (.sym Dsp- offset -u16)))
3883 (syntax (.str "${Dsp-" offset "-u16}[$Bit16An]"))
3884 (base-ifield f-12-4)
3885 (encoding (+ (f-12-2 3) (f-14-1 0) (.sym Dsp- offset -u16) Bit16An))
3886 (ifield-assertion (andif (eq f-12-2 3) (eq f-14-1 0)))
3887 (getter (get-memory-bit 16 (.sym Dsp- offset -u16) Bit16An))
3888 (setter (set-memory-bit 16 (.sym Dsp- offset -u16) Bit16An newval))
3893 (bit16-relative-operand 16)
3895 (define-pmacro (bit32-relative-operand offset group base1 base2)
3897 (define-derived-operand
3898 (name (.sym bit32- offset -11-SB-relative- group))
3899 (comment "m32c bit,base:11[sb] relative bit")
3900 (attrs (machine 32))
3902 (args ((.sym BitBase32- offset -u11- group)))
3903 (syntax (.str "${BitBase32-" offset "-u11-" group "}[sb]"))
3904 (base-ifield (.sym f- base1 -12))
3905 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u11- group)))
3906 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 2)))
3907 (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group)))
3908 (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u11- group) newval))
3910 (define-derived-operand
3911 (name (.sym bit32- offset -19-SB-relative- group))
3912 (comment "m32c bit,base:19[sb] relative bit")
3913 (attrs (machine 32))
3915 (args ((.sym BitBase32- offset -u19- group)))
3916 (syntax (.str "${BitBase32-" offset "-u19-" group "}[sb]"))
3917 (base-ifield (.sym f- base1 -12))
3918 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u19- group)))
3919 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 2)))
3920 (getter (get-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group)))
3921 (setter (set-memory-bit 32 (reg h-sb) (.sym BitBase32- offset -u19- group) newval))
3923 (define-derived-operand
3924 (name (.sym bit32- offset -11-FB-relative- group))
3925 (comment "m32c bit,base:11[fb] relative bit")
3926 (attrs (machine 32))
3928 (args ((.sym BitBase32- offset -s11- group)))
3929 (syntax (.str "${BitBase32-" offset "-s11-" group "}[fb]"))
3930 (base-ifield (.sym f- base1 -12))
3931 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s11- group)))
3932 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -2) 3)))
3933 (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group)))
3934 (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s11- group) newval))
3936 (define-derived-operand
3937 (name (.sym bit32- offset -19-FB-relative- group))
3938 (comment "m32c bit,base:19[fb] relative bit")
3939 (attrs (machine 32))
3941 (args ((.sym BitBase32- offset -s19- group)))
3942 (syntax (.str "${BitBase32-" offset "-s19-" group "}[fb]"))
3943 (base-ifield (.sym f- base1 -12))
3944 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -s19- group)))
3945 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -2) 3)))
3946 (getter (get-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group)))
3947 (setter (set-memory-bit 32 (reg h-fb) (.sym BitBase32- offset -s19- group) newval))
3949 (define-derived-operand
3950 (name (.sym bit32- offset -11-An-relative- group))
3951 (comment "m32c bit,base:11[An] relative bit")
3952 (attrs (machine 32))
3954 (args ((.sym BitBase32- offset -u11- group) (.sym Bit32An group)))
3955 (syntax (.str "${BitBase32-" offset "-u11-" group "}[$Bit32An" group "]"))
3956 (base-ifield (.sym f- base1 -12))
3957 (encoding (+ ((.sym f- base1 -3) 1) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u11- group) (.sym Bit32An group)))
3958 (ifield-assertion (andif (eq (.sym f- base1 -3) 1) (eq (.sym f- base2 -1) 0)))
3959 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group)))
3960 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u11- group) newval))
3962 (define-derived-operand
3963 (name (.sym bit32- offset -19-An-relative- group))
3964 (comment "m32c bit,base:19[An] relative bit")
3965 (attrs (machine 32))
3967 (args ((.sym BitBase32- offset -u19- group) (.sym Bit32An group)))
3968 (syntax (.str "${BitBase32-" offset "-u19-" group "}[$Bit32An" group "]"))
3969 (base-ifield (.sym f- base1 -12))
3970 (encoding (+ ((.sym f- base1 -3) 2) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u19- group) (.sym Bit32An group)))
3971 (ifield-assertion (andif (eq (.sym f- base1 -3) 2) (eq (.sym f- base2 -1) 0)))
3972 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group)))
3973 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u19- group) newval))
3975 (define-derived-operand
3976 (name (.sym bit32- offset -27-An-relative- group))
3977 (comment "m32c bit,base:27[An] relative bit")
3978 (attrs (machine 32))
3980 (args ((.sym BitBase32- offset -u27- group) (.sym Bit32An group)))
3981 (syntax (.str "${BitBase32-" offset "-u27-" group "}[$Bit32An" group "]"))
3982 (base-ifield (.sym f- base1 -12))
3983 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -1) 0) (.sym BitBase32- offset -u27- group) (.sym Bit32An group)))
3984 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -1) 0)))
3985 (getter (get-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group)))
3986 (setter (set-memory-bit 32 (.sym Bit32An group) (.sym BitBase32- offset -u27- group) newval))
3991 (bit32-relative-operand 16 Unprefixed 4 8)
3992 (bit32-relative-operand 24 Prefixed 12 16)
3994 (define-derived-operand
3995 (name bit16-11-SB-relative-S)
3996 (comment "m16c bit,base:11[sb] relative bit")
3997 (attrs (machine 16))
3999 (args (BitBase16-8-u11-S))
4000 (syntax "${BitBase16-8-u11-S}[sb]")
4001 (base-ifield (.sym f-5-3))
4002 (encoding (+ BitBase16-8-u11-S))
4003 ; (ifield-assertion (#t))
4004 (getter (get-memory-bit 16 (reg h-sb) BitBase16-8-u11-S))
4005 (setter (set-memory-bit 16 (reg h-sb) BitBase16-8-u11-S newval))
4008 (define-derived-operand
4009 (name Rn16-push-S-derived)
4010 (comment "m16c r0[lh] for push,pop short version")
4011 (attrs (machine 16))
4013 (args (Rn16-push-S))
4014 (syntax "${Rn16-push-S}")
4015 (base-ifield (.sym f-4-1))
4016 (encoding (+ Rn16-push-S))
4017 ; (ifield-assertion (#t))
4018 (getter (trunc QI Rn16-push-S))
4019 (setter (set Rn16-push-S newval))
4022 (define-derived-operand
4023 (name An16-push-S-derived)
4024 (comment "m16c r0[lh] for push,pop short version")
4025 (attrs (machine 16))
4027 (args (An16-push-S))
4028 (syntax "${An16-push-S}")
4029 (base-ifield (.sym f-4-1))
4030 (encoding (+ An16-push-S))
4031 ; (ifield-assertion (#t))
4032 (getter (trunc QI An16-push-S))
4033 (setter (set An16-push-S newval))
4036 ;-------------------------------------------------------------
4038 ;-------------------------------------------------------------
4040 (define-pmacro (bit16-absolute offset)
4042 (define-derived-operand
4043 (name (.sym bit16- offset -16-absolute))
4044 (comment "m16c absolute address")
4045 (attrs (machine 16))
4047 (args ((.sym BitBase16- offset -u16)))
4048 (syntax (.str "${BitBase16-" offset "-u16}"))
4049 (base-ifield f-12-4)
4050 (encoding (+ (f-12-4 #xF) (.sym BitBase16- offset -u16)))
4051 (ifield-assertion (eq f-12-4 #xF))
4052 (getter (get-memory-bit 16 0 (.sym BitBase16- offset -u16)))
4053 (setter (set-memory-bit 16 0 (.sym BitBase16- offset -u16) newval))
4060 (define-pmacro (bit32-absolute offset group base1 base2)
4062 (define-derived-operand
4063 (name (.sym bit32- offset -19-absolute- group))
4064 (comment "m32c absolute address bit")
4065 (attrs (machine 32))
4067 (args ((.sym BitBase32- offset -u19- group)))
4068 (syntax (.str "${BitBase32-" offset "-u19-" group "}"))
4069 (base-ifield (.sym f- base1 -12))
4070 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 3) (.sym BitBase32- offset -u19- group)))
4071 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 3)))
4072 (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u19- group)))
4073 (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u19- group) newval))
4075 (define-derived-operand
4076 (name (.sym bit32- offset -27-absolute- group))
4077 (comment "m32c absolute address bit")
4078 (attrs (machine 32))
4080 (args ((.sym BitBase32- offset -u27- group)))
4081 (syntax (.str "${BitBase32-" offset "-u27-" group "}"))
4082 (base-ifield (.sym f- base1 -12))
4083 (encoding (+ ((.sym f- base1 -3) 3) ((.sym f- base2 -2) 2) (.sym BitBase32- offset -u27- group)))
4084 (ifield-assertion (andif (eq (.sym f- base1 -3) 3) (eq (.sym f- base2 -2) 2)))
4085 (getter (get-memory-bit 32 0 (.sym BitBase32- offset -u27- group)))
4086 (setter (set-memory-bit 32 0 (.sym BitBase32- offset -u27- group) newval))
4091 (bit32-absolute 16 Unprefixed 4 8)
4092 (bit32-absolute 24 Prefixed 12 16)
4094 ;-------------------------------------------------------------
4095 ; Destination operands for short fomat insns
4096 ;-------------------------------------------------------------
4098 (define-derived-operand
4099 (name dst16-3-S-R0l-direct-QI)
4100 (comment "m16c R0l direct QI")
4101 (attrs (machine 16))
4106 (encoding (+ (f-5-3 4)))
4107 (ifield-assertion (eq f-5-3 4))
4108 (getter (trunc QI R0l))
4109 (setter (set R0l newval))
4111 (define-derived-operand
4112 (name dst16-3-S-R0h-direct-QI)
4113 (comment "m16c R0h direct QI")
4114 (attrs (machine 16))
4119 (encoding (+ (f-5-3 3)))
4120 (ifield-assertion (eq f-5-3 3))
4121 (getter (trunc QI R0h))
4122 (setter (set R0h newval))
4124 (define-derived-operand
4125 (name dst16-3-S-8-8-SB-relative-QI)
4126 (comment "m16c SB relative QI")
4127 (attrs (machine 16))
4130 (syntax "${Dsp-8-u8}[sb]")
4132 (encoding (+ (f-5-3 5) Dsp-8-u8))
4133 (ifield-assertion (eq f-5-3 5))
4134 (getter (mem16 QI (add Dsp-8-u8 (reg h-sb))))
4135 (setter (set (mem16 QI (add Dsp-8-u8 (reg h-sb))) newval))
4137 (define-derived-operand
4138 (name dst16-3-S-8-8-FB-relative-QI)
4139 (comment "m16c FB relative QI")
4140 (attrs (machine 16))
4143 (syntax "${Dsp-8-s8}[fb]")
4145 (encoding (+ (f-5-3 6) Dsp-8-s8))
4146 (ifield-assertion (eq f-5-3 6))
4147 (getter (mem16 QI (add Dsp-8-s8 (reg h-fb))))
4148 (setter (set (mem16 QI (add Dsp-8-s8 (reg h-fb))) newval))
4150 (define-derived-operand
4151 (name dst16-3-S-8-16-absolute-QI)
4152 (comment "m16c absolute address QI")
4153 (attrs (machine 16))
4156 (syntax "${Dsp-8-u16}")
4158 (encoding (+ (f-5-3 7) Dsp-8-u16))
4159 (ifield-assertion (eq f-5-3 7))
4160 (getter (mem16 QI Dsp-8-u16))
4161 (setter (set (mem16 QI Dsp-8-u16) newval))
4163 (define-derived-operand
4164 (name dst16-3-S-16-8-SB-relative-QI)
4165 (comment "m16c SB relative QI")
4166 (attrs (machine 16))
4169 (syntax "${Dsp-16-u8}[sb]")
4171 (encoding (+ (f-5-3 5) Dsp-16-u8))
4172 (ifield-assertion (eq f-5-3 5))
4173 (getter (mem16 QI (add Dsp-16-u8 (reg h-sb))))
4174 (setter (set (mem16 QI (add Dsp-16-u8 (reg h-sb))) newval))
4176 (define-derived-operand
4177 (name dst16-3-S-16-8-FB-relative-QI)
4178 (comment "m16c FB relative QI")
4179 (attrs (machine 16))
4182 (syntax "${Dsp-16-s8}[fb]")
4184 (encoding (+ (f-5-3 6) Dsp-16-s8))
4185 (ifield-assertion (eq f-5-3 6))
4186 (getter (mem16 QI (add Dsp-16-s8 (reg h-fb))))
4187 (setter (set (mem16 QI (add Dsp-16-s8 (reg h-fb))) newval))
4189 (define-derived-operand
4190 (name dst16-3-S-16-16-absolute-QI)
4191 (comment "m16c absolute address QI")
4192 (attrs (machine 16))
4195 (syntax "${Dsp-16-u16}")
4197 (encoding (+ (f-5-3 7) Dsp-16-u16))
4198 (ifield-assertion (eq f-5-3 7))
4199 (getter (mem16 QI Dsp-16-u16))
4200 (setter (set (mem16 QI Dsp-16-u16) newval))
4202 (define-derived-operand
4203 (name srcdst16-r0l-r0h-S-derived)
4204 (comment "m16c r0l/r0h operand for short format insns")
4205 (attrs (machine 16))
4207 (args (SrcDst16-r0l-r0h-S-normal))
4208 (syntax "${SrcDst16-r0l-r0h-S-normal}")
4210 (encoding (+ (f-6-2 0) SrcDst16-r0l-r0h-S-normal))
4211 (ifield-assertion (eq f-6-2 0))
4212 (getter (trunc SI SrcDst16-r0l-r0h-S-normal))
4213 (setter ()) ; no setter
4215 (define-derived-operand
4216 (name dst32-2-S-R0l-direct-QI)
4217 (comment "m32c R0l direct QI")
4218 (attrs (machine 32))
4223 (encoding (+ (f-2-2 0)))
4224 (ifield-assertion (eq f-2-2 0))
4225 (getter (trunc QI R0l))
4226 (setter (set R0l newval))
4228 (define-derived-operand
4229 (name dst32-2-S-R0-direct-HI)
4230 (comment "m32c R0 direct HI")
4231 (attrs (machine 32))
4236 (encoding (+ (f-2-2 0)))
4237 (ifield-assertion (eq f-2-2 0))
4238 (getter (trunc HI R0))
4239 (setter (set R0 newval))
4241 (define-derived-operand
4242 (name dst32-1-S-A0-direct-HI)
4243 (comment "m32c A0 direct HI")
4244 (attrs (machine 32))
4249 (encoding (+ (f-7-1 0)))
4250 (ifield-assertion (eq f-7-1 0))
4251 (getter (trunc HI A0))
4252 (setter (set A0 newval))
4254 (define-derived-operand
4255 (name dst32-1-S-A1-direct-HI)
4256 (comment "m32c A1 direct HI")
4257 (attrs (machine 32))
4262 (encoding (+ (f-7-1 1)))
4263 (ifield-assertion (eq f-7-1 1))
4264 (getter (trunc HI A1))
4265 (setter (set A1 newval))
4267 (define-pmacro (dst32-2-S-operands xmode)
4269 (define-derived-operand
4270 (name (.sym dst32-2-S-8-SB-relative- xmode))
4271 (comment "m32c SB relative for short binary insns")
4272 (attrs (machine 32))
4275 (syntax "${Dsp-8-u8}[sb]")
4277 (encoding (+ (f-2-2 2) Dsp-8-u8))
4278 (ifield-assertion (eq f-2-2 2))
4279 (getter (c-call xmode (.str "operand_getter_" xmode) sb Dsp-8-u8))
4280 (setter (c-call DFLT (.str "operand_setter_" xmode) newval sb Dsp-8-u8))
4281 ; (getter (mem32 xmode (add Dsp-8-u8 (reg h-sb))))
4282 ; (setter (set (mem32 xmode (add Dsp-8-u8 (reg h-sb))) newval))
4284 (define-derived-operand
4285 (name (.sym dst32-2-S-8-FB-relative- xmode))
4286 (comment "m32c FB relative for short binary insns")
4287 (attrs (machine 32))
4290 (syntax "${Dsp-8-s8}[fb]")
4292 (encoding (+ (f-2-2 3) Dsp-8-s8))
4293 (ifield-assertion (eq f-2-2 3))
4294 (getter (c-call xmode (.str "operand_getter_" xmode) fb Dsp-8-s8))
4295 (setter (c-call DFLT (.str "operand_setter_" xmode) newval fb Dsp-8-s8))
4296 ; (getter (mem32 xmode (add Dsp-8-s8 (reg h-fb))))
4297 ; (setter (set (mem32 xmode (add Dsp-8-s8 (reg h-fb))) newval))
4299 (define-derived-operand
4300 (name (.sym dst32-2-S-16-absolute- xmode))
4301 (comment "m32c absolute address for short binary insns")
4302 (attrs (machine 32))
4305 (syntax "${Dsp-8-u16}")
4307 (encoding (+ (f-2-2 1) Dsp-8-u16))
4308 (ifield-assertion (eq f-2-2 1))
4309 (getter (c-call xmode (.str "operand_getter_" xmode) (const 0) Dsp-8-u16))
4310 (setter (c-call DFLT (.str "operand_setter_" xmode) newval (const 0) Dsp-8-u16))
4311 ; (getter (mem32 xmode Dsp-8-u16))
4312 ; (setter (set (mem32 xmode Dsp-8-u16) newval))
4314 ; (define-derived-operand
4315 ; (name (.sym dst32-2-S-8-SB-relative-indirect- xmode))
4316 ; (comment "m32c SB relative for short binary insns")
4317 ; (attrs (machine 32))
4319 ; (args (Dsp-16-u8))
4320 ; (syntax "[${Dsp-16-u8}[sb]]")
4321 ; (base-ifield f-10-2)
4322 ; (encoding (+ (f-10-2 2) Dsp-16-u8))
4323 ; (ifield-assertion (eq f-10-2 2))
4324 ; (getter (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb)))))
4325 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-u8 (reg h-sb)))) newval))
4327 ; (define-derived-operand
4328 ; (name (.sym dst32-2-S-8-FB-relative-indirect- xmode))
4329 ; (comment "m32c FB relative for short binary insns")
4330 ; (attrs (machine 32))
4332 ; (args (Dsp-16-s8))
4333 ; (syntax "[${Dsp-16-s8}[fb]]")
4334 ; (base-ifield f-10-2)
4335 ; (encoding (+ (f-10-2 3) Dsp-16-s8))
4336 ; (ifield-assertion (eq f-10-2 3))
4337 ; (getter (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb)))))
4338 ; (setter (set (mem32 xmode (indirect-addr (add Dsp-16-s8 (reg h-fb)))) newval))
4340 ; (define-derived-operand
4341 ; (name (.sym dst32-2-S-16-absolute-indirect- xmode))
4342 ; (comment "m32c absolute address for short binary insns")
4343 ; (attrs (machine 32))
4345 ; (args (Dsp-16-u16))
4346 ; (syntax "[${Dsp-16-u16}]")
4347 ; (base-ifield f-10-2)
4348 ; (encoding (+ (f-10-2 1) Dsp-16-u16))
4349 ; (ifield-assertion (eq f-10-2 1))
4350 ; (getter (mem32 xmode (indirect-addr Dsp-16-u16)))
4351 ; (setter (set (mem32 xmode (indirect-addr Dsp-16-u16)) newval))
4356 (dst32-2-S-operands QI)
4357 (dst32-2-S-operands HI)
4358 (dst32-2-S-operands SI)
4360 ;=============================================================
4362 ;-------------------------------------------------------------
4363 ; Source operands with no additional fields
4364 ;-------------------------------------------------------------
4366 (define-pmacro (src16-basic-operand xmode)
4368 (define-anyof-operand
4369 (name (.sym src16-basic- xmode))
4370 (comment (.str "m16c source operand of size " xmode " with no additional fields"))
4371 (attrs (machine 16))
4374 (.sym src16-Rn-direct- xmode)
4375 (.sym src16-An-direct- xmode)
4376 (.sym src16-An-indirect- xmode)
4381 (src16-basic-operand QI)
4382 (src16-basic-operand HI)
4384 (define-pmacro (src32-basic-operand xmode)
4386 (define-anyof-operand
4387 (name (.sym src32-basic-Unprefixed- xmode))
4388 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4389 (attrs (machine 32))
4392 (.sym src32-Rn-direct-Unprefixed- xmode)
4393 (.sym src32-An-direct-Unprefixed- xmode)
4394 (.sym src32-An-indirect-Unprefixed- xmode)
4397 (define-anyof-operand
4398 (name (.sym src32-basic-Prefixed- xmode))
4399 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4400 (attrs (machine 32))
4403 (.sym src32-Rn-direct-Prefixed- xmode)
4404 (.sym src32-An-direct-Prefixed- xmode)
4405 (.sym src32-An-indirect-Prefixed- xmode)
4408 ; (define-anyof-operand
4409 ; (name (.sym src32-basic-indirect- xmode))
4410 ; (comment (.str "m32c destination operand of size " xmode " indirect with no additional fields"))
4411 ; (attrs (machine 32))
4414 ; (.sym src32-An-indirect-indirect- xmode)
4420 (src32-basic-operand QI)
4421 (src32-basic-operand HI)
4422 (src32-basic-operand SI)
4424 (define-anyof-operand
4425 (name src32-basic-ExtPrefixed-QI)
4426 (comment "m32c source operand of size QI with no additional fields")
4427 (attrs (machine 32))
4430 src32-Rn-direct-Prefixed-QI
4431 src32-An-indirect-Prefixed-QI
4435 ;-------------------------------------------------------------
4436 ; Source operands with additional fields at offset 16 bits
4437 ;-------------------------------------------------------------
4439 (define-pmacro (src16-16-operand xmode)
4441 (define-anyof-operand
4442 (name (.sym src16-16-8- xmode))
4443 (comment (.str "m16c source operand of size " xmode " with additional 8 bit fields at offset 16"))
4444 (attrs (machine 16))
4447 (.sym src16-16-8-An-relative- xmode)
4448 (.sym src16-16-8-SB-relative- xmode)
4449 (.sym src16-16-8-FB-relative- xmode)
4452 (define-anyof-operand
4453 (name (.sym src16-16-16- xmode))
4454 (comment (.str "m16c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4455 (attrs (machine 16))
4458 (.sym src16-16-16-An-relative- xmode)
4459 (.sym src16-16-16-SB-relative- xmode)
4460 (.sym src16-16-16-absolute- xmode)
4465 (src16-16-operand QI)
4466 (src16-16-operand HI)
4468 (define-pmacro (src32-16-operand xmode)
4470 (define-anyof-operand
4471 (name (.sym src32-16-8-Unprefixed- xmode))
4472 (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 16"))
4473 (attrs (machine 32))
4476 (.sym src32-16-8-An-relative-Unprefixed- xmode)
4477 (.sym src32-16-8-SB-relative-Unprefixed- xmode)
4478 (.sym src32-16-8-FB-relative-Unprefixed- xmode)
4481 (define-anyof-operand
4482 (name (.sym src32-16-16-Unprefixed- xmode))
4483 (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4484 (attrs (machine 32))
4487 (.sym src32-16-16-An-relative-Unprefixed- xmode)
4488 (.sym src32-16-16-SB-relative-Unprefixed- xmode)
4489 (.sym src32-16-16-FB-relative-Unprefixed- xmode)
4490 (.sym src32-16-16-absolute-Unprefixed- xmode)
4493 (define-anyof-operand
4494 (name (.sym src32-16-24-Unprefixed- xmode))
4495 (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16"))
4496 (attrs (machine 32))
4499 (.sym src32-16-24-An-relative-Unprefixed- xmode)
4500 (.sym src32-16-24-absolute-Unprefixed- xmode)
4506 (src32-16-operand QI)
4507 (src32-16-operand HI)
4508 (src32-16-operand SI)
4510 ;-------------------------------------------------------------
4511 ; Source operands with additional fields at offset 24 bits
4512 ;-------------------------------------------------------------
4514 (define-pmacro (src-24-operand group xmode)
4516 (define-anyof-operand
4517 (name (.sym src32-24-8- group - xmode))
4518 (comment (.str "m32c source operand of size " xmode " with additional 8 bit fields at offset 24"))
4519 (attrs (machine 32))
4522 (.sym src32-24-8-An-relative- group - xmode)
4523 (.sym src32-24-8-SB-relative- group - xmode)
4524 (.sym src32-24-8-FB-relative- group - xmode)
4527 (define-anyof-operand
4528 (name (.sym src32-24-16- group - xmode))
4529 (comment (.str "m32c source operand of size " xmode " with additional 16 bit fields at offset 16"))
4530 (attrs (machine 32))
4533 (.sym src32-24-16-An-relative- group - xmode)
4534 (.sym src32-24-16-SB-relative- group - xmode)
4535 (.sym src32-24-16-FB-relative- group - xmode)
4536 (.sym src32-24-16-absolute- group - xmode)
4539 (define-anyof-operand
4540 (name (.sym src32-24-24- group - xmode))
4541 (comment (.str "m32c source operand of size " xmode " with additional 24 bit fields at offset 16"))
4542 (attrs (machine 32))
4545 (.sym src32-24-24-An-relative- group - xmode)
4546 (.sym src32-24-24-absolute- group - xmode)
4552 (src-24-operand Prefixed QI)
4553 (src-24-operand Prefixed HI)
4554 (src-24-operand Prefixed SI)
4556 (define-pmacro (src-24-indirect-operand xmode)
4558 ; (define-anyof-operand
4559 ; (name (.sym src32-24-8-indirect- xmode))
4560 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4561 ; (attrs (machine 32))
4564 ; (.sym src32-24-8-An-relative-indirect- xmode)
4565 ; (.sym src32-24-8-SB-relative-indirect- xmode)
4566 ; (.sym src32-24-8-FB-relative-indirect- xmode)
4569 ; (define-anyof-operand
4570 ; (name (.sym src32-24-16-indirect- xmode))
4571 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4572 ; (attrs (machine 32))
4575 ; (.sym src32-24-16-An-relative-indirect- xmode)
4576 ; (.sym src32-24-16-SB-relative-indirect- xmode)
4577 ; (.sym src32-24-16-FB-relative-indirect- xmode)
4580 ; (define-anyof-operand
4581 ; (name (.sym src32-24-24-indirect- xmode))
4582 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
4583 ; (attrs (machine 32))
4586 ; (.sym src32-24-24-An-relative-indirect- xmode)
4589 ; (define-anyof-operand
4590 ; (name (.sym src32-24-16-absolute-indirect- xmode))
4591 ; (comment (.str "m32c source operand of size " xmode " 16 bit absolute indirect"))
4592 ; (attrs (machine 32))
4595 ; (.sym src32-24-16-absolute-indirect-derived- xmode)
4598 ; (define-anyof-operand
4599 ; (name (.sym src32-24-24-absolute-indirect- xmode))
4600 ; (comment (.str "m32c source operand of size " xmode " 24 bit absolute indirect"))
4601 ; (attrs (machine 32))
4604 ; (.sym src32-24-24-absolute-indirect-derived- xmode)
4610 ; (src-24-indirect-operand QI)
4611 ; (src-24-indirect-operand HI)
4612 ; (src-24-indirect-operand SI)
4614 ;-------------------------------------------------------------
4615 ; Destination operands with no additional fields
4616 ;-------------------------------------------------------------
4618 (define-pmacro (dst16-basic-operand xmode)
4620 (define-anyof-operand
4621 (name (.sym dst16-basic- xmode))
4622 (comment (.str "m16c destination operand of size " xmode " with no additional fields"))
4623 (attrs (machine 16))
4626 (.sym dst16-Rn-direct- xmode)
4627 (.sym dst16-An-direct- xmode)
4628 (.sym dst16-An-indirect- xmode)
4634 (dst16-basic-operand QI)
4635 (dst16-basic-operand HI)
4636 (dst16-basic-operand SI)
4638 (define-pmacro (dst32-basic-operand xmode)
4640 (define-anyof-operand
4641 (name (.sym dst32-basic-Unprefixed- xmode))
4642 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4643 (attrs (machine 32))
4646 (.sym dst32-Rn-direct-Unprefixed- xmode)
4647 (.sym dst32-An-direct-Unprefixed- xmode)
4648 (.sym dst32-An-indirect-Unprefixed- xmode)
4651 (define-anyof-operand
4652 (name (.sym dst32-basic-Prefixed- xmode))
4653 (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
4654 (attrs (machine 32))
4657 (.sym dst32-Rn-direct-Prefixed- xmode)
4658 (.sym dst32-An-direct-Prefixed- xmode)
4659 (.sym dst32-An-indirect-Prefixed- xmode)
4665 (dst32-basic-operand QI)
4666 (dst32-basic-operand HI)
4667 (dst32-basic-operand SI)
4669 ;-------------------------------------------------------------
4670 ; Destination operands with possible additional fields at offset 16 bits
4671 ;-------------------------------------------------------------
4673 (define-pmacro (dst16-16-operand xmode)
4675 (define-anyof-operand
4676 (name (.sym dst16-16- xmode))
4677 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4678 (attrs (machine 16))
4681 (.sym dst16-Rn-direct- xmode)
4682 (.sym dst16-An-direct- xmode)
4683 (.sym dst16-An-indirect- xmode)
4684 (.sym dst16-16-8-An-relative- xmode)
4685 (.sym dst16-16-16-An-relative- xmode)
4686 (.sym dst16-16-8-SB-relative- xmode)
4687 (.sym dst16-16-16-SB-relative- xmode)
4688 (.sym dst16-16-8-FB-relative- xmode)
4689 (.sym dst16-16-16-absolute- xmode)
4692 (define-anyof-operand
4693 (name (.sym dst16-16-8- xmode))
4694 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4695 (attrs (machine 16))
4698 (.sym dst16-16-8-An-relative- xmode)
4699 (.sym dst16-16-8-SB-relative- xmode)
4700 (.sym dst16-16-8-FB-relative- xmode)
4703 (define-anyof-operand
4704 (name (.sym dst16-16-16- xmode))
4705 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 16"))
4706 (attrs (machine 16))
4709 (.sym dst16-16-16-An-relative- xmode)
4710 (.sym dst16-16-16-SB-relative- xmode)
4711 (.sym dst16-16-16-absolute- xmode)
4717 (dst16-16-operand QI)
4718 (dst16-16-operand HI)
4719 (dst16-16-operand SI)
4721 (define-anyof-operand
4722 (name dst16-16-Ext-QI)
4723 (comment "m16c destination operand of size QI for 'ext' insns with additional fields at offset 16")
4724 (attrs (machine 16))
4727 dst16-Rn-direct-Ext-QI
4728 dst16-An-indirect-Ext-QI
4729 dst16-16-8-An-relative-Ext-QI
4730 dst16-16-16-An-relative-Ext-QI
4731 dst16-16-8-SB-relative-Ext-QI
4732 dst16-16-16-SB-relative-Ext-QI
4733 dst16-16-8-FB-relative-Ext-QI
4734 dst16-16-16-absolute-Ext-QI
4738 (define-derived-operand
4739 (name dst16-An-indirect-Mova-HI)
4740 (comment "m16c addressof An indirect destination HI")
4744 (syntax "[$Dst16An]")
4745 (base-ifield f-12-4)
4746 (encoding (+ (f-12-2 1) (f-14-1 1) Dst16An))
4748 (andif (eq f-12-2 1) (eq f-14-1 1)))
4753 (define-derived-operand
4754 (name dst16-16-8-An-relative-Mova-HI)
4756 "m16c addressof dsp:8[An] relative destination HI")
4759 (args (Dst16An Dsp-16-u8))
4760 (syntax "${Dsp-16-u8}[$Dst16An]")
4761 (base-ifield f-12-4)
4763 (+ (f-12-2 2) (f-14-1 0) Dsp-16-u8 Dst16An))
4765 (andif (eq f-12-2 2) (eq f-14-1 0)))
4766 (getter (add Dsp-16-u8 Dst16An))
4769 (define-derived-operand
4770 (name dst16-16-16-An-relative-Mova-HI)
4772 "m16c addressof dsp:16[An] relative destination HI")
4775 (args (Dst16An Dsp-16-u16))
4776 (syntax "${Dsp-16-u16}[$Dst16An]")
4777 (base-ifield f-12-4)
4779 (+ (f-12-2 3) (f-14-1 0) Dsp-16-u16 Dst16An))
4781 (andif (eq f-12-2 3) (eq f-14-1 0)))
4782 (getter (add Dsp-16-u16 Dst16An))
4785 (define-derived-operand
4786 (name dst16-16-8-SB-relative-Mova-HI)
4788 "m16c addressof dsp:8[sb] relative destination HI")
4792 (syntax "${Dsp-16-u8}[sb]")
4793 (base-ifield f-12-4)
4794 (encoding (+ (f-12-4 10) Dsp-16-u8))
4795 (ifield-assertion (eq f-12-4 10))
4796 (getter (add Dsp-16-u8 (reg h-sb)))
4799 (define-derived-operand
4800 (name dst16-16-16-SB-relative-Mova-HI)
4802 "m16c addressof dsp:16[sb] relative destination HI")
4806 (syntax "${Dsp-16-u16}[sb]")
4807 (base-ifield f-12-4)
4808 (encoding (+ (f-12-4 14) Dsp-16-u16))
4809 (ifield-assertion (eq f-12-4 14))
4810 (getter (add Dsp-16-u16 (reg h-sb)))
4813 (define-derived-operand
4814 (name dst16-16-8-FB-relative-Mova-HI)
4816 "m16c addressof dsp:8[fb] relative destination HI")
4820 (syntax "${Dsp-16-s8}[fb]")
4821 (base-ifield f-12-4)
4822 (encoding (+ (f-12-4 11) Dsp-16-s8))
4823 (ifield-assertion (eq f-12-4 11))
4824 (getter (add Dsp-16-s8 (reg h-fb)))
4827 (define-derived-operand
4828 (name dst16-16-16-absolute-Mova-HI)
4829 (comment "m16c addressof absolute address HI")
4833 (syntax "${Dsp-16-u16}")
4834 (base-ifield f-12-4)
4835 (encoding (+ (f-12-4 15) Dsp-16-u16))
4836 (ifield-assertion (eq f-12-4 15))
4841 (define-anyof-operand
4842 (name dst16-16-Mova-HI)
4843 (comment "m16c addressof destination operand of size HI with additional fields at offset 16")
4844 (attrs (machine 16))
4847 dst16-An-indirect-Mova-HI
4848 dst16-16-8-An-relative-Mova-HI
4849 dst16-16-16-An-relative-Mova-HI
4850 dst16-16-8-SB-relative-Mova-HI
4851 dst16-16-16-SB-relative-Mova-HI
4852 dst16-16-8-FB-relative-Mova-HI
4853 dst16-16-16-absolute-Mova-HI
4857 (define-derived-operand
4858 (name dst32-An-indirect-Unprefixed-Mova-SI)
4859 (comment "m32c addressof An indirect destination SI")
4862 (args (Dst32AnUnprefixed))
4863 (syntax "[$Dst32AnUnprefixed]")
4866 (+ (f-4-3 0) (f-8-1 0) Dst32AnUnprefixed))
4868 (andif (eq f-4-3 0) (eq f-8-1 0)))
4869 (getter Dst32AnUnprefixed)
4873 (define-derived-operand
4874 (name dst32-16-8-An-relative-Unprefixed-Mova-SI)
4875 (comment "m32c addressof dsp:8[An] relative destination SI")
4878 (args (Dst32AnUnprefixed Dsp-16-u8))
4879 (syntax "${Dsp-16-u8}[$Dst32AnUnprefixed]")
4887 (andif (eq f-4-3 1) (eq f-8-1 0)))
4888 (getter (add Dsp-16-u8 Dst32AnUnprefixed))
4892 (define-derived-operand
4893 (name dst32-16-16-An-relative-Unprefixed-Mova-SI)
4895 "m32c addressof dsp:16[An] relative destination SI")
4898 (args (Dst32AnUnprefixed Dsp-16-u16))
4899 (syntax "${Dsp-16-u16}[$Dst32AnUnprefixed]")
4907 (andif (eq f-4-3 2) (eq f-8-1 0)))
4908 (getter (add Dsp-16-u16 Dst32AnUnprefixed))
4912 (define-derived-operand
4913 (name dst32-16-24-An-relative-Unprefixed-Mova-SI)
4914 (comment "addressof m32c dsp:16[An] relative destination SI")
4917 (args (Dst32AnUnprefixed Dsp-16-u24))
4918 (syntax "${Dsp-16-u24}[$Dst32AnUnprefixed]")
4926 (andif (eq f-4-3 3) (eq f-8-1 0)))
4927 (getter (add Dsp-16-u24 Dst32AnUnprefixed))
4931 (define-derived-operand
4932 (name dst32-16-8-SB-relative-Unprefixed-Mova-SI)
4933 (comment "m32c addressof dsp:8[sb] relative destination SI")
4937 (syntax "${Dsp-16-u8}[sb]")
4939 (encoding (+ (f-4-3 1) (f-8-2 2) Dsp-16-u8))
4941 (andif (eq f-4-3 1) (eq f-8-2 2)))
4942 (getter (add Dsp-16-u8 (reg h-sb)))
4946 (define-derived-operand
4947 (name dst32-16-16-SB-relative-Unprefixed-Mova-SI)
4948 (comment "m32c addressof dsp:16[sb] relative destination SI")
4952 (syntax "${Dsp-16-u16}[sb]")
4954 (encoding (+ (f-4-3 2) (f-8-2 2) Dsp-16-u16))
4956 (andif (eq f-4-3 2) (eq f-8-2 2)))
4957 (getter (add Dsp-16-u16 (reg h-sb)))
4961 (define-derived-operand
4962 (name dst32-16-8-FB-relative-Unprefixed-Mova-SI)
4963 (comment "m32c addressof dsp:8[fb] relative destination SI")
4967 (syntax "${Dsp-16-s8}[fb]")
4969 (encoding (+ (f-4-3 1) (f-8-2 3) Dsp-16-s8))
4971 (andif (eq f-4-3 1) (eq f-8-2 3)))
4972 (getter (add Dsp-16-s8 (reg h-fb)))
4976 (define-derived-operand
4977 (name dst32-16-16-FB-relative-Unprefixed-Mova-SI)
4978 (comment "m32c addressof dsp:16[fb] relative destination SI")
4982 (syntax "${Dsp-16-s16}[fb]")
4984 (encoding (+ (f-4-3 2) (f-8-2 3) Dsp-16-s16))
4986 (andif (eq f-4-3 2) (eq f-8-2 3)))
4987 (getter (add Dsp-16-s16 (reg h-fb)))
4991 (define-derived-operand
4992 (name dst32-16-16-absolute-Unprefixed-Mova-SI)
4993 (comment "m32c addressof absolute address SI") (attrs (ISA m32c))
4996 (syntax "${Dsp-16-u16}")
4998 (encoding (+ (f-4-3 3) (f-8-2 3) Dsp-16-u16))
5000 (andif (eq f-4-3 3) (eq f-8-2 3)))
5005 (define-derived-operand
5006 (name dst32-16-24-absolute-Unprefixed-Mova-SI)
5007 (comment "m32c addressof absolute address SI") (attrs (ISA m32c))
5010 (syntax "${Dsp-16-u24}")
5012 (encoding (+ (f-4-3 3) (f-8-2 2) Dsp-16-u24))
5014 (andif (eq f-4-3 3) (eq f-8-2 2)))
5019 (define-anyof-operand
5020 (name dst32-16-Unprefixed-Mova-SI)
5022 "m32c addressof destination operand of size SI with additional fields at offset 16")
5026 dst32-An-indirect-Unprefixed-Mova-SI
5027 dst32-16-8-An-relative-Unprefixed-Mova-SI
5028 dst32-16-16-An-relative-Unprefixed-Mova-SI
5029 dst32-16-24-An-relative-Unprefixed-Mova-SI
5030 dst32-16-8-SB-relative-Unprefixed-Mova-SI
5031 dst32-16-16-SB-relative-Unprefixed-Mova-SI
5032 dst32-16-8-FB-relative-Unprefixed-Mova-SI
5033 dst32-16-16-FB-relative-Unprefixed-Mova-SI
5034 dst32-16-16-absolute-Unprefixed-Mova-SI
5035 dst32-16-24-absolute-Unprefixed-Mova-SI))
5037 (define-pmacro (dst32-16-operand xmode)
5039 (define-anyof-operand
5040 (name (.sym dst32-16-Unprefixed- xmode))
5041 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5042 (attrs (machine 32))
5045 (.sym dst32-Rn-direct-Unprefixed- xmode)
5046 (.sym dst32-An-direct-Unprefixed- xmode)
5047 (.sym dst32-An-indirect-Unprefixed- xmode)
5048 (.sym dst32-16-8-An-relative-Unprefixed- xmode)
5049 (.sym dst32-16-16-An-relative-Unprefixed- xmode)
5050 (.sym dst32-16-24-An-relative-Unprefixed- xmode)
5051 (.sym dst32-16-8-SB-relative-Unprefixed- xmode)
5052 (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
5053 (.sym dst32-16-8-FB-relative-Unprefixed- xmode)
5054 (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
5055 (.sym dst32-16-16-absolute-Unprefixed- xmode)
5056 (.sym dst32-16-24-absolute-Unprefixed- xmode)
5059 (define-anyof-operand
5060 (name (.sym dst32-16-8-Unprefixed- xmode))
5061 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5062 (attrs (machine 32))
5065 (.sym dst32-16-8-An-relative-Unprefixed- xmode)
5066 (.sym dst32-16-8-SB-relative-Unprefixed- xmode)
5067 (.sym dst32-16-8-FB-relative-Unprefixed- xmode)
5070 (define-anyof-operand
5071 (name (.sym dst32-16-16-Unprefixed- xmode))
5072 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5073 (attrs (machine 32))
5076 (.sym dst32-16-16-An-relative-Unprefixed- xmode)
5077 (.sym dst32-16-16-SB-relative-Unprefixed- xmode)
5078 (.sym dst32-16-16-FB-relative-Unprefixed- xmode)
5079 (.sym dst32-16-16-absolute-Unprefixed- xmode)
5082 (define-anyof-operand
5083 (name (.sym dst32-16-24-Unprefixed- xmode))
5084 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 16"))
5085 (attrs (machine 32))
5088 (.sym dst32-16-24-An-relative-Unprefixed- xmode)
5089 (.sym dst32-16-24-absolute-Unprefixed- xmode)
5095 (dst32-16-operand QI)
5096 (dst32-16-operand HI)
5097 (dst32-16-operand SI)
5099 (define-pmacro (dst32-16-Ext-operand smode dmode)
5101 (define-anyof-operand
5102 (name (.sym dst32-16-ExtUnprefixed- smode))
5103 (comment (.str "m32c destination operand of size " smode " with additional fields at offset 16"))
5104 (attrs (machine 32))
5107 (.sym dst32-Rn-direct-ExtUnprefixed- smode)
5108 (.sym dst32-An-direct-Unprefixed- dmode) ; ExtUnprefixed mode not required for this operand -- use the normal dmode version
5109 (.sym dst32-An-indirect-ExtUnprefixed- smode)
5110 (.sym dst32-16-8-An-relative-ExtUnprefixed- smode)
5111 (.sym dst32-16-16-An-relative-ExtUnprefixed- smode)
5112 (.sym dst32-16-24-An-relative-ExtUnprefixed- smode)
5113 (.sym dst32-16-8-SB-relative-ExtUnprefixed- smode)
5114 (.sym dst32-16-16-SB-relative-ExtUnprefixed- smode)
5115 (.sym dst32-16-8-FB-relative-ExtUnprefixed- smode)
5116 (.sym dst32-16-16-FB-relative-ExtUnprefixed- smode)
5117 (.sym dst32-16-16-absolute-ExtUnprefixed- smode)
5118 (.sym dst32-16-24-absolute-ExtUnprefixed- smode)
5124 (dst32-16-Ext-operand QI HI)
5125 (dst32-16-Ext-operand HI SI)
5127 (define-anyof-operand
5128 (name dst32-16-Unprefixed-Mulex-HI)
5129 (comment "m32c destination operand of size HI with additional fields at offset 16")
5130 (attrs (machine 32))
5133 dst32-R3-direct-Unprefixed-HI
5134 dst32-An-direct-Unprefixed-HI
5135 dst32-An-indirect-Unprefixed-HI
5136 dst32-16-8-An-relative-Unprefixed-HI
5137 dst32-16-16-An-relative-Unprefixed-HI
5138 dst32-16-24-An-relative-Unprefixed-HI
5139 dst32-16-8-SB-relative-Unprefixed-HI
5140 dst32-16-16-SB-relative-Unprefixed-HI
5141 dst32-16-8-FB-relative-Unprefixed-HI
5142 dst32-16-16-FB-relative-Unprefixed-HI
5143 dst32-16-16-absolute-Unprefixed-HI
5144 dst32-16-24-absolute-Unprefixed-HI
5147 ;-------------------------------------------------------------
5148 ; Destination operands with possible additional fields at offset 24 bits
5149 ;-------------------------------------------------------------
5151 (define-pmacro (dst16-24-operand xmode)
5153 (define-anyof-operand
5154 (name (.sym dst16-24- xmode))
5155 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 24"))
5156 (attrs (machine 16))
5159 (.sym dst16-Rn-direct- xmode)
5160 (.sym dst16-An-direct- xmode)
5161 (.sym dst16-An-indirect- xmode)
5162 (.sym dst16-24-8-An-relative- xmode)
5163 (.sym dst16-24-16-An-relative- xmode)
5164 (.sym dst16-24-8-SB-relative- xmode)
5165 (.sym dst16-24-16-SB-relative- xmode)
5166 (.sym dst16-24-8-FB-relative- xmode)
5167 (.sym dst16-24-16-absolute- xmode)
5173 (dst16-24-operand QI)
5174 (dst16-24-operand HI)
5176 (define-pmacro (dst32-24-operand xmode)
5178 (define-anyof-operand
5179 (name (.sym dst32-24-Unprefixed- xmode))
5180 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5181 (attrs (machine 32))
5184 (.sym dst32-Rn-direct-Unprefixed- xmode)
5185 (.sym dst32-An-direct-Unprefixed- xmode)
5186 (.sym dst32-An-indirect-Unprefixed- xmode)
5187 (.sym dst32-24-8-An-relative-Unprefixed- xmode)
5188 (.sym dst32-24-16-An-relative-Unprefixed- xmode)
5189 (.sym dst32-24-24-An-relative-Unprefixed- xmode)
5190 (.sym dst32-24-8-SB-relative-Unprefixed- xmode)
5191 (.sym dst32-24-16-SB-relative-Unprefixed- xmode)
5192 (.sym dst32-24-8-FB-relative-Unprefixed- xmode)
5193 (.sym dst32-24-16-FB-relative-Unprefixed- xmode)
5194 (.sym dst32-24-16-absolute-Unprefixed- xmode)
5195 (.sym dst32-24-24-absolute-Unprefixed- xmode)
5198 (define-anyof-operand
5199 (name (.sym dst32-24-Prefixed- xmode))
5200 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5201 (attrs (machine 32))
5204 (.sym dst32-Rn-direct-Prefixed- xmode)
5205 (.sym dst32-An-direct-Prefixed- xmode)
5206 (.sym dst32-An-indirect-Prefixed- xmode)
5207 (.sym dst32-24-8-An-relative-Prefixed- xmode)
5208 (.sym dst32-24-16-An-relative-Prefixed- xmode)
5209 (.sym dst32-24-24-An-relative-Prefixed- xmode)
5210 (.sym dst32-24-8-SB-relative-Prefixed- xmode)
5211 (.sym dst32-24-16-SB-relative-Prefixed- xmode)
5212 (.sym dst32-24-8-FB-relative-Prefixed- xmode)
5213 (.sym dst32-24-16-FB-relative-Prefixed- xmode)
5214 (.sym dst32-24-16-absolute-Prefixed- xmode)
5215 (.sym dst32-24-24-absolute-Prefixed- xmode)
5218 (define-anyof-operand
5219 (name (.sym dst32-24-8-Prefixed- xmode))
5220 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5221 (attrs (machine 32))
5224 (.sym dst32-24-8-An-relative-Prefixed- xmode)
5225 (.sym dst32-24-8-SB-relative-Prefixed- xmode)
5226 (.sym dst32-24-8-FB-relative-Prefixed- xmode)
5229 (define-anyof-operand
5230 (name (.sym dst32-24-16-Prefixed- xmode))
5231 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5232 (attrs (machine 32))
5235 (.sym dst32-24-16-An-relative-Prefixed- xmode)
5236 (.sym dst32-24-16-SB-relative-Prefixed- xmode)
5237 (.sym dst32-24-16-FB-relative-Prefixed- xmode)
5238 (.sym dst32-24-16-absolute-Prefixed- xmode)
5241 (define-anyof-operand
5242 (name (.sym dst32-24-24-Prefixed- xmode))
5243 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5244 (attrs (machine 32))
5247 (.sym dst32-24-24-An-relative-Prefixed- xmode)
5248 (.sym dst32-24-24-absolute-Prefixed- xmode)
5251 ; (define-anyof-operand
5252 ; (name (.sym dst32-24-indirect- xmode))
5253 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5254 ; (attrs (machine 32))
5257 ; (.sym dst32-An-indirect-indirect- xmode)
5258 ; (.sym dst32-24-8-An-relative-indirect- xmode)
5259 ; (.sym dst32-24-16-An-relative-indirect- xmode)
5260 ; (.sym dst32-24-24-An-relative-indirect- xmode)
5261 ; (.sym dst32-24-8-SB-relative-indirect- xmode)
5262 ; (.sym dst32-24-16-SB-relative-indirect- xmode)
5263 ; (.sym dst32-24-8-FB-relative-indirect- xmode)
5264 ; (.sym dst32-24-16-FB-relative-indirect- xmode)
5267 ; (define-anyof-operand
5268 ; (name (.sym dst32-basic-indirect- xmode))
5269 ; (comment (.str "m32c destination operand of size " xmode " with no additional fields"))
5270 ; (attrs (machine 32))
5273 ; (.sym dst32-An-indirect-indirect- xmode)
5276 ; (define-anyof-operand
5277 ; (name (.sym dst32-24-8-indirect- xmode))
5278 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5279 ; (attrs (machine 32))
5282 ; (.sym dst32-24-8-An-relative-indirect- xmode)
5283 ; (.sym dst32-24-8-SB-relative-indirect- xmode)
5284 ; (.sym dst32-24-8-FB-relative-indirect- xmode)
5287 ; (define-anyof-operand
5288 ; (name (.sym dst32-24-16-indirect- xmode))
5289 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5290 ; (attrs (machine 32))
5293 ; (.sym dst32-24-16-An-relative-indirect- xmode)
5294 ; (.sym dst32-24-16-SB-relative-indirect- xmode)
5295 ; (.sym dst32-24-16-FB-relative-indirect- xmode)
5298 ; (define-anyof-operand
5299 ; (name (.sym dst32-24-24-indirect- xmode))
5300 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 24"))
5301 ; (attrs (machine 32))
5304 ; (.sym dst32-24-24-An-relative-indirect- xmode)
5307 ; (define-anyof-operand
5308 ; (name (.sym dst32-24-absolute-indirect- xmode))
5309 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5310 ; (attrs (machine 32))
5313 ; (.sym dst32-24-16-absolute-indirect-derived- xmode)
5314 ; (.sym dst32-24-24-absolute-indirect-derived- xmode)
5317 ; (define-anyof-operand
5318 ; (name (.sym dst32-24-16-absolute-indirect- xmode))
5319 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5320 ; (attrs (machine 32))
5323 ; (.sym dst32-24-16-absolute-indirect-derived- xmode)
5326 ; (define-anyof-operand
5327 ; (name (.sym dst32-24-24-absolute-indirect- xmode))
5328 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5329 ; (attrs (machine 32))
5332 ; (.sym dst32-24-24-absolute-indirect-derived- xmode)
5338 (dst32-24-operand QI)
5339 (dst32-24-operand HI)
5340 (dst32-24-operand SI)
5342 ;-------------------------------------------------------------
5343 ; Destination operands with possible additional fields at offset 32 bits
5344 ;-------------------------------------------------------------
5346 (define-pmacro (dst16-32-operand xmode)
5348 (define-anyof-operand
5349 (name (.sym dst16-32- xmode))
5350 (comment (.str "m16c destination operand of size " xmode " with additional fields at offset 32"))
5351 (attrs (machine 16))
5354 (.sym dst16-Rn-direct- xmode)
5355 (.sym dst16-An-direct- xmode)
5356 (.sym dst16-An-indirect- xmode)
5357 (.sym dst16-32-8-An-relative- xmode)
5358 (.sym dst16-32-16-An-relative- xmode)
5359 (.sym dst16-32-8-SB-relative- xmode)
5360 (.sym dst16-32-16-SB-relative- xmode)
5361 (.sym dst16-32-8-FB-relative- xmode)
5362 (.sym dst16-32-16-absolute- xmode)
5367 (dst16-32-operand QI)
5368 (dst16-32-operand HI)
5370 ; This macro actually handles operands at offset 32, 40 and 48 bits
5371 (define-pmacro (dst32-32plus-operand offset xmode)
5373 (define-anyof-operand
5374 (name (.sym dst32- offset -Unprefixed- xmode))
5375 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5376 (attrs (machine 32))
5379 (.sym dst32-Rn-direct-Unprefixed- xmode)
5380 (.sym dst32-An-direct-Unprefixed- xmode)
5381 (.sym dst32-An-indirect-Unprefixed- xmode)
5382 (.sym dst32- offset -8-An-relative-Unprefixed- xmode)
5383 (.sym dst32- offset -16-An-relative-Unprefixed- xmode)
5384 (.sym dst32- offset -24-An-relative-Unprefixed- xmode)
5385 (.sym dst32- offset -8-SB-relative-Unprefixed- xmode)
5386 (.sym dst32- offset -16-SB-relative-Unprefixed- xmode)
5387 (.sym dst32- offset -8-FB-relative-Unprefixed- xmode)
5388 (.sym dst32- offset -16-FB-relative-Unprefixed- xmode)
5389 (.sym dst32- offset -16-absolute-Unprefixed- xmode)
5390 (.sym dst32- offset -24-absolute-Unprefixed- xmode)
5393 (define-anyof-operand
5394 (name (.sym dst32- offset -Prefixed- xmode))
5395 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5396 (attrs (machine 32))
5399 (.sym dst32-Rn-direct-Prefixed- xmode)
5400 (.sym dst32-An-direct-Prefixed- xmode)
5401 (.sym dst32-An-indirect-Prefixed- xmode)
5402 (.sym dst32- offset -8-An-relative-Prefixed- xmode)
5403 (.sym dst32- offset -16-An-relative-Prefixed- xmode)
5404 (.sym dst32- offset -24-An-relative-Prefixed- xmode)
5405 (.sym dst32- offset -8-SB-relative-Prefixed- xmode)
5406 (.sym dst32- offset -16-SB-relative-Prefixed- xmode)
5407 (.sym dst32- offset -8-FB-relative-Prefixed- xmode)
5408 (.sym dst32- offset -16-FB-relative-Prefixed- xmode)
5409 (.sym dst32- offset -16-absolute-Prefixed- xmode)
5410 (.sym dst32- offset -24-absolute-Prefixed- xmode)
5413 ; (define-anyof-operand
5414 ; (name (.sym dst32- offset -indirect- xmode))
5415 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5416 ; (attrs (machine 32))
5419 ; (.sym dst32-An-indirect-indirect- xmode)
5420 ; (.sym dst32- offset -8-An-relative-indirect- xmode)
5421 ; (.sym dst32- offset -16-An-relative-indirect- xmode)
5422 ; (.sym dst32- offset -24-An-relative-indirect- xmode)
5423 ; (.sym dst32- offset -8-SB-relative-indirect- xmode)
5424 ; (.sym dst32- offset -16-SB-relative-indirect- xmode)
5425 ; (.sym dst32- offset -8-FB-relative-indirect- xmode)
5426 ; (.sym dst32- offset -16-FB-relative-indirect- xmode)
5429 ; (define-anyof-operand
5430 ; (name (.sym dst32- offset -absolute-indirect- xmode))
5431 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5432 ; (attrs (machine 32))
5435 ; (.sym dst32- offset -16-absolute-indirect-derived- xmode)
5436 ; (.sym dst32- offset -24-absolute-indirect-derived- xmode)
5442 (dst32-32plus-operand 32 QI)
5443 (dst32-32plus-operand 32 HI)
5444 (dst32-32plus-operand 32 SI)
5445 (dst32-32plus-operand 40 QI)
5446 (dst32-32plus-operand 40 HI)
5447 (dst32-32plus-operand 40 SI)
5449 ;-------------------------------------------------------------
5450 ; Destination operands with possible additional fields at offset 48 bits
5451 ;-------------------------------------------------------------
5453 (define-pmacro (dst32-48-operand offset xmode)
5455 (define-anyof-operand
5456 (name (.sym dst32- offset -Prefixed- xmode))
5457 (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5458 (attrs (machine 32))
5461 (.sym dst32-Rn-direct-Prefixed- xmode)
5462 (.sym dst32-An-direct-Prefixed- xmode)
5463 (.sym dst32-An-indirect-Prefixed- xmode)
5464 (.sym dst32- offset -8-An-relative-Prefixed- xmode)
5465 (.sym dst32- offset -16-An-relative-Prefixed- xmode)
5466 (.sym dst32- offset -24-An-relative-Prefixed- xmode)
5467 (.sym dst32- offset -8-SB-relative-Prefixed- xmode)
5468 (.sym dst32- offset -16-SB-relative-Prefixed- xmode)
5469 (.sym dst32- offset -8-FB-relative-Prefixed- xmode)
5470 (.sym dst32- offset -16-FB-relative-Prefixed- xmode)
5471 (.sym dst32- offset -16-absolute-Prefixed- xmode)
5472 (.sym dst32- offset -24-absolute-Prefixed- xmode)
5475 ; (define-anyof-operand
5476 ; (name (.sym dst32- offset -indirect- xmode))
5477 ; (comment (.str "m32c destination operand of size " xmode " with additional fields at offset 32"))
5478 ; (attrs (machine 32))
5481 ; (.sym dst32-An-indirect-indirect- xmode)
5482 ; (.sym dst32- offset -8-An-relative-indirect- xmode)
5483 ; (.sym dst32- offset -16-An-relative-indirect- xmode)
5484 ; (.sym dst32- offset -24-An-relative-indirect- xmode)
5485 ; (.sym dst32- offset -8-SB-relative-indirect- xmode)
5486 ; (.sym dst32- offset -16-SB-relative-indirect- xmode)
5487 ; (.sym dst32- offset -8-FB-relative-indirect- xmode)
5488 ; (.sym dst32- offset -16-FB-relative-indirect- xmode)
5491 ; (define-anyof-operand
5492 ; (name (.sym dst32- offset -absolute-indirect- xmode))
5493 ; (comment (.str "m32c destination operand of size " xmode " absolute indirect"))
5494 ; (attrs (machine 32))
5497 ; (.sym dst32- offset -16-absolute-indirect-derived- xmode)
5498 ; (.sym dst32- offset -24-absolute-indirect-derived- xmode)
5504 (dst32-48-operand 48 QI)
5505 (dst32-48-operand 48 HI)
5506 (dst32-48-operand 48 SI)
5508 ;-------------------------------------------------------------
5509 ; Bit operands for m16c
5510 ;-------------------------------------------------------------
5512 (define-pmacro (bit16-operand offset)
5514 (define-anyof-operand
5515 (name (.sym bit16- offset))
5516 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5517 (attrs (machine 16))
5523 (.sym bit16- offset -8-An-relative)
5524 (.sym bit16- offset -16-An-relative)
5525 (.sym bit16- offset -8-SB-relative)
5526 (.sym bit16- offset -16-SB-relative)
5527 (.sym bit16- offset -8-FB-relative)
5528 (.sym bit16- offset -16-absolute)
5531 (define-anyof-operand
5532 (name (.sym bit16- offset -basic))
5533 (comment (.str "m16c bit operand with no additional fields"))
5534 (attrs (machine 16))
5540 (define-anyof-operand
5541 (name (.sym bit16- offset -8))
5542 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5543 (attrs (machine 16))
5548 (.sym bit16- offset -8-An-relative)
5549 (.sym bit16- offset -8-SB-relative)
5550 (.sym bit16- offset -8-FB-relative)
5553 (define-anyof-operand
5554 (name (.sym bit16- offset -16))
5555 (comment (.str "m16c bit operand with possible additional fields at offset 24"))
5556 (attrs (machine 16))
5559 (.sym bit16- offset -16-An-relative)
5560 (.sym bit16- offset -16-SB-relative)
5561 (.sym bit16- offset -16-absolute)
5569 ;-------------------------------------------------------------
5570 ; Bit operands for m32c
5571 ;-------------------------------------------------------------
5573 (define-pmacro (bit32-operand offset group)
5575 (define-anyof-operand
5576 (name (.sym bit32- offset - group))
5577 (comment (.str "m32c bit operand with possible additional fields at offset 24"))
5578 (attrs (machine 32))
5581 (.sym bit32-Rn-direct- group)
5582 (.sym bit32-An-direct- group)
5583 (.sym bit32-An-indirect- group)
5584 (.sym bit32- offset -11-An-relative- group)
5585 (.sym bit32- offset -19-An-relative- group)
5586 (.sym bit32- offset -27-An-relative- group)
5587 (.sym bit32- offset -11-SB-relative- group)
5588 (.sym bit32- offset -19-SB-relative- group)
5589 (.sym bit32- offset -11-FB-relative- group)
5590 (.sym bit32- offset -19-FB-relative- group)
5591 (.sym bit32- offset -19-absolute- group)
5592 (.sym bit32- offset -27-absolute- group)
5598 (bit32-operand 16 Unprefixed)
5599 (bit32-operand 24 Prefixed)
5601 (define-anyof-operand
5602 (name bit32-basic-Unprefixed)
5603 (comment "m32c bit operand with no additional fields")
5604 (attrs (machine 32))
5607 bit32-Rn-direct-Unprefixed
5608 bit32-An-direct-Unprefixed
5609 bit32-An-indirect-Unprefixed
5613 (define-anyof-operand
5614 (name bit32-16-8-Unprefixed)
5615 (comment "m32c bit operand with 8 bit additional fields")
5616 (attrs (machine 32))
5619 bit32-16-11-An-relative-Unprefixed
5620 bit32-16-11-SB-relative-Unprefixed
5621 bit32-16-11-FB-relative-Unprefixed
5625 (define-anyof-operand
5626 (name bit32-16-16-Unprefixed)
5627 (comment "m32c bit operand with 16 bit additional fields")
5628 (attrs (machine 32))
5631 bit32-16-19-An-relative-Unprefixed
5632 bit32-16-19-SB-relative-Unprefixed
5633 bit32-16-19-FB-relative-Unprefixed
5634 bit32-16-19-absolute-Unprefixed
5638 (define-anyof-operand
5639 (name bit32-16-24-Unprefixed)
5640 (comment "m32c bit operand with 24 bit additional fields")
5641 (attrs (machine 32))
5644 bit32-16-27-An-relative-Unprefixed
5645 bit32-16-27-absolute-Unprefixed
5649 ;-------------------------------------------------------------
5650 ; Operands for short format binary insns
5651 ;-------------------------------------------------------------
5653 (define-anyof-operand
5655 (comment "m16c source operand of size QI for short format insns")
5656 (attrs (machine 16))
5659 src16-2-S-8-SB-relative-QI
5660 src16-2-S-8-FB-relative-QI
5661 src16-2-S-16-absolute-QI
5665 (define-anyof-operand
5667 (comment "m32c source operand of size QI for short format insns")
5668 (attrs (machine 32))
5671 src32-2-S-8-SB-relative-QI
5672 src32-2-S-8-FB-relative-QI
5673 src32-2-S-16-absolute-QI
5677 (define-anyof-operand
5679 (comment "m32c source operand of size QI for short format insns")
5680 (attrs (machine 32))
5683 src32-2-S-8-SB-relative-HI
5684 src32-2-S-8-FB-relative-HI
5685 src32-2-S-16-absolute-HI
5689 (define-anyof-operand
5691 (comment "m16c destination operand of size QI for short format insns")
5692 (attrs (machine 16))
5695 dst16-3-S-R0l-direct-QI
5696 dst16-3-S-R0h-direct-QI
5697 dst16-3-S-8-8-SB-relative-QI
5698 dst16-3-S-8-8-FB-relative-QI
5699 dst16-3-S-8-16-absolute-QI
5703 (define-anyof-operand
5705 (comment "m16c destination operand of size QI for short format insns")
5706 (attrs (machine 16))
5709 dst16-3-S-R0l-direct-QI
5710 dst16-3-S-R0h-direct-QI
5711 dst16-3-S-16-8-SB-relative-QI
5712 dst16-3-S-16-8-FB-relative-QI
5713 dst16-3-S-16-16-absolute-QI
5717 (define-anyof-operand
5718 (name srcdst16-r0l-r0h-S)
5719 (comment "m16c r0l/r0h operand of size QI for short format insns")
5720 (attrs (machine 16))
5723 srcdst16-r0l-r0h-S-derived
5727 (define-anyof-operand
5728 (name dst32-2-S-basic-QI)
5729 (comment "m32c r0l operand of size QI for short format binary insns")
5730 (attrs (machine 32))
5733 dst32-2-S-R0l-direct-QI
5737 (define-anyof-operand
5738 (name dst32-2-S-basic-HI)
5739 (comment "m32c r0 operand of size HI for short format binary insns")
5740 (attrs (machine 32))
5743 dst32-2-S-R0-direct-HI
5747 (define-pmacro (dst32-2-S-operands xmode)
5749 (define-anyof-operand
5750 (name (.sym dst32-2-S-8- xmode))
5751 (comment "m32c operand of size " xmode " for short format binary insns")
5752 (attrs (machine 32))
5755 (.sym dst32-2-S-8-SB-relative- xmode)
5756 (.sym dst32-2-S-8-FB-relative- xmode)
5759 (define-anyof-operand
5760 (name (.sym dst32-2-S-16- xmode))
5761 (comment "m32c operand of size " xmode " for short format binary insns")
5762 (attrs (machine 32))
5765 (.sym dst32-2-S-16-absolute- xmode)
5768 ; (define-anyof-operand
5769 ; (name (.sym dst32-2-S-8-indirect- xmode))
5770 ; (comment "m32c operand of size " xmode " for short format binary insns")
5771 ; (attrs (machine 32))
5774 ; (.sym dst32-2-S-8-SB-relative-indirect- xmode)
5775 ; (.sym dst32-2-S-8-FB-relative-indirect- xmode)
5778 ; (define-anyof-operand
5779 ; (name (.sym dst32-2-S-absolute-indirect- xmode))
5780 ; (comment "m32c operand of size " xmode " for short format binary insns")
5781 ; (attrs (machine 32))
5784 ; (.sym dst32-2-S-16-absolute-indirect- xmode)
5790 (dst32-2-S-operands QI)
5791 (dst32-2-S-operands HI)
5792 (dst32-2-S-operands SI)
5794 (define-anyof-operand
5796 (comment "m32c An operand for short format binary insns")
5797 (attrs (machine 32))
5800 dst32-1-S-A0-direct-HI
5801 dst32-1-S-A1-direct-HI
5805 (define-anyof-operand
5807 (comment "m16c bit operand for short format insns")
5808 (attrs (machine 16))
5811 bit16-11-SB-relative-S
5815 (define-anyof-operand
5816 (name Rn16-push-S-anyof)
5817 (comment "m16c bit operand for short format insns")
5818 (attrs (machine 16))
5825 (define-anyof-operand
5826 (name An16-push-S-anyof)
5827 (comment "m16c bit operand for short format insns")
5828 (attrs (machine 16))
5835 ;=============================================================
5836 ; Common macros for instruction definitions
5838 (define-pmacro (set-z x)
5840 (set zbit (zflag x)))
5844 (define-pmacro (set-s x)
5846 (set sbit (nflag x)))
5849 (define-pmacro (set-z-and-s x)
5855 ;=============================================================
5857 ;-------------------------------------------------------------
5859 (define-pmacro (unary-insn-defn-g mach group mode wstr op encoding sem opg)
5860 (dni (.sym op mach wstr - group)
5861 (.str op wstr opg " dst" mach "-" group "-" mode)
5863 (.str op wstr opg " ${dst" mach "-" group "-" mode "}")
5865 (sem mode (.sym dst mach - group - mode))
5869 (define-pmacro (unary-insn-defn mach group mode wstr op encoding sem)
5870 (unary-insn-defn-g mach group mode wstr op encoding sem "")
5874 (define-pmacro (unary16-defn-g mode wstr wbit op opc1 opc2 opc3 sem opg)
5875 (unary-insn-defn-g 16 16 mode wstr op
5876 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16- mode))
5879 (define-pmacro (unary16-defn mode wstr wbit op opc1 opc2 opc3 sem)
5880 (unary-16-defn-g mode wstr wbit op opc1 opc2 opc3 sem "")
5883 (define-pmacro (unary32-defn-g mode wstr wbit op opc1 opc2 opc3 sem opg)
5885 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
5886 ; define the absolute-indirect insns first in order to prevent them from being selected
5887 ; when the mode is register-indirect
5888 ; (unary-insn-defn 32 24-absolute-indirect mode wstr op
5889 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (.sym dst32-24-absolute-indirect- mode) (f-18-2 opc2) (f-20-4 opc3))
5891 (unary-insn-defn-g 32 16-Unprefixed mode wstr op
5892 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3))
5894 ; (unary-insn-defn 32 24-indirect mode wstr op
5895 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (.sym dst32-24-indirect- mode) (f-18-2 opc2) (f-20-4 opc3))
5899 (define-pmacro (unary32-defn mode wstr wbit op opc1 opc2 opc3 sem)
5900 (unary32-defn-g mode wstr wbit op opc1 opc2 opc3 sem "")
5903 (define-pmacro (unary-insn-mach-g mach op opc1 opc2 opc3 sem opg)
5905 (.apply (.sym unary mach -defn-g) (QI .b 0 op opc1 opc2 opc3 sem opg))
5906 (.apply (.sym unary mach -defn-g) (HI .w 1 op opc1 opc2 opc3 sem opg))
5909 (define-pmacro (unary-insn-mach mach op opc1 opc2 opc3 sem)
5910 (unary-insn-mach-g mach op opc1 opc2 opc3 sem "")
5913 (define-pmacro (unary-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
5915 (unary-insn-mach-g 16 op opc16-1 opc16-2 opc16-3 sem "")
5916 (unary-insn-mach-g 32 op opc32-1 opc32-2 opc32-3 sem "")
5920 (define-pmacro (unary-insn-g op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
5922 (unary-insn-mach-g 16 op opc16-1 opc16-2 opc16-3 sem "$G")
5923 (unary-insn-mach-g 32 op opc32-1 opc32-2 opc32-3 sem "$G")
5927 ;-------------------------------------------------------------
5928 ; Sign/zero extension macros
5929 ;-------------------------------------------------------------
5931 (define-pmacro (ext-insn-defn mach group smode dmode wstr op encoding sem)
5932 (dni (.sym op mach wstr - group)
5933 (.str op wstr " dst" mach "-" group "-" smode)
5935 (.str op wstr " ${dst" mach "-" group "-" smode "}")
5937 (sem smode dmode (.sym dst mach - group - smode) (.sym dst mach - group - smode))
5941 (define-pmacro (ext16-defn smode dmode wstr wbit op opc1 opc2 opc3 sem)
5942 (ext-insn-defn 16 16-Ext smode dmode wstr op
5943 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-Ext- smode))
5947 (define-pmacro (ext32-defn smode dmode wstr wbit op opc1 opc2 opc3 sem)
5948 (ext-insn-defn 32 16-ExtUnprefixed smode dmode wstr op
5949 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst32-16-ExtUnprefixed- smode))
5953 (define-pmacro (ext32-binary-insn src-group dst-group op wstr encoding sem)
5954 (dni (.sym op 32 wstr - src-group - dst-group)
5955 (.str op 32 wstr " src32-" src-group "-QI,dst32-" dst-group "-HI")
5957 (.str op wstr " ${src32-" src-group "-QI},${dst32-" dst-group "-HI}")
5959 (sem QI HI (.sym src32- src-group -QI) (.sym dst32 - dst-group -HI))
5963 (define-pmacro (ext32-binary-defn op wstr opc1 opc2 sem)
5965 (ext32-binary-insn basic-ExtPrefixed 24-Prefixed op wstr
5966 (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-basic-ExtPrefixed-QI dst32-24-Prefixed-HI (f-20-4 opc2))
5968 (ext32-binary-insn 24-24-Prefixed 48-Prefixed op wstr
5969 (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-24-24-Prefixed-QI dst32-48-Prefixed-HI (f-20-4 opc2))
5971 (ext32-binary-insn 24-16-Prefixed 40-Prefixed op wstr
5972 (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-24-16-Prefixed-QI dst32-40-Prefixed-HI (f-20-4 opc2))
5974 (ext32-binary-insn 24-8-Prefixed 32-Prefixed op wstr
5975 (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 0) src32-24-8-Prefixed-QI dst32-32-Prefixed-HI (f-20-4 opc2))
5980 ;=============================================================
5981 ; Binary Arithmetic macros
5983 ;-------------------------------------------------------------
5984 ;<arith>.size:S src2,r0[l] -- for m32c
5985 ;-------------------------------------------------------------
5987 (define-pmacro (binary-arith32-S-src2 op xmode wstr wbit opc1 opc2 sem)
5988 (dni (.sym op 32 wstr .S-src2-r0- xmode)
5989 (.str op 32 wstr ":S src2,r0[l]")
5991 (.str op wstr"$S ${src32-2-S-" xmode "},${Dst32R0" xmode "-S}")
5992 (+ opc1 opc2 (.sym src32-2-S- xmode) (f-7-1 wbit))
5993 (sem xmode (.sym src32-2-S- xmode) (.sym Dst32R0 xmode -S))
5997 ;-------------------------------------------------------------
5998 ;<arith>.b:S src2,r0l/r0h -- for m16c
5999 ;-------------------------------------------------------------
6001 (define-pmacro (binary-arith16-b-S-src2 op opc1 opc2 sem)
6003 (dni (.sym op 16 .b.S-src2)
6004 (.str op ".b:S src2,r0[lh]")
6006 (.str op ".b$S ${src16-2-S},${Dst16RnQI-S}")
6007 (+ opc1 opc2 Dst16RnQI-S src16-2-S)
6008 (sem QI src16-2-S Dst16RnQI-S)
6010 (dni (.sym op 16 .b.S-r0l-r0h)
6011 (.str op ".b:S r0l/r0h")
6013 (.str op ".b$S ${srcdst16-r0l-r0h-S}")
6014 (+ opc1 opc2 srcdst16-r0l-r0h-S)
6015 (if (eq srcdst16-r0l-r0h-S 0)
6022 ;-------------------------------------------------------------
6023 ;<arith>.b:S #imm8,dst3 -- for m16c
6024 ;-------------------------------------------------------------
6026 (define-pmacro (binary-arith16-b-S-imm8-dst3 op sz opc1 opc2 sem)
6027 (dni (.sym op 16 .b.S-imm8-dst3)
6028 (.str op sz ":S imm8,dst3")
6030 (.str op sz "$S #${Imm-8-QI},${Dst16-3-S-16}")
6031 (+ opc1 opc2 Dst16-3-S-16 Imm-8-QI)
6032 (sem QI Imm-8-QI Dst16-3-S-16)
6036 ;-------------------------------------------------------------
6037 ;<arith>.size:Q #imm4,sp -- for m16c
6038 ;-------------------------------------------------------------
6040 (define-pmacro (binary-arith16-Q-sp op opc1 opc2 opc3 sem)
6041 (dni (.sym op 16 -wQ-sp)
6042 (.str op ".w:q #imm4,sp")
6044 (.str op ".w$Q #${Imm-12-s4},sp")
6045 (+ opc1 opc2 opc3 Imm-12-s4)
6046 (sem QI Imm-12-s4 sp)
6050 ;-------------------------------------------------------------
6051 ;<arith>.size:G #imm,sp -- for m16c
6052 ;-------------------------------------------------------------
6054 (define-pmacro (binary-arith16-G-sp-defn mode wstr wbit op opc1 opc2 opc3 opc4 sem)
6055 (dni (.sym op 16 wstr - G-sp)
6056 (.str op wstr " imm-sp " mode)
6058 (.str op wstr "$G #${Imm-16-" mode "},sp")
6059 (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16- mode))
6060 (sem mode (.sym Imm-16- mode) sp)
6064 (define-pmacro (binary-arith16-G-sp op opc1 opc2 opc3 opc4 sem)
6066 (binary-arith16-G-sp-defn QI .b 0 op opc1 opc2 opc3 opc4 sem)
6067 (binary-arith16-G-sp-defn HI .w 1 op opc1 opc2 opc3 opc4 sem)
6071 ;-------------------------------------------------------------
6072 ;<arith>.size:G #imm,dst -- for m16c and m32c
6073 ;-------------------------------------------------------------
6075 (define-pmacro (binary-arith-imm-dst-defn mach src dstgroup dmode wstr op suffix encoding sem)
6076 (dni (.sym op mach wstr - imm-G - dstgroup)
6077 (.str op wstr " " mach "-imm-G-" dstgroup "-" dmode)
6079 (.str op wstr "$"suffix " #${" src "},${dst" mach "-" dstgroup "-" dmode "}")
6081 (sem dmode src (.sym dst mach - dstgroup - dmode))
6086 (define-pmacro (binary-arith16-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6088 (binary-arith-imm-dst-defn 16 (.sym Imm-32- smode) 16-16 dmode wstr op suffix
6089 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- dmode) (.sym Imm-32- smode))
6091 (binary-arith-imm-dst-defn 16 (.sym Imm-24- smode) 16-8 dmode wstr op suffix
6092 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- dmode) (.sym Imm-24- smode))
6094 (binary-arith-imm-dst-defn 16 (.sym Imm-16- smode) basic dmode wstr op suffix
6095 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- dmode) (.sym Imm-16- smode))
6100 ; m32c Unprefixed variants
6101 (define-pmacro (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6103 (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 16-24-Unprefixed dmode wstr op suffix
6104 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-16-24-Unprefixed- dmode) (.sym Imm-40- smode))
6106 (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 16-16-Unprefixed dmode wstr op suffix
6107 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-16-16-Unprefixed- dmode) (.sym Imm-32- smode))
6109 (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) 16-8-Unprefixed dmode wstr op suffix
6110 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-16-8-Unprefixed- dmode) (.sym Imm-24- smode))
6112 (binary-arith-imm-dst-defn 32 (.sym Imm-16- smode) basic-Unprefixed dmode wstr op suffix
6113 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3) (.sym dst32-basic-Unprefixed- dmode) (.sym Imm-16- smode))
6118 ; m32c Prefixed variants
6119 (define-pmacro (binary-arith32-imm-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6121 (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-Prefixed dmode wstr op suffix
6122 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-24-Prefixed- dmode) (.sym Imm-48- smode))
6124 (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-Prefixed dmode wstr op suffix
6125 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-16-Prefixed- dmode) (.sym Imm-40- smode))
6127 (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-Prefixed dmode wstr op suffix
6128 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-8-Prefixed- dmode) (.sym Imm-32- smode))
6130 (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-Prefixed dmode wstr op suffix
6131 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-basic-Prefixed- dmode) (.sym Imm-24- smode))
6137 (define-pmacro (binary-arith32-imm-dst-defn smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6139 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6140 ; define the absolute-indirect insns first in order to prevent them from being selected
6141 ; when the mode is register-indirect
6142 ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-absolute-indirect dmode wstr op suffix
6143 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-24-absolute-indirect- dmode) (.sym Imm-48- smode))
6145 ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-absolute-indirect dmode wstr op suffix
6146 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-16-absolute-indirect- dmode) (.sym Imm-40- smode))
6148 ; Unprefixed modes next
6149 (binary-arith32-imm-dst-Unprefixed smode dmode wstr wbit op suffix opc1 opc2 opc3 sem)
6151 ; Remaining indirect modes
6152 ; (binary-arith-imm-dst-defn 32 (.sym Imm-24- smode) basic-indirect dmode wstr op suffix
6153 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-basic-indirect- dmode) (.sym Imm-24- smode))
6155 ; (binary-arith-imm-dst-defn 32 (.sym Imm-48- smode) 24-24-indirect dmode wstr op suffix
6156 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-24-indirect- dmode) (.sym Imm-48- smode))
6158 ; (binary-arith-imm-dst-defn 32 (.sym Imm-40- smode) 24-16-indirect dmode wstr op suffix
6159 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-16-indirect- dmode) (.sym Imm-40- smode))
6161 ; (binary-arith-imm-dst-defn 32 (.sym Imm-32- smode) 24-8-indirect dmode wstr op suffix
6162 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3) (.sym dst32-24-8-indirect- dmode) (.sym Imm-32- smode))
6167 (define-pmacro (binary-arith-imm-dst-mach mach op suffix opc1 opc2 opc3 sem)
6169 (.apply (.sym binary-arith mach -imm-dst-defn) (QI QI .b 0 op suffix opc1 opc2 opc3 sem))
6170 (.apply (.sym binary-arith mach -imm-dst-defn) (HI HI .w 1 op suffix opc1 opc2 opc3 sem))
6174 (define-pmacro (binary-arith-imm-dst op suffix opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6176 (binary-arith-imm-dst-mach 16 op suffix opc16-1 opc16-2 opc16-3 sem)
6177 (binary-arith-imm-dst-mach 32 op suffix opc32-1 opc32-2 opc32-3 sem)
6181 ;-------------------------------------------------------------
6182 ;<arith>.size:Q #imm4,dst -- for m16c and m32c
6183 ;-------------------------------------------------------------
6185 (define-pmacro (binary-arith-imm4-dst-defn mach src dstgroup mode wstr op encoding sem)
6186 (dni (.sym op mach wstr - imm4-Q - dstgroup)
6187 (.str op wstr " " mach "-imm4-Q-" dstgroup "-" mode)
6189 (.str op wstr "$Q #${" src "},${dst" mach "-" dstgroup "-" mode "}")
6191 (sem mode src (.sym dst mach - dstgroup - mode))
6196 (define-pmacro (binary-arith16-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6197 (binary-arith-imm4-dst-defn 16 Imm-8-s4 16 mode wstr op
6198 (+ opc1 opc2 (f-7-1 wbit2) Imm-8-s4 (.sym dst16-16- mode))
6202 (define-pmacro (binary-arith16-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6203 (binary-arith-imm4-dst-defn 16 Imm-sh-8-s4 16 mode wstr op
6204 (+ opc1 opc2 (f-7-1 wbit2) Imm-sh-8-s4 (.sym dst16-16- mode))
6209 (define-pmacro (binary-arith32-imm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6211 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6212 ; define the absolute-indirect insns first in order to prevent them from being selected
6213 ; when the mode is register-indirect
6214 ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-absolute-indirect mode wstr op
6215 ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-absolute-indirect- mode) (f-18-2 opc2) Imm-20-s4)
6217 (binary-arith-imm4-dst-defn 32 Imm-12-s4 16-Unprefixed mode wstr op
6218 (+ (f-0-3 opc1) (f-3-1 wbit1) (f-7-1 wbit2) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) Imm-12-s4)
6220 ; (binary-arith-imm4-dst-defn 32 Imm-20-s4 24-indirect mode wstr op
6221 ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-indirect- mode) (f-18-2 opc2) Imm-20-s4)
6226 (define-pmacro (binary-arith32-shimm4-dst-defn mode wstr wbit1 wbit2 op opc1 opc2 sem)
6228 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6229 ; define the absolute-indirect insns first in order to prevent them from being selected
6230 ; when the mode is register-indirect
6231 ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-absolute-indirect mode wstr op
6232 ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-absolute-indirect- mode) (f-18-2 opc2) Imm-sh-20-s4)
6234 (binary-arith-imm4-dst-defn 32 Imm-sh-12-s4 16-Unprefixed mode wstr op
6235 (+ (f-0-3 opc1) (f-3-1 wbit1) (f-7-1 wbit2) (.sym dst32-16-Unprefixed- mode) (f-10-2 opc2) Imm-sh-12-s4)
6237 ; (binary-arith-imm4-dst-defn 32 Imm-sh-20-s4 24-indirect mode wstr op
6238 ; (+ (f-0-4 0) (f-4-4 9) (f-8-3 opc1) (f-11-1 wbit1) (f-15-1 wbit2) (.sym dst32-24-indirect- mode) (f-18-2 opc2) Imm-sh-20-s4)
6243 (define-pmacro (binary-arith-imm4-dst-mach mach op opc1 opc2 sem)
6245 (.apply (.sym binary-arith mach -imm4-dst-defn) (QI .b 0 0 op opc1 opc2 sem))
6246 (.apply (.sym binary-arith mach -imm4-dst-defn) (HI .w 0 1 op opc1 opc2 sem))
6250 (define-pmacro (binary-arith-imm4-dst op opc16-1 opc16-2 opc32-1 opc32-2 sem)
6252 (binary-arith-imm4-dst-mach 16 op opc16-1 opc16-2 sem)
6253 (binary-arith-imm4-dst-mach 32 op opc32-1 opc32-2 sem)
6257 ;-------------------------------------------------------------
6258 ;<arith>.size:G src,dst -- for m16c and m32c
6259 ;-------------------------------------------------------------
6261 (define-pmacro (binary-arith-src-dst-defn mach srcgroup dstgroup smode dmode wstr op suffix encoding sem)
6262 (dni (.sym op mach wstr - srcgroup - dstgroup)
6263 (.str op wstr " dst" mach "-" srcgroup "-" dstgroup "-" dmode)
6265 (.str op wstr "$" suffix " ${src" mach "-" srcgroup "-" smode "},${dst" mach "-" dstgroup "-" dmode "}")
6267 (sem dmode (.sym src mach - srcgroup - smode) (.sym dst mach - dstgroup - dmode))
6272 (define-pmacro (binary-arith16-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem)
6274 (binary-arith-src-dst-defn 16 basic 16 smode dmode wstr op suffix
6275 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-basic- smode) (.sym dst16-16- dmode))
6277 (binary-arith-src-dst-defn 16 16-16 32 smode dmode wstr op suffix
6278 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-16- smode) (.sym dst16-32- dmode))
6280 (binary-arith-src-dst-defn 16 16-8 24 smode dmode wstr op suffix
6281 (+ opc1 opc2 (f-7-1 wbit) (.sym src16-16-8- smode) (.sym dst16-24- dmode))
6286 ; m32c Prefixed variants
6287 (define-pmacro (binary-arith32-src-dst-Prefixed smode dmode wstr wbit op suffix opc1 opc2 sem)
6289 (binary-arith-src-dst-defn 32 basic-Prefixed 24-Prefixed smode dmode wstr op suffix
6290 (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-basic-Prefixed- smode) (.sym dst32-24-Prefixed- dmode) (f-20-4 opc2))
6292 (binary-arith-src-dst-defn 32 24-24-Prefixed 48-Prefixed smode dmode wstr op suffix
6293 (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
6295 (binary-arith-src-dst-defn 32 24-16-Prefixed 40-Prefixed smode dmode wstr op suffix
6296 (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
6298 (binary-arith-src-dst-defn 32 24-8-Prefixed 32-Prefixed smode dmode wstr op suffix
6299 (+ (f-0-4 0) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit) (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-Prefixed- dmode) (f-20-4 opc2))
6305 (define-pmacro (binary-arith32-src-dst-defn smode dmode wstr wbit op suffix opc1 opc2 sem)
6307 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6308 ; define the absolute-indirect insns first in order to prevent them from being selected
6309 ; when the mode is register-indirect
6310 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-absolute-indirect smode dmode wstr op suffix
6311 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6312 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6314 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-absolute-indirect smode dmode wstr op suffix
6315 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6316 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6318 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-Prefixed smode dmode wstr op suffix
6319 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6320 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
6322 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-Prefixed smode dmode wstr op suffix
6323 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6324 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
6326 ; (binary-arith-src-dst-defn 32 24-24-absolute-indirect 48-indirect smode dmode wstr op suffix
6327 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6328 ; (.sym src32-24-24-absolute-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6330 ; (binary-arith-src-dst-defn 32 24-16-absolute-indirect 40-indirect smode dmode wstr op suffix
6331 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6332 ; (.sym src32-24-16-absolute-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6334 ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-absolute-indirect smode dmode wstr op suffix
6335 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6336 ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2))
6338 ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-absolute-indirect smode dmode wstr op suffix
6339 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6340 ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6342 ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-absolute-indirect smode dmode wstr op suffix
6343 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6344 ; (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6346 ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-absolute-indirect smode dmode wstr op suffix
6347 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6348 ; (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2))
6350 ; (binary-arith-src-dst-defn 32 basic-indirect 24-absolute-indirect smode dmode wstr op suffix
6351 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6352 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-absolute-indirect- dmode) (f-20-4 opc2))
6354 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-absolute-indirect smode dmode wstr op suffix
6355 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6356 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-absolute-indirect- dmode) (f-20-4 opc2))
6358 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-absolute-indirect smode dmode wstr op suffix
6359 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6360 ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-absolute-indirect- dmode) (f-20-4 opc2))
6362 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-absolute-indirect smode dmode wstr op suffix
6363 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6364 ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-absolute-indirect- dmode) (f-20-4 opc2))
6366 (binary-arith-src-dst-defn 32 basic-Unprefixed 16-Unprefixed smode dmode wstr op suffix
6367 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-basic-Unprefixed- smode) (.sym dst32-16-Unprefixed- dmode) (f-12-4 opc2))
6369 (binary-arith-src-dst-defn 32 16-24-Unprefixed 40-Unprefixed smode dmode wstr op suffix
6370 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-24-Unprefixed- smode) (.sym dst32-40-Unprefixed- dmode) (f-12-4 opc2))
6372 (binary-arith-src-dst-defn 32 16-16-Unprefixed 32-Unprefixed smode dmode wstr op suffix
6373 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-16-Unprefixed- smode) (.sym dst32-32-Unprefixed- dmode) (f-12-4 opc2))
6375 (binary-arith-src-dst-defn 32 16-8-Unprefixed 24-Unprefixed smode dmode wstr op suffix
6376 (+ (f-0-1 opc1) (f-7-1 wbit) (.sym src32-16-8-Unprefixed- smode) (.sym dst32-24-Unprefixed- dmode) (f-12-4 opc2))
6378 ; (binary-arith-src-dst-defn 32 basic-indirect 24-Prefixed smode dmode wstr op suffix
6379 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6380 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-Prefixed- dmode) (f-20-4 opc2))
6382 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-Prefixed smode dmode wstr op suffix
6383 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6384 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-Prefixed- dmode) (f-20-4 opc2))
6386 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-Prefixed smode dmode wstr op suffix
6387 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6388 ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-Prefixed- dmode) (f-20-4 opc2))
6390 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-Prefixed smode dmode wstr op suffix
6391 ; (+ (f-0-4 4) (f-4-4 1) (f-8-1 opc1) (f-15-1 wbit)
6392 ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-Prefixed- dmode) (f-20-4 opc2))
6394 ; (binary-arith-src-dst-defn 32 basic-Prefixed 24-indirect smode dmode wstr op suffix
6395 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6396 ; (.sym src32-basic-Prefixed- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2))
6398 ; (binary-arith-src-dst-defn 32 24-24-Prefixed 48-indirect smode dmode wstr op suffix
6399 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6400 ; (.sym src32-24-24-Prefixed- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6402 ; (binary-arith-src-dst-defn 32 24-16-Prefixed 40-indirect smode dmode wstr op suffix
6403 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6404 ; (.sym src32-24-16-Prefixed- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6406 ; (binary-arith-src-dst-defn 32 24-8-Prefixed 32-indirect smode dmode wstr op suffix
6407 ; (+ (f-0-4 0) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6408 ; (.sym src32-24-8-Prefixed- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2))
6410 ; (binary-arith-src-dst-defn 32 basic-indirect 24-indirect smode dmode wstr op suffix
6411 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6412 ; (.sym src32-basic-indirect- smode) (.sym dst32-24-indirect- dmode) (f-20-4 opc2))
6414 ; (binary-arith-src-dst-defn 32 24-24-indirect 48-indirect smode dmode wstr op suffix
6415 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6416 ; (.sym src32-24-24-indirect- smode) (.sym dst32-48-indirect- dmode) (f-20-4 opc2))
6418 ; (binary-arith-src-dst-defn 32 24-16-indirect 40-indirect smode dmode wstr op suffix
6419 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6420 ; (.sym src32-24-16-indirect- smode) (.sym dst32-40-indirect- dmode) (f-20-4 opc2))
6422 ; (binary-arith-src-dst-defn 32 24-8-indirect 32-indirect smode dmode wstr op suffix
6423 ; (+ (f-0-4 4) (f-4-4 9) (f-8-1 opc1) (f-15-1 wbit)
6424 ; (.sym src32-24-8-indirect- smode) (.sym dst32-32-indirect- dmode) (f-20-4 opc2))
6429 (define-pmacro (binary-arith-src-dst-mach mach op suffix opc1 opc2 sem)
6431 (.apply (.sym binary-arith mach -src-dst-defn) (QI QI .b 0 op suffix opc1 opc2 sem))
6432 (.apply (.sym binary-arith mach -src-dst-defn) (HI HI .w 1 op suffix opc1 opc2 sem))
6436 (define-pmacro (binary-arith-src-dst op suffix opc16-1 opc16-2 opc32-1 opc32-2 sem)
6438 (binary-arith-src-dst-mach 16 op suffix opc16-1 opc16-2 sem)
6439 (binary-arith-src-dst-mach 32 op suffix opc32-1 opc32-2 sem)
6443 ;-------------------------------------------------------------
6444 ;<arith>.size:S #imm,dst -- for m32c
6445 ;-------------------------------------------------------------
6447 (define-pmacro (binary-arith32-s-imm-dst-defn src dstgroup mode wstr op encoding sem)
6448 (dni (.sym op 32 wstr - imm-S - dstgroup)
6449 (.str op wstr " 32-imm-S-" dstgroup "-" mode)
6451 (.str op wstr "$S #${" src "},${dst32-" dstgroup "-" mode "}")
6453 (sem mode src (.sym dst32- dstgroup - mode))
6457 (define-pmacro (binary-arith32-z-imm-dst-defn src dstgroup mode wstr op encoding sem)
6458 (dni (.sym op 32 wstr - imm-Z - dstgroup)
6459 (.str op wstr " 32-imm-Z-" dstgroup "-" mode)
6461 (.str op wstr "$Z #0,${dst32-" dstgroup "-" mode "}")
6463 (sem mode (const 0) (.sym dst32- dstgroup - mode))
6467 (define-pmacro (binary-arith32-s-imm-dst mode wstr wbit op opc1 opc2 sem)
6469 ; (binary-arith32-s-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op
6470 ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-absolute-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-32- mode))
6472 (binary-arith32-s-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op
6473 (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-8- mode))
6475 (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op
6476 (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-24- mode))
6478 (binary-arith32-s-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op
6479 (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit) (.sym Imm-16- mode))
6481 ; (binary-arith32-s-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op
6482 ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-8-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-24- mode))
6487 (define-pmacro (binary-arith32-z-imm-dst mode wstr wbit op opc1 opc2 sem)
6489 ; (binary-arith32-z-imm-dst-defn (.sym Imm-32- mode) 2-S-absolute-indirect mode wstr op
6490 ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-absolute-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-32- mode))
6492 (binary-arith32-z-imm-dst-defn (.sym Imm-8- mode) 2-S-basic mode wstr op
6493 (+ (f-0-2 opc1) (.sym dst32-2-S-basic- mode) (f-4-3 opc2) (f-7-1 wbit))
6495 (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-16 mode wstr op
6496 (+ (f-0-2 opc1) (.sym dst32-2-S-16- mode) (f-4-3 opc2) (f-7-1 wbit))
6498 (binary-arith32-z-imm-dst-defn (.sym Imm-16- mode) 2-S-8 mode wstr op
6499 (+ (f-0-2 opc1) (.sym dst32-2-S-8- mode) (f-4-3 opc2) (f-7-1 wbit))
6501 ; (binary-arith32-z-imm-dst-defn (.sym Imm-24- mode) 2-S-8-indirect mode wstr op
6502 ; (+ (f-0-4 0) (f-4-4 9) (f-8-2 opc1) (.sym dst32-2-S-8-indirect- mode) (f-12-3 opc2) (f-15-1 wbit) (.sym Imm-24- mode))
6507 ;-------------------------------------------------------------
6508 ;<arith>.L:S #imm1,An -- for m32c
6509 ;-------------------------------------------------------------
6511 (define-pmacro (binary-arith32-l-s-imm1-an op opc1 opc2 sem)
6513 (dni (.sym op 32.l-s-imm1-S-an)
6514 (.str op ".l 32-imm1-S-an")
6516 (.str op ".l$S #${Imm1-S},${dst32-an-S}")
6517 (+ opc1 Imm1-S opc2 dst32-an-S)
6518 (sem SI Imm1-S dst32-an-S)
6523 ;-------------------------------------------------------------
6524 ;<arith>.L:Q #imm3,sp -- for m32c
6525 ;-------------------------------------------------------------
6527 (define-pmacro (binary-arith32-l-q-imm3-sp op opc1 opc2 sem)
6529 (dni (.sym op 32.l-imm3-Q)
6530 (.str op ".l 32-imm3-Q")
6532 (.str op ".l$Q #${Imm3-S},sp")
6533 (+ opc1 Imm3-S opc2)
6539 ;-------------------------------------------------------------
6540 ;<arith>.L:S #imm8,sp -- for m32c
6541 ;-------------------------------------------------------------
6543 (define-pmacro (binary-arith32-l-s-imm8-sp op opc1 opc2 opc3 opc4 sem)
6545 (dni (.sym op 32.l-imm8-S)
6546 (.str op ".l 32-imm8-S")
6548 (.str op ".l$S #${Imm-16-QI},sp")
6549 (+ opc1 opc2 opc3 opc4 Imm-16-QI)
6550 (sem SI Imm-16-QI sp)
6555 ;-------------------------------------------------------------
6556 ;<arith>.L:G #imm16,sp -- for m32c
6557 ;-------------------------------------------------------------
6559 (define-pmacro (binary-arith32-l-g-imm16-sp op opc1 opc2 opc3 opc4 sem)
6561 (dni (.sym op 32.l-imm16-G)
6562 (.str op ".l 32-imm16-G")
6564 (.str op ".l$G #${Imm-16-HI},sp")
6565 (+ opc1 opc2 opc3 opc4 Imm-16-HI)
6566 (sem SI Imm-16-HI sp)
6571 ;-------------------------------------------------------------
6572 ;<arith>jnz.size #imm4,dst,label -- for m16c and m32c
6573 ;-------------------------------------------------------------
6575 (define-pmacro (arith-jnz-imm4-dst-defn mach src dstgroup label mode wstr op encoding sem)
6576 (dni (.sym op mach wstr - imm4 - dstgroup)
6577 (.str op wstr " " mach "-imm4-" dstgroup "-" label "-" mode)
6579 (.str op wstr " #${" src "},${dst" mach "-" dstgroup "-" mode "},${" label "}")
6581 (sem mode src (.sym dst mach - dstgroup - mode) label)
6586 (define-pmacro (arith-jnz16-imm4-dst-defn mode wstr wbit op i4n opc1 opc2 sem)
6588 (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) basic Lab-16-8 mode wstr op
6589 (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-basic- mode) Lab-16-8)
6591 (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) 16-16 Lab-32-8 mode wstr op
6592 (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-16-16- mode) Lab-16-8)
6594 (arith-jnz-imm4-dst-defn 16 (.sym Imm-8- i4n) 16-8 Lab-24-8 mode wstr op
6595 (+ opc1 opc2 (f-7-1 wbit) (.sym Imm-8- i4n) (.sym dst16-16-8- mode) Lab-16-8)
6601 (define-pmacro (arith-jnz32-imm4-dst-defn mode wstr wbit op i4n opc1 opc2 sem)
6603 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) basic-Unprefixed Lab-16-8 mode wstr op
6604 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-16-8)
6606 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-24-Unprefixed Lab-40-8 mode wstr op
6607 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-40-8)
6609 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-16-Unprefixed Lab-32-8 mode wstr op
6610 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-32-8)
6612 (arith-jnz-imm4-dst-defn 32 (.sym Imm-12- i4n) 16-8-Unprefixed Lab-24-8 mode wstr op
6613 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) (.sym Imm-12- i4n) Lab-24-8)
6618 (define-pmacro (arith-jnz-imm4-dst-mach mach op i4n opc1 opc2 sem)
6620 (.apply (.sym arith-jnz mach -imm4-dst-defn) (QI .b 0 op i4n opc1 opc2 sem))
6621 (.apply (.sym arith-jnz mach -imm4-dst-defn) (HI .w 1 op i4n opc1 opc2 sem))
6625 (define-pmacro (arith-jnz-imm4-dst op i4n opc16-1 opc16-2 opc32-1 opc32-2 sem)
6627 (arith-jnz-imm4-dst-mach 16 op i4n opc16-1 opc16-2 sem)
6628 (arith-jnz-imm4-dst-mach 32 op i4n opc32-1 opc32-2 sem)
6632 ;-------------------------------------------------------------
6633 ;mov.size dsp8[sp],dst -- for m16c and m32c
6634 ;-------------------------------------------------------------
6635 (define-pmacro (mov-dspsp-dst-defn mach dstgroup dsp mode wstr op encoding sem)
6636 (dni (.sym op mach wstr -dspsp-dst- dstgroup)
6637 (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
6639 (.str op wstr "$G ${" dsp "}[sp],${dst" mach "-" dstgroup "-" mode "}")
6641 (sem mach mode dsp (.sym dst mach - dstgroup - mode))
6644 (define-pmacro (mov-src-dspsp-defn mach dstgroup dsp mode wstr op encoding sem)
6645 (dni (.sym op mach wstr -dst-dspsp- dstgroup)
6646 (.str op wstr " " mach "-dsp[sp]-" dstgroup "-" dsp "-" mode)
6648 (.str op wstr "$G ${dst" mach "-" dstgroup "-" mode "},${" dsp "}[sp]")
6650 (sem mach mode (.sym dst mach - dstgroup - mode) dsp)
6655 (define-pmacro (mov16-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem)
6657 (mov-dspsp-dst-defn 16 basic Dsp-16-s8 mode wstr op
6658 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-s8)
6660 (mov-dspsp-dst-defn 16 16-16 Dsp-32-s8 mode wstr op
6661 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-s8)
6663 (mov-dspsp-dst-defn 16 16-8 Dsp-24-s8 mode wstr op
6664 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-s8)
6669 (define-pmacro (mov16-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem)
6671 (mov-src-dspsp-defn 16 basic Dsp-16-s8 mode wstr op
6672 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-basic- mode) Dsp-16-s8)
6674 (mov-src-dspsp-defn 16 16-16 Dsp-32-s8 mode wstr op
6675 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-16- mode) Dsp-32-s8)
6677 (mov-src-dspsp-defn 16 16-8 Dsp-24-s8 mode wstr op
6678 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16-8- mode) Dsp-24-s8)
6684 (define-pmacro (mov32-dspsp-dst-defn mode wstr wbit op opc1 opc2 opc3 sem)
6686 (mov-dspsp-dst-defn 32 basic-Unprefixed Dsp-16-s8 mode wstr op
6687 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-s8)
6689 (mov-dspsp-dst-defn 32 16-24-Unprefixed Dsp-40-s8 mode wstr op
6690 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-40-s8)
6692 (mov-dspsp-dst-defn 32 16-16-Unprefixed Dsp-32-s8 mode wstr op
6693 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-32-s8)
6695 (mov-dspsp-dst-defn 32 16-8-Unprefixed Dsp-24-s8 mode wstr op
6696 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-24-s8)
6700 (define-pmacro (mov32-src-dspsp-defn mode wstr wbit op opc1 opc2 opc3 sem)
6702 (mov-src-dspsp-defn 32 basic-Unprefixed Dsp-16-s8 mode wstr op
6703 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-basic-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-16-s8)
6705 (mov-src-dspsp-defn 32 16-24-Unprefixed Dsp-40-s8 mode wstr op
6706 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-24-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-40-s8)
6708 (mov-src-dspsp-defn 32 16-16-Unprefixed Dsp-32-s8 mode wstr op
6709 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-16-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-32-s8)
6711 (mov-src-dspsp-defn 32 16-8-Unprefixed Dsp-24-s8 mode wstr op
6712 (+ (f-0-4 opc1) (f-7-1 wbit) (.sym dst32-16-8-Unprefixed- mode) (f-10-2 opc2) (f-12-4 opc3) Dsp-24-s8)
6717 (define-pmacro (mov-src-dspsp-mach mach op opc1 opc2 opc3 sem)
6719 (.apply (.sym mov mach -src-dspsp-defn) (QI .b 0 op opc1 opc2 opc3 sem))
6720 (.apply (.sym mov mach -src-dspsp-defn) (HI .w 1 op opc1 opc2 opc3 sem))
6724 (define-pmacro (mov-dspsp-dst-mach mach op opc1 opc2 opc3 sem)
6726 (.apply (.sym mov mach -dspsp-dst-defn) (QI .b 0 op opc1 opc2 opc3 sem))
6727 (.apply (.sym mov mach -dspsp-dst-defn) (HI .w 1 op opc1 opc2 opc3 sem))
6731 (define-pmacro (mov-dspsp-dst op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6733 (mov-dspsp-dst-mach 16 op opc16-1 opc16-2 opc16-3 sem)
6734 (mov-dspsp-dst-mach 32 op opc32-1 opc32-2 opc32-3 sem)
6737 (define-pmacro (mov-src-dspsp op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6739 (mov-src-dspsp-mach 16 op opc16-1 opc16-2 opc16-3 sem)
6740 (mov-src-dspsp-mach 32 op opc32-1 opc32-2 opc32-3 sem)
6744 ;-------------------------------------------------------------
6745 ; lde dsp24,dst -- for m16c
6746 ;-------------------------------------------------------------
6748 (define-pmacro (lde-dst-dsp mode wstr wbit dstgroup srcdisp)
6751 (dni (.sym lde wstr - dstgroup -u20)
6752 (.str "lde" wstr "-" dstgroup "-u20")
6754 (.str "lde" wstr " ${" srcdisp "},${dst16-" dstgroup "-" mode "}")
6755 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x8)
6756 (.sym dst16- dstgroup - mode) srcdisp)
6760 (dni (.sym lde wstr - dstgroup -u20a0)
6761 (.str "lde" wstr "-" dstgroup "-u20a0")
6763 (.str "lde" wstr " ${" srcdisp "}[a0],${dst16-" dstgroup "-" mode "}")
6764 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x9)
6765 (.sym dst16- dstgroup - mode) srcdisp)
6769 (dni (.sym lde wstr - dstgroup -a1a0)
6770 (.str "lde" wstr "-" dstgroup "-a1a0")
6772 (.str "lde" wstr " [a1a0],${dst16-" dstgroup "-" mode "}")
6773 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #xa)
6774 (.sym dst16- dstgroup - mode))
6780 (define-pmacro (lde-dst mode wstr wbit)
6783 (lde-dst-dsp mode wstr wbit basic Dsp-16-u20)
6784 (lde-dst-dsp mode wstr wbit 16-8 Dsp-24-u20)
6785 (lde-dst-dsp mode wstr wbit 16-16 Dsp-32-u20)
6789 ;-------------------------------------------------------------
6790 ; ste dst,dsp24 -- for m16c
6791 ;-------------------------------------------------------------
6793 (define-pmacro (ste-dst-dsp mode wstr wbit dstgroup srcdisp)
6796 (dni (.sym ste wstr - dstgroup -u20)
6797 (.str "ste" wstr "-" dstgroup "-u20")
6799 (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},${" srcdisp "}")
6800 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x0)
6801 (.sym dst16- dstgroup - mode) srcdisp)
6805 (dni (.sym ste wstr - dstgroup -u20a0)
6806 (.str "ste" wstr "-" dstgroup "-u20a0")
6808 (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},${" srcdisp "}[a0]")
6809 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x1)
6810 (.sym dst16- dstgroup - mode) srcdisp)
6814 (dni (.sym ste wstr - dstgroup -a1a0)
6815 (.str "ste" wstr "-" dstgroup "-a1a0")
6817 (.str "ste" wstr " ${dst16-" dstgroup "-" mode "},[a1a0]")
6818 (+ (f-0-4 #x7) (f-4-3 #x2) (f-7-1 wbit) (f-8-4 #x2)
6819 (.sym dst16- dstgroup - mode))
6825 (define-pmacro (ste-dst mode wstr wbit)
6828 (ste-dst-dsp mode wstr wbit basic Dsp-16-u20)
6829 (ste-dst-dsp mode wstr wbit 16-8 Dsp-24-u20)
6830 (ste-dst-dsp mode wstr wbit 16-16 Dsp-32-u20)
6834 ;=============================================================
6836 ;-------------------------------------------------------------
6838 (define-pmacro (div-sem divop modop opmode reg src quot rem max min)
6841 (set obit (const BI 1))
6842 (sequence ((opmode quot-result) (opmode rem-result))
6843 (set quot-result (divop opmode (ext opmode reg) src))
6844 (set rem-result (modop opmode (ext opmode reg) src))
6845 (set obit (orif (gt opmode quot-result max)
6846 (lt opmode quot-result min)))
6847 (set quot quot-result)
6848 (set rem rem-result))))
6851 ;<divop>.size #imm -- for m16c and m32c
6852 (define-pmacro (div-imm-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem)
6853 (dni (.sym op mach wstr - src)
6854 (.str op mach wstr "-" src)
6856 (.str op wstr " #${" src "}")
6858 (sem divop modop opmode reg src quot rem max min)
6861 (define-pmacro (div16-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem)
6862 (div-imm-defn 16 wstr op (.sym Imm-16 - smode)
6863 (+ opc1 opc2 (f-7-1 wbit) opc3 opc4 (.sym Imm-16 - smode))
6864 divop modop opmode reg quot rem max min
6867 (define-pmacro (div32-imm-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 opc4 sem)
6868 (div-imm-defn 32 wstr op (.sym Imm-16 - smode)
6869 (+ (f-0-4 opc1) (f-4-4 opc2) (f-8-3 opc3) (f-11-1 wbit) (f-12-4 opc4) (.sym Imm-16 - smode))
6870 divop modop opmode reg quot rem max min
6873 (define-pmacro (div-imm-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 opc4 sem)
6875 (.apply (.sym div mach -imm-defn) (QI .b 0 op divop modop opmode R0 R0l R0h max-QI min-QI opc1 opc2 opc3 opc4 sem))
6876 (.apply (.sym div mach -imm-defn) (HI .w 1 op divop modop opmode R2R0 R0 R2 max-HI min-HI opc1 opc2 opc3 opc4 sem))
6879 (define-pmacro (div-imm op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 opc16-4 opc32-1 opc32-2 opc32-3 opc32-4 sem)
6881 (div-imm-mach 16 op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 opc16-4 sem)
6882 (div-imm-mach 32 op divop modop opmode max-QI min-QI max-HI min-HI opc32-1 opc32-2 opc32-3 opc32-4 sem)
6886 ;<divop>.size src -- for m16c and m32c
6887 (define-pmacro (div-src-defn mach wstr op src encoding divop modop opmode reg quot rem max min sem)
6888 (dni (.sym op mach wstr - src)
6889 (.str op mach wstr "-" src)
6891 (.str op wstr " ${" src "}")
6893 (sem divop modop opmode reg src quot rem max min)
6896 (define-pmacro (div16-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem)
6897 (div-src-defn 16 wstr op (.sym dst16-16 - smode)
6898 (+ opc1 opc2 (f-7-1 wbit) opc3 (.sym dst16-16 - smode))
6899 divop modop opmode reg quot rem max min
6902 (define-pmacro (div32-src-defn smode wstr wbit op divop modop opmode reg quot rem max min opc1 opc2 opc3 sem)
6904 ; Multi insns are tried for assembly in the reverse order in which they appear here, so
6905 ; define the absolute-indirect insns first in order to prevent them from being selected
6906 ; when the mode is register-indirect
6907 ; (div-src-defn 32 wstr op (.sym dst32-24-absolute-indirect- smode)
6908 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (f-18-2 opc2) (f-20-4 opc3) (.sym dst32-24-absolute-indirect - smode))
6909 ; divop modop opmode reg quot rem max min
6911 (div-src-defn 32 wstr op (.sym dst32-16-Unprefixed- smode)
6912 (+ (f-0-4 opc1) (f-7-1 wbit) (f-10-2 opc2) (f-12-4 opc3) (.sym dst32-16-Unprefixed- smode))
6913 divop modop opmode reg quot rem max min
6915 ; (div-src-defn 32 wstr op (.sym dst32-24-indirect- smode)
6916 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 opc1) (f-15-1 wbit) (f-18-2 opc2) (f-20-4 opc3) (.sym dst32-24-indirect - smode))
6917 ; divop modop opmode reg quot rem max min
6921 (define-pmacro (div-src-mach mach op divop modop opmode max-QI min-QI max-HI min-HI opc1 opc2 opc3 sem)
6923 (.apply (.sym div mach -src-defn) (QI .b 0 op divop modop opmode R0 R0l R0h max-QI min-QI opc1 opc2 opc3 sem))
6924 (.apply (.sym div mach -src-defn) (HI .w 1 op divop modop opmode R2R0 R0 R2 max-HI min-HI opc1 opc2 opc3 sem))
6927 (define-pmacro (div-src op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6929 (div-src-mach 16 op divop modop opmode max-QI min-QI max-HI min-HI opc16-1 opc16-2 opc16-3 sem)
6930 (div-src-mach 32 op divop modop opmode max-QI min-QI max-HI min-HI opc32-1 opc32-2 opc32-3 sem)
6934 ;=============================================================
6937 (define-pmacro (bit-insn-defn mach op suffix opnd encoding sem)
6938 (dni (.sym op mach - suffix - opnd)
6939 (.str op mach ":" suffix " " opnd)
6941 (.str op "$" suffix " ${" opnd "}")
6947 (define-pmacro (bitsrc16-defn op opc1 opc2 opc3 sem)
6948 (bit-insn-defn 16 op X bit16-16
6949 (+ opc1 opc2 opc3 bit16-16)
6953 (define-pmacro (bitsrc32-defn op opc1 opc2 opc3 sem)
6955 (bit-insn-defn 32 op X bit32-24-Prefixed
6956 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) bit32-24-Prefixed (f-15-1 opc2) (f-18-3 opc3))
6961 (define-pmacro (bitsrc-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6963 (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem)
6964 (bitsrc32-defn op opc32-1 opc32-2 opc32-3 sem)
6968 (define-pmacro (bitdst16-defn op opc1 opc2 opc3 opc4 opc5 opc6 sem)
6970 (bit-insn-defn 16 op G bit16-16-basic (+ opc1 opc2 opc3 bit16-16-basic) sem)
6971 (bit-insn-defn 16 op G bit16-16-16 (+ opc1 opc2 opc3 bit16-16-16) sem)
6972 (bit-insn-defn 16 op S bit16-11-S (+ opc4 opc5 opc6 bit16-11-S) sem)
6973 (bit-insn-defn 16 op G bit16-16-8 (+ opc1 opc2 opc3 bit16-16-8) sem)
6977 (define-pmacro (bitdst32-defn op opc1 opc2 opc3 sem)
6979 (bit-insn-defn 32 op X bit32-16-Unprefixed
6980 (+ (f-0-4 opc1) bit32-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3))
6985 (define-pmacro (bitdstnos-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
6987 (bitsrc16-defn op opc16-1 opc16-2 opc16-3 sem)
6988 (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem)
6992 (define-pmacro (bitdst-insn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 opc32-1 opc32-2 opc32-3 sem)
6994 (bitdst16-defn op opc16-1 opc16-2 opc16-3 opc16-4 opc16-5 opc16-6 sem)
6995 (bitdst32-defn op opc32-1 opc32-2 opc32-3 sem)
6999 ;=============================================================
7002 (define-pmacro (bitcond-insn-defn mach op bit-opnd cond-opnd encoding sem)
7003 (dni (.sym op mach - bit-opnd - cond-opnd)
7004 (.str op mach " " bit-opnd " " cond-opnd)
7006 (.str op "${" cond-opnd "} ${" bit-opnd "}")
7008 (sem mach bit-opnd cond-opnd)
7012 (define-pmacro (bitcond16-defn op opc1 opc2 opc3 sem)
7014 (bitcond-insn-defn 16 op bit16-16-basic cond16-16 (+ opc1 opc2 opc3 bit16-16-basic cond16-16) sem)
7015 (bitcond-insn-defn 16 op bit16-16-16 cond16-32 (+ opc1 opc2 opc3 bit16-16-16 cond16-32) sem)
7016 (bitcond-insn-defn 16 op bit16-16-8 cond16-24 (+ opc1 opc2 opc3 bit16-16-8 cond16-24) sem)
7020 (define-pmacro (bitcond32-defn op opc1 opc2 opc3 sem)
7022 (bitcond-insn-defn 32 op bit32-16-24-Unprefixed cond32-40
7023 (+ (f-0-4 opc1) bit32-16-24-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-40)
7025 (bitcond-insn-defn 32 op bit32-16-16-Unprefixed cond32-32
7026 (+ (f-0-4 opc1) bit32-16-16-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-32)
7028 (bitcond-insn-defn 32 op bit32-16-8-Unprefixed cond32-24
7029 (+ (f-0-4 opc1) bit32-16-8-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-24)
7031 (bitcond-insn-defn 32 op bit32-basic-Unprefixed cond32-16
7032 (+ (f-0-4 opc1) bit32-basic-Unprefixed (f-7-1 opc2) (f-10-3 opc3) cond32-16)
7037 (define-pmacro (bitcond-insn op opc16-1 opc16-2 opc16-3 opc32-1 opc32-2 opc32-3 sem)
7039 (bitcond16-defn op opc16-1 opc16-2 opc16-3 sem)
7040 (bitcond32-defn op opc32-1 opc32-2 opc32-3 sem)
7044 ;=============================================================
7045 ;<insn>.size #imm1,#imm2,dst -- for m32c
7047 (define-pmacro (insn-imm1-imm2-dst-defn src1 src2 dstgroup xmode wstr op encoding sem)
7048 (dni (.sym op 32 wstr - src1 - src2 - dstgroup)
7049 (.str op 32 wstr "-" src1 "-" src2 "-" dstgroup "-" xmode)
7051 (.str op wstr " #${" src1 "},#${" src2 "},${dst32-" dstgroup "-" xmode "}")
7053 (sem xmode src1 src2 (.sym dst32- dstgroup - xmode))
7057 ; m32c Prefixed variants
7058 (define-pmacro (insn32-imm1-imm2-dst-Prefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem)
7060 (insn-imm1-imm2-dst-defn (.sym Imm-48- xmode) (.sym Imm- base4 - xmode) 24-24-Prefixed xmode wstr op
7061 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
7062 (.sym dst32-24-24-Prefixed- xmode) (.sym Imm-48- xmode) (.sym Imm- base4 - xmode))
7064 (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base3 - xmode) 24-16-Prefixed xmode wstr op
7065 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
7066 (.sym dst32-24-16-Prefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base3 - xmode))
7068 (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base2 - xmode) 24-8-Prefixed xmode wstr op
7069 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
7070 (.sym dst32-24-8-Prefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base2 - xmode))
7072 (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base1 - xmode) basic-Prefixed xmode wstr op
7073 (+ (f-0-4 0) (f-4-4 1) (f-8-4 opc1) (f-18-2 opc2) (f-15-1 wbit) (f-20-4 opc3)
7074 (.sym dst32-basic-Prefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base1 - xmode))
7079 ; m32c Unprefixed variants
7080 (define-pmacro (insn32-imm1-imm2-dst-Unprefixed-defn xmode wstr wbit base1 base2 base3 base4 op opc1 opc2 opc3 sem)
7082 (insn-imm1-imm2-dst-defn (.sym Imm-40- xmode) (.sym Imm- base4 - xmode) 16-24-Unprefixed xmode wstr op
7083 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7084 (.sym dst32-16-24-Unprefixed- xmode) (.sym Imm-40- xmode) (.sym Imm- base4 - xmode))
7086 (insn-imm1-imm2-dst-defn (.sym Imm-32- xmode) (.sym Imm- base3 - xmode) 16-16-Unprefixed xmode wstr op
7087 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7088 (.sym dst32-16-16-Unprefixed- xmode) (.sym Imm-32- xmode) (.sym Imm- base3 - xmode))
7090 (insn-imm1-imm2-dst-defn (.sym Imm-24- xmode) (.sym Imm- base2 - xmode) 16-8-Unprefixed xmode wstr op
7091 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7092 (.sym dst32-16-8-Unprefixed- xmode) (.sym Imm-24- xmode) (.sym Imm- base2 - xmode))
7094 (insn-imm1-imm2-dst-defn (.sym Imm-16- xmode) (.sym Imm- base1 - xmode) basic-Unprefixed xmode wstr op
7095 (+ (f-0-4 opc1) (f-10-2 opc2) (f-7-1 wbit) (f-12-4 opc3)
7096 (.sym dst32-basic-Unprefixed- xmode) (.sym Imm-16- xmode) (.sym Imm- base1 - xmode))
7101 (define-pmacro (insn-imm1-imm2-dst-Prefixed op opc32-1 opc32-2 opc32-3 sem)
7103 (insn32-imm1-imm2-dst-Prefixed-defn QI .b 0 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem)
7104 (insn32-imm1-imm2-dst-Prefixed-defn HI .w 1 40 48 56 64 op opc32-1 opc32-2 opc32-3 sem)
7107 (define-pmacro (insn-imm1-imm2-dst-Unprefixed op opc32-1 opc32-2 opc32-3 sem)
7109 (insn32-imm1-imm2-dst-Unprefixed-defn QI .b 0 24 32 40 48 op opc32-1 opc32-2 opc32-3 sem)
7110 (insn32-imm1-imm2-dst-Unprefixed-defn HI .w 1 32 40 48 56 op opc32-1 opc32-2 opc32-3 sem)
7114 ;=============================================================
7116 ;-------------------------------------------------------------
7118 ;-------------------------------------------------------------
7120 (define-pmacro (abs-sem mode dst)
7121 (sequence ((mode result))
7122 (set result (abs mode dst))
7123 (set obit (eq result dst))
7124 (set-z-and-s result)
7127 (unary-insn abs (f-0-4 7) (f-4-3 3) (f-8-4 #xF) #xA #x1 #xF abs-sem)
7129 ;-------------------------------------------------------------
7130 ; adcf - addition carry flag
7131 ;-------------------------------------------------------------
7133 (define-pmacro (adcf-sem mode dst)
7134 (sequence ((mode result))
7135 (set result (addc mode dst 0 cbit))
7136 (set obit (add-oflag mode dst 0 cbit))
7137 (set cbit (add-cflag mode dst 0 cbit))
7138 (set-z-and-s result)
7141 (unary-insn adcf (f-0-4 7) (f-4-3 3) (f-8-4 #xE) #xB #x1 #xE adcf-sem)
7143 ;-------------------------------------------------------------
7144 ; add - binary addition
7145 ;-------------------------------------------------------------
7147 (define-pmacro (add-sem mode src1 dst)
7148 (sequence ((mode result))
7149 (set result (add mode src1 dst))
7150 (set obit (add-oflag mode src1 dst 0))
7151 (set cbit (add-cflag mode src1 dst 0))
7152 (set-z-and-s result)
7156 ; add.L:G #imm32,dst (m32 #2)
7157 (binary-arith32-imm-dst-defn SI SI .l 0 add G #x8 #x3 #x1 add-sem)
7158 ; add.size:G #imm,dst (m16 #1 m32 #1)
7159 (binary-arith-imm-dst add G (f-0-4 7) (f-4-3 3) (f-8-4 4) #x8 #x2 #xE add-sem)
7160 ; add.size:Q #imm4,dst (m16 #2 m32 #3)
7161 (binary-arith-imm4-dst add (f-0-4 #xC) (f-4-3 4) #x7 #x3 add-sem)
7162 (binary-arith32-imm4-dst-defn SI .l 1 0 add #x7 #x3 add-sem)
7163 ; add.b:S #imm8,dst3 (m16 #3)
7164 (binary-arith16-b-S-imm8-dst3 add ".b" (f-0-4 8) (f-4-1 0) add-sem)
7165 ; add.BW:Q #imm4,sp (m16 #7)
7166 (binary-arith16-Q-sp add (f-0-4 7) (f-4-4 #xD) (f-8-4 #xB) add-sem)
7167 (dnmi add16-bQ-sp "add16-bQ-sp" ()
7168 "add.b:q #${Imm-12-s4},sp"
7169 (emit add16-wQ-sp Imm-12-s4))
7170 ; add.BW:G #imm,sp (m16 #6)
7171 (binary-arith16-G-sp add (f-0-4 7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #xB) add-sem)
7172 ; add.BW:G src,dst (m16 #4 m32 #6)
7173 (binary-arith-src-dst add G (f-0-4 #xA) (f-4-3 0) #x1 #x8 add-sem)
7174 ; add.B.S src2,r0l/r0h (m16 #5)
7175 (binary-arith16-b-S-src2 add (f-0-4 2) (f-4-1 0) add-sem)
7176 ; add.L:G src,dst (m32 #7)
7177 (binary-arith32-src-dst-defn SI SI .l 1 add G #x1 #x2 add-sem)
7178 ; add.L:S #imm{1,2},A0/A1 (m32 #5)
7179 (binary-arith32-l-s-imm1-an add (f-0-2 2) (f-3-4 6) add-sem)
7180 ; add.L:Q #imm3,sp (m32 #9)
7181 (binary-arith32-l-q-imm3-sp add (f-0-2 1) (f-4-3 1) add-sem)
7182 ; add.L:S #imm8,sp (m32 #10)
7183 (binary-arith32-l-s-imm8-sp add (f-0-4 #xb) (f-4-4 6) (f-8-4 0) (f-12-4 3) add-sem)
7184 ; add.L:G #imm16,sp (m32 #8)
7185 (binary-arith32-l-g-imm16-sp add (f-0-4 #xb) (f-4-4 6) (f-8-4 1) (f-12-4 3) add-sem)
7186 ; add.BW:S #imm,dst2 (m32 #4)
7187 (binary-arith32-s-imm-dst QI .b 0 add #x0 #x3 add-sem)
7188 (binary-arith32-s-imm-dst HI .w 1 add #x0 #x3 add-sem)
7190 ;-------------------------------------------------------------
7191 ; adc - binary add with carry
7192 ;-------------------------------------------------------------
7194 (define-pmacro (addc-sem mode src dst)
7195 (sequence ((mode result))
7196 (set result (addc mode src dst cbit))
7197 (set obit (add-oflag mode src dst cbit))
7198 (set cbit (add-cflag mode src dst cbit))
7199 (set-z-and-s result)
7203 ; adc.size:G #imm,dst
7204 (binary-arith16-imm-dst-defn QI QI .b 0 adc X (f-0-4 7) (f-4-3 3) (f-8-4 6) addc-sem)
7205 (binary-arith16-imm-dst-defn HI HI .w 1 adc X (f-0-4 7) (f-4-3 3) (f-8-4 6) addc-sem)
7206 (binary-arith32-imm-dst-Prefixed QI QI .b 0 adc X #x8 #x2 #xE addc-sem)
7207 (binary-arith32-imm-dst-Prefixed HI HI .w 1 adc X #x8 #x2 #xE addc-sem)
7210 (binary-arith16-src-dst-defn QI QI .b 0 adc X (f-0-4 #xB) (f-4-3 0) addc-sem)
7211 (binary-arith16-src-dst-defn HI HI .w 1 adc X (f-0-4 #xB) (f-4-3 0) addc-sem)
7212 (binary-arith32-src-dst-Prefixed QI QI .b 0 adc X #x1 #x4 addc-sem)
7213 (binary-arith32-src-dst-Prefixed HI HI .w 1 adc X #x1 #x4 addc-sem)
7215 ;-------------------------------------------------------------
7216 ; dadc - decimal add with carry
7217 ; dadd - decimal addition
7218 ;-------------------------------------------------------------
7220 (define-pmacro (dadc-sem mode src dst)
7221 (sequence ((mode result))
7222 (set result (subc mode dst src (not cbit)))
7223 (set cbit (sub-cflag mode dst src (not cbit)))
7224 (set-z-and-s result)
7228 (define-pmacro (decimal-subtraction16-insn op opc1 opc2)
7231 (dni (.sym op 16.b-imm8)
7232 (.str op ".b #imm8")
7234 (.str op ".b #${Imm-16-QI}")
7235 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc1) Imm-16-QI)
7236 ((.sym op -sem) QI Imm-16-QI R0l)
7239 (dni (.sym op 16.w-imm16)
7240 (.str op ".b #imm16")
7242 (.str op ".w #${Imm-16-HI}")
7243 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc1) Imm-16-HI)
7244 ((.sym op -sem) HI Imm-16-HI R0)
7247 (dni (.sym op 16.b-r0h-r0l)
7248 (.str op ".b r0h,r0l")
7250 (.str op ".b r0h,r0l")
7251 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 opc2))
7252 ((.sym op -sem) QI R0h R0l)
7255 (dni (.sym op 16.w-r1-r0)
7256 (.str op ".b r1,r0")
7258 (.str op ".w r1,r0")
7259 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 opc2))
7260 ((.sym op -sem) HI R1 R0)
7266 (decimal-subtraction16-insn dadc #xE #x6 )
7268 ; dadc.size #imm,dst
7269 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadc X #x8 #x0 #xE dadc-sem)
7270 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadc X #x8 #x0 #xE dadc-sem)
7272 (binary-arith32-src-dst-Prefixed QI QI .b 0 dadc X #x1 #x8 dadc-sem)
7273 (binary-arith32-src-dst-Prefixed HI HI .w 1 dadc X #x1 #x8 dadc-sem)
7275 (define-pmacro (dadd-sem mode src dst)
7276 (sequence ((mode result))
7277 (set result (subc mode dst src 0))
7278 (set cbit (sub-cflag mode dst src 0))
7279 (set-z-and-s result)
7284 (decimal-subtraction16-insn dadd #xC #x4)
7286 ; dadd.size #imm,dst
7287 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dadd X #x8 #x1 #xE dadd-sem)
7288 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dadd X #x8 #x1 #xE dadd-sem)
7290 (binary-arith32-src-dst-Prefixed QI QI .b 0 dadd X #x1 #x0 dadd-sem)
7291 (binary-arith32-src-dst-Prefixed HI HI .w 1 dadd X #x1 #x0 dadd-sem)
7293 ;-------------------------------------------------------------;
7294 ; addx - Add extend sign with no carry
7295 ;-------------------------------------------------------------;
7297 (define-pmacro (addx-sem mode src dst)
7298 (sequence ((SI source) (SI result))
7299 (set source (zext SI (trunc QI src)))
7300 (set result (add SI source dst))
7301 (set obit (add-oflag SI source dst 0))
7302 (set cbit (add-cflag SI source dst 0))
7303 (set-z-and-s result)
7308 (binary-arith32-imm-dst-defn QI SI "" 0 addx X #x8 #x1 #x1 addx-sem)
7310 (binary-arith32-src-dst-defn QI SI "" 0 addx X #x1 #x2 addx-sem)
7312 ;-------------------------------------------------------------
7313 ; adjnz - Add/Sub and branch if not zero
7314 ;-------------------------------------------------------------
7316 (define-pmacro (arith-jnz-sem mode src dst label)
7317 (sequence ((mode result))
7318 (set result (add mode src dst))
7324 ; adjnz.size #imm4,dst,label
7325 (arith-jnz-imm4-dst adjnz s4 (f-0-4 #xF) (f-4-3 4) #xf #x1 arith-jnz-sem)
7327 ;-------------------------------------------------------------
7329 ;-------------------------------------------------------------
7331 (define-pmacro (and-sem mode src1 dst)
7332 (sequence ((mode result))
7333 (set result (and mode src1 dst))
7334 (set-z-and-s result)
7338 ; and.size:G #imm,dst (m16 #1 m32 #1)
7339 (binary-arith-imm-dst and G (f-0-4 7) (f-4-3 3) (f-8-4 2) #x8 #x3 #xF and-sem)
7340 ; and.b:S #imm8,dst3 (m16 #2)
7341 (binary-arith16-b-S-imm8-dst3 and ".b" (f-0-4 9) (f-4-1 0) and-sem)
7342 ; and.BW:G src,dst (m16 #3 m32 #3)
7343 (binary-arith-src-dst and G (f-0-4 #x9) (f-4-3 0) #x1 #xD and-sem)
7344 ; and.B.S src2,r0l/r0h (m16 #4)
7345 (binary-arith16-b-S-src2 and (f-0-4 1) (f-4-1 0) and-sem)
7346 ; and.BW:S #imm,dst2 (m32 #2)
7347 (binary-arith32-s-imm-dst QI .b 0 and #x1 #x6 and-sem)
7348 (binary-arith32-s-imm-dst HI .w 1 and #x1 #x6 and-sem)
7350 ;-------------------------------------------------------------
7352 ;-------------------------------------------------------------
7354 (define-pmacro (band-sem src)
7355 (set cbit (and src cbit))
7357 (bitsrc-insn band (f-0-4 7) (f-4-4 #xE) (f-8-4 4) #xD #x0 #x1 band-sem)
7359 ;-------------------------------------------------------------
7361 ;-------------------------------------------------------------
7363 (define-pmacro (bclr-sem dst)
7366 (bitdst-insn bclr (f-0-4 7) (f-4-4 #xE) (f-8-4 8) (f-0-2 1) (f-2-2 0) (f-4-1 0) #xD #x0 #x6 bclr-sem)
7368 ;-------------------------------------------------------------
7369 ; bitindex - bit index
7370 ;-------------------------------------------------------------
7372 (define-pmacro (bitindex-sem mode dst)
7375 (unary-insn-defn 32 16-Unprefixed QI .b bitindex
7376 (+ (f-0-4 #xC) (f-7-1 0) dst32-16-Unprefixed-QI (f-10-2 #x2) (f-12-4 #xE))
7378 (unary-insn-defn 32 16-Unprefixed HI .w bitindex
7379 (+ (f-0-4 #xC) (f-7-1 1) dst32-16-Unprefixed-HI (f-10-2 #x2) (f-12-4 #xE))
7382 ;-------------------------------------------------------------
7383 ; bmCnd - bit move condition
7384 ;-------------------------------------------------------------
7386 (define-pmacro (test-condition16 cond)
7388 ((#x00) (trunc BI cbit))
7389 ((#x01) (not (or cbit zbit)))
7390 ((#x02) (trunc BI zbit))
7391 ((#x03) (trunc BI sbit))
7392 ((#x04) (or zbit (xor sbit obit)))
7393 ((#x05) (trunc BI obit))
7394 ((#x06) (xor sbit obit))
7396 ((#xf9) (or cbit zbit))
7399 ((#xfc) (not (or zbit (xor sbit obit))))
7401 ((#xfe) (not (xor sbit obit)))
7406 (define-pmacro (test-condition32 cond)
7409 ((#x01) (or cbit zbit))
7413 ((#x05) (not (or zbit (xor sbit obit))))
7414 ((#x06) (not (xor sbit obit)))
7415 ((#x08) (trunc BI cbit))
7416 ((#x09) (not (or cbit zbit)))
7417 ((#x0a) (trunc BI zbit))
7418 ((#x0b) (trunc BI sbit))
7419 ((#x0c) (trunc BI obit))
7420 ((#x0d) (or zbit (xor sbit obit)))
7421 ((#x0e) (xor sbit obit))
7426 (define-pmacro (bitcond-sem mach op cond)
7427 (if ((.sym test-condition mach) cond)
7431 (bitcond-insn bm (f-0-4 7) (f-4-4 #xE) (f-8-4 2) #xD #x0 #x2 bitcond-sem)
7437 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xD) cond16c)
7438 (bitcond-sem 16 cbit cond16c)
7445 (+ (f-0-4 #xD) (f-4-4 #x9) (f-8-1 0) (f-10-3 5) cond32)
7446 (bitcond-sem 32 cbit cond32)
7449 ;-------------------------------------------------------------
7451 ;-------------------------------------------------------------
7453 (define-pmacro (bnand-sem src)
7454 (set cbit (and (inv src) cbit))
7456 (bitsrc-insn bnand (f-0-4 7) (f-4-4 #xE) (f-8-4 5) #xD #x0 #x3 bnand-sem)
7458 ;-------------------------------------------------------------
7460 ;-------------------------------------------------------------
7462 (define-pmacro (bnor-sem src)
7463 (set cbit (or (inv src) cbit))
7465 (bitsrc-insn bnor (f-0-4 7) (f-4-4 #xE) (f-8-4 7) #xD #x0 #x6 bnor-sem)
7467 ;-------------------------------------------------------------
7469 ;-------------------------------------------------------------
7471 (define-pmacro (bnot-sem dst)
7474 (bitdst-insn bnot (f-0-4 7) (f-4-4 #xE) (f-8-4 #xA) (f-0-2 1) (f-2-2 1) (f-4-1 0) #xD #x0 #x3 bnot-sem)
7476 ;-------------------------------------------------------------
7478 ;-------------------------------------------------------------
7480 (define-pmacro (bntst-sem src)
7481 (set cbit (inv src))
7482 (set zbit (inv src))
7484 (bitsrc-insn bntst (f-0-4 7) (f-4-4 #xE) (f-8-4 3) #xD #x0 #x0 bntst-sem)
7486 ;-------------------------------------------------------------
7488 ;-------------------------------------------------------------
7490 (define-pmacro (bnxor-sem src)
7491 (set cbit (xor (inv src) cbit))
7493 (bitsrc-insn bnxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xD) #xD #x0 #x7 bnxor-sem)
7495 ;-------------------------------------------------------------
7497 ;-------------------------------------------------------------
7499 (define-pmacro (bor-sem src)
7500 (set cbit (or src cbit))
7502 (bitsrc-insn bor (f-0-4 7) (f-4-4 #xE) (f-8-4 #x6) #xD #x0 #x4 bor-sem)
7504 ;-------------------------------------------------------------
7506 ;-------------------------------------------------------------
7512 (+ (f-0-4 #x0) (f-4-4 #x0))
7520 (+ (f-0-4 #x0) (f-4-4 #x0))
7524 ;-------------------------------------------------------------
7526 ;-------------------------------------------------------------
7532 (+ (f-0-4 #x0) (f-4-4 #x8))
7536 ;-------------------------------------------------------------
7538 ;-------------------------------------------------------------
7540 (define-pmacro (bset-sem dst)
7543 (bitdst-insn bset (f-0-4 7) (f-4-4 #xE) (f-8-4 9) (f-0-2 1) (f-2-2 0) (f-4-1 1) #xD #x0 #x7 bset-sem)
7545 ;-------------------------------------------------------------
7547 ;-------------------------------------------------------------
7549 (define-pmacro (btst-sem dst)
7550 (set zbit (inv dst))
7553 (bitdst-insn btst (f-0-4 7) (f-4-4 #xE) (f-8-4 #xB) (f-0-2 1) (f-2-2 1) (f-4-1 1) #xD #x0 #x0 btst-sem)
7555 ;-------------------------------------------------------------
7557 ;-------------------------------------------------------------
7559 (define-pmacro (btstc-sem dst)
7560 (set zbit (inv dst))
7564 (bitdstnos-insn btstc (f-0-4 7) (f-4-4 #xE) (f-8-4 #x0) #xD #x0 #x4 btstc-sem)
7566 ;-------------------------------------------------------------
7568 ;-------------------------------------------------------------
7570 (define-pmacro (btsts-sem dst)
7571 (set zbit (inv dst))
7575 (bitdstnos-insn btsts (f-0-4 7) (f-4-4 #xE) (f-8-4 #x1) #xD #x0 #x5 btsts-sem)
7577 ;-------------------------------------------------------------
7579 ;-------------------------------------------------------------
7581 (define-pmacro (bxor-sem src)
7582 (set cbit (xor src cbit))
7584 (bitsrc-insn bxor (f-0-4 7) (f-4-4 #xE) (f-8-4 #xC) #xD #x0 #x5 bxor-sem)
7586 ;-------------------------------------------------------------
7588 ;-------------------------------------------------------------
7590 (define-pmacro (clip-sem mode imm1 imm2 dest)
7592 (if (gt mode imm1 dest)
7594 (if (lt mode imm2 dest)
7598 (insn-imm1-imm2-dst-Prefixed clip #x8 #x3 #xE clip-sem)
7600 ;-------------------------------------------------------------
7601 ; cmp - binary compare
7602 ;-------------------------------------------------------------
7604 (define-pmacro (cmp-sem mode src1 dst)
7605 (sequence ((mode result))
7606 (set result (sub mode dst src1))
7607 (set obit (sub-oflag mode dst src1 0))
7608 (set cbit (not (sub-cflag mode dst src1 0)))
7609 (set-z-and-s result))
7612 ; cmp.L:G #imm32,dst (m32 #2)
7613 (binary-arith32-imm-dst-defn SI SI .l 0 cmp G #xA #x3 #x1 cmp-sem)
7614 ; cmp.size:G #imm,dst (m16 #1 m32 #1)
7615 (binary-arith-imm-dst cmp G (f-0-4 7) (f-4-3 3) (f-8-4 8) #x9 #x2 #xE cmp-sem)
7616 ; cmp.size:Q #imm4,dst (m16 #2 m32 #3)
7617 (binary-arith-imm4-dst cmp (f-0-4 #xD) (f-4-3 0) #x7 #x1 cmp-sem)
7618 ; cmp.b:S #imm8,dst3 (m16 #3)
7619 (binary-arith16-b-S-imm8-dst3 cmp ".b" (f-0-4 #xE) (f-4-1 0) cmp-sem)
7620 ; cmp.BW:G src,dst (m16 #4 m32 #5)
7621 (binary-arith-src-dst cmp G (f-0-4 #xC) (f-4-3 0) #x1 #x6 cmp-sem)
7622 ; cmp.B.S src2,r0l/r0h (m16 #5)
7623 (binary-arith16-b-S-src2 cmp (f-0-4 3) (f-4-1 1) cmp-sem)
7624 ; cmp.L:G src,dst (m32 #6)
7625 (binary-arith32-src-dst-defn SI SI .l 1 cmp G #x1 #x1 cmp-sem)
7626 ; cmp.BW:S #imm,dst2 (m32 #4)
7627 (binary-arith32-s-imm-dst QI .b 0 cmp #x1 #x3 cmp-sem)
7628 (binary-arith32-s-imm-dst HI .w 1 cmp #x1 #x3 cmp-sem)
7629 ; cmp.BW:s src2,r0[l] (m32 #7)
7630 (binary-arith32-S-src2 cmp QI .b 0 (f-0-2 1) (f-4-3 0) cmp-sem)
7631 (binary-arith32-S-src2 cmp HI .w 1 (f-0-2 1) (f-4-3 0) cmp-sem)
7633 ;-------------------------------------------------------------
7634 ; cmpx - binary compare extend sign
7635 ;-------------------------------------------------------------
7637 (define-pmacro (cmpx-sem mode src1 dst)
7638 (sequence ((mode result))
7639 (set result (sub mode dst (ext mode src1)))
7640 (set obit (sub-oflag mode dst (ext mode src1) 0))
7641 (set cbit (sub-cflag mode dst (ext mode src1) 0))
7642 (set-z-and-s result))
7645 (binary-arith32-imm-dst-defn QI SI "" 0 cmpx X #xA #x1 #x1 cmpx-sem)
7647 ;-------------------------------------------------------------
7649 ;-------------------------------------------------------------
7651 (define-pmacro (dec-sem mode dest)
7652 (sequence ((mode result))
7653 (set result (sub mode dest 1))
7654 (set-z-and-s result)
7661 "dec.b ${Dst16-3-S-8}"
7662 (+ (f-0-4 #xA) (f-4-1 #x1) Dst16-3-S-8)
7663 (dec-sem QI Dst16-3-S-8)
7669 "dec.w ${Dst16An-S}"
7670 (+ (f-0-4 #xF) (f-5-3 #x2) Dst16An-S)
7671 (dec-sem HI Dst16An-S)
7674 (unary32-defn QI .b 0 dec #xB #x0 #xE dec-sem)
7675 (unary32-defn HI .w 1 dec #xB #x0 #xE dec-sem)
7677 ;-------------------------------------------------------------
7679 ; divu - divide unsigned
7680 ; divx - divide extension
7681 ;-------------------------------------------------------------
7684 (div-imm div div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #x1) #xB #x0 #x2 #x3 div-sem)
7685 (div-imm divu udiv umod USI 255 0 65535 0 (f-0-4 #x7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #x0) #xB #x0 #x0 #x3 div-sem)
7686 (div-imm divx div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 6) (f-8-4 #xE) (f-12-4 #x3) #xB #x2 #x2 #x3 div-sem)
7688 (div-src div div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 3) (f-8-4 #xD) #x8 #x1 #xE div-sem)
7689 (div-src divu udiv umod USI 255 0 65535 0 (f-0-4 #x7) (f-4-3 3) (f-8-4 #xC) #x8 #x0 #xE div-sem)
7690 (div-src divx div mod SI 127 -128 32767 -32768 (f-0-4 #x7) (f-4-3 3) (f-8-4 #x9) #x9 #x1 #xE div-sem)
7692 (div-src-defn 32 .l div dst32-24-Prefixed-SI
7693 (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xA) (f-15-1 1) (f-18-2 #x1) (f-20-4 #xf) dst32-24-Prefixed-SI)
7694 div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000)
7696 (div-src-defn 32 .l divu dst32-24-Prefixed-SI
7697 (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xA) (f-15-1 1) (f-18-2 #x0) (f-20-4 #xf) dst32-24-Prefixed-SI)
7698 udiv umod USI R2R0 R2R0 NoRemainder #x80000000 0
7700 (div-src-defn 32 .l divx dst32-24-Prefixed-SI
7701 (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xA) (f-15-1 1) (f-18-2 #x2) (f-20-4 #xf) dst32-24-Prefixed-SI)
7702 div mod SI R2R0 R2R0 NoRemainder #x7fffffff (neg SI #x80000000)
7705 ;-------------------------------------------------------------
7706 ; dsbb - decimal subtraction with borrow
7707 ; dsub - decimal subtraction
7708 ;-------------------------------------------------------------
7710 (define-pmacro (dsbb-sem mode src dst)
7711 (sequence ((mode result))
7712 (set result (subc mode dst src (not cbit)))
7713 (set cbit (sub-cflag mode dst src (not cbit)))
7714 (set-z-and-s result)
7719 (decimal-subtraction16-insn dsbb #xF #x7)
7721 ; dsbb.size #imm,dst
7722 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsbb X #x9 #x0 #xE dsbb-sem)
7723 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsbb X #x9 #x0 #xE dsbb-sem)
7725 (binary-arith32-src-dst-Prefixed QI QI .b 0 dsbb X #x1 #xA dsbb-sem)
7726 (binary-arith32-src-dst-Prefixed HI HI .w 1 dsbb X #x1 #xA dsbb-sem)
7728 (define-pmacro (dsub-sem mode src dst)
7729 (sequence ((mode result))
7730 (set result (subc mode dst src 0))
7731 (set cbit (sub-cflag mode dst src 0))
7732 (set-z-and-s result)
7737 (decimal-subtraction16-insn dsub #xD #x5)
7739 ; dsub.size #imm,dst
7740 (binary-arith32-imm-dst-Prefixed QI QI .b 0 dsub X #x9 #x1 #xE dsub-sem)
7741 (binary-arith32-imm-dst-Prefixed HI HI .w 1 dsub X #x9 #x1 #xE dsub-sem)
7743 (binary-arith32-src-dst-Prefixed QI QI .b 0 dsub X #x1 #x2 dsub-sem)
7744 (binary-arith32-src-dst-Prefixed HI HI .w 1 dsub X #x1 #x2 dsub-sem)
7746 ;-------------------------------------------------------------
7747 ; sub - binary subtraction
7748 ;-------------------------------------------------------------
7750 (define-pmacro (sub-sem mode src1 dst)
7751 (sequence ((mode result))
7752 (set result (sub mode dst src1))
7753 (set obit (sub-oflag mode dst src1 0))
7754 (set cbit (sub-cflag mode dst src1 0))
7756 (set-z-and-s result)))
7758 ; sub.size:G #imm,dst (m16 #1 m32 #1)
7759 (binary-arith-imm-dst sub G (f-0-4 7) (f-4-3 3) (f-8-4 5) #x8 #x3 #xE sub-sem)
7760 ; sub.b:S #imm8,dst3 (m16 #2)
7761 (binary-arith16-b-S-imm8-dst3 sub ".b" (f-0-4 8) (f-4-1 1) sub-sem)
7762 ; sub.BW:G src,dst (m16 #3 m32 #4)
7763 (binary-arith-src-dst sub G (f-0-4 #xA) (f-4-3 4) #x1 #xA sub-sem)
7764 ; sub.B.S src2,r0l/r0h (m16 #4)
7765 (binary-arith16-b-S-src2 sub (f-0-4 2) (f-4-1 1) sub-sem)
7766 ; sub.L:G #imm32,dst (m32 #2)
7767 (binary-arith32-imm-dst-defn SI SI .l 0 sub G #x9 #x3 #x1 sub-sem)
7768 ; sub.BW:S #imm,dst2 (m32 #3)
7769 (binary-arith32-s-imm-dst QI .b 0 sub #x0 #x7 sub-sem)
7770 (binary-arith32-s-imm-dst HI .w 1 sub #x0 #x7 sub-sem)
7771 ; sub.L:G src,dst (m32 #5)
7772 (binary-arith32-src-dst-defn SI SI .l 1 sub G #x1 #x0 sub-sem)
7774 ;-------------------------------------------------------------
7775 ; enter - enter function
7776 ; exitd - exit and deallocate stack frame
7777 ;-------------------------------------------------------------
7779 (define-pmacro (enter16-sem mach amt)
7781 (set (reg h-sp) (sub (reg h-sp) 2))
7782 (set (mem16 HI (reg h-sp)) (reg h-fb))
7783 (set (reg h-fb) (reg h-sp))
7784 (set (reg h-sp) (sub (reg h-sp) amt))))
7786 (define-pmacro (exit16-sem mach)
7787 (sequence ((SI newpc))
7788 (set (reg h-sp) (reg h-fb))
7789 (set (reg h-fb) (mem16 HI (reg h-sp)))
7790 (set (reg h-sp) (add (reg h-sp) 2))
7791 (set newpc (mem16 HI (reg h-sp)))
7792 (set (reg h-sp) (add (reg h-sp) 2))
7793 (set newpc (or newpc (sll (mem16 QI (reg h-sp)) (const 16))))
7794 (set (reg h-sp) (add (reg h-sp) 1))
7797 (define-pmacro (enter32-sem mach amt)
7799 (set (reg h-sp) (sub (reg h-sp) 4))
7800 (set (mem32 SI (reg h-sp)) (reg h-fb))
7801 (set (reg h-fb) (reg h-sp))
7802 (set (reg h-sp) (sub (reg h-sp) amt))))
7804 (define-pmacro (exit32-sem mach)
7805 (sequence ((SI newpc))
7806 (set (reg h-sp) (reg h-fb))
7807 (set (reg h-fb) (mem32 SI (reg h-sp)))
7808 (set (reg h-sp) (add (reg h-sp) 4))
7809 (set newpc (mem32 SI (reg h-sp)))
7810 (set (reg h-sp) (add (reg h-sp) 4))
7813 (dni enter16 "enter #Imm-16-QI" ((machine 16))
7814 ("enter #${Dsp-16-u8}")
7815 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 2) Dsp-16-u8)
7816 (enter16-sem 16 Dsp-16-u8)
7819 (dni exitd16 "exitd" ((machine 16))
7821 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 2))
7825 (dni enter32 "enter #Imm-8-QI" ((machine 32))
7826 ("enter #${Dsp-8-u8}")
7827 (+ (f-0-4 #xE) (f-4-4 #xC) Dsp-8-u8)
7828 (enter32-sem 32 Dsp-8-u8)
7831 (dni exitd32 "exitd" ((machine 32))
7833 (+ (f-0-4 #xF) (f-4-4 #xC))
7837 ;-------------------------------------------------------------
7838 ; fclr - flag register clear
7839 ; fset - flag register set
7840 ;-------------------------------------------------------------
7842 (define-pmacro (set-flags-sem flag)
7843 (sequence ((SI tmp))
7845 ((#x0) (set cbit 1))
7846 ((#x1) (set dbit 1))
7847 ((#x2) (set zbit 1))
7848 ((#x3) (set sbit 1))
7849 ((#x4) (set bbit 1))
7850 ((#x5) (set obit 1))
7851 ((#x6) (set ibit 1))
7852 ((#x7) (set ubit 1)))
7856 (define-pmacro (clear-flags-sem flag)
7857 (sequence ((SI tmp))
7859 ((#x0) (set cbit 0))
7860 ((#x1) (set dbit 0))
7861 ((#x2) (set zbit 0))
7862 ((#x3) (set sbit 0))
7863 ((#x4) (set bbit 0))
7864 ((#x5) (set obit 0))
7865 ((#x6) (set ibit 0))
7866 ((#x7) (set ubit 0)))
7870 (dni fclr16 "fclr flag" ((machine 16))
7872 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 5))
7873 (clear-flags-sem flags16)
7876 (dni fset16 "fset flag" ((machine 16))
7878 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) flags16 (f-12-4 4))
7879 (set-flags-sem flags16)
7882 (dni fclr "fclr" ((machine 32))
7884 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xE) (f-12-1 1) flags32)
7885 (clear-flags-sem flags32)
7888 (dni fset "fset" ((machine 32))
7890 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xE) (f-12-1 1) flags32)
7891 (set-flags-sem flags32)
7894 ;-------------------------------------------------------------
7896 ;-------------------------------------------------------------
7898 (define-pmacro (inc-sem mode dest)
7899 (sequence ((mode result))
7900 (set result (add mode dest 1))
7901 (set-z-and-s result)
7908 "inc.b ${Dst16-3-S-8}"
7909 (+ (f-0-4 #xA) (f-4-1 #x0) Dst16-3-S-8)
7910 (inc-sem QI Dst16-3-S-8)
7916 "inc.w ${Dst16An-S}"
7917 (+ (f-0-4 #xB) (f-5-3 #x2) Dst16An-S)
7918 (inc-sem HI Dst16An-S)
7921 (unary32-defn QI .b 0 inc #xA #x0 #xE inc-sem)
7922 (unary32-defn HI .w 1 inc #xA #x0 #xE inc-sem)
7924 ;-------------------------------------------------------------
7925 ; freit - fast return from interrupt (m32)
7927 ; into - interrupt on overflow
7928 ;-------------------------------------------------------------
7931 (dni freit32 "FREIT" ((machine 32))
7933 (+ (f-0-4 9) (f-4-4 #xF))
7937 (dni int16 "int Dsp-10-u6" ((machine 16))
7938 ("int #${Dsp-10-u6}")
7939 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-2 3) Dsp-10-u6)
7940 (c-call VOID "do_int" pc Dsp-10-u6)
7943 (dni into16 "into" ((machine 16))
7945 (+ (f-0-4 #xF) (f-4-4 6))
7949 (dni int32 "int Dsp-8-u6" ((machine 32))
7950 ("int #${Dsp-8-u6}")
7951 (+ (f-0-4 #xB) (f-4-4 #xE) Dsp-8-u6 (f-14-2 0))
7952 (c-call VOID "do_int" pc Dsp-8-u6)
7955 (dni into32 "into" ((machine 32))
7957 (+ (f-0-4 #xB) (f-4-4 #xF))
7961 ;-------------------------------------------------------------
7963 ;-------------------------------------------------------------
7965 ; TODO add support to insns allowing index
7966 (define-pmacro (indexb-sem mode d) (set SrcIndex d) (set DstIndex d))
7967 (define-pmacro (indexbd-sem mode d) (set SrcIndex (const 0)) (set DstIndex d))
7968 (define-pmacro (indexbs-sem mode d) (set SrcIndex d) (set DstIndex (const 0)))
7969 (define-pmacro (indexw-sem mode d)
7970 (set SrcIndex (sll d (const 2))) (set DstIndex (sll d (const 2))))
7971 (define-pmacro (indexwd-sem mode d)
7972 (set SrcIndex (const 0)) (set DstIndex (sll d (const 2))))
7973 (define-pmacro (indexws-sem mode d)
7974 (set SrcIndex (sll d (const 2))) (set DstIndex (const 0)))
7975 (define-pmacro (indexl-sem mode d)
7976 (set SrcIndex d) (set DstIndex (sll d (const 2))))
7977 (define-pmacro (indexld-sem mode d)
7978 (set SrcIndex (const 0)) (set DstIndex (sll d (const 2))))
7979 (define-pmacro (indexls-sem mode d)
7980 (set SrcIndex (sll d (const 2))) (set DstIndex (const 0)))
7982 ; indexb src (index byte)
7983 (unary32-defn QI .b 0 indexb #x8 0 #x3 indexb-sem)
7984 (unary32-defn HI .w 1 indexb #x8 1 #x3 indexb-sem)
7985 ; indexbd src (index byte dest)
7986 (unary32-defn QI .b 0 indexbd #xA 0 3 indexbd-sem)
7987 (unary32-defn HI .w 1 indexbd #xA 1 3 indexbd-sem)
7988 ; indexbs src (index byte src)
7989 (unary32-defn QI .b 0 indexbs #xC 0 3 indexbs-sem)
7990 (unary32-defn HI .w 1 indexbs #xC 1 3 indexbs-sem)
7991 ; indexl src (index long)
7992 (unary32-defn QI .b 0 indexl 9 2 3 indexl-sem)
7993 (unary32-defn HI .w 1 indexl 9 3 3 indexl-sem)
7994 ; indexld src (index long dest)
7995 (unary32-defn QI .b 0 indexld #xB 2 3 indexld-sem)
7996 (unary32-defn HI .w 1 indexld #xB 3 3 indexld-sem)
7997 ; indexls src (index long src)
7998 (unary32-defn QI .b 0 indexls 9 0 3 indexls-sem)
7999 (unary32-defn HI .w 1 indexls 9 1 3 indexls-sem)
8000 ; indexw src (index word)
8001 (unary32-defn QI .b 0 indexw 8 2 3 indexw-sem)
8002 (unary32-defn HI .w 1 indexw 8 3 3 indexw-sem)
8003 ; indexwd src (index word dest)
8004 (unary32-defn QI .b 0 indexwd #xA 2 3 indexwd-sem)
8005 (unary32-defn HI .w 1 indexwd #xA 3 3 indexwd-sem)
8006 ; indexws (index word src)
8007 (unary32-defn QI .b 0 indexws #xC 2 3 indexws-sem)
8008 (unary32-defn HI .w 1 indexws #xC 3 3 indexws-sem)
8010 ;-------------------------------------------------------------
8011 ; jcc - jump on condition
8012 ;-------------------------------------------------------------
8014 (define-pmacro (jcnd32-sem cnd label)
8017 ((#x00) (if (not cbit) (set pc label))) ;ltu nc
8018 ((#x01) (if (not (and cbit (not zbit))) (set pc label))) ;leu
8019 ((#x02) (if (not zbit) (set pc label))) ;ne nz
8020 ((#x03) (if (not sbit) (set pc label))) ;pz
8021 ((#x04) (if (not obit) (set pc label))) ;no
8022 ((#x05) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt
8023 ((#x06) (if (not (xor sbit obit)) (set pc label))) ;ge
8024 ((#x08) (if (trunc BI cbit) (set pc label))) ;geu c
8025 ((#x09) (if (and cbit (not zbit)) (set pc label))) ;gtu
8026 ((#x0a) (if (trunc BI zbit) (set pc label))) ;eq z
8027 ((#x0b) (if (trunc BI sbit) (set pc label))) ;n
8028 ((#x0c) (if (trunc BI obit) (set pc label))) ;o
8029 ((#x0d) (if (or zbit (xor sbit obit)) (set pc label))) ;le
8030 ((#x0e) (if (xor sbit obit) (set pc label))) ;lt
8035 (define-pmacro (jcnd16-sem cnd label)
8038 ((#x00) (if (trunc BI cbit) (set pc label))) ;geu c
8039 ((#x01) (if (and cbit (not zbit)) (set pc label))) ;gtu
8040 ((#x02) (if (trunc BI zbit) (set pc label))) ;eq z
8041 ((#x03) (if (trunc BI sbit) (set pc label))) ;n
8042 ((#x04) (if (not cbit) (set pc label))) ;ltu nc
8043 ((#x05) (if (not (and cbit (not zbit))) (set pc label))) ;leu
8044 ((#x06) (if (not zbit) (set pc label))) ;ne nz
8045 ((#x07) (if (not sbit) (set pc label))) ;pz
8046 ((#x08) (if (or zbit (xor sbit obit)) (set pc label))) ;le
8047 ((#x09) (if (trunc BI obit) (set pc label))) ;o
8048 ((#x0a) (if (not (xor sbit obit)) (set pc label))) ;ge
8049 ((#x0c) (if (not (or zbit (xor sbit obit))) (set pc label))) ;gt
8050 ((#x0d) (if (not obit) (set pc label))) ;no
8051 ((#x0e) (if (xor sbit obit) (set pc label))) ;lt
8058 (RELAXABLE (machine 16))
8059 "j$cond16j5 ${Lab-8-8}"
8060 (+ (f-0-4 #x6) (f-4-1 1) cond16j5 Lab-8-8)
8061 (jcnd16-sem cond16j5 Lab-8-8)
8067 (RELAXABLE (machine 16))
8068 "j$cond16j ${Lab-16-8}"
8069 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xC) cond16j Lab-16-8)
8070 (jcnd16-sem cond16j Lab-16-8)
8076 (RELAXABLE (machine 32))
8077 "j$cond32j ${Lab-8-8}"
8078 (+ (f-0-1 1) (f-4-3 5) cond32j Lab-8-8)
8079 (jcnd32-sem cond32j Lab-8-8)
8083 ;-------------------------------------------------------------
8085 ;-------------------------------------------------------------
8087 ; jmp.s label3 (m16 #1)
8088 (dni jmp16.s "jmp.s Lab-5-3" (RELAXABLE (machine 16))
8089 ("jmp.s ${Lab-5-3}")
8090 (+ (f-0-4 6) (f-4-1 0) Lab-5-3)
8091 (sequence () (set pc Lab-5-3))
8093 ; jmp.b label8 (m16 #2)
8094 (dni jmp16.b "jmp.b Lab-8-8" (RELAXABLE (machine 16))
8095 ("jmp.b ${Lab-8-8}")
8096 (+ (f-0-4 #xF) (f-4-4 #xE) Lab-8-8)
8097 (sequence () (set pc Lab-8-8))
8099 ; jmp.w label16 (m16 #3)
8100 (dni jmp16.w "jmp.w Lab-8-16" (RELAXABLE (machine 16))
8101 ("jmp.w ${Lab-8-16}")
8102 (+ (f-0-4 #xF) (f-4-4 4) Lab-8-16)
8103 (sequence () (set pc Lab-8-16))
8105 ; jmp.a label24 (m16 #4)
8106 (dni jmp16.a "jmp.a Lab-8-24" ((machine 16))
8107 ("jmp.a ${Lab-8-24}")
8108 (+ (f-0-4 #xF) (f-4-4 #xC) Lab-8-24)
8109 (sequence () (set pc Lab-8-24))
8112 (define-pmacro (jmp16-sem mode dst)
8113 (set pc (and dst #xfffff))
8115 (define-pmacro (jmp32-sem mode dst)
8118 ; jmpi.w dst (m16 #1 m32 #2)
8119 (unary-insn-defn 16 16 HI .w jmpi (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 2) dst16-16-HI) jmp16-sem)
8120 (unary-insn-defn 32 16-Unprefixed HI .w jmpi (+ (f-0-4 #xC) (f-7-1 1) dst32-16-Unprefixed-HI (f-10-2 #x0) (f-12-4 #xF)) jmp32-sem)
8121 ; jmpi.a dst (m16 #2 m32 #2)
8122 (unary-insn-defn 16 16 SI .a jmpi (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 0) dst16-16-SI) jmp16-sem)
8123 (unary-insn-defn 32 16-Unprefixed SI .a jmpi (+ (f-0-4 #x8) (f-7-1 0) dst32-16-Unprefixed-SI (f-10-2 #x0) (f-12-4 1)) jmp32-sem)
8124 ; jmps imm8 (m16 #1)
8125 (dni jmps16 "jmps Imm-8-QI" ((machine 16))
8126 ("jmps #${Imm-8-QI}")
8127 (+ (f-0-4 #xE) (f-4-4 #xE) Imm-8-QI)
8128 (sequence () (set pc Imm-8-QI))
8130 ; jmp.s label3 (m32 #1)
8133 (RELAXABLE (machine 32))
8134 "jmp.s ${Lab32-jmp-s}"
8135 (+ (f-0-2 1) (f-4-3 5) Lab32-jmp-s)
8136 (set pc Lab32-jmp-s)
8139 ; jmp.b label8 (m32 #2)
8140 (dni jmp32.b "jmp.b Lab-8-8" (RELAXABLE (machine 32))
8141 ("jmp.b ${Lab-8-8}")
8142 (+ (f-0-4 #xB) (f-4-4 #xB) Lab-8-8)
8145 ; jmp.w label16 (m32 #3)
8146 (dni jmp32.w "jmp.w Lab-8-16" (RELAXABLE (machine 32))
8147 ("jmp.w ${Lab-8-16}")
8148 (+ (f-0-4 #xC) (f-4-4 #xE) Lab-8-16)
8151 ; jmp.a label24 (m32 #4)
8152 (dni jmp32.a "jmp.a Lab-8-24" ((machine 32))
8153 ("jmp.a ${Lab-8-24}")
8154 (+ (f-0-4 #xC) (f-4-4 #xC) Lab-8-24)
8157 ; jmp.s imm8 (m32 #1)
8158 (dni jmps32 "jmps Imm-8-QI" ((machine 32))
8159 ("jmps #${Imm-8-QI}")
8160 (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI)
8164 ;-------------------------------------------------------------
8165 ; jsr jump subroutine
8166 ;-------------------------------------------------------------
8168 (define-pmacro (jsr16-sem length dst)
8169 (sequence ((SI tpc))
8170 (set tpc (add pc length))
8171 (set (reg h-sp) (sub (reg h-sp) 2))
8172 (set (mem16 HI (reg h-sp)) (srl (and tpc #xffff00) 8))
8173 (set (reg h-sp) (sub (reg h-sp) 1))
8174 (set (mem16 QI (reg h-sp)) (and tpc #xff))
8178 (define-pmacro (jsr32-sem length dst)
8179 (sequence ((SI tpc))
8180 (set tpc (add pc length))
8181 (set (reg h-sp) (sub (reg h-sp) 2))
8182 (set (mem32 HI (reg h-sp)) (srl (and tpc #xffff0000) 16))
8183 (set (reg h-sp) (sub (reg h-sp) 2))
8184 (set (mem32 HI (reg h-sp)) (and tpc #xffff))
8189 ; jsr.w label16 (m16 #1)
8190 (dni jsr16.w "jsr.w Lab-8-16" (RELAXABLE (machine 16))
8191 ("jsr.w ${Lab-8-16}")
8192 (+ (f-0-4 #xF) (f-4-4 5) Lab-8-16)
8193 (jsr16-sem 3 Lab-8-16)
8195 ; jsr.a label24 (m16 #2)
8196 (dni jsr16.a "jsr.a Lab-8-24" ((machine 16))
8197 ("jsr.a ${Lab-8-24}")
8198 (+ (f-0-4 #xF) (f-4-4 #xD) Lab-8-24)
8199 (jsr16-sem 4 Lab-8-24)
8201 (define-pmacro (jsri-defn mode op16 op16-1 op16-2 op16-3 op16-sem
8202 op32 op32-1 op32-2 op32-3 op32-4 op32-sem len)
8204 (dni (.sym jsri16 mode - op16)
8205 (.str "jsri." mode " " op16)
8207 (.str "jsri." mode " ${" op16 "}")
8208 (+ op16-1 op16-2 op16-3 op16)
8211 (dni (.sym jsri32 mode - op32)
8212 (.str "jsri." mode " " op32)
8214 (.str "jsri." mode " ${" op32 "}")
8215 (+ op32-1 op32-2 op32-3 op32-4 op32)
8220 ; jsri.w dst (m16 #1 m32 #1))
8221 (jsri-defn w dst16-basic-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8222 dst32-basic-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 2)
8223 (jsri-defn w dst16-16-8-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8224 dst32-16-8-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 3)
8225 (jsri-defn w dst16-16-16-HI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x3) jsr16-sem
8226 dst32-16-16-Unprefixed-HI (f-0-4 #xC) (f-7-1 1) (f-10-2 #x1) (f-12-4 #xF) jsr32-sem 4)
8227 (dni jsri32.w "jsr.w dst32-16-24-Unprefixed-HI" ((machine 32))
8228 ("jsri.w ${dst32-16-24-Unprefixed-HI}")
8229 (+ (f-0-4 #xC) (f-7-1 1) dst32-16-24-Unprefixed-HI (f-10-2 #x1) (f-12-4 #xF))
8230 (jsr32-sem 6 dst32-16-24-Unprefixed-HI)
8233 ; jsri.a (m16 #2 m32 #2)
8234 (jsri-defn a dst16-basic-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8235 dst32-basic-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 2)
8236 (jsri-defn a dst16-16-8-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8237 dst32-16-8-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 3)
8238 (jsri-defn a dst16-16-16-SI (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #x1) jsr16-sem
8239 dst32-16-16-Unprefixed-SI (f-0-4 #x9) (f-7-1 0) (f-10-2 #x0) (f-12-4 #x1) jsr32-sem 4)
8240 (dni jsri32.a "jsr.w dst32-16-24-Unprefixed-HI" ((machine 32))
8241 ("jsri.w ${dst32-16-24-Unprefixed-SI}")
8242 (+ (f-0-4 #x9) (f-7-1 0) dst32-16-24-Unprefixed-SI (f-10-2 #x0) (f-12-4 #x1))
8243 (jsr32-sem 6 dst32-16-24-Unprefixed-SI)
8245 ; jsr.w label16 (m32 #1)
8246 (dni jsr32.w "jsr.w label" (RELAXABLE (machine 32))
8247 ("jsr.w ${Lab-8-16}")
8248 (+ (f-0-4 #xC) (f-4-4 #xF) Lab-8-16)
8249 (jsr32-sem 3 Lab-8-16)
8251 ; jsr.a label16 (m32 #2)
8252 (dni jsr32.a "jsr.a label" ((machine 32))
8253 ("jsr.a ${Lab-8-24}")
8254 (+ (f-0-4 #xC) (f-4-4 #xD) Lab-8-24)
8255 (jsr32-sem 4 Lab-8-24)
8257 ; jsrs imm8 (m16 #1)
8258 (dni jsrs16 "jsrs Imm-8-QI" ((machine 16))
8259 ("jsrs #${Imm-8-QI}")
8260 (+ (f-0-4 #xE) (f-4-4 #xF) Imm-8-QI)
8261 (jsr16-sem 2 Imm-8-QI)
8263 ; jsrs imm8 (m32 #1)
8264 (dni jsrs "jsrs #Imm-8-QI" ((machine 32))
8265 ("jsrs #${Imm-8-QI}")
8266 (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI)
8267 (jsr32-sem 2 Imm-8-QI)
8270 ;-------------------------------------------------------------
8271 ; ldc - load control register
8272 ; stc - store control register
8273 ;-------------------------------------------------------------
8275 (define-pmacro (ldc32-cr1-sem src dst)
8278 ((#x0) (set (reg h-dct0) src))
8279 ((#x1) (set (reg h-dct1) src))
8280 ((#x2) (sequence ((HI tflag))
8282 (if (and tflag #x1) (set cbit 1))
8283 (if (and tflag #x2) (set dbit 1))
8284 (if (and tflag #x4) (set zbit 1))
8285 (if (and tflag #x8) (set sbit 1))
8286 (if (and tflag #x10) (set bbit 1))
8287 (if (and tflag #x20) (set obit 1))
8288 (if (and tflag #x40) (set ibit 1))
8289 (if (and tflag #x80) (set ubit 1))))
8290 ((#x3) (set (reg h-svf) src))
8291 ((#x4) (set (reg h-drc0) src))
8292 ((#x5) (set (reg h-drc1) src))
8293 ((#x6) (set (reg h-dmd0) src))
8294 ((#x7) (set (reg h-dmd1) src))
8298 (define-pmacro (ldc32-cr2-sem src dst)
8301 ((#x0) (set (reg h-intb) src))
8302 ((#x1) (set (reg h-sp) src))
8303 ((#x2) (set (reg h-sb) src))
8304 ((#x3) (set (reg h-fb) src))
8305 ((#x4) (set (reg h-svp) src))
8306 ((#x5) (set (reg h-vct) src))
8307 ((#x7) (set (reg h-isp) src))
8311 (define-pmacro (ldc32-cr3-sem src dst)
8314 ((#x2) (set (reg h-dma0) src))
8315 ((#x3) (set (reg h-dma1) src))
8316 ((#x4) (set (reg h-dra0) src))
8317 ((#x5) (set (reg h-dra1) src))
8318 ((#x6) (set (reg h-dsa0) src))
8319 ((#x7) (set (reg h-dsa1) src))
8323 (define-pmacro (ldc16-sem src dst)
8326 ((#x1) (set (reg h-intb) src))
8327 ((#x2) (set (reg h-intb) (or (reg h-intb) (sll src (const 16)))))
8328 ((#x3) (sequence ((HI tflag))
8330 (if (and tflag #x1) (set cbit 1))
8331 (if (and tflag #x2) (set dbit 1))
8332 (if (and tflag #x4) (set zbit 1))
8333 (if (and tflag #x8) (set sbit 1))
8334 (if (and tflag #x10) (set bbit 1))
8335 (if (and tflag #x20) (set obit 1))
8336 (if (and tflag #x40) (set ibit 1))
8337 (if (and tflag #x80) (set ubit 1))))
8338 ((#x4) (set (reg h-isp) src))
8339 ((#x5) (set (reg h-sp) src))
8340 ((#x6) (set (reg h-sb) src))
8341 ((#x7) (set (reg h-fb) src))
8346 (define-pmacro (stc32-cr1-sem src dst)
8349 ((#x0) (set dst (reg h-dct0)))
8350 ((#x1) (set dst (reg h-dct1)))
8351 ((#x2) (sequence ((HI tflag))
8353 (if (eq cbit 1) (set tflag (or tflag #x1)))
8354 (if (eq dbit 1) (set tflag (or tflag #x2)))
8355 (if (eq zbit 1) (set tflag (or tflag #x4)))
8356 (if (eq sbit 1) (set tflag (or tflag #x8)))
8357 (if (eq bbit 1) (set tflag (or tflag #x10)))
8358 (if (eq obit 1) (set tflag (or tflag #x20)))
8359 (if (eq ibit 1) (set tflag (or tflag #x40)))
8360 (if (eq ubit 1) (set tflag (or tflag #x80)))
8362 ((#x3) (set dst (reg h-svf)))
8363 ((#x4) (set dst (reg h-drc0)))
8364 ((#x5) (set dst (reg h-drc1)))
8365 ((#x6) (set dst (reg h-dmd0)))
8366 ((#x7) (set dst (reg h-dmd1)))
8370 (define-pmacro (stc32-cr2-sem src dst)
8373 ((#x0) (set dst (reg h-intb)))
8374 ((#x1) (set dst (reg h-sp)))
8375 ((#x2) (set dst (reg h-sb)))
8376 ((#x3) (set dst (reg h-fb)))
8377 ((#x4) (set dst (reg h-svp)))
8378 ((#x5) (set dst (reg h-vct)))
8379 ((#x7) (set dst (reg h-isp)))
8383 (define-pmacro (stc32-cr3-sem src dst)
8386 ((#x2) (set dst (reg h-dma0)))
8387 ((#x3) (set dst (reg h-dma1)))
8388 ((#x4) (set dst (reg h-dra0)))
8389 ((#x5) (set dst (reg h-dra1)))
8390 ((#x6) (set dst (reg h-dsa0)))
8391 ((#x7) (set dst (reg h-dsa1)))
8395 (define-pmacro (stc16-sem src dst)
8398 ((#x1) (set dst (and (reg h-intb) (const #xffff))))
8399 ((#x2) (set dst (srl (reg h-intb) (const 16))))
8400 ((#x3) (sequence ((HI tflag))
8402 (if (eq cbit 1) (set tflag (or tflag #x1)))
8403 (if (eq dbit 1) (set tflag (or tflag #x2)))
8404 (if (eq zbit 1) (set tflag (or tflag #x4)))
8405 (if (eq sbit 1) (set tflag (or tflag #x8)))
8406 (if (eq bbit 1) (set tflag (or tflag #x10)))
8407 (if (eq obit 1) (set tflag (or tflag #x20)))
8408 (if (eq ibit 1) (set tflag (or tflag #x40)))
8409 (if (eq ubit 1) (set tflag (or tflag #x80)))
8411 ((#x4) (set dst (reg h-isp)))
8412 ((#x5) (set dst (reg h-sp)))
8413 ((#x6) (set dst (reg h-sb)))
8414 ((#x7) (set dst (reg h-fb)))
8419 (dni ldc16.imm16 "ldc #imm,dst" ((machine 16))
8420 ("ldc #${Imm-16-HI},${cr16}")
8421 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 0) cr16 Imm-16-HI)
8422 (ldc16-sem Imm-16-HI cr16)
8425 (dni ldc16.dst "ldc src,dest" ((machine 16))
8426 ("ldc ${dst16-16-HI},${cr16}")
8427 (+ (f-0-4 7) (f-4-4 #xA) (f-8-1 1) cr16 dst16-16-HI)
8428 (ldc16-sem dst16-16-HI cr16)
8430 ; ldc src,dest (m32c #4)
8431 (dni ldc32.src-cr1 "ldc src,dst" ((machine 32))
8432 ("ldc ${dst32-24-Prefixed-HI},${cr1-Prefixed-32}")
8433 (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-HI (f-15-1 1) (f-18-2 0) (f-20-1 1) cr1-Prefixed-32)
8434 (ldc32-cr1-sem dst32-24-Prefixed-HI cr1-Prefixed-32)
8436 ; ldc src,dest (m32c #5)
8437 (dni ldc32.src-cr2 "ldc src,dest" ((machine 32))
8438 ("ldc ${dst32-16-Unprefixed-SI},${cr2-32}")
8439 (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 0) cr2-32)
8440 (ldc32-cr2-sem dst32-16-Unprefixed-SI cr2-32)
8442 ; ldc src,dest (m32c #6)
8443 (dni ldc32.src-cr3 "ldc src,dst" ((machine 32))
8444 ("ldc ${dst32-24-Prefixed-SI},${cr3-Prefixed-32}")
8445 (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-SI (f-15-1 1) (f-18-2 0) (f-20-1 0) cr3-Prefixed-32)
8446 (ldc32-cr3-sem dst32-24-Prefixed-SI cr3-Prefixed-32)
8448 ; ldc src,dest (m32c #1)
8449 (dni ldc32.imm16-cr1 "ldc #imm,dst" ((machine 32))
8450 ("ldc #${Imm-16-HI},${cr1-Unprefixed-32}")
8451 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32 Imm-16-HI)
8452 (ldc32-cr1-sem Imm-16-HI cr1-Unprefixed-32)
8454 ; ldc src,dest (m32c #2)
8455 (dni ldc32.imm16-cr2 "ldc #imm,dst" ((machine 32))
8456 ("ldc #${Dsp-16-u24},${cr2-32}")
8457 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 2) (f-12-1 1) cr2-32 Dsp-16-u24)
8458 (ldc32-cr2-sem Dsp-16-u24 cr2-32)
8460 ; ldc src,dest (m32c #3)
8461 (dni ldc32.imm16-cr3 "ldc #imm,dst" ((machine 32))
8462 ("ldc #${Dsp-16-u24},${cr3-Unprefixed-32}")
8463 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 6) (f-12-1 1) cr3-Unprefixed-32 Dsp-16-u24)
8464 (ldc32-cr3-sem Dsp-16-u24 cr3-Unprefixed-32)
8467 (dni stc16.src "stc src,dest" ((machine 16))
8468 ("stc ${cr16},${dst16-16-HI}")
8469 (+ (f-0-4 7) (f-4-4 #xB) (f-8-1 1) cr16 dst16-16-HI)
8470 (stc16-sem cr16 dst16-16-HI )
8473 (dni stc16.pc "stc pc,dest" ((machine 16))
8474 ("stc pc,${dst16-16-HI}")
8475 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xC) dst16-16-HI)
8476 (sequence () (set dst16-16-HI (reg h-pc)))
8479 (dni stc32.src-cr1 "stc src,dst" ((machine 32))
8480 ("stc ${cr1-Prefixed-32},${dst32-24-Prefixed-HI}")
8481 (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-HI (f-15-1 1) (f-18-2 1) (f-20-1 1) cr1-Prefixed-32)
8482 (stc32-cr1-sem cr1-Prefixed-32 dst32-24-Prefixed-HI )
8485 (dni stc32.src-cr2 "stc src,dest" ((machine 32))
8486 ("stc ${cr2-32},${dst32-16-Unprefixed-SI}")
8487 (+ (f-0-4 #xD) dst32-16-Unprefixed-SI (f-7-1 1) (f-10-2 0) (f-12-1 2) cr2-32)
8488 (stc32-cr2-sem cr2-32 dst32-16-Unprefixed-SI )
8491 (dni stc32.src-cr3 "stc src,dst" ((machine 32))
8492 ("stc ${cr3-Prefixed-32},${dst32-24-Prefixed-SI}")
8493 (+ (f-0-4 0) (f-4-4 1) (f-8-4 #xD) dst32-24-Prefixed-SI (f-15-1 1) (f-18-2 1) (f-20-1 0) cr3-Prefixed-32)
8494 (stc32-cr3-sem cr3-Prefixed-32 dst32-24-Prefixed-SI )
8497 ;-------------------------------------------------------------
8498 ; ldctx - load context
8499 ; stctx - store context
8500 ;-------------------------------------------------------------
8503 (dni ldctx16 "ldctx abs16,abs24" ((machine 16))
8504 ("ldctx ${Dsp-16-u16},${Dsp-32-u24}")
8505 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24)
8508 (dni ldctx32 "ldctx abs16,abs24" ((machine 32))
8509 ("ldctx ${Dsp-16-u16},${Dsp-32-u24}")
8510 (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xC) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24)
8513 (dni stctx16 "stctx abs16,abs24" ((machine 16))
8514 ("stctx ${Dsp-16-u16},${Dsp-32-u24}")
8515 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 #x0) Dsp-16-u16 Dsp-32-u24)
8518 (dni stctx32 "stctx abs16,abs24" ((machine 32))
8519 ("stctx ${Dsp-16-u16},${Dsp-32-u24}")
8520 (+ (f-0-4 #xB) (f-4-4 #x6) (f-8-4 #xD) (f-12-4 #x3) Dsp-16-u16 Dsp-32-u24)
8524 ;-------------------------------------------------------------
8525 ; lde - load from extra far data area (m16)
8526 ; ste - store to extra far data area (m16)
8527 ;-------------------------------------------------------------
8535 ;-------------------------------------------------------------
8536 ; ldipl - load interrupt permission level
8537 ;-------------------------------------------------------------
8540 ; ldintb <==> ldc #imm,intbh ; ldc #imm,intbl
8541 (dni ldipl16.imm "ldipl #imm" ((machine 16))
8542 ("ldipl #${Imm-13-u3}")
8543 (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xA) (f-12-1 0) Imm-13-u3)
8546 (dni ldipl32.imm "ldipl #imm" ((machine 32))
8547 ("ldipl #${Imm-13-u3}")
8548 (+ (f-0-4 #xD) (f-4-4 5) (f-8-4 #xE) (f-12-1 1) Imm-13-u3)
8553 ;-------------------------------------------------------------
8554 ; max - maximum value
8555 ;-------------------------------------------------------------
8557 ; TODO check semantics for min -1,0
8558 (define-pmacro (max-sem mode src dst)
8560 (if (gt mode src dst)
8561 (set mode dst src)))
8564 ; max.size:G #imm,dst
8565 (binary-arith32-imm-dst-Prefixed QI QI .b 0 max X #x8 #x3 #xF max-sem)
8566 (binary-arith32-imm-dst-Prefixed HI HI .w 1 max X #x8 #x3 #xF max-sem)
8569 (binary-arith32-src-dst-Prefixed QI QI .b 0 max X #x1 #xD max-sem)
8570 (binary-arith32-src-dst-Prefixed HI HI .w 1 max X #x1 #xD max-sem)
8572 ;-------------------------------------------------------------
8573 ; min - minimum value
8574 ;-------------------------------------------------------------
8576 (define-pmacro (min-sem mode src dst)
8578 (if (lt mode src dst)
8579 (set mode dst src)))
8582 ; min.size:G #imm,dst
8583 (binary-arith32-imm-dst-Prefixed QI QI .b 0 min X #x8 #x2 #xF min-sem)
8584 (binary-arith32-imm-dst-Prefixed HI HI .w 1 min X #x8 #x2 #xF min-sem)
8587 (binary-arith32-src-dst-Prefixed QI QI .b 0 min X #x1 #xC min-sem)
8588 (binary-arith32-src-dst-Prefixed HI HI .w 1 min X #x1 #xC min-sem)
8590 ;-------------------------------------------------------------
8592 ;-------------------------------------------------------------
8594 (define-pmacro (mov-sem mode src1 dst)
8595 (sequence ((mode result))
8597 (set-z-and-s result)
8598 (set mode dst src1))
8601 (define-pmacro (mov-dspsp-dst-sem mach mode src1 dst)
8602 (set dst (mem-mach mach mode (add sp src1)))
8605 (define-pmacro (mov-src-dspsp-sem mach mode src dst1)
8606 (set (mem-mach mach mode (add sp dst1)) src)
8609 (define-pmacro (mov16-imm-an-defn size mode imm regn op1 op2)
8610 (dni (.sym mov16. size .S-imm- regn)
8611 (.str "mov." size ":S " imm "," regn)
8613 (.str "mov." size "$S #${" imm "}," regn)
8615 (mov-sem mode imm (reg (.sym h- regn)))
8618 ; mov.size:G #imm,dst (m16 #1 m32 #1)
8619 (binary-arith-imm-dst mov G (f-0-4 7) (f-4-3 2) (f-8-4 #xC) #x9 #x2 #xF mov-sem)
8620 ; mov.L:G #imm32,dst (m32 #2)
8621 (binary-arith32-imm-dst-defn SI SI .l 0 mov G #xB #x3 #x1 mov-sem)
8622 ; mov.BW:S #imm,dst2 (m32 #4)
8623 (binary-arith32-s-imm-dst QI .b 0 mov #x0 #x2 mov-sem)
8624 (binary-arith32-s-imm-dst HI .w 1 mov #x0 #x2 mov-sem)
8625 ; mov.b:S #imm8,dst3 (m16 #3)
8626 (binary-arith16-b-S-imm8-dst3 mov ".b" (f-0-4 #xC) (f-4-1 0) mov-sem)
8627 ; mov.b:S #imm8,aN (m16 #4)
8628 (mov16-imm-an-defn b QI Imm-8-QI a0 (f-0-4 #xE) (f-4-4 2))
8629 (mov16-imm-an-defn b QI Imm-8-QI a1 (f-0-4 #xE) (f-4-4 #xA))
8630 (mov16-imm-an-defn w HI Imm-8-HI a0 (f-0-4 #xA) (f-4-4 2))
8631 (mov16-imm-an-defn w HI Imm-8-HI a1 (f-0-4 #xA) (f-4-4 #xA))
8632 ; mov.WL:S #imm,A0/A1 (m32 #5)
8633 (define-pmacro (mov32-wl-s-defn mode sz op1 imm regn op2)
8634 (dni (.sym mov32- sz - regn)
8635 (.str "mov." sz ":s" imm "," regn)
8637 (.str "mov." sz "$S #${" imm "}," regn)
8638 (+ (f-0-4 op1) (f-4-4 op2) imm)
8639 (mov-sem mode imm (reg (.sym h- regn)))
8642 (mov32-wl-s-defn HI w #x9 Imm-8-HI a0 #xC)
8643 (mov32-wl-s-defn HI w #x9 Imm-8-HI a1 #xD)
8644 (mov32-wl-s-defn SI l #xB Dsp-8-s24 a0 #xC)
8645 (mov32-wl-s-defn SI l #xB Dsp-8-s24 a1 #xD)
8647 ; mov.size:Q #imm4,dst (m16 #2 m32 #3)
8648 (binary-arith16-imm4-dst-defn QI .b 0 0 mov (f-0-4 #xD) (f-4-3 4) mov-sem)
8649 (binary-arith16-imm4-dst-defn QI .w 0 1 mov (f-0-4 #xD) (f-4-3 4) mov-sem)
8650 (binary-arith32-imm4-dst-defn QI .b 1 0 mov #x7 #x2 mov-sem)
8651 (binary-arith32-imm4-dst-defn HI .w 1 1 mov #x7 #x2 mov-sem)
8653 ; mov.BW:Z #0,dst (m16 #5 m32 #6)
8654 (dni mov16.b-Z-imm8-dst3
8655 "mov.b:Z #0,Dst16-3-S-8"
8657 "mov.b$Z #0,${Dst16-3-S-8}"
8658 (+ (f-0-4 #xB) (f-4-1 #x0) Dst16-3-S-8)
8659 (mov-sem QI (const 0) Dst16-3-S-8)
8661 ; (binary-arith16-b-Z-imm8-dst3 mov ".b" (f-0-4 #xB) (f-4-1 0) mov-sem)
8662 (binary-arith32-z-imm-dst QI .b 0 mov #x0 #x1 mov-sem)
8663 (binary-arith32-z-imm-dst HI .w 1 mov #x0 #x1 mov-sem)
8664 ; mov.BW:G src,dst (m16 #6 m32 #7)
8665 (binary-arith-src-dst mov G (f-0-4 #x7) (f-4-3 1) #x1 #xB mov-sem)
8666 ; mov.B:S src2,a0/a1 (m16 #7)
8667 (dni (.sym mov 16 .b.S-An)
8668 (.str mov ".b:S src2,a[01]")
8670 (.str mov ".b$S ${src16-2-S},${Dst16AnQI-S}")
8671 (+ (f-0-4 #x3) (f-4-1 0) Dst16AnQI-S src16-2-S)
8672 (mov-sem QI src16-2-S Dst16AnQI-S)
8674 (define-pmacro (mov16-b-s-an-defn op1 op2 op2c)
8675 (dni (.sym mov16.b.S- op1 - op2)
8676 (.str mov ".b:S " op1 "," op2)
8678 (.str mov ".b$S " op1 "," op2)
8679 (+ (f-0-4 #x3) op2c)
8680 (mov-sem QI (reg (.sym h- op1)) (reg (.sym h- op2)))
8683 (mov16-b-s-an-defn r0l a1 (f-4-4 #x4))
8684 (mov16-b-s-an-defn r0h a0 (f-4-4 #x0))
8686 ; mov.L:G src,dst (m32 #8)
8687 (binary-arith32-src-dst-defn SI SI .l 1 mov G #x1 #x3 mov-sem)
8688 ; mov.B:S r0l/r0h,dst2 (m16 #8)
8689 (dni (.sym mov 16 .b.S-Rn-An)
8690 (.str mov ".b:S r0[lh],src2")
8692 (.str mov ".b$S ${Dst16RnQI-S},${src16-2-S}")
8693 (+ (f-0-4 #x0) (f-4-1 0) Dst16RnQI-S src16-2-S)
8694 (mov-sem QI src16-2-S Dst16RnQI-S)
8697 ; mov.B.S src2,r0l/r0h (m16 #9)
8698 (binary-arith16-b-S-src2 mov (f-0-4 0) (f-4-1 1) mov-sem)
8700 ; mov.BW:S src2,r0l/r0 (m32 #9)
8701 ; mov.BW:S src2,r1l/r1 (m32 #10)
8702 (define-pmacro (mov32-src-r sz szcode mode src dst opc1 opc2)
8704 (dni (.sym mov32. sz - src - dst)
8705 (.str "mov." sz "src," dst)
8707 (.str "mov." sz "$S ${" (.sym src - mode) "}," dst)
8708 (+ (f-0-2 opc1) (.sym src - mode) (f-4-3 opc2) (f-7-1 szcode))
8709 (mov-sem mode (.sym src - mode) (reg (.sym h- dst)))
8713 (mov32-src-r b 0 QI dst32-2-S-16 r0l 0 4)
8714 (mov32-src-r w 1 HI dst32-2-S-16 r0 0 4)
8715 (mov32-src-r b 0 QI dst32-2-S-8 r0l 0 4)
8716 (mov32-src-r w 1 HI dst32-2-S-8 r0 0 4)
8717 (mov32-src-r b 0 QI dst32-2-S-basic r1l 1 7)
8718 (mov32-src-r w 1 HI dst32-2-S-basic r1 1 7)
8719 (mov32-src-r b 0 QI dst32-2-S-16 r1l 1 7)
8720 (mov32-src-r w 1 HI dst32-2-S-16 r1 1 7)
8721 (mov32-src-r b 0 QI dst32-2-S-8 r1l 1 7)
8722 (mov32-src-r w 1 HI dst32-2-S-8 r1 1 7)
8724 ; mov.BW:S r0l/r0,dst2 (m32 #11)
8725 (define-pmacro (mov32-r-dest sz szcode mode src dst opc1 opc2)
8727 (dni (.sym mov32. sz - src - dst)
8728 (.str "mov." sz "src," dst)
8730 (.str "mov." sz "$S " src ",${" (.sym dst - mode) "}")
8731 (+ (f-0-2 opc1) (.sym dst - mode) (f-4-3 opc2) (f-7-1 szcode))
8732 (mov-sem mode (reg (.sym h- src)) (.sym dst - mode))
8736 (mov32-r-dest b 0 QI r0l dst32-2-S-16 0 0)
8737 (mov32-r-dest w 1 HI r0 dst32-2-S-16 0 0)
8738 (mov32-r-dest b 0 QI r0l dst32-2-S-8 0 0)
8739 (mov32-r-dest w 1 HI r0 dst32-2-S-8 0 0)
8741 ; mov.L:S src,A0/A1 (m32 #12)
8742 (define-pmacro (mov32-src-a src dst dstcode opc1 opc2)
8744 (dni (.sym mov32. sz - src - dst)
8745 (.str "mov." sz "src," dst)
8747 (.str "mov.l" "$S ${" (.sym src - SI) "}," dst)
8748 (+ (f-0-2 opc1) (.sym src - SI) (f-4-3 opc2) (f-7-1 dstcode))
8749 (mov-sem SI (.sym src - SI) (reg (.sym h- dst)))
8753 (mov32-src-a dst32-2-S-16 a0 0 1 4)
8754 (mov32-src-a dst32-2-S-16 a1 1 1 4)
8755 (mov32-src-a dst32-2-S-8 a0 0 1 4)
8756 (mov32-src-a dst32-2-S-8 a1 1 1 4)
8758 ; mov.BW:G dsp8[sp],dst (m16 #10 m32 #13)
8759 ; mov.BW:G src,dsp8[sp] (m16 #11 m32 #14)
8760 (mov-dspsp-dst mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #xB) #xB #x0 #xF mov-dspsp-dst-sem)
8761 (mov-src-dspsp mov (f-0-4 #x7) (f-4-3 2) (f-8-4 #x3) #xA #x0 #xF mov-src-dspsp-sem)
8763 ;-------------------------------------------------------------
8764 ; mova - move effective address
8765 ;-------------------------------------------------------------
8767 (define-pmacro (mov16a-defn dst dstop dstcode)
8768 (dni (.sym mova16. src - dst)
8769 (.str "mova src," dst)
8771 (.str "mova ${dst16-16-Mova-HI}," dst)
8772 (+ (f-0-4 #xE) (f-4-4 #xB) dst16-16-Mova-HI (f-8-4 dstcode))
8773 (sequence () (set HI (reg dstop) dst16-16-Mova-HI))
8776 (mov16a-defn r0 h-r0 0)
8777 (mov16a-defn r1 h-r1 1)
8778 (mov16a-defn r2 h-r2 2)
8779 (mov16a-defn r3 h-r3 3)
8780 (mov16a-defn a0 h-a0 4)
8781 (mov16a-defn a1 h-a1 5)
8783 (define-pmacro (mov32a-defn dst dstop dstcode)
8784 (dni (.sym mova32. src - dst)
8785 (.str "mova src," dst)
8787 (.str "mova ${dst32-16-Unprefixed-Mova-SI}," dst)
8788 (+ (f-0-4 #xD) dst32-16-Unprefixed-Mova-SI (f-7-1 1) (f-10-2 1) (f-12-1 1) (f-13-3 dstcode))
8789 (sequence () (set SI (reg dstop) dst32-16-Unprefixed-Mova-SI))
8792 (mov32a-defn r2r0 h-r2r0 0)
8793 (mov32a-defn r3r1 h-r3r1 1)
8794 (mov32a-defn a0 h-a0 2)
8795 (mov32a-defn a1 h-a1 3)
8797 ;-------------------------------------------------------------
8798 ; movDir - move nibble
8799 ;-------------------------------------------------------------
8801 (define-pmacro (movdir-sem nib src dst)
8802 (sequence ((SI tmp))
8804 ((0) (set dst (or (and dst #xf0) (and src #xf))))
8805 ((1) (set dst (or (and dst #x0f) (sll (and src #xf) 4))))
8806 ((2) (set dst (or (and dst #xf0) (srl (and src #xf0) 4))))
8807 ((3) (set dst (or (and dst #x0f) (and src #xf0))))
8812 (define-pmacro (mov16dir-1-defn nib dircode dir)
8813 (dni (.sym mov nib 16 ".r0l-dst")
8814 (.str "mov" nib " r0l,dst")
8816 (.str "mov" nib " r0l,${dst16-16-QI}")
8817 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI)
8818 (movdir-sem dircode (reg h-r0l) dst16-16-QI)
8821 (mov16dir-1-defn ll 0 8)
8822 (mov16dir-1-defn lh 1 #xA)
8823 (mov16dir-1-defn hl 2 9)
8824 (mov16dir-1-defn hh 3 #xB)
8825 (define-pmacro (mov16dir-2-defn nib dircode dir)
8826 (dni (.sym mov nib 16 ".src-r0l")
8827 (.str "mov" nib " src,r0l")
8829 (.str "mov" nib " ${dst16-16-QI},r0l")
8830 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 dir) dst16-16-QI)
8831 (movdir-sem dircode dst16-16-QI (reg h-r0l))
8834 (mov16dir-2-defn ll 0 0)
8835 (mov16dir-2-defn lh 1 2)
8836 (mov16dir-2-defn hl 2 1)
8837 (mov16dir-2-defn hh 3 3)
8839 (define-pmacro (mov32dir-1-defn nib o1o0)
8840 (dni (.sym mov nib 32 ".r0l-dst")
8841 (.str "mov" nib " r0l,dst")
8843 (.str "mov" nib " r0l,${dst32-24-Prefixed-QI}")
8844 (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #xB) dst32-24-Prefixed-QI (f-15-1 0) (f-18-2 o1o0) (f-20-4 #xE))
8845 (movdir-sem o1o0 (reg h-r0l) dst32-24-Prefixed-QI)
8848 (mov32dir-1-defn ll 0)
8849 (mov32dir-1-defn lh 1)
8850 (mov32dir-1-defn hl 2)
8851 (mov32dir-1-defn hh 3)
8852 (define-pmacro (mov32dir-2-defn nib o1o0)
8853 (dni (.sym mov nib 32 ".src-r0l")
8854 (.str "mov" nib " src,r0l")
8856 (.str "mov" nib " ${dst32-24-Prefixed-QI},r0l")
8857 (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #xA) dst32-24-Prefixed-QI (f-15-1 0) (f-18-2 o1o0) (f-20-4 #xE))
8858 (movdir-sem o1o0 dst32-24-Prefixed-QI (reg h-r0l))
8861 (mov32dir-2-defn ll 0)
8862 (mov32dir-2-defn lh 1)
8863 (mov32dir-2-defn hl 2)
8864 (mov32dir-2-defn hh 3)
8866 ;-------------------------------------------------------------
8867 ; movx - move extend sign (m32)
8868 ;-------------------------------------------------------------
8870 (define-pmacro (movx-sem mode src dst)
8871 (sequence ((SI source) (SI result))
8873 (set-z-and-s result)
8878 (binary-arith32-imm-dst-defn QI SI "" 0 movx X #xB #x1 #x1 movx-sem)
8880 ;-------------------------------------------------------------
8882 ;-------------------------------------------------------------
8884 (define-pmacro (mul-sem mode src1 dst)
8885 (sequence ((mode result))
8886 (set obit (add-oflag mode src1 dst 0))
8887 (set result (mul mode src1 dst))
8892 (binary-arith-imm-dst mul G (f-0-4 7) (f-4-3 6) (f-8-4 5) #x8 #x1 #xF mul-sem)
8894 (binary-arith-src-dst mul G (f-0-4 #x7) (f-4-3 4) #x1 #xC mul-sem)
8896 ;-------------------------------------------------------------
8897 ; mulex - multiple extend sign (m32)
8898 ;-------------------------------------------------------------
8901 ; (dni mulex-absolute-indirect "mulex [src]" ((machine 32))
8902 ; ("mulex ${dst32-24-absolute-indirect-HI}")
8903 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 #xC) dst32-24-absolute-indirect-HI (f-15-1 1) (f-18-2 3) (f-20-4 #xE))
8904 ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-absolute-indirect-HI)))
8906 (dni mulex "mulex src" ((machine 32))
8907 ("mulex ${dst32-16-Unprefixed-Mulex-HI}")
8908 (+ (f-0-4 #xC) dst32-16-Unprefixed-Mulex-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
8909 (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-16-Unprefixed-Mulex-HI)))
8911 ; (dni mulex-indirect "mulex [src]" ((machine 32))
8912 ; ("mulex ${dst32-24-indirect-HI}")
8913 ; (+ (f-0-4 0) (f-4-4 9) (f-8-4 #xC) dst32-24-indirect-HI (f-15-1 1) (f-18-2 3) (f-20-4 #xE))
8914 ; (set R1R2R0 (mul DI (ext DI R2R0) (ext DI dst32-24-indirect-HI)))
8917 ;-------------------------------------------------------------
8918 ; mulu - multiply unsigned
8919 ;-------------------------------------------------------------
8921 (define-pmacro (mulu-sem mode src1 dst)
8922 (sequence ((mode result))
8923 (set obit (add-oflag mode src1 dst 0))
8924 (set result (mul mode src1 dst))
8929 (binary-arith-imm-dst mulu G (f-0-4 7) (f-4-3 6) (f-8-4 4) #x8 #x0 #xF mulu-sem)
8931 (binary-arith-src-dst mulu G (f-0-4 #x7) (f-4-3 0) #x1 #x4 mulu-sem)
8933 ;-------------------------------------------------------------
8934 ; neg - twos complement
8935 ;-------------------------------------------------------------
8937 (define-pmacro (neg-sem mode dst)
8938 (sequence ((mode result))
8939 (set result (neg mode dst))
8940 (set-z-and-s result)
8945 (unary-insn neg (f-0-4 7) (f-4-3 2) (f-8-4 #x5) #xA #x2 #xF neg-sem)
8947 ;-------------------------------------------------------------
8948 ; not - twos complement
8949 ;-------------------------------------------------------------
8951 (define-pmacro (not-sem mode dst)
8952 (sequence ((mode result))
8953 (set result (not mode dst))
8954 (set-z-and-s result)
8959 (unary-insn-g not (f-0-4 7) (f-4-3 2) (f-8-4 #x7) #xA #x1 #xE not-sem)
8962 "not.b:s Dst16-3-S-8"
8964 "not.b:s ${Dst16-3-S-8}"
8965 (+ (f-0-4 #xb) (f-4-1 #x1) Dst16-3-S-8)
8966 (not-sem QI Dst16-3-S-8)
8969 ;-------------------------------------------------------------
8971 ;-------------------------------------------------------------
8977 (+ (f-0-4 #x0) (f-4-4 #x4))
8985 (+ (f-0-4 #xD) (f-4-4 #xE))
8989 ;-------------------------------------------------------------
8991 ;-------------------------------------------------------------
8993 (define-pmacro (or-sem mode src1 dst)
8994 (sequence ((mode result))
8995 (set result (or mode src1 dst))
8996 (set-z-and-s result)
9000 ; or.BW #imm,dst (m16 #1 m32 #1)
9001 (binary-arith-imm-dst or G (f-0-4 7) (f-4-3 3) (f-8-4 3) #x8 #x2 #xF or-sem)
9002 ; or.b:S #imm8,dst3 (m16 #2 m32 #2)
9003 (binary-arith16-b-S-imm8-dst3 or ".b" (f-0-4 9) (f-4-1 1) or-sem)
9004 (binary-arith32-s-imm-dst QI .b 0 or #x1 #x2 or-sem)
9005 (binary-arith32-s-imm-dst HI .w 1 or #x1 #x2 or-sem)
9006 ; or.BW src,dst (m16 #3 m32 #3)
9007 (binary-arith-src-dst or G (f-0-4 #x9) (f-4-3 4) #x1 #x5 or-sem)
9009 ;-------------------------------------------------------------
9010 ; pop - restore register/memory
9011 ;-------------------------------------------------------------
9013 ; TODO future: split this into .b and .w semantics
9014 (define-pmacro (pop-sem-mach mach mode dst)
9015 (sequence ((mode b_or_w) (SI length))
9017 (set b_or_w (srl b_or_w #x8))
9020 (set length 2)) ; .w
9023 ((1) (set dst (mem-mach mach QI (reg h-sp))))
9024 ((2) (set dst (mem-mach mach HI (reg h-sp)))))
9025 (set (reg h-sp) (add (reg h-sp) length))
9029 (define-pmacro (pop-sem16 mode dest) (pop-sem-mach 16 mode dest))
9030 (define-pmacro (pop-sem32 mode dest) (pop-sem-mach 32 mode dest))
9033 (unary-insn-mach 16 pop (f-0-4 7) (f-4-3 2) (f-8-4 #xD) pop-sem16)
9035 (unary-insn-mach 32 pop #xB #x2 #xF pop-sem32)
9038 (dni pop16.b-s-rn "pop.b:S r0[lh]" ((machine 16))
9039 "pop.b$S ${Rn16-push-S-anyof}"
9040 (+ (f-0-4 #x9) Rn16-push-S-anyof (f-5-3 #x2))
9041 (pop-sem16 QI Rn16-push-S-anyof)
9044 (dni pop16.b-s-an "pop.w:S a[01]" ((machine 16))
9045 "pop.w$S ${An16-push-S-anyof}"
9046 (+ (f-0-4 #xD) An16-push-S-anyof (f-5-3 #x2))
9047 (pop-sem16 HI An16-push-S-anyof)
9050 ;-------------------------------------------------------------
9051 ; popc - pop control register
9052 ; pushc - push control register
9053 ;-------------------------------------------------------------
9055 (define-pmacro (popc32-cr1-sem mode dst)
9058 ((#x0) (set (reg h-dct0) (mem32 mode (reg h-sp))))
9059 ((#x1) (set (reg h-dct1) (mem32 mode (reg h-sp))))
9060 ((#x2) (sequence ((HI tflag))
9061 (set tflag (mem32 mode (reg h-sp)))
9062 (if (and tflag #x1) (set cbit 1))
9063 (if (and tflag #x2) (set dbit 1))
9064 (if (and tflag #x4) (set zbit 1))
9065 (if (and tflag #x8) (set sbit 1))
9066 (if (and tflag #x10) (set bbit 1))
9067 (if (and tflag #x20) (set obit 1))
9068 (if (and tflag #x40) (set ibit 1))
9069 (if (and tflag #x80) (set ubit 1))))
9070 ((#x3) (set (reg h-svf) (mem32 mode (reg h-sp))))
9071 ((#x4) (set (reg h-drc0) (mem32 mode (reg h-sp))))
9072 ((#x5) (set (reg h-drc1) (mem32 mode (reg h-sp))))
9073 ((#x6) (set (reg h-dmd0) (mem32 mode (reg h-sp))))
9074 ((#x7) (set (reg h-dmd1) (mem32 mode (reg h-sp))))
9076 (set (reg h-sp) (add (reg h-sp) 2))
9079 (define-pmacro (popc32-cr2-sem mode dst)
9082 ((#x0) (set (reg h-intb) (mem32 mode (reg h-sp))))
9083 ((#x1) (set (reg h-sp) (mem32 mode (reg h-sp))))
9084 ((#x2) (set (reg h-sb) (mem32 mode (reg h-sp))))
9085 ((#x3) (set (reg h-fb) (mem32 mode (reg h-sp))))
9086 ((#x7) (set (reg h-isp) (mem32 mode (reg h-sp))))
9088 (set (reg h-sp) (add (reg h-sp) 4))
9091 (define-pmacro (popc16-sem mode dst)
9094 ((#x1) (set (reg h-intb) (or (and (reg h-intb) #x0000)
9095 (mem16 mode (reg h-sp)))))
9096 ((#x2) (set (reg h-intb) (or (and (reg h-intb) #xffff0000)
9097 (mem16 mode (reg h-sp)))))
9098 ((#x3) (sequence ((HI tflag))
9099 (set tflag (mem16 mode (reg h-sp)))
9100 (if (and tflag #x1) (set cbit 1))
9101 (if (and tflag #x2) (set dbit 1))
9102 (if (and tflag #x4) (set zbit 1))
9103 (if (and tflag #x8) (set sbit 1))
9104 (if (and tflag #x10) (set bbit 1))
9105 (if (and tflag #x20) (set obit 1))
9106 (if (and tflag #x40) (set ibit 1))
9107 (if (and tflag #x80) (set ubit 1))))
9108 ((#x4) (set (reg h-isp) (mem16 mode (reg h-sp))))
9109 ((#x5) (set (reg h-sp) (mem16 mode (reg h-sp))))
9110 ((#x6) (set (reg h-sb) (mem16 mode (reg h-sp))))
9111 ((#x7) (set (reg h-fb) (mem16 mode (reg h-sp))))
9113 (set (reg h-sp) (add (reg h-sp) 2))
9116 ; popc dest (m16c #1)
9117 (dni popc16.imm16 "popc dst" ((machine 16))
9119 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 3) cr16)
9120 (popc16-sem HI cr16)
9122 ; popc dest (m32c #1)
9123 (dni popc32.imm16-cr1 "popc dst" ((machine 32))
9124 ("popc ${cr1-Unprefixed-32}")
9125 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32)
9126 (popc32-cr1-sem HI cr1-Unprefixed-32)
9128 ; popc dest (m32c #2)
9129 (dni popc32.imm16-cr2 "popc dst" ((machine 32))
9131 (+ (f-0-4 #xD) (f-4-4 3) (f-8-4 2) (f-12-1 1) cr2-32)
9132 (popc32-cr2-sem SI cr2-32)
9135 (define-pmacro (pushc32-cr1-sem mode dst)
9137 (set (reg h-sp) (sub (reg h-sp) 2))
9139 ((#x0) (set (mem32 mode (reg h-sp)) (reg h-dct0)))
9140 ((#x1) (set (mem32 mode (reg h-sp)) (reg h-dct1)))
9141 ((#x2) (sequence ((HI tflag))
9143 (if (eq cbit 1) (set tflag (or tflag #x1)))
9144 (if (eq dbit 1) (set tflag (or tflag #x2)))
9145 (if (eq zbit 1) (set tflag (or tflag #x4)))
9146 (if (eq sbit 1) (set tflag (or tflag #x8)))
9147 (if (eq bbit 1) (set tflag (or tflag #x10)))
9148 (if (eq obit 1) (set tflag (or tflag #x20)))
9149 (if (eq ibit 1) (set tflag (or tflag #x40)))
9150 (if (eq ubit 1) (set tflag (or tflag #x80)))
9151 (set (mem32 mode (reg h-sp)) tflag)))
9152 ((#x3) (set (mem32 mode (reg h-sp)) (reg h-svf)))
9153 ((#x4) (set (mem32 mode (reg h-sp)) (reg h-drc0)))
9154 ((#x5) (set (mem32 mode (reg h-sp)) (reg h-drc1)))
9155 ((#x6) (set (mem32 mode (reg h-sp)) (reg h-dmd0)))
9156 ((#x7) (set (mem32 mode (reg h-sp)) (reg h-dmd1)))
9160 (define-pmacro (pushc32-cr2-sem mode dst)
9162 (set (reg h-sp) (sub (reg h-sp) 4))
9164 ((#x0) (set (mem32 mode (reg h-sp)) (reg h-intb)))
9165 ((#x1) (set (mem32 mode (reg h-sp)) (reg h-sp)))
9166 ((#x2) (set (mem32 mode (reg h-sp)) (reg h-sb)))
9167 ((#x3) (set (mem32 mode (reg h-sp)) (reg h-fb)))
9168 ((#x7) (set (mem32 mode (reg h-sp)) (reg h-isp)))
9172 (define-pmacro (pushc16-sem mode dst)
9174 (set (reg h-sp) (sub (reg h-sp) 2))
9176 ((#x1) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff)))
9177 ((#x2) (set (mem16 mode (reg h-sp)) (and (reg h-intb) #xffff0000)))
9178 ((#x3) (sequence ((HI tflag))
9179 (if (eq cbit 1) (set tflag (or tflag #x1)))
9180 (if (eq dbit 1) (set tflag (or tflag #x2)))
9181 (if (eq zbit 1) (set tflag (or tflag #x4)))
9182 (if (eq sbit 1) (set tflag (or tflag #x8)))
9183 (if (eq bbit 1) (set tflag (or tflag #x10)))
9184 (if (eq obit 1) (set tflag (or tflag #x20)))
9185 (if (eq ibit 1) (set tflag (or tflag #x40)))
9186 (if (eq ubit 1) (set tflag (or tflag #x80)))
9187 (set (mem16 mode (reg h-sp)) tflag)))
9189 ((#x4) (set (mem16 mode (reg h-sp)) (reg h-isp)))
9190 ((#x5) (set (mem16 mode (reg h-sp)) (reg h-sp)))
9191 ((#x6) (set (mem16 mode (reg h-sp)) (reg h-sb)))
9192 ((#x7) (set (mem16 mode (reg h-sp)) (reg h-fb)))
9197 (dni pushc16.imm16 "pushc dst" ((machine 16))
9199 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-1 0) (f-12-4 2) cr16)
9200 (pushc16-sem HI cr16)
9202 ; pushc src (m32c #1)
9203 (dni pushc32.imm16-cr1 "pushc dst" ((machine 32))
9204 ("pushc ${cr1-Unprefixed-32}")
9205 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 #xA) (f-12-1 1) cr1-Unprefixed-32)
9206 (pushc32-cr1-sem HI cr1-Unprefixed-32)
9208 ; pushc src (m32c #2)
9209 (dni pushc32.imm16-cr2 "pushc dst" ((machine 32))
9211 (+ (f-0-4 #xD) (f-4-4 1) (f-8-4 2) (f-12-1 1) cr2-32)
9212 (pushc32-cr2-sem SI cr2-32)
9215 ;-------------------------------------------------------------
9216 ; popm - pop multiple
9217 ; pushm - push multiple
9218 ;-------------------------------------------------------------
9220 (define-pmacro (popm-sem machine dst)
9221 (sequence ((SI addrlen))
9226 (sequence () (set R0 (mem-mach machine HI (reg h-sp)))
9227 (set (reg h-sp) (add (reg h-sp) 2))))
9229 (sequence () (set R1 (mem-mach machine HI (reg h-sp)))
9230 (set (reg h-sp) (add (reg h-sp) 2))))
9232 (sequence () (set R2 (mem-mach machine HI (reg h-sp)))
9233 (set (reg h-sp) (add (reg h-sp) 2))))
9235 (sequence () (set R3 (mem-mach machine HI (reg h-sp)))
9236 (set (reg h-sp) (add (reg h-sp) 2))))
9238 (sequence () (set A0 (mem-mach machine HI (reg h-sp)))
9239 (set (reg h-sp) (add (reg h-sp) addrlen))))
9241 (sequence () (set A1 (mem-mach machine HI (reg h-sp)))
9242 (set (reg h-sp) (add (reg h-sp) addrlen))))
9244 (sequence () (set (reg h-sb) (mem-mach machine HI (reg h-sp)))
9245 (set (reg h-sp) (add (reg h-sp) addrlen))))
9247 (sequence () (set (reg h-fb) (mem-mach machine HI (reg h-sp)))
9248 (set (reg h-sp) (add (reg h-sp) addrlen))))
9252 (define-pmacro (pushm-sem machine dst)
9253 (sequence ((SI count) (SI addrlen))
9258 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9259 (set (mem-mach machine HI (reg h-sp)) (reg h-fb))))
9261 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9262 (set (mem-mach machine HI (reg h-sp)) (reg h-sb))))
9264 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9265 (set (mem-mach machine HI (reg h-sp)) A1)))
9267 (sequence () (set (reg h-sp) (sub (reg h-sp) addrlen))
9268 (set (mem-mach machine HI (reg h-sp)) A0)))
9270 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9271 (set (mem-mach machine HI (reg h-sp)) R3)))
9273 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9274 (set (mem-mach machine HI (reg h-sp)) R2)))
9276 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9277 (set (mem-mach machine HI (reg h-sp)) R1)))
9279 (sequence () (set (reg h-sp) (sub (reg h-sp) 2))
9280 (set (mem-mach machine HI (reg h-sp)) R0)))
9284 (dni popm16 "popm regs" ((machine 16))
9285 ("popm ${Regsetpop}")
9286 (+ (f-0-4 #xE) (f-4-4 #xD) Regsetpop)
9287 (popm-sem 16 Regsetpop)
9289 (dni pushm16 "pushm regs" ((machine 16))
9290 ("pushm ${Regsetpush}")
9291 (+ (f-0-4 #xE) (f-4-4 #xC) Regsetpush)
9292 (pushm-sem 16 Regsetpush)
9294 (dni popm "popm regs" ((machine 32))
9295 ("popm ${Regsetpop}")
9296 (+ (f-0-4 #x8) (f-4-4 #xE) Regsetpop)
9297 (popm-sem 32 Regsetpop)
9299 (dni pushm "pushm regs" ((machine 32))
9300 ("pushm ${Regsetpush}")
9301 (+ (f-0-4 #x8) (f-4-4 #xF) Regsetpush)
9302 (pushm-sem 32 Regsetpush)
9305 ;-------------------------------------------------------------
9306 ; push - Save register/memory/immediate data
9307 ;-------------------------------------------------------------
9309 ; TODO future: split this into .b and .w semantics
9310 (define-pmacro (push-sem-mach mach mode dst)
9311 (sequence ((mode b_or_w) (SI length))
9313 (set b_or_w (srl b_or_w #x8))
9316 (if (eq b_or_w #xff)
9318 (set length 4))) ; .l
9319 (set (reg h-sp) (sub (reg h-sp) length))
9321 ((1) (set (mem-mach mach QI (reg h-sp)) dst))
9322 ((2) (set (mem-mach mach HI (reg h-sp)) dst))
9323 ((4) (set (mem-mach mach SI (reg h-sp)) dst)))
9327 (define-pmacro (push-sem16 mode dst) (push-sem-mach 16 mode dst))
9328 (define-pmacro (push-sem32 mode dst) (push-sem-mach 32 mode dst))
9330 ; push.BW:G imm (m16 #1 m32 #1)
9331 (dni push16.b.G-imm "push.b:G #Imm-16-QI" ((machine 16))
9332 ("push.b$G #${Imm-16-QI}")
9333 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 2) Imm-16-QI)
9334 (push-sem16 QI Imm-16-QI)
9337 (dni push16.w.G-imm "push.w:G #Imm-16-HI" ((machine 16))
9338 ("push.w$G #${Imm-16-HI}")
9339 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 2) Imm-16-HI)
9340 (push-sem16 HI Imm-16-HI)
9343 (dni push32.b.imm "push.w #Imm-8-QI" ((machine 32))
9344 ("push.b #Imm-8-QI")
9345 (+ (f-0-4 #xA) (f-4-4 #xE) Imm-8-QI)
9346 (push-sem32 QI Imm-8-QI)
9349 (dni push32.w.imm "push.w #Imm-8-HI" ((machine 32))
9350 ("push.w #${Imm-8-HI}")
9351 (+ (f-0-4 #xA) (f-4-4 #xF) Imm-8-HI)
9352 (push-sem32 HI Imm-8-HI)
9355 ; push.BW:G src (m16 #2)
9356 (unary-insn-mach-g 16 push (f-0-4 7) (f-4-3 2) (f-8-4 #x4) push-sem16 $G)
9357 ; push.BW:G src (m32 #2)
9358 (unary-insn-mach 32 push #xC #x0 #xE push-sem32)
9361 ; push.b:S r0l/r0h (m16 #3)
9362 (dni push16.b-s-rn "push.b:S r0[lh]" ((machine 16))
9363 "push.b$S ${Rn16-push-S-anyof}"
9364 (+ (f-0-4 #x8) Rn16-push-S-anyof (f-5-3 #x2))
9365 (push-sem16 QI Rn16-push-S-anyof)
9367 ; push.w:S a0/a1 (m16 #4)
9368 (dni push16.b-s-an "push.w:S a[01]" ((machine 16))
9369 "push.w$S ${An16-push-S-anyof}"
9370 (+ (f-0-4 #xC) An16-push-S-anyof (f-5-3 #x2))
9371 (push-sem16 HI An16-push-S-anyof)
9374 ; push.l imm32 (m32 #3)
9375 (dni push32.l.imm "push.l #Imm-16-SI" ((machine 32))
9376 ("push.l #${Imm-16-SI}")
9377 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 5) (f-12-4 3) Imm-16-SI)
9378 (push-sem32 SI Imm-16-SI)
9380 ; push.l src (m32 #4)
9381 (unary-insn-defn 32 16-Unprefixed SI .l push (+ (f-0-4 #xA) (f-7-1 0) dst32-16-Unprefixed-SI (f-10-2 0) (f-12-4 1)) push-sem32)
9383 ;-------------------------------------------------------------
9384 ; pusha - push effective address
9385 ;------------------------------------------------------------
9387 (define-pmacro (push16a-sem mode dst)
9389 (set (reg h-sp) (sub (reg h-sp) 2))
9390 (set (mem16 HI (reg h-sp)) dst))
9392 (define-pmacro (push32a-sem mode dst)
9394 (set (reg h-sp) (sub (reg h-sp) 4))
9395 (set (mem32 SI (reg h-sp)) dst))
9397 (unary-insn-defn 16 16-Mova HI "" pusha (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 9) dst16-16-Mova-HI) push16a-sem)
9398 (unary-insn-defn 32 16-Unprefixed-Mova SI "" pusha (+ (f-0-4 #xB) (f-7-1 0) dst32-16-Unprefixed-Mova-SI (f-10-2 0) (f-12-4 1)) push32a-sem)
9400 ;-------------------------------------------------------------
9401 ; reit - return from interrupt
9402 ;-------------------------------------------------------------
9405 (dni reit16 "REIT" ((machine 16))
9407 (+ (f-0-4 #xF) (f-4-4 #xB))
9410 (dni reit32 "REIT" ((machine 32))
9412 (+ (f-0-4 9) (f-4-4 #xE))
9416 ;-------------------------------------------------------------
9417 ; rmpa - repeat multiple and addition
9418 ;-------------------------------------------------------------
9421 (dni rmpa16.b "rmpa.size" ((machine 16))
9423 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 1))
9426 (dni rmpa16.w "rmpa.size" ((machine 16))
9428 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 1))
9431 (dni rmpa32.b "rmpa.size" ((machine 32))
9433 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 4) (f-12-4 3))
9437 (dni rmpa32.w "rmpa.size" ((machine 32))
9439 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 5) (f-12-4 3))
9443 ;-------------------------------------------------------------
9444 ; rolc - rotate left with carry
9445 ;-------------------------------------------------------------
9447 ; TODO check semantics
9448 ; TODO future: split this into .b and .w semantics
9449 (define-pmacro (rolc-sem mode dst)
9450 (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask))
9452 (set b_or_w (srl b_or_w #x8))
9454 (set mask #x8000) ; .b
9455 (set mask #x80000000)) ; .w
9457 (set cbit (and dst mask))
9458 (set result (sll mode dst 1))
9459 (set result (or result ocbit))
9460 (set-z-and-s result)
9464 (unary-insn rolc (f-0-4 7) (f-4-3 3) (f-8-4 #xA) #xB #x2 #xE rolc-sem)
9466 ;-------------------------------------------------------------
9467 ; rorc - rotate right with carry
9468 ;-------------------------------------------------------------
9470 ; TODO check semantics
9471 ; TODO future: split this into .b and .w semantics
9472 (define-pmacro (rorc-sem mode dst)
9473 (sequence ((mode result) (SI ocbit) (mode b_or_w) (USI mask) (SI shamt))
9475 (set b_or_w (srl b_or_w #x8))
9477 (sequence () (set mask #x7fff) (set shamt 15)) ; .b
9478 (sequence () (set mask #x7fffffff) (set shamt 31))) ; .w
9480 (set cbit (and dst #x1))
9481 (set result (srl mode dst (const 1)))
9482 (set result (or (and result mask) (sll ocbit shamt)))
9483 (set-z-and-s result)
9487 (unary-insn rorc (f-0-4 7) (f-4-3 3) (f-8-4 #xB) #xA #x2 #xE rorc-sem)
9489 ;-------------------------------------------------------------
9491 ;-------------------------------------------------------------
9493 ; TODO future: split this into .b and .w semantics
9494 (define-pmacro (rot-1-sem mode src1 dst)
9495 (sequence ((mode tmp) (mode b_or_w) (USI mask) (SI shift))
9497 ((#x0) (set shift 1))
9498 ((#x1) (set shift 2))
9499 ((#x2) (set shift 3))
9500 ((#x3) (set shift 4))
9501 ((#x4) (set shift 5))
9502 ((#x5) (set shift 6))
9503 ((#x6) (set shift 7))
9504 ((#x7) (set shift 8))
9505 ((-8) (set shift -1))
9506 ((-7) (set shift -2))
9507 ((-6) (set shift -3))
9508 ((-5) (set shift -4))
9509 ((-4) (set shift -5))
9510 ((-3) (set shift -6))
9511 ((-2) (set shift -7))
9512 ((-1) (set shift -8))
9513 (else (set shift 0))
9516 (set b_or_w (srl b_or_w #x8))
9518 (set mask #x7fff) ; .b
9519 (set mask #x7fffffff)) ; .w
9521 (if (gt mode shift 0)
9523 (set tmp (rol mode tmp shift))
9524 (set cbit (and tmp #x1)))
9526 (set tmp (ror mode tmp (mul shift -1)))
9527 (set cbit (and tmp mask))))
9531 (define-pmacro (rot-2-sem mode dst)
9532 (sequence ((mode tmp) (mode b_or_w) (USI mask))
9534 (set b_or_w (srl b_or_w #x8))
9536 (set mask #x7fff) ; .b
9537 (set mask #x7fffffff)) ; .w
9539 (if (gt mode (reg h-r1h) 0)
9541 (set tmp (rol mode tmp (reg h-r1h)))
9542 (set cbit (and tmp #x1)))
9544 (set tmp (ror mode tmp (reg h-r1h)))
9545 (set cbit (and tmp mask))))
9551 (binary-arith16-shimm4-dst-defn QI .b 0 0 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem)
9552 (binary-arith16-shimm4-dst-defn HI .w 0 1 rot (f-0-4 #xE) (f-4-3 0) rot-1-sem)
9553 (binary-arith32-shimm4-dst-defn QI .b 0 0 rot #x7 #x2 rot-1-sem)
9554 (binary-arith32-shimm4-dst-defn HI .w 0 1 rot #x7 #x2 rot-1-sem)
9557 (dni rot16.b-dst "rot r1h,dest" ((machine 16))
9558 ("rot.b r1h,${dst16-16-QI}")
9559 (+ (f-0-4 7) (f-4-4 #x4) (f-8-4 #x6) dst16-16-QI)
9560 (rot-2-sem QI dst16-16-QI)
9562 (dni rot16.w-dst "rot r1h,dest" ((machine 16))
9563 ("rot.w r1h,${dst16-16-HI}")
9564 (+ (f-0-4 7) (f-4-4 #x5) (f-8-4 #x6) dst16-16-HI)
9565 (rot-2-sem HI dst16-16-HI)
9568 (dni rot32.b-dst "rot r1h,dest" ((machine 32))
9569 ("rot.b r1h,${dst32-16-Unprefixed-QI}")
9570 (+ (f-0-4 #xA) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xF))
9571 (rot-2-sem QI dst32-16-Unprefixed-QI)
9573 (dni rot32.w-dst "rot r1h,dest" ((machine 32))
9574 ("rot.w r1h,${dst32-16-Unprefixed-HI}")
9575 (+ (f-0-4 #xA) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xF))
9576 (rot-2-sem HI dst32-16-Unprefixed-HI)
9579 ;-------------------------------------------------------------
9580 ; rts - return from subroutine
9581 ;-------------------------------------------------------------
9583 (define-pmacro (rts16-sem)
9584 (sequence ((SI tpc))
9585 (set tpc (mem16 HI (reg h-sp)))
9586 (set (reg h-sp) (add (reg h-sp) 2))
9587 (set tpc (or tpc (sll (mem16 QI (reg h-sp)) 16)))
9588 (set (reg h-sp) (add (reg h-sp) 1))
9592 (define-pmacro (rts32-sem)
9593 (sequence ((SI tpc))
9594 (set tpc (mem32 HI (reg h-sp)))
9595 (set (reg h-sp) (add (reg h-sp) 2))
9596 (set tpc (or tpc (sll (mem32 HI (reg h-sp)) 16)))
9597 (set (reg h-sp) (add (reg h-sp) 2))
9602 (dni rts16 "rts" ((machine 16))
9604 (+ (f-0-4 #xF) (f-4-4 3))
9608 (dni rts32 "rts" ((machine 32))
9610 (+ (f-0-4 #xD) (f-4-4 #xF))
9614 ;-------------------------------------------------------------
9615 ; sbb - subtract with borrow
9616 ;-------------------------------------------------------------
9618 (define-pmacro (sbb-sem mode src dst)
9619 (sequence ((mode result))
9620 (set result (subc mode dst src cbit))
9621 (set obit (add-oflag mode dst src cbit))
9622 (set cbit (add-oflag mode dst src cbit))
9623 (set-z-and-s result)
9627 ; sbb.size:G #imm,dst
9628 (binary-arith16-imm-dst-defn QI QI .b 0 sbb X (f-0-4 7) (f-4-3 3) (f-8-4 7) sbb-sem)
9629 (binary-arith16-imm-dst-defn HI HI .w 1 sbb X (f-0-4 7) (f-4-3 3) (f-8-4 7) sbb-sem)
9630 (binary-arith32-imm-dst-Prefixed QI QI .b 0 sbb X #x9 #x2 #xE sbb-sem)
9631 (binary-arith32-imm-dst-Prefixed HI HI .w 1 sbb X #x9 #x2 #xE sbb-sem)
9634 (binary-arith16-src-dst-defn QI QI .b 0 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem)
9635 (binary-arith16-src-dst-defn HI HI .w 1 sbb X (f-0-4 #xB) (f-4-3 4) sbb-sem)
9636 (binary-arith32-src-dst-Prefixed QI QI .b 0 sbb X #x1 #x6 sbb-sem)
9637 (binary-arith32-src-dst-Prefixed HI HI .w 1 sbb X #x1 #x6 sbb-sem)
9639 ;-------------------------------------------------------------
9640 ; sbjnz - subtract then jump on not zero
9641 ;-------------------------------------------------------------
9643 (define-pmacro (sub-jnz-sem mode src dst label)
9644 (sequence ((mode result))
9645 (set result (sub mode dst src))
9651 ; sbjnz.size #imm4,dst,label
9652 (arith-jnz-imm4-dst sbjnz s4n (f-0-4 #xF) (f-4-3 4) #xf #x1 sub-jnz-sem)
9654 ;-------------------------------------------------------------
9655 ; sccnd - store condition on condition (m32)
9656 ;-------------------------------------------------------------
9658 (define-pmacro (sccnd-sem cnd dst)
9662 ((#x00) (if (not cbit) (set dst 1))) ;ltu nc
9663 ((#x01) (if (or cbit zbit) (set dst 1))) ;leu
9664 ((#x02) (if (not zbit) (set dst 1))) ;ne nz
9665 ((#x03) (if (not sbit) (set dst 1))) ;pz
9666 ((#x04) (if (not obit) (set dst 1))) ;no
9667 ((#x05) (if (not (or zbit (xor sbit obit))) (set dst 1))) ;gt
9668 ((#x06) (if (xor sbit obit) (set dst 1))) ;ge
9669 ((#x08) (if (trunc BI cbit) (set dst 1))) ;geu c
9670 ((#x09) (if (not (or cbit zbit)) (set dst 1))) ;gtu
9671 ((#x0a) (if (trunc BI zbit) (set dst 1))) ;eq z
9672 ((#x0b) (if (trunc BI sbit) (set dst 1))) ;n
9673 ((#x0c) (if (trunc BI obit) (set dst 1))) ;o
9674 ((#x0d) (if (or zbit (xor sbit obit)) (set dst 1))) ;le
9675 ((#x0e) (if (xor sbit obit) (set dst 1))) ;lt
9684 "sc$sccond32 ${dst32-16-Unprefixed-HI}"
9685 (+ (f-0-4 #xD) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) sccond32)
9686 (sccnd-sem sccond32 dst32-16-Unprefixed-HI)
9689 ;-------------------------------------------------------------
9690 ; scmpu - string compare unequal (m32)
9691 ;-------------------------------------------------------------
9694 (dni scmpu.b "scmpu.b" ((machine 32))
9696 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xC) (f-12-4 3))
9697 (c-call VOID "scmpu_QI_semantics")
9700 (dni scmpu.w "scmpu.w" ((machine 32))
9702 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 #xD) (f-12-4 3))
9703 (c-call VOID "scmpu_HI_semantics")
9706 ;-------------------------------------------------------------
9707 ; sha - shift arithmetic
9708 ;-------------------------------------------------------------
9710 ; TODO future: split this into .b and .w semantics
9711 (define-pmacro (sha-sem mode src1 dst)
9712 (sequence ((mode result)(mode shift)(mode shmode))
9714 ((#x0) (set shift 1))
9715 ((#x1) (set shift 2))
9716 ((#x2) (set shift 3))
9717 ((#x3) (set shift 4))
9718 ((#x4) (set shift 5))
9719 ((#x5) (set shift 6))
9720 ((#x6) (set shift 7))
9721 ((#x7) (set shift 8))
9722 ((-8) (set shift -1))
9723 ((-7) (set shift -2))
9724 ((-6) (set shift -3))
9725 ((-5) (set shift -4))
9726 ((-4) (set shift -5))
9727 ((-3) (set shift -6))
9728 ((-2) (set shift -7))
9729 ((-1) (set shift -8))
9730 (else (set shift 0))
9733 (set shmode (srl shmode #x8))
9734 (if (lt mode shift #x0) (set result (sra mode dst (mul shift -1))))
9735 (if (gt mode shift 0) (set result (sll mode dst shift)))
9736 (if (eq shmode #x0) ; QI
9739 (if (lt mode shift #x0)
9740 (set cbitamt (sub #x8 shift)) ; sra
9741 (set cbitamt (sub shift 1))) ; sll
9742 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9743 (set obit (ne (and dst #x80) (and result #x80)))
9745 (if (eq shmode #xff) ; HI
9748 (if (lt mode shift #x0)
9749 (set cbitamt (sub 16 shift)) ; sra
9750 (set cbitamt (sub shift 1))) ; sll
9751 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9752 (set obit (ne (and dst #x8000) (and result #x8000)))
9754 (set-z-and-s result)
9757 (define-pmacro (shar1h-sem mode dst)
9758 (sequence ((mode result)(mode shmode))
9760 (set shmode (srl shmode #x8))
9761 (if (lt mode (reg h-r1h) 0) (set result (sra mode dst (reg h-r1h))))
9762 (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h))))
9763 (if (eq shmode #x0) ; QI
9766 (if (lt mode (reg h-r1h) #x0)
9767 (set cbitamt (sub #x8 (reg h-r1h))) ; sra
9768 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9769 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9770 (set obit (ne (and dst #x80) (and result #x80)))
9772 (if (eq shmode #xff) ; HI
9775 (if (lt mode (reg h-r1h) #x0)
9776 (set cbitamt (sub 16 (reg h-r1h))) ; sra
9777 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9778 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9779 (set obit (ne (and dst #x8000) (and result #x8000)))
9781 (set-z-and-s result)
9784 ; sha.BW #imm4,dst (m16 #1 m32 #1)
9785 (binary-arith16-shimm4-dst-defn QI .b 0 0 sha (f-0-4 #xF) (f-4-3 0) sha-sem)
9786 (binary-arith16-shimm4-dst-defn HI .w 0 1 sha (f-0-4 #xF) (f-4-3 0) sha-sem)
9787 (binary-arith32-shimm4-dst-defn QI .b 1 0 sha #x7 #x0 sha-sem)
9788 (binary-arith32-shimm4-dst-defn HI .w 1 1 sha #x7 #x0 sha-sem)
9789 ; sha.BW r1h,dst (m16 #2 m32 #3)
9790 (dni sha16.b-dst "sha.b r1h,dest" ((machine 16))
9791 ("sha.b r1h,${dst16-16-QI}")
9792 (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xF) dst16-16-QI)
9793 (shar1h-sem HI dst16-16-QI)
9795 (dni sha16.w-dst "sha.w r1h,dest" ((machine 16))
9796 ("sha.w r1h,${dst16-16-HI}")
9797 (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xF) dst16-16-HI)
9798 (shar1h-sem HI dst16-16-HI)
9800 (dni sha32.b-dst "sha.b r1h,dest" ((machine 32))
9801 ("sha.b r1h,${dst32-16-Unprefixed-QI}")
9802 (+ (f-0-4 #xB) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE))
9803 (shar1h-sem QI dst32-16-Unprefixed-QI)
9805 (dni sha32.w-dst "sha.w r1h,dest" ((machine 32))
9806 ("sha.w r1h,${dst32-16-Unprefixed-HI}")
9807 (+ (f-0-4 #xB) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
9808 (shar1h-sem HI dst32-16-Unprefixed-HI)
9810 ; sha.L #imm,dst (m16 #3)
9811 (dni sha16-L-imm-r2r0 "sha.L #Imm-sh-12-s4,r2r0" ((machine 16))
9812 "sha.l #${Imm-sh-12-s4},r2r0"
9813 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xA) Imm-sh-12-s4)
9814 (sha-sem SI Imm-sh-12-s4 (reg h-r2r0))
9816 (dni sha16-L-imm-r3r1 "sha.L #Imm-sh-12-s4,r3r1" ((machine 16))
9817 "sha.l #${Imm-sh-12-s4},r3r1"
9818 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #xB) Imm-sh-12-s4)
9819 (sha-sem SI Imm-sh-12-s4 (reg h-r3r1))
9821 ; sha.L r1h,dst (m16 #4)
9822 (dni sha16-L-r1h-r2r0 "sha.L r1h,r2r0" ((machine 16))
9824 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 2) (f-12-4 1))
9825 (sha-sem SI (reg h-r1h) (reg h-r2r0))
9827 (dni sha16-L-r1h-r3r1 "sha.L r1h,r3r1" ((machine 16))
9829 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 3) (f-12-4 1))
9830 (sha-sem SI (reg h-r1h) (reg h-r3r1))
9832 ; sha.L #imm8,dst (m32 #2)
9833 (binary-arith32-imm-dst-defn QI SI .l 0 sha X #xA #x2 #x1 sha-sem)
9834 ; sha.L r1h,dst (m32 #4)
9835 (dni sha32.l-dst "sha.l r1h,dest" ((machine 32))
9836 ("sha.l r1h,${dst32-16-Unprefixed-SI}")
9837 (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 1) (f-12-4 1))
9838 (shar1h-sem QI dst32-16-Unprefixed-SI)
9841 ;-------------------------------------------------------------
9842 ; shanc - shift arithmetic non carry (m32)
9843 ;-------------------------------------------------------------
9845 ; TODO check semantics
9847 (binary-arith32-imm-dst-defn QI SI .l 0 shanc X #xC #x2 #x1 sha-sem)
9849 ;-------------------------------------------------------------
9850 ; shl - shift logical
9851 ;-------------------------------------------------------------
9853 ; TODO future: split this into .b and .w semantics
9854 (define-pmacro (shl-sem mode src1 dst)
9855 (sequence ((mode result)(mode shift)(mode shmode))
9857 ((#x0) (set shift 1))
9858 ((#x1) (set shift 2))
9859 ((#x2) (set shift 3))
9860 ((#x3) (set shift 4))
9861 ((#x4) (set shift 5))
9862 ((#x5) (set shift 6))
9863 ((#x6) (set shift 7))
9864 ((#x7) (set shift 8))
9865 ((-8) (set shift -1))
9866 ((-7) (set shift -2))
9867 ((-6) (set shift -3))
9868 ((-5) (set shift -4))
9869 ((-4) (set shift -5))
9870 ((-3) (set shift -6))
9871 ((-2) (set shift -7))
9872 ((-1) (set shift -8))
9873 (else (set shift 0))
9876 (set shmode (srl shmode #x8))
9877 (if (lt mode shift #x0) (set result (srl mode dst (mul shift -1))))
9878 (if (gt mode shift 0) (set result (sll mode dst shift)))
9879 (if (eq shmode #x0) ; QI
9882 (if (lt mode shift #x0)
9883 (set cbitamt (sub #x8 shift)); srl
9884 (set cbitamt (sub shift 1))) ; sll
9885 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9886 (set obit (ne (and dst #x80) (and result #x80)))
9888 (if (eq shmode #xff) ; HI
9891 (if (lt mode shift #x0)
9892 (set cbitamt (sub 16 shift)) ; srl
9893 (set cbitamt (sub shift 1))) ; sll
9894 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9895 (set obit (ne (and dst #x8000) (and result #x8000)))
9897 (set-z-and-s result)
9900 (define-pmacro (shlr1h-sem mode dst)
9901 (sequence ((mode result)(mode shmode))
9903 (set shmode (srl shmode #x8))
9904 (if (lt mode (reg h-r1h) 0) (set result (srl mode dst (reg h-r1h))))
9905 (if (gt mode (reg h-r1h) 0) (set result (sll mode dst (reg h-r1h))))
9906 (if (eq shmode #x0) ; QI
9909 (if (lt mode (reg h-r1h) #x0)
9910 (set cbitamt (sub #x8 (reg h-r1h))) ; srl
9911 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9912 (set cbit (srl (and (sll dst cbitamt) #x80) #x7))
9913 (set obit (ne (and dst #x80) (and result #x80)))
9915 (if (eq shmode #xff) ; HI
9918 (if (lt mode (reg h-r1h) #x0)
9919 (set cbitamt (sub 16 (reg h-r1h))) ; srl
9920 (set cbitamt (sub (reg h-r1h) 1))) ; sll
9921 (set cbit (srl (and (sll dst cbitamt) #x8000) #xf))
9922 (set obit (ne (and dst #x8000) (and result #x8000)))
9924 (set-z-and-s result)
9927 ; shl.BW #imm4,dst (m16 #1 m32 #1)
9928 (binary-arith16-shimm4-dst-defn QI .b 0 0 shl (f-0-4 #xE) (f-4-3 4) shl-sem)
9929 (binary-arith16-shimm4-dst-defn HI .w 0 1 shl (f-0-4 #xE) (f-4-3 4) shl-sem)
9930 (binary-arith32-shimm4-dst-defn QI .b 0 0 shl #x7 #x0 shl-sem)
9931 (binary-arith32-shimm4-dst-defn HI .w 0 1 shl #x7 #x0 shl-sem)
9932 ; shl.BW r1h,dst (m16 #2 m32 #3)
9933 (dni shl16.b-dst "shl.b r1h,dest" ((machine 16))
9934 ("shl.b r1h,${dst16-16-QI}")
9935 (+ (f-0-4 7) (f-4-4 4) (f-8-4 #xE) dst16-16-QI)
9936 (shlr1h-sem HI dst16-16-QI)
9938 (dni shl16.w-dst "shl.w r1h,dest" ((machine 16))
9939 ("shl.w r1h,${dst16-16-HI}")
9940 (+ (f-0-4 7) (f-4-4 5) (f-8-4 #xE) dst16-16-HI)
9941 (shlr1h-sem HI dst16-16-HI)
9943 (dni shl32.b-dst "shl.b r1h,dest" ((machine 32))
9944 ("shl.b r1h,${dst32-16-Unprefixed-QI}")
9945 (+ (f-0-4 #xA) dst32-16-Unprefixed-QI (f-7-1 0) (f-10-2 3) (f-12-4 #xE))
9946 (shlr1h-sem QI dst32-16-Unprefixed-QI)
9948 (dni shl32.w-dst "shl.w r1h,dest" ((machine 32))
9949 ("shl.w r1h,${dst32-16-Unprefixed-HI}")
9950 (+ (f-0-4 #xA) dst32-16-Unprefixed-HI (f-7-1 1) (f-10-2 3) (f-12-4 #xE))
9951 (shlr1h-sem HI dst32-16-Unprefixed-HI)
9953 ; shl.L #imm,dst (m16 #3)
9954 (dni shl16-L-imm-r2r0 "shl.L #Imm-sh-12-s4,r2r0" ((machine 16))
9955 "shl.l #${Imm-sh-12-s4},r2r0"
9956 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x8) Imm-sh-12-s4)
9957 (shl-sem SI Imm-sh-12-s4 (reg h-r2r0))
9959 (dni shl16-L-imm-r3r1 "shl.L #Imm-sh-12-s4,r3r1" ((machine 16))
9960 "shl.l #${Imm-sh-12-s4},r3r1"
9961 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 #x9) Imm-sh-12-s4)
9962 (shl-sem SI Imm-sh-12-s4 (reg h-r3r1))
9964 ; shl.L r1h,dst (m16 #4)
9965 (dni shl16-L-r1h-r2r0 "shl.L r1h,r2r0" ((machine 16))
9967 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 0) (f-12-4 1))
9968 (shl-sem SI (reg h-r1h) (reg h-r2r0))
9970 (dni shl16-L-r1h-r3r1 "shl.L r1h,r3r1" ((machine 16))
9972 (+ (f-0-4 #xE) (f-4-4 #xB) (f-8-4 1) (f-12-4 1))
9973 (shl-sem SI (reg h-r1h) (reg h-r3r1))
9975 ; shl.L #imm8,dst (m32 #2)
9976 (binary-arith32-imm-dst-defn QI SI .l 0 shl X #x9 #x2 #x1 shl-sem)
9977 ; shl.L r1h,dst (m32 #4)
9978 (dni shl32.l-dst "shl.l r1h,dest" ((machine 32))
9979 ("shl.l r1h,${dst32-16-Unprefixed-SI}")
9980 (+ (f-0-4 #xC) dst32-16-Unprefixed-SI (f-7-1 0) (f-10-2 0) (f-12-4 1))
9981 (shlr1h-sem QI dst32-16-Unprefixed-SI)
9984 ;-------------------------------------------------------------
9985 ; shlnc - shift logical non carry
9986 ;-------------------------------------------------------------
9988 ; TODO check semantics
9990 (binary-arith32-imm-dst-defn QI SI .l 0 shlnc X #x8 #x2 #x1 shl-sem)
9992 ;-------------------------------------------------------------
9993 ; sin - string input (m32)
9994 ;-------------------------------------------------------------
9997 (dni sin32.b "sin" ((machine 32))
9999 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 8) (f-12-4 3))
10000 (c-call VOID "sin_QI_semantics")
10003 (dni sin32.w "sin" ((machine 32))
10005 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 9) (f-12-4 3))
10006 (c-call VOID "sin_HI_semantics")
10009 ;-------------------------------------------------------------
10010 ; smovb - string move backward
10011 ;-------------------------------------------------------------
10014 (dni smovb16.b "smovb.b" ((machine 16))
10016 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 9))
10017 (c-call VOID "smovb_QI_semantics")
10020 (dni smovb16.w "smovb.w" ((machine 16))
10022 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 9))
10023 (c-call VOID "smovb_HI_semantics")
10026 (dni smovb32.b "smovb.b" ((machine 32))
10028 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 8) (f-12-4 3))
10029 (c-call VOID "smovb_QI_semantics")
10032 (dni smovb32.w "smovb.w" ((machine 32))
10034 (+ (f-0-4 #xB) (f-4-4 6) (f-8-4 9) (f-12-4 3))
10035 (c-call VOID "smovb_HI_semantics")
10038 ;-------------------------------------------------------------
10039 ; smovf - string move forward (m32)
10040 ;-------------------------------------------------------------
10043 (dni smovf16.b "smovf.b" ((machine 16))
10045 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 8))
10046 (c-call VOID "smovf_QI_semantics")
10049 (dni smovf16.w "smovf.w" ((machine 16))
10051 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 8))
10052 (c-call VOID "smovf_HI_semantics")
10055 (dni smovf32.b "smovf.b" ((machine 32))
10057 (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 8) (f-12-4 3))
10058 (c-call VOID "smovf_QI_semantics")
10061 (dni smovf32.w "smovf.w" ((machine 32))
10063 (+ (f-0-4 #xB) (f-4-4 0) (f-8-4 9) (f-12-4 3))
10064 (c-call VOID "smovf_HI_semantics")
10067 ;-------------------------------------------------------------
10068 ; smovu - string move unequal (m32)
10069 ;-------------------------------------------------------------
10072 (dni smovu.b "smovu.b" ((machine 32))
10074 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 8) (f-12-4 3))
10075 (c-call VOID "smovu_QI_semantics")
10078 (dni smovu.w "smovu.w" ((machine 32))
10080 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 9) (f-12-4 3))
10081 (c-call VOID "smovu_HI_semantics")
10084 ;-------------------------------------------------------------
10085 ; sout - string output (m32)
10086 ;-------------------------------------------------------------
10089 (dni sout.b "sout.b" ((machine 32))
10091 (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 8) (f-12-4 3))
10092 (c-call VOID "sout_QI_semantics")
10095 (dni sout.w "sout" ((machine 32))
10097 (+ (f-0-4 #xB) (f-4-4 4) (f-8-4 9) (f-12-4 3))
10098 (c-call VOID "sout_HI_semantics")
10101 ;-------------------------------------------------------------
10102 ; sstr - string store
10103 ;-------------------------------------------------------------
10106 (dni sstr16.b "sstr.b" ((machine 16))
10108 (+ (f-0-4 7) (f-4-4 #xC) (f-8-4 #xE) (f-12-4 #xA))
10109 (c-call VOID "sstr_QI_semantics")
10112 (dni sstr16.w "sstr.w" ((machine 16))
10114 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xE) (f-12-4 #xA))
10115 (c-call VOID "sstr_HI_semantics")
10118 (dni sstr.b "sstr" ((machine 32))
10120 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 0) (f-12-4 3))
10121 (c-call VOID "sstr_QI_semantics")
10124 (dni sstr.w "sstr" ((machine 32))
10126 (+ (f-0-4 #xB) (f-4-4 8) (f-8-4 1) (f-12-4 3))
10127 (c-call VOID "sstr_HI_semantics")
10130 ;-------------------------------------------------------------
10131 ; stnz - store on not zero
10132 ;-------------------------------------------------------------
10134 (define-pmacro (stnz-sem mode src dst)
10136 (if (ne zbit (const 1))
10139 ; stnz #imm8,dst3 (m16)
10140 (binary-arith16-b-S-imm8-dst3 stnz "" (f-0-4 #xD) (f-4-1 0) stnz-sem)
10141 ; stnz.BW #imm,dst (m32)
10142 (binary-arith32-imm-dst-defn QI QI .b 0 stnz X #x9 #x1 #xF stnz-sem)
10143 (binary-arith32-imm-dst-defn HI HI .w 1 stnz X #x9 #x1 #xF stnz-sem)
10145 ;-------------------------------------------------------------
10146 ; stz - store on zero
10147 ;-------------------------------------------------------------
10149 (define-pmacro (stz-sem mode src dst)
10151 (if (eq zbit (const 1))
10154 ; stz #imm8,dst3 (m16)
10155 (binary-arith16-b-S-imm8-dst3 stz "" (f-0-4 #xC) (f-4-1 1) stz-sem)
10156 ; stz.BW #imm,dst (m32)
10157 (binary-arith32-imm-dst-defn QI QI .b 0 stz X #x9 #x0 #xF stz-sem)
10158 (binary-arith32-imm-dst-defn HI HI .w 1 stz X #x9 #x0 #xF stz-sem)
10160 ;-------------------------------------------------------------
10161 ; stzx - store on zero extention
10162 ;-------------------------------------------------------------
10164 (define-pmacro (stzx-sem mode src1 src2 dst)
10166 (if (eq zbit (const 1))
10170 ; stzx #imm8,dst3 (m16)
10171 (dni stzx16-imm8-imm8-r0h "stzx #Imm8,#Imm8,r0h" ((machine 16))
10172 ("stzx #${Imm-8-QI},#${Imm-16-QI},r0h")
10173 (+ (f-0-4 #xD) (f-4-4 #xB) Imm-8-QI Imm-16-QI)
10174 (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0h))
10176 (dni stzx16-imm8-imm8-r0l "stzx #Imm8,#Imm8,r0l" ((machine 16))
10177 ("stzx #${Imm-8-QI},#${Imm-16-QI},r0l")
10178 (+ (f-0-4 #xD) (f-4-4 #xC) Imm-8-QI Imm-16-QI)
10179 (stzx-sem QI Imm-8-QI Imm-16-QI (reg h-r0l))
10181 (dni stzx16-imm8-imm8-dsp8sb "stzx #Imm8,#Imm8,dsp8[sb]" ((machine 16))
10182 ("stzx #${Imm-8-QI},#${Imm-24-QI},${Dsp-16-u8}[sb]")
10183 (+ (f-0-4 #xD) (f-4-4 #xD) Imm-8-QI Dsp-16-u8 Imm-24-QI)
10184 (stzx-sem QI Imm-8-QI Imm-16-QI (mem16 QI (add (reg h-sb) Dsp-24-u8)))
10186 (dni stzx16-imm8-imm8-dsp8fb "stzx #Imm8,#Imm8,dsp8[fb]" ((machine 16))
10187 ("stzx #${Imm-8-QI},#${Imm-24-QI},${Dsp-16-s8}[fb]")
10188 (+ (f-0-4 #xD) (f-4-4 #xE) Imm-8-QI Dsp-16-s8 Imm-24-QI)
10189 (stzx-sem QI Imm-8-QI Imm-24-QI (mem16 QI (add (reg h-fb) Dsp-16-s8)))
10191 (dni stzx16-imm8-imm8-abs16 "stzx #Imm8,#Imm8,abs16" ((machine 16))
10192 ("stzx #${Imm-8-QI},#${Imm-32-QI},${Dsp-16-u16}")
10193 (+ (f-0-4 #xD) (f-4-4 #xE) Imm-8-QI Dsp-16-u16 Imm-32-QI)
10194 (stzx-sem QI Imm-8-QI Imm-32-QI (mem16 QI Dsp-16-u16))
10196 ; stzx.BW #imm,dst (m32)
10197 (insn-imm1-imm2-dst-Unprefixed stzx #x9 #x3 #xF stzx-sem)
10199 ;-------------------------------------------------------------
10200 ; subx - subtract extend (m32)
10201 ;-------------------------------------------------------------
10203 (define-pmacro (subx-sem mode src1 dst)
10204 (sequence ((mode result))
10205 (set result (sub mode dst (ext mode src1)))
10206 (set obit (sub-oflag mode dst (ext mode src1) 0))
10207 (set cbit (sub-cflag mode dst (ext mode src1) 0))
10209 (set-z-and-s result)))
10211 (binary-arith32-imm-dst-defn QI SI "" 0 subx G #x9 #x1 #x1 subx-sem)
10213 (binary-arith32-src-dst-defn QI SI "" 0 subx G #x1 #x0 subx-sem)
10215 ;-------------------------------------------------------------
10217 ;-------------------------------------------------------------
10219 (define-pmacro (tst-sem mode src1 dst)
10220 (sequence ((mode result))
10221 (set result (and mode dst src1))
10222 (set-z-and-s result))
10225 ; tst.BW #imm,dst (m16 #1 m32 #1)
10226 (binary-arith-imm-dst tst G (f-0-4 7) (f-4-3 3) (f-8-4 0) #x9 #x3 #xE tst-sem)
10227 ; tst.BW src,dst (m16 #2 m32 #3)
10228 (binary-arith16-src-dst-defn QI QI .b 0 tst X (f-0-4 #x8) (f-4-3 0) tst-sem)
10229 (binary-arith16-src-dst-defn HI HI .w 1 tst X (f-0-4 #x8) (f-4-3 0) tst-sem)
10230 (binary-arith32-src-dst-Prefixed QI QI .b 0 tst G #x1 #x9 tst-sem)
10231 (binary-arith32-src-dst-Prefixed HI HI .w 1 tst G #x1 #x9 tst-sem)
10232 ; tst.BW:S #imm,dst2 (m32 #2)
10233 (binary-arith32-s-imm-dst QI .b 0 tst #x0 #x6 tst-sem)
10234 (binary-arith32-s-imm-dst HI .w 1 tst #x0 #x6 tst-sem)
10236 ;-------------------------------------------------------------
10238 ;-------------------------------------------------------------
10240 (dni und16 "und" ((machine 16))
10242 (+ (f-0-4 #xF) (f-4-4 #xF))
10246 (dni und32 "und" ((machine 32))
10248 (+ (f-0-4 #xF) (f-4-4 #xF))
10252 ;-------------------------------------------------------------
10254 ;-------------------------------------------------------------
10257 (dni wait16 "wait" ((machine 16))
10259 (+ (f-0-4 7) (f-4-4 #xD) (f-8-4 #xF) (f-12-4 3))
10263 (dni wait "wait" ((machine 32))
10265 (+ (f-0-4 #xB) (f-4-4 2) (f-8-4 0) (f-12-4 3))
10269 ;-------------------------------------------------------------
10271 ;-------------------------------------------------------------
10273 (define-pmacro (xchg-sem mode src dst)
10274 (sequence ((mode result))
10279 (define-pmacro (xchg16-defn mode sz szc src srcreg)
10280 (dni (.sym xchg16 sz - srcreg)
10281 (.str "xchg" sz "-" srcreg ",dst16-16-" mode)
10283 (.str "xchg." sz " " srcreg ",${dst16-16-" mode "}")
10284 (+ (f-0-4 #x7) (f-4-3 #x5) (f-7-1 szc) (f-8-2 0) (f-10-2 src) (.sym dst16-16- mode))
10285 (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst16-16- mode))
10288 (xchg16-defn QI b 0 0 r0l)
10289 (xchg16-defn QI b 0 1 r0h)
10290 (xchg16-defn QI b 0 2 r1l)
10291 (xchg16-defn QI b 0 3 r1h)
10292 (xchg16-defn HI w 1 0 r0)
10293 (xchg16-defn HI w 1 1 r1)
10294 (xchg16-defn HI w 1 2 r2)
10295 (xchg16-defn HI w 1 3 r3)
10296 (define-pmacro (xchg32-defn mode sz szc src srcreg)
10297 (dni (.sym xchg32 sz - srcreg)
10298 (.str "xchg" sz "-" srcreg ",dst32-16-Unprefixed-" mode)
10300 (.str "xchg." sz " " srcreg ",${dst32-16-Unprefixed-" mode "}")
10301 (+ (f-0-4 #xD) (.sym dst32-16-Unprefixed- mode) (f-7-1 szc) (f-10-2 0) (f-12-1 1) (f-13-3 src))
10302 (xchg-sem mode (reg (.sym h- srcreg)) (.sym dst32-16-Unprefixed- mode))
10305 (xchg32-defn QI b 0 0 r0l)
10306 (xchg32-defn QI b 0 1 r1l)
10307 (xchg32-defn QI b 0 2 a0)
10308 (xchg32-defn QI b 0 3 a1)
10309 (xchg32-defn QI b 0 4 r0h)
10310 (xchg32-defn QI b 0 5 r1h)
10311 (xchg32-defn HI w 1 0 r0)
10312 (xchg32-defn HI w 1 1 r1)
10313 (xchg32-defn HI w 1 2 a0)
10314 (xchg32-defn HI w 1 3 a1)
10315 (xchg32-defn HI w 1 4 r2)
10316 (xchg32-defn HI w 1 5 r3)
10318 ;-------------------------------------------------------------
10319 ; xor - exclusive or
10320 ;-------------------------------------------------------------
10322 (define-pmacro (xor-sem mode src1 dst)
10323 (sequence ((mode result))
10324 (set result (xor mode src1 dst))
10325 (set-z-and-s result)
10329 ; xor.BW #imm,dst (m16 #1 m32 #1)
10330 (binary-arith-imm-dst xor G (f-0-4 7) (f-4-3 3) (f-8-4 1) #x9 #x0 #xE xor-sem)
10331 ; xor.BW src,dst (m16 #3 m32 #3)
10332 (binary-arith-src-dst xor G (f-0-4 #x8) (f-4-3 4) #x1 #x9 xor-sem)
10334 ;-------------------------------------------------------------
10336 ;-------------------------------------------------------------
10338 (define-pmacro (exts-sem smode dmode src dst)
10339 (set dst (ext dmode (trunc smode src)))
10341 (define-pmacro (extz-sem smode dmode src dst)
10342 (set dst (zext dmode (trunc smode src)))
10345 ; exts.b dst for m16c
10346 (ext16-defn QI HI .b 0 exts (f-0-4 7) (f-4-3 6) (f-8-4 6) exts-sem)
10348 ; exts.w r0 for m16c
10353 (+ (f-0-4 #x7) (f-4-4 #xC) (f-8-4 #xF) (f-12-4 3))
10354 (exts-sem HI SI R0 R2R0)
10357 ; exts.size dst for m32c
10358 (ext32-defn QI HI .b 0 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem)
10359 (ext32-defn HI SI .w 1 exts (f-0-4 #xC) (f-10-2 1) (f-12-4 #xE) exts-sem)
10360 ; exts.b src,dst for m32c
10361 (ext32-binary-defn exts .b #x1 #x7 exts-sem)
10363 ; extz.b src,dst for m32c
10364 (ext32-binary-defn extz "" #x1 #xB extz-sem)
10366 ;-------------------------------------------------------------
10368 ;-------------------------------------------------------------
10371 (dni srcind "SRC-INDIRECT" ((machine 32))
10373 (+ (f-0-4 4) (f-4-4 1))
10374 (set (reg h-src-indirect) 1)
10377 (dni destind "DEST-INDIRECT" ((machine 32))
10379 (+ (f-0-4 0) (f-4-4 9))
10380 (set (reg h-dst-indirect) 1)
10383 (dni srcdestind "SRC-DEST-INDIRECT" ((machine 32))
10384 ("src-dest-indirect")
10385 (+ (f-0-4 4) (f-4-4 9))
10386 (sequence () (set (reg h-src-indirect) 1) (set (reg h-dst-indirect) 1))