summaryrefslogtreecommitdiff
path: root/src/arch/x86/instruction.h
blob: af1c5bc78039ed8463fd60e9261b9ac5bd9a2921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

/* OpenIDA - Outil d'analyse de fichiers binaires
 * instruction.h - prototypes pour la gestion des instructions de l'architecture x86
 *
 * Copyright (C) 2008 Cyrille Bagard
 *
 *  This file is part of OpenIDA.
 *
 *  OpenIDA is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  OpenIDA is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef _ARCH_X86_INSTRUCTION_H
#define _ARCH_X86_INSTRUCTION_H


#include "../instruction.h"
#include "../instruction-int.h"



/* Définition d'une instruction x86 */
typedef struct _asm_x86_instr asm_x86_instr;



/* Enumération de tous les opcodes */
typedef enum _X86Opcodes
{
    X86_OP_INC_EAX,                         /* inc (0x40)                  */
    X86_OP_INC_ECX,                         /* inc (0x41)                  */
    X86_OP_INC_EDX,                         /* inc (0x42)                  */
    X86_OP_INC_EBX,                         /* inc (0x43)                  */
    X86_OP_INC_ESP,                         /* inc (0x44)                  */
    X86_OP_INC_EBP,                         /* inc (0x45)                  */
    X86_OP_INC_ESI,                         /* inc (0x46)                  */
    X86_OP_INC_EDI,                         /* inc (0x47)                  */

    X86_OP_DEC_EAX,                         /* dec (0x48)                  */
    X86_OP_DEC_ECX,                         /* dec (0x49)                  */
    X86_OP_DEC_EDX,                         /* dec (0x4a)                  */
    X86_OP_DEC_EBX,                         /* dec (0x4b)                  */
    X86_OP_DEC_ESP,                         /* dec (0x4c)                  */
    X86_OP_DEC_EBP,                         /* dec (0x4d)                  */
    X86_OP_DEC_ESI,                         /* dec (0x4e)                  */
    X86_OP_DEC_EDI,                         /* dec (0x4f)                  */

    X86_OP_PUSH_EAX,                        /* push (0x50)                 */
    X86_OP_PUSH_ECX,                        /* push (0x51)                 */
    X86_OP_PUSH_EDX,                        /* push (0x52)                 */
    X86_OP_PUSH_EBX,                        /* push (0x53)                 */
    X86_OP_PUSH_ESP,                        /* push (0x54)                 */
    X86_OP_PUSH_EBP,                        /* push (0x55)                 */
    X86_OP_PUSH_ESI,                        /* push (0x56)                 */
    X86_OP_PUSH_EDI,                        /* push (0x57)                 */

    X86_OP_POP_EAX,                         /* pop (0x58)                  */
    X86_OP_POP_ECX,                         /* pop (0x59)                  */
    X86_OP_POP_EDX,                         /* pop (0x5a)                  */
    X86_OP_POP_EBX,                         /* pop (0x5b)                  */
    X86_OP_POP_ESP,                         /* pop (0x5c)                  */
    X86_OP_POP_EBP,                         /* pop (0x5d)                  */
    X86_OP_POP_ESI,                         /* pop (0x5e)                  */
    X86_OP_POP_EDI,                         /* pop (0x5f)                  */

    X86_OP_PUSH_IMM32,                      /* push (0x68)                 */

    X86_OP_NOP,                             /* nop (0x90)                  */

    X86_OP_MOV_AX,                          /* mov (0xb8)                  */
    X86_OP_MOV_CX,                          /* mov (0xb9)                  */
    X86_OP_MOV_DX,                          /* mov (0xba)                  */
    X86_OP_MOV_BX,                          /* mov (0xbb)                  */
    X86_OP_MOV_SP,                          /* mov (0xbc)                  */
    X86_OP_MOV_BP,                          /* mov (0xbd)                  */
    X86_OP_MOV_SI,                          /* mov (0xbe)                  */
    X86_OP_MOV_DI,                          /* mov (0xbf)                  */

    X86_OP_RET,                             /* ret (0xc3)                  */
    X86_OP_LEAVE,                           /* leave (0xc9)                */

    X86_OP_INT,                             /* int (0xcd)                  */

    X86_OP_CALL,                            /* call (0xe8)                 */

    X86_OP_HLT,                             /* hlt (0xf4)                  */

    X86_OP_INC_AX,                          /* inc (0x66 0x40)             */
    X86_OP_INC_CX,                          /* inc (0x66 0x41)             */
    X86_OP_INC_DX,                          /* inc (0x66 0x42)             */
    X86_OP_INC_BX,                          /* inc (0x66 0x43)             */
    X86_OP_INC_SP,                          /* inc (0x66 0x44)             */
    X86_OP_INC_BP,                          /* inc (0x66 0x45)             */
    X86_OP_INC_SI,                          /* inc (0x66 0x46)             */
    X86_OP_INC_DI,                          /* inc (0x66 0x47)             */

    X86_OP_DEC_AX,                          /* dec (0x66 0x48)             */
    X86_OP_DEC_CX,                          /* dec (0x66 0x49)             */
    X86_OP_DEC_DX,                          /* dec (0x66 0x4a)             */
    X86_OP_DEC_BX,                          /* dec (0x66 0x4b)             */
    X86_OP_DEC_SP,                          /* dec (0x66 0x4c)             */
    X86_OP_DEC_BP,                          /* dec (0x66 0x4d)             */
    X86_OP_DEC_SI,                          /* dec (0x66 0x4e)             */
    X86_OP_DEC_DI,                          /* dec (0x66 0x4f)             */

    X86_OP_PUSH_AX,                         /* push (0x66 0x50)            */
    X86_OP_PUSH_CX,                         /* push (0x66 0x51)            */
    X86_OP_PUSH_DX,                         /* push (0x66 0x52)            */
    X86_OP_PUSH_BX,                         /* push (0x66 0x53)            */
    X86_OP_PUSH_SP,                         /* push (0x66 0x54)            */
    X86_OP_PUSH_BP,                         /* push (0x66 0x55)            */
    X86_OP_PUSH_SI,                         /* push (0x66 0x56)            */
    X86_OP_PUSH_DI,                         /* push (0x66 0x57)            */

    X86_OP_POP_AX,                          /* pop (0x66 0x58)             */
    X86_OP_POP_CX,                          /* pop (0x66 0x59)             */
    X86_OP_POP_DX,                          /* pop (0x66 0x5a)             */
    X86_OP_POP_BX,                          /* pop (0x66 0x5b)             */
    X86_OP_POP_SP,                          /* pop (0x66 0x5c)             */
    X86_OP_POP_BP,                          /* pop (0x66 0x5d)             */
    X86_OP_POP_SI,                          /* pop (0x66 0x5e)             */
    X86_OP_POP_DI,                          /* pop (0x66 0x5f)             */

    X86_OP_PUSH_IMM16,                      /* push (0x66 0x68)            */

    X86_OP_MOV_EAX,                         /* mov (0x66 0xb8)             */
    X86_OP_MOV_ECX,                         /* mov (0x66 0xb9)             */
    X86_OP_MOV_EDX,                         /* mov (0x66 0xba)             */
    X86_OP_MOV_EBX,                         /* mov (0x66 0xbb)             */
    X86_OP_MOV_ESP,                         /* mov (0x66 0xbc)             */
    X86_OP_MOV_EBP,                         /* mov (0x66 0xbd)             */
    X86_OP_MOV_ESI,                         /* mov (0x66 0xbe)             */
    X86_OP_MOV_EDI,                         /* mov (0x66 0xbf)             */

    X86_OP_COUNT

} X86Opcodes;




/* Eventuel préfixe rencontré */
typedef enum _X86Prefix
{
    X86_PRE_NONE = 0,                       /* Aucun préfixe               */


    X86_PRE_OPSIZE                          /* Basculement des opérandes   */


} X86Prefix;



/* Définition d'une instruction x86 */
struct _asm_x86_instr
{
    asm_instr base;                         /* A laisser en premier...     */

    X86Opcodes type;


    X86Prefix prefix;                       /* Eventuel préfixe trouvé     */


};






#endif  /* _ARCH_X86_INSTRUCTION_H */