Directly call i386-dregs functions
[deliverable/binutils-gdb.git] / include / opcode / i386.h
CommitLineData
0b1cf022 1/* opcode/i386.h -- Intel 80386 opcode macros
4b95cf5c 2 Copyright (C) 1989-2014 Free Software Foundation, Inc.
252b5132 3
543613e9 4 This file is part of GAS, the GNU Assembler, and GDB, the GNU Debugger.
252b5132 5
543613e9
NC
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
e4e42b45 8 the Free Software Foundation; either version 3 of the License, or
543613e9 9 (at your option) any later version.
252b5132 10
543613e9
NC
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.
252b5132 15
543613e9
NC
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
e4e42b45
NC
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
252b5132 20
d0b47220
AM
21/* The SystemV/386 SVR3.2 assembler, and probably all AT&T derived
22 ix86 Unix assemblers, generate floating point instructions with
23 reversed source and destination registers in certain cases.
24 Unfortunately, gcc and possibly many other programs use this
25 reversed syntax, so we're stuck with it.
252b5132 26
7f3f1ea2
AM
27 eg. `fsub %st(3),%st' results in st = st - st(3) as expected, but
28 `fsub %st,%st(3)' results in st(3) = st - st(3), rather than
29 the expected st(3) = st(3) - st
252b5132
RH
30
31 This happens with all the non-commutative arithmetic floating point
32 operations with two register operands, where the source register is
d796c0ad 33 %st, and destination register is %st(i).
7f3f1ea2
AM
34
35 The affected opcode map is dceX, dcfX, deeX, defX. */
252b5132 36
35669430
DE
37#ifndef OPCODE_I386_H
38#define OPCODE_I386_H
39
d0b47220 40#ifndef SYSV386_COMPAT
252b5132 41/* Set non-zero for broken, compatible instructions. Set to zero for
d0b47220 42 non-broken opcodes at your peril. gcc generates SystemV/386
252b5132 43 compatible instructions. */
d0b47220
AM
44#define SYSV386_COMPAT 1
45#endif
46#ifndef OLDGCC_COMPAT
47/* Set non-zero to cater for old (<= 2.8.1) versions of gcc that could
48 generate nonsense fsubp, fsubrp, fdivp and fdivrp with operands
49 reversed. */
50#define OLDGCC_COMPAT SYSV386_COMPAT
252b5132 51#endif
252b5132 52
252b5132 53#define MOV_AX_DISP32 0xa0
252b5132 54#define POP_SEG_SHORT 0x07
252b5132 55#define JUMP_PC_RELATIVE 0xeb
543613e9 56#define INT_OPCODE 0xcd
252b5132 57#define INT3_OPCODE 0xcc
0b1cf022
L
58/* The opcode for the fwait instruction, which disassembler treats as a
59 prefix when it can. */
252b5132 60#define FWAIT_OPCODE 0x9b
fedc618e
DE
61
62/* Instruction prefixes.
63 NOTE: For certain SSE* instructions, 0x66,0xf2,0xf3 are treated as
64 part of the opcode. Other prefixes may still appear between them
65 and the 0x0f part of the opcode. */
252b5132 66#define ADDR_PREFIX_OPCODE 0x67
252b5132 67#define DATA_PREFIX_OPCODE 0x66
252b5132 68#define LOCK_PREFIX_OPCODE 0xf0
252b5132 69#define CS_PREFIX_OPCODE 0x2e
252b5132 70#define DS_PREFIX_OPCODE 0x3e
252b5132 71#define ES_PREFIX_OPCODE 0x26
252b5132 72#define FS_PREFIX_OPCODE 0x64
252b5132 73#define GS_PREFIX_OPCODE 0x65
252b5132 74#define SS_PREFIX_OPCODE 0x36
252b5132
RH
75#define REPNE_PREFIX_OPCODE 0xf2
76#define REPE_PREFIX_OPCODE 0xf3
42164a71
L
77#define XACQUIRE_PREFIX_OPCODE 0xf2
78#define XRELEASE_PREFIX_OPCODE 0xf3
7e8b059b 79#define BND_PREFIX_OPCODE 0xf2
050dfa73 80
0b1cf022
L
81#define TWO_BYTE_OPCODE_ESCAPE 0x0f
82#define NOP_OPCODE (char) 0x90
050dfa73 83
0b1cf022 84/* register numbers */
35669430
DE
85#define EAX_REG_NUM 0
86#define ECX_REG_NUM 1
87#define EDX_REG_NUM 2
88#define EBX_REG_NUM 3
0b1cf022 89#define ESP_REG_NUM 4
35669430
DE
90#define EBP_REG_NUM 5
91#define ESI_REG_NUM 6
92#define EDI_REG_NUM 7
050dfa73 93
0b1cf022
L
94/* modrm_byte.regmem for twobyte escape */
95#define ESCAPE_TO_TWO_BYTE_ADDRESSING ESP_REG_NUM
96/* index_base_byte.index for no index register addressing */
97#define NO_INDEX_REGISTER ESP_REG_NUM
98/* index_base_byte.base for no base register addressing */
99#define NO_BASE_REGISTER EBP_REG_NUM
100#define NO_BASE_REGISTER_16 6
0f10071e 101
0b1cf022
L
102/* modrm.mode = REGMEM_FIELD_HAS_REG when a register is in there */
103#define REGMEM_FIELD_HAS_REG 0x3/* always = 0x3 */
104#define REGMEM_FIELD_HAS_MEM (~REGMEM_FIELD_HAS_REG)
252b5132 105
35669430
DE
106/* Extract fields from the mod/rm byte. */
107#define MODRM_MOD_FIELD(modrm) (((modrm) >> 6) & 3)
108#define MODRM_REG_FIELD(modrm) (((modrm) >> 3) & 7)
109#define MODRM_RM_FIELD(modrm) (((modrm) >> 0) & 7)
110
111/* Extract fields from the sib byte. */
112#define SIB_SCALE_FIELD(sib) (((sib) >> 6) & 3)
113#define SIB_INDEX_FIELD(sib) (((sib) >> 3) & 7)
114#define SIB_BASE_FIELD(sib) (((sib) >> 0) & 7)
115
0b1cf022
L
116/* x86-64 extension prefix. */
117#define REX_OPCODE 0x40
252b5132 118
35669430
DE
119/* Non-zero if OPCODE is the rex prefix. */
120#define REX_PREFIX_P(opcode) (((opcode) & 0xf0) == REX_OPCODE)
121
0b1cf022 122/* Indicates 64 bit operand size. */
161a04f6 123#define REX_W 8
0b1cf022 124/* High extension to reg field of modrm byte. */
161a04f6 125#define REX_R 4
0b1cf022 126/* High extension to SIB index field. */
161a04f6 127#define REX_X 2
0b1cf022 128/* High extension to base field of modrm or SIB, or reg field of opcode. */
161a04f6 129#define REX_B 1
252b5132 130
0b1cf022 131/* max operands per insn */
c0f3af97 132#define MAX_OPERANDS 5
252b5132 133
0b1cf022
L
134/* max immediates per insn (lcall, ljmp, insertq, extrq) */
135#define MAX_IMMEDIATE_OPERANDS 2
5f47d35b 136
0b1cf022
L
137/* max memory refs per insn (string ops) */
138#define MAX_MEMORY_OPERANDS 2
252b5132 139
0b1cf022 140/* max size of insn mnemonics. */
c0f3af97 141#define MAX_MNEM_SIZE 20
252b5132 142
0b1cf022
L
143/* max size of register name in insn mnemonics. */
144#define MAX_REG_NAME_SIZE 8
35669430
DE
145
146#endif /* OPCODE_I386_H */
This page took 0.580703 seconds and 4 git commands to generate.