1 /* m32c.opc --- semantics for m32c opcodes. -*- mode: c -*-
3 Copyright (C) 2005-2014 Free Software Foundation, Inc.
4 Contributed by Red Hat, Inc.
6 This file is part of the GNU simulators.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
30 #define AU __attribute__((unused))
32 #define tprintf if (trace) printf
48 #define M32C_ONLY() /* FIXME: add something here */
50 #define GETBYTE() (op[opi++] = getbyte())
52 #define UNSUPPORTED() unsupported("unsupported", m32c_opcode_pc)
53 #define NOTYET() unsupported("unimplemented", m32c_opcode_pc)
56 unsupported (char *tag, int orig_pc)
59 printf("%s opcode at %08x\n", tag, orig_pc);
64 printf(" %s", bits(b>>4, 4));
65 printf(" %s", bits(b, 4));
72 printf(" %02x", mem_get_pc ());
86 rv = mem_get_qi (get_reg(pc));
89 rv = mem_get_hi (get_reg(pc));
92 rv = mem_get_psi (get_reg(pc));
95 rv = mem_get_si (get_reg(pc));
102 #define IMM4() (immm >= 8 ? 7 - immm : immm + 1)
104 #define NO_PREFIX() PREFIX(0,0,0)
106 /* Indicate which sorts of prefixes are allowed for the current
109 prefix (src_allowed, dest_allowed, index_bytewidth)
111 /* At the moment, we don't do anything with this information. We
112 just wanted to get the information entered in some
113 machine-readable form while we were going through all the
117 #define MATH_OP(dc,s,c,op) \
121 mb = s & b2mask[dc.bytes]; \
122 ll = (long long)ma op (long long)mb op c; \
123 tprintf("0x%x " #op " 0x%x " #op " 0x%x = 0x%llx\n", ma, mb, c, ll); \
124 ma = sign_ext (ma, dc.bytes * 8); \
125 mb = sign_ext (s, dc.bytes * 8); \
127 tprintf("%d " #op " %d " #op " %d = %d\n", ma, mb, c, v); \
128 set_oszc (v, dc.bytes, (1 op 1) ? (ll > b2mask[dc.bytes]) : (ll >= 0)); \
132 #define LOGIC_OP(dc,s,op) \
136 mb = s & b2mask[dc.bytes]; \
138 tprintf("0x%x " #op " 0x%x = 0x%x\n", ma, mb, v); \
139 set_sz (v, dc.bytes); \
143 #define BIT_OP(dc,bit,expr) \
144 b = get_bit2 (dc, bitindex == -1 ? bit : bitindex); \
146 tprintf ("b=%d, bit=%d, carry=%d, %s = %d\n", \
147 b, bitindex == -1 ? bit : bitindex, carry, #expr, v); \
148 put_bit2 (dc, bitindex == -1 ? bit : bitindex, v);
150 #define BIT_OPC(dc,bit,expr) \
151 b = get_bit2 (dc, bitindex == -1 ? bit : bitindex); \
153 tprintf ("b=%d, bit=%d, carry=%d, %s = %d\n", \
154 b, bitindex == -1 ? bit : bitindex, carry, #expr, v); \
157 #define carry (FLAG_C ? 1 : 0)
160 cmp (int d, int s, int bytes)
164 b = sign_ext (d, bytes*8) - sign_ext (s, bytes*8);
165 tprintf ("cmp: %x - %x = %08x, %x - %x = %d\n",
167 sign_ext(d,bytes*8), sign_ext(s,bytes*8), b);
171 if (b & b2signbit[bytes])
173 if ((d & b2mask[bytes]) >= (s & b2mask[bytes]))
175 if (b < b2minsigned[bytes] || b > b2maxsigned[bytes])
178 set_flags (FLAGBIT_Z | FLAGBIT_S | FLAGBIT_O | FLAGBIT_C, f);
182 dadd_op (int ddd, int dd, int sss, int ss, int imm, int add, int cy, int w)
191 sc = decode_src23 (sss, ss, w+1);
194 dc = decode_dest23 (ddd, dd, w+1);
202 tprintf("decimal: %d %s %d", a, add?"+":"-", b);
204 tprintf(" c=%d", carry);
211 cy = res > (w ? 9999 : 99);
220 res += w ? 10000 : 100;
223 res = int2bcd (res, w);
224 tprintf(" = %x\n", res);
226 set_szc (res, w+1, cy);
230 #define DADDV(A,C) dadd_op(ddd, dd, sss, ss, 0, A, C, w)
231 #define DADDI(A,C) dadd_op(ddd, dd, 0, 0, 1, A, C, w)
234 div_op (int sss, int ss, int u, int x, int bytes)
243 sc = decode_dest23 (sss, ss, bytes);
247 v = get_reg (bytes > 1 ? r2r0 : r0);
251 /* FIXME? do we sign extend a0/a1 to .L? Docs say zero extend. */
252 s = sign_ext (s, bytes*8);
253 v = sign_ext (v, bytes*8);
258 set_flags (FLAGBIT_O, FLAGBIT_O);
264 a = (unsigned int)v / (unsigned int)s;
265 b = (unsigned int)v % (unsigned int)s;
281 tprintf ("%d / %d = %d rem %d\n", v, s, a, b);
282 if ((!u && (a > b2maxsigned[bytes]
283 || a < b2minsigned[bytes]))
284 || (u && (a > b2mask[bytes])))
285 set_flags (FLAGBIT_O, FLAGBIT_O);
287 set_flags (FLAGBIT_O, 0);
306 index_op (int sss, int ss, int do_s, int do_d, int scale, int w)
308 srcdest sc = decode_src23 (sss, ss, w+1);
309 int v = get_src (sc) * scale;
310 tprintf("%d = %d * %d, %d %d\n", v, get_src(sc), scale, do_s, do_d);
311 decode_index (do_s * v, do_d * v);
313 #define INDEXOP(scale,do_s,do_d) \
314 index_op (sss, ss, do_s, do_d, scale, w); goto next_opcode
317 rot_op (srcdest sd, int rotc, int count)
319 int mask = (sd.bytes == 2) ? 0xffff : 0xff;
320 int msb = (sd.bytes == 2) ? 0x8000 : 0x80;
321 int v = get_src (sd);
324 tprintf("%s %x by %d\n", rotc ? "rotc" : "rot", v, count);
325 tprintf (": %s %d\n", bits(v, 8*sd.bytes), c);
328 ct = (v & msb) ? 1 : 0;
333 tprintf (": %s %d\n", bits(v, 8*sd.bytes), c);
340 v |= (rotc ? c : ct) * msb;
342 tprintf (": %s %d\n", bits(v, 8*sd.bytes), c);
346 set_szc (v, sd.bytes, c);
350 shift_op (srcdest sd, int arith, int count, int setc)
352 int mask = (sd.bytes == 2) ? 0xffff : 0xff;
353 int msb = (sd.bytes == 2) ? 0x8000 : 0x80;
354 int v = get_src (sd);
364 tprintf("%s %x by %d\n", arith ? "sha" : "shl", v, count);
365 tprintf (": %s %d %d\n", bits(v, 8*sd.bytes), c, o);
368 c = (v & msb) ? 1 : 0;
371 if (c != ((v & msb) ? 1 : 0))
373 tprintf (": %s %d %d\n", bits(v, 8*sd.bytes), c, o);
380 v = (v & msb) | (v >> 1);
382 v = (v >> 1) & (msb - 1);
383 tprintf (": %s %d %d\n", bits(v, 8*sd.bytes), c, o);
387 set_sz (v, sd.bytes);
390 set_flags (FLAGBIT_O, o ? FLAGBIT_O : 0);
399 unsigned char op[40];
406 int t0, t1=0, t2, t3=0;
409 step_result = M32C_MAKE_STEPPED ();
411 decode_indirect (0, 0);
416 m32c_opcode_pc = get_reg (pc);
418 tprintf("trace: decode pc = %06x\n", m32c_opcode_pc);
420 if (m32c_opcode_pc == 0)
423 printf("Abort: PC is zero, here from:\n");
425 printf(" 0x%06x\n", pcs[(ipcs+15-i)%16]);
426 return M32C_MAKE_HIT_BREAK ();
428 pcs[ipcs++] = m32c_opcode_pc;
431 /** VARY sss 000 001 010 011 100 */
432 /** VARY ddd 000 001 010 011 100 */
434 /** 0000 1001 indirect dest */
436 decode_indirect (0, 1);
439 /** 0100 0001 indirect src */
441 decode_indirect (1, 0);
444 /** 0100 1001 indirect src and dest */
446 decode_indirect (1, 1);
449 /** 1010 ddd w dd01 1111 ABS.size dest */
452 dc = decode_dest23 (ddd, dd, w+1);
453 v = sign_ext (get_src (dc), w?16:8);
455 tprintf("abs(%d) = %d\n", v, a);
459 /** 0000 0001 1000 ddd w dd10 1110 ADC.size #IMM,dest */
462 dc = decode_dest23 (ddd, dd, w+1);
464 MATH_OP (dc, imm, carry, +);
466 /** 0000 0001 1sss ddd w dd ss 0100 ADC.size src,dest */
469 sc = decode_src23 (sss, ss, w+1);
470 dc = decode_dest23 (ddd, dd, w+1);
472 MATH_OP (dc, b, carry, +);
474 /** 1011 ddd w dd01 1110 ADCF.size dest */
477 dc = decode_dest23 (ddd, dd, w+1);
478 MATH_OP (dc, 0, carry, +);
480 /** 1000 ddd w dd10 1110 ADD.size:G #IMM,dest */
483 dc = decode_dest23(ddd, dd, w+1);
485 MATH_OP (dc, imm, 0, +);
487 /** 1000 ddd0 dd11 0001 ADD.L:G #IMM,dest */
490 dc = decode_dest23(ddd, dd, 4);
492 MATH_OP (dc, imm, 0, +);
494 /** 111L ddd w dd11 immm ADD.size:Q #IMM,dest */
497 dc = decode_dest23(ddd, dd, L ? 4 : (w+1));
498 imm = sign_ext (immm, 4);
499 MATH_OP (dc, imm, 0, +);
501 /** 00dd 011w ADD.size:S #IMM,dest */
504 dc = decode_dest2(dd, w+1);
506 MATH_OP (dc, imm, 0, +);
508 /** 10i0 110d ADD.L:S #IMM,A0/A1 */
511 dc = reg_sd (d ? a1 : a0);
513 MATH_OP (dc, imm, 0, +);
515 /** 1sss ddd w dd ss 1000 ADD.size:G src,dest */
518 sc = decode_src23(sss, ss, w+1);
519 dc = decode_dest23(ddd, dd, w+1);
521 MATH_OP (dc, b, 0, +);
523 /** 1sss ddd1 dd ss 0010 ADD.L:G src,dest */
526 sc = decode_src23(sss, ss, 4);
527 dc = decode_dest23(ddd, dd, 4);
529 MATH_OP (dc, b, 0, +);
531 /** 1011 0110 0001 0011 ADD.L:G #IMM16,SP */
535 b = sign_ext (IMM(2), 16);
536 MATH_OP (dc, b, 0, +);
538 /** 01ii 001i ADD.L:Q #IMM3,SP */
543 MATH_OP (dc, b, 0, +);
545 /** 1011 0110 0000 0011 ADD.L:S #IMM8,SP */
549 b = sign_ext (IMM(1), 8);
550 MATH_OP (dc, b, 0, +);
552 /** 1000 ddd0 dd01 0001 ADDX #IMM,dest */
555 dc = decode_dest23(ddd, dd, 4);
556 imm = sign_ext (IMM(1), 8);
557 MATH_OP (dc, imm, 0, +);
559 /** 1sss ddd0 dd ss 0010 ADDX src,dest */
562 sc = decode_src23(sss, ss, 1);
563 dc = decode_dest23(ddd, dd, 4);
564 b = sign_ext (get_src (sc), 8);
565 MATH_OP (dc, b, 0, +);
567 /** 1111 ddd w dd01 immm ADJNZ.size #IMM,dest,label */
570 dc = decode_dest23 (ddd, dd, w+1);
572 imm = sign_ext(immm, 4);
573 tprintf("%d + %d = %d\n", v, imm, v+imm);
576 a = sign_ext (IMM(1), 8);
577 if ((v & (w ? 0xffff : 0xff)) != 0)
579 tprintf("jmp: %x + 2 + %d = ", get_reg (pc), a);
580 put_reg (pc, m32c_opcode_pc + 2 + a);
581 tprintf("%x\n", get_reg (pc));
584 /** 1000 ddd w dd11 1111 AND.size:G #IMM,dest */
587 dc = decode_dest23(ddd, dd, w+1);
589 LOGIC_OP (dc, imm, &);
591 /** 01dd 110w AND.size:S #IMM,dest */
594 dc = decode_dest2(dd, w+1);
596 LOGIC_OP (dc, imm, &);
598 /** 1sss ddd w dd ss 1101 AND.size:G src,dest */
601 sc = decode_src23(sss, ss, w+1);
602 dc = decode_dest23(ddd, dd, w+1);
606 /** 0000 0001 1101 sss0 ss00 1bit BAND src */
608 sc = decode_src23 (sss, ss, 1);
609 BIT_OPC (sc, bit, b & carry);
611 /** 1101 ddd0 dd11 0bit BCLR dest */
613 dc = decode_dest23 (ddd, dd, 1);
616 /** 1100 ddd w dd10 1110 BITINDEX.size src */
619 dc = decode_dest23 (ddd, dd, w+1);
620 bitindex = get_src (dc);
621 tprintf ("bitindex set to %d\n", bitindex);
624 /** 1101 ddd0 dd01 0bit BMcnd dest */
627 dc = decode_dest23 (ddd, dd, 1);
628 if (condition_true (IMM (1)))
629 put_bit2 (dc, bit, 1);
631 put_bit2 (dc, bit, 0);
633 /** 1101 1001 0c10 1cnd BMcnd C */
636 if (condition_true (c * 8 + cnd))
641 /** 0000 0001 1101 sss0 ss01 1bit BNAND src */
644 sc = decode_src23 (sss, ss, 1);
645 BIT_OPC (sc, bit, (!b) & carry);
647 /** 0000 0001 1101 sss0 ss11 0bit BNOR src */
650 sc = decode_src23 (sss, ss, 1);
651 BIT_OPC (sc, bit, (!b) | carry);
653 /** 1101 ddd0 dd01 1bit BNOT dest */
656 dc = decode_dest23 (ddd, dd, 1);
657 BIT_OP (dc, bit, !b);
659 /** 0000 0001 1101 sss0 ss00 0bit BNTST src */
662 sc = decode_dest23 (sss, ss, 1);
663 b = get_bit2 (sc, bit);
666 /** 0000 0001 1101 sss0 ss11 1bit BNXOR src */
669 sc = decode_src23 (sss, ss, 1);
670 BIT_OPC (sc, bit, !b ^ carry);
672 /** 0000 0001 1101 sss0 ss10 0bit BOR src */
675 sc = decode_src23 (sss, ss, 1);
676 BIT_OPC (sc, bit, b | carry);
680 /* We report the break to our caller with the PC still pointing at the
681 breakpoint instruction. */
682 put_reg (pc, m32c_opcode_pc);
685 if (in_gdb || (regs.r_intbl == 0 && regs.r_intbh == 0))
686 return M32C_MAKE_HIT_BREAK ();
687 if (mem_get_qi (0xFFFFE7) == 0xff)
688 trigger_based_interrupt (0);
690 trigger_fixed_interrupt (0xFFFFE4);
692 /** 1111 1110 GBRK */
694 /* This alternate break, which is not part of the chip's opcode set,
695 is here in case you need to debug a program that itself uses the
696 chip's BRK opcode. You'll need to modify your copy of GDB to use
697 this opcode instead of the real BRK. */
700 /* We report the break to our caller with the PC still pointing at the
701 breakpoint instruction. */
702 put_reg (pc, m32c_opcode_pc);
704 printf("[gdb break]\n");
705 return M32C_MAKE_HIT_BREAK ();
707 /** 0000 1000 BRK2 */
710 printf("[break2]\n");
712 return M32C_MAKE_HIT_BREAK ();
713 if (mem_get_qi (0xFFFFE7) == 0xff)
714 trigger_based_interrupt (0);
716 trigger_fixed_interrupt (0xFFFFE4);
718 /** 1101 ddd0 dd11 1bit BSET dest */
720 dc = decode_dest23 (ddd, dd, 1);
723 /** 1101 sss0 ss00 0bit BTST:G src */
726 sc = decode_src23 (sss, ss, 1);
727 b = get_bit2 (sc, bit);
730 /** 00bb 101b BTST:S src */
732 sc = decode_src23 (3, 3, 1); /* bit,base:19 */
733 b = get_bit2 (sc, bb*2 + b);
736 /** 1101 ddd0 dd10 0bit BTSTC dest */
739 sc = decode_dest23 (ddd, dd, 1);
740 b = get_bit2 (sc, bit);
742 put_bit2 (sc, bit, 0);
744 /** 1101 ddd0 dd10 1bit BTSTS dest */
747 sc = decode_dest23 (ddd, dd, 1);
748 b = get_bit2 (sc, bit);
750 put_bit2 (sc, bit, 1);
752 /** 0000 0001 1101 sss0 ss10 1bit BXOR src */
755 sc = decode_src23 (sss, ss, 1);
756 BIT_OPC (sc, bit, b ^ carry);
758 /** 0000 0001 1000 ddd w dd11 1110 CLIP.size #IMM1,#IMM2,dest */
761 dc = decode_dest23 (ddd, dd, w+1);
762 a = sign_ext (IMM(w+1), w*8+8);
763 b = sign_ext (IMM(w+1), w*8+8);
764 v = sign_ext (get_src (dc), w*8+8);
765 tprintf("clip %d <= %d <= %d : ", a, v, b);
773 /** 1001 ddd w dd10 1110 CMP.size:G #IMM,dest */
776 dc = decode_dest23 (ddd, dd, w+1);
781 /** 1010 ddd0 dd11 0001 CMP.L:G #IMM32,dest */
784 dc = decode_dest23 (ddd, dd, 4);
789 /** 1110 ddd w dd01 immm CMP.size:Q #IMM,dest */
792 dc = decode_dest23 (ddd, dd, w+1);
794 immm = sign_ext (immm, 4);
797 /** 01dd 011w CMP.size:S #IMM,dest */
800 dc = decode_dest2 (dd, w+1);
802 imm = sign_ext (IMM(w+1),w*8+8);
805 /** 1sss ddd w dd ss 0110 CMP.size:G src,dest */
808 sc = decode_src23 (sss, ss, w+1);
809 dc = decode_dest23 (ddd, dd, w+1);
814 /** 1sss ddd1 dd ss 0001 CMP.L:G src,dest */
817 sc = decode_src23 (sss, ss, 4);
818 dc = decode_dest23 (ddd, dd, 4);
823 /** 01dd 000w CMP.size:S src,R0/R0L */
826 dc = decode_dest2 (dd, w+1);
827 a = get_reg (w ? r0 : r0l);
831 /** 1010 ddd0 dd01 0001 CMPX #IMM,dest */
834 dc = decode_dest23 (ddd, dd, 4);
836 imm = sign_ext (IMM(1), 8);
839 /** 0000 0001 1000 ddd w dd00 1110 DADC.size #IMM,dest */
843 /** 0000 0001 1sss ddd w dd ss 1000 DADC.size src,dest */
847 /** 0000 0001 1000 ddd w dd01 1110 DADD.size #IMM,dest */
851 /** 0000 0001 1sss ddd w dd ss 0000 DADD.size src,dest */
855 /** 1011 ddd w dd00 1110 DEC.size dest */
858 dc = decode_dest23 (ddd, dd, w+1);
861 tprintf ("%x -- = %x\n", a, v);
865 /** 1011 0000 010w 0011 DIV.size #IMM */
868 div_op (-1, 0, 0, 0, w+1);
870 /** 1000 sss w ss01 1110 DIV.size src */
873 div_op (sss, ss, 0, 0, w+1);
875 /** 0000 0001 1010 sss1 ss01 1111 DIV.L src */
879 div_op (sss, ss, 0, 0, 4);
881 /** 1011 0000 000w 0011 DIVU.size #IMM */
884 div_op (-1, 0, 1, 0, w+1);
886 /** 1000 sss w ss00 1110 DIVU.size src */
889 div_op (sss, ss, 1, 0, w+1);
891 /** 0000 0001 1010 sss1 ss00 1111 DIVU.L src */
895 div_op (sss, ss, 1, 0, 4);
897 /** 1011 0010 010w 0011 DIVX.size #IMM */
900 div_op (-1, 0, 0, 1, w+1);
902 /** 1001 sss w ss01 1110 DIVX.size src */
905 div_op (sss, ss, 0, 1, w+1);
907 /** 0000 0001 1010 sss1 ss10 1111 DIVX.L src */
911 div_op (sss, ss, 0, 1, 4);
913 /** 0000 0001 1001 ddd w dd00 1110 DSBB.size #IMM,dest */
917 /** 0000 0001 1sss ddd w dd ss 1010 DSBB.size src,dest */
921 /** 0000 0001 1001 ddd w dd01 1110 DSUB.size #IMM,dest */
925 /** 0000 0001 1sss ddd w dd ss 0010 DSUB.size src,dest */
929 /** 1110 1100 ENTER #IMM */
932 put_reg (sp, get_reg (sp) - 4);
933 mem_put_si (get_reg (sp), get_reg (fb));
934 put_reg (fb, get_reg (sp));
935 put_reg (sp, get_reg (sp) - imm);
937 /** 1111 1100 EXITD */
939 put_reg (sp, get_reg (fb));
940 put_reg (fb, mem_get_si (get_reg (sp)));
941 put_reg (sp, get_reg (sp) + 4);
942 put_reg (pc, mem_get_si (get_reg (sp)));
943 put_reg (sp, get_reg (sp) + 4);
945 /** 1100 ddd w dd01 1110 EXTS.size dest */
948 dc = decode_dest23 (ddd, dd, w+1);
949 v = sign_ext (get_src (dc), (w+1)*8);
954 /** 0000 0001 1sss ddd0 dd ss 0111 EXTS.B src,dest */
957 sc = decode_src23 (sss, ss, 1);
958 dc = decode_dest23 (ddd, dd, 2);
959 v = sign_ext (get_src (sc), 8);
963 /** 0000 0001 1sss ddd0 dd ss 1011 EXTZ src,dest */
966 sc = decode_src23 (sss, ss, 1);
967 dc = decode_dest23 (ddd, dd, 2);
972 /** 1101 0011 1110 1dst FCLR dest */
974 set_flags (1 << dst, 0);
976 /** 1001 1111 FREIT */
980 /** 1101 0001 1110 1dst FSET dest */
982 set_flags (1 << dst, 1 << dst);
984 /** 1010 ddd w dd00 1110 INC.size dest */
987 dc = decode_dest23 (ddd, dd, w+1);
990 tprintf ("%x ++ = %x\n", a, v);
994 /** 1000 sss0 ss0w 0011 INDEXB.size src */
996 /** 1010 sss0 ss0w 0011 INDEXBD.size src */
998 /** 1100 sss0 ss0w 0011 INDEXBS.size src */
1000 /** 1001 sss0 ss1w 0011 INDEXL.size src */
1002 /** 1011 sss0 ss1w 0011 INDEXLD.size src */
1004 /** 1001 sss0 ss0w 0011 INDEXLS.size src */
1006 /** 1000 sss0 ss1w 0011 INDEXW.size src */
1008 /** 1010 sss0 ss1w 0011 INDEXWD.size src */
1010 /** 1100 sss0 ss1w 0011 INDEXWS.size src */
1013 /** 1011 1110 vector00 INT #IMM */
1016 trigger_based_interrupt (vector);
1018 /** 1011 1111 INTO */
1022 trigger_fixed_interrupt (0xffffe0);
1024 /** 1ccc 101c Jcnd label */
1027 v = sign_ext (IMM(1), 8);
1028 if (condition_true (ccc*2+c))
1029 put_reg (pc, m32c_opcode_pc + 1 + v);
1031 /** 01dd 101d JMP.S label */
1034 put_reg (pc, m32c_opcode_pc + (dd*2+d) + 2);
1036 /** 1011 1011 JMP.B label */
1039 imm = sign_ext (IMM(1), 8);
1043 printf("[jmp-to-self detected as exit]\n");
1044 return M32C_MAKE_HIT_BREAK ();
1046 put_reg (pc, m32c_opcode_pc + 1 + imm);
1048 /** 1100 1110 JMP.W label */
1051 imm = sign_ext (IMM(2), 16);
1052 put_reg (pc, m32c_opcode_pc + 1 + imm);
1054 /** 1100 1100 JMP.A label */
1060 /** 1100 sss1 ss00 1111 JMPI.W src */
1063 sc = decode_src23 (sss, ss, 2);
1065 a = sign_ext (a, 16);
1066 put_reg (pc, m32c_opcode_pc + a);
1068 /** 1000 sss0 ss00 0001 JMPI.A src */
1071 sc = decode_src23 (sss, ss, 3);
1075 /** 1101 1100 JMPS #IMM8 */
1079 a = 0xff0000 + mem_get_hi (0xfffe00 - imm * 2);
1082 /** 1100 1111 JSR.W label */
1085 imm = sign_ext (IMM(2), 16);
1086 put_reg (sp, get_reg (sp) - 4);
1087 mem_put_si (get_reg (sp), get_reg (pc));
1088 put_reg (pc, m32c_opcode_pc + imm + 1);
1090 /** 1100 1101 JSR.A label */
1094 put_reg (sp, get_reg (sp) - 4);
1095 mem_put_si (get_reg (sp), get_reg (pc));
1098 /** 1100 sss1 ss01 1111 JSRI.W src */
1101 sc = decode_src23 (sss, ss, 2);
1103 a = sign_ext (a, 16);
1104 put_reg (sp, get_reg (sp) - 4);
1105 mem_put_si (get_reg (sp), get_reg (pc));
1106 put_reg (pc, m32c_opcode_pc + a);
1108 /** 1001 sss0 ss00 0001 JSRI.A src */
1111 sc = decode_src23 (sss, ss, 3);
1113 put_reg (sp, get_reg (sp) - 4);
1114 mem_put_si (get_reg (sp), get_reg (pc));
1117 /** 1101 1101 JSRS #IMM8 */
1121 a = 0xff0000 + mem_get_hi (0xfffe00 - imm * 2);
1122 put_reg (sp, get_reg (sp) - 4);
1123 mem_put_si (get_reg (sp), get_reg (pc));
1126 /** 1101 0101 1010 1dst LDC #IMM16,dest */
1129 dc = decode_cr_b (dst, CR_B_DCT0);
1132 /** 1101 0101 0010 1dst LDC #IMM24,dest */
1135 dc = decode_cr_b (dst, CR_B_INTB);
1138 /** 1101 0101 0110 1dst LDC #IMM24,dest */
1141 dc = decode_cr_b (dst, CR_B_DMA0);
1144 /** 0000 0001 1101 sss1 ss00 1dst LDC src,dest */
1147 sc = decode_src23 (sss, ss, 2);
1148 dc = decode_cr_b (dst, CR_B_DCT0);
1152 /** 1101 sss1 ss00 0dst LDC src,dest */
1155 sc = decode_src23 (sss, ss, 3);
1156 dc = decode_cr_b (dst, CR_B_INTB);
1160 /** 0000 0001 1101 sss1 ss00 0dst LDC src,dest */
1163 sc = decode_src23 (sss, ss, 3);
1164 dc = decode_cr_b (dst, CR_B_DMA0);
1168 /** 1011 0110 1100 0011 LDCTX */
1172 /** 1101 0101 1110 1imm LDIPL #IMM */
1174 set_flags (0x7000, imm*0x1000);
1176 /** 0000 0001 1000 ddd w dd11 1111 MAX.size #IMM,dest */
1180 dc = decode_dest23 (ddd, dd, w);
1181 imm = sign_ext (IMM(w), w*8);
1182 a = sign_ext (get_src (dc), w*8);
1183 tprintf ("max %d %d\n", imm, a);
1187 /** 0000 0001 1sss ddd w dd ss 1101 MAX.size src,dest */
1191 sc = decode_src23 (sss, ss, w);
1192 dc = decode_dest23 (ddd, dd, w);
1193 b = sign_ext (get_src (sc), w*8);
1194 a = sign_ext (get_src (dc), w*8);
1195 tprintf ("max %d %d\n", b, a);
1199 /** 0000 0001 1000 ddd w dd10 1111 MIN.size #IMM,dest */
1203 dc = decode_dest23 (ddd, dd, w);
1204 imm = sign_ext (IMM(w), w*8);
1205 a = sign_ext (get_src (dc), w*8);
1206 tprintf ("min %d %d\n", imm, a);
1210 /** 0000 0001 1sss ddd w dd ss 1100 MIN.size src,dest */
1214 sc = decode_src23 (sss, ss, w);
1215 dc = decode_dest23 (ddd, dd, w);
1216 b = sign_ext (get_src (sc), w*8);
1217 a = sign_ext (get_src (dc), w*8);
1218 tprintf ("min %d %d\n", b, a);
1222 /** 1001 ddd w dd10 1111 MOV.size:G #IMM,dest */
1224 dc = decode_dest23 (ddd, dd, w+1);
1227 tprintf("%x = %x\n", v, v);
1231 /** 1011 ddd0 dd11 0001 MOV.L:G #IMM,dest */
1233 dc = decode_dest23 (ddd, dd, 4);
1236 tprintf("%x = %x\n", v, v);
1240 /** 1111 ddd w dd10 immm MOV.size:Q #IMM4,dest */
1242 dc = decode_dest23 (ddd, dd, w+1);
1243 imm = sign_ext (immm, 4);
1245 tprintf("%x = %d\n", v, v);
1249 /** 00dd 010w MOV.size:S #IMM,dest */
1252 dc = decode_dest2 (dd, w+1);
1257 /** 10w1 110d MOV.size:S #IMM,a0/a1 */
1259 imm = IMM(w ? 3 : 2);
1260 put_reg (d ? a1 : a0, imm);
1261 set_sz (imm & addr_mask, w+1);
1263 /** 00dd 001w MOV.size:Z #0,dest */
1266 dc = decode_dest2 (dd, w+1);
1270 /** 1sss ddd w dd ss 1011 MOV.size:G src,dest */
1273 sc = decode_src23 (sss, ss, w+1);
1274 dc = decode_dest23 (ddd, dd, w+1);
1279 /** 1sss ddd1 dd ss 0011 MOV.L:G src,dest */
1282 sc = decode_src23 (sss, ss, 4);
1283 dc = decode_dest23 (ddd, dd, 4);
1288 /** VARY SS 01 10 11 */
1289 /** 00SS 100w MOV.size:S src,R0L/R0 */
1292 sc = decode_dest2 (SS, w+1);
1294 put_reg (w ? r0 : r0l, v);
1297 /** 01ss 111w MOV.size:S src,R1L/R1 */
1300 sc = decode_dest2 (ss, w+1);
1302 put_reg (w ? r1 : r1l, v);
1305 /** VARY DD 01 10 11 */
1306 /** 00DD 000w MOV.size:S R0L/R0,dest */
1309 dc = decode_dest2 (DD, w+1);
1310 v = get_reg (w ? r0 : r0l);
1314 /** 01ss 100d MOV.L:S src,A0/A1 */
1317 sc = decode_dest2 (ss, 4);
1319 put_reg (d ? a1 : a0, v);
1322 /** 1011 ddd w dd00 1111 MOV.size:G dsp:8[SP], dest */
1326 dc = decode_dest23 (ddd, dd, w+1);
1327 a = get_reg (sp) + sign_ext (imm, 8);
1336 /** 1010 sss w ss00 1111 MOV.size:G src,dsp:8[SP] */
1339 sc = decode_dest23 (sss, ss, w+1);
1341 a = get_reg (sp) + sign_ext (imm, 8);
1350 /** 1101 sss1 ss01 1dst MOVA src,dest */
1352 static reg_id map[8] = { r2r0, r3r1, a0, a1 };
1354 sc = decode_src23 (sss, ss, 1);
1355 if (!sc.mem || !map[dst])
1357 put_reg (map[dst], sc.u.addr);
1359 /** 0000 0001 1011 ddd0 dd hl 1110 MOVdir R0L,dest */
1362 dc = decode_dest23 (ddd, dd, 1);
1367 case 0: a = (a & 0xf0) | (b & 0x0f); break;
1368 case 1: a = (a & 0xf0) | ((b>>4) & 0x0f); break;
1369 case 2: a = (a & 0x0f) | ((b & 0x0f)<<4); break;
1370 case 3: a = (a & 0x0f) | (b & 0xf0); break;
1374 /** 0000 0001 1010 sss0 ss hl 1110 MOVdir src,R0L */
1377 sc = decode_dest23 (sss, ss, 1);
1382 case 0: a = (a & 0xf0) | (b & 0x0f); break;
1383 case 1: a = (a & 0xf0) | ((b>>4) & 0x0f); break;
1384 case 2: a = (a & 0x0f) | ((b & 0x0f)<<4); break;
1385 case 3: a = (a & 0x0f) | (b & 0xf0); break;
1389 /** 1011 ddd0 dd01 0001 MOVX #IMM,dest */
1392 dc = decode_dest23 (ddd, dd, 4);
1393 imm = sign_ext (IMM(1), 8);
1397 /** 1000 ddd w dd01 1111 MUL.size #IMM,dest */
1401 dc = decode_dest23 (ddd, dd, w);
1402 v = sign_ext (get_src (dc), w*8);
1403 imm = sign_ext (IMM(w), w*8);
1404 tprintf("%d * %d = %d\n", v, imm, v*imm);
1409 /** 1sss ddd w dd ss 1100 MUL.size src,dest */
1413 sc = decode_src23 (sss, ss, w);
1414 dc = decode_dest23 (ddd, dd, w);
1415 a = sign_ext (get_src (sc), w*8);
1416 b = sign_ext (get_src (dc), w*8);
1417 tprintf("%d * %d = %d\n", a, b, a*b);
1422 /** 0000 0001 1000 sss1 ss01 1111 MUL.L src,R2R0 */
1426 sc = decode_src23 (sss, ss, 4);
1427 a = sign_ext (get_src (sc), 32);
1428 b = sign_ext (get_reg (r2r0), 32);
1429 ll = (long long)a * (long long)b;
1430 tprintf("%d * %d = %lld (%llx)\n", a, b, ll, ll);
1431 if (ll < b2minsigned[4] || ll > b2maxsigned[4])
1432 set_flags (FLAGBIT_O, FLAGBIT_O);
1434 set_flags (FLAGBIT_O, 0);
1435 put_reg (r2r0, (int)ll);
1437 /** 1100 sss1 ss11 1110 MULEX src */
1440 sc = decode_dest23 (sss, ss, 2);
1441 a = sign_ext (get_src (sc), 16);
1442 b = sign_ext (get_reg (r2r0), 32);
1443 ll = (long long)a * (long long)b;
1444 tprintf("%d * %d = %lld (%llx)\n", a, b, ll, ll);
1445 put_reg (r2r0, (int)ll);
1446 put_reg (r1, (int)(ll >> 32));
1448 /** 1000 ddd w dd00 1111 MULU.size #IMM,dest */
1452 dc = decode_dest23 (ddd, dd, w);
1455 tprintf("%d * %d = %d\n", v, imm, v*imm);
1460 /** 1sss ddd w dd ss 0100 MULU.size src,dest */
1464 sc = decode_src23 (sss, ss, w);
1465 dc = decode_dest23 (ddd, dd, w);
1468 tprintf("%d * %d = %d\n", a, b, a*b);
1473 /** 0000 0001 1000 sss1 ss00 1111 MULU.L src,R2R0 */
1477 sc = decode_src23 (sss, ss, 4);
1480 ll = (long long)a * (long long)b;
1481 tprintf("%d * %d = %lld (%llx)\n", a, b, ll, ll);
1482 if (ll < b2minsigned[4] || ll > b2maxsigned[4])
1483 set_flags (FLAGBIT_O, FLAGBIT_O);
1485 set_flags (FLAGBIT_O, 0);
1486 put_reg (r2r0, (int)ll);
1488 /** 1010 ddd w dd10 1111 NEG.size dest */
1491 dc = decode_dest23 (ddd, dd, w+1);
1492 a = sign_ext (get_src (dc), (w+1)*8);
1494 tprintf("%d * -1 = %d\n", a, v);
1495 set_oszc(v, w+1, v==0);
1498 /** 1101 1110 NOP */
1502 /** 1010 ddd w dd01 1110 NOT.size dest */
1505 dc = decode_dest23 (ddd, dd, w+1);
1508 tprintf("~ %x = %x\n", a, v);
1512 /** 1000 ddd w dd10 1111 OR.size:G #IMM,dest */
1515 dc = decode_dest23(ddd, dd, w+1);
1517 LOGIC_OP (dc, imm, |);
1519 /** 01dd 010w OR.size:S #IMM,dest */
1522 dc = decode_dest2(dd, w+1);
1524 LOGIC_OP (dc, imm, |);
1526 /** 1sss ddd w dd ss 0101 OR.size:G src,dest */
1529 sc = decode_src23(sss, ss, w+1);
1530 dc = decode_dest23(ddd, dd, w+1);
1532 LOGIC_OP (dc, b, |);
1534 /** 1011 ddd w dd10 1111 POP.size dest */
1537 dc = decode_dest23 (ddd, dd, w+1);
1539 a = mem_get_hi (get_reg (sp));
1541 a = mem_get_qi (get_reg (sp));
1542 put_reg (sp, get_reg (sp) + 2);
1543 tprintf("pop%s: %x\n", w ? "hi" : "qi", a);
1546 /** 1101 0011 1010 1dst POPC dest */
1549 dc = decode_cr_b (dst, CR_B_DCT0);
1550 a = mem_get_hi (get_reg (sp));
1551 put_reg (sp, get_reg (sp) + 2);
1552 tprintf("pophi: %x\n", a);
1555 /** 1101 0011 0010 1dst POPC dest */
1558 dc = decode_cr_b (dst, CR_B_INTB);
1559 a = mem_get_si (get_reg (sp));
1560 put_reg (sp, get_reg (sp) + 4);
1561 tprintf("popsi: %x\n", a);
1564 /** 1000 1110 POPM dest */
1566 static int map[] = { r0, r1, r2, r3, a0, a1, sb, fb };
1569 tprintf("popm: %x\n", imm);
1573 v = mem_get_hi (get_reg (sp));
1574 put_reg (map[a], v);
1575 put_reg (sp, get_reg (sp) + 2);
1580 v = mem_get_si (get_reg (sp));
1581 put_reg (map[a], v);
1582 put_reg (sp, get_reg (sp) + 4);
1585 /** 1010 111w PUSH.size #IMM */
1589 tprintf("push%s: %x\n", w ? "hi" : "qi", imm);
1590 int a = get_reg (sp) - 2;
1592 mem_put_hi (a, imm);
1594 mem_put_qi (a, imm);
1597 /** 1100 sss w ss00 1110 PUSH.size src */
1600 sc = decode_dest23 (sss, ss, w+1);
1602 put_reg (sp, get_reg (sp) - 2);
1604 mem_put_hi (get_reg (sp), a);
1606 mem_put_qi (get_reg (sp), a);
1607 tprintf("push%s: %x\n", w ? "hi" : "qi", a);
1609 /** 1011 0110 0101 0011 PUSH.L #IMM32 */
1612 put_reg (sp, get_reg (sp) - 4);
1613 mem_put_si (get_reg (sp), imm);
1615 /** 1010 sss0 ss00 0001 PUSH.L src */
1618 sc = decode_dest23 (sss, ss, 4);
1620 put_reg (sp, get_reg (sp) - 4);
1621 mem_put_si (get_reg (sp), a);
1623 /** 1011 0sa0 ss00 0001 PUSHA src */
1626 sc = decode_dest23 (sa, ss, 1);
1627 put_reg (sp, get_reg (sp) - 4);
1628 mem_put_hi (get_reg (sp), sc.u.addr);
1629 tprintf("pushsi: %x\n", sc.u.addr);
1631 /** 1101 0001 1010 1src PUSHC src */
1634 sc = decode_cr_b (src, CR_B_DCT0);
1636 put_reg (sp, get_reg (sp) - 2);
1637 mem_put_hi (get_reg (sp), a);
1638 tprintf("pushhi: %x\n", a);
1640 /** 1101 0001 0010 1src PUSHC src */
1643 sc = decode_cr_b (src, CR_B_INTB);
1645 put_reg (sp, get_reg (sp) - 4);
1646 mem_put_si (get_reg (sp), a);
1647 tprintf("pushsi: %x\n", a);
1649 /** 1000 1111 PUSHM src */
1651 static int map[] = { fb, sb, a1, a0, r3, r2, r1, r0 };
1653 tprintf("pushm: %x\n", imm);
1657 put_reg (sp, get_reg (sp) - 4);
1658 v = get_reg (map[a]);
1659 mem_put_si (get_reg (sp), v);
1664 put_reg (sp, get_reg (sp) - 2);
1665 v = get_reg (map[a]);
1666 mem_put_hi (get_reg (sp), v);
1669 /** 1001 1110 REIT */
1672 put_reg (pc, mem_get_si (a));
1674 put_reg (flags, mem_get_hi (a));
1678 /** 1011 1000 010w 0011 RMPA.size */
1680 int count = get_reg (r3);
1681 int list1 = get_reg (a0);
1682 int list2 = get_reg (a1);
1683 long long sum = get_reg_ll (r3r1r2r0) & 0xffffff;
1689 a = sign_ext (mem_get_hi (list1), 16);
1690 b = sign_ext (mem_get_hi (list2), 16);
1694 a = sign_ext (mem_get_qi (list1), 8);
1695 b = sign_ext (mem_get_qi (list2), 8);
1697 tprintf("%lld + %d * %d = ", sum, a, b);
1699 tprintf("%lld\n", sum);
1704 put_reg (r3, count);
1705 put_reg (a0, list1);
1706 put_reg (a1, list2);
1707 put_reg (r2r0, (int)(sum & 0xffffffffU));
1708 put_reg (r1, (int)(sum >> 32));
1710 /** 1011 ddd w dd10 1110 ROLC.size dest */
1713 dc = decode_dest23 (ddd, dd, w+1);
1716 /** 1010 ddd w dd10 1110 RORC.size dest */
1719 dc = decode_dest23 (ddd, dd, w+1);
1722 /** 1110 ddd w dd10 immm ROT.size #IMM, dest */
1725 dc = decode_dest23 (ddd, dd, w+1);
1726 rot_op (dc, IMM4(), -1);
1728 /** 1010 ddd w dd11 1111 ROT.size R1H,dest */
1731 dc = decode_dest23 (ddd, dd, w+1);
1732 a = sign_ext (get_reg (r1h), 8);
1735 /** 1101 1111 RTS */
1737 put_reg (pc, mem_get_si (get_reg (sp)));
1738 put_reg (sp, get_reg (sp) + 4);
1740 /** 0000 0001 1001 ddd w dd10 1110 SBB.size #IMM, dest */
1743 dc = decode_dest23 (ddd, dd, w+1);
1745 MATH_OP (dc, imm, !carry, -);
1747 /** 0000 0001 1sss ddd w dd ss 0110 SBB.size src,dest */
1750 sc = decode_src23 (sss, ss, w+1);
1751 dc = decode_dest23 (ddd, dd, w+1);
1752 MATH_OP (dc, get_src (sc), !carry, -);
1754 /** 1101 ddd1 dd11 cond SCcond dest */
1757 dc = decode_dest23 (ddd, dd, 2);
1758 if (condition_true (cond))
1763 /** 1011 1000 110w 0011 SCMPU.size */
1770 t0 = mem_get_qi (ta0);
1771 t2 = mem_get_qi (ta1);
1774 t1 = mem_get_qi (ta0 + 1);
1775 t3 = mem_get_qi (ta1 + 1);
1778 if (dif == 0 && t0 != 0 && w)
1780 set_oszc (dif, 1, dif > 0);
1785 if (t0 == 0 || t0 != t2)
1787 if (w && (t1 == 0 || t1 != t3))
1791 /** 1111 ddd w dd00 immm SHA.size #IMM,dest */
1794 dc = decode_dest23 (ddd, dd, w+1);
1795 shift_op (dc, 1, IMM4(), 1);
1797 /** 1010 ddd0 dd10 0001 SHA.L #IMM,dest */
1800 dc = decode_dest23 (ddd, dd, 4);
1801 imm = sign_ext (IMM(1), 8);
1802 shift_op (dc, 1, imm, 1);
1804 /** 1011 ddd w dd11 1110 SHA.size R1H,dest */
1807 dc = decode_dest23 (ddd, dd, w+1);
1808 a = sign_ext (get_reg (r1h), 8);
1809 shift_op (dc, 1, a, 1);
1811 /** 1100 ddd0 dd01 0001 SHA.L R1H,dest */
1814 dc = decode_dest23 (ddd, dd, 4);
1815 a = sign_ext (get_reg (r1h), 8);
1816 shift_op (dc, 1, a, 1);
1818 /** 1100 ddd0 dd10 0001 SHANC.L #IMM,dest */
1822 dc = decode_dest23 (ddd, dd, 4);
1823 imm = sign_ext (IMM(1), 8);
1824 shift_op (dc, 1, imm, 0);
1826 /** 1110 ddd w dd00 immm SHL.size #IMM, dest */
1829 dc = decode_dest23 (ddd, dd, w+1);
1830 shift_op (dc, 0, IMM4(), 1);
1832 /** 1001 ddd0 dd10 0001 SHL.L #IMM, dest */
1835 dc = decode_dest23 (ddd, dd, 4);
1836 imm = sign_ext (IMM(1), 8);
1837 shift_op (dc, 0, imm, 1);
1839 /** 1010 ddd w dd11 1110 SHL.size R1H,dest */
1842 dc = decode_dest23 (ddd, dd, w+1);
1843 a = sign_ext (get_reg (r1h), 8);
1844 shift_op (dc, 0, a, 1);
1846 /** 1100 ddd0 dd00 0001 SHL.L R1H,dest */
1849 dc = decode_dest23 (ddd, dd, 4);
1850 a = sign_ext (get_reg (r1h), 8);
1851 shift_op (dc, 0, a, 1);
1853 /** 1000 ddd0 dd10 0001 SHLNC.L #IMM,dest */
1857 dc = decode_dest23 (ddd, dd, 4);
1858 imm = sign_ext (IMM(1), 8);
1859 shift_op (dc, 0, imm, 0);
1861 /** 1011 0010 100w 0011 SIN.size */
1869 mem_put_hi(a, mem_get_hi (v));
1871 mem_put_qi(a, mem_get_qi (v));
1879 /** 1011 0110 100w 0011 SMOVB.size */
1887 mem_put_hi(a, mem_get_hi (v));
1889 mem_put_qi(a, mem_get_qi (v));
1898 /** 1011 0000 100w 0011 SMOVF.size */
1906 mem_put_hi(a, mem_get_hi (v));
1908 mem_put_qi(a, mem_get_qi (v));
1917 /** 1011 1000 100w 0011 SMOVU.size */
1924 mem_put_hi(a, (t0 = mem_get_hi (v)));
1926 mem_put_qi(a, (t0 = mem_get_qi (v)));
1930 || (w && ((t0 & 0xff) == 0 || (t0 & 0xff00) == 0)))
1936 /** 1011 0100 100w 0011 SOUT.size */
1944 mem_put_hi(a, mem_get_hi (v));
1946 mem_put_qi(a, mem_get_qi (v));
1954 /** 1011 1000 000w 0011 SSTR.size */
1958 v = get_reg (w ? r0 : r0l);
1971 /** 0000 0001 1101 ddd1 dd01 0src STC src,dest */
1974 dc = decode_dest23 (ddd, dd, 4);
1975 sc = decode_cr_b (src, CR_B_DMA0);
1979 /** 0000 0001 1101 ddd1 dd01 1src STC src,dest */
1982 dc = decode_dest23 (ddd, dd, 2);
1983 sc = decode_cr_b (src, CR_B_DCT0);
1987 /** 1101 ddd1 dd01 0src STC src,dest */
1990 dc = decode_dest23 (ddd, dd, 4);
1991 sc = decode_cr_b (src, CR_B_INTB);
1995 /** 1011 0110 1101 0011 STCX abs16,abs24 */
1999 /** 1001 ddd w dd01 1111 STNZ.size #IMM,dest */
2002 dc = decode_dest23 (ddd, dd, w+1);
2007 /** 1001 ddd w dd00 1111 STZ.size #IMM,dest */
2010 dc = decode_dest23 (ddd, dd, w+1);
2015 /** 1001 ddd w dd11 1111 STZX.size #IMM1,#IMM2,dest */
2018 dc = decode_dest23 (ddd, dd, w+1);
2026 /** 1000 ddd w dd11 1110 SUB.size:G #IMM,dest */
2029 dc = decode_dest23(ddd, dd, w+1);
2031 MATH_OP (dc, imm, 0, -);
2033 /** 1001 ddd0 dd11 0001 SUB.L:G #IMM,dest */
2036 dc = decode_dest23(ddd, dd, 4);
2038 MATH_OP (dc, imm, 0, -);
2040 /** 00dd 111w SUB.size:S #IMM,dest */
2043 dc = decode_dest2(dd, w+1);
2045 MATH_OP (dc, imm, 0, -);
2047 /** 1sss ddd w dd ss 1010 SUB.size:G src,dest */
2050 sc = decode_src23(sss, ss, w+1);
2051 dc = decode_dest23(ddd, dd, w+1);
2053 MATH_OP (dc, b, 0, -);
2055 /** 1sss ddd1 dd ss 0000 SUB.L:G src,dest */
2058 sc = decode_src23(sss, ss, 4);
2059 dc = decode_dest23(ddd, dd, 4);
2061 MATH_OP (dc, b, 0, -);
2063 /** 1001 ddd0 dd01 0001 SUBX #IMM,dest */
2066 dc = decode_dest23(ddd, dd, 4);
2067 imm = sign_ext (IMM(1), 8);
2068 MATH_OP (dc, imm, 0, -);
2070 /** 1sss ddd0 dd ss 0000 SUBX src,dest */
2073 sc = decode_src23(sss, ss, 1);
2074 dc = decode_dest23(ddd, dd, 4);
2075 b = sign_ext (get_src (sc), 8);
2076 MATH_OP (dc, b, 0, -);
2078 /** 1001 ddd w dd11 1110 TST.size:G #IMM,dest */
2081 dc = decode_dest23 (ddd, dd, w+1);
2087 /** 00dd 110w TST.size:S #IMM,dest */
2090 dc = decode_dest2 (dd, w+1);
2096 /** 0000 0001 1sss ddd w dd ss 1001 TST.size:G src,dest */
2099 sc = decode_src23 (sss, ss, w+1);
2100 dc = decode_dest23 (ddd, dd, w+1);
2106 /** 1111 1111 UND */
2108 trigger_fixed_interrupt (0xffffdc);
2110 /** 1011 0010 0000 0011 WAIT */
2114 /** 1101 ddd w dd00 1src XCHG.size src,dest */
2116 dc = decode_dest23 (ddd, dd, w+1);
2117 sc = decode_src3 (src, w+1);
2123 /** 1001 ddd w dd00 1110 XOR.size #IMM,dest */
2126 dc = decode_dest23(ddd, dd, w+1);
2128 LOGIC_OP (dc, imm, ^);
2130 /** 1sss ddd w dd ss 1001 XOR.size src,dest */
2133 sc = decode_src23(sss, ss, w+1);
2134 dc = decode_dest23(ddd, dd, w+1);
2136 LOGIC_OP (dc, b, ^);