1 /* Print i386 instructions for GDB, the GNU debugger.
2 Copyright (C) 1988, 1989, 1991, 1993, 1994 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 * 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu)
23 * modified by John Hassey (hassey@dg-rtp.dg.com)
27 * The main tables describing the instructions is essentially a copy
28 * of the "Opcode Map" chapter (Appendix A) of the Intel 80386
29 * Programmers Manual. Usually, there is a capital letter, followed
30 * by a small letter. The capital letter tell the addressing mode,
31 * and the small letter tells about the operand size. Refer to
32 * the Intel manual for details.
44 /* Points to first byte not fetched. */
45 bfd_byte
*max_fetched
;
46 bfd_byte the_buffer
[MAXLEN
];
51 /* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
52 to ADDR (exclusive) are valid. Returns 1 for success, longjmps
54 #define FETCH_DATA(info, addr) \
55 ((addr) <= ((struct dis_private *)(info->private_data))->max_fetched \
56 ? 1 : fetch_data ((info), (addr)))
59 fetch_data (info
, addr
)
60 struct disassemble_info
*info
;
64 struct dis_private
*priv
= (struct dis_private
*)info
->private_data
;
65 bfd_vma start
= priv
->insn_start
+ (priv
->max_fetched
- priv
->the_buffer
);
67 status
= (*info
->read_memory_func
) (start
,
69 addr
- priv
->max_fetched
,
73 (*info
->memory_error_func
) (status
, start
, info
);
74 longjmp (priv
->bailout
, 1);
77 priv
->max_fetched
= addr
;
81 #define Eb OP_E, b_mode
82 #define indirEb OP_indirE, b_mode
83 #define Gb OP_G, b_mode
84 #define Ev OP_E, v_mode
85 #define indirEv OP_indirE, v_mode
86 #define Ew OP_E, w_mode
87 #define Ma OP_E, v_mode
89 #define Mp OP_E, 0 /* ? */
90 #define Gv OP_G, v_mode
91 #define Gw OP_G, w_mode
92 #define Rw OP_rm, w_mode
93 #define Rd OP_rm, d_mode
94 #define Ib OP_I, b_mode
95 #define sIb OP_sI, b_mode /* sign extened byte */
96 #define Iv OP_I, v_mode
97 #define Iw OP_I, w_mode
98 #define Jb OP_J, b_mode
99 #define Jv OP_J, v_mode
100 #define ONE OP_ONE, 0
101 #define Cd OP_C, d_mode
102 #define Dd OP_D, d_mode
103 #define Td OP_T, d_mode
105 #define eAX OP_REG, eAX_reg
106 #define eBX OP_REG, eBX_reg
107 #define eCX OP_REG, eCX_reg
108 #define eDX OP_REG, eDX_reg
109 #define eSP OP_REG, eSP_reg
110 #define eBP OP_REG, eBP_reg
111 #define eSI OP_REG, eSI_reg
112 #define eDI OP_REG, eDI_reg
113 #define AL OP_REG, al_reg
114 #define CL OP_REG, cl_reg
115 #define DL OP_REG, dl_reg
116 #define BL OP_REG, bl_reg
117 #define AH OP_REG, ah_reg
118 #define CH OP_REG, ch_reg
119 #define DH OP_REG, dh_reg
120 #define BH OP_REG, bh_reg
121 #define AX OP_REG, ax_reg
122 #define DX OP_REG, dx_reg
123 #define indirDX OP_REG, indir_dx_reg
125 #define Sw OP_SEG, w_mode
126 #define Ap OP_DIR, lptr
127 #define Av OP_DIR, v_mode
128 #define Ob OP_OFF, b_mode
129 #define Ov OP_OFF, v_mode
130 #define Xb OP_DSSI, b_mode
131 #define Xv OP_DSSI, v_mode
132 #define Yb OP_ESDI, b_mode
133 #define Yv OP_ESDI, v_mode
135 #define es OP_REG, es_reg
136 #define ss OP_REG, ss_reg
137 #define cs OP_REG, cs_reg
138 #define ds OP_REG, ds_reg
139 #define fs OP_REG, fs_reg
140 #define gs OP_REG, gs_reg
142 int OP_E(), OP_indirE(), OP_G(), OP_I(), OP_sI(), OP_REG();
143 int OP_J(), OP_SEG();
144 int OP_DIR(), OP_OFF(), OP_DSSI(), OP_ESDI(), OP_ONE(), OP_C();
145 int OP_D(), OP_T(), OP_rm();
147 static void dofloat (), putop (), append_prefix (), set_op ();
148 static int get16 (), get32 ();
190 #define indir_dx_reg 150
192 #define GRP1b NULL, NULL, 0
193 #define GRP1S NULL, NULL, 1
194 #define GRP1Ss NULL, NULL, 2
195 #define GRP2b NULL, NULL, 3
196 #define GRP2S NULL, NULL, 4
197 #define GRP2b_one NULL, NULL, 5
198 #define GRP2S_one NULL, NULL, 6
199 #define GRP2b_cl NULL, NULL, 7
200 #define GRP2S_cl NULL, NULL, 8
201 #define GRP3b NULL, NULL, 9
202 #define GRP3S NULL, NULL, 10
203 #define GRP4 NULL, NULL, 11
204 #define GRP5 NULL, NULL, 12
205 #define GRP6 NULL, NULL, 13
206 #define GRP7 NULL, NULL, 14
207 #define GRP8 NULL, NULL, 15
210 #define FLOAT NULL, NULL, FLOATCODE
222 struct dis386 dis386
[] = {
240 { "(bad)" }, /* 0x0f extended opcode escape */
266 { "(bad)" }, /* SEG ES prefix */
275 { "(bad)" }, /* SEG CS prefix */
284 { "(bad)" }, /* SEG SS prefix */
293 { "(bad)" }, /* SEG DS prefix */
334 { "boundS", Gv
, Ma
},
336 { "(bad)" }, /* seg fs */
337 { "(bad)" }, /* seg gs */
338 { "(bad)" }, /* op size prefix */
339 { "(bad)" }, /* adr size prefix */
341 { "pushS", Iv
}, /* 386 book wrong */
342 { "imulS", Gv
, Ev
, Iv
},
343 { "pushl", sIb
}, /* push of byte really pushes 4 bytes */
344 { "imulS", Gv
, Ev
, Ib
},
345 { "insb", Yb
, indirDX
},
346 { "insS", Yv
, indirDX
},
347 { "outsb", indirDX
, Xb
},
348 { "outsS", indirDX
, Xv
},
387 { "xchgS", eCX
, eAX
},
388 { "xchgS", eDX
, eAX
},
389 { "xchgS", eBX
, eAX
},
390 { "xchgS", eSP
, eAX
},
391 { "xchgS", eBP
, eAX
},
392 { "xchgS", eSI
, eAX
},
393 { "xchgS", eDI
, eAX
},
398 { "(bad)" }, /* fwait */
414 { "testS", eAX
, Iv
},
416 { "stosS", Yv
, eAX
},
418 { "lodsS", eAX
, Xv
},
420 { "scasS", eAX
, Yv
},
489 { "inb", AL
, indirDX
},
490 { "inS", eAX
, indirDX
},
491 { "outb", indirDX
, AL
},
492 { "outS", indirDX
, eAX
},
494 { "(bad)" }, /* lock prefix */
496 { "(bad)" }, /* repne */
497 { "(bad)" }, /* repz */
513 struct dis386 dis386_twobyte
[] = {
526 { "(bad)" }, { "(bad)" },
527 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
529 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
530 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
532 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
533 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
535 /* these are all backward in appendix A of the intel book */
545 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
546 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
548 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
549 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
551 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
552 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
554 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
555 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
557 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
558 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
560 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
561 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
563 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
564 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
566 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
567 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
569 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
570 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
572 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
573 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
575 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
576 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
618 { "shldS", Ev
, Gv
, Ib
},
619 { "shldS", Ev
, Gv
, CL
},
627 { "shrdS", Ev
, Gv
, Ib
},
628 { "shrdS", Ev
, Gv
, CL
},
632 { "cmpxchgb", Eb
, Gb
},
633 { "cmpxchgS", Ev
, Gv
},
634 { "lssS", Gv
, Mp
}, /* 386 lists only Mp */
636 { "lfsS", Gv
, Mp
}, /* 386 lists only Mp */
637 { "lgsS", Gv
, Mp
}, /* 386 lists only Mp */
638 { "movzbS", Gv
, Eb
},
639 { "movzwS", Gv
, Ew
},
647 { "movsbS", Gv
, Eb
},
648 { "movswS", Gv
, Ew
},
652 { "(bad)" }, { "(bad)" },
653 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
664 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
665 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
667 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
668 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
670 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
671 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
673 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
674 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
676 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
677 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
679 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
680 { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" },
683 static char obuf
[100];
685 static char scratchbuf
[100];
686 static unsigned char *start_codep
;
687 static unsigned char *codep
;
688 static disassemble_info
*the_info
;
692 static void oappend ();
694 static char *names32
[]={
695 "%eax","%ecx","%edx","%ebx", "%esp","%ebp","%esi","%edi",
697 static char *names16
[] = {
698 "%ax","%cx","%dx","%bx","%sp","%bp","%si","%di",
700 static char *names8
[] = {
701 "%al","%cl","%dl","%bl","%ah","%ch","%dh","%bh",
703 static char *names_seg
[] = {
704 "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
706 static char *names_rmw
[] = {
707 "%bx,%si","%bx,%di","%bp,%si","%bp,%di","%si","%di","%bp","%bx",
710 struct dis386 grps
[][8] = {
828 { "imulS", eAX
, Ev
},
830 { "idivS", eAX
, Ev
},
848 { "lcall", indirEv
},
889 #define PREFIX_REPZ 1
890 #define PREFIX_REPNZ 2
891 #define PREFIX_LOCK 4
893 #define PREFIX_SS 0x10
894 #define PREFIX_DS 0x20
895 #define PREFIX_ES 0x40
896 #define PREFIX_FS 0x80
897 #define PREFIX_GS 0x100
898 #define PREFIX_DATA 0x200
899 #define PREFIX_ADR 0x400
900 #define PREFIX_FWAIT 0x800
910 FETCH_DATA (the_info
, codep
+ 1);
914 prefixes
|= PREFIX_REPZ
;
917 prefixes
|= PREFIX_REPNZ
;
920 prefixes
|= PREFIX_LOCK
;
923 prefixes
|= PREFIX_CS
;
926 prefixes
|= PREFIX_SS
;
929 prefixes
|= PREFIX_DS
;
932 prefixes
|= PREFIX_ES
;
935 prefixes
|= PREFIX_FS
;
938 prefixes
|= PREFIX_GS
;
941 prefixes
|= PREFIX_DATA
;
944 prefixes
|= PREFIX_ADR
;
947 prefixes
|= PREFIX_FWAIT
;
960 static char op1out
[100], op2out
[100], op3out
[100];
961 static int op_address
[3], op_ad
, op_index
[3];
966 * On the 386's of 1988, the maximum length of an instruction is 15 bytes.
967 * (see topic "Redundant prefixes" in the "Differences from 8086"
968 * section of the "Virtual 8086 Mode" chapter.)
969 * 'pc' should be the address of this instruction, it will
970 * be used to print the target address if this is a relative jump or call
971 * The function returns the length of this instruction in bytes.
974 print_insn_i286_or_i386 (pc
, info
)
976 disassemble_info
*info
;
980 int enter_instruction
;
981 char *first
, *second
, *third
;
984 struct dis_private priv
;
985 bfd_byte
*inbuf
= priv
.the_buffer
;
987 info
->private_data
= (PTR
) &priv
;
988 priv
.max_fetched
= priv
.the_buffer
;
989 priv
.insn_start
= pc
;
990 if (setjmp (priv
.bailout
) != 0)
999 op_index
[0] = op_index
[1] = op_index
[2] = -1;
1003 start_codep
= inbuf
;
1008 FETCH_DATA (info
, codep
+ 1);
1010 enter_instruction
= 1;
1012 enter_instruction
= 0;
1016 if (prefixes
& PREFIX_REPZ
)
1018 if (prefixes
& PREFIX_REPNZ
)
1020 if (prefixes
& PREFIX_LOCK
)
1023 if ((prefixes
& PREFIX_FWAIT
)
1024 && ((*codep
< 0xd8) || (*codep
> 0xdf)))
1026 /* fwait not followed by floating point instruction */
1027 (*info
->fprintf_func
) (info
->stream
, "fwait");
1031 if (prefixes
& PREFIX_DATA
)
1034 if (prefixes
& PREFIX_ADR
)
1037 oappend ("addr16 ");
1042 FETCH_DATA (info
, codep
+ 2);
1043 dp
= &dis386_twobyte
[*++codep
];
1046 dp
= &dis386
[*codep
];
1049 /* Fetch the mod/reg/rm byte. FIXME: We should be only fetching
1050 this if we need it. As it is, this code loses if there is a
1051 one-byte instruction (without a mod/reg/rm byte) at the end of
1052 the address space. */
1054 FETCH_DATA (info
, codep
+ 1);
1055 mod
= (*codep
>> 6) & 3;
1056 reg
= (*codep
>> 3) & 7;
1059 if (dp
->name
== NULL
&& dp
->bytemode1
== FLOATCODE
)
1065 if (dp
->name
== NULL
)
1066 dp
= &grps
[dp
->bytemode1
][reg
];
1073 (*dp
->op1
)(dp
->bytemode1
);
1078 (*dp
->op2
)(dp
->bytemode2
);
1083 (*dp
->op3
)(dp
->bytemode3
);
1086 obufp
= obuf
+ strlen (obuf
);
1087 for (i
= strlen (obuf
); i
< 6; i
++)
1090 (*info
->fprintf_func
) (info
->stream
, "%s", obuf
);
1092 /* enter instruction is printed with operands in the
1093 * same order as the intel book; everything else
1094 * is printed in reverse order
1096 if (enter_instruction
)
1101 op_ad
= op_index
[0];
1102 op_index
[0] = op_index
[2];
1103 op_index
[2] = op_ad
;
1114 if (op_index
[0] != -1)
1115 (*info
->print_address_func
) (op_address
[op_index
[0]], info
);
1117 (*info
->fprintf_func
) (info
->stream
, "%s", first
);
1123 (*info
->fprintf_func
) (info
->stream
, ",");
1124 if (op_index
[1] != -1)
1125 (*info
->print_address_func
) (op_address
[op_index
[1]], info
);
1127 (*info
->fprintf_func
) (info
->stream
, "%s", second
);
1133 (*info
->fprintf_func
) (info
->stream
, ",");
1134 if (op_index
[2] != -1)
1135 (*info
->print_address_func
) (op_address
[op_index
[2]], info
);
1137 (*info
->fprintf_func
) (info
->stream
, "%s", third
);
1139 return (codep
- inbuf
);
1143 print_insn_i286 (pc
, info
)
1145 disassemble_info
*info
;
1150 return print_insn_i286_or_i386 (pc
, info
);
1154 print_insn_i386 (pc
, info
)
1156 disassemble_info
*info
;
1161 return print_insn_i286_or_i386 (pc
, info
, 36);
1164 char *float_mem
[] = {
1240 #define STi OP_STi, 0
1241 int OP_ST(), OP_STi();
1243 #define FGRPd9_2 NULL, NULL, 0
1244 #define FGRPd9_4 NULL, NULL, 1
1245 #define FGRPd9_5 NULL, NULL, 2
1246 #define FGRPd9_6 NULL, NULL, 3
1247 #define FGRPd9_7 NULL, NULL, 4
1248 #define FGRPda_5 NULL, NULL, 5
1249 #define FGRPdb_4 NULL, NULL, 6
1250 #define FGRPde_3 NULL, NULL, 7
1251 #define FGRPdf_4 NULL, NULL, 8
1253 struct dis386 float_reg
[][8] = {
1256 { "fadd", ST
, STi
},
1257 { "fmul", ST
, STi
},
1260 { "fsub", ST
, STi
},
1261 { "fsubr", ST
, STi
},
1262 { "fdiv", ST
, STi
},
1263 { "fdivr", ST
, STi
},
1300 { "fadd", STi
, ST
},
1301 { "fmul", STi
, ST
},
1304 { "fsub", STi
, ST
},
1305 { "fsubr", STi
, ST
},
1306 { "fdiv", STi
, ST
},
1307 { "fdivr", STi
, ST
},
1322 { "faddp", STi
, ST
},
1323 { "fmulp", STi
, ST
},
1326 { "fsubp", STi
, ST
},
1327 { "fsubrp", STi
, ST
},
1328 { "fdivp", STi
, ST
},
1329 { "fdivrp", STi
, ST
},
1345 char *fgrps
[][8] = {
1348 "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
1353 "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)",
1358 "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)",
1363 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp",
1368 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos",
1373 "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
1378 "feni(287 only)","fdisi(287 only)","fNclex","fNinit",
1379 "fNsetpm(287 only)","(bad)","(bad)","(bad)",
1384 "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
1389 "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
1397 unsigned char floatop
;
1399 floatop
= codep
[-1];
1403 putop (float_mem
[(floatop
- 0xd8) * 8 + reg
]);
1410 dp
= &float_reg
[floatop
- 0xd8][reg
];
1411 if (dp
->name
== NULL
)
1413 putop (fgrps
[dp
->bytemode1
][rm
]);
1414 /* instruction fnstsw is only one with strange arg */
1416 && FETCH_DATA (the_info
, codep
+ 1)
1418 strcpy (op1out
, "%eax");
1425 (*dp
->op1
)(dp
->bytemode1
);
1428 (*dp
->op2
)(dp
->bytemode2
);
1446 sprintf (scratchbuf
, "%%st(%d)", rm
);
1447 oappend (scratchbuf
);
1452 /* capital letters in template are macros */
1459 for (p
= template; *p
; p
++)
1466 case 'C': /* For jcxz/jecxz */
1471 if ((prefixes
& PREFIX_FWAIT
) == 0)
1475 /* operand size flag */
1491 obufp
+= strlen (s
);
1498 if (prefixes
& PREFIX_CS
)
1500 if (prefixes
& PREFIX_DS
)
1502 if (prefixes
& PREFIX_SS
)
1504 if (prefixes
& PREFIX_ES
)
1506 if (prefixes
& PREFIX_FS
)
1508 if (prefixes
& PREFIX_GS
)
1513 OP_indirE (bytemode
)
1532 /* skip mod/rm byte */
1544 oappend (names8
[rm
]);
1547 oappend (names16
[rm
]);
1551 oappend (names32
[rm
]);
1553 oappend (names16
[rm
]);
1556 oappend ("<bad dis table>");
1566 if (mod
== 0 && rm
== 6)
1568 sprintf (scratchbuf
, "0x%04x", get16 ());
1569 oappend (scratchbuf
);
1575 FETCH_DATA (the_info
, codep
+ 1);
1576 disp
= *(char *)codep
++;
1584 sprintf (scratchbuf
, "0x%x", disp
& 0xffff);
1585 oappend (scratchbuf
);
1588 sprintf (scratchbuf
, "(%s)", names_rmw
[rm
]);
1589 oappend (scratchbuf
);
1597 FETCH_DATA (the_info
, codep
+ 1);
1598 scale
= (*codep
>> 6) & 3;
1599 index
= (*codep
>> 3) & 7;
1610 /* implies havesib and havebase */
1626 FETCH_DATA (the_info
, codep
+ 1);
1627 disp
= *(char *)codep
++;
1644 if (mod
!= 0 || rm
== 5 || (havesib
&& base
== 5))
1646 sprintf (scratchbuf
, "0x%x", disp
);
1647 oappend (scratchbuf
);
1650 if (havebase
|| havesib
)
1654 oappend (names32
[base
]);
1659 sprintf (scratchbuf
, ",%s", names32
[index
]);
1660 oappend (scratchbuf
);
1662 sprintf (scratchbuf
, ",%d", 1 << scale
);
1663 oappend (scratchbuf
);
1677 oappend (names8
[reg
]);
1680 oappend (names16
[reg
]);
1683 oappend (names32
[reg
]);
1687 oappend (names32
[reg
]);
1689 oappend (names16
[reg
]);
1692 oappend ("<internal disassembler error>");
1703 FETCH_DATA (the_info
, codep
+ 4);
1704 x
= *codep
++ & 0xff;
1705 x
|= (*codep
++ & 0xff) << 8;
1706 x
|= (*codep
++ & 0xff) << 16;
1707 x
|= (*codep
++ & 0xff) << 24;
1716 FETCH_DATA (the_info
, codep
+ 2);
1717 x
= *codep
++ & 0xff;
1718 x
|= (*codep
++ & 0xff) << 8;
1726 op_index
[op_ad
] = op_ad
;
1727 op_address
[op_ad
] = op
;
1738 case indir_dx_reg
: s
= "(%dx)"; break;
1739 case ax_reg
: case cx_reg
: case dx_reg
: case bx_reg
:
1740 case sp_reg
: case bp_reg
: case si_reg
: case di_reg
:
1741 s
= names16
[code
- ax_reg
];
1743 case es_reg
: case ss_reg
: case cs_reg
:
1744 case ds_reg
: case fs_reg
: case gs_reg
:
1745 s
= names_seg
[code
- es_reg
];
1747 case al_reg
: case ah_reg
: case cl_reg
: case ch_reg
:
1748 case dl_reg
: case dh_reg
: case bl_reg
: case bh_reg
:
1749 s
= names8
[code
- al_reg
];
1751 case eAX_reg
: case eCX_reg
: case eDX_reg
: case eBX_reg
:
1752 case eSP_reg
: case eBP_reg
: case eSI_reg
: case eDI_reg
:
1754 s
= names32
[code
- eAX_reg
];
1756 s
= names16
[code
- eAX_reg
];
1759 s
= "<internal disassembler error>";
1775 FETCH_DATA (the_info
, codep
+ 1);
1776 op
= *codep
++ & 0xff;
1788 oappend ("<internal disassembler error>");
1791 sprintf (scratchbuf
, "$0x%x", op
);
1792 oappend (scratchbuf
);
1805 FETCH_DATA (the_info
, codep
+ 1);
1806 op
= *(char *)codep
++;
1812 op
= (short)get16();
1815 op
= (short)get16 ();
1818 oappend ("<internal disassembler error>");
1821 sprintf (scratchbuf
, "$0x%x", op
);
1822 oappend (scratchbuf
);
1836 FETCH_DATA (the_info
, codep
+ 1);
1837 disp
= *(char *)codep
++;
1844 disp
= (short)get16 ();
1845 /* for some reason, a data16 prefix on a jump instruction
1846 means that the pc is masked to 16 bits after the
1847 displacement is added! */
1852 oappend ("<internal disassembler error>");
1855 disp
= (start_pc
+ codep
- start_codep
+ disp
) & mask
;
1857 sprintf (scratchbuf
, "0x%x", disp
);
1858 oappend (scratchbuf
);
1867 static char *sreg
[] = {
1868 "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
1871 oappend (sreg
[reg
]);
1894 sprintf (scratchbuf
, "0x%x,0x%x", seg
, offset
);
1895 oappend (scratchbuf
);
1901 offset
= (short)get16 ();
1903 offset
= start_pc
+ codep
- start_codep
+ offset
;
1905 sprintf (scratchbuf
, "0x%x", offset
);
1906 oappend (scratchbuf
);
1909 oappend ("<internal disassembler error>");
1927 sprintf (scratchbuf
, "0x%x", off
);
1928 oappend (scratchbuf
);
1938 oappend (aflag
? "%edi" : "%di");
1949 oappend (aflag
? "%esi" : "%si");
1968 codep
++; /* skip mod/rm */
1969 sprintf (scratchbuf
, "%%cr%d", reg
);
1970 oappend (scratchbuf
);
1979 codep
++; /* skip mod/rm */
1980 sprintf (scratchbuf
, "%%db%d", reg
);
1981 oappend (scratchbuf
);
1990 codep
++; /* skip mod/rm */
1991 sprintf (scratchbuf
, "%%tr%d", reg
);
1992 oappend (scratchbuf
);
2003 oappend (names32
[rm
]);
2006 oappend (names16
[rm
]);