1 /* tc-i386.h -- Header file for tc-i386.c
2 Copyright (C) 1989, 1992 Free Software Foundation.
4 This file is part of GAS, the GNU Assembler.
6 GAS 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, or (at your option)
11 GAS 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 GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 * $FreeBSD: src/gnu/usr.bin/as/config/tc-i386.h,v 1.6 1999/08/27 23:34:30 peter Exp $
27 #define AOUT_MACHTYPE 134
29 #define REVERSE_SORT_RELOCS
31 #define LOCAL_LABELS_FB
33 #define tc_coff_symbol_emit_hook(a) ; /* not used */
35 /* Local labels starts with .L */
36 /* fixme-now: this is for testing against old gas */
37 /* #define LOCAL_LABEL(name) ((name)[0] == '.' && (name)[1] == 'L') */
38 #define tc_aout_pre_write_hook(x) {;} /* not used */
39 #define tc_crawl_symbol_chain(a) {;} /* not used */
40 #define tc_headers_hook(a) {;} /* not used */
42 #define MAX_OPERANDS 3 /* max operands per insn */
43 #define MAX_PREFIXES 4 /* max prefixes per opcode */
44 #define MAX_IMMEDIATE_OPERANDS 2 /* max immediates per insn */
45 #define MAX_MEMORY_OPERANDS 2 /* max memory ref per insn
48 /* we define the syntax here (modulo base,index,scale syntax) */
49 #define REGISTER_PREFIX '%'
50 #define IMMEDIATE_PREFIX '$'
51 #define ABSOLUTE_PREFIX '*'
52 #define PREFIX_SEPERATOR '/'
54 #define TWO_BYTE_OPCODE_ESCAPE 0x0f
57 #define NOP_OPCODE 0x90
59 #define NOP_OPCODE 0x00
62 /* register numbers */
66 /* modrm_byte.regmem for twobyte escape */
67 #define ESCAPE_TO_TWO_BYTE_ADDRESSING ESP_REG_NUM
68 /* index_base_byte.index for no index register addressing */
69 #define NO_INDEX_REGISTER ESP_REG_NUM
70 /* index_base_byte.base for no base register addressing */
71 #define NO_BASE_REGISTER EBP_REG_NUM
73 /* these are the att as opcode suffixes, making movl --> mov, for example */
74 #define DWORD_OPCODE_SUFFIX 'l'
75 #define WORD_OPCODE_SUFFIX 'w'
76 #define BYTE_OPCODE_SUFFIX 'b'
78 /* modrm.mode = REGMEM_FIELD_HAS_REG when a register is in there */
79 #define REGMEM_FIELD_HAS_REG 0x3 /* always = 0x3 */
80 #define REGMEM_FIELD_HAS_MEM (~REGMEM_FIELD_HAS_REG)
82 #define END_OF_INSN '\0'
85 When an operand is read in it is classified by its type. This type includes
86 all the possible ways an operand can be used. Thus, '%eax' is both 'register
87 # 0' and 'The Accumulator'. In our language this is expressed by OR'ing
88 'Reg32' (any 32 bit register) and 'Acc' (the accumulator).
89 Operands are classified so that we can match given operand types with
90 the opcode table in i386-opcode.h.
94 #define Reg8 0x1 /* 8 bit reg */
95 #define Reg16 0x2 /* 16 bit reg */
96 #define Reg32 0x4 /* 32 bit reg */
97 #define Reg (Reg8|Reg16|Reg32) /* gen'l register */
98 #define WordReg (Reg16|Reg32) /* for push/pop operands */
100 #define Imm8 0x8 /* 8 bit immediate */
101 #define Imm8S 0x10 /* 8 bit immediate sign extended */
102 #define Imm16 0x20 /* 16 bit immediate */
103 #define Imm32 0x40 /* 32 bit immediate */
104 #define Imm1 0x80 /* 1 bit immediate */
105 #define ImmUnknown Imm32 /* for unknown expressions */
106 #define Imm (Imm8|Imm8S|Imm16|Imm32) /* gen'l immediate */
108 #define Disp8 0x200 /* 8 bit displacement (for jumps) */
109 #define Disp16 0x400 /* 16 bit displacement */
110 #define Disp32 0x800 /* 32 bit displacement */
111 #define Disp (Disp8|Disp16|Disp32) /* General displacement */
112 #define DispUnknown Disp32 /* for unknown size displacements */
116 #define BaseIndex 0x8000
117 #define Mem (Disp|Mem8|Mem16|Mem32|BaseIndex) /* General memory */
118 #define WordMem (Mem16|Mem32|Disp|BaseIndex)
119 #define ByteMem (Mem8|Disp|BaseIndex)
121 #define InOutPortReg 0x10000 /* register to hold in/out port addr = dx */
122 #define ShiftCount 0x20000 /* register to hold shift cound = cl */
123 #define Control 0x40000 /* Control register */
124 #define Debug 0x80000 /* Debug register */
125 #define Test 0x100000 /* Test register */
126 #define FloatReg 0x200000 /* Float register */
127 #define FloatAcc 0x400000 /* Float stack top %st(0) */
128 #define SReg2 0x800000 /* 2 bit segment register */
129 #define SReg3 0x1000000 /* 3 bit segment register */
130 #define Acc 0x2000000 /* Accumulator %al or %ax or %eax */
131 #define ImplicitRegister (InOutPortReg|ShiftCount|Acc|FloatAcc)
132 #define JumpAbsolute 0x4000000
133 #define Abs8 0x08000000
134 #define Abs16 0x10000000
135 #define Abs32 0x20000000
136 #define Abs (Abs8|Abs16|Abs32)
138 #define Byte (Reg8|Imm8|Imm8S)
139 #define Word (Reg16|Imm16)
140 #define DWord (Reg32|Imm32)
142 #define SMALLEST_DISP_TYPE(num) \
143 fits_in_signed_byte(num) ? (Disp8|Disp32|Abs8|Abs32) : (Disp32|Abs32)
146 /* instruction name sans width suffix ("mov" for movl insns) */
149 /* how many operands */
150 unsigned int operands;
152 /* base_opcode is the fundamental opcode byte with a optional prefix(es). */
153 unsigned int base_opcode;
155 /* extension_opcode is the 3 bit extension for group <n> insns.
156 If this template has no extension opcode (the usual case) use None */
157 unsigned char extension_opcode;
158 #define None 0xff /* If no extension_opcode is possible. */
160 /* the bits in opcode_modifier are used to generate the final opcode from
161 the base_opcode. These bits also are used to detect alternate forms of
162 the same instruction */
163 unsigned int opcode_modifier;
165 /* opcode_modifier bits: */
166 #define W 0x1 /* set if operands are words or dwords */
167 #define D 0x2 /* D = 0 if Reg --> Regmem; D = 1 if Regmem --> Reg */
168 /* direction flag for floating insns: MUST BE 0x400 */
172 #define ShortForm 0x10 /* register is in low 3 bits of opcode */
173 #define ShortFormW 0x20 /* ShortForm and W bit is 0x8 */
174 #define Seg2ShortForm 0x40 /* encoding of load segment reg insns */
175 #define Seg3ShortForm 0x80 /* fs/gs segment register insns. */
176 #define Jump 0x100 /* special case for jump insns. */
177 #define JumpInterSegment 0x200 /* special case for intersegment leaps/calls */
178 /* 0x400 CANNOT BE USED since it's already used by FloatD above */
179 #define DONT_USE 0x400
180 #define NoModrm 0x800
182 #define imulKludge 0x2000
183 #define JumpByte 0x4000
184 #define JumpDword 0x8000
185 #define ReverseRegRegmem 0x10000
187 /* (opcode_modifier & COMES_IN_ALL_SIZES) is true if the
188 instuction comes in byte, word, and dword sizes and is encoded into
189 machine code in the canonical way. */
190 #define COMES_IN_ALL_SIZES (W)
192 /* (opcode_modifier & COMES_IN_BOTH_DIRECTIONS) indicates that the
193 source and destination operands can be reversed by setting either
194 the D (for integer insns) or the FloatD (for floating insns) bit
196 #define COMES_IN_BOTH_DIRECTIONS (D|FloatD)
198 /* operand_types[i] describes the type of operand i. This is made
199 by OR'ing together all of the possible type masks. (e.g.
200 'operand_types[i] = Reg|Imm' specifies that operand i can be
201 either a register or an immediate operand */
202 unsigned int operand_types[3];
206 'templates' is for grouping together 'template' structures for opcodes
207 of the same name. This is only used for storing the insns in the grand
208 ole hash table of insns.
209 The templates themselves start at START and range up to (but not including)
217 /* these are for register name --> number & type hash lookup */
220 unsigned int reg_type;
221 unsigned int reg_num;
226 unsigned int seg_prefix;
229 /* these are for prefix name --> prefix code hash lookup */
232 unsigned char prefix_code;
235 /* 386 operand encoding bytes: see 386 book for details of this. */
237 unsigned regmem:3; /* codes register or memory operand */
238 unsigned reg:3; /* codes register operand (or extended opcode) */
239 unsigned mode:2; /* how to interpret regmem & reg */
242 /* 386 opcode byte to code indirect addressing. */
251 /* end of tc-i386.h */