summaryrefslogtreecommitdiff
path: root/src/arch/x86/instruction.h
blob: af4f7cf445b9bbea414b5592b6180b72c7311f6e (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

/* 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_XOR_REG1632,                     /* xor ([0x66] 0x31)           */

    X86_OP_INC_E_AX,                        /* inc ([0x66] 0x40)           */
    X86_OP_INC_E_CX,                        /* inc ([0x66] 0x41)           */
    X86_OP_INC_E_DX,                        /* inc ([0x66] 0x42)           */
    X86_OP_INC_E_BX,                        /* inc ([0x66] 0x43)           */
    X86_OP_INC_E_SP,                        /* inc ([0x66] 0x44)           */
    X86_OP_INC_E_BP,                        /* inc ([0x66] 0x45)           */
    X86_OP_INC_E_SI,                        /* inc ([0x66] 0x46)           */
    X86_OP_INC_E_DI,                        /* inc ([0x66] 0x47)           */

    X86_OP_DEC_E_AX,                        /* dec ([0x66] 0x48)           */
    X86_OP_DEC_E_CX,                        /* dec ([0x66] 0x49)           */
    X86_OP_DEC_E_DX,                        /* dec ([0x66] 0x4a)           */
    X86_OP_DEC_E_BX,                        /* dec ([0x66] 0x4b)           */
    X86_OP_DEC_E_SP,                        /* dec ([0x66] 0x4c)           */
    X86_OP_DEC_E_BP,                        /* dec ([0x66] 0x4d)           */
    X86_OP_DEC_E_SI,                        /* dec ([0x66] 0x4e)           */
    X86_OP_DEC_E_DI,                        /* dec ([0x66] 0x4f)           */

    X86_OP_PUSH_E_AX,                       /* push ([0x66] 0x50)          */
    X86_OP_PUSH_E_CX,                       /* push ([0x66] 0x51)          */
    X86_OP_PUSH_E_DX,                       /* push ([0x66] 0x52)          */
    X86_OP_PUSH_E_BX,                       /* push ([0x66] 0x53)          */
    X86_OP_PUSH_E_SP,                       /* push ([0x66] 0x54)          */
    X86_OP_PUSH_E_BP,                       /* push ([0x66] 0x55)          */
    X86_OP_PUSH_E_SI,                       /* push ([0x66] 0x56)          */
    X86_OP_PUSH_E_DI,                       /* push ([0x66] 0x57)          */

    X86_OP_POP_E_AX,                        /* pop ([0x66] 0x58)           */
    X86_OP_POP_E_CX,                        /* pop ([0x66] 0x59)           */
    X86_OP_POP_E_DX,                        /* pop ([0x66] 0x5a)           */
    X86_OP_POP_E_BX,                        /* pop ([0x66] 0x5b)           */
    X86_OP_POP_E_SP,                        /* pop ([0x66] 0x5c)           */
    X86_OP_POP_E_BP,                        /* pop ([0x66] 0x5d)           */
    X86_OP_POP_E_SI,                        /* pop ([0x66] 0x5e)           */
    X86_OP_POP_E_DI,                        /* pop ([0x66] 0x5f)           */

    X86_OP_PUSH_IMM1632,                    /* push ([0x66] 0x68)          */

    X86_OP_MOV_REG1632,                     /* mov ([0x66] 0x89)           */

    X86_OP_ADD8_REG1632,                    /* add ([0x66] 0x83)           */
    X86_OP_OR8_REG1632,                     /* or ([0x66] 0x83)            */
    X86_OP_ADC8_REG1632,                    /* adc ([0x66] 0x83)           */
    X86_OP_SBB8_REG1632,                    /* sbb ([0x66] 0x83)           */
    X86_OP_AND8_REG1632,                    /* and ([0x66] 0x83)           */
    X86_OP_SUB8_REG1632,                    /* sub ([0x66] 0x83)           */
    X86_OP_XOR8_REG1632,                    /* xor ([0x66] 0x83)           */

    X86_OP_TEST_RM8,                        /* test ([0x66] 0x84)          */
    X86_OP_TEST_RM1632,                     /* test ([0x66] 0x85)          */

    X86_OP_MOV_FROM_CONTENT1632,            /* mov ([0x66] 0x8b)           */

    X86_OP_LEA,                             /* lea ([0x66] 0x8d)           */   /* 66 ? */

    X86_OP_NOP,                             /* nop (0x90)                  */

    X86_OP_MOV_MOFFS_TO_AL,                 /* mov (0xa0)                  */
    X86_OP_MOV_MOFFS_TO_E_AX,               /* mov ([0x66] 0xa1)           */

    X86_OP_TEST_AL,                         /* test (0xa8)                 */
    X86_OP_TEST_E_AX,                       /* test ([0x66] 0xa9)          */

    X86_OP_MOV_E_AX,                        /* mov ([0x66] 0xb8)           */
    X86_OP_MOV_E_CX,                        /* mov ([0x66] 0xb9)           */
    X86_OP_MOV_E_DX,                        /* mov ([0x66] 0xba)           */
    X86_OP_MOV_E_BX,                        /* mov ([0x66] 0xbb)           */
    X86_OP_MOV_E_SP,                        /* mov ([0x66] 0xbc)           */
    X86_OP_MOV_E_BP,                        /* mov ([0x66] 0xbd)           */
    X86_OP_MOV_E_SI,                        /* mov ([0x66] 0xbe)           */
    X86_OP_MOV_E_DI,                        /* mov ([0x66] 0xbf)           */

    X86_OP_RET,                             /* ret (0xc3)                  */

    X86_OP_MOV_TO_CONTENT1632,              /* mov ([0x66] 0xc7)           */

    X86_OP_LEAVE,                           /* leave (0xc9)                */

    X86_OP_INT,                             /* int (0xcd)                  */

    X86_OP_CALL,                            /* call (0xe8)                 */

    X86_OP_HLT,                             /* hlt (0xf4)                  */

    X86_OP_PUSH_CONTENT,                    /* push ([0x66] 0xff)          */   /* 66 ? */

    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 */