1 /* s12z-decode.c -- Freescale S12Z disassembly
2 Copyright (C) 2018-2022 Free Software Foundation, Inc.
4 This file is part of the GNU opcodes library.
6 This library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 It is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
27 #include "opcode/s12z.h"
34 typedef int (*insn_bytes_f
) (struct mem_read_abstraction_base
*);
36 typedef int (*operands_f
) (struct mem_read_abstraction_base
*,
37 int *n_operands
, struct operand
**operand
);
39 typedef enum optr (*discriminator_f
) (struct mem_read_abstraction_base
*,
76 static const struct opr_pb opr_pb
[] = {
77 {0xF0, 0x70, 1, OPR_IMMe4
},
78 {0xF8, 0xB8, 1, OPR_REG
},
79 {0xC0, 0x40, 1, OPR_OFXYS
},
80 {0xEF, 0xE3, 1, OPR_XY_PRE_INC
},
81 {0xEF, 0xE7, 1, OPR_XY_POST_INC
},
82 {0xEF, 0xC3, 1, OPR_XY_PRE_DEC
},
83 {0xEF, 0xC7, 1, OPR_XY_POST_DEC
},
84 {0xFF, 0xFB, 1, OPR_S_PRE_DEC
},
85 {0xFF, 0xFF, 1, OPR_S_POST_INC
},
86 {0xC8, 0x88, 1, OPR_REG_DIRECT
},
87 {0xE8, 0xC8, 1, OPR_REG_INDIRECT
},
89 {0xCE, 0xC0, 2, OPR_IDX_DIRECT
},
90 {0xCE, 0xC4, 2, OPR_IDX_INDIRECT
},
91 {0xC0, 0x00, 2, OPR_EXT1
},
93 {0xC8, 0x80, 3, OPR_IDX2_REG
},
94 {0xFA, 0xF8, 3, OPR_EXT18
},
96 {0xCF, 0xC2, 4, OPR_IDX3_DIRECT
},
97 {0xCF, 0xC6, 4, OPR_IDX3_INDIRECT
},
99 {0xF8, 0xE8, 4, OPR_IDX3_DIRECT_REG
},
100 {0xFF, 0xFA, 4, OPR_EXT3_DIRECT
},
101 {0xFF, 0xFE, 4, OPR_EXT3_INDIRECT
},
104 /* Return the number of bytes in a OPR operand, including the XB postbyte.
105 It does not include any preceeding opcodes. */
107 x_opr_n_bytes (struct mem_read_abstraction_base
*mra
, int offset
)
110 int status
= mra
->read (mra
, offset
, 1, &xb
);
115 for (i
= 0; i
< sizeof (opr_pb
) / sizeof (opr_pb
[0]); ++i
)
117 const struct opr_pb
*pb
= opr_pb
+ i
;
118 if ((xb
& pb
->mask
) == pb
->value
)
120 return pb
->n_operands
;
128 opr_n_bytes_p1 (struct mem_read_abstraction_base
*mra
)
130 int n
= x_opr_n_bytes (mra
, 0);
137 opr_n_bytes2 (struct mem_read_abstraction_base
*mra
)
139 int s
= x_opr_n_bytes (mra
, 0);
142 int n
= x_opr_n_bytes (mra
, s
);
167 static const struct opr_bb bb_modes
[] =
169 {0x60, 0x00, 2, false, BB_REG_REG_REG
},
170 {0x60, 0x20, 3, false, BB_REG_REG_IMM
},
171 {0x70, 0x40, 2, true, BB_REG_OPR_REG
},
172 {0x70, 0x50, 2, true, BB_OPR_REG_REG
},
173 {0x70, 0x60, 3, true, BB_REG_OPR_IMM
},
174 {0x70, 0x70, 3, true, BB_OPR_REG_IMM
}
178 bfextins_n_bytes (struct mem_read_abstraction_base
*mra
)
181 int status
= mra
->read (mra
, 0, 1, &bb
);
186 const struct opr_bb
*bbs
= 0;
187 for (i
= 0; i
< sizeof (bb_modes
) / sizeof (bb_modes
[0]); ++i
)
190 if ((bb
& bbs
->mask
) == bbs
->value
)
196 int n
= bbs
->n_operands
;
199 int x
= x_opr_n_bytes (mra
, n
- 1);
209 single (struct mem_read_abstraction_base
*mra ATTRIBUTE_UNUSED
)
215 two (struct mem_read_abstraction_base
*mra ATTRIBUTE_UNUSED
)
221 three (struct mem_read_abstraction_base
*mra ATTRIBUTE_UNUSED
)
227 four (struct mem_read_abstraction_base
*mra ATTRIBUTE_UNUSED
)
233 five (struct mem_read_abstraction_base
*mra ATTRIBUTE_UNUSED
)
239 pcrel_15bit (struct mem_read_abstraction_base
*mra
)
242 int status
= mra
->read (mra
, 0, 1, &byte
);
245 return (byte
& 0x80) ? 3 : 2;
251 xysp_reg_from_postbyte (uint8_t postbyte
)
254 switch ((postbyte
& 0x30) >> 4)
271 static struct operand
*
272 create_immediate_operand (int value
)
274 struct immediate_operand
*op
= malloc (sizeof (*op
));
278 op
->parent
.cl
= OPND_CL_IMMEDIATE
;
279 op
->parent
.osize
= -1;
282 return (struct operand
*) op
;
285 static struct operand
*
286 create_bitfield_operand (int width
, int offset
)
288 struct bitfield_operand
*op
= malloc (sizeof (*op
));
292 op
->parent
.cl
= OPND_CL_BIT_FIELD
;
293 op
->parent
.osize
= -1;
297 return (struct operand
*) op
;
300 static struct operand
*
301 create_register_operand_with_size (int reg
, short osize
)
303 struct register_operand
*op
= malloc (sizeof (*op
));
307 op
->parent
.cl
= OPND_CL_REGISTER
;
308 op
->parent
.osize
= osize
;
311 return (struct operand
*) op
;
314 static struct operand
*
315 create_register_operand (int reg
)
317 return create_register_operand_with_size (reg
, -1);
320 static struct operand
*
321 create_register_all_operand (void)
323 struct register_operand
*op
= malloc (sizeof (*op
));
327 op
->parent
.cl
= OPND_CL_REGISTER_ALL
;
328 op
->parent
.osize
= -1;
330 return (struct operand
*) op
;
333 static struct operand
*
334 create_register_all16_operand (void)
336 struct register_operand
*op
= malloc (sizeof (*op
));
340 op
->parent
.cl
= OPND_CL_REGISTER_ALL16
;
341 op
->parent
.osize
= -1;
343 return (struct operand
*) op
;
347 static struct operand
*
348 create_simple_memory_operand (bfd_vma addr
, bfd_vma base
, bool relative
)
350 struct simple_memory_operand
*op
;
352 assert (relative
|| base
== 0);
353 op
= malloc (sizeof (*op
));
356 op
->parent
.cl
= OPND_CL_SIMPLE_MEMORY
;
357 op
->parent
.osize
= -1;
360 op
->relative
= relative
;
362 return (struct operand
*) op
;
365 static struct operand
*
366 create_memory_operand (bool indirect
, int base
, int n_regs
, int reg0
, int reg1
)
368 struct memory_operand
*op
= malloc (sizeof (*op
));
372 op
->parent
.cl
= OPND_CL_MEMORY
;
373 op
->parent
.osize
= -1;
374 op
->indirect
= indirect
;
375 op
->base_offset
= base
;
376 op
->mutation
= OPND_RM_NONE
;
381 return (struct operand
*) op
;
384 static struct operand
*
385 create_memory_auto_operand (enum op_reg_mutation mutation
, int reg
)
387 struct memory_operand
*op
= malloc (sizeof (*op
));
391 op
->parent
.cl
= OPND_CL_MEMORY
;
392 op
->parent
.osize
= -1;
393 op
->indirect
= false;
395 op
->mutation
= mutation
;
400 return (struct operand
*) op
;
406 z_ext24_decode (struct mem_read_abstraction_base
*mra
, int *n_operands
,
407 struct operand
**operand
)
411 int status
= mra
->read (mra
, 0, 3, buffer
);
417 for (i
= 0; i
< 3; ++i
)
423 op
= create_simple_memory_operand (addr
, 0, false);
426 operand
[(*n_operands
)++] = op
;
432 z_decode_signed_value (struct mem_read_abstraction_base
*mra
, int offset
,
433 short size
, uint32_t *result
)
438 int status
= mra
->read (mra
, offset
, size
, buffer
);
444 for (i
= 0; i
< size
; ++i
)
445 value
= (value
<< 8) | buffer
[i
];
447 if (buffer
[0] & 0x80)
449 /* Deal with negative values */
450 value
-= 1u << (size
* 4) << (size
* 4);
457 decode_signed_value (struct mem_read_abstraction_base
*mra
, short size
,
460 return z_decode_signed_value (mra
, 0, size
, result
);
464 x_imm1 (struct mem_read_abstraction_base
*mra
,
466 int *n_operands
, struct operand
**operand
)
470 int status
= mra
->read (mra
, offset
, 1, &byte
);
474 op
= create_immediate_operand (byte
);
477 operand
[(*n_operands
)++] = op
;
481 /* An eight bit immediate operand. */
483 imm1_decode (struct mem_read_abstraction_base
*mra
,
484 int *n_operands
, struct operand
**operand
)
486 return x_imm1 (mra
, 0, n_operands
, operand
);
490 trap_decode (struct mem_read_abstraction_base
*mra
,
491 int *n_operands
, struct operand
**operand
)
493 return x_imm1 (mra
, -1, n_operands
, operand
);
497 static struct operand
*
498 x_opr_decode_with_size (struct mem_read_abstraction_base
*mra
, int offset
,
502 int status
= mra
->read (mra
, offset
, 1, &postbyte
);
507 enum OPR_MODE mode
= -1;
509 for (i
= 0; i
< sizeof (opr_pb
) / sizeof (opr_pb
[0]); ++i
)
511 const struct opr_pb
*pb
= opr_pb
+ i
;
512 if ((postbyte
& pb
->mask
) == pb
->value
)
519 struct operand
*operand
= NULL
;
525 uint8_t x
= (postbyte
& 0x0F);
531 operand
= create_immediate_operand (n
);
536 uint8_t x
= (postbyte
& 0x07);
537 operand
= create_register_operand (x
);
542 operand
= create_memory_operand (false, postbyte
& 0x0F, 1,
543 xysp_reg_from_postbyte (postbyte
), -1);
548 operand
= create_memory_operand (false, 0, 2, postbyte
& 0x07,
549 xysp_reg_from_postbyte (postbyte
));
552 case OPR_REG_INDIRECT
:
554 operand
= create_memory_operand (true, 0, 2, postbyte
& 0x07,
555 (postbyte
& 0x10) ? REG_Y
: REG_X
);
559 case OPR_IDX_INDIRECT
:
562 status
= mra
->read (mra
, offset
, 1, &x1
);
569 /* Deal with negative values */
573 operand
= create_memory_operand (true, idx
, 1,
574 xysp_reg_from_postbyte (postbyte
), -1);
578 case OPR_IDX3_DIRECT
:
581 status
= mra
->read (mra
, offset
, 3, x
);
584 int idx
= x
[0] << 16 | x
[1] << 8 | x
[2];
588 /* Deal with negative values */
592 operand
= create_memory_operand (false, idx
, 1,
593 xysp_reg_from_postbyte (postbyte
), -1);
597 case OPR_IDX3_DIRECT_REG
:
600 status
= mra
->read (mra
, offset
, 3, x
);
603 int idx
= x
[0] << 16 | x
[1] << 8 | x
[2];
607 /* Deal with negative values */
611 operand
= create_memory_operand (false, idx
, 1, postbyte
& 0x07, -1);
615 case OPR_IDX3_INDIRECT
:
618 status
= mra
->read (mra
, offset
, 3, x
);
621 int idx
= x
[0] << 16 | x
[1] << 8 | x
[2];
625 /* Deal with negative values */
629 operand
= create_memory_operand (true, idx
, 1,
630 xysp_reg_from_postbyte (postbyte
), -1);
637 status
= mra
->read (mra
, offset
, 1, &x1
);
644 /* Deal with negative values */
648 operand
= create_memory_operand (false, idx
, 1,
649 xysp_reg_from_postbyte (postbyte
), -1);
656 status
= mra
->read (mra
, offset
, 2, x
);
659 uint32_t idx
= x
[1] | x
[0] << 8 ;
660 idx
|= (postbyte
& 0x30) << 12;
662 operand
= create_memory_operand (false, idx
, 1, postbyte
& 0x07, -1);
668 operand
= create_memory_auto_operand (OPND_RM_PRE_INC
,
669 (postbyte
& 0x10) ? REG_Y
: REG_X
);
672 case OPR_XY_POST_INC
:
674 operand
= create_memory_auto_operand (OPND_RM_POST_INC
,
675 (postbyte
& 0x10) ? REG_Y
: REG_X
);
680 operand
= create_memory_auto_operand (OPND_RM_PRE_DEC
,
681 (postbyte
& 0x10) ? REG_Y
: REG_X
);
684 case OPR_XY_POST_DEC
:
686 operand
= create_memory_auto_operand (OPND_RM_POST_DEC
,
687 (postbyte
& 0x10) ? REG_Y
: REG_X
);
692 operand
= create_memory_auto_operand (OPND_RM_PRE_DEC
, REG_S
);
697 operand
= create_memory_auto_operand (OPND_RM_POST_INC
, REG_S
);
703 const size_t size
= 2;
705 status
= mra
->read (mra
, offset
, size
, buffer
);
710 for (i
= 0; i
< size
; ++i
)
716 ext18
|= (postbyte
& 0x01) << 16;
717 ext18
|= (postbyte
& 0x04) << 15;
719 operand
= create_simple_memory_operand (ext18
, 0, false);
726 status
= mra
->read (mra
, offset
, 1, &x1
);
731 addr
|= (postbyte
& 0x3f) << 8;
733 operand
= create_simple_memory_operand (addr
, 0, false);
737 case OPR_EXT3_DIRECT
:
739 const size_t size
= 3;
741 status
= mra
->read (mra
, offset
, size
, buffer
);
746 for (i
= 0; i
< size
; ++i
)
748 ext24
|= buffer
[i
] << (8 * (size
- i
- 1));
751 operand
= create_simple_memory_operand (ext24
, 0, false);
755 case OPR_EXT3_INDIRECT
:
757 const size_t size
= 3;
759 status
= mra
->read (mra
, offset
, size
, buffer
);
764 for (i
= 0; i
< size
; ++i
)
766 ext24
|= buffer
[i
] << (8 * (size
- i
- 1));
769 operand
= create_memory_operand (true, ext24
, 0, -1, -1);
774 printf ("Unknown OPR mode #0x%x (%d)", postbyte
, mode
);
779 operand
->osize
= osize
;
784 static struct operand
*
785 x_opr_decode (struct mem_read_abstraction_base
*mra
, int offset
)
787 return x_opr_decode_with_size (mra
, offset
, -1);
791 z_opr_decode (struct mem_read_abstraction_base
*mra
,
792 int *n_operands
, struct operand
**operand
)
794 struct operand
*op
= x_opr_decode (mra
, 0);
797 operand
[(*n_operands
)++] = op
;
802 z_opr_decode2 (struct mem_read_abstraction_base
*mra
,
803 int *n_operands
, struct operand
**operand
)
805 int n
= x_opr_n_bytes (mra
, 0);
808 struct operand
*op
= x_opr_decode (mra
, 0);
811 operand
[(*n_operands
)++] = op
;
812 op
= x_opr_decode (mra
, n
);
815 operand
[(*n_operands
)++] = op
;
820 imm1234 (struct mem_read_abstraction_base
*mra
, int base
,
821 int *n_operands
, struct operand
**operand
)
825 int status
= mra
->read (mra
, -1, 1, &opcode
);
831 int size
= registers
[opcode
& 0xF].bytes
;
834 if (decode_signed_value (mra
, size
, &imm
) < 0)
837 op
= create_immediate_operand (imm
);
840 operand
[(*n_operands
)++] = op
;
845 /* Special case of LD and CMP with register S and IMM operand */
847 reg_s_imm (struct mem_read_abstraction_base
*mra
, int *n_operands
,
848 struct operand
**operand
)
852 op
= create_register_operand (REG_S
);
855 operand
[(*n_operands
)++] = op
;
858 if (decode_signed_value (mra
, 3, &imm
) < 0)
860 op
= create_immediate_operand (imm
);
863 operand
[(*n_operands
)++] = op
;
867 /* Special case of LD, CMP and ST with register S and OPR operand */
869 reg_s_opr (struct mem_read_abstraction_base
*mra
, int *n_operands
,
870 struct operand
**operand
)
874 op
= create_register_operand (REG_S
);
877 operand
[(*n_operands
)++] = op
;
878 op
= x_opr_decode (mra
, 0);
881 operand
[(*n_operands
)++] = op
;
886 z_imm1234_8base (struct mem_read_abstraction_base
*mra
, int *n_operands
,
887 struct operand
**operand
)
889 return imm1234 (mra
, 8, n_operands
, operand
);
893 z_imm1234_0base (struct mem_read_abstraction_base
*mra
, int *n_operands
,
894 struct operand
**operand
)
896 return imm1234 (mra
, 0, n_operands
, operand
);
901 z_tfr (struct mem_read_abstraction_base
*mra
, int *n_operands
,
902 struct operand
**operand
)
906 int status
= mra
->read (mra
, 0, 1, &byte
);
910 op
= create_register_operand (byte
>> 4);
913 operand
[(*n_operands
)++] = op
;
914 op
= create_register_operand (byte
& 0x0F);
917 operand
[(*n_operands
)++] = op
;
922 z_reg (struct mem_read_abstraction_base
*mra
, int *n_operands
,
923 struct operand
**operand
)
927 int status
= mra
->read (mra
, -1, 1, &byte
);
931 op
= create_register_operand (byte
& 0x07);
934 operand
[(*n_operands
)++] = op
;
940 reg_xy (struct mem_read_abstraction_base
*mra
,
941 int *n_operands
, struct operand
**operand
)
945 int status
= mra
->read (mra
, -1, 1, &byte
);
949 op
= create_register_operand ((byte
& 0x01) ? REG_Y
: REG_X
);
952 operand
[(*n_operands
)++] = op
;
957 lea_reg_xys_opr (struct mem_read_abstraction_base
*mra
,
958 int *n_operands
, struct operand
**operand
)
962 int status
= mra
->read (mra
, -1, 1, &byte
);
980 op
= create_register_operand (reg_xys
);
983 operand
[(*n_operands
)++] = op
;
984 op
= x_opr_decode (mra
, 0);
987 operand
[(*n_operands
)++] = op
;
992 lea_reg_xys (struct mem_read_abstraction_base
*mra
,
993 int *n_operands
, struct operand
**operand
)
997 int status
= mra
->read (mra
, -1, 1, &byte
);
1002 switch (byte
& 0x03)
1015 status
= mra
->read (mra
, 0, 1, &byte
);
1019 op
= create_register_operand (reg_n
);
1022 operand
[(*n_operands
)++] = op
;
1023 op
= create_memory_operand (false, (int8_t) byte
, 1, reg_n
, -1);
1026 operand
[(*n_operands
)++] = op
;
1031 /* PC Relative offsets of size 15 or 7 bits */
1033 rel_15_7 (struct mem_read_abstraction_base
*mra
, int offset
,
1034 int *n_operands
, struct operand
**operands
)
1038 int status
= mra
->read (mra
, offset
- 1, 1, &upper
);
1042 bool rel_size
= (upper
& 0x80);
1044 int16_t addr
= upper
;
1047 /* 15 bits. Get the next byte */
1049 status
= mra
->read (mra
, offset
, 1, &lower
);
1057 bool negative
= (addr
& 0x4000);
1060 addr
= addr
- 0x4000;
1065 bool negative
= (addr
& 0x40);
1071 op
= create_simple_memory_operand (addr
, mra
->posn (mra
) - 1, true);
1074 operands
[(*n_operands
)++] = op
;
1079 /* PC Relative offsets of size 15 or 7 bits */
1081 decode_rel_15_7 (struct mem_read_abstraction_base
*mra
,
1082 int *n_operands
, struct operand
**operand
)
1084 return rel_15_7 (mra
, 1, n_operands
, operand
);
1087 static int shift_n_bytes (struct mem_read_abstraction_base
*);
1088 static int mov_imm_opr_n_bytes (struct mem_read_abstraction_base
*);
1089 static int loop_prim_n_bytes (struct mem_read_abstraction_base
*);
1090 static int bm_rel_n_bytes (struct mem_read_abstraction_base
*);
1091 static int mul_n_bytes (struct mem_read_abstraction_base
*);
1092 static int bm_n_bytes (struct mem_read_abstraction_base
*);
1094 static int psh_pul_decode (struct mem_read_abstraction_base
*mra
, int *n_operands
, struct operand
**operand
);
1095 static int shift_decode (struct mem_read_abstraction_base
*mra
, int *n_operands
, struct operand
**operand
);
1096 static int mul_decode (struct mem_read_abstraction_base
*mra
, int *n_operands
, struct operand
**operand
);
1097 static int bm_decode (struct mem_read_abstraction_base
*mra
, int *n_operands
, struct operand
**operand
);
1098 static int bm_rel_decode (struct mem_read_abstraction_base
*mra
, int *n_operands
, struct operand
**operand
);
1099 static int mov_imm_opr (struct mem_read_abstraction_base
*mra
, int *n_operands
, struct operand
**operand
);
1100 static int loop_primitive_decode (struct mem_read_abstraction_base
*mra
, int *n_operands
, struct operand
**operands
);
1101 static int bit_field_decode (struct mem_read_abstraction_base
*mra
, int *n_operands
, struct operand
**operands
);
1102 static int exg_sex_decode (struct mem_read_abstraction_base
*mra
, int *n_operands
, struct operand
**operands
);
1105 static enum optr
shift_discrim (struct mem_read_abstraction_base
*mra
, enum optr hint
);
1106 static enum optr
psh_pul_discrim (struct mem_read_abstraction_base
*mra
, enum optr hint
);
1107 static enum optr
mul_discrim (struct mem_read_abstraction_base
*mra
, enum optr hint
);
1108 static enum optr
loop_primitive_discrim (struct mem_read_abstraction_base
*mra
, enum optr hint
);
1109 static enum optr
bit_field_discrim (struct mem_read_abstraction_base
*mra
, enum optr hint
);
1110 static enum optr
exg_sex_discrim (struct mem_read_abstraction_base
*mra
, enum optr hint
);
1114 cmp_xy (struct mem_read_abstraction_base
*mra ATTRIBUTE_UNUSED
,
1115 int *n_operands
, struct operand
**operand
)
1119 op
= create_register_operand (REG_X
);
1122 operand
[(*n_operands
)++] = op
;
1123 op
= create_register_operand (REG_Y
);
1126 operand
[(*n_operands
)++] = op
;
1131 sub_d6_x_y (struct mem_read_abstraction_base
*mra ATTRIBUTE_UNUSED
,
1132 int *n_operands
, struct operand
**operand
)
1136 op
= create_register_operand (REG_D6
);
1139 operand
[(*n_operands
)++] = op
;
1140 op
= create_register_operand (REG_X
);
1143 operand
[(*n_operands
)++] = op
;
1144 op
= create_register_operand (REG_Y
);
1147 operand
[(*n_operands
)++] = op
;
1152 sub_d6_y_x (struct mem_read_abstraction_base
*mra ATTRIBUTE_UNUSED
,
1153 int *n_operands
, struct operand
**operand
)
1157 op
= create_register_operand (REG_D6
);
1160 operand
[(*n_operands
)++] = op
;
1161 op
= create_register_operand (REG_Y
);
1164 operand
[(*n_operands
)++] = op
;
1165 op
= create_register_operand (REG_X
);
1168 operand
[(*n_operands
)++] = op
;
1173 ld_18bit_decode (struct mem_read_abstraction_base
*mra
, int *n_operands
,
1174 struct operand
**operand
);
1177 mul_discrim (struct mem_read_abstraction_base
*mra
, enum optr hint
)
1180 int status
= mra
->read (mra
, 0, 1, &mb
);
1184 bool signed_op
= (mb
& 0x80);
1189 return signed_op
? OP_muls
: OP_mulu
;
1192 return signed_op
? OP_divs
: OP_divu
;
1195 return signed_op
? OP_mods
: OP_modu
;
1198 return signed_op
? OP_macs
: OP_macu
;
1201 return signed_op
? OP_qmuls
: OP_qmulu
;
1212 /* The operation that this opcode performs. */
1215 /* The size of this operation. May be -1 if it is implied
1216 in the operands or if size is not applicable. */
1219 /* Some operations need this function to work out which operation
1221 discriminator_f discriminator
;
1223 /* A function returning the number of bytes in this instruction. */
1224 insn_bytes_f insn_bytes
;
1226 operands_f operands
;
1227 operands_f operands2
;
1230 static const struct opcode page2
[] =
1232 [0x00] = {OP_ld
, -1, 0, opr_n_bytes_p1
, reg_s_opr
, 0},
1233 [0x01] = {OP_st
, -1, 0, opr_n_bytes_p1
, reg_s_opr
, 0},
1234 [0x02] = {OP_cmp
, -1, 0, opr_n_bytes_p1
, reg_s_opr
, 0},
1235 [0x03] = {OP_ld
, -1, 0, four
, reg_s_imm
, 0},
1236 [0x04] = {OP_cmp
, -1, 0, four
, reg_s_imm
, 0},
1237 [0x05] = {OP_stop
, -1, 0, single
, 0, 0},
1238 [0x06] = {OP_wai
, -1, 0, single
, 0, 0},
1239 [0x07] = {OP_sys
, -1, 0, single
, 0, 0},
1240 [0x08] = {0xFFFF, -1, bit_field_discrim
, bfextins_n_bytes
, bit_field_decode
, 0}, /* BFEXT / BFINS */
1241 [0x09] = {0xFFFF, -1, bit_field_discrim
, bfextins_n_bytes
, bit_field_decode
, 0},
1242 [0x0a] = {0xFFFF, -1, bit_field_discrim
, bfextins_n_bytes
, bit_field_decode
, 0},
1243 [0x0b] = {0xFFFF, -1, bit_field_discrim
, bfextins_n_bytes
, bit_field_decode
, 0},
1244 [0x0c] = {0xFFFF, -1, bit_field_discrim
, bfextins_n_bytes
, bit_field_decode
, 0},
1245 [0x0d] = {0xFFFF, -1, bit_field_discrim
, bfextins_n_bytes
, bit_field_decode
, 0},
1246 [0x0e] = {0xFFFF, -1, bit_field_discrim
, bfextins_n_bytes
, bit_field_decode
, 0},
1247 [0x0f] = {0xFFFF, -1, bit_field_discrim
, bfextins_n_bytes
, bit_field_decode
, 0},
1248 [0x10] = {OP_minu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1249 [0x11] = {OP_minu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1250 [0x12] = {OP_minu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1251 [0x13] = {OP_minu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1252 [0x14] = {OP_minu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1253 [0x15] = {OP_minu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1254 [0x16] = {OP_minu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1255 [0x17] = {OP_minu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1256 [0x18] = {OP_maxu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1257 [0x19] = {OP_maxu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1258 [0x1a] = {OP_maxu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1259 [0x1b] = {OP_maxu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1260 [0x1c] = {OP_maxu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1261 [0x1d] = {OP_maxu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1262 [0x1e] = {OP_maxu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1263 [0x1f] = {OP_maxu
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1264 [0x20] = {OP_mins
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1265 [0x21] = {OP_mins
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1266 [0x22] = {OP_mins
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1267 [0x23] = {OP_mins
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1268 [0x24] = {OP_mins
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1269 [0x25] = {OP_mins
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1270 [0x26] = {OP_mins
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1271 [0x27] = {OP_mins
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1272 [0x28] = {OP_maxs
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1273 [0x29] = {OP_maxs
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1274 [0x2a] = {OP_maxs
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1275 [0x2b] = {OP_maxs
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1276 [0x2c] = {OP_maxs
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1277 [0x2d] = {OP_maxs
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1278 [0x2e] = {OP_maxs
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1279 [0x2f] = {OP_maxs
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1280 [0x30] = {OPBASE_div
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1281 [0x31] = {OPBASE_div
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1282 [0x32] = {OPBASE_div
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1283 [0x33] = {OPBASE_div
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1284 [0x34] = {OPBASE_div
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1285 [0x35] = {OPBASE_div
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1286 [0x36] = {OPBASE_div
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1287 [0x37] = {OPBASE_div
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1288 [0x38] = {OPBASE_mod
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1289 [0x39] = {OPBASE_mod
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1290 [0x3a] = {OPBASE_mod
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1291 [0x3b] = {OPBASE_mod
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1292 [0x3c] = {OPBASE_mod
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1293 [0x3d] = {OPBASE_mod
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1294 [0x3e] = {OPBASE_mod
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1295 [0x3f] = {OPBASE_mod
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1296 [0x40] = {OP_abs
, -1, 0, single
, z_reg
, 0},
1297 [0x41] = {OP_abs
, -1, 0, single
, z_reg
, 0},
1298 [0x42] = {OP_abs
, -1, 0, single
, z_reg
, 0},
1299 [0x43] = {OP_abs
, -1, 0, single
, z_reg
, 0},
1300 [0x44] = {OP_abs
, -1, 0, single
, z_reg
, 0},
1301 [0x45] = {OP_abs
, -1, 0, single
, z_reg
, 0},
1302 [0x46] = {OP_abs
, -1, 0, single
, z_reg
, 0},
1303 [0x47] = {OP_abs
, -1, 0, single
, z_reg
, 0},
1304 [0x48] = {OPBASE_mac
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1305 [0x49] = {OPBASE_mac
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1306 [0x4a] = {OPBASE_mac
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1307 [0x4b] = {OPBASE_mac
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1308 [0x4c] = {OPBASE_mac
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1309 [0x4d] = {OPBASE_mac
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1310 [0x4e] = {OPBASE_mac
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1311 [0x4f] = {OPBASE_mac
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1312 [0x50] = {OP_adc
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1313 [0x51] = {OP_adc
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1314 [0x52] = {OP_adc
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1315 [0x53] = {OP_adc
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1316 [0x54] = {OP_adc
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1317 [0x55] = {OP_adc
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1318 [0x56] = {OP_adc
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1319 [0x57] = {OP_adc
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1320 [0x58] = {OP_bit
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1321 [0x59] = {OP_bit
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1322 [0x5a] = {OP_bit
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1323 [0x5b] = {OP_bit
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1324 [0x5c] = {OP_bit
, -1, 0, two
, z_reg
, z_imm1234_8base
},
1325 [0x5d] = {OP_bit
, -1, 0, two
, z_reg
, z_imm1234_8base
},
1326 [0x5e] = {OP_bit
, -1, 0, five
, z_reg
, z_imm1234_8base
},
1327 [0x5f] = {OP_bit
, -1, 0, five
, z_reg
, z_imm1234_8base
},
1328 [0x60] = {OP_adc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1329 [0x61] = {OP_adc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1330 [0x62] = {OP_adc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1331 [0x63] = {OP_adc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1332 [0x64] = {OP_adc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1333 [0x65] = {OP_adc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1334 [0x66] = {OP_adc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1335 [0x67] = {OP_adc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1336 [0x68] = {OP_bit
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1337 [0x69] = {OP_bit
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1338 [0x6a] = {OP_bit
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1339 [0x6b] = {OP_bit
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1340 [0x6c] = {OP_bit
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1341 [0x6d] = {OP_bit
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1342 [0x6e] = {OP_bit
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1343 [0x6f] = {OP_bit
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1344 [0x70] = {OP_sbc
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1345 [0x71] = {OP_sbc
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1346 [0x72] = {OP_sbc
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1347 [0x73] = {OP_sbc
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1348 [0x74] = {OP_sbc
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1349 [0x75] = {OP_sbc
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1350 [0x76] = {OP_sbc
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1351 [0x77] = {OP_sbc
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1352 [0x78] = {OP_eor
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1353 [0x79] = {OP_eor
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1354 [0x7a] = {OP_eor
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1355 [0x7b] = {OP_eor
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1356 [0x7c] = {OP_eor
, -1, 0, two
, z_reg
, z_imm1234_8base
},
1357 [0x7d] = {OP_eor
, -1, 0, two
, z_reg
, z_imm1234_8base
},
1358 [0x7e] = {OP_eor
, -1, 0, five
, z_reg
, z_imm1234_8base
},
1359 [0x7f] = {OP_eor
, -1, 0, five
, z_reg
, z_imm1234_8base
},
1360 [0x80] = {OP_sbc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1361 [0x81] = {OP_sbc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1362 [0x82] = {OP_sbc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1363 [0x83] = {OP_sbc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1364 [0x84] = {OP_sbc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1365 [0x85] = {OP_sbc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1366 [0x86] = {OP_sbc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1367 [0x87] = {OP_sbc
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1368 [0x88] = {OP_eor
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1369 [0x89] = {OP_eor
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1370 [0x8a] = {OP_eor
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1371 [0x8b] = {OP_eor
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1372 [0x8c] = {OP_eor
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1373 [0x8d] = {OP_eor
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1374 [0x8e] = {OP_eor
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1375 [0x8f] = {OP_eor
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1376 [0x90] = {OP_rti
, -1, 0, single
, 0, 0},
1377 [0x91] = {OP_clb
, -1, 0, two
, z_tfr
, 0},
1378 [0x92] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1379 [0x93] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1380 [0x94] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1381 [0x95] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1382 [0x96] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1383 [0x97] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1384 [0x98] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1385 [0x99] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1386 [0x9a] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1387 [0x9b] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1388 [0x9c] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1389 [0x9d] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1390 [0x9e] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1391 [0x9f] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1392 [0xa0] = {OP_sat
, -1, 0, single
, z_reg
, 0},
1393 [0xa1] = {OP_sat
, -1, 0, single
, z_reg
, 0},
1394 [0xa2] = {OP_sat
, -1, 0, single
, z_reg
, 0},
1395 [0xa3] = {OP_sat
, -1, 0, single
, z_reg
, 0},
1396 [0xa4] = {OP_sat
, -1, 0, single
, z_reg
, 0},
1397 [0xa5] = {OP_sat
, -1, 0, single
, z_reg
, 0},
1398 [0xa6] = {OP_sat
, -1, 0, single
, z_reg
, 0},
1399 [0xa7] = {OP_sat
, -1, 0, single
, z_reg
, 0},
1400 [0xa8] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1401 [0xa9] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1402 [0xaa] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1403 [0xab] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1404 [0xac] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1405 [0xad] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1406 [0xae] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1407 [0xaf] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1408 [0xb0] = {OPBASE_qmul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1409 [0xb1] = {OPBASE_qmul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1410 [0xb2] = {OPBASE_qmul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1411 [0xb3] = {OPBASE_qmul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1412 [0xb4] = {OPBASE_qmul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1413 [0xb5] = {OPBASE_qmul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1414 [0xb6] = {OPBASE_qmul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1415 [0xb7] = {OPBASE_qmul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1416 [0xb8] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1417 [0xb9] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1418 [0xba] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1419 [0xbb] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1420 [0xbc] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1421 [0xbd] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1422 [0xbe] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1423 [0xbf] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1424 [0xc0] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1425 [0xc1] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1426 [0xc2] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1427 [0xc3] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1428 [0xc4] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1429 [0xc5] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1430 [0xc6] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1431 [0xc7] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1432 [0xc8] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1433 [0xc9] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1434 [0xca] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1435 [0xcb] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1436 [0xcc] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1437 [0xcd] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1438 [0xce] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1439 [0xcf] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1440 [0xd0] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1441 [0xd1] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1442 [0xd2] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1443 [0xd3] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1444 [0xd4] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1445 [0xd5] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1446 [0xd6] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1447 [0xd7] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1448 [0xd8] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1449 [0xd9] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1450 [0xda] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1451 [0xdb] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1452 [0xdc] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1453 [0xdd] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1454 [0xde] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1455 [0xdf] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1456 [0xe0] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1457 [0xe1] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1458 [0xe2] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1459 [0xe3] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1460 [0xe4] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1461 [0xe5] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1462 [0xe6] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1463 [0xe7] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1464 [0xe8] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1465 [0xe9] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1466 [0xea] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1467 [0xeb] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1468 [0xec] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1469 [0xed] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1470 [0xee] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1471 [0xef] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1472 [0xf0] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1473 [0xf1] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1474 [0xf2] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1475 [0xf3] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1476 [0xf4] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1477 [0xf5] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1478 [0xf6] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1479 [0xf7] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1480 [0xf8] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1481 [0xf9] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1482 [0xfa] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1483 [0xfb] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1484 [0xfc] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1485 [0xfd] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1486 [0xfe] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1487 [0xff] = {OP_trap
, -1, 0, single
, trap_decode
, 0},
1490 static const struct opcode page1
[] =
1492 [0x00] = {OP_bgnd
, -1, 0, single
, 0, 0},
1493 [0x01] = {OP_nop
, -1, 0, single
, 0, 0},
1494 [0x02] = {OP_brclr
, -1, 0, bm_rel_n_bytes
, bm_rel_decode
, 0},
1495 [0x03] = {OP_brset
, -1, 0, bm_rel_n_bytes
, bm_rel_decode
, 0},
1496 [0x04] = {0xFFFF, -1, psh_pul_discrim
, two
, psh_pul_decode
, 0}, /* psh/pul */
1497 [0x05] = {OP_rts
, -1, 0, single
, 0, 0},
1498 [0x06] = {OP_lea
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1499 [0x07] = {OP_lea
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1500 [0x08] = {OP_lea
, -1, 0, opr_n_bytes_p1
, lea_reg_xys_opr
, 0},
1501 [0x09] = {OP_lea
, -1, 0, opr_n_bytes_p1
, lea_reg_xys_opr
, 0},
1502 [0x0a] = {OP_lea
, -1, 0, opr_n_bytes_p1
, lea_reg_xys_opr
, 0},
1503 [0x0b] = {0xFFFF, -1, loop_primitive_discrim
, loop_prim_n_bytes
, loop_primitive_decode
, 0}, /* Loop primitives TBcc / DBcc */
1504 [0x0c] = {OP_mov
, 0, 0, mov_imm_opr_n_bytes
, mov_imm_opr
, 0},
1505 [0x0d] = {OP_mov
, 1, 0, mov_imm_opr_n_bytes
, mov_imm_opr
, 0},
1506 [0x0e] = {OP_mov
, 2, 0, mov_imm_opr_n_bytes
, mov_imm_opr
, 0},
1507 [0x0f] = {OP_mov
, 3, 0, mov_imm_opr_n_bytes
, mov_imm_opr
, 0},
1508 [0x10] = {0xFFFF, -1, shift_discrim
, shift_n_bytes
, shift_decode
, 0}, /* lsr/lsl/asl/asr/rol/ror */
1509 [0x11] = {0xFFFF, -1, shift_discrim
, shift_n_bytes
, shift_decode
, 0},
1510 [0x12] = {0xFFFF, -1, shift_discrim
, shift_n_bytes
, shift_decode
, 0},
1511 [0x13] = {0xFFFF, -1, shift_discrim
, shift_n_bytes
, shift_decode
, 0},
1512 [0x14] = {0xFFFF, -1, shift_discrim
, shift_n_bytes
, shift_decode
, 0},
1513 [0x15] = {0xFFFF, -1, shift_discrim
, shift_n_bytes
, shift_decode
, 0},
1514 [0x16] = {0xFFFF, -1, shift_discrim
, shift_n_bytes
, shift_decode
, 0},
1515 [0x17] = {0xFFFF, -1, shift_discrim
, shift_n_bytes
, shift_decode
, 0},
1516 [0x18] = {OP_lea
, -1, 0, two
, lea_reg_xys
, NULL
},
1517 [0x19] = {OP_lea
, -1, 0, two
, lea_reg_xys
, NULL
},
1518 [0x1a] = {OP_lea
, -1, 0, two
, lea_reg_xys
, NULL
},
1520 [0x1c] = {OP_mov
, 0, 0, opr_n_bytes2
, z_opr_decode2
, 0},
1521 [0x1d] = {OP_mov
, 1, 0, opr_n_bytes2
, z_opr_decode2
, 0},
1522 [0x1e] = {OP_mov
, 2, 0, opr_n_bytes2
, z_opr_decode2
, 0},
1523 [0x1f] = {OP_mov
, 3, 0, opr_n_bytes2
, z_opr_decode2
, 0},
1524 [0x20] = {OP_bra
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1525 [0x21] = {OP_bsr
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1526 [0x22] = {OP_bhi
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1527 [0x23] = {OP_bls
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1528 [0x24] = {OP_bcc
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1529 [0x25] = {OP_bcs
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1530 [0x26] = {OP_bne
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1531 [0x27] = {OP_beq
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1532 [0x28] = {OP_bvc
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1533 [0x29] = {OP_bvs
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1534 [0x2a] = {OP_bpl
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1535 [0x2b] = {OP_bmi
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1536 [0x2c] = {OP_bge
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1537 [0x2d] = {OP_blt
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1538 [0x2e] = {OP_bgt
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1539 [0x2f] = {OP_ble
, -1, 0, pcrel_15bit
, decode_rel_15_7
, 0},
1540 [0x30] = {OP_inc
, -1, 0, single
, z_reg
, 0},
1541 [0x31] = {OP_inc
, -1, 0, single
, z_reg
, 0},
1542 [0x32] = {OP_inc
, -1, 0, single
, z_reg
, 0},
1543 [0x33] = {OP_inc
, -1, 0, single
, z_reg
, 0},
1544 [0x34] = {OP_inc
, -1, 0, single
, z_reg
, 0},
1545 [0x35] = {OP_inc
, -1, 0, single
, z_reg
, 0},
1546 [0x36] = {OP_inc
, -1, 0, single
, z_reg
, 0},
1547 [0x37] = {OP_inc
, -1, 0, single
, z_reg
, 0},
1548 [0x38] = {OP_clr
, -1, 0, single
, z_reg
, 0},
1549 [0x39] = {OP_clr
, -1, 0, single
, z_reg
, 0},
1550 [0x3a] = {OP_clr
, -1, 0, single
, z_reg
, 0},
1551 [0x3b] = {OP_clr
, -1, 0, single
, z_reg
, 0},
1552 [0x3c] = {OP_clr
, -1, 0, single
, z_reg
, 0},
1553 [0x3d] = {OP_clr
, -1, 0, single
, z_reg
, 0},
1554 [0x3e] = {OP_clr
, -1, 0, single
, z_reg
, 0},
1555 [0x3f] = {OP_clr
, -1, 0, single
, z_reg
, 0},
1556 [0x40] = {OP_dec
, -1, 0, single
, z_reg
, 0},
1557 [0x41] = {OP_dec
, -1, 0, single
, z_reg
, 0},
1558 [0x42] = {OP_dec
, -1, 0, single
, z_reg
, 0},
1559 [0x43] = {OP_dec
, -1, 0, single
, z_reg
, 0},
1560 [0x44] = {OP_dec
, -1, 0, single
, z_reg
, 0},
1561 [0x45] = {OP_dec
, -1, 0, single
, z_reg
, 0},
1562 [0x46] = {OP_dec
, -1, 0, single
, z_reg
, 0},
1563 [0x47] = {OP_dec
, -1, 0, single
, z_reg
, 0},
1564 [0x48] = {OPBASE_mul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1565 [0x49] = {OPBASE_mul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1566 [0x4a] = {OPBASE_mul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1567 [0x4b] = {OPBASE_mul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1568 [0x4c] = {OPBASE_mul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1569 [0x4d] = {OPBASE_mul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1570 [0x4e] = {OPBASE_mul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1571 [0x4f] = {OPBASE_mul
, -1, mul_discrim
, mul_n_bytes
, mul_decode
, 0},
1572 [0x50] = {OP_add
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1573 [0x51] = {OP_add
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1574 [0x52] = {OP_add
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1575 [0x53] = {OP_add
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1576 [0x54] = {OP_add
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1577 [0x55] = {OP_add
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1578 [0x56] = {OP_add
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1579 [0x57] = {OP_add
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1580 [0x58] = {OP_and
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1581 [0x59] = {OP_and
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1582 [0x5a] = {OP_and
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1583 [0x5b] = {OP_and
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1584 [0x5c] = {OP_and
, -1, 0, two
, z_reg
, z_imm1234_8base
},
1585 [0x5d] = {OP_and
, -1, 0, two
, z_reg
, z_imm1234_8base
},
1586 [0x5e] = {OP_and
, -1, 0, five
, z_reg
, z_imm1234_8base
},
1587 [0x5f] = {OP_and
, -1, 0, five
, z_reg
, z_imm1234_8base
},
1588 [0x60] = {OP_add
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1589 [0x61] = {OP_add
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1590 [0x62] = {OP_add
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1591 [0x63] = {OP_add
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1592 [0x64] = {OP_add
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1593 [0x65] = {OP_add
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1594 [0x66] = {OP_add
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1595 [0x67] = {OP_add
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1596 [0x68] = {OP_and
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1597 [0x69] = {OP_and
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1598 [0x6a] = {OP_and
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1599 [0x6b] = {OP_and
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1600 [0x6c] = {OP_and
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1601 [0x6d] = {OP_and
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1602 [0x6e] = {OP_and
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1603 [0x6f] = {OP_and
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1604 [0x70] = {OP_sub
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1605 [0x71] = {OP_sub
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1606 [0x72] = {OP_sub
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1607 [0x73] = {OP_sub
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1608 [0x74] = {OP_sub
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1609 [0x75] = {OP_sub
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1610 [0x76] = {OP_sub
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1611 [0x77] = {OP_sub
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1612 [0x78] = {OP_or
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1613 [0x79] = {OP_or
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1614 [0x7a] = {OP_or
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1615 [0x7b] = {OP_or
, -1, 0, three
, z_reg
, z_imm1234_8base
},
1616 [0x7c] = {OP_or
, -1, 0, two
, z_reg
, z_imm1234_8base
},
1617 [0x7d] = {OP_or
, -1, 0, two
, z_reg
, z_imm1234_8base
},
1618 [0x7e] = {OP_or
, -1, 0, five
, z_reg
, z_imm1234_8base
},
1619 [0x7f] = {OP_or
, -1, 0, five
, z_reg
, z_imm1234_8base
},
1620 [0x80] = {OP_sub
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1621 [0x81] = {OP_sub
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1622 [0x82] = {OP_sub
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1623 [0x83] = {OP_sub
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1624 [0x84] = {OP_sub
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1625 [0x85] = {OP_sub
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1626 [0x86] = {OP_sub
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1627 [0x87] = {OP_sub
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1628 [0x88] = {OP_or
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1629 [0x89] = {OP_or
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1630 [0x8a] = {OP_or
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1631 [0x8b] = {OP_or
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1632 [0x8c] = {OP_or
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1633 [0x8d] = {OP_or
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1634 [0x8e] = {OP_or
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1635 [0x8f] = {OP_or
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1636 [0x90] = {OP_ld
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1637 [0x91] = {OP_ld
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1638 [0x92] = {OP_ld
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1639 [0x93] = {OP_ld
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1640 [0x94] = {OP_ld
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1641 [0x95] = {OP_ld
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1642 [0x96] = {OP_ld
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1643 [0x97] = {OP_ld
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1644 [0x98] = {OP_ld
, -1, 0, four
, reg_xy
, z_imm1234_0base
},
1645 [0x99] = {OP_ld
, -1, 0, four
, reg_xy
, z_imm1234_0base
},
1646 [0x9a] = {OP_clr
, -1, 0, single
, reg_xy
, 0},
1647 [0x9b] = {OP_clr
, -1, 0, single
, reg_xy
, 0},
1648 [0x9c] = {OP_inc
, 0, 0, opr_n_bytes_p1
, z_opr_decode
, 0},
1649 [0x9d] = {OP_inc
, 1, 0, opr_n_bytes_p1
, z_opr_decode
, 0},
1650 [0x9e] = {OP_tfr
, -1, 0, two
, z_tfr
, NULL
},
1651 [0x9f] = {OP_inc
, 3, 0, opr_n_bytes_p1
, z_opr_decode
, 0},
1652 [0xa0] = {OP_ld
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1653 [0xa1] = {OP_ld
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1654 [0xa2] = {OP_ld
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1655 [0xa3] = {OP_ld
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1656 [0xa4] = {OP_ld
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1657 [0xa5] = {OP_ld
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1658 [0xa6] = {OP_ld
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1659 [0xa7] = {OP_ld
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1660 [0xa8] = {OP_ld
, -1, 0, opr_n_bytes_p1
, reg_xy
, z_opr_decode
},
1661 [0xa9] = {OP_ld
, -1, 0, opr_n_bytes_p1
, reg_xy
, z_opr_decode
},
1662 [0xaa] = {OP_jmp
, -1, 0, opr_n_bytes_p1
, z_opr_decode
, 0},
1663 [0xab] = {OP_jsr
, -1, 0, opr_n_bytes_p1
, z_opr_decode
, 0},
1664 [0xac] = {OP_dec
, 0, 0, opr_n_bytes_p1
, z_opr_decode
, 0},
1665 [0xad] = {OP_dec
, 1, 0, opr_n_bytes_p1
, z_opr_decode
, 0},
1666 [0xae] = {0xFFFF, -1, exg_sex_discrim
, two
, exg_sex_decode
, 0}, /* EXG / SEX */
1667 [0xaf] = {OP_dec
, 3, 0, opr_n_bytes_p1
, 0, z_opr_decode
},
1668 [0xb0] = {OP_ld
, -1, 0, four
, z_reg
, z_ext24_decode
},
1669 [0xb1] = {OP_ld
, -1, 0, four
, z_reg
, z_ext24_decode
},
1670 [0xb2] = {OP_ld
, -1, 0, four
, z_reg
, z_ext24_decode
},
1671 [0xb3] = {OP_ld
, -1, 0, four
, z_reg
, z_ext24_decode
},
1672 [0xb4] = {OP_ld
, -1, 0, four
, z_reg
, z_ext24_decode
},
1673 [0xb5] = {OP_ld
, -1, 0, four
, z_reg
, z_ext24_decode
},
1674 [0xb6] = {OP_ld
, -1, 0, four
, z_reg
, z_ext24_decode
},
1675 [0xb7] = {OP_ld
, -1, 0, four
, z_reg
, z_ext24_decode
},
1676 [0xb8] = {OP_ld
, -1, 0, four
, reg_xy
, z_ext24_decode
},
1677 [0xb9] = {OP_ld
, -1, 0, four
, reg_xy
, z_ext24_decode
},
1678 [0xba] = {OP_jmp
, -1, 0, four
, z_ext24_decode
, 0},
1679 [0xbb] = {OP_jsr
, -1, 0, four
, z_ext24_decode
, 0},
1680 [0xbc] = {OP_clr
, 0, 0, opr_n_bytes_p1
, z_opr_decode
, 0},
1681 [0xbd] = {OP_clr
, 1, 0, opr_n_bytes_p1
, z_opr_decode
, 0},
1682 [0xbe] = {OP_clr
, 2, 0, opr_n_bytes_p1
, z_opr_decode
, 0},
1683 [0xbf] = {OP_clr
, 3, 0, opr_n_bytes_p1
, z_opr_decode
, 0},
1684 [0xc0] = {OP_st
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1685 [0xc1] = {OP_st
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1686 [0xc2] = {OP_st
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1687 [0xc3] = {OP_st
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1688 [0xc4] = {OP_st
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1689 [0xc5] = {OP_st
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1690 [0xc6] = {OP_st
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1691 [0xc7] = {OP_st
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1692 [0xc8] = {OP_st
, -1, 0, opr_n_bytes_p1
, reg_xy
, z_opr_decode
},
1693 [0xc9] = {OP_st
, -1, 0, opr_n_bytes_p1
, reg_xy
, z_opr_decode
},
1694 [0xca] = {OP_ld
, -1, 0, three
, reg_xy
, ld_18bit_decode
},
1695 [0xcb] = {OP_ld
, -1, 0, three
, reg_xy
, ld_18bit_decode
},
1696 [0xcc] = {OP_com
, 0, 0, opr_n_bytes_p1
, NULL
, z_opr_decode
},
1697 [0xcd] = {OP_com
, 1, 0, opr_n_bytes_p1
, NULL
, z_opr_decode
},
1698 [0xce] = {OP_andcc
, -1, 0, two
, imm1_decode
, 0},
1699 [0xcf] = {OP_com
, 3, 0, opr_n_bytes_p1
, NULL
, z_opr_decode
},
1700 [0xd0] = {OP_st
, -1, 0, four
, z_reg
, z_ext24_decode
},
1701 [0xd1] = {OP_st
, -1, 0, four
, z_reg
, z_ext24_decode
},
1702 [0xd2] = {OP_st
, -1, 0, four
, z_reg
, z_ext24_decode
},
1703 [0xd3] = {OP_st
, -1, 0, four
, z_reg
, z_ext24_decode
},
1704 [0xd4] = {OP_st
, -1, 0, four
, z_reg
, z_ext24_decode
},
1705 [0xd5] = {OP_st
, -1, 0, four
, z_reg
, z_ext24_decode
},
1706 [0xd6] = {OP_st
, -1, 0, four
, z_reg
, z_ext24_decode
},
1707 [0xd7] = {OP_st
, -1, 0, four
, z_reg
, z_ext24_decode
},
1708 [0xd8] = {OP_st
, -1, 0, four
, reg_xy
, z_ext24_decode
},
1709 [0xd9] = {OP_st
, -1, 0, four
, reg_xy
, z_ext24_decode
},
1710 [0xda] = {OP_ld
, -1, 0, three
, reg_xy
, ld_18bit_decode
},
1711 [0xdb] = {OP_ld
, -1, 0, three
, reg_xy
, ld_18bit_decode
},
1712 [0xdc] = {OP_neg
, 0, 0, opr_n_bytes_p1
, NULL
, z_opr_decode
},
1713 [0xdd] = {OP_neg
, 1, 0, opr_n_bytes_p1
, NULL
, z_opr_decode
},
1714 [0xde] = {OP_orcc
, -1, 0, two
, imm1_decode
, 0},
1715 [0xdf] = {OP_neg
, 3, 0, opr_n_bytes_p1
, NULL
, z_opr_decode
},
1716 [0xe0] = {OP_cmp
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1717 [0xe1] = {OP_cmp
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1718 [0xe2] = {OP_cmp
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1719 [0xe3] = {OP_cmp
, -1, 0, three
, z_reg
, z_imm1234_0base
},
1720 [0xe4] = {OP_cmp
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1721 [0xe5] = {OP_cmp
, -1, 0, two
, z_reg
, z_imm1234_0base
},
1722 [0xe6] = {OP_cmp
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1723 [0xe7] = {OP_cmp
, -1, 0, five
, z_reg
, z_imm1234_0base
},
1724 [0xe8] = {OP_cmp
, -1, 0, four
, reg_xy
, z_imm1234_0base
},
1725 [0xe9] = {OP_cmp
, -1, 0, four
, reg_xy
, z_imm1234_0base
},
1726 [0xea] = {OP_ld
, -1, 0, three
, reg_xy
, ld_18bit_decode
},
1727 [0xeb] = {OP_ld
, -1, 0, three
, reg_xy
, ld_18bit_decode
},
1728 [0xec] = {OP_bclr
, -1, 0, bm_n_bytes
, bm_decode
, 0},
1729 [0xed] = {OP_bset
, -1, 0, bm_n_bytes
, bm_decode
, 0},
1730 [0xee] = {OP_btgl
, -1, 0, bm_n_bytes
, bm_decode
, 0},
1731 [0xef] = {OP_INVALID
, -1, 0, NULL
, NULL
, NULL
}, /* SPARE */
1732 [0xf0] = {OP_cmp
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1733 [0xf1] = {OP_cmp
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1734 [0xf2] = {OP_cmp
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1735 [0xf3] = {OP_cmp
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1736 [0xf4] = {OP_cmp
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1737 [0xf5] = {OP_cmp
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1738 [0xf6] = {OP_cmp
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1739 [0xf7] = {OP_cmp
, -1, 0, opr_n_bytes_p1
, z_reg
, z_opr_decode
},
1740 [0xf8] = {OP_cmp
, -1, 0, opr_n_bytes_p1
, reg_xy
, z_opr_decode
},
1741 [0xf9] = {OP_cmp
, -1, 0, opr_n_bytes_p1
, reg_xy
, z_opr_decode
},
1742 [0xfa] = {OP_ld
, -1, 0, three
, reg_xy
, ld_18bit_decode
},
1743 [0xfb] = {OP_ld
, -1, 0, three
, reg_xy
, ld_18bit_decode
},
1744 [0xfc] = {OP_cmp
, -1, 0, single
, cmp_xy
, 0},
1745 [0xfd] = {OP_sub
, -1, 0, single
, sub_d6_x_y
, 0},
1746 [0xfe] = {OP_sub
, -1, 0, single
, sub_d6_y_x
, 0},
1747 [0xff] = {OP_swi
, -1, 0, single
, 0, 0}
1750 static const int oprregs1
[] =
1752 REG_D3
, REG_D2
, REG_D1
, REG_D0
, REG_CCL
, REG_CCH
1755 static const int oprregs2
[] =
1757 REG_Y
, REG_X
, REG_D7
, REG_D6
, REG_D5
, REG_D4
1778 static const struct mb mul_table
[] = {
1779 {0x40, 0x00, MUL_REG_REG
},
1781 {0x47, 0x40, MUL_REG_OPR
},
1782 {0x47, 0x41, MUL_REG_OPR
},
1783 {0x47, 0x43, MUL_REG_OPR
},
1785 {0x47, 0x44, MUL_REG_IMM
},
1786 {0x47, 0x45, MUL_REG_IMM
},
1787 {0x47, 0x47, MUL_REG_IMM
},
1789 {0x43, 0x42, MUL_OPR_OPR
},
1794 mul_decode (struct mem_read_abstraction_base
*mra
,
1795 int *n_operands
, struct operand
**operand
)
1799 int status
= mra
->read (mra
, 0, 1, &mb
);
1804 status
= mra
->read (mra
, -1, 1, &byte
);
1808 enum MUL_MODE mode
= -1;
1810 for (i
= 0; i
< sizeof (mul_table
) / sizeof (mul_table
[0]); ++i
)
1812 const struct mb
*mm
= mul_table
+ i
;
1813 if ((mb
& mm
->mask
) == mm
->value
)
1819 op
= create_register_operand (byte
& 0x07);
1822 operand
[(*n_operands
)++] = op
;
1828 int size
= (mb
& 0x3);
1829 op
= create_register_operand_with_size ((mb
& 0x38) >> 3, size
);
1832 operand
[(*n_operands
)++] = op
;
1835 if (z_decode_signed_value (mra
, 1, size
+ 1, &imm
) < 0)
1837 op
= create_immediate_operand (imm
);
1840 operand
[(*n_operands
)++] = op
;
1844 op
= create_register_operand ((mb
& 0x38) >> 3);
1847 operand
[(*n_operands
)++] = op
;
1848 op
= create_register_operand (mb
& 0x07);
1851 operand
[(*n_operands
)++] = op
;
1854 op
= create_register_operand ((mb
& 0x38) >> 3);
1857 operand
[(*n_operands
)++] = op
;
1858 op
= x_opr_decode_with_size (mra
, 1, mb
& 0x3);
1861 operand
[(*n_operands
)++] = op
;
1865 int first
= x_opr_n_bytes (mra
, 1);
1868 op
= x_opr_decode_with_size (mra
, 1, (mb
& 0x30) >> 4);
1871 operand
[(*n_operands
)++] = op
;
1872 op
= x_opr_decode_with_size (mra
, first
+ 1, (mb
& 0x0c) >> 2);
1875 operand
[(*n_operands
)++] = op
;
1884 mul_n_bytes (struct mem_read_abstraction_base
*mra
)
1889 int status
= mra
->read (mra
, 0, 1, &mb
);
1893 enum MUL_MODE mode
= -1;
1895 for (i
= 0; i
< sizeof (mul_table
) / sizeof (mul_table
[0]); ++i
)
1897 const struct mb
*mm
= mul_table
+ i
;
1898 if ((mb
& mm
->mask
) == mm
->value
)
1905 int size
= (mb
& 0x3) + 1;
1915 first
= x_opr_n_bytes (mra
, 1);
1921 first
= x_opr_n_bytes (mra
, nx
- 1);
1925 second
= x_opr_n_bytes (mra
, nx
- 1);
1936 /* The NXP documentation is vague about BM_RESERVED0 and BM_RESERVED1,
1937 and contains obvious typos.
1938 However the Freescale tools and experiments with the chip itself
1939 seem to indicate that they behave like BM_REG_IMM and BM_OPR_REG
1960 static const struct bm bm_table
[] = {
1961 { 0xC6, 0x04, BM_REG_IMM
},
1962 { 0x84, 0x00, BM_REG_IMM
},
1963 { 0x06, 0x06, BM_REG_IMM
},
1964 { 0xC6, 0x44, BM_RESERVED0
},
1966 { 0x8F, 0x80, BM_OPR_B
},
1967 { 0x8E, 0x82, BM_OPR_W
},
1968 { 0x8C, 0x88, BM_OPR_L
},
1970 { 0x83, 0x81, BM_OPR_REG
},
1971 { 0x87, 0x84, BM_RESERVED1
},
1975 bm_decode (struct mem_read_abstraction_base
*mra
,
1976 int *n_operands
, struct operand
**operand
)
1980 int status
= mra
->read (mra
, 0, 1, &bm
);
1985 enum BM_MODE mode
= -1;
1986 for (i
= 0; i
< sizeof (bm_table
) / sizeof (bm_table
[0]); ++i
)
1988 const struct bm
*bme
= bm_table
+ i
;
1989 if ((bm
& bme
->mask
) == bme
->value
)
2000 op
= create_register_operand (bm
& 0x07);
2003 operand
[(*n_operands
)++] = op
;
2006 op
= x_opr_decode_with_size (mra
, 1, 0);
2009 operand
[(*n_operands
)++] = op
;
2012 op
= x_opr_decode_with_size (mra
, 1, 1);
2015 operand
[(*n_operands
)++] = op
;
2018 op
= x_opr_decode_with_size (mra
, 1, 3);
2021 operand
[(*n_operands
)++] = op
;
2027 status
= mra
->read (mra
, 1, 1, &xb
);
2030 /* Don't emit a size suffix for register operands */
2031 if ((xb
& 0xF8) != 0xB8)
2032 op
= x_opr_decode_with_size (mra
, 1, (bm
& 0x0c) >> 2);
2034 op
= x_opr_decode (mra
, 1);
2037 operand
[(*n_operands
)++] = op
;
2047 imm
= (bm
& 0x38) >> 3;
2048 op
= create_immediate_operand (imm
);
2051 operand
[(*n_operands
)++] = op
;
2054 imm
|= (bm
& 0x03) << 3;
2057 imm
|= (bm
& 0x01) << 3;
2060 imm
|= (bm
& 0x70) >> 4;
2061 op
= create_immediate_operand (imm
);
2064 operand
[(*n_operands
)++] = op
;
2068 op
= create_register_operand ((bm
& 0x70) >> 4);
2071 operand
[(*n_operands
)++] = op
;
2079 bm_rel_decode (struct mem_read_abstraction_base
*mra
,
2080 int *n_operands
, struct operand
**operand
)
2084 int status
= mra
->read (mra
, 0, 1, &bm
);
2089 enum BM_MODE mode
= -1;
2090 for (i
= 0; i
< sizeof (bm_table
) / sizeof (bm_table
[0]); ++i
)
2092 const struct bm
*bme
= bm_table
+ i
;
2093 if ((bm
& bme
->mask
) == bme
->value
)
2105 op
= create_register_operand (bm
& 0x07);
2108 operand
[(*n_operands
)++] = op
;
2111 op
= x_opr_decode_with_size (mra
, 1, 0);
2114 operand
[(*n_operands
)++] = op
;
2115 n
= x_opr_n_bytes (mra
, 1);
2121 op
= x_opr_decode_with_size (mra
, 1, 1);
2124 operand
[(*n_operands
)++] = op
;
2125 n
= x_opr_n_bytes (mra
, 1);
2131 op
= x_opr_decode_with_size (mra
, 1, 3);
2134 operand
[(*n_operands
)++] = op
;
2135 n
= x_opr_n_bytes (mra
, 1);
2144 status
= mra
->read (mra
, +1, 1, &xb
);
2147 /* Don't emit a size suffix for register operands */
2148 if ((xb
& 0xF8) != 0xB8)
2150 short os
= (bm
& 0x0c) >> 2;
2151 op
= x_opr_decode_with_size (mra
, 1, os
);
2154 op
= x_opr_decode (mra
, 1);
2157 operand
[(*n_operands
)++] = op
;
2166 imm
|= (bm
& 0x02) << 3;
2169 imm
|= (bm
& 0x01) << 3;
2172 imm
|= (bm
& 0x70) >> 4;
2173 op
= create_immediate_operand (imm
);
2176 operand
[(*n_operands
)++] = op
;
2179 imm
= (bm
& 0x38) >> 3;
2180 op
= create_immediate_operand (imm
);
2183 operand
[(*n_operands
)++] = op
;
2186 imm
= (bm
& 0xF8) >> 3;
2187 op
= create_immediate_operand (imm
);
2190 operand
[(*n_operands
)++] = op
;
2194 op
= create_register_operand ((bm
& 0x70) >> 4);
2197 operand
[(*n_operands
)++] = op
;
2198 x
= x_opr_n_bytes (mra
, 1);
2205 return rel_15_7 (mra
, n
+ 1, n_operands
, operand
);
2209 bm_n_bytes (struct mem_read_abstraction_base
*mra
)
2212 int status
= mra
->read (mra
, 0, 1, &bm
);
2217 enum BM_MODE mode
= -1;
2218 for (i
= 0; i
< sizeof (bm_table
) / sizeof (bm_table
[0]); ++i
)
2220 const struct bm
*bme
= bm_table
+ i
;
2221 if ((bm
& bme
->mask
) == bme
->value
)
2240 n
= x_opr_n_bytes (mra
, 1);
2250 bm_rel_n_bytes (struct mem_read_abstraction_base
*mra
)
2252 int n
= 1 + bm_n_bytes (mra
);
2255 int status
= mra
->read (mra
, n
- 2, 1, &rb
);
2269 /* shift direction */
2300 static const struct sb sb_table
[] = {
2301 {0x30, 0x00, SB_REG_REG_N_EFF
},
2302 {0x30, 0x10, SB_REG_REG_N
},
2303 {0x34, 0x20, SB_REG_OPR_EFF
},
2304 {0x34, 0x24, SB_ROT
},
2305 {0x34, 0x30, SB_REG_OPR_OPR
},
2306 {0x34, 0x34, SB_OPR_N
},
2310 shift_n_bytes (struct mem_read_abstraction_base
*mra
)
2314 int status
= mra
->read (mra
, 0, 1, &sb
);
2319 enum SB_MODE mode
= -1;
2320 for (i
= 0; i
< sizeof (sb_table
) / sizeof (sb_table
[0]); ++i
)
2322 const struct sb
*sbe
= sb_table
+ i
;
2323 if ((sb
& sbe
->mask
) == sbe
->value
)
2329 case SB_REG_REG_N_EFF
:
2331 case SB_REG_OPR_EFF
:
2333 opr1
= x_opr_n_bytes (mra
, 1);
2337 case SB_REG_OPR_OPR
:
2338 opr1
= x_opr_n_bytes (mra
, 1);
2342 if ((sb
& 0x30) != 0x20)
2344 opr2
= x_opr_n_bytes (mra
, opr1
+ 1);
2348 return 2 + opr1
+ opr2
;
2359 mov_imm_opr_n_bytes (struct mem_read_abstraction_base
*mra
)
2362 int status
= mra
->read (mra
, -1, 1, &byte
);
2366 int size
= byte
- 0x0c + 1;
2367 int n
= x_opr_n_bytes (mra
, size
);
2371 return size
+ n
+ 1;
2375 mov_imm_opr (struct mem_read_abstraction_base
*mra
,
2376 int *n_operands
, struct operand
**operand
)
2380 int status
= mra
->read (mra
, -1, 1, &byte
);
2384 int size
= byte
- 0x0c + 1;
2386 if (decode_signed_value (mra
, size
, &imm
))
2389 op
= create_immediate_operand (imm
);
2392 operand
[(*n_operands
)++] = op
;
2393 op
= x_opr_decode (mra
, size
);
2396 operand
[(*n_operands
)++] = op
;
2403 ld_18bit_decode (struct mem_read_abstraction_base
*mra
,
2404 int *n_operands
, struct operand
**operand
)
2409 int status
= mra
->read (mra
, 0, 2, buffer
+ 1);
2413 status
= mra
->read (mra
, -1, 1, buffer
);
2417 buffer
[0] = (buffer
[0] & 0x30) >> 4;
2421 for (i
= 0; i
< size
; ++i
)
2423 imm
|= buffer
[i
] << (8 * (size
- i
- 1));
2426 op
= create_immediate_operand (imm
);
2429 operand
[(*n_operands
)++] = op
;
2435 /* Loop Primitives */
2450 static const struct lp lp_mode
[] = {
2451 {0x08, 0x00, LP_REG
},
2452 {0x0C, 0x08, LP_XY
},
2453 {0x0C, 0x0C, LP_OPR
},
2458 loop_prim_n_bytes (struct mem_read_abstraction_base
*mra
)
2462 int status
= mra
->read (mra
, mx
++, 1, &lb
);
2466 enum LP_MODE mode
= -1;
2468 for (i
= 0; i
< sizeof (lp_mode
) / sizeof (lp_mode
[0]); ++i
)
2470 const struct lp
*pb
= lp_mode
+ i
;
2471 if ((lb
& pb
->mask
) == pb
->value
)
2480 int n
= x_opr_n_bytes (mra
, mx
);
2487 status
= mra
->read (mra
, mx
++, 1, &rb
);
2500 exg_sex_discrim (struct mem_read_abstraction_base
*mra
,
2501 enum optr hint ATTRIBUTE_UNUSED
)
2504 int status
= mra
->read (mra
, 0, 1, &eb
);
2505 enum optr
operator = OP_INVALID
;
2509 struct operand
*op0
= create_register_operand ((eb
& 0xf0) >> 4);
2512 struct operand
*op1
= create_register_operand (eb
& 0xf);
2516 int reg0
= ((struct register_operand
*) op0
)->reg
;
2517 int reg1
= ((struct register_operand
*) op1
)->reg
;
2518 if (reg0
>= 0 && reg0
< S12Z_N_REGISTERS
2519 && reg1
>= 0 && reg1
< S12Z_N_REGISTERS
)
2521 const struct reg
*r0
= registers
+ reg0
;
2522 const struct reg
*r1
= registers
+ reg1
;
2524 operator = r0
->bytes
< r1
->bytes
? OP_sex
: OP_exg
;
2535 exg_sex_decode (struct mem_read_abstraction_base
*mra
,
2536 int *n_operands
, struct operand
**operands
)
2540 int status
= mra
->read (mra
, 0, 1, &eb
);
2544 /* Ship out the operands. */
2545 op
= create_register_operand ((eb
& 0xf0) >> 4);
2548 operands
[(*n_operands
)++] = op
;
2549 op
= create_register_operand (eb
& 0xf);
2552 operands
[(*n_operands
)++] = op
;
2557 loop_primitive_discrim (struct mem_read_abstraction_base
*mra
,
2558 enum optr hint ATTRIBUTE_UNUSED
)
2561 int status
= mra
->read (mra
, 0, 1, &lb
);
2565 enum optr opbase
= (lb
& 0x80) ? OP_dbNE
: OP_tbNE
;
2566 return opbase
+ ((lb
& 0x70) >> 4);
2570 loop_primitive_decode (struct mem_read_abstraction_base
*mra
,
2571 int *n_operands
, struct operand
**operands
)
2576 int status
= mra
->read (mra
, 0, 1, &lb
);
2580 enum LP_MODE mode
= -1;
2582 for (i
= 0; i
< sizeof (lp_mode
) / sizeof (lp_mode
[0]); ++i
)
2584 const struct lp
*pb
= lp_mode
+ i
;
2585 if ((lb
& pb
->mask
) == pb
->value
)
2595 op
= create_register_operand (lb
& 0x07);
2598 operands
[(*n_operands
)++] = op
;
2601 op
= create_register_operand ((lb
& 0x01) + REG_X
);
2604 operands
[(*n_operands
)++] = op
;
2607 n
= x_opr_n_bytes (mra
, 1);
2611 op
= x_opr_decode_with_size (mra
, 1, lb
& 0x03);
2614 operands
[(*n_operands
)++] = op
;
2618 return rel_15_7 (mra
, offs
+ 1, n_operands
, operands
);
2623 shift_discrim (struct mem_read_abstraction_base
*mra
,
2624 enum optr hint ATTRIBUTE_UNUSED
)
2628 int status
= mra
->read (mra
, 0, 1, &sb
);
2632 enum SB_DIR dir
= (sb
& 0x40) ? SB_LEFT
: SB_RIGHT
;
2633 enum SB_TYPE type
= (sb
& 0x80) ? SB_ARITHMETIC
: SB_LOGICAL
;
2634 enum SB_MODE mode
= -1;
2635 for (i
= 0; i
< sizeof (sb_table
) / sizeof (sb_table
[0]); ++i
)
2637 const struct sb
*sbe
= sb_table
+ i
;
2638 if ((sb
& sbe
->mask
) == sbe
->value
)
2643 return (dir
== SB_LEFT
) ? OP_rol
: OP_ror
;
2645 if (type
== SB_LOGICAL
)
2646 return (dir
== SB_LEFT
) ? OP_lsl
: OP_lsr
;
2648 return (dir
== SB_LEFT
) ? OP_asl
: OP_asr
;
2653 shift_decode (struct mem_read_abstraction_base
*mra
, int *n_operands
,
2654 struct operand
**operands
)
2659 int status
= mra
->read (mra
, -1, 1, &byte
);
2664 status
= mra
->read (mra
, 0, 1, &sb
);
2668 enum SB_MODE mode
= -1;
2669 for (i
= 0; i
< sizeof (sb_table
) / sizeof (sb_table
[0]); ++i
)
2671 const struct sb
*sbe
= sb_table
+ i
;
2672 if ((sb
& sbe
->mask
) == sbe
->value
)
2679 case SB_REG_OPR_EFF
:
2681 case SB_REG_OPR_OPR
:
2687 status
= mra
->read (mra
, 1, 1, &xb
);
2690 /* The size suffix is not printed if the OPR operand refers
2691 directly to a register, because the size is implied by the
2692 size of that register. */
2693 if ((xb
& 0xF8) != 0xB8)
2701 /* Destination register */
2704 case SB_REG_REG_N_EFF
:
2706 op
= create_register_operand (byte
& 0x07);
2709 operands
[(*n_operands
)++] = op
;
2711 case SB_REG_OPR_EFF
:
2712 case SB_REG_OPR_OPR
:
2713 op
= create_register_operand (byte
& 0x07);
2716 operands
[(*n_operands
)++] = op
;
2720 op
= x_opr_decode_with_size (mra
, 1, osize
);
2723 operands
[(*n_operands
)++] = op
;
2730 /* Source register */
2733 case SB_REG_REG_N_EFF
:
2735 op
= create_register_operand_with_size (sb
& 0x07, osize
);
2738 operands
[(*n_operands
)++] = op
;
2741 case SB_REG_OPR_OPR
:
2742 op
= x_opr_decode_with_size (mra
, 1, osize
);
2745 operands
[(*n_operands
)++] = op
;
2755 case SB_REG_OPR_EFF
:
2757 op
= x_opr_decode_with_size (mra
, 1, osize
);
2760 operands
[(*n_operands
)++] = op
;
2766 status
= mra
->read (mra
, 1, 1, &xb
);
2770 /* This case is slightly unusual.
2771 If XB matches the binary pattern 0111XXXX, then instead of
2772 interpreting this as a general OPR postbyte in the IMMe4 mode,
2773 the XB byte is interpreted in s special way. */
2774 if ((xb
& 0xF0) == 0x70)
2778 int shift
= ((sb
& 0x08) >> 3) | ((xb
& 0x0f) << 1);
2779 op
= create_immediate_operand (shift
);
2782 operands
[(*n_operands
)++] = op
;
2786 /* This should not happen. */
2792 op
= x_opr_decode (mra
, 1);
2795 operands
[(*n_operands
)++] = op
;
2799 case SB_REG_OPR_OPR
:
2802 int n
= x_opr_n_bytes (mra
, 1);
2805 status
= mra
->read (mra
, 1 + n
, 1, &xb
);
2809 if ((xb
& 0xF0) == 0x70)
2811 int imm
= xb
& 0x0F;
2813 imm
|= (sb
& 0x08) >> 3;
2814 op
= create_immediate_operand (imm
);
2817 operands
[(*n_operands
)++] = op
;
2821 op
= x_opr_decode (mra
, 1 + n
);
2824 operands
[(*n_operands
)++] = op
;
2834 case SB_REG_REG_N_EFF
:
2835 case SB_REG_OPR_EFF
:
2838 int imm
= (sb
& 0x08) ? 2 : 1;
2839 op
= create_immediate_operand (imm
);
2842 operands
[(*n_operands
)++] = op
;
2853 psh_pul_discrim (struct mem_read_abstraction_base
*mra
,
2854 enum optr hint ATTRIBUTE_UNUSED
)
2857 int status
= mra
->read (mra
, 0, 1, &byte
);
2861 return (byte
& 0x80) ? OP_pull
: OP_push
;
2866 psh_pul_decode (struct mem_read_abstraction_base
*mra
,
2867 int *n_operands
, struct operand
**operand
)
2871 int status
= mra
->read (mra
, 0, 1, &byte
);
2877 if ((byte
& 0x3F) == 0)
2879 op
= create_register_all16_operand ();
2882 operand
[(*n_operands
)++] = op
;
2885 for (bit
= 5; bit
>= 0; --bit
)
2887 if (byte
& (0x1 << bit
))
2889 op
= create_register_operand (oprregs2
[bit
]);
2892 operand
[(*n_operands
)++] = op
;
2898 if ((byte
& 0x3F) == 0)
2900 op
= create_register_all_operand ();
2903 operand
[(*n_operands
)++] = op
;
2906 for (bit
= 5; bit
>= 0; --bit
)
2908 if (byte
& (0x1 << bit
))
2910 op
= create_register_operand (oprregs1
[bit
]);
2913 operand
[(*n_operands
)++] = op
;
2921 bit_field_discrim (struct mem_read_abstraction_base
*mra
,
2922 enum optr hint ATTRIBUTE_UNUSED
)
2926 status
= mra
->read (mra
, 0, 1, &bb
);
2930 return (bb
& 0x80) ? OP_bfins
: OP_bfext
;
2934 bit_field_decode (struct mem_read_abstraction_base
*mra
,
2935 int *n_operands
, struct operand
**operands
)
2941 status
= mra
->read (mra
, -1, 1, &byte2
);
2946 status
= mra
->read (mra
, 0, 1, &bb
);
2950 enum BB_MODE mode
= -1;
2952 const struct opr_bb
*bbs
= 0;
2953 for (i
= 0; i
< sizeof (bb_modes
) / sizeof (bb_modes
[0]); ++i
)
2956 if ((bb
& bbs
->mask
) == bbs
->value
)
2962 int reg1
= byte2
& 0x07;
2966 case BB_REG_REG_REG
:
2967 case BB_REG_REG_IMM
:
2968 case BB_REG_OPR_REG
:
2969 case BB_REG_OPR_IMM
:
2970 op
= create_register_operand (reg1
);
2973 operands
[(*n_operands
)++] = op
;
2975 case BB_OPR_REG_REG
:
2976 op
= x_opr_decode_with_size (mra
, 1, (bb
>> 2) & 0x03);
2979 operands
[(*n_operands
)++] = op
;
2981 case BB_OPR_REG_IMM
:
2982 op
= x_opr_decode_with_size (mra
, 2, (bb
>> 2) & 0x03);
2985 operands
[(*n_operands
)++] = op
;
2989 /* Second operand */
2992 case BB_REG_REG_REG
:
2993 case BB_REG_REG_IMM
:
2995 int reg_src
= (bb
>> 2) & 0x07;
2996 op
= create_register_operand (reg_src
);
2999 operands
[(*n_operands
)++] = op
;
3002 case BB_OPR_REG_REG
:
3003 case BB_OPR_REG_IMM
:
3005 int reg_src
= (byte2
& 0x07);
3006 op
= create_register_operand (reg_src
);
3009 operands
[(*n_operands
)++] = op
;
3012 case BB_REG_OPR_REG
:
3013 op
= x_opr_decode_with_size (mra
, 1, (bb
>> 2) & 0x03);
3016 operands
[(*n_operands
)++] = op
;
3018 case BB_REG_OPR_IMM
:
3019 op
= x_opr_decode_with_size (mra
, 2, (bb
>> 2) & 0x03);
3022 operands
[(*n_operands
)++] = op
;
3029 case BB_REG_REG_REG
:
3030 case BB_OPR_REG_REG
:
3031 case BB_REG_OPR_REG
:
3033 int reg_parm
= bb
& 0x03;
3034 op
= create_register_operand (reg_parm
);
3037 operands
[(*n_operands
)++] = op
;
3040 case BB_REG_REG_IMM
:
3041 case BB_OPR_REG_IMM
:
3042 case BB_REG_OPR_IMM
:
3045 status
= mra
->read (mra
, 1, 1, &i1
);
3048 int offset
= i1
& 0x1f;
3049 int width
= bb
& 0x03;
3052 op
= create_bitfield_operand (width
, offset
);
3055 operands
[(*n_operands
)++] = op
;
3063 /* Decode the next instruction at MRA, according to OPC.
3064 The operation to be performed is returned.
3065 The number of operands, will be placed in N_OPERANDS.
3066 The operands themselved into OPERANDS. */
3068 decode_operation (const struct opcode
*opc
,
3069 struct mem_read_abstraction_base
*mra
,
3070 int *n_operands
, struct operand
**operands
)
3072 enum optr op
= opc
->operator;
3073 if (opc
->discriminator
)
3075 op
= opc
->discriminator (mra
, opc
->operator);
3076 if (op
== OP_INVALID
)
3081 if (opc
->operands (mra
, n_operands
, operands
) < 0)
3085 if (opc
->operands2 (mra
, n_operands
, operands
) < 0)
3092 decode_s12z (enum optr
*myoperator
, short *osize
,
3093 int *n_operands
, struct operand
**operands
,
3094 struct mem_read_abstraction_base
*mra
)
3099 int status
= mra
->read (mra
, 0, 1, &byte
);
3105 const struct opcode
*opc
= page1
+ byte
;
3106 if (byte
== PAGE2_PREBYTE
)
3108 /* Opcodes in page2 have an additional byte */
3112 status
= mra
->read (mra
, 0, 1, &byte2
);
3116 opc
= page2
+ byte2
;
3118 *myoperator
= decode_operation (opc
, mra
, n_operands
, operands
);
3119 *osize
= opc
->osize
;
3121 /* Return the number of bytes in the instruction. */
3122 if (*myoperator
!= OP_INVALID
&& opc
->insn_bytes
)
3124 int n
= opc
->insn_bytes (mra
);