1 /* Print i386 instructions for GDB, the GNU debugger.
2 Copyright (C) 1988, 89, 91, 93, 94, 95, 96, 97, 98, 1999
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 * 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu)
24 * modified by John Hassey (hassey@dg-rtp.dg.com)
28 * The main tables describing the instructions is essentially a copy
29 * of the "Opcode Map" chapter (Appendix A) of the Intel 80386
30 * Programmers Manual. Usually, there is a capital letter, followed
31 * by a small letter. The capital letter tell the addressing mode,
32 * and the small letter tells about the operand size. Refer to
33 * the Intel manual for details.
44 #ifndef UNIXWARE_COMPAT
45 /* Set non-zero for broken, compatible instructions. Set to zero for
46 non-broken opcodes. */
47 #define UNIXWARE_COMPAT 1
50 static int fetch_data
PARAMS ((struct disassemble_info
*, bfd_byte
*));
54 /* Points to first byte not fetched. */
55 bfd_byte
*max_fetched
;
56 bfd_byte the_buffer
[MAXLEN
];
61 /* The opcode for the fwait instruction, which we treat as a prefix
63 #define FWAIT_OPCODE (0x9b)
65 /* Flags for the prefixes for the current instruction. See below. */
68 /* Flags for prefixes which we somehow handled when printing the
69 current instruction. */
70 static int used_prefixes
;
72 /* Flags stored in PREFIXES. */
74 #define PREFIX_REPNZ 2
77 #define PREFIX_SS 0x10
78 #define PREFIX_DS 0x20
79 #define PREFIX_ES 0x40
80 #define PREFIX_FS 0x80
81 #define PREFIX_GS 0x100
82 #define PREFIX_DATA 0x200
83 #define PREFIX_ADDR 0x400
84 #define PREFIX_FWAIT 0x800
86 /* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
87 to ADDR (exclusive) are valid. Returns 1 for success, longjmps
89 #define FETCH_DATA(info, addr) \
90 ((addr) <= ((struct dis_private *)(info->private_data))->max_fetched \
91 ? 1 : fetch_data ((info), (addr)))
94 fetch_data (info
, addr
)
95 struct disassemble_info
*info
;
99 struct dis_private
*priv
= (struct dis_private
*)info
->private_data
;
100 bfd_vma start
= priv
->insn_start
+ (priv
->max_fetched
- priv
->the_buffer
);
102 status
= (*info
->read_memory_func
) (start
,
104 addr
- priv
->max_fetched
,
108 /* If we did manage to read at least one byte, then
109 print_insn_i386 will do something sensible. Otherwise, print
110 an error. We do that here because this is where we know
112 if (priv
->max_fetched
== priv
->the_buffer
)
113 (*info
->memory_error_func
) (status
, start
, info
);
114 longjmp (priv
->bailout
, 1);
117 priv
->max_fetched
= addr
;
123 #define Eb OP_E, b_mode
124 #define indirEb OP_indirE, b_mode
125 #define Gb OP_G, b_mode
126 #define Ev OP_E, v_mode
127 #define Ed OP_E, d_mode
128 #define indirEv OP_indirE, v_mode
129 #define Ew OP_E, w_mode
130 #define Ma OP_E, v_mode
131 #define M OP_E, 0 /* lea */
132 #define Mp OP_E, 0 /* 32 or 48 bit memory operand for LDS, LES etc */
133 #define Gv OP_G, v_mode
134 #define Gw OP_G, w_mode
135 #define Rd OP_Rd, d_mode
136 #define Ib OP_I, b_mode
137 #define sIb OP_sI, b_mode /* sign extened byte */
138 #define Iv OP_I, v_mode
139 #define Iw OP_I, w_mode
140 #define Jb OP_J, b_mode
141 #define Jv OP_J, v_mode
142 #define Cd OP_C, d_mode
143 #define Dd OP_D, d_mode
144 #define Td OP_T, d_mode
146 #define eAX OP_REG, eAX_reg
147 #define eBX OP_REG, eBX_reg
148 #define eCX OP_REG, eCX_reg
149 #define eDX OP_REG, eDX_reg
150 #define eSP OP_REG, eSP_reg
151 #define eBP OP_REG, eBP_reg
152 #define eSI OP_REG, eSI_reg
153 #define eDI OP_REG, eDI_reg
154 #define AL OP_REG, al_reg
155 #define CL OP_REG, cl_reg
156 #define DL OP_REG, dl_reg
157 #define BL OP_REG, bl_reg
158 #define AH OP_REG, ah_reg
159 #define CH OP_REG, ch_reg
160 #define DH OP_REG, dh_reg
161 #define BH OP_REG, bh_reg
162 #define AX OP_REG, ax_reg
163 #define DX OP_REG, dx_reg
164 #define indirDX OP_REG, indir_dx_reg
166 #define Sw OP_SEG, w_mode
168 #define Ob OP_OFF, b_mode
169 #define Ov OP_OFF, v_mode
170 #define Xb OP_DSreg, eSI_reg
171 #define Xv OP_DSreg, eSI_reg
172 #define Yb OP_ESreg, eDI_reg
173 #define Yv OP_ESreg, eDI_reg
174 #define DSBX OP_DSreg, eBX_reg
176 #define es OP_REG, es_reg
177 #define ss OP_REG, ss_reg
178 #define cs OP_REG, cs_reg
179 #define ds OP_REG, ds_reg
180 #define fs OP_REG, fs_reg
181 #define gs OP_REG, gs_reg
185 #define EM OP_EM, v_mode
186 #define EX OP_EX, v_mode
187 #define MS OP_MS, v_mode
189 #define OPSUF OP_3DNowSuffix, 0
190 #define OPSIMD OP_SIMD_Suffix, 0
192 /* bits in sizeflag */
193 #if 0 /* leave undefined until someone adds the extra flag to objdump */
194 #define SUFFIX_ALWAYS 4
199 typedef void (*op_rtn
) PARAMS ((int bytemode
, int sizeflag
));
201 static void OP_E
PARAMS ((int, int));
202 static void OP_G
PARAMS ((int, int));
203 static void OP_I
PARAMS ((int, int));
204 static void OP_indirE
PARAMS ((int, int));
205 static void OP_sI
PARAMS ((int, int));
206 static void OP_REG
PARAMS ((int, int));
207 static void OP_J
PARAMS ((int, int));
208 static void OP_DIR
PARAMS ((int, int));
209 static void OP_OFF
PARAMS ((int, int));
210 static void OP_ESreg
PARAMS ((int, int));
211 static void OP_DSreg
PARAMS ((int, int));
212 static void OP_SEG
PARAMS ((int, int));
213 static void OP_C
PARAMS ((int, int));
214 static void OP_D
PARAMS ((int, int));
215 static void OP_T
PARAMS ((int, int));
216 static void OP_Rd
PARAMS ((int, int));
217 static void OP_ST
PARAMS ((int, int));
218 static void OP_STi
PARAMS ((int, int));
219 static void OP_MMX
PARAMS ((int, int));
220 static void OP_XMM
PARAMS ((int, int));
221 static void OP_EM
PARAMS ((int, int));
222 static void OP_EX
PARAMS ((int, int));
223 static void OP_MS
PARAMS ((int, int));
224 static void OP_3DNowSuffix
PARAMS ((int, int));
225 static void OP_SIMD_Suffix
PARAMS ((int, int));
226 static void SIMD_Fixup
PARAMS ((int, int));
228 static void append_seg
PARAMS ((void));
229 static void set_op
PARAMS ((unsigned int op
));
230 static void putop
PARAMS ((const char *template, int sizeflag
));
231 static void dofloat
PARAMS ((int sizeflag
));
232 static int get16
PARAMS ((void));
233 static int get32
PARAMS ((void));
234 static void ckprefix
PARAMS ((void));
235 static const char *prefix_name
PARAMS ((int, int));
236 static void ptr_reg
PARAMS ((int, int));
237 static void BadOp
PARAMS ((void));
279 #define indir_dx_reg 150
282 #define USE_PREFIX_USER_TABLE 2
284 #define GRP1b NULL, NULL, 0, NULL, USE_GROUPS, NULL, 0
285 #define GRP1S NULL, NULL, 1, NULL, USE_GROUPS, NULL, 0
286 #define GRP1Ss NULL, NULL, 2, NULL, USE_GROUPS, NULL, 0
287 #define GRP2b NULL, NULL, 3, NULL, USE_GROUPS, NULL, 0
288 #define GRP2S NULL, NULL, 4, NULL, USE_GROUPS, NULL, 0
289 #define GRP2b_one NULL, NULL, 5, NULL, USE_GROUPS, NULL, 0
290 #define GRP2S_one NULL, NULL, 6, NULL, USE_GROUPS, NULL, 0
291 #define GRP2b_cl NULL, NULL, 7, NULL, USE_GROUPS, NULL, 0
292 #define GRP2S_cl NULL, NULL, 8, NULL, USE_GROUPS, NULL, 0
293 #define GRP3b NULL, NULL, 9, NULL, USE_GROUPS, NULL, 0
294 #define GRP3S NULL, NULL, 10, NULL, USE_GROUPS, NULL, 0
295 #define GRP4 NULL, NULL, 11, NULL, USE_GROUPS, NULL, 0
296 #define GRP5 NULL, NULL, 12, NULL, USE_GROUPS, NULL, 0
297 #define GRP6 NULL, NULL, 13, NULL, USE_GROUPS, NULL, 0
298 #define GRP7 NULL, NULL, 14, NULL, USE_GROUPS, NULL, 0
299 #define GRP8 NULL, NULL, 15, NULL, USE_GROUPS, NULL, 0
300 #define GRP9 NULL, NULL, 16, NULL, USE_GROUPS, NULL, 0
301 #define GRP10 NULL, NULL, 17, NULL, USE_GROUPS, NULL, 0
302 #define GRP11 NULL, NULL, 18, NULL, USE_GROUPS, NULL, 0
303 #define GRP12 NULL, NULL, 19, NULL, USE_GROUPS, NULL, 0
304 #define GRP13 NULL, NULL, 20, NULL, USE_GROUPS, NULL, 0
305 #define GRP14 NULL, NULL, 21, NULL, USE_GROUPS, NULL, 0
306 #define GRPAMD NULL, NULL, 22, NULL, USE_GROUPS, NULL, 0
308 #define PREGRP0 NULL, NULL, 0, NULL, USE_PREFIX_USER_TABLE, NULL, 0
309 #define PREGRP1 NULL, NULL, 1, NULL, USE_PREFIX_USER_TABLE, NULL, 0
310 #define PREGRP2 NULL, NULL, 2, NULL, USE_PREFIX_USER_TABLE, NULL, 0
311 #define PREGRP3 NULL, NULL, 3, NULL, USE_PREFIX_USER_TABLE, NULL, 0
312 #define PREGRP4 NULL, NULL, 4, NULL, USE_PREFIX_USER_TABLE, NULL, 0
313 #define PREGRP5 NULL, NULL, 5, NULL, USE_PREFIX_USER_TABLE, NULL, 0
314 #define PREGRP6 NULL, NULL, 6, NULL, USE_PREFIX_USER_TABLE, NULL, 0
315 #define PREGRP7 NULL, NULL, 7, NULL, USE_PREFIX_USER_TABLE, NULL, 0
316 #define PREGRP8 NULL, NULL, 8, NULL, USE_PREFIX_USER_TABLE, NULL, 0
317 #define PREGRP9 NULL, NULL, 9, NULL, USE_PREFIX_USER_TABLE, NULL, 0
318 #define PREGRP10 NULL, NULL, 10, NULL, USE_PREFIX_USER_TABLE, NULL, 0
319 #define PREGRP11 NULL, NULL, 11, NULL, USE_PREFIX_USER_TABLE, NULL, 0
320 #define PREGRP12 NULL, NULL, 12, NULL, USE_PREFIX_USER_TABLE, NULL, 0
321 #define PREGRP13 NULL, NULL, 13, NULL, USE_PREFIX_USER_TABLE, NULL, 0
322 #define PREGRP14 NULL, NULL, 14, NULL, USE_PREFIX_USER_TABLE, NULL, 0
325 #define FLOAT NULL, NULL, FLOATCODE, NULL, 0, NULL, 0
337 /* Upper case letters in the instruction names here are macros.
338 'A' => print 'b' if no register operands or suffix_always is true
339 'B' => print 'b' if suffix_always is true
340 'E' => print 'e' if 32-bit form of jcxz
341 'L' => print 'l' if suffix_always is true
342 'N' => print 'n' if instruction has no wait "prefix"
343 'P' => print 'w' or 'l' if instruction has an operand size prefix,
344 or suffix_always is true
345 'Q' => print 'w' or 'l' if no register operands or suffix_always is true
346 'R' => print 'w' or 'l' ("wd" or "dq" in intel mode)
347 'S' => print 'w' or 'l' if suffix_always is true
348 'W' => print 'b' or 'w' ("w" or "de" in intel mode)
351 static const struct dis386 dis386_att
[] = {
353 { "addB", Eb
, Gb
, XX
},
354 { "addS", Ev
, Gv
, XX
},
355 { "addB", Gb
, Eb
, XX
},
356 { "addS", Gv
, Ev
, XX
},
357 { "addB", AL
, Ib
, XX
},
358 { "addS", eAX
, Iv
, XX
},
359 { "pushP", es
, XX
, XX
},
360 { "popP", es
, XX
, XX
},
362 { "orB", Eb
, Gb
, XX
},
363 { "orS", Ev
, Gv
, XX
},
364 { "orB", Gb
, Eb
, XX
},
365 { "orS", Gv
, Ev
, XX
},
366 { "orB", AL
, Ib
, XX
},
367 { "orS", eAX
, Iv
, XX
},
368 { "pushP", cs
, XX
, XX
},
369 { "(bad)", XX
, XX
, XX
}, /* 0x0f extended opcode escape */
371 { "adcB", Eb
, Gb
, XX
},
372 { "adcS", Ev
, Gv
, XX
},
373 { "adcB", Gb
, Eb
, XX
},
374 { "adcS", Gv
, Ev
, XX
},
375 { "adcB", AL
, Ib
, XX
},
376 { "adcS", eAX
, Iv
, XX
},
377 { "pushP", ss
, XX
, XX
},
378 { "popP", ss
, XX
, XX
},
380 { "sbbB", Eb
, Gb
, XX
},
381 { "sbbS", Ev
, Gv
, XX
},
382 { "sbbB", Gb
, Eb
, XX
},
383 { "sbbS", Gv
, Ev
, XX
},
384 { "sbbB", AL
, Ib
, XX
},
385 { "sbbS", eAX
, Iv
, XX
},
386 { "pushP", ds
, XX
, XX
},
387 { "popP", ds
, XX
, XX
},
389 { "andB", Eb
, Gb
, XX
},
390 { "andS", Ev
, Gv
, XX
},
391 { "andB", Gb
, Eb
, XX
},
392 { "andS", Gv
, Ev
, XX
},
393 { "andB", AL
, Ib
, XX
},
394 { "andS", eAX
, Iv
, XX
},
395 { "(bad)", XX
, XX
, XX
}, /* SEG ES prefix */
396 { "daa", XX
, XX
, XX
},
398 { "subB", Eb
, Gb
, XX
},
399 { "subS", Ev
, Gv
, XX
},
400 { "subB", Gb
, Eb
, XX
},
401 { "subS", Gv
, Ev
, XX
},
402 { "subB", AL
, Ib
, XX
},
403 { "subS", eAX
, Iv
, XX
},
404 { "(bad)", XX
, XX
, XX
}, /* SEG CS prefix */
405 { "das", XX
, XX
, XX
},
407 { "xorB", Eb
, Gb
, XX
},
408 { "xorS", Ev
, Gv
, XX
},
409 { "xorB", Gb
, Eb
, XX
},
410 { "xorS", Gv
, Ev
, XX
},
411 { "xorB", AL
, Ib
, XX
},
412 { "xorS", eAX
, Iv
, XX
},
413 { "(bad)", XX
, XX
, XX
}, /* SEG SS prefix */
414 { "aaa", XX
, XX
, XX
},
416 { "cmpB", Eb
, Gb
, XX
},
417 { "cmpS", Ev
, Gv
, XX
},
418 { "cmpB", Gb
, Eb
, XX
},
419 { "cmpS", Gv
, Ev
, XX
},
420 { "cmpB", AL
, Ib
, XX
},
421 { "cmpS", eAX
, Iv
, XX
},
422 { "(bad)", XX
, XX
, XX
}, /* SEG DS prefix */
423 { "aas", XX
, XX
, XX
},
425 { "incS", eAX
, XX
, XX
},
426 { "incS", eCX
, XX
, XX
},
427 { "incS", eDX
, XX
, XX
},
428 { "incS", eBX
, XX
, XX
},
429 { "incS", eSP
, XX
, XX
},
430 { "incS", eBP
, XX
, XX
},
431 { "incS", eSI
, XX
, XX
},
432 { "incS", eDI
, XX
, XX
},
434 { "decS", eAX
, XX
, XX
},
435 { "decS", eCX
, XX
, XX
},
436 { "decS", eDX
, XX
, XX
},
437 { "decS", eBX
, XX
, XX
},
438 { "decS", eSP
, XX
, XX
},
439 { "decS", eBP
, XX
, XX
},
440 { "decS", eSI
, XX
, XX
},
441 { "decS", eDI
, XX
, XX
},
443 { "pushS", eAX
, XX
, XX
},
444 { "pushS", eCX
, XX
, XX
},
445 { "pushS", eDX
, XX
, XX
},
446 { "pushS", eBX
, XX
, XX
},
447 { "pushS", eSP
, XX
, XX
},
448 { "pushS", eBP
, XX
, XX
},
449 { "pushS", eSI
, XX
, XX
},
450 { "pushS", eDI
, XX
, XX
},
452 { "popS", eAX
, XX
, XX
},
453 { "popS", eCX
, XX
, XX
},
454 { "popS", eDX
, XX
, XX
},
455 { "popS", eBX
, XX
, XX
},
456 { "popS", eSP
, XX
, XX
},
457 { "popS", eBP
, XX
, XX
},
458 { "popS", eSI
, XX
, XX
},
459 { "popS", eDI
, XX
, XX
},
461 { "pushaP", XX
, XX
, XX
},
462 { "popaP", XX
, XX
, XX
},
463 { "boundS", Gv
, Ma
, XX
},
464 { "arpl", Ew
, Gw
, XX
},
465 { "(bad)", XX
, XX
, XX
}, /* seg fs */
466 { "(bad)", XX
, XX
, XX
}, /* seg gs */
467 { "(bad)", XX
, XX
, XX
}, /* op size prefix */
468 { "(bad)", XX
, XX
, XX
}, /* adr size prefix */
470 { "pushP", Iv
, XX
, XX
}, /* 386 book wrong */
471 { "imulS", Gv
, Ev
, Iv
},
472 { "pushP", sIb
, XX
, XX
}, /* push of byte really pushes 2 or 4 bytes */
473 { "imulS", Gv
, Ev
, sIb
},
474 { "insb", Yb
, indirDX
, XX
},
475 { "insR", Yv
, indirDX
, XX
},
476 { "outsb", indirDX
, Xb
, XX
},
477 { "outsR", indirDX
, Xv
, XX
},
479 { "jo", Jb
, XX
, XX
},
480 { "jno", Jb
, XX
, XX
},
481 { "jb", Jb
, XX
, XX
},
482 { "jae", Jb
, XX
, XX
},
483 { "je", Jb
, XX
, XX
},
484 { "jne", Jb
, XX
, XX
},
485 { "jbe", Jb
, XX
, XX
},
486 { "ja", Jb
, XX
, XX
},
488 { "js", Jb
, XX
, XX
},
489 { "jns", Jb
, XX
, XX
},
490 { "jp", Jb
, XX
, XX
},
491 { "jnp", Jb
, XX
, XX
},
492 { "jl", Jb
, XX
, XX
},
493 { "jge", Jb
, XX
, XX
},
494 { "jle", Jb
, XX
, XX
},
495 { "jg", Jb
, XX
, XX
},
499 { "(bad)", XX
, XX
, XX
},
501 { "testB", Eb
, Gb
, XX
},
502 { "testS", Ev
, Gv
, XX
},
503 { "xchgB", Eb
, Gb
, XX
},
504 { "xchgS", Ev
, Gv
, XX
},
506 { "movB", Eb
, Gb
, XX
},
507 { "movS", Ev
, Gv
, XX
},
508 { "movB", Gb
, Eb
, XX
},
509 { "movS", Gv
, Ev
, XX
},
510 { "movQ", Ev
, Sw
, XX
},
511 { "leaS", Gv
, M
, XX
},
512 { "movQ", Sw
, Ev
, XX
},
513 { "popQ", Ev
, XX
, XX
},
515 { "nop", XX
, XX
, XX
},
516 { "xchgS", eCX
, eAX
, XX
},
517 { "xchgS", eDX
, eAX
, XX
},
518 { "xchgS", eBX
, eAX
, XX
},
519 { "xchgS", eSP
, eAX
, XX
},
520 { "xchgS", eBP
, eAX
, XX
},
521 { "xchgS", eSI
, eAX
, XX
},
522 { "xchgS", eDI
, eAX
, XX
},
524 { "cWtR", XX
, XX
, XX
},
525 { "cRtd", XX
, XX
, XX
},
526 { "lcallP", Ap
, XX
, XX
},
527 { "(bad)", XX
, XX
, XX
}, /* fwait */
528 { "pushfP", XX
, XX
, XX
},
529 { "popfP", XX
, XX
, XX
},
530 { "sahf", XX
, XX
, XX
},
531 { "lahf", XX
, XX
, XX
},
533 { "movB", AL
, Ob
, XX
},
534 { "movS", eAX
, Ov
, XX
},
535 { "movB", Ob
, AL
, XX
},
536 { "movS", Ov
, eAX
, XX
},
537 { "movsb", Yb
, Xb
, XX
},
538 { "movsR", Yv
, Xv
, XX
},
539 { "cmpsb", Xb
, Yb
, XX
},
540 { "cmpsR", Xv
, Yv
, XX
},
542 { "testB", AL
, Ib
, XX
},
543 { "testS", eAX
, Iv
, XX
},
544 { "stosB", Yb
, AL
, XX
},
545 { "stosS", Yv
, eAX
, XX
},
546 { "lodsB", AL
, Xb
, XX
},
547 { "lodsS", eAX
, Xv
, XX
},
548 { "scasB", AL
, Yb
, XX
},
549 { "scasS", eAX
, Yv
, XX
},
551 { "movB", AL
, Ib
, XX
},
552 { "movB", CL
, Ib
, XX
},
553 { "movB", DL
, Ib
, XX
},
554 { "movB", BL
, Ib
, XX
},
555 { "movB", AH
, Ib
, XX
},
556 { "movB", CH
, Ib
, XX
},
557 { "movB", DH
, Ib
, XX
},
558 { "movB", BH
, Ib
, XX
},
560 { "movS", eAX
, Iv
, XX
},
561 { "movS", eCX
, Iv
, XX
},
562 { "movS", eDX
, Iv
, XX
},
563 { "movS", eBX
, Iv
, XX
},
564 { "movS", eSP
, Iv
, XX
},
565 { "movS", eBP
, Iv
, XX
},
566 { "movS", eSI
, Iv
, XX
},
567 { "movS", eDI
, Iv
, XX
},
571 { "retP", Iw
, XX
, XX
},
572 { "retP", XX
, XX
, XX
},
573 { "lesS", Gv
, Mp
, XX
},
574 { "ldsS", Gv
, Mp
, XX
},
575 { "movA", Eb
, Ib
, XX
},
576 { "movQ", Ev
, Iv
, XX
},
578 { "enterP", Iw
, Ib
, XX
},
579 { "leaveP", XX
, XX
, XX
},
580 { "lretP", Iw
, XX
, XX
},
581 { "lretP", XX
, XX
, XX
},
582 { "int3", XX
, XX
, XX
},
583 { "int", Ib
, XX
, XX
},
584 { "into", XX
, XX
, XX
},
585 { "iretP", XX
, XX
, XX
},
591 { "aam", sIb
, XX
, XX
},
592 { "aad", sIb
, XX
, XX
},
593 { "(bad)", XX
, XX
, XX
},
594 { "xlat", DSBX
, XX
, XX
},
605 { "loopne", Jb
, XX
, XX
},
606 { "loope", Jb
, XX
, XX
},
607 { "loop", Jb
, XX
, XX
},
608 { "jEcxz", Jb
, XX
, XX
},
609 { "inB", AL
, Ib
, XX
},
610 { "inS", eAX
, Ib
, XX
},
611 { "outB", Ib
, AL
, XX
},
612 { "outS", Ib
, eAX
, XX
},
614 { "callP", Jv
, XX
, XX
},
615 { "jmpP", Jv
, XX
, XX
},
616 { "ljmpP", Ap
, XX
, XX
},
617 { "jmp", Jb
, XX
, XX
},
618 { "inB", AL
, indirDX
, XX
},
619 { "inS", eAX
, indirDX
, XX
},
620 { "outB", indirDX
, AL
, XX
},
621 { "outS", indirDX
, eAX
, XX
},
623 { "(bad)", XX
, XX
, XX
}, /* lock prefix */
624 { "(bad)", XX
, XX
, XX
},
625 { "(bad)", XX
, XX
, XX
}, /* repne */
626 { "(bad)", XX
, XX
, XX
}, /* repz */
627 { "hlt", XX
, XX
, XX
},
628 { "cmc", XX
, XX
, XX
},
632 { "clc", XX
, XX
, XX
},
633 { "stc", XX
, XX
, XX
},
634 { "cli", XX
, XX
, XX
},
635 { "sti", XX
, XX
, XX
},
636 { "cld", XX
, XX
, XX
},
637 { "std", XX
, XX
, XX
},
642 static const struct dis386 dis386_intel
[] = {
644 { "add", Eb
, Gb
, XX
},
645 { "add", Ev
, Gv
, XX
},
646 { "add", Gb
, Eb
, XX
},
647 { "add", Gv
, Ev
, XX
},
648 { "add", AL
, Ib
, XX
},
649 { "add", eAX
, Iv
, XX
},
650 { "push", es
, XX
, XX
},
651 { "pop", es
, XX
, XX
},
653 { "or", Eb
, Gb
, XX
},
654 { "or", Ev
, Gv
, XX
},
655 { "or", Gb
, Eb
, XX
},
656 { "or", Gv
, Ev
, XX
},
657 { "or", AL
, Ib
, XX
},
658 { "or", eAX
, Iv
, XX
},
659 { "push", cs
, XX
, XX
},
660 { "(bad)", XX
, XX
, XX
}, /* 0x0f extended opcode escape */
662 { "adc", Eb
, Gb
, XX
},
663 { "adc", Ev
, Gv
, XX
},
664 { "adc", Gb
, Eb
, XX
},
665 { "adc", Gv
, Ev
, XX
},
666 { "adc", AL
, Ib
, XX
},
667 { "adc", eAX
, Iv
, XX
},
668 { "push", ss
, XX
, XX
},
669 { "pop", ss
, XX
, XX
},
671 { "sbb", Eb
, Gb
, XX
},
672 { "sbb", Ev
, Gv
, XX
},
673 { "sbb", Gb
, Eb
, XX
},
674 { "sbb", Gv
, Ev
, XX
},
675 { "sbb", AL
, Ib
, XX
},
676 { "sbb", eAX
, Iv
, XX
},
677 { "push", ds
, XX
, XX
},
678 { "pop", ds
, XX
, XX
},
680 { "and", Eb
, Gb
, XX
},
681 { "and", Ev
, Gv
, XX
},
682 { "and", Gb
, Eb
, XX
},
683 { "and", Gv
, Ev
, XX
},
684 { "and", AL
, Ib
, XX
},
685 { "and", eAX
, Iv
, XX
},
686 { "(bad)", XX
, XX
, XX
}, /* SEG ES prefix */
687 { "daa", XX
, XX
, XX
},
689 { "sub", Eb
, Gb
, XX
},
690 { "sub", Ev
, Gv
, XX
},
691 { "sub", Gb
, Eb
, XX
},
692 { "sub", Gv
, Ev
, XX
},
693 { "sub", AL
, Ib
, XX
},
694 { "sub", eAX
, Iv
, XX
},
695 { "(bad)", XX
, XX
, XX
}, /* SEG CS prefix */
696 { "das", XX
, XX
, XX
},
698 { "xor", Eb
, Gb
, XX
},
699 { "xor", Ev
, Gv
, XX
},
700 { "xor", Gb
, Eb
, XX
},
701 { "xor", Gv
, Ev
, XX
},
702 { "xor", AL
, Ib
, XX
},
703 { "xor", eAX
, Iv
, XX
},
704 { "(bad)", XX
, XX
, XX
}, /* SEG SS prefix */
705 { "aaa", XX
, XX
, XX
},
707 { "cmp", Eb
, Gb
, XX
},
708 { "cmp", Ev
, Gv
, XX
},
709 { "cmp", Gb
, Eb
, XX
},
710 { "cmp", Gv
, Ev
, XX
},
711 { "cmp", AL
, Ib
, XX
},
712 { "cmp", eAX
, Iv
, XX
},
713 { "(bad)", XX
, XX
, XX
}, /* SEG DS prefix */
714 { "aas", XX
, XX
, XX
},
716 { "inc", eAX
, XX
, XX
},
717 { "inc", eCX
, XX
, XX
},
718 { "inc", eDX
, XX
, XX
},
719 { "inc", eBX
, XX
, XX
},
720 { "inc", eSP
, XX
, XX
},
721 { "inc", eBP
, XX
, XX
},
722 { "inc", eSI
, XX
, XX
},
723 { "inc", eDI
, XX
, XX
},
725 { "dec", eAX
, XX
, XX
},
726 { "dec", eCX
, XX
, XX
},
727 { "dec", eDX
, XX
, XX
},
728 { "dec", eBX
, XX
, XX
},
729 { "dec", eSP
, XX
, XX
},
730 { "dec", eBP
, XX
, XX
},
731 { "dec", eSI
, XX
, XX
},
732 { "dec", eDI
, XX
, XX
},
734 { "push", eAX
, XX
, XX
},
735 { "push", eCX
, XX
, XX
},
736 { "push", eDX
, XX
, XX
},
737 { "push", eBX
, XX
, XX
},
738 { "push", eSP
, XX
, XX
},
739 { "push", eBP
, XX
, XX
},
740 { "push", eSI
, XX
, XX
},
741 { "push", eDI
, XX
, XX
},
743 { "pop", eAX
, XX
, XX
},
744 { "pop", eCX
, XX
, XX
},
745 { "pop", eDX
, XX
, XX
},
746 { "pop", eBX
, XX
, XX
},
747 { "pop", eSP
, XX
, XX
},
748 { "pop", eBP
, XX
, XX
},
749 { "pop", eSI
, XX
, XX
},
750 { "pop", eDI
, XX
, XX
},
752 { "pusha", XX
, XX
, XX
},
753 { "popa", XX
, XX
, XX
},
754 { "bound", Gv
, Ma
, XX
},
755 { "arpl", Ew
, Gw
, XX
},
756 { "(bad)", XX
, XX
, XX
}, /* seg fs */
757 { "(bad)", XX
, XX
, XX
}, /* seg gs */
758 { "(bad)", XX
, XX
, XX
}, /* op size prefix */
759 { "(bad)", XX
, XX
, XX
}, /* adr size prefix */
761 { "push", Iv
, XX
, XX
}, /* 386 book wrong */
762 { "imul", Gv
, Ev
, Iv
},
763 { "push", sIb
, XX
, XX
}, /* push of byte really pushes 2 or 4 bytes */
764 { "imul", Gv
, Ev
, sIb
},
765 { "ins", Yb
, indirDX
, XX
},
766 { "ins", Yv
, indirDX
, XX
},
767 { "outs", indirDX
, Xb
, XX
},
768 { "outs", indirDX
, Xv
, XX
},
770 { "jo", Jb
, XX
, XX
},
771 { "jno", Jb
, XX
, XX
},
772 { "jb", Jb
, XX
, XX
},
773 { "jae", Jb
, XX
, XX
},
774 { "je", Jb
, XX
, XX
},
775 { "jne", Jb
, XX
, XX
},
776 { "jbe", Jb
, XX
, XX
},
777 { "ja", Jb
, XX
, XX
},
779 { "js", Jb
, XX
, XX
},
780 { "jns", Jb
, XX
, XX
},
781 { "jp", Jb
, XX
, XX
},
782 { "jnp", Jb
, XX
, XX
},
783 { "jl", Jb
, XX
, XX
},
784 { "jge", Jb
, XX
, XX
},
785 { "jle", Jb
, XX
, XX
},
786 { "jg", Jb
, XX
, XX
},
790 { "(bad)", XX
, XX
, XX
},
792 { "test", Eb
, Gb
, XX
},
793 { "test", Ev
, Gv
, XX
},
794 { "xchg", Eb
, Gb
, XX
},
795 { "xchg", Ev
, Gv
, XX
},
797 { "mov", Eb
, Gb
, XX
},
798 { "mov", Ev
, Gv
, XX
},
799 { "mov", Gb
, Eb
, XX
},
800 { "mov", Gv
, Ev
, XX
},
801 { "mov", Ev
, Sw
, XX
},
802 { "lea", Gv
, M
, XX
},
803 { "mov", Sw
, Ev
, XX
},
804 { "pop", Ev
, XX
, XX
},
806 { "nop", XX
, XX
, XX
},
807 { "xchg", eCX
, eAX
, XX
},
808 { "xchg", eDX
, eAX
, XX
},
809 { "xchg", eBX
, eAX
, XX
},
810 { "xchg", eSP
, eAX
, XX
},
811 { "xchg", eBP
, eAX
, XX
},
812 { "xchg", eSI
, eAX
, XX
},
813 { "xchg", eDI
, eAX
, XX
},
815 { "cW", XX
, XX
, XX
}, /* cwde and cbw */
816 { "cR", XX
, XX
, XX
}, /* cdq and cwd */
817 { "lcall", Ap
, XX
, XX
},
818 { "(bad)", XX
, XX
, XX
}, /* fwait */
819 { "pushf", XX
, XX
, XX
},
820 { "popf", XX
, XX
, XX
},
821 { "sahf", XX
, XX
, XX
},
822 { "lahf", XX
, XX
, XX
},
824 { "mov", AL
, Ob
, XX
},
825 { "mov", eAX
, Ov
, XX
},
826 { "mov", Ob
, AL
, XX
},
827 { "mov", Ov
, eAX
, XX
},
828 { "movs", Yb
, Xb
, XX
},
829 { "movs", Yv
, Xv
, XX
},
830 { "cmps", Xb
, Yb
, XX
},
831 { "cmps", Xv
, Yv
, XX
},
833 { "test", AL
, Ib
, XX
},
834 { "test", eAX
, Iv
, XX
},
835 { "stos", Yb
, AL
, XX
},
836 { "stos", Yv
, eAX
, XX
},
837 { "lods", AL
, Xb
, XX
},
838 { "lods", eAX
, Xv
, XX
},
839 { "scas", AL
, Yb
, XX
},
840 { "scas", eAX
, Yv
, XX
},
842 { "mov", AL
, Ib
, XX
},
843 { "mov", CL
, Ib
, XX
},
844 { "mov", DL
, Ib
, XX
},
845 { "mov", BL
, Ib
, XX
},
846 { "mov", AH
, Ib
, XX
},
847 { "mov", CH
, Ib
, XX
},
848 { "mov", DH
, Ib
, XX
},
849 { "mov", BH
, Ib
, XX
},
851 { "mov", eAX
, Iv
, XX
},
852 { "mov", eCX
, Iv
, XX
},
853 { "mov", eDX
, Iv
, XX
},
854 { "mov", eBX
, Iv
, XX
},
855 { "mov", eSP
, Iv
, XX
},
856 { "mov", eBP
, Iv
, XX
},
857 { "mov", eSI
, Iv
, XX
},
858 { "mov", eDI
, Iv
, XX
},
862 { "ret", Iw
, XX
, XX
},
863 { "ret", XX
, XX
, XX
},
864 { "les", Gv
, Mp
, XX
},
865 { "lds", Gv
, Mp
, XX
},
866 { "mov", Eb
, Ib
, XX
},
867 { "mov", Ev
, Iv
, XX
},
869 { "enter", Iw
, Ib
, XX
},
870 { "leave", XX
, XX
, XX
},
871 { "lret", Iw
, XX
, XX
},
872 { "lret", XX
, XX
, XX
},
873 { "int3", XX
, XX
, XX
},
874 { "int", Ib
, XX
, XX
},
875 { "into", XX
, XX
, XX
},
876 { "iret", XX
, XX
, XX
},
882 { "aam", sIb
, XX
, XX
},
883 { "aad", sIb
, XX
, XX
},
884 { "(bad)", XX
, XX
, XX
},
885 { "xlat", DSBX
, XX
, XX
},
896 { "loopne", Jb
, XX
, XX
},
897 { "loope", Jb
, XX
, XX
},
898 { "loop", Jb
, XX
, XX
},
899 { "jEcxz", Jb
, XX
, XX
},
900 { "in", AL
, Ib
, XX
},
901 { "in", eAX
, Ib
, XX
},
902 { "out", Ib
, AL
, XX
},
903 { "out", Ib
, eAX
, XX
},
905 { "call", Jv
, XX
, XX
},
906 { "jmp", Jv
, XX
, XX
},
907 { "ljmp", Ap
, XX
, XX
},
908 { "jmp", Jb
, XX
, XX
},
909 { "in", AL
, indirDX
, XX
},
910 { "in", eAX
, indirDX
, XX
},
911 { "out", indirDX
, AL
, XX
},
912 { "out", indirDX
, eAX
, XX
},
914 { "(bad)", XX
, XX
, XX
}, /* lock prefix */
915 { "(bad)", XX
, XX
, XX
},
916 { "(bad)", XX
, XX
, XX
}, /* repne */
917 { "(bad)", XX
, XX
, XX
}, /* repz */
918 { "hlt", XX
, XX
, XX
},
919 { "cmc", XX
, XX
, XX
},
923 { "clc", XX
, XX
, XX
},
924 { "stc", XX
, XX
, XX
},
925 { "cli", XX
, XX
, XX
},
926 { "sti", XX
, XX
, XX
},
927 { "cld", XX
, XX
, XX
},
928 { "std", XX
, XX
, XX
},
933 static const struct dis386 dis386_twobyte_att
[] = {
937 { "larS", Gv
, Ew
, XX
},
938 { "lslS", Gv
, Ew
, XX
},
939 { "(bad)", XX
, XX
, XX
},
940 { "(bad)", XX
, XX
, XX
},
941 { "clts", XX
, XX
, XX
},
942 { "(bad)", XX
, XX
, XX
},
944 { "invd", XX
, XX
, XX
},
945 { "wbinvd", XX
, XX
, XX
},
946 { "(bad)", XX
, XX
, XX
},
947 { "ud2a", XX
, XX
, XX
},
948 { "(bad)", XX
, XX
, XX
},
950 { "femms", XX
, XX
, XX
},
951 { "", MX
, EM
, OPSUF
}, /* See OP_3DNowSuffix */
955 { "movlps", XM
, EX
, SIMD_Fixup
, 'h' }, /* really only 2 operands */
956 { "movlps", EX
, XM
, SIMD_Fixup
, 'h' },
957 { "unpcklps", XM
, EX
, XX
},
958 { "unpckhps", XM
, EX
, XX
},
959 { "movhps", XM
, EX
, SIMD_Fixup
, 'l' },
960 { "movhps", EX
, XM
, SIMD_Fixup
, 'l' },
963 { "(bad)", XX
, XX
, XX
},
964 { "(bad)", XX
, XX
, XX
},
965 { "(bad)", XX
, XX
, XX
},
966 { "(bad)", XX
, XX
, XX
},
967 { "(bad)", XX
, XX
, XX
},
968 { "(bad)", XX
, XX
, XX
},
969 { "(bad)", XX
, XX
, XX
},
971 /* these are all backward in appendix A of the intel book */
972 { "movL", Rd
, Cd
, XX
},
973 { "movL", Rd
, Dd
, XX
},
974 { "movL", Cd
, Rd
, XX
},
975 { "movL", Dd
, Rd
, XX
},
976 { "movL", Rd
, Td
, XX
},
977 { "(bad)", XX
, XX
, XX
},
978 { "movL", Td
, Rd
, XX
},
979 { "(bad)", XX
, XX
, XX
},
981 { "movaps", XM
, EX
, XX
},
982 { "movaps", EX
, XM
, XX
},
984 { "movntps", Ev
, XM
, XX
},
987 { "ucomiss", XM
, EX
, XX
},
988 { "comiss", XM
, EX
, XX
},
990 { "wrmsr", XX
, XX
, XX
},
991 { "rdtsc", XX
, XX
, XX
},
992 { "rdmsr", XX
, XX
, XX
},
993 { "rdpmc", XX
, XX
, XX
},
994 { "sysenter", XX
, XX
, XX
},
995 { "sysexit", XX
, XX
, XX
},
996 { "(bad)", XX
, XX
, XX
},
997 { "(bad)", XX
, XX
, XX
},
999 { "(bad)", XX
, XX
, XX
},
1000 { "(bad)", XX
, XX
, XX
},
1001 { "(bad)", XX
, XX
, XX
},
1002 { "(bad)", XX
, XX
, XX
},
1003 { "(bad)", XX
, XX
, XX
},
1004 { "(bad)", XX
, XX
, XX
},
1005 { "(bad)", XX
, XX
, XX
},
1006 { "(bad)", XX
, XX
, XX
},
1008 { "cmovo", Gv
, Ev
, XX
},
1009 { "cmovno", Gv
, Ev
, XX
},
1010 { "cmovb", Gv
, Ev
, XX
},
1011 { "cmovae", Gv
, Ev
, XX
},
1012 { "cmove", Gv
, Ev
, XX
},
1013 { "cmovne", Gv
, Ev
, XX
},
1014 { "cmovbe", Gv
, Ev
, XX
},
1015 { "cmova", Gv
, Ev
, XX
},
1017 { "cmovs", Gv
, Ev
, XX
},
1018 { "cmovns", Gv
, Ev
, XX
},
1019 { "cmovp", Gv
, Ev
, XX
},
1020 { "cmovnp", Gv
, Ev
, XX
},
1021 { "cmovl", Gv
, Ev
, XX
},
1022 { "cmovge", Gv
, Ev
, XX
},
1023 { "cmovle", Gv
, Ev
, XX
},
1024 { "cmovg", Gv
, Ev
, XX
},
1026 { "movmskps", Gv
, EX
, XX
},
1030 { "andps", XM
, EX
, XX
},
1031 { "andnps", XM
, EX
, XX
},
1032 { "orps", XM
, EX
, XX
},
1033 { "xorps", XM
, EX
, XX
},
1037 { "(bad)", XX
, XX
, XX
},
1038 { "(bad)", XX
, XX
, XX
},
1044 { "punpcklbw", MX
, EM
, XX
},
1045 { "punpcklwd", MX
, EM
, XX
},
1046 { "punpckldq", MX
, EM
, XX
},
1047 { "packsswb", MX
, EM
, XX
},
1048 { "pcmpgtb", MX
, EM
, XX
},
1049 { "pcmpgtw", MX
, EM
, XX
},
1050 { "pcmpgtd", MX
, EM
, XX
},
1051 { "packuswb", MX
, EM
, XX
},
1053 { "punpckhbw", MX
, EM
, XX
},
1054 { "punpckhwd", MX
, EM
, XX
},
1055 { "punpckhdq", MX
, EM
, XX
},
1056 { "packssdw", MX
, EM
, XX
},
1057 { "(bad)", XX
, XX
, XX
},
1058 { "(bad)", XX
, XX
, XX
},
1059 { "movd", MX
, Ed
, XX
},
1060 { "movq", MX
, EM
, XX
},
1062 { "pshufw", MX
, EM
, Ib
},
1066 { "pcmpeqb", MX
, EM
, XX
},
1067 { "pcmpeqw", MX
, EM
, XX
},
1068 { "pcmpeqd", MX
, EM
, XX
},
1069 { "emms", XX
, XX
, XX
},
1071 { "(bad)", XX
, XX
, XX
},
1072 { "(bad)", XX
, XX
, XX
},
1073 { "(bad)", XX
, XX
, XX
},
1074 { "(bad)", XX
, XX
, XX
},
1075 { "(bad)", XX
, XX
, XX
},
1076 { "(bad)", XX
, XX
, XX
},
1077 { "movd", Ed
, MX
, XX
},
1078 { "movq", EM
, MX
, XX
},
1080 { "jo", Jv
, XX
, XX
},
1081 { "jno", Jv
, XX
, XX
},
1082 { "jb", Jv
, XX
, XX
},
1083 { "jae", Jv
, XX
, XX
},
1084 { "je", Jv
, XX
, XX
},
1085 { "jne", Jv
, XX
, XX
},
1086 { "jbe", Jv
, XX
, XX
},
1087 { "ja", Jv
, XX
, XX
},
1089 { "js", Jv
, XX
, XX
},
1090 { "jns", Jv
, XX
, XX
},
1091 { "jp", Jv
, XX
, XX
},
1092 { "jnp", Jv
, XX
, XX
},
1093 { "jl", Jv
, XX
, XX
},
1094 { "jge", Jv
, XX
, XX
},
1095 { "jle", Jv
, XX
, XX
},
1096 { "jg", Jv
, XX
, XX
},
1098 { "seto", Eb
, XX
, XX
},
1099 { "setno", Eb
, XX
, XX
},
1100 { "setb", Eb
, XX
, XX
},
1101 { "setae", Eb
, XX
, XX
},
1102 { "sete", Eb
, XX
, XX
},
1103 { "setne", Eb
, XX
, XX
},
1104 { "setbe", Eb
, XX
, XX
},
1105 { "seta", Eb
, XX
, XX
},
1107 { "sets", Eb
, XX
, XX
},
1108 { "setns", Eb
, XX
, XX
},
1109 { "setp", Eb
, XX
, XX
},
1110 { "setnp", Eb
, XX
, XX
},
1111 { "setl", Eb
, XX
, XX
},
1112 { "setge", Eb
, XX
, XX
},
1113 { "setle", Eb
, XX
, XX
},
1114 { "setg", Eb
, XX
, XX
},
1116 { "pushP", fs
, XX
, XX
},
1117 { "popP", fs
, XX
, XX
},
1118 { "cpuid", XX
, XX
, XX
},
1119 { "btS", Ev
, Gv
, XX
},
1120 { "shldS", Ev
, Gv
, Ib
},
1121 { "shldS", Ev
, Gv
, CL
},
1122 { "(bad)", XX
, XX
, XX
},
1123 { "(bad)", XX
, XX
, XX
},
1125 { "pushP", gs
, XX
, XX
},
1126 { "popP", gs
, XX
, XX
},
1127 { "rsm", XX
, XX
, XX
},
1128 { "btsS", Ev
, Gv
, XX
},
1129 { "shrdS", Ev
, Gv
, Ib
},
1130 { "shrdS", Ev
, Gv
, CL
},
1132 { "imulS", Gv
, Ev
, XX
},
1134 { "cmpxchgB", Eb
, Gb
, XX
},
1135 { "cmpxchgS", Ev
, Gv
, XX
},
1136 { "lssS", Gv
, Mp
, XX
},
1137 { "btrS", Ev
, Gv
, XX
},
1138 { "lfsS", Gv
, Mp
, XX
},
1139 { "lgsS", Gv
, Mp
, XX
},
1140 { "movzbR", Gv
, Eb
, XX
},
1141 { "movzwR", Gv
, Ew
, XX
}, /* yes, there really is movzww ! */
1143 { "(bad)", XX
, XX
, XX
},
1144 { "ud2b", XX
, XX
, XX
},
1146 { "btcS", Ev
, Gv
, XX
},
1147 { "bsfS", Gv
, Ev
, XX
},
1148 { "bsrS", Gv
, Ev
, XX
},
1149 { "movsbR", Gv
, Eb
, XX
},
1150 { "movswR", Gv
, Ew
, XX
}, /* yes, there really is movsww ! */
1152 { "xaddB", Eb
, Gb
, XX
},
1153 { "xaddS", Ev
, Gv
, XX
},
1155 { "(bad)", XX
, XX
, XX
},
1156 { "pinsrw", MX
, Ev
, Ib
},
1157 { "pextrw", Ev
, MX
, Ib
},
1158 { "shufps", XM
, EX
, Ib
},
1161 { "bswap", eAX
, XX
, XX
}, /* bswap doesn't support 16 bit regs */
1162 { "bswap", eCX
, XX
, XX
},
1163 { "bswap", eDX
, XX
, XX
},
1164 { "bswap", eBX
, XX
, XX
},
1165 { "bswap", eSP
, XX
, XX
},
1166 { "bswap", eBP
, XX
, XX
},
1167 { "bswap", eSI
, XX
, XX
},
1168 { "bswap", eDI
, XX
, XX
},
1170 { "(bad)", XX
, XX
, XX
},
1171 { "psrlw", MX
, EM
, XX
},
1172 { "psrld", MX
, EM
, XX
},
1173 { "psrlq", MX
, EM
, XX
},
1174 { "(bad)", XX
, XX
, XX
},
1175 { "pmullw", MX
, EM
, XX
},
1176 { "(bad)", XX
, XX
, XX
},
1177 { "pmovmskb", Ev
, MX
, XX
},
1179 { "psubusb", MX
, EM
, XX
},
1180 { "psubusw", MX
, EM
, XX
},
1181 { "pminub", MX
, EM
, XX
},
1182 { "pand", MX
, EM
, XX
},
1183 { "paddusb", MX
, EM
, XX
},
1184 { "paddusw", MX
, EM
, XX
},
1185 { "pmaxub", MX
, EM
, XX
},
1186 { "pandn", MX
, EM
, XX
},
1188 { "pavgb", MX
, EM
, XX
},
1189 { "psraw", MX
, EM
, XX
},
1190 { "psrad", MX
, EM
, XX
},
1191 { "pavgw", MX
, EM
, XX
},
1192 { "pmulhuw", MX
, EM
, XX
},
1193 { "pmulhw", MX
, EM
, XX
},
1194 { "(bad)", XX
, XX
, XX
},
1195 { "movntq", Ev
, MX
, XX
},
1197 { "psubsb", MX
, EM
, XX
},
1198 { "psubsw", MX
, EM
, XX
},
1199 { "pminsw", MX
, EM
, XX
},
1200 { "por", MX
, EM
, XX
},
1201 { "paddsb", MX
, EM
, XX
},
1202 { "paddsw", MX
, EM
, XX
},
1203 { "pmaxsw", MX
, EM
, XX
},
1204 { "pxor", MX
, EM
, XX
},
1206 { "(bad)", XX
, XX
, XX
},
1207 { "psllw", MX
, EM
, XX
},
1208 { "pslld", MX
, EM
, XX
},
1209 { "psllq", MX
, EM
, XX
},
1210 { "(bad)", XX
, XX
, XX
},
1211 { "pmaddwd", MX
, EM
, XX
},
1212 { "psadbw", MX
, EM
, XX
},
1213 { "maskmovq", MX
, EM
, XX
},
1215 { "psubb", MX
, EM
, XX
},
1216 { "psubw", MX
, EM
, XX
},
1217 { "psubd", MX
, EM
, XX
},
1218 { "(bad)", XX
, XX
, XX
},
1219 { "paddb", MX
, EM
, XX
},
1220 { "paddw", MX
, EM
, XX
},
1221 { "paddd", MX
, EM
, XX
},
1222 { "(bad)", XX
, XX
, XX
}
1225 static const struct dis386 dis386_twobyte_intel
[] = {
1229 { "lar", Gv
, Ew
, XX
},
1230 { "lsl", Gv
, Ew
, XX
},
1231 { "(bad)", XX
, XX
, XX
},
1232 { "(bad)", XX
, XX
, XX
},
1233 { "clts", XX
, XX
, XX
},
1234 { "(bad)", XX
, XX
, XX
},
1236 { "invd", XX
, XX
, XX
},
1237 { "wbinvd", XX
, XX
, XX
},
1238 { "(bad)", XX
, XX
, XX
},
1239 { "ud2a", XX
, XX
, XX
},
1240 { "(bad)", XX
, XX
, XX
},
1242 { "femms" , XX
, XX
, XX
},
1243 { "", MX
, EM
, OPSUF
}, /* See OP_3DNowSuffix */
1247 { "movlps", XM
, EX
, SIMD_Fixup
, 'h' }, /* really only 2 operands */
1248 { "movlps", EX
, XM
, SIMD_Fixup
, 'h' },
1249 { "unpcklps", XM
, EX
, XX
},
1250 { "unpckhps", XM
, EX
, XX
},
1251 { "movhps", XM
, EX
, SIMD_Fixup
, 'l' },
1252 { "movhps", EX
, XM
, SIMD_Fixup
, 'l' },
1255 { "(bad)", XX
, XX
, XX
},
1256 { "(bad)", XX
, XX
, XX
},
1257 { "(bad)", XX
, XX
, XX
},
1258 { "(bad)", XX
, XX
, XX
},
1259 { "(bad)", XX
, XX
, XX
},
1260 { "(bad)", XX
, XX
, XX
},
1261 { "(bad)", XX
, XX
, XX
},
1263 /* these are all backward in appendix A of the intel book */
1264 { "mov", Rd
, Cd
, XX
},
1265 { "mov", Rd
, Dd
, XX
},
1266 { "mov", Cd
, Rd
, XX
},
1267 { "mov", Dd
, Rd
, XX
},
1268 { "mov", Rd
, Td
, XX
},
1269 { "(bad)", XX
, XX
, XX
},
1270 { "mov", Td
, Rd
, XX
},
1271 { "(bad)", XX
, XX
, XX
},
1273 { "movaps", XM
, EX
, XX
},
1274 { "movaps", EX
, XM
, XX
},
1276 { "movntps", Ev
, XM
, XX
},
1279 { "ucomiss", XM
, EX
, XX
},
1280 { "comiss", XM
, EX
, XX
},
1282 { "wrmsr", XX
, XX
, XX
},
1283 { "rdtsc", XX
, XX
, XX
},
1284 { "rdmsr", XX
, XX
, XX
},
1285 { "rdpmc", XX
, XX
, XX
},
1286 { "sysenter", XX
, XX
, XX
},
1287 { "sysexit", XX
, XX
, XX
},
1288 { "(bad)", XX
, XX
, XX
},
1289 { "(bad)", XX
, XX
, XX
},
1291 { "(bad)", XX
, XX
, XX
},
1292 { "(bad)", XX
, XX
, XX
},
1293 { "(bad)", XX
, XX
, XX
},
1294 { "(bad)", XX
, XX
, XX
},
1295 { "(bad)", XX
, XX
, XX
},
1296 { "(bad)", XX
, XX
, XX
},
1297 { "(bad)", XX
, XX
, XX
},
1298 { "(bad)", XX
, XX
, XX
},
1300 { "cmovo", Gv
, Ev
, XX
},
1301 { "cmovno", Gv
, Ev
, XX
},
1302 { "cmovb", Gv
, Ev
, XX
},
1303 { "cmovae", Gv
, Ev
, XX
},
1304 { "cmove", Gv
, Ev
, XX
},
1305 { "cmovne", Gv
, Ev
, XX
},
1306 { "cmovbe", Gv
, Ev
, XX
},
1307 { "cmova", Gv
, Ev
, XX
},
1309 { "cmovs", Gv
, Ev
, XX
},
1310 { "cmovns", Gv
, Ev
, XX
},
1311 { "cmovp", Gv
, Ev
, XX
},
1312 { "cmovnp", Gv
, Ev
, XX
},
1313 { "cmovl", Gv
, Ev
, XX
},
1314 { "cmovge", Gv
, Ev
, XX
},
1315 { "cmovle", Gv
, Ev
, XX
},
1316 { "cmovg", Gv
, Ev
, XX
},
1318 { "movmskps", Gv
, EX
, XX
},
1322 { "andps", XM
, EX
, XX
},
1323 { "andnps", XM
, EX
, XX
},
1324 { "orps", XM
, EX
, XX
},
1325 { "xorps", XM
, EX
, XX
},
1329 { "(bad)", XX
, XX
, XX
},
1330 { "(bad)", XX
, XX
, XX
},
1336 { "punpcklbw", MX
, EM
, XX
},
1337 { "punpcklwd", MX
, EM
, XX
},
1338 { "punpckldq", MX
, EM
, XX
},
1339 { "packsswb", MX
, EM
, XX
},
1340 { "pcmpgtb", MX
, EM
, XX
},
1341 { "pcmpgtw", MX
, EM
, XX
},
1342 { "pcmpgtd", MX
, EM
, XX
},
1343 { "packuswb", MX
, EM
, XX
},
1345 { "punpckhbw", MX
, EM
, XX
},
1346 { "punpckhwd", MX
, EM
, XX
},
1347 { "punpckhdq", MX
, EM
, XX
},
1348 { "packssdw", MX
, EM
, XX
},
1349 { "(bad)", XX
, XX
, XX
},
1350 { "(bad)", XX
, XX
, XX
},
1351 { "movd", MX
, Ed
, XX
},
1352 { "movq", MX
, EM
, XX
},
1354 { "pshufw", MX
, EM
, Ib
},
1358 { "pcmpeqb", MX
, EM
, XX
},
1359 { "pcmpeqw", MX
, EM
, XX
},
1360 { "pcmpeqd", MX
, EM
, XX
},
1361 { "emms", XX
, XX
, XX
},
1363 { "(bad)", XX
, XX
, XX
},
1364 { "(bad)", XX
, XX
, XX
},
1365 { "(bad)", XX
, XX
, XX
},
1366 { "(bad)", XX
, XX
, XX
},
1367 { "(bad)", XX
, XX
, XX
},
1368 { "(bad)", XX
, XX
, XX
},
1369 { "movd", Ed
, MX
, XX
},
1370 { "movq", EM
, MX
, XX
},
1372 { "jo", Jv
, XX
, XX
},
1373 { "jno", Jv
, XX
, XX
},
1374 { "jb", Jv
, XX
, XX
},
1375 { "jae", Jv
, XX
, XX
},
1376 { "je", Jv
, XX
, XX
},
1377 { "jne", Jv
, XX
, XX
},
1378 { "jbe", Jv
, XX
, XX
},
1379 { "ja", Jv
, XX
, XX
},
1381 { "js", Jv
, XX
, XX
},
1382 { "jns", Jv
, XX
, XX
},
1383 { "jp", Jv
, XX
, XX
},
1384 { "jnp", Jv
, XX
, XX
},
1385 { "jl", Jv
, XX
, XX
},
1386 { "jge", Jv
, XX
, XX
},
1387 { "jle", Jv
, XX
, XX
},
1388 { "jg", Jv
, XX
, XX
},
1390 { "seto", Eb
, XX
, XX
},
1391 { "setno", Eb
, XX
, XX
},
1392 { "setb", Eb
, XX
, XX
},
1393 { "setae", Eb
, XX
, XX
},
1394 { "sete", Eb
, XX
, XX
},
1395 { "setne", Eb
, XX
, XX
},
1396 { "setbe", Eb
, XX
, XX
},
1397 { "seta", Eb
, XX
, XX
},
1399 { "sets", Eb
, XX
, XX
},
1400 { "setns", Eb
, XX
, XX
},
1401 { "setp", Eb
, XX
, XX
},
1402 { "setnp", Eb
, XX
, XX
},
1403 { "setl", Eb
, XX
, XX
},
1404 { "setge", Eb
, XX
, XX
},
1405 { "setle", Eb
, XX
, XX
},
1406 { "setg", Eb
, XX
, XX
},
1408 { "push", fs
, XX
, XX
},
1409 { "pop", fs
, XX
, XX
},
1410 { "cpuid", XX
, XX
, XX
},
1411 { "bt", Ev
, Gv
, XX
},
1412 { "shld", Ev
, Gv
, Ib
},
1413 { "shld", Ev
, Gv
, CL
},
1414 { "(bad)", XX
, XX
, XX
},
1415 { "(bad)", XX
, XX
, XX
},
1417 { "push", gs
, XX
, XX
},
1418 { "pop", gs
, XX
, XX
},
1419 { "rsm" , XX
, XX
, XX
},
1420 { "bts", Ev
, Gv
, XX
},
1421 { "shrd", Ev
, Gv
, Ib
},
1422 { "shrd", Ev
, Gv
, CL
},
1424 { "imul", Gv
, Ev
, XX
},
1426 { "cmpxchg", Eb
, Gb
, XX
},
1427 { "cmpxchg", Ev
, Gv
, XX
},
1428 { "lss", Gv
, Mp
, XX
},
1429 { "btr", Ev
, Gv
, XX
},
1430 { "lfs", Gv
, Mp
, XX
},
1431 { "lgs", Gv
, Mp
, XX
},
1432 { "movzx", Gv
, Eb
, XX
},
1433 { "movzx", Gv
, Ew
, XX
},
1435 { "(bad)", XX
, XX
, XX
},
1436 { "ud2b", XX
, XX
, XX
},
1438 { "btc", Ev
, Gv
, XX
},
1439 { "bsf", Gv
, Ev
, XX
},
1440 { "bsr", Gv
, Ev
, XX
},
1441 { "movsx", Gv
, Eb
, XX
},
1442 { "movsx", Gv
, Ew
, XX
},
1444 { "xadd", Eb
, Gb
, XX
},
1445 { "xadd", Ev
, Gv
, XX
},
1447 { "(bad)", XX
, XX
, XX
},
1448 { "pinsrw", MX
, Ev
, Ib
},
1449 { "pextrw", Ev
, MX
, Ib
},
1450 { "shufps", XM
, EX
, Ib
},
1453 { "bswap", eAX
, XX
, XX
}, /* bswap doesn't support 16 bit regs */
1454 { "bswap", eCX
, XX
, XX
},
1455 { "bswap", eDX
, XX
, XX
},
1456 { "bswap", eBX
, XX
, XX
},
1457 { "bswap", eSP
, XX
, XX
},
1458 { "bswap", eBP
, XX
, XX
},
1459 { "bswap", eSI
, XX
, XX
},
1460 { "bswap", eDI
, XX
, XX
},
1462 { "(bad)", XX
, XX
, XX
},
1463 { "psrlw", MX
, EM
, XX
},
1464 { "psrld", MX
, EM
, XX
},
1465 { "psrlq", MX
, EM
, XX
},
1466 { "(bad)", XX
, XX
, XX
},
1467 { "pmullw", MX
, EM
, XX
},
1468 { "(bad)", XX
, XX
, XX
},
1469 { "pmovmskb", Ev
, MX
, XX
},
1471 { "psubusb", MX
, EM
, XX
},
1472 { "psubusw", MX
, EM
, XX
},
1473 { "pminub", MX
, EM
, XX
},
1474 { "pand", MX
, EM
, XX
},
1475 { "paddusb", MX
, EM
, XX
},
1476 { "paddusw", MX
, EM
, XX
},
1477 { "pmaxub", MX
, EM
, XX
},
1478 { "pandn", MX
, EM
, XX
},
1480 { "pavgb", MX
, EM
, XX
},
1481 { "psraw", MX
, EM
, XX
},
1482 { "psrad", MX
, EM
, XX
},
1483 { "pavgw", MX
, EM
, XX
},
1484 { "pmulhuw", MX
, EM
, XX
},
1485 { "pmulhw", MX
, EM
, XX
},
1486 { "(bad)", XX
, XX
, XX
},
1487 { "movntq", Ev
, MX
, XX
},
1489 { "psubsb", MX
, EM
, XX
},
1490 { "psubsw", MX
, EM
, XX
},
1491 { "pminsw", MX
, EM
, XX
},
1492 { "por", MX
, EM
, XX
},
1493 { "paddsb", MX
, EM
, XX
},
1494 { "paddsw", MX
, EM
, XX
},
1495 { "pmaxsw", MX
, EM
, XX
},
1496 { "pxor", MX
, EM
, XX
},
1498 { "(bad)", XX
, XX
, XX
},
1499 { "psllw", MX
, EM
, XX
},
1500 { "pslld", MX
, EM
, XX
},
1501 { "psllq", MX
, EM
, XX
},
1502 { "(bad)", XX
, XX
, XX
},
1503 { "pmaddwd", MX
, EM
, XX
},
1504 { "psadbw", MX
, EM
, XX
},
1505 { "maskmovq", MX
, EM
, XX
},
1507 { "psubb", MX
, EM
, XX
},
1508 { "psubw", MX
, EM
, XX
},
1509 { "psubd", MX
, EM
, XX
},
1510 { "(bad)", XX
, XX
, XX
},
1511 { "paddb", MX
, EM
, XX
},
1512 { "paddw", MX
, EM
, XX
},
1513 { "paddd", MX
, EM
, XX
},
1514 { "(bad)", XX
, XX
, XX
}
1517 static const unsigned char onebyte_has_modrm
[256] = {
1518 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1519 /* ------------------------------- */
1520 /* 00 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 00 */
1521 /* 10 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 10 */
1522 /* 20 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 20 */
1523 /* 30 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 30 */
1524 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 40 */
1525 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 50 */
1526 /* 60 */ 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0, /* 60 */
1527 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 70 */
1528 /* 80 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 80 */
1529 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 90 */
1530 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* a0 */
1531 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* b0 */
1532 /* c0 */ 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* c0 */
1533 /* d0 */ 1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* d0 */
1534 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* e0 */
1535 /* f0 */ 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1 /* f0 */
1536 /* ------------------------------- */
1537 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1540 static const unsigned char twobyte_has_modrm
[256] = {
1541 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1542 /* ------------------------------- */
1543 /* 00 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1, /* 0f */
1544 /* 10 */ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0, /* 1f */
1545 /* 20 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 2f */
1546 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1547 /* 40 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4f */
1548 /* 50 */ 1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1, /* 5f */
1549 /* 60 */ 1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1, /* 6f */
1550 /* 70 */ 1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1, /* 7f */
1551 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1552 /* 90 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 9f */
1553 /* a0 */ 0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1, /* af */
1554 /* b0 */ 1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1, /* bf */
1555 /* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
1556 /* d0 */ 0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1, /* df */
1557 /* e0 */ 1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1, /* ef */
1558 /* f0 */ 0,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0 /* ff */
1559 /* ------------------------------- */
1560 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1563 static const unsigned char twobyte_uses_f3_prefix
[256] = {
1564 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1565 /* ------------------------------- */
1566 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1567 /* 10 */ 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
1568 /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0, /* 2f */
1569 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1570 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1571 /* 50 */ 0,1,1,1,0,0,0,0,1,1,0,0,1,1,1,1, /* 5f */
1572 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1573 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1574 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1575 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1576 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1577 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1578 /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1579 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* df */
1580 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1581 /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* ff */
1582 /* ------------------------------- */
1583 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1586 static char obuf
[100];
1588 static char scratchbuf
[100];
1589 static unsigned char *start_codep
;
1590 static unsigned char *insn_codep
;
1591 static unsigned char *codep
;
1592 static disassemble_info
*the_info
;
1596 static void oappend
PARAMS ((const char *s
));
1598 static const char *names32
[]={
1599 "%eax","%ecx","%edx","%ebx", "%esp","%ebp","%esi","%edi",
1601 static const char *names16
[] = {
1602 "%ax","%cx","%dx","%bx","%sp","%bp","%si","%di",
1604 static const char *names8
[] = {
1605 "%al","%cl","%dl","%bl","%ah","%ch","%dh","%bh",
1607 static const char *names_seg
[] = {
1608 "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
1610 static const char *index16
[] = {
1611 "%bx,%si","%bx,%di","%bp,%si","%bp,%di","%si","%di","%bp","%bx"
1614 static const struct dis386 grps
[][8] = {
1617 { "addA", Eb
, Ib
, XX
},
1618 { "orA", Eb
, Ib
, XX
},
1619 { "adcA", Eb
, Ib
, XX
},
1620 { "sbbA", Eb
, Ib
, XX
},
1621 { "andA", Eb
, Ib
, XX
},
1622 { "subA", Eb
, Ib
, XX
},
1623 { "xorA", Eb
, Ib
, XX
},
1624 { "cmpA", Eb
, Ib
, XX
}
1628 { "addQ", Ev
, Iv
, XX
},
1629 { "orQ", Ev
, Iv
, XX
},
1630 { "adcQ", Ev
, Iv
, XX
},
1631 { "sbbQ", Ev
, Iv
, XX
},
1632 { "andQ", Ev
, Iv
, XX
},
1633 { "subQ", Ev
, Iv
, XX
},
1634 { "xorQ", Ev
, Iv
, XX
},
1635 { "cmpQ", Ev
, Iv
, XX
}
1639 { "addQ", Ev
, sIb
, XX
},
1640 { "orQ", Ev
, sIb
, XX
},
1641 { "adcQ", Ev
, sIb
, XX
},
1642 { "sbbQ", Ev
, sIb
, XX
},
1643 { "andQ", Ev
, sIb
, XX
},
1644 { "subQ", Ev
, sIb
, XX
},
1645 { "xorQ", Ev
, sIb
, XX
},
1646 { "cmpQ", Ev
, sIb
, XX
}
1650 { "rolA", Eb
, Ib
, XX
},
1651 { "rorA", Eb
, Ib
, XX
},
1652 { "rclA", Eb
, Ib
, XX
},
1653 { "rcrA", Eb
, Ib
, XX
},
1654 { "shlA", Eb
, Ib
, XX
},
1655 { "shrA", Eb
, Ib
, XX
},
1656 { "(bad)", XX
, XX
, XX
},
1657 { "sarA", Eb
, Ib
, XX
},
1661 { "rolQ", Ev
, Ib
, XX
},
1662 { "rorQ", Ev
, Ib
, XX
},
1663 { "rclQ", Ev
, Ib
, XX
},
1664 { "rcrQ", Ev
, Ib
, XX
},
1665 { "shlQ", Ev
, Ib
, XX
},
1666 { "shrQ", Ev
, Ib
, XX
},
1667 { "(bad)", XX
, XX
, XX
},
1668 { "sarQ", Ev
, Ib
, XX
},
1672 { "rolA", Eb
, XX
, XX
},
1673 { "rorA", Eb
, XX
, XX
},
1674 { "rclA", Eb
, XX
, XX
},
1675 { "rcrA", Eb
, XX
, XX
},
1676 { "shlA", Eb
, XX
, XX
},
1677 { "shrA", Eb
, XX
, XX
},
1678 { "(bad)", XX
, XX
, XX
},
1679 { "sarA", Eb
, XX
, XX
},
1683 { "rolQ", Ev
, XX
, XX
},
1684 { "rorQ", Ev
, XX
, XX
},
1685 { "rclQ", Ev
, XX
, XX
},
1686 { "rcrQ", Ev
, XX
, XX
},
1687 { "shlQ", Ev
, XX
, XX
},
1688 { "shrQ", Ev
, XX
, XX
},
1689 { "(bad)", XX
, XX
, XX
},
1690 { "sarQ", Ev
, XX
, XX
},
1694 { "rolA", Eb
, CL
, XX
},
1695 { "rorA", Eb
, CL
, XX
},
1696 { "rclA", Eb
, CL
, XX
},
1697 { "rcrA", Eb
, CL
, XX
},
1698 { "shlA", Eb
, CL
, XX
},
1699 { "shrA", Eb
, CL
, XX
},
1700 { "(bad)", XX
, XX
, XX
},
1701 { "sarA", Eb
, CL
, XX
},
1705 { "rolQ", Ev
, CL
, XX
},
1706 { "rorQ", Ev
, CL
, XX
},
1707 { "rclQ", Ev
, CL
, XX
},
1708 { "rcrQ", Ev
, CL
, XX
},
1709 { "shlQ", Ev
, CL
, XX
},
1710 { "shrQ", Ev
, CL
, XX
},
1711 { "(bad)", XX
, XX
, XX
},
1712 { "sarQ", Ev
, CL
, XX
}
1716 { "testA", Eb
, Ib
, XX
},
1717 { "(bad)", Eb
, XX
, XX
},
1718 { "notA", Eb
, XX
, XX
},
1719 { "negA", Eb
, XX
, XX
},
1720 { "mulB", AL
, Eb
, XX
},
1721 { "imulB", AL
, Eb
, XX
},
1722 { "divB", AL
, Eb
, XX
},
1723 { "idivB", AL
, Eb
, XX
}
1727 { "testQ", Ev
, Iv
, XX
},
1728 { "(bad)", XX
, XX
, XX
},
1729 { "notQ", Ev
, XX
, XX
},
1730 { "negQ", Ev
, XX
, XX
},
1731 { "mulS", eAX
, Ev
, XX
},
1732 { "imulS", eAX
, Ev
, XX
},
1733 { "divS", eAX
, Ev
, XX
},
1734 { "idivS", eAX
, Ev
, XX
},
1738 { "incA", Eb
, XX
, XX
},
1739 { "decA", Eb
, XX
, XX
},
1740 { "(bad)", XX
, XX
, XX
},
1741 { "(bad)", XX
, XX
, XX
},
1742 { "(bad)", XX
, XX
, XX
},
1743 { "(bad)", XX
, XX
, XX
},
1744 { "(bad)", XX
, XX
, XX
},
1745 { "(bad)", XX
, XX
, XX
},
1749 { "incQ", Ev
, XX
, XX
},
1750 { "decQ", Ev
, XX
, XX
},
1751 { "callP", indirEv
, XX
, XX
},
1752 { "callP", indirEv
, XX
, XX
},
1753 { "jmpP", indirEv
, XX
, XX
},
1754 { "ljmpP", indirEv
, XX
, XX
},
1755 { "pushQ", Ev
, XX
, XX
},
1756 { "(bad)", XX
, XX
, XX
},
1760 { "sldt", Ew
, XX
, XX
},
1761 { "str", Ew
, XX
, XX
},
1762 { "lldt", Ew
, XX
, XX
},
1763 { "ltr", Ew
, XX
, XX
},
1764 { "verr", Ew
, XX
, XX
},
1765 { "verw", Ew
, XX
, XX
},
1766 { "(bad)", XX
, XX
, XX
},
1767 { "(bad)", XX
, XX
, XX
}
1771 { "sgdt", Ew
, XX
, XX
},
1772 { "sidt", Ew
, XX
, XX
},
1773 { "lgdt", Ew
, XX
, XX
},
1774 { "lidt", Ew
, XX
, XX
},
1775 { "smsw", Ew
, XX
, XX
},
1776 { "(bad)", XX
, XX
, XX
},
1777 { "lmsw", Ew
, XX
, XX
},
1778 { "invlpg", Ew
, XX
, XX
},
1782 { "(bad)", XX
, XX
, XX
},
1783 { "(bad)", XX
, XX
, XX
},
1784 { "(bad)", XX
, XX
, XX
},
1785 { "(bad)", XX
, XX
, XX
},
1786 { "btQ", Ev
, Ib
, XX
},
1787 { "btsQ", Ev
, Ib
, XX
},
1788 { "btrQ", Ev
, Ib
, XX
},
1789 { "btcQ", Ev
, Ib
, XX
},
1793 { "(bad)", XX
, XX
, XX
},
1794 { "cmpxchg8b", Ev
, XX
, XX
},
1795 { "(bad)", XX
, XX
, XX
},
1796 { "(bad)", XX
, XX
, XX
},
1797 { "(bad)", XX
, XX
, XX
},
1798 { "(bad)", XX
, XX
, XX
},
1799 { "(bad)", XX
, XX
, XX
},
1800 { "(bad)", XX
, XX
, XX
},
1804 { "(bad)", XX
, XX
, XX
},
1805 { "(bad)", XX
, XX
, XX
},
1806 { "psrlw", MS
, Ib
, XX
},
1807 { "(bad)", XX
, XX
, XX
},
1808 { "psraw", MS
, Ib
, XX
},
1809 { "(bad)", XX
, XX
, XX
},
1810 { "psllw", MS
, Ib
, XX
},
1811 { "(bad)", XX
, XX
, XX
},
1815 { "(bad)", XX
, XX
, XX
},
1816 { "(bad)", XX
, XX
, XX
},
1817 { "psrld", MS
, Ib
, XX
},
1818 { "(bad)", XX
, XX
, XX
},
1819 { "psrad", MS
, Ib
, XX
},
1820 { "(bad)", XX
, XX
, XX
},
1821 { "pslld", MS
, Ib
, XX
},
1822 { "(bad)", XX
, XX
, XX
},
1826 { "(bad)", XX
, XX
, XX
},
1827 { "(bad)", XX
, XX
, XX
},
1828 { "psrlq", MS
, Ib
, XX
},
1829 { "(bad)", XX
, XX
, XX
},
1830 { "(bad)", XX
, XX
, XX
},
1831 { "(bad)", XX
, XX
, XX
},
1832 { "psllq", MS
, Ib
, XX
},
1833 { "(bad)", XX
, XX
, XX
},
1837 { "fxsave", Ev
, XX
, XX
},
1838 { "fxrstor", Ev
, XX
, XX
},
1839 { "ldmxcsr", Ev
, XX
, XX
},
1840 { "stmxcsr", Ev
, XX
, XX
},
1841 { "(bad)", XX
, XX
, XX
},
1842 { "(bad)", XX
, XX
, XX
},
1843 { "(bad)", XX
, XX
, XX
},
1844 { "sfence", None
, XX
, XX
},
1848 { "prefetchnta", Ev
, XX
, XX
},
1849 { "prefetcht0", Ev
, XX
, XX
},
1850 { "prefetcht1", Ev
, XX
, XX
},
1851 { "prefetcht2", Ev
, XX
, XX
},
1852 { "(bad)", XX
, XX
, XX
},
1853 { "(bad)", XX
, XX
, XX
},
1854 { "(bad)", XX
, XX
, XX
},
1855 { "(bad)", XX
, XX
, XX
},
1859 { "prefetch", Eb
, XX
, XX
},
1860 { "prefetchw", Eb
, XX
, XX
},
1861 { "(bad)", XX
, XX
, XX
},
1862 { "(bad)", XX
, XX
, XX
},
1863 { "(bad)", XX
, XX
, XX
},
1864 { "(bad)", XX
, XX
, XX
},
1865 { "(bad)", XX
, XX
, XX
},
1866 { "(bad)", XX
, XX
, XX
},
1871 static const struct dis386 prefix_user_table
[][2] = {
1874 { "addps", XM
, EX
, XX
},
1875 { "addss", XM
, EX
, XX
},
1879 { "", XM
, EX
, OPSIMD
}, /* See OP_SIMD_SUFFIX */
1880 { "", XM
, EX
, OPSIMD
},
1884 { "cvtpi2ps", XM
, EM
, XX
},
1885 { "cvtsi2ss", XM
, Ev
, XX
},
1889 { "cvtps2pi", MX
, EX
, XX
},
1890 { "cvtss2si", Gv
, EX
, XX
},
1894 { "cvttps2pi", MX
, EX
, XX
},
1895 { "cvttss2si", Gv
, EX
, XX
},
1899 { "divps", XM
, EX
, XX
},
1900 { "divss", XM
, EX
, XX
},
1904 { "maxps", XM
, EX
, XX
},
1905 { "maxss", XM
, EX
, XX
},
1909 { "minps", XM
, EX
, XX
},
1910 { "minss", XM
, EX
, XX
},
1914 { "movups", XM
, EX
, XX
},
1915 { "movss", XM
, EX
, XX
},
1919 { "movups", EX
, XM
, XX
},
1920 { "movss", EX
, XM
, XX
},
1924 { "mulps", XM
, EX
, XX
},
1925 { "mulss", XM
, EX
, XX
},
1929 { "rcpps", XM
, EX
, XX
},
1930 { "rcpss", XM
, EX
, XX
},
1934 { "rsqrtps", XM
, EX
, XX
},
1935 { "rsqrtss", XM
, EX
, XX
},
1939 { "sqrtps", XM
, EX
, XX
},
1940 { "sqrtss", XM
, EX
, XX
},
1944 { "subps", XM
, EX
, XX
},
1945 { "subss", XM
, EX
, XX
},
1949 #define INTERNAL_DISASSEMBLER_ERROR _("<internal disassembler error>")
1958 FETCH_DATA (the_info
, codep
+ 1);
1962 prefixes
|= PREFIX_REPZ
;
1965 prefixes
|= PREFIX_REPNZ
;
1968 prefixes
|= PREFIX_LOCK
;
1971 prefixes
|= PREFIX_CS
;
1974 prefixes
|= PREFIX_SS
;
1977 prefixes
|= PREFIX_DS
;
1980 prefixes
|= PREFIX_ES
;
1983 prefixes
|= PREFIX_FS
;
1986 prefixes
|= PREFIX_GS
;
1989 prefixes
|= PREFIX_DATA
;
1992 prefixes
|= PREFIX_ADDR
;
1995 /* fwait is really an instruction. If there are prefixes
1996 before the fwait, they belong to the fwait, *not* to the
1997 following instruction. */
2000 prefixes
|= PREFIX_FWAIT
;
2004 prefixes
= PREFIX_FWAIT
;
2013 /* Return the name of the prefix byte PREF, or NULL if PREF is not a
2017 prefix_name (pref
, sizeflag
)
2042 return (sizeflag
& DFLAG
) ? "data16" : "data32";
2044 return (sizeflag
& AFLAG
) ? "addr16" : "addr32";
2052 static char op1out
[100], op2out
[100], op3out
[100];
2053 static int op_ad
, op_index
[3];
2054 static unsigned int op_address
[3];
2055 static unsigned int start_pc
;
2059 * On the 386's of 1988, the maximum length of an instruction is 15 bytes.
2060 * (see topic "Redundant prefixes" in the "Differences from 8086"
2061 * section of the "Virtual 8086 Mode" chapter.)
2062 * 'pc' should be the address of this instruction, it will
2063 * be used to print the target address if this is a relative jump or call
2064 * The function returns the length of this instruction in bytes.
2067 static int print_insn_i386
2068 PARAMS ((bfd_vma pc
, disassemble_info
*info
));
2070 static char intel_syntax
;
2071 static char open_char
;
2072 static char close_char
;
2073 static char separator_char
;
2074 static char scale_char
;
2077 print_insn_i386_att (pc
, info
)
2079 disassemble_info
*info
;
2084 separator_char
= ',';
2087 return print_insn_i386 (pc
, info
);
2091 print_insn_i386_intel (pc
, info
)
2093 disassemble_info
*info
;
2098 separator_char
= '+';
2101 return print_insn_i386 (pc
, info
);
2105 print_insn_i386 (pc
, info
)
2107 disassemble_info
*info
;
2109 const struct dis386
*dp
;
2112 char *first
, *second
, *third
;
2114 unsigned char need_modrm
;
2115 unsigned char uses_f3_prefix
;
2116 VOLATILE
int sizeflag
;
2117 VOLATILE
int orig_sizeflag
;
2119 struct dis_private priv
;
2120 bfd_byte
*inbuf
= priv
.the_buffer
;
2122 if (info
->mach
== bfd_mach_i386_i386
2123 || info
->mach
== bfd_mach_i386_i386_intel_syntax
)
2124 sizeflag
= AFLAG
|DFLAG
;
2125 else if (info
->mach
== bfd_mach_i386_i8086
)
2129 orig_sizeflag
= sizeflag
;
2131 /* The output looks better if we put 7 bytes on a line, since that
2132 puts most long word instructions on a single line. */
2133 info
->bytes_per_line
= 7;
2135 info
->private_data
= (PTR
) &priv
;
2136 priv
.max_fetched
= priv
.the_buffer
;
2137 priv
.insn_start
= pc
;
2144 op_index
[0] = op_index
[1] = op_index
[2] = -1;
2148 start_codep
= inbuf
;
2151 if (setjmp (priv
.bailout
) != 0)
2155 /* Getting here means we tried for data but didn't get it. That
2156 means we have an incomplete instruction of some sort. Just
2157 print the first byte as a prefix or a .byte pseudo-op. */
2160 name
= prefix_name (inbuf
[0], orig_sizeflag
);
2162 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2165 /* Just print the first byte as a .byte instruction. */
2166 (*info
->fprintf_func
) (info
->stream
, ".byte 0x%x",
2167 (unsigned int) inbuf
[0]);
2180 FETCH_DATA (info
, codep
+ 1);
2181 two_source_ops
= (*codep
== 0x62) || (*codep
== 0xc8);
2185 if ((prefixes
& PREFIX_FWAIT
)
2186 && ((*codep
< 0xd8) || (*codep
> 0xdf)))
2190 /* fwait not followed by floating point instruction. Print the
2191 first prefix, which is probably fwait itself. */
2192 name
= prefix_name (inbuf
[0], orig_sizeflag
);
2194 name
= INTERNAL_DISASSEMBLER_ERROR
;
2195 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2201 FETCH_DATA (info
, codep
+ 2);
2203 dp
= &dis386_twobyte_intel
[*++codep
];
2205 dp
= &dis386_twobyte_att
[*++codep
];
2206 need_modrm
= twobyte_has_modrm
[*codep
];
2207 uses_f3_prefix
= twobyte_uses_f3_prefix
[*codep
];
2212 dp
= &dis386_intel
[*codep
];
2214 dp
= &dis386_att
[*codep
];
2215 need_modrm
= onebyte_has_modrm
[*codep
];
2220 if (!uses_f3_prefix
&& (prefixes
& PREFIX_REPZ
))
2223 used_prefixes
|= PREFIX_REPZ
;
2225 if (prefixes
& PREFIX_REPNZ
)
2228 used_prefixes
|= PREFIX_REPNZ
;
2230 if (prefixes
& PREFIX_LOCK
)
2233 used_prefixes
|= PREFIX_LOCK
;
2236 if (prefixes
& PREFIX_DATA
)
2239 if (prefixes
& PREFIX_ADDR
)
2242 if (sizeflag
& AFLAG
)
2243 oappend ("addr32 ");
2245 oappend ("addr16 ");
2246 used_prefixes
|= PREFIX_ADDR
;
2251 FETCH_DATA (info
, codep
+ 1);
2252 mod
= (*codep
>> 6) & 3;
2253 reg
= (*codep
>> 3) & 7;
2257 if (dp
->name
== NULL
&& dp
->bytemode1
== FLOATCODE
)
2263 if (dp
->name
== NULL
)
2265 switch(dp
->bytemode2
)
2268 dp
= &grps
[dp
->bytemode1
][reg
];
2270 case USE_PREFIX_USER_TABLE
:
2271 dp
= &prefix_user_table
[dp
->bytemode1
][prefixes
& PREFIX_REPZ
? 1 : 0];
2272 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
2275 oappend (INTERNAL_DISASSEMBLER_ERROR
);
2280 putop (dp
->name
, sizeflag
);
2285 (*dp
->op1
)(dp
->bytemode1
, sizeflag
);
2290 (*dp
->op2
)(dp
->bytemode2
, sizeflag
);
2295 (*dp
->op3
)(dp
->bytemode3
, sizeflag
);
2298 /* See if any prefixes were not used. If so, print the first one
2299 separately. If we don't do this, we'll wind up printing an
2300 instruction stream which does not precisely correspond to the
2301 bytes we are disassembling. */
2302 if ((prefixes
& ~used_prefixes
) != 0)
2306 name
= prefix_name (inbuf
[0], orig_sizeflag
);
2308 name
= INTERNAL_DISASSEMBLER_ERROR
;
2309 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2313 obufp
= obuf
+ strlen (obuf
);
2314 for (i
= strlen (obuf
); i
< 6; i
++)
2317 (*info
->fprintf_func
) (info
->stream
, "%s", obuf
);
2319 /* The enter and bound instructions are printed with operands in the same
2320 order as the intel book; everything else is printed in reverse order. */
2321 if (intel_syntax
|| two_source_ops
)
2326 op_ad
= op_index
[0];
2327 op_index
[0] = op_index
[2];
2328 op_index
[2] = op_ad
;
2339 if (op_index
[0] != -1)
2340 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[0]], info
);
2342 (*info
->fprintf_func
) (info
->stream
, "%s", first
);
2348 (*info
->fprintf_func
) (info
->stream
, ",");
2349 if (op_index
[1] != -1)
2350 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[1]], info
);
2352 (*info
->fprintf_func
) (info
->stream
, "%s", second
);
2358 (*info
->fprintf_func
) (info
->stream
, ",");
2359 if (op_index
[2] != -1)
2360 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[2]], info
);
2362 (*info
->fprintf_func
) (info
->stream
, "%s", third
);
2364 return codep
- inbuf
;
2367 static const char *float_mem_att
[] = {
2442 static const char *float_mem_intel
[] = {
2518 #define STi OP_STi, 0
2520 #define FGRPd9_2 NULL, NULL, 0, NULL, 0, NULL, 0
2521 #define FGRPd9_4 NULL, NULL, 1, NULL, 0, NULL, 0
2522 #define FGRPd9_5 NULL, NULL, 2, NULL, 0, NULL, 0
2523 #define FGRPd9_6 NULL, NULL, 3, NULL, 0, NULL, 0
2524 #define FGRPd9_7 NULL, NULL, 4, NULL, 0, NULL, 0
2525 #define FGRPda_5 NULL, NULL, 5, NULL, 0, NULL, 0
2526 #define FGRPdb_4 NULL, NULL, 6, NULL, 0, NULL, 0
2527 #define FGRPde_3 NULL, NULL, 7, NULL, 0, NULL, 0
2528 #define FGRPdf_4 NULL, NULL, 8, NULL, 0, NULL, 0
2530 static const struct dis386 float_reg
[][8] = {
2533 { "fadd", ST
, STi
, XX
},
2534 { "fmul", ST
, STi
, XX
},
2535 { "fcom", STi
, XX
, XX
},
2536 { "fcomp", STi
, XX
, XX
},
2537 { "fsub", ST
, STi
, XX
},
2538 { "fsubr", ST
, STi
, XX
},
2539 { "fdiv", ST
, STi
, XX
},
2540 { "fdivr", ST
, STi
, XX
},
2544 { "fld", STi
, XX
, XX
},
2545 { "fxch", STi
, XX
, XX
},
2547 { "(bad)", XX
, XX
, XX
},
2555 { "fcmovb", ST
, STi
, XX
},
2556 { "fcmove", ST
, STi
, XX
},
2557 { "fcmovbe",ST
, STi
, XX
},
2558 { "fcmovu", ST
, STi
, XX
},
2559 { "(bad)", XX
, XX
, XX
},
2561 { "(bad)", XX
, XX
, XX
},
2562 { "(bad)", XX
, XX
, XX
},
2566 { "fcmovnb",ST
, STi
, XX
},
2567 { "fcmovne",ST
, STi
, XX
},
2568 { "fcmovnbe",ST
, STi
, XX
},
2569 { "fcmovnu",ST
, STi
, XX
},
2571 { "fucomi", ST
, STi
, XX
},
2572 { "fcomi", ST
, STi
, XX
},
2573 { "(bad)", XX
, XX
, XX
},
2577 { "fadd", STi
, ST
, XX
},
2578 { "fmul", STi
, ST
, XX
},
2579 { "(bad)", XX
, XX
, XX
},
2580 { "(bad)", XX
, XX
, XX
},
2582 { "fsub", STi
, ST
, XX
},
2583 { "fsubr", STi
, ST
, XX
},
2584 { "fdiv", STi
, ST
, XX
},
2585 { "fdivr", STi
, ST
, XX
},
2587 { "fsubr", STi
, ST
, XX
},
2588 { "fsub", STi
, ST
, XX
},
2589 { "fdivr", STi
, ST
, XX
},
2590 { "fdiv", STi
, ST
, XX
},
2595 { "ffree", STi
, XX
, XX
},
2596 { "(bad)", XX
, XX
, XX
},
2597 { "fst", STi
, XX
, XX
},
2598 { "fstp", STi
, XX
, XX
},
2599 { "fucom", STi
, XX
, XX
},
2600 { "fucomp", STi
, XX
, XX
},
2601 { "(bad)", XX
, XX
, XX
},
2602 { "(bad)", XX
, XX
, XX
},
2606 { "faddp", STi
, ST
, XX
},
2607 { "fmulp", STi
, ST
, XX
},
2608 { "(bad)", XX
, XX
, XX
},
2611 { "fsubp", STi
, ST
, XX
},
2612 { "fsubrp", STi
, ST
, XX
},
2613 { "fdivp", STi
, ST
, XX
},
2614 { "fdivrp", STi
, ST
, XX
},
2616 { "fsubrp", STi
, ST
, XX
},
2617 { "fsubp", STi
, ST
, XX
},
2618 { "fdivrp", STi
, ST
, XX
},
2619 { "fdivp", STi
, ST
, XX
},
2624 { "(bad)", XX
, XX
, XX
},
2625 { "(bad)", XX
, XX
, XX
},
2626 { "(bad)", XX
, XX
, XX
},
2627 { "(bad)", XX
, XX
, XX
},
2629 { "fucomip",ST
, STi
, XX
},
2630 { "fcomip", ST
, STi
, XX
},
2631 { "(bad)", XX
, XX
, XX
},
2636 static char *fgrps
[][8] = {
2639 "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2644 "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)",
2649 "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)",
2654 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp",
2659 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos",
2664 "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2669 "feni(287 only)","fdisi(287 only)","fNclex","fNinit",
2670 "fNsetpm(287 only)","(bad)","(bad)","(bad)",
2675 "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2680 "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2688 const struct dis386
*dp
;
2689 unsigned char floatop
;
2691 floatop
= codep
[-1];
2696 putop (float_mem_intel
[(floatop
- 0xd8 ) * 8 + reg
], sizeflag
);
2698 putop (float_mem_att
[(floatop
- 0xd8 ) * 8 + reg
], sizeflag
);
2700 if (floatop
== 0xdb)
2701 OP_E (x_mode
, sizeflag
);
2702 else if (floatop
== 0xdd)
2703 OP_E (d_mode
, sizeflag
);
2705 OP_E (v_mode
, sizeflag
);
2710 dp
= &float_reg
[floatop
- 0xd8][reg
];
2711 if (dp
->name
== NULL
)
2713 putop (fgrps
[dp
->bytemode1
][rm
], sizeflag
);
2715 /* instruction fnstsw is only one with strange arg */
2716 if (floatop
== 0xdf && codep
[-1] == 0xe0)
2717 strcpy (op1out
, names16
[0]);
2721 putop (dp
->name
, sizeflag
);
2725 (*dp
->op1
)(dp
->bytemode1
, sizeflag
);
2728 (*dp
->op2
)(dp
->bytemode2
, sizeflag
);
2734 OP_ST (ignore
, sizeflag
)
2735 int ignore ATTRIBUTE_UNUSED
;
2736 int sizeflag ATTRIBUTE_UNUSED
;
2743 OP_STi (ignore
, sizeflag
)
2744 int ignore ATTRIBUTE_UNUSED
;
2745 int sizeflag ATTRIBUTE_UNUSED
;
2747 sprintf (scratchbuf
, "%%st(%d)", rm
);
2748 oappend (scratchbuf
);
2752 /* capital letters in template are macros */
2754 putop (template, sizeflag
)
2755 const char *template;
2760 for (p
= template; *p
; p
++)
2771 #ifdef SUFFIX_ALWAYS
2772 || (sizeflag
& SUFFIX_ALWAYS
)
2780 #ifdef SUFFIX_ALWAYS
2781 if (sizeflag
& SUFFIX_ALWAYS
)
2785 case 'E': /* For jcxz/jecxz */
2786 if (sizeflag
& AFLAG
)
2792 #ifdef SUFFIX_ALWAYS
2793 if (sizeflag
& SUFFIX_ALWAYS
)
2798 if ((prefixes
& PREFIX_FWAIT
) == 0)
2801 used_prefixes
|= PREFIX_FWAIT
;
2806 if ((prefixes
& PREFIX_DATA
)
2807 #ifdef SUFFIX_ALWAYS
2808 || (sizeflag
& SUFFIX_ALWAYS
)
2812 if (sizeflag
& DFLAG
)
2816 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2823 #ifdef SUFFIX_ALWAYS
2824 || (sizeflag
& SUFFIX_ALWAYS
)
2828 if (sizeflag
& DFLAG
)
2832 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2838 if (sizeflag
& DFLAG
)
2851 if (sizeflag
& DFLAG
)
2856 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2861 #ifdef SUFFIX_ALWAYS
2862 if (sizeflag
& SUFFIX_ALWAYS
)
2864 if (sizeflag
& DFLAG
)
2868 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2873 /* operand size flag for cwtl, cbtw */
2874 if (sizeflag
& DFLAG
)
2880 if (sizeflag
& DFLAG
)
2890 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2902 obufp
+= strlen (s
);
2908 if (prefixes
& PREFIX_CS
)
2911 used_prefixes
|= PREFIX_CS
;
2913 if (prefixes
& PREFIX_DS
)
2916 used_prefixes
|= PREFIX_DS
;
2918 if (prefixes
& PREFIX_SS
)
2921 used_prefixes
|= PREFIX_SS
;
2923 if (prefixes
& PREFIX_ES
)
2926 used_prefixes
|= PREFIX_ES
;
2928 if (prefixes
& PREFIX_FS
)
2931 used_prefixes
|= PREFIX_FS
;
2933 if (prefixes
& PREFIX_GS
)
2936 used_prefixes
|= PREFIX_GS
;
2941 OP_indirE (bytemode
, sizeflag
)
2947 OP_E (bytemode
, sizeflag
);
2951 OP_E (bytemode
, sizeflag
)
2957 /* skip mod/rm byte */
2965 oappend (names8
[rm
]);
2968 oappend (names16
[rm
]);
2971 oappend (names32
[rm
]);
2974 if (sizeflag
& DFLAG
)
2975 oappend (names32
[rm
]);
2977 oappend (names16
[rm
]);
2978 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2981 if ( !(codep
[-2] == 0xAE && codep
[-1] == 0xF8 /* sfence */))
2982 BadOp(); /* bad sfence,lea,lds,les,lfs,lgs,lss modrm */
2985 oappend (INTERNAL_DISASSEMBLER_ERROR
);
2994 if (sizeflag
& AFLAG
) /* 32 bit address mode */
3009 FETCH_DATA (the_info
, codep
+ 1);
3010 scale
= (*codep
>> 6) & 3;
3011 index
= (*codep
>> 3) & 7;
3026 FETCH_DATA (the_info
, codep
+ 1);
3028 if ((disp
& 0x80) != 0)
3037 if (mod
!= 0 || base
== 5)
3039 sprintf (scratchbuf
, "0x%x", disp
);
3040 oappend (scratchbuf
);
3043 if (havebase
|| (havesib
&& (index
!= 4 || scale
!= 0)))
3050 oappend("BYTE PTR ");
3053 oappend("WORD PTR ");
3056 oappend("DWORD PTR ");
3059 oappend("QWORD PTR ");
3062 oappend("XWORD PTR ");
3068 *obufp
++ = open_char
;
3071 oappend (names32
[base
]);
3080 *obufp
++ = separator_char
;
3083 sprintf (scratchbuf
, "%s", names32
[index
]);
3086 sprintf (scratchbuf
, ",%s", names32
[index
]);
3087 oappend (scratchbuf
);
3091 && bytemode
!= b_mode
3092 && bytemode
!= w_mode
3093 && bytemode
!= v_mode
))
3095 *obufp
++ = scale_char
;
3097 sprintf (scratchbuf
, "%d", 1 << scale
);
3098 oappend (scratchbuf
);
3102 if (mod
!= 0 || base
== 5)
3104 /* Don't print zero displacements */
3107 sprintf (scratchbuf
, "+%d", disp
);
3108 oappend (scratchbuf
);
3112 sprintf (scratchbuf
, "%d", disp
);
3113 oappend (scratchbuf
);
3117 *obufp
++ = close_char
;
3120 else if (intel_syntax
)
3122 if (mod
!= 0 || base
== 5)
3124 if (prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3125 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
))
3129 oappend (names_seg
[3]);
3132 sprintf (scratchbuf
, "0x%x", disp
);
3133 oappend (scratchbuf
);
3138 { /* 16 bit address mode */
3145 if ((disp
& 0x8000) != 0)
3150 FETCH_DATA (the_info
, codep
+ 1);
3152 if ((disp
& 0x80) != 0)
3157 if ((disp
& 0x8000) != 0)
3163 if (mod
!= 0 || rm
== 6)
3165 sprintf (scratchbuf
, "%d", disp
);
3166 oappend (scratchbuf
);
3169 if (mod
!= 0 || rm
!= 6)
3171 *obufp
++ = open_char
;
3173 oappend (index16
[rm
]);
3174 *obufp
++ = close_char
;
3181 OP_G (bytemode
, sizeflag
)
3188 oappend (names8
[reg
]);
3191 oappend (names16
[reg
]);
3194 oappend (names32
[reg
]);
3197 if (sizeflag
& DFLAG
)
3198 oappend (names32
[reg
]);
3200 oappend (names16
[reg
]);
3201 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3204 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3214 FETCH_DATA (the_info
, codep
+ 4);
3215 x
= *codep
++ & 0xff;
3216 x
|= (*codep
++ & 0xff) << 8;
3217 x
|= (*codep
++ & 0xff) << 16;
3218 x
|= (*codep
++ & 0xff) << 24;
3227 FETCH_DATA (the_info
, codep
+ 2);
3228 x
= *codep
++ & 0xff;
3229 x
|= (*codep
++ & 0xff) << 8;
3237 op_index
[op_ad
] = op_ad
;
3238 op_address
[op_ad
] = op
;
3242 OP_REG (code
, sizeflag
)
3253 case ax_reg
: case cx_reg
: case dx_reg
: case bx_reg
:
3254 case sp_reg
: case bp_reg
: case si_reg
: case di_reg
:
3255 s
= names16
[code
- ax_reg
];
3257 case es_reg
: case ss_reg
: case cs_reg
:
3258 case ds_reg
: case fs_reg
: case gs_reg
:
3259 s
= names_seg
[code
- es_reg
];
3261 case al_reg
: case ah_reg
: case cl_reg
: case ch_reg
:
3262 case dl_reg
: case dh_reg
: case bl_reg
: case bh_reg
:
3263 s
= names8
[code
- al_reg
];
3265 case eAX_reg
: case eCX_reg
: case eDX_reg
: case eBX_reg
:
3266 case eSP_reg
: case eBP_reg
: case eSI_reg
: case eDI_reg
:
3267 if (sizeflag
& DFLAG
)
3268 s
= names32
[code
- eAX_reg
];
3270 s
= names16
[code
- eAX_reg
];
3271 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3274 s
= INTERNAL_DISASSEMBLER_ERROR
;
3281 OP_I (bytemode
, sizeflag
)
3290 FETCH_DATA (the_info
, codep
+ 1);
3291 op
= *codep
++ & 0xff;
3294 if (sizeflag
& DFLAG
)
3298 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3304 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3309 sprintf (scratchbuf
, "0x%x", op
);
3311 sprintf (scratchbuf
, "$0x%x", op
);
3312 oappend (scratchbuf
);
3313 scratchbuf
[0] = '\0';
3317 OP_sI (bytemode
, sizeflag
)
3326 FETCH_DATA (the_info
, codep
+ 1);
3328 if ((op
& 0x80) != 0)
3332 if (sizeflag
& DFLAG
)
3337 if ((op
& 0x8000) != 0)
3340 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3344 if ((op
& 0x8000) != 0)
3348 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3352 sprintf (scratchbuf
, "%d", op
);
3354 sprintf (scratchbuf
, "$0x%x", op
);
3355 oappend (scratchbuf
);
3359 OP_J (bytemode
, sizeflag
)
3369 FETCH_DATA (the_info
, codep
+ 1);
3371 if ((disp
& 0x80) != 0)
3375 if (sizeflag
& DFLAG
)
3380 /* for some reason, a data16 prefix on a jump instruction
3381 means that the pc is masked to 16 bits after the
3382 displacement is added! */
3385 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3388 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3391 disp
= (start_pc
+ codep
- start_codep
+ disp
) & mask
;
3393 sprintf (scratchbuf
, "0x%x", disp
);
3394 oappend (scratchbuf
);
3399 OP_SEG (dummy
, sizeflag
)
3400 int dummy ATTRIBUTE_UNUSED
;
3401 int sizeflag ATTRIBUTE_UNUSED
;
3403 static char *sreg
[] = {
3404 "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
3407 oappend (sreg
[reg
]);
3412 OP_DIR (dummy
, sizeflag
)
3413 int dummy ATTRIBUTE_UNUSED
;
3418 if (sizeflag
& DFLAG
)
3428 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3429 sprintf (scratchbuf
, "$0x%x,$0x%x", seg
, offset
);
3430 oappend (scratchbuf
);
3435 OP_OFF (ignore
, sizeflag
)
3436 int ignore ATTRIBUTE_UNUSED
;
3443 if (sizeflag
& AFLAG
)
3450 if (!(prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3451 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
)))
3453 oappend (names_seg
[3]);
3457 sprintf (scratchbuf
, "0x%x", off
);
3458 oappend (scratchbuf
);
3462 ptr_reg (code
, sizeflag
)
3468 if (sizeflag
& AFLAG
)
3469 s
= names32
[code
- eAX_reg
];
3471 s
= names16
[code
- eAX_reg
];
3477 OP_ESreg (code
, sizeflag
)
3482 ptr_reg (code
, sizeflag
);
3486 OP_DSreg (code
, sizeflag
)
3497 prefixes
|= PREFIX_DS
;
3499 ptr_reg (code
, sizeflag
);
3504 OP_C (dummy
, sizeflag
)
3505 int dummy ATTRIBUTE_UNUSED
;
3506 int sizeflag ATTRIBUTE_UNUSED
;
3508 sprintf (scratchbuf
, "%%cr%d", reg
);
3509 oappend (scratchbuf
);
3514 OP_D (dummy
, sizeflag
)
3515 int dummy ATTRIBUTE_UNUSED
;
3516 int sizeflag ATTRIBUTE_UNUSED
;
3518 sprintf (scratchbuf
, "%%db%d", reg
);
3519 oappend (scratchbuf
);
3524 OP_T (dummy
, sizeflag
)
3525 int dummy ATTRIBUTE_UNUSED
;
3526 int sizeflag ATTRIBUTE_UNUSED
;
3528 sprintf (scratchbuf
, "%%tr%d", reg
);
3529 oappend (scratchbuf
);
3533 OP_Rd (bytemode
, sizeflag
)
3538 OP_E (bytemode
, sizeflag
);
3544 OP_MMX (ignore
, sizeflag
)
3545 int ignore ATTRIBUTE_UNUSED
;
3546 int sizeflag ATTRIBUTE_UNUSED
;
3548 sprintf (scratchbuf
, "%%mm%d", reg
);
3549 oappend (scratchbuf
);
3553 OP_XMM (bytemode
, sizeflag
)
3554 int bytemode ATTRIBUTE_UNUSED
;
3555 int sizeflag ATTRIBUTE_UNUSED
;
3557 sprintf (scratchbuf
, "%%xmm%d", reg
);
3558 oappend (scratchbuf
);
3562 OP_EM (bytemode
, sizeflag
)
3568 OP_E (bytemode
, sizeflag
);
3573 sprintf (scratchbuf
, "%%mm%d", rm
);
3574 oappend (scratchbuf
);
3578 OP_EX (bytemode
, sizeflag
)
3584 OP_E (bytemode
, sizeflag
);
3589 sprintf (scratchbuf
, "%%xmm%d", rm
);
3590 oappend (scratchbuf
);
3594 OP_MS (bytemode
, sizeflag
)
3599 OP_EM (bytemode
, sizeflag
);
3604 static const char *Suffix3DNow
[] = {
3605 /* 00 */ NULL
, NULL
, NULL
, NULL
,
3606 /* 04 */ NULL
, NULL
, NULL
, NULL
,
3607 /* 08 */ NULL
, NULL
, NULL
, NULL
,
3608 /* 0C */ "pi2fw", "pi2fd", NULL
, NULL
,
3609 /* 10 */ NULL
, NULL
, NULL
, NULL
,
3610 /* 14 */ NULL
, NULL
, NULL
, NULL
,
3611 /* 18 */ NULL
, NULL
, NULL
, NULL
,
3612 /* 1C */ "pf2iw", "pf2id", NULL
, NULL
,
3613 /* 20 */ NULL
, NULL
, NULL
, NULL
,
3614 /* 24 */ NULL
, NULL
, NULL
, NULL
,
3615 /* 28 */ NULL
, NULL
, NULL
, NULL
,
3616 /* 2C */ NULL
, NULL
, NULL
, NULL
,
3617 /* 30 */ NULL
, NULL
, NULL
, NULL
,
3618 /* 34 */ NULL
, NULL
, NULL
, NULL
,
3619 /* 38 */ NULL
, NULL
, NULL
, NULL
,
3620 /* 3C */ NULL
, NULL
, NULL
, NULL
,
3621 /* 40 */ NULL
, NULL
, NULL
, NULL
,
3622 /* 44 */ NULL
, NULL
, NULL
, NULL
,
3623 /* 48 */ NULL
, NULL
, NULL
, NULL
,
3624 /* 4C */ NULL
, NULL
, NULL
, NULL
,
3625 /* 50 */ NULL
, NULL
, NULL
, NULL
,
3626 /* 54 */ NULL
, NULL
, NULL
, NULL
,
3627 /* 58 */ NULL
, NULL
, NULL
, NULL
,
3628 /* 5C */ NULL
, NULL
, NULL
, NULL
,
3629 /* 60 */ NULL
, NULL
, NULL
, NULL
,
3630 /* 64 */ NULL
, NULL
, NULL
, NULL
,
3631 /* 68 */ NULL
, NULL
, NULL
, NULL
,
3632 /* 6C */ NULL
, NULL
, NULL
, NULL
,
3633 /* 70 */ NULL
, NULL
, NULL
, NULL
,
3634 /* 74 */ NULL
, NULL
, NULL
, NULL
,
3635 /* 78 */ NULL
, NULL
, NULL
, NULL
,
3636 /* 7C */ NULL
, NULL
, NULL
, NULL
,
3637 /* 80 */ NULL
, NULL
, NULL
, NULL
,
3638 /* 84 */ NULL
, NULL
, NULL
, NULL
,
3639 /* 88 */ NULL
, NULL
, "pfnacc", NULL
,
3640 /* 8C */ NULL
, NULL
, "pfpnacc", NULL
,
3641 /* 90 */ "pfcmpge", NULL
, NULL
, NULL
,
3642 /* 94 */ "pfmin", NULL
, "pfrcp", "pfrsqrt",
3643 /* 98 */ NULL
, NULL
, "pfsub", NULL
,
3644 /* 9C */ NULL
, NULL
, "pfadd", NULL
,
3645 /* A0 */ "pfcmpgt", NULL
, NULL
, NULL
,
3646 /* A4 */ "pfmax", NULL
, "pfrcpit1", "pfrsqit1",
3647 /* A8 */ NULL
, NULL
, "pfsubr", NULL
,
3648 /* AC */ NULL
, NULL
, "pfacc", NULL
,
3649 /* B0 */ "pfcmpeq", NULL
, NULL
, NULL
,
3650 /* B4 */ "pfmul", NULL
, "pfrcpit2", "pfmulhrw",
3651 /* B8 */ NULL
, NULL
, NULL
, "pswapd",
3652 /* BC */ NULL
, NULL
, NULL
, "pavgusb",
3653 /* C0 */ NULL
, NULL
, NULL
, NULL
,
3654 /* C4 */ NULL
, NULL
, NULL
, NULL
,
3655 /* C8 */ NULL
, NULL
, NULL
, NULL
,
3656 /* CC */ NULL
, NULL
, NULL
, NULL
,
3657 /* D0 */ NULL
, NULL
, NULL
, NULL
,
3658 /* D4 */ NULL
, NULL
, NULL
, NULL
,
3659 /* D8 */ NULL
, NULL
, NULL
, NULL
,
3660 /* DC */ NULL
, NULL
, NULL
, NULL
,
3661 /* E0 */ NULL
, NULL
, NULL
, NULL
,
3662 /* E4 */ NULL
, NULL
, NULL
, NULL
,
3663 /* E8 */ NULL
, NULL
, NULL
, NULL
,
3664 /* EC */ NULL
, NULL
, NULL
, NULL
,
3665 /* F0 */ NULL
, NULL
, NULL
, NULL
,
3666 /* F4 */ NULL
, NULL
, NULL
, NULL
,
3667 /* F8 */ NULL
, NULL
, NULL
, NULL
,
3668 /* FC */ NULL
, NULL
, NULL
, NULL
,
3672 OP_3DNowSuffix (bytemode
, sizeflag
)
3673 int bytemode ATTRIBUTE_UNUSED
;
3674 int sizeflag ATTRIBUTE_UNUSED
;
3676 const char *mnemonic
;
3678 FETCH_DATA (the_info
, codep
+ 1);
3679 /* AMD 3DNow! instructions are specified by an opcode suffix in the
3680 place where an 8-bit immediate would normally go. ie. the last
3681 byte of the instruction. */
3682 obufp
= obuf
+ strlen(obuf
);
3683 mnemonic
= Suffix3DNow
[*codep
++ & 0xff];
3688 /* Since a variable sized modrm/sib chunk is between the start
3689 of the opcode (0x0f0f) and the opcode suffix, we need to do
3690 all the modrm processing first, and don't know until now that
3691 we have a bad opcode. This necessitates some cleaning up. */
3699 static const char *simd_cmp_op
[] = {
3711 OP_SIMD_Suffix (bytemode
, sizeflag
)
3712 int bytemode ATTRIBUTE_UNUSED
;
3713 int sizeflag ATTRIBUTE_UNUSED
;
3715 unsigned int cmp_type
;
3717 FETCH_DATA (the_info
, codep
+ 1);
3718 obufp
= obuf
+ strlen(obuf
);
3719 cmp_type
= *codep
++ & 0xff;
3722 sprintf (scratchbuf
, "cmp%s%cs",
3723 simd_cmp_op
[cmp_type
],
3724 prefixes
& PREFIX_REPZ
? 's' : 'p');
3725 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
3726 oappend (scratchbuf
);
3730 /* We have a bad extension byte. Clean up. */
3738 SIMD_Fixup (extrachar
, sizeflag
)
3740 int sizeflag ATTRIBUTE_UNUSED
;
3742 /* Change movlps/movhps to movhlps/movlhps for 2 register operand
3743 forms of these instructions. */
3746 char *p
= obuf
+ strlen(obuf
);
3755 static void BadOp (void)
3757 codep
= insn_codep
+ 1; /* throw away prefixes and 1st. opcode byte */