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","%?","%?",
707 struct dis386 grps[][8] = {
825 { "imulS", eAX, Ev },
827 { "idivS", eAX, Ev },
845 { "lcall", indirEv },
886 #define PREFIX_REPZ 1
887 #define PREFIX_REPNZ 2
888 #define PREFIX_LOCK 4
890 #define PREFIX_SS 0x10
891 #define PREFIX_DS 0x20
892 #define PREFIX_ES 0x40
893 #define PREFIX_FS 0x80
894 #define PREFIX_GS 0x100
895 #define PREFIX_DATA 0x200
896 #define PREFIX_ADR 0x400
897 #define PREFIX_FWAIT 0x800
907 FETCH_DATA (the_info, codep + 1);
911 prefixes |= PREFIX_REPZ;
914 prefixes |= PREFIX_REPNZ;
917 prefixes |= PREFIX_LOCK;
920 prefixes |= PREFIX_CS;
923 prefixes |= PREFIX_SS;
926 prefixes |= PREFIX_DS;
929 prefixes |= PREFIX_ES;
932 prefixes |= PREFIX_FS;
935 prefixes |= PREFIX_GS;
938 prefixes |= PREFIX_DATA;
941 prefixes |= PREFIX_ADR;
944 prefixes |= PREFIX_FWAIT;
956 static char op1out[100], op2out[100], op3out[100];
957 static int op_address[3], op_ad, op_index[3];
962 * On the 386's of 1988, the maximum length of an instruction is 15 bytes.
963 * (see topic "Redundant prefixes" in the "Differences from 8086"
964 * section of the "Virtual 8086 Mode" chapter.)
965 * 'pc' should be the address of this instruction, it will
966 * be used to print the target address if this is a relative jump or call
967 * The function returns the length of this instruction in bytes.
971 print_insn_i386 (pc, info)
973 disassemble_info *info;
977 int enter_instruction;
978 char *first, *second, *third;
981 struct dis_private priv;
982 bfd_byte *inbuf = priv.the_buffer;
984 info->private_data = (PTR) &priv;
985 priv.max_fetched = priv.the_buffer;
986 priv.insn_start = pc;
987 if (setjmp (priv.bailout) != 0)
996 op_index[0] = op_index[1] = op_index[2] = -1;
1000 start_codep = inbuf;
1005 FETCH_DATA (info, codep + 1);
1007 enter_instruction = 1;
1009 enter_instruction = 0;
1013 if (prefixes & PREFIX_REPZ)
1015 if (prefixes & PREFIX_REPNZ)
1017 if (prefixes & PREFIX_LOCK)
1020 if ((prefixes & PREFIX_FWAIT)
1021 && ((*codep < 0xd8) || (*codep > 0xdf)))
1023 /* fwait not followed by floating point instruction */
1024 (*info->fprintf_func) (info->stream, "fwait");
1028 /* these would be initialized to 0 if disassembling for 8086 or 286 */
1032 if (prefixes & PREFIX_DATA)
1035 if (prefixes & PREFIX_ADR)
1038 oappend ("addr16 ");
1043 FETCH_DATA (info, codep + 2);
1044 dp = &dis386_twobyte[*++codep];
1047 dp = &dis386[*codep];
1050 /* Fetch the mod/reg/rm byte. FIXME: We should be only fetching
1051 this if we need it. As it is, this code loses if there is a
1052 one-byte instruction (without a mod/reg/rm byte) at the end of
1053 the address space. */
1055 FETCH_DATA (info, codep + 1);
1056 mod = (*codep >> 6) & 3;
1057 reg = (*codep >> 3) & 7;
1060 if (dp->name == NULL && dp->bytemode1 == FLOATCODE)
1066 if (dp->name == NULL)
1067 dp = &grps[dp->bytemode1][reg];
1074 (*dp->op1)(dp->bytemode1);
1079 (*dp->op2)(dp->bytemode2);
1084 (*dp->op3)(dp->bytemode3);
1087 obufp = obuf + strlen (obuf);
1088 for (i = strlen (obuf); i < 6; i++)
1091 (*info->fprintf_func) (info->stream, "%s", obuf);
1093 /* enter instruction is printed with operands in the
1094 * same order as the intel book; everything else
1095 * is printed in reverse order
1097 if (enter_instruction)
1102 op_ad = op_index[0];
1103 op_index[0] = op_index[2];
1104 op_index[2] = op_ad;
1115 if (op_index[0] != -1)
1116 (*info->print_address_func) (op_address[op_index[0]], info);
1118 (*info->fprintf_func) (info->stream, "%s", first);
1124 (*info->fprintf_func) (info->stream, ",");
1125 if (op_index[1] != -1)
1126 (*info->print_address_func) (op_address[op_index[1]], info);
1128 (*info->fprintf_func) (info->stream, "%s", second);
1134 (*info->fprintf_func) (info->stream, ",");
1135 if (op_index[2] != -1)
1136 (*info->print_address_func) (op_address[op_index[2]], info);
1138 (*info->fprintf_func) (info->stream, "%s", third);
1140 return (codep - inbuf);
1143 char *float_mem[] = {
1219 #define STi OP_STi, 0
1220 int OP_ST(), OP_STi();
1222 #define FGRPd9_2 NULL, NULL, 0
1223 #define FGRPd9_4 NULL, NULL, 1
1224 #define FGRPd9_5 NULL, NULL, 2
1225 #define FGRPd9_6 NULL, NULL, 3
1226 #define FGRPd9_7 NULL, NULL, 4
1227 #define FGRPda_5 NULL, NULL, 5
1228 #define FGRPdb_4 NULL, NULL, 6
1229 #define FGRPde_3 NULL, NULL, 7
1230 #define FGRPdf_4 NULL, NULL, 8
1232 struct dis386 float_reg[][8] = {
1235 { "fadd", ST, STi },
1236 { "fmul", ST, STi },
1239 { "fsub", ST, STi },
1240 { "fsubr", ST, STi },
1241 { "fdiv", ST, STi },
1242 { "fdivr", ST, STi },
1279 { "fadd", STi, ST },
1280 { "fmul", STi, ST },
1283 { "fsub", STi, ST },
1284 { "fsubr", STi, ST },
1285 { "fdiv", STi, ST },
1286 { "fdivr", STi, ST },
1301 { "faddp", STi, ST },
1302 { "fmulp", STi, ST },
1305 { "fsubp", STi, ST },
1306 { "fsubrp", STi, ST },
1307 { "fdivp", STi, ST },
1308 { "fdivrp", STi, ST },
1324 char *fgrps[][8] = {
1327 "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
1332 "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)",
1337 "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)",
1342 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp",
1347 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos",
1352 "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
1357 "feni(287 only)","fdisi(287 only)","fNclex","fNinit",
1358 "fNsetpm(287 only)","(bad)","(bad)","(bad)",
1363 "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
1368 "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
1376 unsigned char floatop;
1378 floatop = codep[-1];
1382 putop (float_mem[(floatop - 0xd8) * 8 + reg]);
1389 dp = &float_reg[floatop - 0xd8][reg];
1390 if (dp->name == NULL)
1392 putop (fgrps[dp->bytemode1][rm]);
1393 /* instruction fnstsw is only one with strange arg */
1395 && FETCH_DATA (the_info, codep + 1)
1397 strcpy (op1out, "%eax");
1404 (*dp->op1)(dp->bytemode1);
1407 (*dp->op2)(dp->bytemode2);
1425 sprintf (scratchbuf, "%%st(%d)", rm);
1426 oappend (scratchbuf);
1431 /* capital letters in template are macros */
1438 for (p = template; *p; p++)
1445 case 'C': /* For jcxz/jecxz */
1450 if ((prefixes & PREFIX_FWAIT) == 0)
1454 /* operand size flag */
1470 obufp += strlen (s);
1477 if (prefixes & PREFIX_CS)
1479 if (prefixes & PREFIX_DS)
1481 if (prefixes & PREFIX_SS)
1483 if (prefixes & PREFIX_ES)
1485 if (prefixes & PREFIX_FS)
1487 if (prefixes & PREFIX_GS)
1492 OP_indirE (bytemode)
1511 /* skip mod/rm byte */
1523 oappend (names8[rm]);
1526 oappend (names16[rm]);
1530 oappend (names32[rm]);
1532 oappend (names16[rm]);
1535 oappend ("<bad dis table>");
1546 FETCH_DATA (the_info, codep + 1);
1547 scale = (*codep >> 6) & 3;
1548 index = (*codep >> 3) & 7;
1559 /* implies havesib and havebase */
1575 FETCH_DATA (the_info, codep + 1);
1576 disp = *(char *)codep++;
1593 if (mod != 0 || rm == 5 || (havesib && base == 5))
1595 sprintf (scratchbuf, "0x%x", disp);
1596 oappend (scratchbuf);
1599 if (havebase || havesib)
1603 oappend (names32[base]);
1608 sprintf (scratchbuf, ",%s", names32[index]);
1609 oappend (scratchbuf);
1611 sprintf (scratchbuf, ",%d", 1 << scale);
1612 oappend (scratchbuf);
1626 oappend (names8[reg]);
1629 oappend (names16[reg]);
1632 oappend (names32[reg]);
1636 oappend (names32[reg]);
1638 oappend (names16[reg]);
1641 oappend ("<internal disassembler error>");
1652 FETCH_DATA (the_info, codep + 4);
1653 x = *codep++ & 0xff;
1654 x |= (*codep++ & 0xff) << 8;
1655 x |= (*codep++ & 0xff) << 16;
1656 x |= (*codep++ & 0xff) << 24;
1665 FETCH_DATA (the_info, codep + 2);
1666 x = *codep++ & 0xff;
1667 x |= (*codep++ & 0xff) << 8;
1675 op_index[op_ad] = op_ad;
1676 op_address[op_ad] = op;
1687 case indir_dx_reg: s = "(%dx)"; break;
1688 case ax_reg: case cx_reg: case dx_reg: case bx_reg:
1689 case sp_reg: case bp_reg: case si_reg: case di_reg:
1690 s = names16[code - ax_reg];
1692 case es_reg: case ss_reg: case cs_reg:
1693 case ds_reg: case fs_reg: case gs_reg:
1694 s = names_seg[code - es_reg];
1696 case al_reg: case ah_reg: case cl_reg: case ch_reg:
1697 case dl_reg: case dh_reg: case bl_reg: case bh_reg:
1698 s = names8[code - al_reg];
1700 case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg:
1701 case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg:
1703 s = names32[code - eAX_reg];
1705 s = names16[code - eAX_reg];
1708 s = "<internal disassembler error>";
1724 FETCH_DATA (the_info, codep + 1);
1725 op = *codep++ & 0xff;
1737 oappend ("<internal disassembler error>");
1740 sprintf (scratchbuf, "$0x%x", op);
1741 oappend (scratchbuf);
1754 FETCH_DATA (the_info, codep + 1);
1755 op = *(char *)codep++;
1761 op = (short)get16();
1764 op = (short)get16 ();
1767 oappend ("<internal disassembler error>");
1770 sprintf (scratchbuf, "$0x%x", op);
1771 oappend (scratchbuf);
1785 FETCH_DATA (the_info, codep + 1);
1786 disp = *(char *)codep++;
1793 disp = (short)get16 ();
1794 /* for some reason, a data16 prefix on a jump instruction
1795 means that the pc is masked to 16 bits after the
1796 displacement is added! */
1801 oappend ("<internal disassembler error>");
1804 disp = (start_pc + codep - start_codep + disp) & mask;
1806 sprintf (scratchbuf, "0x%x", disp);
1807 oappend (scratchbuf);
1816 static char *sreg[] = {
1817 "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
1820 oappend (sreg[reg]);
1843 sprintf (scratchbuf, "0x%x,0x%x", seg, offset);
1844 oappend (scratchbuf);
1850 offset = (short)get16 ();
1852 offset = start_pc + codep - start_codep + offset;
1854 sprintf (scratchbuf, "0x%x", offset);
1855 oappend (scratchbuf);
1858 oappend ("<internal disassembler error>");
1876 sprintf (scratchbuf, "0x%x", off);
1877 oappend (scratchbuf);
1887 oappend (aflag ? "%edi" : "%di");
1898 oappend (aflag ? "%esi" : "%si");
1917 codep++; /* skip mod/rm */
1918 sprintf (scratchbuf, "%%cr%d", reg);
1919 oappend (scratchbuf);
1928 codep++; /* skip mod/rm */
1929 sprintf (scratchbuf, "%%db%d", reg);
1930 oappend (scratchbuf);
1939 codep++; /* skip mod/rm */
1940 sprintf (scratchbuf, "%%tr%d", reg);
1941 oappend (scratchbuf);
1952 oappend (names32[rm]);
1955 oappend (names16[rm]);