5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License (the "License").
7 * You may not use this file except in compliance with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
32 * #pragma ident "@(#)dis_tables.c 1.18 08/05/24 SMI"
34 #if !defined(__APPLE__)
35 #include "dis_tables.h"
37 #include <sys/dtrace.h>
38 #include <sys/dtrace_glue.h>
40 #include <sys/dis_tables.h>
42 #endif /* __APPLE__ */
47 * Disassembly begins in dis_distable, which is equivalent to the One-byte
48 * Opcode Map in the Intel IA32 ISA Reference (page A-6 in my copy). The
49 * decoding loops then traverse out through the other tables as necessary to
50 * decode a given instruction.
52 * The behavior of this file can be controlled by one of the following flags:
54 * DIS_TEXT Include text for disassembly
55 * DIS_MEM Include memory-size calculations
57 * Either or both of these can be defined.
59 * This file is not, and will never be, cstyled. If anything, the tables should
60 * be taken out another tab stop or two so nothing overlaps.
64 * These functions must be provided for the consumer to do disassembly.
67 extern char *strncpy(char *, const char *, size_t);
68 extern size_t strlen(const char *);
69 #if !defined(__APPLE__)
70 extern int strcmp(const char *, const char *);
71 #endif /* __APPLE__ */
72 extern int strncmp(const char *, const char *, size_t);
73 extern size_t strlcat(char *, const char *, size_t);
77 #define TERM 0 /* used to indicate that the 'indirect' */
78 /* field terminates - no pointer. */
80 /* Used to decode instructions. */
81 typedef struct instable
{
82 struct instable
*it_indirect
; /* for decode op codes */
86 uint_t it_suffix
:1; /* mnem + "w", "l", or "d" */
91 uint_t it_invalid64
:1; /* opcode invalid in amd64 */
92 uint_t it_always64
:1; /* 64 bit when in 64 bit mode */
93 uint_t it_invalid32
:1; /* invalid in IA32 */
94 uint_t it_stackop
:1; /* push/pop stack operation */
98 * Instruction formats.
112 M
, /* register or memory */
113 Mb
, /* register or memory, always byte sized */
114 MO
, /* memory only (no registers) */
135 DSHIFT
, /* for double shift that has an 8-bit immediate */
138 NORM
, /* instructions w/o ModR/M byte, no memory access */
139 IMPLMEM
, /* instructions w/o ModR/M byte, implicit mem access */
141 JTAB
, /* jump table */
142 IMUL
, /* for 186 iimul instr */
143 CBW
, /* so data16 can be evaluated for cbw and variants */
144 MvI
, /* for 186 logicals */
145 ENTER
, /* for 186 enter instr */
146 RMw
, /* for 286 arpl instr */
147 Ib
, /* for push immediate byte */
148 F
, /* for 287 instructions */
149 FF
, /* for 287 instructions */
150 FFC
, /* for 287 instructions */
151 DM
, /* 16-bit data */
152 AM
, /* 16-bit addr */
153 LSEG
, /* for 3-bit seg reg encoding */
154 MIb
, /* for 386 logicals */
155 SREG
, /* for 386 special registers */
156 PREFIX
, /* a REP instruction prefix */
157 LOCK
, /* a LOCK instruction prefix */
158 INT3
, /* The int 3 instruction, which has a fake operand */
159 INTx
, /* The normal int instruction, with explicit int num */
160 DSHIFTcl
, /* for double shift that implicitly uses %cl */
161 CWD
, /* so data16 can be evaluated for cwd and variants */
162 RET
, /* single immediate 16-bit operand */
163 MOVZ
, /* for movs and movz, with different size operands */
164 CRC32
, /* for crc32, with different size operands */
165 XADDB
, /* for xaddb */
166 MOVSXZ
, /* AMD64 mov sign extend 32 to 64 bit instruction */
169 * MMX/SIMD addressing modes.
172 MMO
, /* Prefixable MMX/SIMD-Int mm/mem -> mm */
173 MMOIMPL
, /* Prefixable MMX/SIMD-Int mm -> mm (mem) */
174 MMO3P
, /* Prefixable MMX/SIMD-Int mm -> r32,imm8 */
175 MMOM3
, /* Prefixable MMX/SIMD-Int mm -> r32 */
176 MMOS
, /* Prefixable MMX/SIMD-Int mm -> mm/mem */
177 MMOMS
, /* Prefixable MMX/SIMD-Int mm -> mem */
178 MMOPM
, /* MMX/SIMD-Int mm/mem -> mm,imm8 */
179 MMOPM_66o
, /* MMX/SIMD-Int 0x66 optional mm/mem -> mm,imm8 */
180 MMOPRM
, /* Prefixable MMX/SIMD-Int r32/mem -> mm,imm8 */
181 MMOSH
, /* Prefixable MMX mm,imm8 */
182 MM
, /* MMX/SIMD-Int mm/mem -> mm */
183 MMS
, /* MMX/SIMD-Int mm -> mm/mem */
184 MMSH
, /* MMX mm,imm8 */
185 XMMO
, /* Prefixable SIMD xmm/mem -> xmm */
186 XMMOS
, /* Prefixable SIMD xmm -> xmm/mem */
187 XMMOPM
, /* Prefixable SIMD xmm/mem w/to xmm,imm8 */
188 XMMOMX
, /* Prefixable SIMD mm/mem -> xmm */
189 XMMOX3
, /* Prefixable SIMD xmm -> r32 */
190 XMMOXMM
, /* Prefixable SIMD xmm/mem -> mm */
191 XMMOM
, /* Prefixable SIMD xmm -> mem */
192 XMMOMS
, /* Prefixable SIMD mem -> xmm */
193 XMM
, /* SIMD xmm/mem -> xmm */
194 XMM_66r
, /* SIMD 0x66 prefix required xmm/mem -> xmm */
195 XMM_66o
, /* SIMD 0x66 prefix optional xmm/mem -> xmm */
196 XMMXIMPL
, /* SIMD xmm -> xmm (mem) */
197 XMM3P
, /* SIMD xmm -> r32,imm8 */
198 XMM3PM_66r
, /* SIMD 0x66 prefix required xmm -> r32/mem,imm8 */
199 XMMP
, /* SIMD xmm/mem w/to xmm,imm8 */
200 XMMP_66o
, /* SIMD 0x66 prefix optional xmm/mem w/to xmm,imm8 */
201 XMMP_66r
, /* SIMD 0x66 prefix required xmm/mem w/to xmm,imm8 */
202 XMMPRM
, /* SIMD r32/mem -> xmm,imm8 */
203 XMMPRM_66r
, /* SIMD 0x66 prefix required r32/mem -> xmm,imm8 */
204 XMMS
, /* SIMD xmm -> xmm/mem */
205 XMMM
, /* SIMD mem -> xmm */
206 XMMM_66r
, /* SIMD 0x66 prefix required mem -> xmm */
207 XMMMS
, /* SIMD xmm -> mem */
208 XMM3MX
, /* SIMD r32/mem -> xmm */
209 XMM3MXS
, /* SIMD xmm -> r32/mem */
210 XMMSH
, /* SIMD xmm,imm8 */
211 XMMXM3
, /* SIMD xmm/mem -> r32 */
212 XMMX3
, /* SIMD xmm -> r32 */
213 XMMXMM
, /* SIMD xmm/mem -> mm */
214 XMMMX
, /* SIMD mm -> xmm */
215 XMMXM
, /* SIMD xmm -> mm */
216 XMMX2I
, /* SIMD xmm -> xmm, imm, imm */
217 XMM2I
, /* SIMD xmm, imm, imm */
218 XMMFENCE
, /* SIMD lfence or mfence */
219 XMMSFNC
/* SIMD sfence (none or mem) */
222 #define FILL 0x90 /* Fill byte used for alignment (nop) */
225 ** Register numbers for the i386
237 * modes for immediate values
240 #define MODE_IPREL 1 /* signed IP relative value */
241 #define MODE_SIGNED 2 /* sign extended immediate */
242 #define MODE_IMPLIED 3 /* constant value implied from opcode */
243 #define MODE_OFFSET 4 /* offset part of an address */
244 #define MODE_RIPREL 5 /* like IPREL, but from %rip (amd64) */
247 * The letters used in these macros are:
248 * IND - indirect to another to another table
249 * "T" - means to Terminate indirections (this is the final opcode)
250 * "S" - means "operand length suffix required"
251 * "NS" - means "no suffix" which is the operand length suffix of the opcode
252 * "Z" - means instruction size arg required
253 * "u" - means the opcode is invalid in IA32 but valid in amd64
254 * "x" - means the opcode is invalid in amd64, but not IA32
255 * "y" - means the operand size is always 64 bits in 64 bit mode
256 * "p" - means push/pop stack operation
259 #if defined(DIS_TEXT) && defined(DIS_MEM)
260 #define IND(table) {(instable_t *)table, 0, "", 0, 0, 0, 0, 0, 0}
261 #define INDx(table) {(instable_t *)table, 0, "", 0, 0, 1, 0, 0, 0}
262 #define TNS(name, amode) {TERM, amode, name, 0, 0, 0, 0, 0, 0}
263 #define TNSu(name, amode) {TERM, amode, name, 0, 0, 0, 0, 1, 0}
264 #define TNSx(name, amode) {TERM, amode, name, 0, 0, 1, 0, 0, 0}
265 #define TNSy(name, amode) {TERM, amode, name, 0, 0, 0, 1, 0, 0}
266 #define TNSyp(name, amode) {TERM, amode, name, 0, 0, 0, 1, 0, 1}
267 #define TNSZ(name, amode, sz) {TERM, amode, name, 0, sz, 0, 0, 0, 0}
268 #define TNSZy(name, amode, sz) {TERM, amode, name, 0, sz, 0, 1, 0, 0}
269 #define TS(name, amode) {TERM, amode, name, 1, 0, 0, 0, 0, 0}
270 #define TSx(name, amode) {TERM, amode, name, 1, 0, 1, 0, 0, 0}
271 #define TSy(name, amode) {TERM, amode, name, 1, 0, 0, 1, 0, 0}
272 #define TSp(name, amode) {TERM, amode, name, 1, 0, 0, 0, 0, 1}
273 #define TSZ(name, amode, sz) {TERM, amode, name, 1, sz, 0, 0, 0, 0}
274 #define TSZx(name, amode, sz) {TERM, amode, name, 1, sz, 1, 0, 0, 0}
275 #define TSZy(name, amode, sz) {TERM, amode, name, 1, sz, 0, 1, 0, 0}
276 #define INVALID {TERM, UNKNOWN, "", 0, 0, 0, 0, 0}
277 #elif defined(DIS_TEXT)
278 #define IND(table) {(instable_t *)table, 0, "", 0, 0, 0, 0, 0}
279 #define INDx(table) {(instable_t *)table, 0, "", 0, 1, 0, 0, 0}
280 #define TNS(name, amode) {TERM, amode, name, 0, 0, 0, 0, 0}
281 #define TNSu(name, amode) {TERM, amode, name, 0, 0, 0, 1, 0}
282 #define TNSx(name, amode) {TERM, amode, name, 0, 1, 0, 0, 0}
283 #define TNSy(name, amode) {TERM, amode, name, 0, 0, 1, 0, 0}
284 #define TNSyp(name, amode) {TERM, amode, name, 0, 0, 1, 0, 1}
285 #define TNSZ(name, amode, sz) {TERM, amode, name, 0, 0, 0, 0, 0}
286 #define TNSZy(name, amode, sz) {TERM, amode, name, 0, 0, 1, 0, 0}
287 #define TS(name, amode) {TERM, amode, name, 1, 0, 0, 0, 0}
288 #define TSx(name, amode) {TERM, amode, name, 1, 1, 0, 0, 0}
289 #define TSy(name, amode) {TERM, amode, name, 1, 0, 1, 0, 0}
290 #define TSp(name, amode) {TERM, amode, name, 1, 0, 0, 0, 1}
291 #define TSZ(name, amode, sz) {TERM, amode, name, 1, 0, 0, 0, 0}
292 #define TSZx(name, amode, sz) {TERM, amode, name, 1, 1, 0, 0, 0}
293 #define TSZy(name, amode, sz) {TERM, amode, name, 1, 0, 1, 0, 0}
294 #define INVALID {TERM, UNKNOWN, "", 0, 0, 0, 0, 0}
295 #elif defined(DIS_MEM)
296 #define IND(table) {(instable_t *)table, 0, 0, 0, 0, 0, 0}
297 #define INDx(table) {(instable_t *)table, 0, 0, 1, 0, 0, 0}
298 #define TNS(name, amode) {TERM, amode, 0, 0, 0, 0, 0}
299 #define TNSu(name, amode) {TERM, amode, 0, 0, 0, 1, 0}
300 #define TNSy(name, amode) {TERM, amode, 0, 0, 1, 0, 0}
301 #define TNSyp(name, amode) {TERM, amode, 0, 0, 1, 0, 1}
302 #define TNSx(name, amode) {TERM, amode, 0, 1, 0, 0, 0}
303 #define TNSZ(name, amode, sz) {TERM, amode, sz, 0, 0, 0, 0}
304 #define TNSZy(name, amode, sz) {TERM, amode, sz, 0, 1, 0, 0}
305 #define TS(name, amode) {TERM, amode, 0, 0, 0, 0, 0}
306 #define TSx(name, amode) {TERM, amode, 0, 1, 0, 0, 0}
307 #define TSy(name, amode) {TERM, amode, 0, 0, 1, 0, 0}
308 #define TSp(name, amode) {TERM, amode, 0, 0, 0, 0, 1}
309 #define TSZ(name, amode, sz) {TERM, amode, sz, 0, 0, 0, 0}
310 #define TSZx(name, amode, sz) {TERM, amode, sz, 1, 0, 0, 0}
311 #define TSZy(name, amode, sz) {TERM, amode, sz, 0, 1, 0, 0}
312 #define INVALID {TERM, UNKNOWN, 0, 0, 0, 0, 0}
314 #define IND(table) {(instable_t *)table, 0, 0, 0, 0, 0}
315 #define INDx(table) {(instable_t *)table, 0, 1, 0, 0, 0}
316 #define TNS(name, amode) {TERM, amode, 0, 0, 0, 0}
317 #define TNSu(name, amode) {TERM, amode, 0, 0, 1, 0}
318 #define TNSy(name, amode) {TERM, amode, 0, 1, 0, 0}
319 #define TNSyp(name, amode) {TERM, amode, 0, 1, 0, 1}
320 #define TNSx(name, amode) {TERM, amode, 1, 0, 0, 0}
321 #define TNSZ(name, amode, sz) {TERM, amode, 0, 0, 0, 0}
322 #define TNSZy(name, amode, sz) {TERM, amode, 0, 1, 0, 0}
323 #define TS(name, amode) {TERM, amode, 0, 0, 0, 0}
324 #define TSx(name, amode) {TERM, amode, 1, 0, 0, 0}
325 #define TSy(name, amode) {TERM, amode, 0, 1, 0, 0}
326 #define TSp(name, amode) {TERM, amode, 0, 0, 0, 1}
327 #define TSZ(name, amode, sz) {TERM, amode, 0, 0, 0, 0}
328 #define TSZx(name, amode, sz) {TERM, amode, 1, 0, 0, 0}
329 #define TSZy(name, amode, sz) {TERM, amode, 0, 1, 0, 0}
330 #define INVALID {TERM, UNKNOWN, 0, 0, 0, 0}
335 * this decodes the r_m field for mode's 0, 1, 2 in 16 bit mode
337 const char *const dis_addr16
[3][8] = {
338 "(%bx,%si)", "(%bx,%di)", "(%bp,%si)", "(%bp,%di)", "(%si)", "(%di)", "",
340 "(%bx,%si)", "(%bx,%di)", "(%bp,%si)", "(%bp,%di)", "(%si)", "(%di", "(%bp)",
342 "(%bx,%si)", "(%bx,%di)", "(%bp,%si)", "(%bp,%di)", "(%si)", "(%di)", "(%bp)",
348 * This decodes 32 bit addressing mode r_m field for modes 0, 1, 2
350 const char *const dis_addr32_mode0
[16] = {
351 "(%eax)", "(%ecx)", "(%edx)", "(%ebx)", "", "", "(%esi)", "(%edi)",
352 "(%r8d)", "(%r9d)", "(%r10d)", "(%r11d)", "", "", "(%r14d)", "(%r15d)"
355 const char *const dis_addr32_mode12
[16] = {
356 "(%eax)", "(%ecx)", "(%edx)", "(%ebx)", "", "(%ebp)", "(%esi)", "(%edi)",
357 "(%r8d)", "(%r9d)", "(%r10d)", "(%r11d)", "", "(%r13d)", "(%r14d)", "(%r15d)"
361 * This decodes 64 bit addressing mode r_m field for modes 0, 1, 2
363 const char *const dis_addr64_mode0
[16] = {
364 "(%rax)", "(%rcx)", "(%rdx)", "(%rbx)", "", "(%rip)", "(%rsi)", "(%rdi)",
365 "(%r8)", "(%r9)", "(%r10)", "(%r11)", "(%r12)", "(%rip)", "(%r14)", "(%r15)"
367 const char *const dis_addr64_mode12
[16] = {
368 "(%rax)", "(%rcx)", "(%rdx)", "(%rbx)", "", "(%rbp)", "(%rsi)", "(%rdi)",
369 "(%r8)", "(%r9)", "(%r10)", "(%r11)", "(%r12)", "(%r13)", "(%r14)", "(%r15)"
373 * decode for scale from SIB byte
375 const char *const dis_scale_factor
[4] = { ")", ",2)", ",4)", ",8)" };
378 * register decoding for normal references to registers (ie. not addressing)
380 const char *const dis_REG8
[16] = {
381 "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
382 "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"
385 const char *const dis_REG8_REX
[16] = {
386 "%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
387 "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"
390 const char *const dis_REG16
[16] = {
391 "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
392 "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w"
395 const char *const dis_REG32
[16] = {
396 "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
397 "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d"
400 const char *const dis_REG64
[16] = {
401 "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
402 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
405 const char *const dis_DEBUGREG
[16] = {
406 "%db0", "%db1", "%db2", "%db3", "%db4", "%db5", "%db6", "%db7",
407 "%db8", "%db9", "%db10", "%db11", "%db12", "%db13", "%db14", "%db15"
410 const char *const dis_CONTROLREG
[16] = {
411 "%cr0", "%cr1", "%cr2", "%cr3", "%cr4", "%cr5?", "%cr6?", "%cr7?",
412 "%cr8", "%cr9?", "%cr10?", "%cr11?", "%cr12?", "%cr13?", "%cr14?", "%cr15?"
415 const char *const dis_TESTREG
[16] = {
416 "%tr0?", "%tr1?", "%tr2?", "%tr3", "%tr4", "%tr5", "%tr6", "%tr7",
417 "%tr0?", "%tr1?", "%tr2?", "%tr3", "%tr4", "%tr5", "%tr6", "%tr7"
420 const char *const dis_MMREG
[16] = {
421 "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7",
422 "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7"
425 const char *const dis_XMMREG
[16] = {
426 "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7",
427 "%xmm8", "%xmm9", "%xmm10", "%xmm11", "%xmm12", "%xmm13", "%xmm14", "%xmm15"
430 const char *const dis_SEGREG
[16] = {
431 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "<reserved>", "<reserved>",
432 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "<reserved>", "<reserved>"
436 * SIMD predicate suffixes
438 const char *const dis_PREDSUFFIX
[8] = {
439 "eq", "lt", "le", "unord", "neq", "nlt", "nle", "ord"
444 #endif /* DIS_TEXT */
450 * "decode table" for 64 bit mode MOVSXD instruction (opcode 0x63)
452 const instable_t dis_opMOVSLD
= TNS("movslq",MOVSXZ
);
455 * "decode table" for pause and clflush instructions
457 const instable_t dis_opPause
= TNS("pause", NORM
);
460 * Decode table for 0x0F00 opcodes
462 const instable_t dis_op0F00
[8] = {
464 /* [0] */ TNS("sldt",M
), TNS("str",M
), TNSy("lldt",M
), TNSy("ltr",M
),
465 /* [4] */ TNSZ("verr",M
,2), TNSZ("verw",M
,2), INVALID
, INVALID
,
470 * Decode table for 0x0F01 opcodes
472 const instable_t dis_op0F01
[8] = {
474 /* [0] */ TNSZ("sgdt",MO
,6), TNSZ("sidt",MONITOR_MWAIT
,6), TNSZ("lgdt",MO
,6), TNSZ("lidt",MO
,6),
475 /* [4] */ TNSZ("smsw",M
,2), INVALID
, TNSZ("lmsw",M
,2), TNS("invlpg",SWAPGS
),
479 * Decode table for 0x0F18 opcodes -- SIMD prefetch
481 const instable_t dis_op0F18
[8] = {
483 /* [0] */ TNS("prefetchnta",PREF
),TNS("prefetcht0",PREF
), TNS("prefetcht1",PREF
), TNS("prefetcht2",PREF
),
484 /* [4] */ INVALID
, INVALID
, INVALID
, INVALID
,
488 * Decode table for 0x0FAE opcodes -- SIMD state save/restore
490 const instable_t dis_op0FAE
[8] = {
491 /* [0] */ TNSZ("fxsave",M
,512), TNSZ("fxrstor",M
,512), TNS("ldmxcsr",M
), TNS("stmxcsr",M
),
492 /* [4] */ INVALID
, TNS("lfence",XMMFENCE
), TNS("mfence",XMMFENCE
), TNS("sfence",XMMSFNC
),
496 * Decode table for 0x0FBA opcodes
499 const instable_t dis_op0FBA
[8] = {
501 /* [0] */ INVALID
, INVALID
, INVALID
, INVALID
,
502 /* [4] */ TS("bt",MIb
), TS("bts",MIb
), TS("btr",MIb
), TS("btc",MIb
),
506 * Decode table for 0x0FC7 opcode
509 const instable_t dis_op0FC7
[8] = {
511 /* [0] */ INVALID
, TNS("cmpxchg8b",M
), INVALID
, INVALID
,
512 /* [4] */ INVALID
, INVALID
, INVALID
, INVALID
,
517 * Decode table for 0x0FC8 opcode -- 486 bswap instruction
519 *bit pattern: 0000 1111 1100 1reg
521 const instable_t dis_op0FC8
[4] = {
522 /* [0] */ TNS("bswap",R
), INVALID
, INVALID
, INVALID
,
526 * Decode table for 0x0F71, 0x0F72, and 0x0F73 opcodes -- MMX instructions
528 const instable_t dis_op0F7123
[4][8] = {
530 /* [70].0 */ INVALID
, INVALID
, INVALID
, INVALID
,
531 /* .4 */ INVALID
, INVALID
, INVALID
, INVALID
,
533 /* [71].0 */ INVALID
, INVALID
, TNS("psrlw",MMOSH
), INVALID
,
534 /* .4 */ TNS("psraw",MMOSH
), INVALID
, TNS("psllw",MMOSH
), INVALID
,
536 /* [72].0 */ INVALID
, INVALID
, TNS("psrld",MMOSH
), INVALID
,
537 /* .4 */ TNS("psrad",MMOSH
), INVALID
, TNS("pslld",MMOSH
), INVALID
,
539 /* [73].0 */ INVALID
, INVALID
, TNS("psrlq",MMOSH
), TNS("INVALID",MMOSH
),
540 /* .4 */ INVALID
, INVALID
, TNS("psllq",MMOSH
), TNS("INVALID",MMOSH
),
544 * Decode table for SIMD extensions to above 0x0F71-0x0F73 opcodes.
546 const instable_t dis_opSIMD7123
[32] = {
547 /* [70].0 */ INVALID
, INVALID
, INVALID
, INVALID
,
548 /* .4 */ INVALID
, INVALID
, INVALID
, INVALID
,
550 /* [71].0 */ INVALID
, INVALID
, TNS("psrlw",XMMSH
), INVALID
,
551 /* .4 */ TNS("psraw",XMMSH
), INVALID
, TNS("psllw",XMMSH
), INVALID
,
553 /* [72].0 */ INVALID
, INVALID
, TNS("psrld",XMMSH
), INVALID
,
554 /* .4 */ TNS("psrad",XMMSH
), INVALID
, TNS("pslld",XMMSH
), INVALID
,
556 /* [73].0 */ INVALID
, INVALID
, TNS("psrlq",XMMSH
), TNS("psrldq",XMMSH
),
557 /* .4 */ INVALID
, INVALID
, TNS("psllq",XMMSH
), TNS("pslldq",XMMSH
),
561 * SIMD instructions have been wedged into the existing IA32 instruction
562 * set through the use of prefixes. That is, while 0xf0 0x58 may be
563 * addps, 0xf3 0xf0 0x58 (literally, repz addps) is a completely different
564 * instruction - addss. At present, three prefixes have been coopted in
565 * this manner - address size (0x66), repnz (0xf2) and repz (0xf3). The
566 * following tables are used to provide the prefixed instruction names.
567 * The arrays are sparse, but they're fast.
571 * Decode table for SIMD instructions with the address size (0x66) prefix.
573 const instable_t dis_opSIMDdata16
[256] = {
574 /* [00] */ INVALID
, INVALID
, INVALID
, INVALID
,
575 /* [04] */ INVALID
, INVALID
, INVALID
, INVALID
,
576 /* [08] */ INVALID
, INVALID
, INVALID
, INVALID
,
577 /* [0C] */ INVALID
, INVALID
, INVALID
, INVALID
,
579 /* [10] */ TNSZ("movupd",XMM
,16), TNSZ("movupd",XMMS
,16), TNSZ("movlpd",XMMM
,8), TNSZ("movlpd",XMMMS
,8),
580 /* [14] */ TNSZ("unpcklpd",XMM
,16),TNSZ("unpckhpd",XMM
,16),TNSZ("movhpd",XMMM
,8), TNSZ("movhpd",XMMMS
,8),
581 /* [18] */ INVALID
, INVALID
, INVALID
, INVALID
,
582 /* [1C] */ INVALID
, INVALID
, INVALID
, INVALID
,
584 /* [20] */ INVALID
, INVALID
, INVALID
, INVALID
,
585 /* [24] */ INVALID
, INVALID
, INVALID
, INVALID
,
586 /* [28] */ TNSZ("movapd",XMM
,16), TNSZ("movapd",XMMS
,16), TNSZ("cvtpi2pd",XMMOMX
,8),TNSZ("movntpd",XMMOMS
,16),
587 /* [2C] */ TNSZ("cvttpd2pi",XMMXMM
,16),TNSZ("cvtpd2pi",XMMXMM
,16),TNSZ("ucomisd",XMM
,8),TNSZ("comisd",XMM
,8),
589 /* [30] */ INVALID
, INVALID
, INVALID
, INVALID
,
590 /* [34] */ INVALID
, INVALID
, INVALID
, INVALID
,
591 /* [38] */ INVALID
, INVALID
, INVALID
, INVALID
,
592 /* [3C] */ INVALID
, INVALID
, INVALID
, INVALID
,
594 /* [40] */ INVALID
, INVALID
, INVALID
, INVALID
,
595 /* [44] */ INVALID
, INVALID
, INVALID
, INVALID
,
596 /* [48] */ INVALID
, INVALID
, INVALID
, INVALID
,
597 /* [4C] */ INVALID
, INVALID
, INVALID
, INVALID
,
599 /* [50] */ TNS("movmskpd",XMMOX3
), TNSZ("sqrtpd",XMM
,16), INVALID
, INVALID
,
600 /* [54] */ TNSZ("andpd",XMM
,16), TNSZ("andnpd",XMM
,16), TNSZ("orpd",XMM
,16), TNSZ("xorpd",XMM
,16),
601 /* [58] */ TNSZ("addpd",XMM
,16), TNSZ("mulpd",XMM
,16), TNSZ("cvtpd2ps",XMM
,16),TNSZ("cvtps2dq",XMM
,16),
602 /* [5C] */ TNSZ("subpd",XMM
,16), TNSZ("minpd",XMM
,16), TNSZ("divpd",XMM
,16), TNSZ("maxpd",XMM
,16),
604 /* [60] */ TNSZ("punpcklbw",XMM
,16),TNSZ("punpcklwd",XMM
,16),TNSZ("punpckldq",XMM
,16),TNSZ("packsswb",XMM
,16),
605 /* [64] */ TNSZ("pcmpgtb",XMM
,16), TNSZ("pcmpgtw",XMM
,16), TNSZ("pcmpgtd",XMM
,16), TNSZ("packuswb",XMM
,16),
606 /* [68] */ TNSZ("punpckhbw",XMM
,16),TNSZ("punpckhwd",XMM
,16),TNSZ("punpckhdq",XMM
,16),TNSZ("packssdw",XMM
,16),
607 /* [6C] */ TNSZ("punpcklqdq",XMM
,16),TNSZ("punpckhqdq",XMM
,16),TNSZ("movd",XMM3MX
,4),TNSZ("movdqa",XMM
,16),
609 /* [70] */ TNSZ("pshufd",XMMP
,16), INVALID
, INVALID
, INVALID
,
610 /* [74] */ TNSZ("pcmpeqb",XMM
,16), TNSZ("pcmpeqw",XMM
,16), TNSZ("pcmpeqd",XMM
,16), INVALID
,
611 /* [78] */ TNSZ("extrq",XMM2I
,16), TNSZ("extrq",XMM
,16), INVALID
, INVALID
,
612 /* [7C] */ INVALID
, INVALID
, TNSZ("movd",XMM3MXS
,4), TNSZ("movdqa",XMMS
,16),
614 /* [80] */ INVALID
, INVALID
, INVALID
, INVALID
,
615 /* [84] */ INVALID
, INVALID
, INVALID
, INVALID
,
616 /* [88] */ INVALID
, INVALID
, INVALID
, INVALID
,
617 /* [8C] */ INVALID
, INVALID
, INVALID
, INVALID
,
619 /* [90] */ INVALID
, INVALID
, INVALID
, INVALID
,
620 /* [94] */ INVALID
, INVALID
, INVALID
, INVALID
,
621 /* [98] */ INVALID
, INVALID
, INVALID
, INVALID
,
622 /* [9C] */ INVALID
, INVALID
, INVALID
, INVALID
,
624 /* [A0] */ INVALID
, INVALID
, INVALID
, INVALID
,
625 /* [A4] */ INVALID
, INVALID
, INVALID
, INVALID
,
626 /* [A8] */ INVALID
, INVALID
, INVALID
, INVALID
,
627 /* [AC] */ INVALID
, INVALID
, INVALID
, INVALID
,
629 /* [B0] */ INVALID
, INVALID
, INVALID
, INVALID
,
630 /* [B4] */ INVALID
, INVALID
, INVALID
, INVALID
,
631 /* [B8] */ INVALID
, INVALID
, INVALID
, INVALID
,
632 /* [BC] */ INVALID
, INVALID
, INVALID
, INVALID
,
634 /* [C0] */ INVALID
, INVALID
, TNSZ("cmppd",XMMP
,16), INVALID
,
635 /* [C4] */ TNSZ("pinsrw",XMMPRM
,2),TNS("pextrw",XMM3P
), TNSZ("shufpd",XMMP
,16), INVALID
,
636 /* [C8] */ INVALID
, INVALID
, INVALID
, INVALID
,
637 /* [CC] */ INVALID
, INVALID
, INVALID
, INVALID
,
639 /* [D0] */ INVALID
, TNSZ("psrlw",XMM
,16), TNSZ("psrld",XMM
,16), TNSZ("psrlq",XMM
,16),
640 /* [D4] */ TNSZ("paddq",XMM
,16), TNSZ("pmullw",XMM
,16), TNSZ("movq",XMMS
,8), TNS("pmovmskb",XMMX3
),
641 /* [D8] */ TNSZ("psubusb",XMM
,16), TNSZ("psubusw",XMM
,16), TNSZ("pminub",XMM
,16), TNSZ("pand",XMM
,16),
642 /* [DC] */ TNSZ("paddusb",XMM
,16), TNSZ("paddusw",XMM
,16), TNSZ("pmaxub",XMM
,16), TNSZ("pandn",XMM
,16),
644 /* [E0] */ TNSZ("pavgb",XMM
,16), TNSZ("psraw",XMM
,16), TNSZ("psrad",XMM
,16), TNSZ("pavgw",XMM
,16),
645 /* [E4] */ TNSZ("pmulhuw",XMM
,16), TNSZ("pmulhw",XMM
,16), TNSZ("cvttpd2dq",XMM
,16),TNSZ("movntdq",XMMS
,16),
646 /* [E8] */ TNSZ("psubsb",XMM
,16), TNSZ("psubsw",XMM
,16), TNSZ("pminsw",XMM
,16), TNSZ("por",XMM
,16),
647 /* [EC] */ TNSZ("paddsb",XMM
,16), TNSZ("paddsw",XMM
,16), TNSZ("pmaxsw",XMM
,16), TNSZ("pxor",XMM
,16),
649 /* [F0] */ INVALID
, TNSZ("psllw",XMM
,16), TNSZ("pslld",XMM
,16), TNSZ("psllq",XMM
,16),
650 /* [F4] */ TNSZ("pmuludq",XMM
,16), TNSZ("pmaddwd",XMM
,16), TNSZ("psadbw",XMM
,16), TNSZ("maskmovdqu", XMMXIMPL
,16),
651 /* [F8] */ TNSZ("psubb",XMM
,16), TNSZ("psubw",XMM
,16), TNSZ("psubd",XMM
,16), TNSZ("psubq",XMM
,16),
652 /* [FC] */ TNSZ("paddb",XMM
,16), TNSZ("paddw",XMM
,16), TNSZ("paddd",XMM
,16), INVALID
,
656 * Decode table for SIMD instructions with the repnz (0xf2) prefix.
658 const instable_t dis_opSIMDrepnz
[256] = {
659 /* [00] */ INVALID
, INVALID
, INVALID
, INVALID
,
660 /* [04] */ INVALID
, INVALID
, INVALID
, INVALID
,
661 /* [08] */ INVALID
, INVALID
, INVALID
, INVALID
,
662 /* [0C] */ INVALID
, INVALID
, INVALID
, INVALID
,
664 /* [10] */ TNSZ("movsd",XMM
,8), TNSZ("movsd",XMMS
,8), INVALID
, INVALID
,
665 /* [14] */ INVALID
, INVALID
, INVALID
, INVALID
,
666 /* [18] */ INVALID
, INVALID
, INVALID
, INVALID
,
667 /* [1C] */ INVALID
, INVALID
, INVALID
, INVALID
,
669 /* [20] */ INVALID
, INVALID
, INVALID
, INVALID
,
670 /* [24] */ INVALID
, INVALID
, INVALID
, INVALID
,
671 /* [28] */ INVALID
, INVALID
, TNSZ("cvtsi2sd",XMM3MX
,4),TNSZ("movntsd",XMMMS
,8),
672 /* [2C] */ TNSZ("cvttsd2si",XMMXM3
,8),TNSZ("cvtsd2si",XMMXM3
,8),INVALID
, INVALID
,
674 /* [30] */ INVALID
, INVALID
, INVALID
, INVALID
,
675 /* [34] */ INVALID
, INVALID
, INVALID
, INVALID
,
676 /* [38] */ INVALID
, INVALID
, INVALID
, INVALID
,
677 /* [3C] */ INVALID
, INVALID
, INVALID
, INVALID
,
679 /* [40] */ INVALID
, INVALID
, INVALID
, INVALID
,
680 /* [44] */ INVALID
, INVALID
, INVALID
, INVALID
,
681 /* [48] */ INVALID
, INVALID
, INVALID
, INVALID
,
682 /* [4C] */ INVALID
, INVALID
, INVALID
, INVALID
,
684 /* [50] */ INVALID
, TNSZ("sqrtsd",XMM
,8), INVALID
, INVALID
,
685 /* [54] */ INVALID
, INVALID
, INVALID
, INVALID
,
686 /* [58] */ TNSZ("addsd",XMM
,8), TNSZ("mulsd",XMM
,8), TNSZ("cvtsd2ss",XMM
,8), INVALID
,
687 /* [5C] */ TNSZ("subsd",XMM
,8), TNSZ("minsd",XMM
,8), TNSZ("divsd",XMM
,8), TNSZ("maxsd",XMM
,8),
689 /* [60] */ INVALID
, INVALID
, INVALID
, INVALID
,
690 /* [64] */ INVALID
, INVALID
, INVALID
, INVALID
,
691 /* [68] */ INVALID
, INVALID
, INVALID
, INVALID
,
692 /* [6C] */ INVALID
, INVALID
, INVALID
, INVALID
,
694 /* [70] */ TNSZ("pshuflw",XMMP
,16),INVALID
, INVALID
, INVALID
,
695 /* [74] */ INVALID
, INVALID
, INVALID
, INVALID
,
696 /* [78] */ TNSZ("insertq",XMMX2I
,16),TNSZ("insertq",XMM
,8),INVALID
, INVALID
,
697 /* [7C] */ INVALID
, INVALID
, INVALID
, INVALID
,
699 /* [80] */ INVALID
, INVALID
, INVALID
, INVALID
,
700 /* [84] */ INVALID
, INVALID
, INVALID
, INVALID
,
701 /* [88] */ INVALID
, INVALID
, INVALID
, INVALID
,
702 /* [0C] */ INVALID
, INVALID
, INVALID
, INVALID
,
704 /* [90] */ INVALID
, INVALID
, INVALID
, INVALID
,
705 /* [94] */ INVALID
, INVALID
, INVALID
, INVALID
,
706 /* [98] */ INVALID
, INVALID
, INVALID
, INVALID
,
707 /* [9C] */ INVALID
, INVALID
, INVALID
, INVALID
,
709 /* [A0] */ INVALID
, INVALID
, INVALID
, INVALID
,
710 /* [A4] */ INVALID
, INVALID
, INVALID
, INVALID
,
711 /* [A8] */ INVALID
, INVALID
, INVALID
, INVALID
,
712 /* [AC] */ INVALID
, INVALID
, INVALID
, INVALID
,
714 /* [B0] */ INVALID
, INVALID
, INVALID
, INVALID
,
715 /* [B4] */ INVALID
, INVALID
, INVALID
, INVALID
,
716 /* [B8] */ INVALID
, INVALID
, INVALID
, INVALID
,
717 /* [BC] */ INVALID
, INVALID
, INVALID
, INVALID
,
719 /* [C0] */ INVALID
, INVALID
, TNSZ("cmpsd",XMMP
,8), INVALID
,
720 /* [C4] */ INVALID
, INVALID
, INVALID
, INVALID
,
721 /* [C8] */ INVALID
, INVALID
, INVALID
, INVALID
,
722 /* [CC] */ INVALID
, INVALID
, INVALID
, INVALID
,
724 /* [D0] */ INVALID
, INVALID
, INVALID
, INVALID
,
725 /* [D4] */ INVALID
, INVALID
, TNS("movdq2q",XMMXM
), INVALID
,
726 /* [D8] */ INVALID
, INVALID
, INVALID
, INVALID
,
727 /* [DC] */ INVALID
, INVALID
, INVALID
, INVALID
,
729 /* [E0] */ INVALID
, INVALID
, INVALID
, INVALID
,
730 /* [E4] */ INVALID
, INVALID
, TNSZ("cvtpd2dq",XMM
,16),INVALID
,
731 /* [E8] */ INVALID
, INVALID
, INVALID
, INVALID
,
732 /* [EC] */ INVALID
, INVALID
, INVALID
, INVALID
,
734 /* [F0] */ INVALID
, INVALID
, INVALID
, INVALID
,
735 /* [F4] */ INVALID
, INVALID
, INVALID
, INVALID
,
736 /* [F8] */ INVALID
, INVALID
, INVALID
, INVALID
,
737 /* [FC] */ INVALID
, INVALID
, INVALID
, INVALID
,
741 * Decode table for SIMD instructions with the repz (0xf3) prefix.
743 const instable_t dis_opSIMDrepz
[256] = {
744 /* [00] */ INVALID
, INVALID
, INVALID
, INVALID
,
745 /* [04] */ INVALID
, INVALID
, INVALID
, INVALID
,
746 /* [08] */ INVALID
, INVALID
, INVALID
, INVALID
,
747 /* [0C] */ INVALID
, INVALID
, INVALID
, INVALID
,
749 /* [10] */ TNSZ("movss",XMM
,4), TNSZ("movss",XMMS
,4), INVALID
, INVALID
,
750 /* [14] */ INVALID
, INVALID
, INVALID
, INVALID
,
751 /* [18] */ INVALID
, INVALID
, INVALID
, INVALID
,
752 /* [1C] */ INVALID
, INVALID
, INVALID
, INVALID
,
754 /* [20] */ INVALID
, INVALID
, INVALID
, INVALID
,
755 /* [24] */ INVALID
, INVALID
, INVALID
, INVALID
,
756 /* [28] */ INVALID
, INVALID
, TNSZ("cvtsi2ss",XMM3MX
,4),TNSZ("movntss",XMMMS
,4),
757 /* [2C] */ TNSZ("cvttss2si",XMMXM3
,4),TNSZ("cvtss2si",XMMXM3
,4),INVALID
, INVALID
,
759 /* [30] */ INVALID
, INVALID
, INVALID
, INVALID
,
760 /* [34] */ INVALID
, INVALID
, INVALID
, INVALID
,
761 /* [38] */ INVALID
, INVALID
, INVALID
, INVALID
,
762 /* [3C] */ INVALID
, INVALID
, INVALID
, INVALID
,
764 /* [40] */ INVALID
, INVALID
, INVALID
, INVALID
,
765 /* [44] */ INVALID
, INVALID
, INVALID
, INVALID
,
766 /* [48] */ INVALID
, INVALID
, INVALID
, INVALID
,
767 /* [4C] */ INVALID
, INVALID
, INVALID
, INVALID
,
769 /* [50] */ INVALID
, TNSZ("sqrtss",XMM
,4), TNSZ("rsqrtss",XMM
,4), TNSZ("rcpss",XMM
,4),
770 /* [54] */ INVALID
, INVALID
, INVALID
, INVALID
,
771 /* [58] */ TNSZ("addss",XMM
,4), TNSZ("mulss",XMM
,4), TNSZ("cvtss2sd",XMM
,4), TNSZ("cvttps2dq",XMM
,16),
772 /* [5C] */ TNSZ("subss",XMM
,4), TNSZ("minss",XMM
,4), TNSZ("divss",XMM
,4), TNSZ("maxss",XMM
,4),
774 /* [60] */ INVALID
, INVALID
, INVALID
, INVALID
,
775 /* [64] */ INVALID
, INVALID
, INVALID
, INVALID
,
776 /* [68] */ INVALID
, INVALID
, INVALID
, INVALID
,
777 /* [6C] */ INVALID
, INVALID
, INVALID
, TNSZ("movdqu",XMM
,16),
779 /* [70] */ TNSZ("pshufhw",XMMP
,16),INVALID
, INVALID
, INVALID
,
780 /* [74] */ INVALID
, INVALID
, INVALID
, INVALID
,
781 /* [78] */ INVALID
, INVALID
, INVALID
, INVALID
,
782 /* [7C] */ INVALID
, INVALID
, TNSZ("movq",XMM
,8), TNSZ("movdqu",XMMS
,16),
784 /* [80] */ INVALID
, INVALID
, INVALID
, INVALID
,
785 /* [84] */ INVALID
, INVALID
, INVALID
, INVALID
,
786 /* [88] */ INVALID
, INVALID
, INVALID
, INVALID
,
787 /* [0C] */ INVALID
, INVALID
, INVALID
, INVALID
,
789 /* [90] */ INVALID
, INVALID
, INVALID
, INVALID
,
790 /* [94] */ INVALID
, INVALID
, INVALID
, INVALID
,
791 /* [98] */ INVALID
, INVALID
, INVALID
, INVALID
,
792 /* [9C] */ INVALID
, INVALID
, INVALID
, INVALID
,
794 /* [A0] */ INVALID
, INVALID
, INVALID
, INVALID
,
795 /* [A4] */ INVALID
, INVALID
, INVALID
, INVALID
,
796 /* [A8] */ INVALID
, INVALID
, INVALID
, INVALID
,
797 /* [AC] */ INVALID
, INVALID
, INVALID
, INVALID
,
799 /* [B0] */ INVALID
, INVALID
, INVALID
, INVALID
,
800 /* [B4] */ INVALID
, INVALID
, INVALID
, INVALID
,
801 /* [B8] */ TS("popcnt",MRw
), INVALID
, INVALID
, INVALID
,
802 /* [BC] */ INVALID
, TS("lzcnt",MRw
), INVALID
, INVALID
,
804 /* [C0] */ INVALID
, INVALID
, TNSZ("cmpss",XMMP
,4), INVALID
,
805 /* [C4] */ INVALID
, INVALID
, INVALID
, INVALID
,
806 /* [C8] */ INVALID
, INVALID
, INVALID
, INVALID
,
807 /* [CC] */ INVALID
, INVALID
, INVALID
, INVALID
,
809 /* [D0] */ INVALID
, INVALID
, INVALID
, INVALID
,
810 /* [D4] */ INVALID
, INVALID
, TNS("movq2dq",XMMMX
), INVALID
,
811 /* [D8] */ INVALID
, INVALID
, INVALID
, INVALID
,
812 /* [DC] */ INVALID
, INVALID
, INVALID
, INVALID
,
814 /* [E0] */ INVALID
, INVALID
, INVALID
, INVALID
,
815 /* [E4] */ INVALID
, INVALID
, TNSZ("cvtdq2pd",XMM
,8), INVALID
,
816 /* [E8] */ INVALID
, INVALID
, INVALID
, INVALID
,
817 /* [EC] */ INVALID
, INVALID
, INVALID
, INVALID
,
819 /* [F0] */ INVALID
, INVALID
, INVALID
, INVALID
,
820 /* [F4] */ INVALID
, INVALID
, INVALID
, INVALID
,
821 /* [F8] */ INVALID
, INVALID
, INVALID
, INVALID
,
822 /* [FC] */ INVALID
, INVALID
, INVALID
, INVALID
,
825 const instable_t dis_op0F38
[256] = {
826 /* [00] */ TNSZ("pshufb",XMM_66o
,16),TNSZ("phaddw",XMM_66o
,16),TNSZ("phaddd",XMM_66o
,16),TNSZ("phaddsw",XMM_66o
,16),
827 /* [04] */ TNSZ("pmaddubsw",XMM_66o
,16),TNSZ("phsubw",XMM_66o
,16), TNSZ("phsubd",XMM_66o
,16),TNSZ("phsubsw",XMM_66o
,16),
828 /* [08] */ TNSZ("psignb",XMM_66o
,16),TNSZ("psignw",XMM_66o
,16),TNSZ("psignd",XMM_66o
,16),TNSZ("pmulhrsw",XMM_66o
,16),
829 /* [0C] */ INVALID
, INVALID
, INVALID
, INVALID
,
831 /* [10] */ TNSZ("pblendvb",XMM_66r
,16),INVALID
, INVALID
, INVALID
,
832 /* [14] */ TNSZ("blendvps",XMM_66r
,16),TNSZ("blendvpd",XMM_66r
,16),INVALID
, TNSZ("ptest",XMM_66r
,16),
833 /* [18] */ INVALID
, INVALID
, INVALID
, INVALID
,
834 /* [1C] */ TNSZ("pabsb",XMM_66o
,16),TNSZ("pabsw",XMM_66o
,16),TNSZ("pabsd",XMM_66o
,16),INVALID
,
836 /* [20] */ TNSZ("pmovsxbw",XMM_66r
,16),TNSZ("pmovsxbd",XMM_66r
,16),TNSZ("pmovsxbq",XMM_66r
,16),TNSZ("pmovsxwd",XMM_66r
,16),
837 /* [24] */ TNSZ("pmovsxwq",XMM_66r
,16),TNSZ("pmovsxdq",XMM_66r
,16),INVALID
, INVALID
,
838 /* [28] */ TNSZ("pmuldq",XMM_66r
,16),TNSZ("pcmpeqq",XMM_66r
,16),TNSZ("movntdqa",XMMM_66r
,16),TNSZ("packusdw",XMM_66r
,16),
839 /* [2C] */ INVALID
, INVALID
, INVALID
, INVALID
,
841 /* [30] */ TNSZ("pmovzxbw",XMM_66r
,16),TNSZ("pmovzxbd",XMM_66r
,16),TNSZ("pmovzxbq",XMM_66r
,16),TNSZ("pmovzxwd",XMM_66r
,16),
842 /* [34] */ TNSZ("pmovzxwq",XMM_66r
,16),TNSZ("pmovzxdq",XMM_66r
,16),INVALID
, TNSZ("pcmpgtq",XMM_66r
,16),
843 /* [38] */ TNSZ("pminsb",XMM_66r
,16),TNSZ("pminsd",XMM_66r
,16),TNSZ("pminuw",XMM_66r
,16),TNSZ("pminud",XMM_66r
,16),
844 /* [3C] */ TNSZ("pmaxsb",XMM_66r
,16),TNSZ("pmaxsd",XMM_66r
,16),TNSZ("pmaxuw",XMM_66r
,16),TNSZ("pmaxud",XMM_66r
,16),
846 /* [40] */ TNSZ("pmulld",XMM_66r
,16),TNSZ("phminposuw",XMM_66r
,16),INVALID
, INVALID
,
847 /* [44] */ INVALID
, INVALID
, INVALID
, INVALID
,
848 /* [48] */ INVALID
, INVALID
, INVALID
, INVALID
,
849 /* [4C] */ INVALID
, INVALID
, INVALID
, INVALID
,
851 /* [50] */ INVALID
, INVALID
, INVALID
, INVALID
,
852 /* [54] */ INVALID
, INVALID
, INVALID
, INVALID
,
853 /* [58] */ INVALID
, INVALID
, INVALID
, INVALID
,
854 /* [5C] */ INVALID
, INVALID
, INVALID
, INVALID
,
856 /* [60] */ INVALID
, INVALID
, INVALID
, INVALID
,
857 /* [64] */ INVALID
, INVALID
, INVALID
, INVALID
,
858 /* [68] */ INVALID
, INVALID
, INVALID
, INVALID
,
859 /* [6C] */ INVALID
, INVALID
, INVALID
, INVALID
,
861 /* [70] */ INVALID
, INVALID
, INVALID
, INVALID
,
862 /* [74] */ INVALID
, INVALID
, INVALID
, INVALID
,
863 /* [78] */ INVALID
, INVALID
, INVALID
, INVALID
,
864 /* [7C] */ INVALID
, INVALID
, INVALID
, INVALID
,
866 /* [80] */ INVALID
, INVALID
, INVALID
, INVALID
,
867 /* [84] */ INVALID
, INVALID
, INVALID
, INVALID
,
868 /* [88] */ INVALID
, INVALID
, INVALID
, INVALID
,
869 /* [8C] */ INVALID
, INVALID
, INVALID
, INVALID
,
871 /* [90] */ INVALID
, INVALID
, INVALID
, INVALID
,
872 /* [94] */ INVALID
, INVALID
, INVALID
, INVALID
,
873 /* [98] */ INVALID
, INVALID
, INVALID
, INVALID
,
874 /* [9C] */ INVALID
, INVALID
, INVALID
, INVALID
,
876 /* [A0] */ INVALID
, INVALID
, INVALID
, INVALID
,
877 /* [A4] */ INVALID
, INVALID
, INVALID
, INVALID
,
878 /* [A8] */ INVALID
, INVALID
, INVALID
, INVALID
,
879 /* [AC] */ INVALID
, INVALID
, INVALID
, INVALID
,
881 /* [B0] */ INVALID
, INVALID
, INVALID
, INVALID
,
882 /* [B4] */ INVALID
, INVALID
, INVALID
, INVALID
,
883 /* [B8] */ INVALID
, INVALID
, INVALID
, INVALID
,
884 /* [BC] */ INVALID
, INVALID
, INVALID
, INVALID
,
886 /* [C0] */ INVALID
, INVALID
, INVALID
, INVALID
,
887 /* [C4] */ INVALID
, INVALID
, INVALID
, INVALID
,
888 /* [C8] */ INVALID
, INVALID
, INVALID
, INVALID
,
889 /* [CC] */ INVALID
, INVALID
, INVALID
, INVALID
,
891 /* [D0] */ INVALID
, INVALID
, INVALID
, INVALID
,
892 /* [D4] */ INVALID
, INVALID
, INVALID
, INVALID
,
893 /* [D8] */ INVALID
, INVALID
, INVALID
, INVALID
,
894 /* [DC] */ INVALID
, INVALID
, INVALID
, INVALID
,
896 /* [E0] */ INVALID
, INVALID
, INVALID
, INVALID
,
897 /* [E4] */ INVALID
, INVALID
, INVALID
, INVALID
,
898 /* [E8] */ INVALID
, INVALID
, INVALID
, INVALID
,
899 /* [EC] */ INVALID
, INVALID
, INVALID
, INVALID
,
901 /* [F0] */ TNS("crc32b",CRC32
), TS("crc32",CRC32
), INVALID
, INVALID
,
902 /* [F4] */ INVALID
, INVALID
, INVALID
, INVALID
,
903 /* [F8] */ INVALID
, INVALID
, INVALID
, INVALID
,
904 /* [FC] */ INVALID
, INVALID
, INVALID
, INVALID
,
907 const instable_t dis_op0F3A
[256] = {
908 /* [00] */ INVALID
, INVALID
, INVALID
, INVALID
,
909 /* [04] */ INVALID
, INVALID
, INVALID
, INVALID
,
910 /* [08] */ TNSZ("roundps",XMMP_66r
,16),TNSZ("roundpd",XMMP_66r
,16),TNSZ("roundss",XMMP_66r
,16),TNSZ("roundsd",XMMP_66r
,16),
911 /* [0C] */ TNSZ("blendps",XMMP_66r
,16),TNSZ("blendpd",XMMP_66r
,16),TNSZ("pblendw",XMMP_66r
,16),TNSZ("palignr",XMMP_66o
,16),
913 /* [10] */ INVALID
, INVALID
, INVALID
, INVALID
,
914 /* [14] */ TNSZ("pextrb",XMM3PM_66r
,8),TNSZ("pextrw",XMM3PM_66r
,16),TSZ("pextr",XMM3PM_66r
,16),TNSZ("extractps",XMM3PM_66r
,16),
915 /* [18] */ INVALID
, INVALID
, INVALID
, INVALID
,
916 /* [1C] */ INVALID
, INVALID
, INVALID
, INVALID
,
918 /* [20] */ TNSZ("pinsrb",XMMPRM_66r
,8),TNSZ("insertps",XMMP_66r
,16),TSZ("pinsr",XMMPRM_66r
,16),INVALID
,
919 /* [24] */ INVALID
, INVALID
, INVALID
, INVALID
,
920 /* [28] */ INVALID
, INVALID
, INVALID
, INVALID
,
921 /* [2C] */ INVALID
, INVALID
, INVALID
, INVALID
,
923 /* [30] */ INVALID
, INVALID
, INVALID
, INVALID
,
924 /* [34] */ INVALID
, INVALID
, INVALID
, INVALID
,
925 /* [38] */ INVALID
, INVALID
, INVALID
, INVALID
,
926 /* [3C] */ INVALID
, INVALID
, INVALID
, INVALID
,
928 /* [40] */ TNSZ("dpps",XMMP_66r
,16),TNSZ("dppd",XMMP_66r
,16),TNSZ("mpsadbw",XMMP_66r
,16),INVALID
,
929 /* [44] */ INVALID
, INVALID
, INVALID
, INVALID
,
930 /* [48] */ INVALID
, INVALID
, INVALID
, INVALID
,
931 /* [4C] */ INVALID
, INVALID
, INVALID
, INVALID
,
933 /* [50] */ INVALID
, INVALID
, INVALID
, INVALID
,
934 /* [54] */ INVALID
, INVALID
, INVALID
, INVALID
,
935 /* [58] */ INVALID
, INVALID
, INVALID
, INVALID
,
936 /* [5C] */ INVALID
, INVALID
, INVALID
, INVALID
,
938 /* [60] */ TNSZ("pcmpestrm",XMMP_66r
,16),TNSZ("pcmpestri",XMMP_66r
,16),TNSZ("pcmpistrm",XMMP_66r
,16),TNSZ("pcmpistri",XMMP_66r
,16),
939 /* [64] */ INVALID
, INVALID
, INVALID
, INVALID
,
940 /* [68] */ INVALID
, INVALID
, INVALID
, INVALID
,
941 /* [6C] */ INVALID
, INVALID
, INVALID
, INVALID
,
943 /* [70] */ INVALID
, INVALID
, INVALID
, INVALID
,
944 /* [74] */ INVALID
, INVALID
, INVALID
, INVALID
,
945 /* [78] */ INVALID
, INVALID
, INVALID
, INVALID
,
946 /* [7C] */ INVALID
, INVALID
, INVALID
, INVALID
,
948 /* [80] */ INVALID
, INVALID
, INVALID
, INVALID
,
949 /* [84] */ INVALID
, INVALID
, INVALID
, INVALID
,
950 /* [88] */ INVALID
, INVALID
, INVALID
, INVALID
,
951 /* [8C] */ INVALID
, INVALID
, INVALID
, INVALID
,
953 /* [90] */ INVALID
, INVALID
, INVALID
, INVALID
,
954 /* [94] */ INVALID
, INVALID
, INVALID
, INVALID
,
955 /* [98] */ INVALID
, INVALID
, INVALID
, INVALID
,
956 /* [9C] */ INVALID
, INVALID
, INVALID
, INVALID
,
958 /* [A0] */ INVALID
, INVALID
, INVALID
, INVALID
,
959 /* [A4] */ INVALID
, INVALID
, INVALID
, INVALID
,
960 /* [A8] */ INVALID
, INVALID
, INVALID
, INVALID
,
961 /* [AC] */ INVALID
, INVALID
, INVALID
, INVALID
,
963 /* [B0] */ INVALID
, INVALID
, INVALID
, INVALID
,
964 /* [B4] */ INVALID
, INVALID
, INVALID
, INVALID
,
965 /* [B8] */ INVALID
, INVALID
, INVALID
, INVALID
,
966 /* [BC] */ INVALID
, INVALID
, INVALID
, INVALID
,
968 /* [C0] */ INVALID
, INVALID
, INVALID
, INVALID
,
969 /* [C4] */ INVALID
, INVALID
, INVALID
, INVALID
,
970 /* [C8] */ INVALID
, INVALID
, INVALID
, INVALID
,
971 /* [CC] */ INVALID
, INVALID
, INVALID
, INVALID
,
973 /* [D0] */ INVALID
, INVALID
, INVALID
, INVALID
,
974 /* [D4] */ INVALID
, INVALID
, INVALID
, INVALID
,
975 /* [D8] */ INVALID
, INVALID
, INVALID
, INVALID
,
976 /* [DC] */ INVALID
, INVALID
, INVALID
, INVALID
,
978 /* [E0] */ INVALID
, INVALID
, INVALID
, INVALID
,
979 /* [E4] */ INVALID
, INVALID
, INVALID
, INVALID
,
980 /* [E8] */ INVALID
, INVALID
, INVALID
, INVALID
,
981 /* [EC] */ INVALID
, INVALID
, INVALID
, INVALID
,
983 /* [F0] */ INVALID
, INVALID
, INVALID
, INVALID
,
984 /* [F4] */ INVALID
, INVALID
, INVALID
, INVALID
,
985 /* [F8] */ INVALID
, INVALID
, INVALID
, INVALID
,
986 /* [FC] */ INVALID
, INVALID
, INVALID
, INVALID
,
990 * Decode table for 0x0F opcodes
993 const instable_t dis_op0F
[16][16] = {
995 /* [00] */ IND(dis_op0F00
), IND(dis_op0F01
), TNS("lar",MR
), TNS("lsl",MR
),
996 /* [04] */ INVALID
, TNS("syscall",NORM
), TNS("clts",NORM
), TNS("sysret",NORM
),
997 /* [08] */ TNS("invd",NORM
), TNS("wbinvd",NORM
), INVALID
, TNS("ud2",NORM
),
998 /* [0C] */ INVALID
, INVALID
, INVALID
, INVALID
,
1000 /* [10] */ TNSZ("movups",XMMO
,16), TNSZ("movups",XMMOS
,16),TNSZ("movlps",XMMO
,8), TNSZ("movlps",XMMOS
,8),
1001 /* [14] */ TNSZ("unpcklps",XMMO
,16),TNSZ("unpckhps",XMMO
,16),TNSZ("movhps",XMMOM
,8),TNSZ("movhps",XMMOMS
,8),
1002 /* [18] */ IND(dis_op0F18
), INVALID
, INVALID
, INVALID
,
1003 #if !defined(__APPLE__)
1004 /* [1C] */ INVALID
, INVALID
, INVALID
, INVALID
,
1006 /* Need to handle multi-byte NOP */
1007 /* [1C] */ INVALID
, INVALID
, INVALID
, TS("nop",Mw
),
1008 #endif /* __APPLE __ */
1010 /* [20] */ TSy("mov",SREG
), TSy("mov",SREG
), TSy("mov",SREG
), TSy("mov",SREG
),
1011 /* [24] */ TSx("mov",SREG
), INVALID
, TSx("mov",SREG
), INVALID
,
1012 /* [28] */ TNSZ("movaps",XMMO
,16), TNSZ("movaps",XMMOS
,16),TNSZ("cvtpi2ps",XMMOMX
,8),TNSZ("movntps",XMMOS
,16),
1013 /* [2C] */ TNSZ("cvttps2pi",XMMOXMM
,8),TNSZ("cvtps2pi",XMMOXMM
,8),TNSZ("ucomiss",XMMO
,4),TNSZ("comiss",XMMO
,4),
1015 /* [30] */ TNS("wrmsr",NORM
), TNS("rdtsc",NORM
), TNS("rdmsr",NORM
), TNS("rdpmc",NORM
),
1016 /* [34] */ TNSx("sysenter",NORM
), TNSx("sysexit",NORM
), INVALID
, INVALID
,
1017 /* [38] */ INVALID
, INVALID
, INVALID
, INVALID
,
1018 /* [3C] */ INVALID
, INVALID
, INVALID
, INVALID
,
1020 /* [40] */ TS("cmovx.o",MR
), TS("cmovx.no",MR
), TS("cmovx.b",MR
), TS("cmovx.ae",MR
),
1021 /* [44] */ TS("cmovx.e",MR
), TS("cmovx.ne",MR
), TS("cmovx.be",MR
), TS("cmovx.a",MR
),
1022 /* [48] */ TS("cmovx.s",MR
), TS("cmovx.ns",MR
), TS("cmovx.pe",MR
), TS("cmovx.po",MR
),
1023 /* [4C] */ TS("cmovx.l",MR
), TS("cmovx.ge",MR
), TS("cmovx.le",MR
), TS("cmovx.g",MR
),
1025 /* [50] */ TNS("movmskps",XMMOX3
), TNSZ("sqrtps",XMMO
,16), TNSZ("rsqrtps",XMMO
,16),TNSZ("rcpps",XMMO
,16),
1026 /* [54] */ TNSZ("andps",XMMO
,16), TNSZ("andnps",XMMO
,16), TNSZ("orps",XMMO
,16), TNSZ("xorps",XMMO
,16),
1027 /* [58] */ TNSZ("addps",XMMO
,16), TNSZ("mulps",XMMO
,16), TNSZ("cvtps2pd",XMMO
,8),TNSZ("cvtdq2ps",XMMO
,16),
1028 /* [5C] */ TNSZ("subps",XMMO
,16), TNSZ("minps",XMMO
,16), TNSZ("divps",XMMO
,16), TNSZ("maxps",XMMO
,16),
1030 /* [60] */ TNSZ("punpcklbw",MMO
,4),TNSZ("punpcklwd",MMO
,4),TNSZ("punpckldq",MMO
,4),TNSZ("packsswb",MMO
,8),
1031 /* [64] */ TNSZ("pcmpgtb",MMO
,8), TNSZ("pcmpgtw",MMO
,8), TNSZ("pcmpgtd",MMO
,8), TNSZ("packuswb",MMO
,8),
1032 /* [68] */ TNSZ("punpckhbw",MMO
,8),TNSZ("punpckhwd",MMO
,8),TNSZ("punpckhdq",MMO
,8),TNSZ("packssdw",MMO
,8),
1033 /* [6C] */ TNSZ("INVALID",MMO
,0), TNSZ("INVALID",MMO
,0), TNSZ("movd",MMO
,4), TNSZ("movq",MMO
,8),
1035 /* [70] */ TNSZ("pshufw",MMOPM
,8), TNS("psrXXX",MR
), TNS("psrXXX",MR
), TNS("psrXXX",MR
),
1036 /* [74] */ TNSZ("pcmpeqb",MMO
,8), TNSZ("pcmpeqw",MMO
,8), TNSZ("pcmpeqd",MMO
,8), TNS("emms",NORM
),
1037 /* [78] */ TNS("INVALID",XMMO
), TNS("INVALID",XMMO
), INVALID
, INVALID
,
1038 /* [7C] */ INVALID
, INVALID
, TNSZ("movd",MMOS
,4), TNSZ("movq",MMOS
,8),
1040 /* [80] */ TNS("jo",D
), TNS("jno",D
), TNS("jb",D
), TNS("jae",D
),
1041 /* [84] */ TNS("je",D
), TNS("jne",D
), TNS("jbe",D
), TNS("ja",D
),
1042 /* [88] */ TNS("js",D
), TNS("jns",D
), TNS("jp",D
), TNS("jnp",D
),
1043 /* [8C] */ TNS("jl",D
), TNS("jge",D
), TNS("jle",D
), TNS("jg",D
),
1045 /* [90] */ TNS("seto",Mb
), TNS("setno",Mb
), TNS("setb",Mb
), TNS("setae",Mb
),
1046 /* [94] */ TNS("sete",Mb
), TNS("setne",Mb
), TNS("setbe",Mb
), TNS("seta",Mb
),
1047 /* [98] */ TNS("sets",Mb
), TNS("setns",Mb
), TNS("setp",Mb
), TNS("setnp",Mb
),
1048 /* [9C] */ TNS("setl",Mb
), TNS("setge",Mb
), TNS("setle",Mb
), TNS("setg",Mb
),
1050 /* [A0] */ TSp("push",LSEG
), TSp("pop",LSEG
), TNS("cpuid",NORM
), TS("bt",RMw
),
1051 /* [A4] */ TS("shld",DSHIFT
), TS("shld",DSHIFTcl
), INVALID
, INVALID
,
1052 /* [A8] */ TSp("push",LSEG
), TSp("pop",LSEG
), TNS("rsm",NORM
), TS("bts",RMw
),
1053 /* [AC] */ TS("shrd",DSHIFT
), TS("shrd",DSHIFTcl
), IND(dis_op0FAE
), TS("imul",MRw
),
1055 /* [B0] */ TNS("cmpxchgb",RMw
), TS("cmpxchg",RMw
), TS("lss",MR
), TS("btr",RMw
),
1056 /* [B4] */ TS("lfs",MR
), TS("lgs",MR
), TS("movzb",MOVZ
), TNS("movzwl",MOVZ
),
1057 /* [B8] */ TNS("INVALID",MRw
), INVALID
, IND(dis_op0FBA
), TS("btc",RMw
),
1058 /* [BC] */ TS("bsf",MRw
), TS("bsr",MRw
), TS("movsb",MOVZ
), TNS("movswl",MOVZ
),
1060 /* [C0] */ TNS("xaddb",XADDB
), TS("xadd",RMw
), TNSZ("cmpps",XMMOPM
,16),TNS("movnti",RM
),
1061 /* [C4] */ TNSZ("pinsrw",MMOPRM
,2),TNS("pextrw",MMO3P
), TNSZ("shufps",XMMOPM
,16),IND(dis_op0FC7
),
1062 /* [C8] */ INVALID
, INVALID
, INVALID
, INVALID
,
1063 /* [CC] */ INVALID
, INVALID
, INVALID
, INVALID
,
1065 /* [D0] */ INVALID
, TNSZ("psrlw",MMO
,8), TNSZ("psrld",MMO
,8), TNSZ("psrlq",MMO
,8),
1066 /* [D4] */ TNSZ("paddq",MMO
,8), TNSZ("pmullw",MMO
,8), TNSZ("INVALID",MMO
,0), TNS("pmovmskb",MMOM3
),
1067 /* [D8] */ TNSZ("psubusb",MMO
,8), TNSZ("psubusw",MMO
,8), TNSZ("pminub",MMO
,8), TNSZ("pand",MMO
,8),
1068 /* [DC] */ TNSZ("paddusb",MMO
,8), TNSZ("paddusw",MMO
,8), TNSZ("pmaxub",MMO
,8), TNSZ("pandn",MMO
,8),
1070 /* [E0] */ TNSZ("pavgb",MMO
,8), TNSZ("psraw",MMO
,8), TNSZ("psrad",MMO
,8), TNSZ("pavgw",MMO
,8),
1071 /* [E4] */ TNSZ("pmulhuw",MMO
,8), TNSZ("pmulhw",MMO
,8), TNS("INVALID",XMMO
), TNSZ("movntq",MMOMS
,8),
1072 /* [E8] */ TNSZ("psubsb",MMO
,8), TNSZ("psubsw",MMO
,8), TNSZ("pminsw",MMO
,8), TNSZ("por",MMO
,8),
1073 /* [EC] */ TNSZ("paddsb",MMO
,8), TNSZ("paddsw",MMO
,8), TNSZ("pmaxsw",MMO
,8), TNSZ("pxor",MMO
,8),
1075 /* [F0] */ INVALID
, TNSZ("psllw",MMO
,8), TNSZ("pslld",MMO
,8), TNSZ("psllq",MMO
,8),
1076 /* [F4] */ TNSZ("pmuludq",MMO
,8), TNSZ("pmaddwd",MMO
,8), TNSZ("psadbw",MMO
,8), TNSZ("maskmovq",MMOIMPL
,8),
1077 /* [F8] */ TNSZ("psubb",MMO
,8), TNSZ("psubw",MMO
,8), TNSZ("psubd",MMO
,8), TNSZ("psubq",MMO
,8),
1078 /* [FC] */ TNSZ("paddb",MMO
,8), TNSZ("paddw",MMO
,8), TNSZ("paddd",MMO
,8), INVALID
,
1083 * Decode table for 0x80 opcodes
1086 const instable_t dis_op80
[8] = {
1088 /* [0] */ TNS("addb",IMlw
), TNS("orb",IMw
), TNS("adcb",IMlw
), TNS("sbbb",IMlw
),
1089 /* [4] */ TNS("andb",IMw
), TNS("subb",IMlw
), TNS("xorb",IMw
), TNS("cmpb",IMlw
),
1094 * Decode table for 0x81 opcodes.
1097 const instable_t dis_op81
[8] = {
1099 /* [0] */ TS("add",IMlw
), TS("or",IMw
), TS("adc",IMlw
), TS("sbb",IMlw
),
1100 /* [4] */ TS("and",IMw
), TS("sub",IMlw
), TS("xor",IMw
), TS("cmp",IMlw
),
1105 * Decode table for 0x82 opcodes.
1108 const instable_t dis_op82
[8] = {
1110 /* [0] */ TNSx("addb",IMlw
), TNSx("orb",IMlw
), TNSx("adcb",IMlw
), TNSx("sbbb",IMlw
),
1111 /* [4] */ TNSx("andb",IMlw
), TNSx("subb",IMlw
), TNSx("xorb",IMlw
), TNSx("cmpb",IMlw
),
1114 * Decode table for 0x83 opcodes.
1117 const instable_t dis_op83
[8] = {
1119 /* [0] */ TS("add",IMlw
), TS("or",IMlw
), TS("adc",IMlw
), TS("sbb",IMlw
),
1120 /* [4] */ TS("and",IMlw
), TS("sub",IMlw
), TS("xor",IMlw
), TS("cmp",IMlw
),
1124 * Decode table for 0xC0 opcodes.
1127 const instable_t dis_opC0
[8] = {
1129 /* [0] */ TNS("rolb",MvI
), TNS("rorb",MvI
), TNS("rclb",MvI
), TNS("rcrb",MvI
),
1130 /* [4] */ TNS("shlb",MvI
), TNS("shrb",MvI
), INVALID
, TNS("sarb",MvI
),
1134 * Decode table for 0xD0 opcodes.
1137 const instable_t dis_opD0
[8] = {
1139 /* [0] */ TNS("rolb",Mv
), TNS("rorb",Mv
), TNS("rclb",Mv
), TNS("rcrb",Mv
),
1140 /* [4] */ TNS("shlb",Mv
), TNS("shrb",Mv
), TNS("salb",Mv
), TNS("sarb",Mv
),
1144 * Decode table for 0xC1 opcodes.
1145 * 186 instruction set
1148 const instable_t dis_opC1
[8] = {
1150 /* [0] */ TS("rol",MvI
), TS("ror",MvI
), TS("rcl",MvI
), TS("rcr",MvI
),
1151 /* [4] */ TS("shl",MvI
), TS("shr",MvI
), TS("sal",MvI
), TS("sar",MvI
),
1155 * Decode table for 0xD1 opcodes.
1158 const instable_t dis_opD1
[8] = {
1160 /* [0] */ TS("rol",Mv
), TS("ror",Mv
), TS("rcl",Mv
), TS("rcr",Mv
),
1161 /* [4] */ TS("shl",Mv
), TS("shr",Mv
), TS("sal",Mv
), TS("sar",Mv
),
1166 * Decode table for 0xD2 opcodes.
1169 const instable_t dis_opD2
[8] = {
1171 /* [0] */ TNS("rolb",Mv
), TNS("rorb",Mv
), TNS("rclb",Mv
), TNS("rcrb",Mv
),
1172 /* [4] */ TNS("shlb",Mv
), TNS("shrb",Mv
), TNS("salb",Mv
), TNS("sarb",Mv
),
1175 * Decode table for 0xD3 opcodes.
1178 const instable_t dis_opD3
[8] = {
1180 /* [0] */ TS("rol",Mv
), TS("ror",Mv
), TS("rcl",Mv
), TS("rcr",Mv
),
1181 /* [4] */ TS("shl",Mv
), TS("shr",Mv
), TS("salb",Mv
), TS("sar",Mv
),
1186 * Decode table for 0xF6 opcodes.
1189 const instable_t dis_opF6
[8] = {
1191 /* [0] */ TNS("testb",IMw
), TNS("testb",IMw
), TNS("notb",Mw
), TNS("negb",Mw
),
1192 /* [4] */ TNS("mulb",MA
), TNS("imulb",MA
), TNS("divb",MA
), TNS("idivb",MA
),
1197 * Decode table for 0xF7 opcodes.
1200 const instable_t dis_opF7
[8] = {
1202 /* [0] */ TS("test",IMw
), TS("test",IMw
), TS("not",Mw
), TS("neg",Mw
),
1203 /* [4] */ TS("mul",MA
), TS("imul",MA
), TS("div",MA
), TS("idiv",MA
),
1208 * Decode table for 0xFE opcodes.
1211 const instable_t dis_opFE
[8] = {
1213 /* [0] */ TNS("incb",Mw
), TNS("decb",Mw
), INVALID
, INVALID
,
1214 /* [4] */ INVALID
, INVALID
, INVALID
, INVALID
,
1217 * Decode table for 0xFF opcodes.
1220 const instable_t dis_opFF
[8] = {
1222 /* [0] */ TS("inc",Mw
), TS("dec",Mw
), TNSyp("call",INM
), TNS("lcall",INM
),
1223 /* [4] */ TNSy("jmp",INM
), TNS("ljmp",INM
), TSp("push",M
), INVALID
,
1226 /* for 287 instructions, which are a mess to decode */
1228 const instable_t dis_opFP1n2
[8][8] = {
1230 /* bit pattern: 1101 1xxx MODxx xR/M */
1231 /* [0,0] */ TNS("fadds",M
), TNS("fmuls",M
), TNS("fcoms",M
), TNS("fcomps",M
),
1232 /* [0,4] */ TNS("fsubs",M
), TNS("fsubrs",M
), TNS("fdivs",M
), TNS("fdivrs",M
),
1234 /* [1,0] */ TNS("flds",M
), INVALID
, TNS("fsts",M
), TNS("fstps",M
),
1235 /* [1,4] */ TNSZ("fldenv",M
,28), TNSZ("fldcw",M
,2), TNSZ("fnstenv",M
,28), TNSZ("fnstcw",M
,2),
1237 /* [2,0] */ TNS("fiaddl",M
), TNS("fimull",M
), TNS("ficoml",M
), TNS("ficompl",M
),
1238 /* [2,4] */ TNS("fisubl",M
), TNS("fisubrl",M
), TNS("fidivl",M
), TNS("fidivrl",M
),
1240 /* [3,0] */ TNS("fildl",M
), INVALID
, TNS("fistl",M
), TNS("fistpl",M
),
1241 /* [3,4] */ INVALID
, TNSZ("fldt",M
,10), INVALID
, TNSZ("fstpt",M
,10),
1243 /* [4,0] */ TNSZ("faddl",M
,8), TNSZ("fmull",M
,8), TNSZ("fcoml",M
,8), TNSZ("fcompl",M
,8),
1244 /* [4,1] */ TNSZ("fsubl",M
,8), TNSZ("fsubrl",M
,8), TNSZ("fdivl",M
,8), TNSZ("fdivrl",M
,8),
1246 /* [5,0] */ TNSZ("fldl",M
,8), INVALID
, TNSZ("fstl",M
,8), TNSZ("fstpl",M
,8),
1247 /* [5,4] */ TNSZ("frstor",M
,108), INVALID
, TNSZ("fnsave",M
,108), TNSZ("fnstsw",M
,2),
1249 /* [6,0] */ TNSZ("fiadd",M
,2), TNSZ("fimul",M
,2), TNSZ("ficom",M
,2), TNSZ("ficomp",M
,2),
1250 /* [6,4] */ TNSZ("fisub",M
,2), TNSZ("fisubr",M
,2), TNSZ("fidiv",M
,2), TNSZ("fidivr",M
,2),
1252 /* [7,0] */ TNSZ("fild",M
,2), INVALID
, TNSZ("fist",M
,2), TNSZ("fistp",M
,2),
1253 /* [7,4] */ TNSZ("fbld",M
,10), TNSZ("fildll",M
,8), TNSZ("fbstp",M
,10), TNSZ("fistpll",M
,8),
1256 const instable_t dis_opFP3
[8][8] = {
1258 /* bit pattern: 1101 1xxx 11xx xREG */
1259 /* [0,0] */ TNS("fadd",FF
), TNS("fmul",FF
), TNS("fcom",F
), TNS("fcomp",F
),
1260 /* [0,4] */ TNS("fsub",FF
), TNS("fsubr",FF
), TNS("fdiv",FF
), TNS("fdivr",FF
),
1262 /* [1,0] */ TNS("fld",F
), TNS("fxch",F
), TNS("fnop",NORM
), TNS("fstp",F
),
1263 /* [1,4] */ INVALID
, INVALID
, INVALID
, INVALID
,
1265 /* [2,0] */ INVALID
, INVALID
, INVALID
, INVALID
,
1266 /* [2,4] */ INVALID
, TNS("fucompp",NORM
), INVALID
, INVALID
,
1268 /* [3,0] */ INVALID
, INVALID
, INVALID
, INVALID
,
1269 /* [3,4] */ INVALID
, INVALID
, INVALID
, INVALID
,
1271 /* [4,0] */ TNS("fadd",FF
), TNS("fmul",FF
), TNS("fcom",F
), TNS("fcomp",F
),
1272 /* [4,4] */ TNS("fsub",FF
), TNS("fsubr",FF
), TNS("fdiv",FF
), TNS("fdivr",FF
),
1274 /* [5,0] */ TNS("ffree",F
), TNS("fxch",F
), TNS("fst",F
), TNS("fstp",F
),
1275 /* [5,4] */ TNS("fucom",F
), TNS("fucomp",F
), INVALID
, INVALID
,
1277 /* [6,0] */ TNS("faddp",FF
), TNS("fmulp",FF
), TNS("fcomp",F
), TNS("fcompp",NORM
),
1278 /* [6,4] */ TNS("fsubp",FF
), TNS("fsubrp",FF
), TNS("fdivp",FF
), TNS("fdivrp",FF
),
1280 /* [7,0] */ TNS("ffreep",F
), TNS("fxch",F
), TNS("fstp",F
), TNS("fstp",F
),
1281 /* [7,4] */ TNS("fnstsw",M
), TNS("fucomip",FFC
), TNS("fcomip",FFC
), INVALID
,
1284 const instable_t dis_opFP4
[4][8] = {
1286 /* bit pattern: 1101 1001 111x xxxx */
1287 /* [0,0] */ TNS("fchs",NORM
), TNS("fabs",NORM
), INVALID
, INVALID
,
1288 /* [0,4] */ TNS("ftst",NORM
), TNS("fxam",NORM
), TNS("ftstp",NORM
), INVALID
,
1290 /* [1,0] */ TNS("fld1",NORM
), TNS("fldl2t",NORM
), TNS("fldl2e",NORM
), TNS("fldpi",NORM
),
1291 /* [1,4] */ TNS("fldlg2",NORM
), TNS("fldln2",NORM
), TNS("fldz",NORM
), INVALID
,
1293 /* [2,0] */ TNS("f2xm1",NORM
), TNS("fyl2x",NORM
), TNS("fptan",NORM
), TNS("fpatan",NORM
),
1294 /* [2,4] */ TNS("fxtract",NORM
), TNS("fprem1",NORM
), TNS("fdecstp",NORM
), TNS("fincstp",NORM
),
1296 /* [3,0] */ TNS("fprem",NORM
), TNS("fyl2xp1",NORM
), TNS("fsqrt",NORM
), TNS("fsincos",NORM
),
1297 /* [3,4] */ TNS("frndint",NORM
), TNS("fscale",NORM
), TNS("fsin",NORM
), TNS("fcos",NORM
),
1300 const instable_t dis_opFP5
[8] = {
1301 /* bit pattern: 1101 1011 111x xxxx */
1302 /* [0] */ TNS("feni",NORM
), TNS("fdisi",NORM
), TNS("fnclex",NORM
), TNS("fninit",NORM
),
1303 /* [4] */ TNS("fsetpm",NORM
), TNS("frstpm",NORM
), INVALID
, INVALID
,
1306 const instable_t dis_opFP6
[8] = {
1307 /* bit pattern: 1101 1011 11yy yxxx */
1308 /* [00] */ TNS("fcmov.nb",FF
), TNS("fcmov.ne",FF
), TNS("fcmov.nbe",FF
), TNS("fcmov.nu",FF
),
1309 /* [04] */ INVALID
, TNS("fucomi",F
), TNS("fcomi",F
), INVALID
,
1312 const instable_t dis_opFP7
[8] = {
1313 /* bit pattern: 1101 1010 11yy yxxx */
1314 /* [00] */ TNS("fcmov.b",FF
), TNS("fcmov.e",FF
), TNS("fcmov.be",FF
), TNS("fcmov.u",FF
),
1315 /* [04] */ INVALID
, INVALID
, INVALID
, INVALID
,
1319 * Main decode table for the op codes. The first two nibbles
1320 * will be used as an index into the table. If there is a
1321 * a need to further decode an instruction, the array to be
1322 * referenced is indicated with the other two entries being
1326 const instable_t dis_distable
[16][16] = {
1328 /* [0,0] */ TNS("addb",RMw
), TS("add",RMw
), TNS("addb",MRw
), TS("add",MRw
),
1329 /* [0,4] */ TNS("addb",IA
), TS("add",IA
), TSx("push",SEG
), TSx("pop",SEG
),
1330 /* [0,8] */ TNS("orb",RMw
), TS("or",RMw
), TNS("orb",MRw
), TS("or",MRw
),
1331 /* [0,C] */ TNS("orb",IA
), TS("or",IA
), TSx("push",SEG
), IND(dis_op0F
),
1333 /* [1,0] */ TNS("adcb",RMw
), TS("adc",RMw
), TNS("adcb",MRw
), TS("adc",MRw
),
1334 /* [1,4] */ TNS("adcb",IA
), TS("adc",IA
), TSx("push",SEG
), TSx("pop",SEG
),
1335 /* [1,8] */ TNS("sbbb",RMw
), TS("sbb",RMw
), TNS("sbbb",MRw
), TS("sbb",MRw
),
1336 /* [1,C] */ TNS("sbbb",IA
), TS("sbb",IA
), TSx("push",SEG
), TSx("pop",SEG
),
1338 /* [2,0] */ TNS("andb",RMw
), TS("and",RMw
), TNS("andb",MRw
), TS("and",MRw
),
1339 #if !defined(__APPLE__)
1340 /* [2,4] */ TNS("andb",IA
), TS("and",IA
), TNSx("%es:",OVERRIDE
), TNSx("daa",NORM
),
1342 /* [2,4] */ TNS("andb",IA
), TS("and",IA
), TNS("%es:",OVERRIDE
), TNSx("daa",NORM
),
1343 #endif /* __APPLE__ */
1344 /* [2,8] */ TNS("subb",RMw
), TS("sub",RMw
), TNS("subb",MRw
), TS("sub",MRw
),
1345 #if !defined(__APPLE__)
1346 /* [2,C] */ TNS("subb",IA
), TS("sub",IA
), TNSx("%cs:",OVERRIDE
), TNSx("das",NORM
),
1348 /* [2,C] */ TNS("subb",IA
), TS("sub",IA
), TNS("%cs:",OVERRIDE
), TNSx("das",NORM
),
1349 #endif /* __APPLE__ */
1351 /* [3,0] */ TNS("xorb",RMw
), TS("xor",RMw
), TNS("xorb",MRw
), TS("xor",MRw
),
1352 #if !defined(__APPLE__)
1353 /* [3,4] */ TNS("xorb",IA
), TS("xor",IA
), TNSx("%ss:",OVERRIDE
), TNSx("aaa",NORM
),
1355 /* [3,4] */ TNS("xorb",IA
), TS("xor",IA
), TNS("%ss:",OVERRIDE
), TNSx("aaa",NORM
),
1356 #endif /* __APPLE__ */
1357 /* [3,8] */ TNS("cmpb",RMw
), TS("cmp",RMw
), TNS("cmpb",MRw
), TS("cmp",MRw
),
1358 #if !defined(__APPLE__)
1359 /* [3,C] */ TNS("cmpb",IA
), TS("cmp",IA
), TNSx("%ds:",OVERRIDE
), TNSx("aas",NORM
),
1361 /* [3,C] */ TNS("cmpb",IA
), TS("cmp",IA
), TNS("%ds:",OVERRIDE
), TNSx("aas",NORM
),
1362 #endif /* __APPLE__ */
1364 /* [4,0] */ TSx("inc",R
), TSx("inc",R
), TSx("inc",R
), TSx("inc",R
),
1365 /* [4,4] */ TSx("inc",R
), TSx("inc",R
), TSx("inc",R
), TSx("inc",R
),
1366 /* [4,8] */ TSx("dec",R
), TSx("dec",R
), TSx("dec",R
), TSx("dec",R
),
1367 /* [4,C] */ TSx("dec",R
), TSx("dec",R
), TSx("dec",R
), TSx("dec",R
),
1369 /* [5,0] */ TSp("push",R
), TSp("push",R
), TSp("push",R
), TSp("push",R
),
1370 /* [5,4] */ TSp("push",R
), TSp("push",R
), TSp("push",R
), TSp("push",R
),
1371 /* [5,8] */ TSp("pop",R
), TSp("pop",R
), TSp("pop",R
), TSp("pop",R
),
1372 /* [5,C] */ TSp("pop",R
), TSp("pop",R
), TSp("pop",R
), TSp("pop",R
),
1374 /* [6,0] */ TSZx("pusha",IMPLMEM
,28),TSZx("popa",IMPLMEM
,28), TSx("bound",MR
), TNS("arpl",RMw
),
1375 /* [6,4] */ TNS("%fs:",OVERRIDE
), TNS("%gs:",OVERRIDE
), TNS("data16",DM
), TNS("addr16",AM
),
1376 /* [6,8] */ TSp("push",I
), TS("imul",IMUL
), TSp("push",Ib
), TS("imul",IMUL
),
1377 /* [6,C] */ TNSZ("insb",IMPLMEM
,1), TSZ("ins",IMPLMEM
,4), TNSZ("outsb",IMPLMEM
,1),TSZ("outs",IMPLMEM
,4),
1379 /* [7,0] */ TNSy("jo",BD
), TNSy("jno",BD
), TNSy("jb",BD
), TNSy("jae",BD
),
1380 /* [7,4] */ TNSy("je",BD
), TNSy("jne",BD
), TNSy("jbe",BD
), TNSy("ja",BD
),
1381 /* [7,8] */ TNSy("js",BD
), TNSy("jns",BD
), TNSy("jp",BD
), TNSy("jnp",BD
),
1382 /* [7,C] */ TNSy("jl",BD
), TNSy("jge",BD
), TNSy("jle",BD
), TNSy("jg",BD
),
1384 /* [8,0] */ IND(dis_op80
), IND(dis_op81
), INDx(dis_op82
), IND(dis_op83
),
1385 /* [8,4] */ TNS("testb",RMw
), TS("test",RMw
), TNS("xchgb",RMw
), TS("xchg",RMw
),
1386 /* [8,8] */ TNS("movb",RMw
), TS("mov",RMw
), TNS("movb",MRw
), TS("mov",MRw
),
1387 /* [8,C] */ TNS("movw",SM
), TS("lea",MR
), TNS("movw",MS
), TSp("pop",M
),
1389 /* [9,0] */ TNS("nop",NORM
), TS("xchg",RA
), TS("xchg",RA
), TS("xchg",RA
),
1390 /* [9,4] */ TS("xchg",RA
), TS("xchg",RA
), TS("xchg",RA
), TS("xchg",RA
),
1391 /* [9,8] */ TNS("cXtX",CBW
), TNS("cXtX",CWD
), TNSx("lcall",SO
), TNS("fwait",NORM
),
1392 /* [9,C] */ TSZy("pushf",IMPLMEM
,4),TSZy("popf",IMPLMEM
,4), TNSx("sahf",NORM
), TNSx("lahf",NORM
),
1394 /* [A,0] */ TNS("movb",OA
), TS("mov",OA
), TNS("movb",AO
), TS("mov",AO
),
1395 /* [A,4] */ TNSZ("movsb",SD
,1), TS("movs",SD
), TNSZ("cmpsb",SD
,1), TS("cmps",SD
),
1396 /* [A,8] */ TNS("testb",IA
), TS("test",IA
), TNS("stosb",AD
), TS("stos",AD
),
1397 /* [A,C] */ TNS("lodsb",SA
), TS("lods",SA
), TNS("scasb",AD
), TS("scas",AD
),
1399 /* [B,0] */ TNS("movb",IR
), TNS("movb",IR
), TNS("movb",IR
), TNS("movb",IR
),
1400 /* [B,4] */ TNS("movb",IR
), TNS("movb",IR
), TNS("movb",IR
), TNS("movb",IR
),
1401 /* [B,8] */ TS("mov",IR
), TS("mov",IR
), TS("mov",IR
), TS("mov",IR
),
1402 /* [B,C] */ TS("mov",IR
), TS("mov",IR
), TS("mov",IR
), TS("mov",IR
),
1404 /* [C,0] */ IND(dis_opC0
), IND(dis_opC1
), TNSyp("ret",RET
), TNSyp("ret",NORM
),
1405 /* [C,4] */ TNSx("les",MR
), TNSx("lds",MR
), TNS("movb",IMw
), TS("mov",IMw
),
1406 /* [C,8] */ TNSyp("enter",ENTER
), TNSyp("leave",NORM
), TNS("lret",RET
), TNS("lret",NORM
),
1407 /* [C,C] */ TNS("int",INT3
), TNS("int",INTx
), TNSx("into",NORM
), TNS("iret",NORM
),
1409 /* [D,0] */ IND(dis_opD0
), IND(dis_opD1
), IND(dis_opD2
), IND(dis_opD3
),
1410 /* [D,4] */ TNSx("aam",U
), TNSx("aad",U
), TNSx("falc",NORM
), TNSZ("xlat",IMPLMEM
,1),
1412 /* 287 instructions. Note that although the indirect field */
1413 /* indicates opFP1n2 for further decoding, this is not necessarily */
1414 /* the case since the opFP arrays are not partitioned according to key1 */
1415 /* and key2. opFP1n2 is given only to indicate that we haven't */
1416 /* finished decoding the instruction. */
1417 /* [D,8] */ IND(dis_opFP1n2
), IND(dis_opFP1n2
), IND(dis_opFP1n2
), IND(dis_opFP1n2
),
1418 /* [D,C] */ IND(dis_opFP1n2
), IND(dis_opFP1n2
), IND(dis_opFP1n2
), IND(dis_opFP1n2
),
1420 /* [E,0] */ TNSy("loopnz",BD
), TNSy("loopz",BD
), TNSy("loop",BD
), TNSy("jcxz",BD
),
1421 /* [E,4] */ TNS("inb",P
), TS("in",P
), TNS("outb",P
), TS("out",P
),
1422 /* [E,8] */ TNSyp("call",D
), TNSy("jmp",D
), TNSx("ljmp",SO
), TNSy("jmp",BD
),
1423 /* [E,C] */ TNS("inb",V
), TS("in",V
), TNS("outb",V
), TS("out",V
),
1425 /* [F,0] */ TNS("lock",LOCK
), TNS("icebp", NORM
), TNS("repnz",PREFIX
), TNS("repz",PREFIX
),
1426 /* [F,4] */ TNS("hlt",NORM
), TNS("cmc",NORM
), IND(dis_opF6
), IND(dis_opF7
),
1427 /* [F,8] */ TNS("clc",NORM
), TNS("stc",NORM
), TNS("cli",NORM
), TNS("sti",NORM
),
1428 /* [F,C] */ TNS("cld",NORM
), TNS("std",NORM
), IND(dis_opFE
), IND(dis_opFF
),
1434 * common functions to decode and disassemble an x86 or amd64 instruction
1438 * These are the individual fields of a REX prefix. Note that a REX
1439 * prefix with none of these set is still needed to:
1440 * - use the MOVSXD (sign extend 32 to 64 bits) instruction
1441 * - access the %sil, %dil, %bpl, %spl registers
1443 #define REX_W 0x08 /* 64 bit operand size when set */
1444 #define REX_R 0x04 /* high order bit extension of ModRM reg field */
1445 #define REX_X 0x02 /* high order bit extension of SIB index field */
1446 #define REX_B 0x01 /* extends ModRM r_m, SIB base, or opcode reg */
1449 * Even in 64 bit mode, usually only 4 byte immediate operands are supported.
1451 static int isize
[] = {1, 2, 4, 4};
1452 static int isize64
[] = {1, 2, 4, 8};
1455 * Just a bunch of useful macros.
1457 #define WBIT(x) (x & 0x1) /* to get w bit */
1458 #define REGNO(x) (x & 0x7) /* to get 3 bit register */
1459 #define VBIT(x) ((x)>>1 & 0x1) /* to get 'v' bit */
1460 #define OPSIZE(osize, wbit) ((wbit) ? isize[osize] : 1)
1461 #define OPSIZE64(osize, wbit) ((wbit) ? isize64[osize] : 1)
1463 #define REG_ONLY 3 /* mode to indicate a register operand (not memory) */
1465 #define BYTE_OPND 0 /* w-bit value indicating byte register */
1466 #define LONG_OPND 1 /* w-bit value indicating opnd_size register */
1467 #define MM_OPND 2 /* "value" used to indicate a mmx reg */
1468 #define XMM_OPND 3 /* "value" used to indicate a xmm reg */
1469 #define SEG_OPND 4 /* "value" used to indicate a segment reg */
1470 #define CONTROL_OPND 5 /* "value" used to indicate a control reg */
1471 #define DEBUG_OPND 6 /* "value" used to indicate a debug reg */
1472 #define TEST_OPND 7 /* "value" used to indicate a test reg */
1473 #define WORD_OPND 8 /* w-bit value indicating word size reg */
1476 * Get the next byte and separate the op code into the high and low nibbles.
1479 dtrace_get_opcode(dis86_t
*x
, uint_t
*high
, uint_t
*low
)
1484 * x86 instructions have a maximum length of 15 bytes. Bail out if
1485 * we try to read more.
1487 if (x
->d86_len
>= 15)
1488 return (x
->d86_error
= 1);
1492 byte
= x
->d86_get_byte(x
->d86_data
);
1494 return (x
->d86_error
= 1);
1495 x
->d86_bytes
[x
->d86_len
++] = byte
;
1496 *low
= byte
& 0xf; /* ----xxxx low 4 bits */
1497 *high
= byte
>> 4 & 0xf; /* xxxx---- bits 7 to 4 */
1502 * Get and decode an SIB (scaled index base) byte
1505 dtrace_get_SIB(dis86_t
*x
, uint_t
*ss
, uint_t
*index
, uint_t
*base
)
1512 byte
= x
->d86_get_byte(x
->d86_data
);
1517 x
->d86_bytes
[x
->d86_len
++] = byte
;
1520 *index
= (byte
>> 3) & 0x7;
1521 *ss
= (byte
>> 6) & 0x3;
1525 * Get the byte following the op code and separate it into the
1526 * mode, register, and r/m fields.
1529 dtrace_get_modrm(dis86_t
*x
, uint_t
*mode
, uint_t
*reg
, uint_t
*r_m
)
1531 if (x
->d86_got_modrm
== 0) {
1532 if (x
->d86_rmindex
== -1)
1533 x
->d86_rmindex
= x
->d86_len
;
1534 dtrace_get_SIB(x
, mode
, reg
, r_m
);
1535 x
->d86_got_modrm
= 1;
1540 * Adjust register selection based on any REX prefix bits present.
1544 dtrace_rex_adjust(uint_t rex_prefix
, uint_t mode
, uint_t
*reg
, uint_t
*r_m
)
1546 #pragma unused (mode)
1547 if (reg
!= NULL
&& r_m
== NULL
) {
1548 if (rex_prefix
& REX_B
)
1551 if (reg
!= NULL
&& (REX_R
& rex_prefix
) != 0)
1553 if (r_m
!= NULL
&& (REX_B
& rex_prefix
) != 0)
1559 * Get an immediate operand of the given size, with sign extension.
1562 dtrace_imm_opnd(dis86_t
*x
, int wbit
, int size
, int opindex
)
1568 if (x
->d86_numopnds
< (uint_t
)opindex
+ 1)
1569 x
->d86_numopnds
= (uint_t
)opindex
+ 1;
1576 if (x
->d86_opnd_size
== SIZE16
)
1578 else if (x
->d86_opnd_size
== SIZE32
)
1600 x
->d86_opnd
[opindex
].d86_value
= 0;
1601 for (i
= 0; i
< size
; ++i
) {
1602 byte
= x
->d86_get_byte(x
->d86_data
);
1607 x
->d86_bytes
[x
->d86_len
++] = byte
;
1608 x
->d86_opnd
[opindex
].d86_value
|= (uint64_t)byte
<< (i
* 8);
1610 /* Do sign extension */
1611 if (x
->d86_bytes
[x
->d86_len
- 1] & 0x80) {
1612 for (; i
< (int)sizeof (uint64_t); i
++)
1613 x
->d86_opnd
[opindex
].d86_value
|=
1614 (uint64_t)0xff << (i
* 8);
1617 x
->d86_opnd
[opindex
].d86_mode
= MODE_SIGNED
;
1618 x
->d86_opnd
[opindex
].d86_value_size
= valsize
;
1619 x
->d86_imm_bytes
+= size
;
1624 * Get an ip relative operand of the given size, with sign extension.
1627 dtrace_disp_opnd(dis86_t
*x
, int wbit
, int size
, int opindex
)
1629 dtrace_imm_opnd(x
, wbit
, size
, opindex
);
1631 x
->d86_opnd
[opindex
].d86_mode
= MODE_IPREL
;
1636 * Check to see if there is a segment override prefix pending.
1637 * If so, print it in the current 'operand' location and set
1638 * the override flag back to false.
1642 dtrace_check_override(dis86_t
*x
, int opindex
)
1645 if (x
->d86_seg_prefix
) {
1646 (void) strlcat(x
->d86_opnd
[opindex
].d86_prefix
,
1647 x
->d86_seg_prefix
, PFIXLEN
);
1650 #pragma unused (opindex)
1652 x
->d86_seg_prefix
= NULL
;
1657 * Process a single instruction Register or Memory operand.
1659 * mode = addressing mode from ModRM byte
1660 * r_m = r_m (or reg if mode == 3) field from ModRM byte
1661 * wbit = indicates which register (8bit, 16bit, ... MMX, etc.) set to use.
1662 * o = index of operand that we are processing (0, 1 or 2)
1664 * the value of reg or r_m must have already been adjusted for any REX prefix.
1668 dtrace_get_operand(dis86_t
*x
, uint_t mode
, uint_t r_m
, int wbit
, int opindex
)
1670 int have_SIB
= 0; /* flag presence of scale-index-byte */
1671 uint_t ss
; /* scale-factor from opcode */
1672 uint_t index
; /* index register number */
1673 uint_t base
; /* base register number */
1674 int dispsize
; /* size of displacement in bytes */
1676 char *opnd
= x
->d86_opnd
[opindex
].d86_opnd
;
1678 #pragma unused (wbit)
1681 if (x
->d86_numopnds
< (uint_t
)opindex
+ 1)
1682 x
->d86_numopnds
= (uint_t
)opindex
+ 1;
1688 * first handle a simple register
1690 if (mode
== REG_ONLY
) {
1694 (void) strlcat(opnd
, dis_MMREG
[r_m
], OPLEN
);
1697 (void) strlcat(opnd
, dis_XMMREG
[r_m
], OPLEN
);
1700 (void) strlcat(opnd
, dis_SEGREG
[r_m
], OPLEN
);
1703 (void) strlcat(opnd
, dis_CONTROLREG
[r_m
], OPLEN
);
1706 (void) strlcat(opnd
, dis_DEBUGREG
[r_m
], OPLEN
);
1709 (void) strlcat(opnd
, dis_TESTREG
[r_m
], OPLEN
);
1712 if (x
->d86_rex_prefix
== 0)
1713 (void) strlcat(opnd
, dis_REG8
[r_m
], OPLEN
);
1715 (void) strlcat(opnd
, dis_REG8_REX
[r_m
], OPLEN
);
1718 (void) strlcat(opnd
, dis_REG16
[r_m
], OPLEN
);
1721 if (x
->d86_opnd_size
== SIZE16
)
1722 (void) strlcat(opnd
, dis_REG16
[r_m
], OPLEN
);
1723 else if (x
->d86_opnd_size
== SIZE32
)
1724 (void) strlcat(opnd
, dis_REG32
[r_m
], OPLEN
);
1726 (void) strlcat(opnd
, dis_REG64
[r_m
], OPLEN
);
1729 #endif /* DIS_TEXT */
1734 * if symbolic representation, skip override prefix, if any
1736 dtrace_check_override(x
, opindex
);
1739 * Handle 16 bit memory references first, since they decode
1740 * the mode values more simply.
1741 * mode 1 is r_m + 8 bit displacement
1742 * mode 2 is r_m + 16 bit displacement
1743 * mode 0 is just r_m, unless r_m is 6 which is 16 bit disp
1745 if (x
->d86_addr_size
== SIZE16
) {
1746 if ((mode
== 0 && r_m
== 6) || mode
== 2)
1747 dtrace_imm_opnd(x
, WORD_OPND
, 2, opindex
);
1749 dtrace_imm_opnd(x
, BYTE_OPND
, 1, opindex
);
1751 if (mode
== 0 && r_m
== 6)
1752 x
->d86_opnd
[opindex
].d86_mode
= MODE_SIGNED
;
1754 x
->d86_opnd
[opindex
].d86_mode
= MODE_NONE
;
1756 x
->d86_opnd
[opindex
].d86_mode
= MODE_OFFSET
;
1757 (void) strlcat(opnd
, dis_addr16
[mode
][r_m
], OPLEN
);
1763 * 32 and 64 bit addressing modes are more complex since they
1764 * can involve an SIB (scaled index and base) byte to decode.
1766 if (r_m
== ESP_REGNO
|| r_m
== ESP_REGNO
+ 8) {
1768 dtrace_get_SIB(x
, &ss
, &index
, &base
);
1771 if (base
!= 5 || mode
!= 0)
1772 if (x
->d86_rex_prefix
& REX_B
)
1774 if (x
->d86_rex_prefix
& REX_X
)
1781 * Compute the displacement size and get its bytes
1789 else if ((r_m
& 7) == EBP_REGNO
||
1790 (have_SIB
&& (base
& 7) == EBP_REGNO
))
1794 dtrace_imm_opnd(x
, dispsize
== 4 ? LONG_OPND
: BYTE_OPND
,
1802 x
->d86_opnd
[opindex
].d86_mode
= MODE_OFFSET
;
1804 if (have_SIB
== 0) {
1805 if (x
->d86_mode
== SIZE32
) {
1807 (void) strlcat(opnd
, dis_addr32_mode0
[r_m
],
1810 (void) strlcat(opnd
, dis_addr32_mode12
[r_m
],
1814 (void) strlcat(opnd
, dis_addr64_mode0
[r_m
],
1817 x
->d86_opnd
[opindex
].d86_mode
=
1821 (void) strlcat(opnd
, dis_addr64_mode12
[r_m
],
1826 uint_t need_paren
= 0;
1828 if (x
->d86_mode
== SIZE32
) /* NOTE this is not addr_size! */
1829 regs
= (char **)dis_REG32
;
1831 regs
= (char **)dis_REG64
;
1834 * print the base (if any)
1836 if (base
== EBP_REGNO
&& mode
== 0) {
1837 if (index
!= ESP_REGNO
) {
1838 (void) strlcat(opnd
, "(", OPLEN
);
1842 (void) strlcat(opnd
, "(", OPLEN
);
1843 (void) strlcat(opnd
, regs
[base
], OPLEN
);
1848 * print the index (if any)
1850 if (index
!= ESP_REGNO
) {
1851 (void) strlcat(opnd
, ",", OPLEN
);
1852 (void) strlcat(opnd
, regs
[index
], OPLEN
);
1853 (void) strlcat(opnd
, dis_scale_factor
[ss
], OPLEN
);
1856 (void) strlcat(opnd
, ")", OPLEN
);
1862 * Operand sequence for standard instruction involving one register
1863 * and one register/memory operand.
1864 * wbit indicates a byte(0) or opnd_size(1) operation
1865 * vbit indicates direction (0 for "opcode r,r_m") or (1 for "opcode r_m, r")
1867 #define STANDARD_MODRM(x, mode, reg, r_m, rex_prefix, wbit, vbit) { \
1868 dtrace_get_modrm(x, &mode, ®, &r_m); \
1869 dtrace_rex_adjust(rex_prefix, mode, ®, &r_m); \
1870 dtrace_get_operand(x, mode, r_m, wbit, vbit); \
1871 dtrace_get_operand(x, REG_ONLY, reg, wbit, 1 - vbit); \
1875 * Similar to above, but allows for the two operands to be of different
1876 * classes (ie. wbit).
1877 * wbit is for the r_m operand
1878 * w2 is for the reg operand
1880 #define MIXED_MM(x, mode, reg, r_m, rex_prefix, wbit, w2, vbit) { \
1881 dtrace_get_modrm(x, &mode, ®, &r_m); \
1882 dtrace_rex_adjust(rex_prefix, mode, ®, &r_m); \
1883 dtrace_get_operand(x, mode, r_m, wbit, vbit); \
1884 dtrace_get_operand(x, REG_ONLY, reg, w2, 1 - vbit); \
1888 * Similar, but for 2 operands plus an immediate.
1889 * vbit indicates direction
1890 * 0 for "opcode imm, r, r_m" or
1891 * 1 for "opcode imm, r_m, r"
1893 #define THREEOPERAND(x, mode, reg, r_m, rex_prefix, wbit, w2, immsize, vbit) { \
1894 dtrace_get_modrm(x, &mode, ®, &r_m); \
1895 dtrace_rex_adjust(rex_prefix, mode, ®, &r_m); \
1896 dtrace_get_operand(x, mode, r_m, wbit, 2-vbit); \
1897 dtrace_get_operand(x, REG_ONLY, reg, w2, 1+vbit); \
1898 dtrace_imm_opnd(x, wbit, immsize, 0); \
1902 * Similar, but for 2 operands plus two immediates.
1904 #define FOUROPERAND(x, mode, reg, r_m, rex_prefix, wbit, w2, immsize) { \
1905 dtrace_get_modrm(x, &mode, ®, &r_m); \
1906 dtrace_rex_adjust(rex_prefix, mode, ®, &r_m); \
1907 dtrace_get_operand(x, mode, r_m, wbit, 2); \
1908 dtrace_get_operand(x, REG_ONLY, reg, w2, 3); \
1909 dtrace_imm_opnd(x, wbit, immsize, 1); \
1910 dtrace_imm_opnd(x, wbit, immsize, 0); \
1914 * 1 operands plus two immediates.
1916 #define ONEOPERAND_TWOIMM(x, mode, reg, r_m, rex_prefix, wbit, immsize) { \
1917 dtrace_get_modrm(x, &mode, ®, &r_m); \
1918 dtrace_rex_adjust(rex_prefix, mode, ®, &r_m); \
1919 dtrace_get_operand(x, mode, r_m, wbit, 2); \
1920 dtrace_imm_opnd(x, wbit, immsize, 1); \
1921 dtrace_imm_opnd(x, wbit, immsize, 0); \
1925 * Dissassemble a single x86 or amd64 instruction.
1927 * Mode determines the default operating mode (SIZE16, SIZE32 or SIZE64)
1928 * for interpreting instructions.
1930 * returns non-zero for bad opcode
1933 dtrace_disx86(dis86_t
*x
, uint_t cpu_mode
)
1935 instable_t
*dp
; /* decode table being used */
1941 #define NOMEM (nomem = 1)
1943 #define NOMEM /* nothing */
1945 uint_t opnd_size
; /* SIZE16, SIZE32 or SIZE64 */
1946 uint_t addr_size
; /* SIZE16, SIZE32 or SIZE64 */
1947 uint_t wbit
= 0; /* opcode wbit, 0 is 8 bit, !0 for opnd_size */
1948 uint_t w2
; /* wbit value for second operand */
1950 uint_t mode
= 0; /* mode value from ModRM byte */
1951 uint_t reg
; /* reg value from ModRM byte */
1952 uint_t r_m
; /* r_m value from ModRM byte */
1954 uint_t opcode1
; /* high nibble of 1st byte */
1955 uint_t opcode2
; /* low nibble of 1st byte */
1956 uint_t opcode3
; /* extra opcode bits usually from ModRM byte */
1957 uint_t opcode4
; /* high nibble of 2nd byte */
1958 uint_t opcode5
; /* low nibble of 2nd byte */
1959 uint_t opcode6
; /* high nibble of 3rd byte */
1960 uint_t opcode7
; /* low nibble of 3rd byte */
1961 uint_t opcode_bytes
= 1;
1964 * legacy prefixes come in 5 flavors, you should have only one of each
1966 uint_t opnd_size_prefix
= 0;
1967 uint_t addr_size_prefix
= 0;
1968 uint_t segment_prefix
= 0;
1969 uint_t lock_prefix
= 0;
1970 uint_t rep_prefix
= 0;
1971 uint_t rex_prefix
= 0; /* amd64 register extension prefix */
1977 x
->d86_rmindex
= -1;
1980 x
->d86_numopnds
= 0;
1981 x
->d86_seg_prefix
= NULL
;
1983 for (i
= 0; i
< 4; ++i
) {
1984 x
->d86_opnd
[i
].d86_opnd
[0] = 0;
1985 x
->d86_opnd
[i
].d86_prefix
[0] = 0;
1986 x
->d86_opnd
[i
].d86_value_size
= 0;
1987 x
->d86_opnd
[i
].d86_value
= 0;
1988 x
->d86_opnd
[i
].d86_mode
= MODE_NONE
;
1994 if (cpu_mode
== SIZE16
) {
1997 } else if (cpu_mode
== SIZE32
) {
2006 * Get one opcode byte and check for zero padding that follows
2009 if (dtrace_get_opcode(x
, &opcode1
, &opcode2
) != 0)
2012 if (opcode1
== 0 && opcode2
== 0 &&
2013 x
->d86_check_func
!= NULL
&& x
->d86_check_func(x
->d86_data
)) {
2015 (void) strncpy(x
->d86_mnem
, ".byte\t0", OPLEN
);
2016 x
->d86_mnem
[OPLEN
- 1] = '\0';
2022 * Gather up legacy x86 prefix bytes.
2025 uint_t
*which_prefix
= NULL
;
2027 dp
= (instable_t
*)&dis_distable
[opcode1
][opcode2
];
2029 switch (dp
->it_adrmode
) {
2031 which_prefix
= &rep_prefix
;
2034 which_prefix
= &lock_prefix
;
2037 which_prefix
= &segment_prefix
;
2039 x
->d86_seg_prefix
= (char *)dp
->it_name
;
2041 if (dp
->it_invalid64
&& cpu_mode
== SIZE64
)
2045 which_prefix
= &addr_size_prefix
;
2048 which_prefix
= &opnd_size_prefix
;
2051 if (which_prefix
== NULL
)
2053 *which_prefix
= (opcode1
<< 4) | opcode2
;
2054 if (dtrace_get_opcode(x
, &opcode1
, &opcode2
) != 0)
2059 * Handle amd64 mode PREFIX values.
2060 * Some of the segment prefixes are no-ops. (only FS/GS actually work)
2061 * We might have a REX prefix (opcodes 0x40-0x4f)
2063 if (cpu_mode
== SIZE64
) {
2064 if (segment_prefix
!= 0x64 && segment_prefix
!= 0x65)
2067 if (opcode1
== 0x4) {
2068 rex_prefix
= (opcode1
<< 4) | opcode2
;
2069 if (dtrace_get_opcode(x
, &opcode1
, &opcode2
) != 0)
2071 dp
= (instable_t
*)&dis_distable
[opcode1
][opcode2
];
2076 * Deal with selection of operand and address size now.
2077 * Note that the REX.W bit being set causes opnd_size_prefix to be
2080 if (cpu_mode
== SIZE64
) {
2081 if (rex_prefix
& REX_W
)
2083 else if (opnd_size_prefix
)
2086 if (addr_size_prefix
)
2088 } else if (cpu_mode
== SIZE32
) {
2089 if (opnd_size_prefix
)
2091 if (addr_size_prefix
)
2094 if (opnd_size_prefix
)
2096 if (addr_size_prefix
)
2101 * The pause instruction - a repz'd nop. This doesn't fit
2102 * with any of the other prefix goop added for SSE, so we'll
2103 * special-case it here.
2105 if (rep_prefix
== 0xf3 && opcode1
== 0x9 && opcode2
== 0x0) {
2107 dp
= (instable_t
*)&dis_opPause
;
2111 * Some 386 instructions have 2 bytes of opcode before the mod_r/m
2112 * byte so we may need to perform a table indirection.
2114 if (dp
->it_indirect
== (instable_t
*)dis_op0F
) {
2115 if (dtrace_get_opcode(x
, &opcode4
, &opcode5
) != 0)
2118 if (opcode4
== 0x7 && opcode5
>= 0x1 && opcode5
<= 0x3) {
2121 if (dtrace_get_opcode(x
, &opcode6
, &opcode7
) != 0)
2124 subcode
= ((opcode6
& 0x3) << 1) |
2125 ((opcode7
& 0x8) >> 3);
2126 dp
= (instable_t
*)&dis_op0F7123
[opcode5
][subcode
];
2127 } else if ((opcode4
== 0xc) && (opcode5
>= 0x8)) {
2128 dp
= (instable_t
*)&dis_op0FC8
[0];
2129 } else if ((opcode4
== 0x3) && (opcode5
== 0xA)) {
2131 if (dtrace_get_opcode(x
, &opcode6
, &opcode7
) != 0)
2133 if (opnd_size
== SIZE16
)
2136 dp
= (instable_t
*)&dis_op0F3A
[(opcode6
<<4)|opcode7
];
2138 if (LIT_STRNEQL(dp
->it_name
, "INVALID"))
2141 switch (dp
->it_adrmode
) {
2145 if (opnd_size_prefix
== 0) {
2150 if (opnd_size_prefix
== 0) {
2151 /* SSSE3 MMX instructions */
2154 dp
->it_adrmode
= MMOPM_66o
;
2163 } else if ((opcode4
== 0x3) && (opcode5
== 0x8)) {
2165 if (dtrace_get_opcode(x
, &opcode6
, &opcode7
) != 0)
2167 dp
= (instable_t
*)&dis_op0F38
[(opcode6
<<4)|opcode7
];
2169 if (LIT_STRNEQL(dp
->it_name
, "INVALID"))
2172 switch (dp
->it_adrmode
) {
2175 if (opnd_size_prefix
== 0) {
2180 if (opnd_size_prefix
== 0) {
2181 /* SSSE3 MMX instructions */
2184 dp
->it_adrmode
= MM
;
2191 if (rep_prefix
!= 0xF2) {
2200 dp
= (instable_t
*)&dis_op0F
[opcode4
][opcode5
];
2205 * If still not at a TERM decode entry, then a ModRM byte
2206 * exists and its fields further decode the instruction.
2208 x
->d86_got_modrm
= 0;
2209 if (dp
->it_indirect
!= TERM
) {
2210 dtrace_get_modrm(x
, &mode
, &opcode3
, &r_m
);
2216 * decode 287 instructions (D8-DF) from opcodeN
2218 if (opcode1
== 0xD && opcode2
>= 0x8) {
2219 if (opcode2
== 0xB && mode
== 0x3 && opcode3
== 4)
2220 dp
= (instable_t
*)&dis_opFP5
[r_m
];
2221 else if (opcode2
== 0xA && mode
== 0x3 && opcode3
< 4)
2222 dp
= (instable_t
*)&dis_opFP7
[opcode3
];
2223 else if (opcode2
== 0xB && mode
== 0x3)
2224 dp
= (instable_t
*)&dis_opFP6
[opcode3
];
2225 else if (opcode2
== 0x9 && mode
== 0x3 && opcode3
>= 4)
2226 dp
= (instable_t
*)&dis_opFP4
[opcode3
- 4][r_m
];
2227 else if (mode
== 0x3)
2229 &dis_opFP3
[opcode2
- 8][opcode3
];
2232 &dis_opFP1n2
[opcode2
- 8][opcode3
];
2234 dp
= (instable_t
*)dp
->it_indirect
+ opcode3
;
2239 * In amd64 bit mode, ARPL opcode is changed to MOVSXD
2240 * (sign extend 32bit to 64 bit)
2242 if (cpu_mode
== SIZE64
&& opcode1
== 0x6 && opcode2
== 0x3)
2243 dp
= (instable_t
*)&dis_opMOVSLD
;
2246 * at this point we should have a correct (or invalid) opcode
2248 if ((cpu_mode
== SIZE64
&& dp
->it_invalid64
) ||
2249 (cpu_mode
!= SIZE64
&& dp
->it_invalid32
))
2251 if (dp
->it_indirect
!= TERM
)
2255 * deal with MMX/SSE opcodes which are changed by prefixes
2257 switch (dp
->it_adrmode
) {
2275 * This is horrible. Some SIMD instructions take the
2276 * form 0x0F 0x?? ..., which is easily decoded using the
2277 * existing tables. Other SIMD instructions use various
2278 * prefix bytes to overload existing instructions. For
2279 * Example, addps is F0, 58, whereas addss is F3 (repz),
2280 * F0, 58. Presumably someone got a raise for this.
2282 * If we see one of the instructions which can be
2283 * modified in this way (if we've got one of the SIMDO*
2284 * address modes), we'll check to see if the last prefix
2285 * was a repz. If it was, we strip the prefix from the
2286 * mnemonic, and we indirect using the dis_opSIMDrepz
2291 * Calculate our offset in dis_op0F
2293 if ((uintptr_t)dp
- (uintptr_t)dis_op0F
> sizeof (dis_op0F
))
2296 off
= ((uintptr_t)dp
- (uintptr_t)dis_op0F
) /
2297 sizeof (instable_t
);
2300 * Rewrite if this instruction used one of the magic prefixes.
2303 if (rep_prefix
== 0xf2)
2304 dp
= (instable_t
*)&dis_opSIMDrepnz
[off
];
2306 dp
= (instable_t
*)&dis_opSIMDrepz
[off
];
2308 } else if (opnd_size_prefix
) {
2309 dp
= (instable_t
*)&dis_opSIMDdata16
[off
];
2310 opnd_size_prefix
= 0;
2311 if (opnd_size
== SIZE16
)
2318 * As with the "normal" SIMD instructions, the MMX
2319 * shuffle instructions are overloaded. These
2320 * instructions, however, are special in that they use
2321 * an extra byte, and thus an extra table. As of this
2322 * writing, they only use the opnd_size prefix.
2326 * Calculate our offset in dis_op0F7123
2328 if ((uintptr_t)dp
- (uintptr_t)dis_op0F7123
>
2329 sizeof (dis_op0F7123
))
2332 if (opnd_size_prefix
) {
2333 off
= ((uintptr_t)dp
- (uintptr_t)dis_op0F7123
) /
2334 sizeof (instable_t
);
2335 dp
= (instable_t
*)&dis_opSIMD7123
[off
];
2336 opnd_size_prefix
= 0;
2337 if (opnd_size
== SIZE16
)
2343 if (rep_prefix
== 0xf3) {
2346 * Calculate our offset in dis_op0F
2348 if ((uintptr_t)dp
- (uintptr_t)dis_op0F
2349 > sizeof (dis_op0F
))
2352 off
= ((uintptr_t)dp
- (uintptr_t)dis_op0F
) /
2353 sizeof (instable_t
);
2355 dp
= (instable_t
*)&dis_opSIMDrepz
[off
];
2365 * In 64 bit mode, some opcodes automatically use opnd_size == SIZE64.
2367 if (cpu_mode
== SIZE64
)
2368 if (dp
->it_always64
|| (opnd_size
== SIZE32
&& dp
->it_stackop
))
2373 * At this point most instructions can format the opcode mnemonic
2374 * including the prefixes.
2377 (void) strlcat(x
->d86_mnem
, "lock ", OPLEN
);
2379 if (rep_prefix
== 0xf2)
2380 (void) strlcat(x
->d86_mnem
, "repnz ", OPLEN
);
2381 else if (rep_prefix
== 0xf3)
2382 (void) strlcat(x
->d86_mnem
, "repz ", OPLEN
);
2384 if (cpu_mode
== SIZE64
&& addr_size_prefix
)
2385 (void) strlcat(x
->d86_mnem
, "addr32 ", OPLEN
);
2387 if (dp
->it_adrmode
!= CBW
&&
2388 dp
->it_adrmode
!= CWD
&&
2389 dp
->it_adrmode
!= XMMSFNC
) {
2390 if (LIT_STRNEQL(dp
->it_name
, "INVALID"))
2392 (void) strlcat(x
->d86_mnem
, dp
->it_name
, OPLEN
);
2393 if (dp
->it_suffix
) {
2394 char *types
[] = {"", "w", "l", "q"};
2395 if (opcode_bytes
== 2 && opcode4
== 4) {
2396 /* It's a cmovx.yy. Replace the suffix x */
2397 for (i
= 5; i
< OPLEN
; i
++) {
2398 if (x
->d86_mnem
[i
] == '.')
2401 x
->d86_mnem
[i
- 1] = *types
[opnd_size
];
2402 } else if ((opnd_size
== 2) && (opcode_bytes
== 3) &&
2403 ((opcode6
== 1 && opcode7
== 6) ||
2404 (opcode6
== 2 && opcode7
== 2))) {
2406 * To handle PINSRD and PEXTRD
2408 (void) strlcat(x
->d86_mnem
, "d", OPLEN
);
2410 (void) strlcat(x
->d86_mnem
, types
[opnd_size
],
2418 * Process operands based on the addressing modes.
2420 x
->d86_mode
= cpu_mode
;
2421 x
->d86_rex_prefix
= rex_prefix
;
2422 x
->d86_opnd_size
= opnd_size
;
2423 x
->d86_addr_size
= addr_size
;
2424 vbit
= 0; /* initialize for mem/reg -> reg */
2425 switch (dp
->it_adrmode
) {
2427 * amd64 instruction to sign extend 32 bit reg/mem operands
2428 * into 64 bit register values
2432 if (rex_prefix
== 0) {
2433 (void) strncpy(x
->d86_mnem
, "movzld", OPLEN
);
2434 x
->d86_mnem
[OPLEN
- 1] = '\0';
2437 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2438 dtrace_rex_adjust(rex_prefix
, mode
, ®
, &r_m
);
2439 x
->d86_opnd_size
= SIZE64
;
2440 dtrace_get_operand(x
, REG_ONLY
, reg
, LONG_OPND
, 1);
2441 x
->d86_opnd_size
= opnd_size
= SIZE32
;
2443 dtrace_get_operand(x
, mode
, r_m
, wbit
, 0);
2447 * movsbl movsbw movsbq (0x0FBE) or movswl movswq (0x0FBF)
2448 * movzbl movzbw movzbq (0x0FB6) or movzwl movzwq (0x0FB7)
2449 * wbit lives in 2nd byte, note that operands
2450 * are different sized
2453 if (rex_prefix
& REX_W
) {
2454 /* target register size = 64 bit */
2455 x
->d86_mnem
[5] = 'q';
2457 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2458 dtrace_rex_adjust(rex_prefix
, mode
, ®
, &r_m
);
2459 dtrace_get_operand(x
, REG_ONLY
, reg
, LONG_OPND
, 1);
2460 x
->d86_opnd_size
= opnd_size
= SIZE16
;
2461 wbit
= WBIT(opcode5
);
2462 dtrace_get_operand(x
, mode
, r_m
, wbit
, 0);
2466 if (rex_prefix
& REX_W
)
2468 x
->d86_opnd_size
= opnd_size
;
2470 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2471 dtrace_rex_adjust(rex_prefix
, mode
, ®
, &r_m
);
2472 dtrace_get_operand(x
, REG_ONLY
, reg
, LONG_OPND
, 1);
2473 wbit
= WBIT(opcode7
);
2474 if (opnd_size_prefix
)
2475 x
->d86_opnd_size
= opnd_size
= SIZE16
;
2476 dtrace_get_operand(x
, mode
, r_m
, wbit
, 0);
2480 * imul instruction, with either 8-bit or longer immediate
2481 * opcode 0x6B for byte, sign-extended displacement, 0x69 for word(s)
2485 THREEOPERAND(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, LONG_OPND
,
2486 OPSIZE(opnd_size
, opcode2
== 0x9), 1);
2489 /* memory or register operand to register, with 'w' bit */
2491 wbit
= WBIT(opcode2
);
2492 STANDARD_MODRM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, 0);
2495 /* register to memory or register operand, with 'w' bit */
2496 /* arpl happens to fit here also because it is odd */
2498 if (opcode_bytes
== 2)
2499 wbit
= WBIT(opcode5
);
2501 wbit
= WBIT(opcode2
);
2502 STANDARD_MODRM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, 1);
2505 /* xaddb instruction */
2508 STANDARD_MODRM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, 1);
2511 /* MMX register to memory or register operand */
2515 wbit
= !LIT_STRNEQL(dp
->it_name
, "movd") ? MM_OPND
: LONG_OPND
;
2519 MIXED_MM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, MM_OPND
, 1);
2522 /* MMX register to memory */
2524 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2525 if (mode
== REG_ONLY
)
2528 MIXED_MM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, MM_OPND
, 1);
2531 /* Double shift. Has immediate operand specifying the shift. */
2534 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2535 dtrace_rex_adjust(rex_prefix
, mode
, ®
, &r_m
);
2536 dtrace_get_operand(x
, mode
, r_m
, wbit
, 2);
2537 dtrace_get_operand(x
, REG_ONLY
, reg
, LONG_OPND
, 1);
2538 dtrace_imm_opnd(x
, wbit
, 1, 0);
2542 * Double shift. With no immediate operand, specifies using %cl.
2546 STANDARD_MODRM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, 1);
2549 /* immediate to memory or register operand */
2551 wbit
= WBIT(opcode2
);
2552 dtrace_rex_adjust(rex_prefix
, mode
, NULL
, &r_m
);
2553 dtrace_get_operand(x
, mode
, r_m
, wbit
, 1);
2555 * Have long immediate for opcode 0x81, but not 0x80 nor 0x83
2557 dtrace_imm_opnd(x
, wbit
, OPSIZE(opnd_size
, opcode2
== 1), 0);
2560 /* immediate to memory or register operand with the */
2561 /* 'w' bit present */
2563 wbit
= WBIT(opcode2
);
2564 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2565 dtrace_rex_adjust(rex_prefix
, mode
, NULL
, &r_m
);
2566 dtrace_get_operand(x
, mode
, r_m
, wbit
, 1);
2567 dtrace_imm_opnd(x
, wbit
, OPSIZE(opnd_size
, wbit
), 0);
2570 /* immediate to register with register in low 3 bits */
2573 /* w-bit here (with regs) is bit 3 */
2574 wbit
= opcode2
>>3 & 0x1;
2575 reg
= REGNO(opcode2
);
2576 dtrace_rex_adjust(rex_prefix
, mode
, ®
, NULL
);
2579 dtrace_get_operand(x
, mode
, r_m
, wbit
, 1);
2580 dtrace_imm_opnd(x
, wbit
, OPSIZE64(opnd_size
, wbit
), 0);
2583 /* MMX immediate shift of register */
2587 goto mm_shift
; /* in next case */
2589 /* SIMD immediate shift of register */
2593 reg
= REGNO(opcode7
);
2594 dtrace_rex_adjust(rex_prefix
, mode
, ®
, NULL
);
2595 dtrace_get_operand(x
, REG_ONLY
, reg
, wbit
, 1);
2596 dtrace_imm_opnd(x
, wbit
, 1, 0);
2600 /* accumulator to memory operand */
2605 /* memory operand to accumulator */
2607 wbit
= WBIT(opcode2
);
2608 dtrace_get_operand(x
, REG_ONLY
, EAX_REGNO
, wbit
, 1 - vbit
);
2609 dtrace_imm_opnd(x
, wbit
, OPSIZE64(addr_size
, LONG_OPND
), vbit
);
2611 x
->d86_opnd
[vbit
].d86_mode
= MODE_OFFSET
;
2616 /* segment register to memory or register operand */
2621 /* memory or register operand to segment register */
2623 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2624 dtrace_rex_adjust(rex_prefix
, mode
, NULL
, &r_m
);
2625 dtrace_get_operand(x
, mode
, r_m
, LONG_OPND
, vbit
);
2626 dtrace_get_operand(x
, REG_ONLY
, reg
, SEG_OPND
, 1 - vbit
);
2630 * rotate or shift instructions, which may shift by 1 or
2631 * consult the cl register, depending on the 'v' bit
2634 vbit
= VBIT(opcode2
);
2635 wbit
= WBIT(opcode2
);
2636 dtrace_rex_adjust(rex_prefix
, mode
, NULL
, &r_m
);
2637 dtrace_get_operand(x
, mode
, r_m
, wbit
, 1);
2640 (void) strlcat(x
->d86_opnd
[0].d86_opnd
, "%cl", OPLEN
);
2642 x
->d86_opnd
[0].d86_mode
= MODE_SIGNED
;
2643 x
->d86_opnd
[0].d86_value_size
= 1;
2644 x
->d86_opnd
[0].d86_value
= 1;
2649 * immediate rotate or shift instructions
2652 wbit
= WBIT(opcode2
);
2654 dtrace_rex_adjust(rex_prefix
, mode
, NULL
, &r_m
);
2655 dtrace_get_operand(x
, mode
, r_m
, wbit
, 1);
2656 dtrace_imm_opnd(x
, wbit
, 1, 0);
2659 /* bit test instructions */
2662 goto normal_imm_mem
;
2664 /* single memory or register operand with 'w' bit present */
2666 wbit
= WBIT(opcode2
);
2668 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2669 dtrace_rex_adjust(rex_prefix
, mode
, NULL
, &r_m
);
2670 dtrace_get_operand(x
, mode
, r_m
, wbit
, 0);
2674 if (cpu_mode
== SIZE64
&& mode
== 3 && r_m
== 0) {
2676 (void) strncpy(x
->d86_mnem
, "swapgs", OPLEN
);
2677 x
->d86_mnem
[OPLEN
- 1] = '\0';
2684 /* prefetch instruction - memory operand, but no memory acess */
2689 /* single memory or register operand */
2694 /* single memory or register byte operand */
2703 (void) strncpy(x
->d86_mnem
, "monitor", OPLEN
);
2704 x
->d86_mnem
[OPLEN
- 1] = '\0';
2708 } else if (r_m
== 1) {
2710 (void) strncpy(x
->d86_mnem
, "mwait", OPLEN
);
2711 x
->d86_mnem
[OPLEN
- 1] = '\0';
2722 /* Similar to M, but only memory (no direct registers) */
2724 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2727 dtrace_rex_adjust(rex_prefix
, mode
, NULL
, &r_m
);
2728 dtrace_get_operand(x
, mode
, r_m
, wbit
, 0);
2731 /* move special register to register or reverse if vbit */
2739 wbit
= CONTROL_OPND
;
2757 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2758 dtrace_rex_adjust(rex_prefix
, mode
, ®
, &r_m
);
2759 dtrace_get_operand(x
, REG_ONLY
, reg
, wbit
, vbit
);
2760 dtrace_get_operand(x
, REG_ONLY
, r_m
, LONG_OPND
, 1 - vbit
);
2765 * single register operand with register in the low 3
2769 if (opcode_bytes
== 2)
2770 reg
= REGNO(opcode5
);
2772 reg
= REGNO(opcode2
);
2773 dtrace_rex_adjust(rex_prefix
, mode
, ®
, NULL
);
2774 dtrace_get_operand(x
, REG_ONLY
, reg
, LONG_OPND
, 0);
2779 * register to accumulator with register in the low 3
2780 * bits of op code, xchg instructions
2784 reg
= REGNO(opcode2
);
2785 dtrace_rex_adjust(rex_prefix
, mode
, ®
, NULL
);
2786 dtrace_get_operand(x
, REG_ONLY
, reg
, LONG_OPND
, 0);
2787 dtrace_get_operand(x
, REG_ONLY
, EAX_REGNO
, LONG_OPND
, 1);
2791 * single segment register operand, with register in
2792 * bits 3-4 of op code byte
2796 reg
= (x
->d86_bytes
[x
->d86_len
- 1] >> 3) & 0x3;
2797 dtrace_get_operand(x
, REG_ONLY
, reg
, SEG_OPND
, 0);
2801 * single segment register operand, with register in
2802 * bits 3-5 of op code
2806 /* long seg reg from opcode */
2807 reg
= (x
->d86_bytes
[x
->d86_len
- 1] >> 3) & 0x7;
2808 dtrace_get_operand(x
, REG_ONLY
, reg
, SEG_OPND
, 0);
2811 /* memory or register operand to register */
2814 STANDARD_MODRM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, 0);
2819 STANDARD_MODRM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, 1);
2822 /* MMX/SIMD-Int memory or mm reg to mm reg */
2826 wbit
= !LIT_STRNEQL(dp
->it_name
, "movd") ? MM_OPND
: LONG_OPND
;
2830 MIXED_MM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, MM_OPND
, 0);
2835 wbit
= !LIT_STRNEQL(dp
->it_name
, "movd") ? MM_OPND
: LONG_OPND
;
2839 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2840 if (mode
!= REG_ONLY
)
2843 dtrace_rex_adjust(rex_prefix
, mode
, ®
, &r_m
);
2844 dtrace_get_operand(x
, mode
, r_m
, wbit
, 0);
2845 dtrace_get_operand(x
, REG_ONLY
, reg
, MM_OPND
, 1);
2846 mode
= 0; /* change for memory access size... */
2849 /* MMX/SIMD-Int and SIMD-FP predicated mm reg to r32 */
2856 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2857 if (mode
!= REG_ONLY
)
2860 THREEOPERAND(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, LONG_OPND
, 1,
2866 THREEOPERAND(x
, mode
, reg
, r_m
, rex_prefix
, LONG_OPND
, XMM_OPND
,
2870 /* MMX/SIMD-Int predicated r32/mem to mm reg */
2880 THREEOPERAND(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, w2
, 1, 1);
2883 /* MMX/SIMD-Int predicated mm/mem to mm reg */
2886 wbit
= w2
= MM_OPND
;
2889 /* MMX/SIMD-Int mm reg to r32 */
2892 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2893 if (mode
!= REG_ONLY
)
2896 MIXED_MM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, LONG_OPND
, 0);
2899 /* SIMD memory or xmm reg operand to xmm reg */
2906 STANDARD_MODRM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, 0);
2908 if (dp
->it_adrmode
== XMMXIMPL
&& mode
!= REG_ONLY
)
2913 * movlps and movhlps share opcodes. They differ in the
2914 * addressing modes allowed for their operands.
2915 * movhps and movlhps behave similarly.
2917 if (mode
== REG_ONLY
) {
2918 if (LIT_STRNEQL(dp
->it_name
, "movlps"))
2919 (void) strncpy(x
->d86_mnem
, "movhlps", OPLEN
);
2920 x
->d86_mnem
[OPLEN
- 1] = '\0';
2921 } else if (LIT_STRNEQL(dp
->it_name
, "movhps")) {
2922 (void) strncpy(x
->d86_mnem
, "movlhps", OPLEN
);
2923 x
->d86_mnem
[OPLEN
- 1] = '\0';
2927 if (dp
->it_adrmode
== XMMXIMPL
)
2928 mode
= 0; /* change for memory access size... */
2931 /* SIMD xmm reg to memory or xmm reg */
2936 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2938 if ((LIT_STRNEQL(dp
->it_name
, "movlps") ||
2939 LIT_STRNEQL(dp
->it_name
, "movhps") ||
2940 LIT_STRNEQL(dp
->it_name
, "movntps")) &&
2945 MIXED_MM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, XMM_OPND
, 1);
2948 /* SIMD memory to xmm reg */
2953 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
2955 if (mode
== REG_ONLY
) {
2956 if (LIT_STRNEQL(dp
->it_name
, "movhps")) {
2957 (void) strncpy(x
->d86_mnem
, "movlhps", OPLEN
);
2958 x
->d86_mnem
[OPLEN
- 1] = '\0';
2963 MIXED_MM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, XMM_OPND
, 0);
2966 /* SIMD memory or r32 to xmm reg */
2969 MIXED_MM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, XMM_OPND
, 0);
2974 MIXED_MM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, XMM_OPND
, 1);
2977 /* SIMD memory or mm reg to xmm reg */
2979 /* SIMD mm to xmm */
2982 MIXED_MM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, XMM_OPND
, 0);
2985 /* SIMD memory or xmm reg to mm reg */
2990 MIXED_MM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, MM_OPND
, 0);
2994 /* SIMD memory or xmm reg to r32 */
2997 MIXED_MM(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, LONG_OPND
, 0);
3000 /* SIMD xmm to r32 */
3003 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
3004 if (mode
!= REG_ONLY
)
3006 dtrace_rex_adjust(rex_prefix
, mode
, ®
, &r_m
);
3007 dtrace_get_operand(x
, mode
, r_m
, XMM_OPND
, 0);
3008 dtrace_get_operand(x
, REG_ONLY
, reg
, LONG_OPND
, 1);
3012 /* SIMD predicated memory or xmm reg with/to xmm reg */
3018 THREEOPERAND(x
, mode
, reg
, r_m
, rex_prefix
, wbit
, XMM_OPND
, 1,
3023 * cmpps and cmpss vary their instruction name based
3024 * on the value of imm8. Other XMMP instructions,
3025 * such as shufps, require explicit specification of
3028 if (dp
->it_name
[0] == 'c' &&
3029 dp
->it_name
[1] == 'm' &&
3030 dp
->it_name
[2] == 'p' &&
3031 strlen(dp
->it_name
) == 5) {
3032 uchar_t pred
= x
->d86_opnd
[0].d86_value
& 0xff;
3034 if (pred
>= (sizeof (dis_PREDSUFFIX
) / sizeof (char *)))
3037 (void) strncpy(x
->d86_mnem
, "cmp", OPLEN
);
3038 x
->d86_mnem
[OPLEN
- 1] = '\0';
3039 (void) strlcat(x
->d86_mnem
, dis_PREDSUFFIX
[pred
],
3041 (void) strlcat(x
->d86_mnem
,
3042 dp
->it_name
+ strlen(dp
->it_name
) - 2,
3044 x
->d86_opnd
[0] = x
->d86_opnd
[1];
3045 x
->d86_opnd
[1] = x
->d86_opnd
[2];
3046 x
->d86_numopnds
= 2;
3052 FOUROPERAND(x
, mode
, reg
, r_m
, rex_prefix
, XMM_OPND
, XMM_OPND
,
3058 ONEOPERAND_TWOIMM(x
, mode
, reg
, r_m
, rex_prefix
, XMM_OPND
, 1);
3062 /* immediate operand to accumulator */
3064 wbit
= WBIT(opcode2
);
3065 dtrace_get_operand(x
, REG_ONLY
, EAX_REGNO
, wbit
, 1);
3066 dtrace_imm_opnd(x
, wbit
, OPSIZE(opnd_size
, wbit
), 0);
3070 /* memory or register operand to accumulator */
3072 wbit
= WBIT(opcode2
);
3073 dtrace_rex_adjust(rex_prefix
, mode
, NULL
, &r_m
);
3074 dtrace_get_operand(x
, mode
, r_m
, wbit
, 0);
3077 /* si register to di register used to reference memory */
3080 dtrace_check_override(x
, 0);
3081 x
->d86_numopnds
= 2;
3082 if (addr_size
== SIZE64
) {
3083 (void) strlcat(x
->d86_opnd
[0].d86_opnd
, "(%rsi)",
3085 (void) strlcat(x
->d86_opnd
[1].d86_opnd
, "(%rdi)",
3087 } else if (addr_size
== SIZE32
) {
3088 (void) strlcat(x
->d86_opnd
[0].d86_opnd
, "(%esi)",
3090 (void) strlcat(x
->d86_opnd
[1].d86_opnd
, "(%edi)",
3093 (void) strlcat(x
->d86_opnd
[0].d86_opnd
, "(%si)",
3095 (void) strlcat(x
->d86_opnd
[1].d86_opnd
, "(%di)",
3102 /* accumulator to di register */
3104 wbit
= WBIT(opcode2
);
3106 dtrace_check_override(x
, 1);
3107 x
->d86_numopnds
= 2;
3108 dtrace_get_operand(x
, REG_ONLY
, EAX_REGNO
, wbit
, 0);
3109 if (addr_size
== SIZE64
)
3110 (void) strlcat(x
->d86_opnd
[1].d86_opnd
, "(%rdi)",
3112 else if (addr_size
== SIZE32
)
3113 (void) strlcat(x
->d86_opnd
[1].d86_opnd
, "(%edi)",
3116 (void) strlcat(x
->d86_opnd
[1].d86_opnd
, "(%di)",
3121 /* si register to accumulator */
3123 wbit
= WBIT(opcode2
);
3125 dtrace_check_override(x
, 0);
3126 x
->d86_numopnds
= 2;
3127 if (addr_size
== SIZE64
)
3128 (void) strlcat(x
->d86_opnd
[0].d86_opnd
, "(%rsi)",
3130 else if (addr_size
== SIZE32
)
3131 (void) strlcat(x
->d86_opnd
[0].d86_opnd
, "(%esi)",
3134 (void) strlcat(x
->d86_opnd
[0].d86_opnd
, "(%si)",
3136 dtrace_get_operand(x
, REG_ONLY
, EAX_REGNO
, wbit
, 1);
3141 * single operand, a 16/32 bit displacement
3145 dtrace_disp_opnd(x
, wbit
, OPSIZE(opnd_size
, LONG_OPND
), 0);
3149 /* jmp/call indirect to memory or register operand */
3152 (void) strlcat(x
->d86_opnd
[0].d86_prefix
, "*", OPLEN
);
3154 dtrace_rex_adjust(rex_prefix
, mode
, NULL
, &r_m
);
3155 dtrace_get_operand(x
, mode
, r_m
, LONG_OPND
, 0);
3160 * for long jumps and long calls -- a new code segment
3161 * register and an offset in IP -- stored in object
3162 * code in reverse order. Note - not valid in amd64
3165 dtrace_check_override(x
, 1);
3167 dtrace_imm_opnd(x
, wbit
, OPSIZE(opnd_size
, LONG_OPND
), 1);
3169 x
->d86_opnd
[1].d86_mode
= MODE_SIGNED
;
3171 /* will now get segment operand */
3172 dtrace_imm_opnd(x
, wbit
, 2, 0);
3176 * jmp/call. single operand, 8 bit displacement.
3177 * added to current EIP in 'compofff'
3180 dtrace_disp_opnd(x
, BYTE_OPND
, 1, 0);
3184 /* single 32/16 bit immediate operand */
3187 dtrace_imm_opnd(x
, wbit
, OPSIZE(opnd_size
, LONG_OPND
), 0);
3190 /* single 8 bit immediate operand */
3193 dtrace_imm_opnd(x
, wbit
, 1, 0);
3198 dtrace_imm_opnd(x
, wbit
, 2, 0);
3199 dtrace_imm_opnd(x
, wbit
, 1, 1);
3200 switch (opnd_size
) {
3202 x
->d86_memsize
= (x
->d86_opnd
[1].d86_value
+ 1) * 8;
3205 x
->d86_memsize
= (x
->d86_opnd
[1].d86_value
+ 1) * 4;
3208 x
->d86_memsize
= (x
->d86_opnd
[1].d86_value
+ 1) * 2;
3214 /* 16-bit immediate operand */
3217 dtrace_imm_opnd(x
, wbit
, 2, 0);
3220 /* single 8 bit port operand */
3222 dtrace_check_override(x
, 0);
3223 dtrace_imm_opnd(x
, BYTE_OPND
, 1, 0);
3227 /* single operand, dx register (variable port instruction) */
3229 x
->d86_numopnds
= 1;
3230 dtrace_check_override(x
, 0);
3232 (void) strlcat(x
->d86_opnd
[0].d86_opnd
, "(%dx)", OPLEN
);
3238 * The int instruction, which has two forms:
3239 * int 3 (breakpoint) or
3240 * int n, where n is indicated in the subsequent
3241 * byte (format Ib). The int 3 instruction (opcode 0xCC),
3242 * where, although the 3 looks like an operand,
3243 * it is implied by the opcode. It must be converted
3244 * to the correct base and output.
3248 x
->d86_numopnds
= 1;
3249 x
->d86_opnd
[0].d86_mode
= MODE_SIGNED
;
3250 x
->d86_opnd
[0].d86_value_size
= 1;
3251 x
->d86_opnd
[0].d86_value
= 3;
3256 /* single 8 bit immediate operand */
3258 dtrace_imm_opnd(x
, BYTE_OPND
, 1, 0);
3262 /* an unused byte must be discarded */
3264 if (x
->d86_get_byte(x
->d86_data
) < 0)
3272 if (opnd_size
== SIZE16
)
3273 (void) strlcat(x
->d86_mnem
, "cbtw", OPLEN
);
3274 else if (opnd_size
== SIZE32
)
3275 (void) strlcat(x
->d86_mnem
, "cwtl", OPLEN
);
3277 (void) strlcat(x
->d86_mnem
, "cltq", OPLEN
);
3285 if (opnd_size
== SIZE16
)
3286 (void) strlcat(x
->d86_mnem
, "cwtd", OPLEN
);
3287 else if (opnd_size
== SIZE32
)
3288 (void) strlcat(x
->d86_mnem
, "cltd", OPLEN
);
3290 (void) strlcat(x
->d86_mnem
, "cqtd", OPLEN
);
3298 * sfence is sfence if mode is REG_ONLY. If mode isn't
3299 * REG_ONLY, mnemonic should be 'clflush'.
3301 dtrace_get_modrm(x
, &mode
, ®
, &r_m
);
3303 /* sfence doesn't take operands */
3305 if (mode
== REG_ONLY
) {
3306 (void) strlcat(x
->d86_mnem
, "sfence", OPLEN
);
3308 (void) strlcat(x
->d86_mnem
, "clflush", OPLEN
);
3309 dtrace_rex_adjust(rex_prefix
, mode
, ®
, &r_m
);
3310 dtrace_get_operand(x
, mode
, r_m
, BYTE_OPND
, 0);
3314 if (mode
!= REG_ONLY
) {
3315 dtrace_rex_adjust(rex_prefix
, mode
, ®
, &r_m
);
3316 dtrace_get_operand(x
, mode
, r_m
, BYTE_OPND
, 0);
3323 * no disassembly, the mnemonic was all there was so go on
3326 if (dp
->it_invalid32
&& cpu_mode
!= SIZE64
)
3335 * Only the following exact byte sequences are allowed:
3340 if ((uint8_t)x
->d86_bytes
[x
->d86_len
- 1] != 0xe8 &&
3341 (uint8_t)x
->d86_bytes
[x
->d86_len
- 1] != 0xf0)
3350 x
->d86_numopnds
= 1;
3351 (void) strlcat(x
->d86_opnd
[0].d86_opnd
, "%st(X)", OPLEN
);
3352 x
->d86_opnd
[0].d86_opnd
[4] = r_m
+ '0';
3357 /* float reg to float reg, with ret bit present */
3359 vbit
= opcode2
>> 2 & 0x1; /* vbit = 1: st -> st(i) */
3361 case FFC
: /* case for vbit always = 0 */
3363 x
->d86_numopnds
= 2;
3364 (void) strlcat(x
->d86_opnd
[1 - vbit
].d86_opnd
, "%st", OPLEN
);
3365 (void) strlcat(x
->d86_opnd
[vbit
].d86_opnd
, "%st(X)", OPLEN
);
3366 x
->d86_opnd
[vbit
].d86_opnd
[4] = r_m
+ '0';
3371 /* an invalid op code */
3387 * compute the size of any memory accessed by the instruction
3389 if (x
->d86_memsize
!= 0) {
3391 } else if (dp
->it_stackop
) {
3392 switch (opnd_size
) {
3403 } else if (nomem
|| mode
== REG_ONLY
) {
3406 } else if (dp
->it_size
!= 0) {
3408 * In 64 bit mode descriptor table entries
3409 * go up to 10 bytes and popf/pushf are always 8 bytes
3411 if (x
->d86_mode
== SIZE64
&& dp
->it_size
== 6)
3412 x
->d86_memsize
= 10;
3413 else if (x
->d86_mode
== SIZE64
&& opcode1
== 0x9 &&
3414 (opcode2
== 0xc || opcode2
== 0xd))
3417 x
->d86_memsize
= dp
->it_size
;
3419 } else if (wbit
== 0) {
3422 } else if (wbit
== LONG_OPND
) {
3423 if (opnd_size
== SIZE64
)
3425 else if (opnd_size
== SIZE32
)
3430 } else if (wbit
== SEG_OPND
) {
3441 (void) strlcat(x
->d86_mnem
, "undef", OPLEN
);
3449 * Some instructions should have immediate operands printed
3450 * as unsigned integers. We compare against this table.
3452 static char *unsigned_ops
[] = {
3453 "or", "and", "xor", "test", "in", "out", "lcall", "ljmp",
3454 "rcr", "rcl", "ror", "rol", "shl", "shr", "sal", "psr", "psl",
3460 isunsigned_op(char *opcode
)
3464 int is_unsigned
= 0;
3467 * Work back to start of last mnemonic, since we may have
3468 * prefixes on some opcodes.
3470 where
= opcode
+ strlen(opcode
) - 1;
3471 while (where
> opcode
&& *where
!= ' ')
3476 for (i
= 0; unsigned_ops
[i
]; ++i
) {
3477 if (strncmp(where
, unsigned_ops
[i
],
3478 strlen(unsigned_ops
[i
])))
3483 return (is_unsigned
);
3487 * Print a numeric immediate into end of buf, maximum length buflen.
3488 * The immediate may be an address or a displacement. Mask is set
3489 * for address size. If the immediate is a "small negative", or
3490 * if it's a negative displacement of any magnitude, print as -<absval>.
3491 * Respect the "octal" flag. "Small negative" is defined as "in the
3492 * interval [NEG_LIMIT, 0)".
3494 * Also, "isunsigned_op()" instructions never print negatives.
3496 * Return whether we decided to print a negative value or not.
3499 #define NEG_LIMIT -255
3501 enum {POS
, TRY_NEG
};
3504 print_imm(dis86_t
*dis
, uint64_t usv
, uint64_t mask
, char *buf
,
3505 size_t buflen
, int disp
, int try_neg
)
3508 int64_t sv
= (int64_t)usv
;
3509 int octal
= dis
->d86_flags
& DIS_F_OCTAL
;
3511 curlen
= strlen(buf
);
3513 if (try_neg
== TRY_NEG
&& sv
< 0 &&
3514 (disp
|| sv
>= NEG_LIMIT
) &&
3515 !isunsigned_op(dis
->d86_mnem
)) {
3516 dis
->d86_sprintf_func(buf
+ curlen
, buflen
- curlen
,
3517 octal
? "-0%llo" : "-0x%llx", (-sv
) & mask
);
3521 dis
->d86_sprintf_func(buf
+ curlen
, buflen
- curlen
,
3522 octal
? "+0%llo" : "+0x%llx", usv
& mask
);
3524 dis
->d86_sprintf_func(buf
+ curlen
, buflen
- curlen
,
3525 octal
? "0%llo" : "0x%llx", usv
& mask
);
3546 dtrace_disx86_str(dis86_t
*dis
, uint_t mode
, uint64_t pc
, char *buf
,
3549 uint64_t reltgt
= 0;
3552 int (*lookup
)(void *, uint64_t, char *, size_t);
3555 uint64_t usv
, mask
, save_mask
, save_usv
;
3556 static uint64_t masks
[] =
3557 {0xffU
, 0xffffU
, 0xffffffffU
, 0xffffffffffffffffULL
};
3560 dis
->d86_sprintf_func(buf
, buflen
, "%-6s ", dis
->d86_mnem
);
3563 * For PC-relative jumps, the pc is really the next pc after executing
3564 * this instruction, so increment it appropriately.
3568 for (i
= 0; i
< dis
->d86_numopnds
; i
++) {
3569 d86opnd_t
*op
= &dis
->d86_opnd
[i
];
3572 (void) strlcat(buf
, ",", buflen
);
3574 (void) strlcat(buf
, op
->d86_prefix
, buflen
);
3577 * sv is for the signed, possibly-truncated immediate or
3578 * displacement; usv retains the original size and
3579 * unsignedness for symbol lookup.
3582 sv
= usv
= op
->d86_value
;
3585 * About masks: for immediates that represent
3586 * addresses, the appropriate display size is
3587 * the effective address size of the instruction.
3588 * This includes MODE_OFFSET, MODE_IPREL, and
3589 * MODE_RIPREL. Immediates that are simply
3590 * immediate values should display in the operand's
3591 * size, however, since they don't represent addresses.
3594 /* d86_addr_size is SIZEnn, which is log2(real size) */
3595 mask
= masks
[dis
->d86_addr_size
];
3597 /* d86_value_size and d86_imm_bytes are in bytes */
3598 if (op
->d86_mode
== MODE_SIGNED
||
3599 op
->d86_mode
== MODE_IMPLIED
)
3600 mask
= masks
[log2(op
->d86_value_size
)];
3602 switch (op
->d86_mode
) {
3606 (void) strlcat(buf
, op
->d86_opnd
, buflen
);
3615 if (dis
->d86_seg_prefix
)
3616 (void) strlcat(buf
, dis
->d86_seg_prefix
,
3619 if (op
->d86_mode
== MODE_SIGNED
||
3620 op
->d86_mode
== MODE_IMPLIED
) {
3621 (void) strlcat(buf
, "$", buflen
);
3624 if (print_imm(dis
, usv
, mask
, buf
, buflen
,
3626 (op
->d86_mode
== MODE_SIGNED
||
3627 op
->d86_mode
== MODE_IMPLIED
)) {
3630 * We printed a negative value for an
3631 * immediate that wasn't a
3632 * displacement. Note that fact so we can
3633 * print the positive value as an
3640 (void) strlcat(buf
, op
->d86_opnd
, buflen
);
3651 reltgt
= (uint16_t)reltgt
;
3654 reltgt
= (uint32_t)reltgt
;
3658 (void) print_imm(dis
, usv
, mask
, buf
, buflen
,
3661 if (op
->d86_mode
== MODE_RIPREL
)
3662 (void) strlcat(buf
, "(%rip)", buflen
);
3668 * The symbol lookups may result in false positives,
3669 * particularly on object files, where small numbers may match
3670 * the 0-relative non-relocated addresses of symbols.
3673 lookup
= dis
->d86_sym_lookup
;
3675 if ((dis
->d86_flags
& DIS_F_NOIMMSYM
) == 0 &&
3676 lookup(dis
->d86_data
, tgt
, NULL
, 0) == 0) {
3677 (void) strlcat(buf
, "\t<", buflen
);
3678 curlen
= strlen(buf
);
3679 lookup(dis
->d86_data
, tgt
, buf
+ curlen
,
3681 (void) strlcat(buf
, ">", buflen
);
3685 * If we printed a negative immediate above, print the
3686 * positive in case our heuristic was unhelpful
3689 (void) strlcat(buf
, "\t<", buflen
);
3690 (void) print_imm(dis
, save_usv
, save_mask
, buf
, buflen
,
3692 (void) strlcat(buf
, ">", buflen
);
3697 /* Print symbol or effective address for reltgt */
3699 (void) strlcat(buf
, "\t<", buflen
);
3700 curlen
= strlen(buf
);
3701 lookup(dis
->d86_data
, reltgt
, buf
+ curlen
,
3703 (void) strlcat(buf
, ">", buflen
);
3707 #endif /* DIS_TEXT */