fcml  1.2.2
fcml_common_utils.h
Go to the documentation of this file.
1 /*
2  * FCML - Free Code Manipulation Library.
3  * Copyright (C) 2010-2020 Slawomir Wojtasiak
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
28 #ifndef FCML_COMMON_UTILS_H_
29 #define FCML_COMMON_UTILS_H_
30 
31 #include "fcml_lib_export.h"
32 
33 #include "fcml_common.h"
34 #include "fcml_assembler.h"
35 #include "fcml_disassembler.h"
36 #include "fcml_instructions.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
48 extern LIB_EXPORT fcml_st_register fcml_reg_AL;
49 extern LIB_EXPORT fcml_st_register fcml_reg_AX;
50 extern LIB_EXPORT fcml_st_register fcml_reg_EAX;
51 extern LIB_EXPORT fcml_st_register fcml_reg_RAX;
52 extern LIB_EXPORT fcml_st_register fcml_reg_MM0;
53 extern LIB_EXPORT fcml_st_register fcml_reg_XMM0;
54 extern LIB_EXPORT fcml_st_register fcml_reg_YMM0;
55 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM0;
56 
57 extern LIB_EXPORT fcml_st_register fcml_reg_CL;
58 extern LIB_EXPORT fcml_st_register fcml_reg_CX;
59 extern LIB_EXPORT fcml_st_register fcml_reg_ECX;
60 extern LIB_EXPORT fcml_st_register fcml_reg_RCX;
61 extern LIB_EXPORT fcml_st_register fcml_reg_MM1;
62 extern LIB_EXPORT fcml_st_register fcml_reg_XMM1;
63 extern LIB_EXPORT fcml_st_register fcml_reg_YMM1;
64 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM1;
65 
66 extern LIB_EXPORT fcml_st_register fcml_reg_DL;
67 extern LIB_EXPORT fcml_st_register fcml_reg_DX;
68 extern LIB_EXPORT fcml_st_register fcml_reg_EDX;
69 extern LIB_EXPORT fcml_st_register fcml_reg_RDX;
70 extern LIB_EXPORT fcml_st_register fcml_reg_MM2;
71 extern LIB_EXPORT fcml_st_register fcml_reg_XMM2;
72 extern LIB_EXPORT fcml_st_register fcml_reg_YMM2;
73 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM2;
74 
75 extern LIB_EXPORT fcml_st_register fcml_reg_BL;
76 extern LIB_EXPORT fcml_st_register fcml_reg_BX;
77 extern LIB_EXPORT fcml_st_register fcml_reg_EBX;
78 extern LIB_EXPORT fcml_st_register fcml_reg_RBX;
79 extern LIB_EXPORT fcml_st_register fcml_reg_MM3;
80 extern LIB_EXPORT fcml_st_register fcml_reg_XMM3;
81 extern LIB_EXPORT fcml_st_register fcml_reg_YMM3;
82 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM3;
83 
84 extern LIB_EXPORT fcml_st_register fcml_reg_AH;
85 extern LIB_EXPORT fcml_st_register fcml_reg_SPL;
86 extern LIB_EXPORT fcml_st_register fcml_reg_SP;
87 extern LIB_EXPORT fcml_st_register fcml_reg_ESP;
88 extern LIB_EXPORT fcml_st_register fcml_reg_RSP;
89 extern LIB_EXPORT fcml_st_register fcml_reg_MM4;
90 extern LIB_EXPORT fcml_st_register fcml_reg_XMM4;
91 extern LIB_EXPORT fcml_st_register fcml_reg_YMM4;
92 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM4;
93 
94 extern LIB_EXPORT fcml_st_register fcml_reg_CH;
95 extern LIB_EXPORT fcml_st_register fcml_reg_BPL;
96 extern LIB_EXPORT fcml_st_register fcml_reg_BP;
97 extern LIB_EXPORT fcml_st_register fcml_reg_EBP;
98 extern LIB_EXPORT fcml_st_register fcml_reg_RBP;
99 extern LIB_EXPORT fcml_st_register fcml_reg_MM5;
100 extern LIB_EXPORT fcml_st_register fcml_reg_XMM5;
101 extern LIB_EXPORT fcml_st_register fcml_reg_YMM5;
102 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM5;
103 
104 extern LIB_EXPORT fcml_st_register fcml_reg_DH;
105 extern LIB_EXPORT fcml_st_register fcml_reg_SIL;
106 extern LIB_EXPORT fcml_st_register fcml_reg_SI;
107 extern LIB_EXPORT fcml_st_register fcml_reg_ESI;
108 extern LIB_EXPORT fcml_st_register fcml_reg_RSI;
109 extern LIB_EXPORT fcml_st_register fcml_reg_MM6;
110 extern LIB_EXPORT fcml_st_register fcml_reg_XMM6;
111 extern LIB_EXPORT fcml_st_register fcml_reg_YMM6;
112 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM6;
113 
114 extern LIB_EXPORT fcml_st_register fcml_reg_BH;
115 extern LIB_EXPORT fcml_st_register fcml_reg_DIL;
116 extern LIB_EXPORT fcml_st_register fcml_reg_DI;
117 extern LIB_EXPORT fcml_st_register fcml_reg_EDI;
118 extern LIB_EXPORT fcml_st_register fcml_reg_RDI;
119 extern LIB_EXPORT fcml_st_register fcml_reg_MM7;
120 extern LIB_EXPORT fcml_st_register fcml_reg_XMM7;
121 extern LIB_EXPORT fcml_st_register fcml_reg_YMM7;
122 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM7;
123 
124 extern LIB_EXPORT fcml_st_register fcml_reg_R8L;
125 extern LIB_EXPORT fcml_st_register fcml_reg_R8W;
126 extern LIB_EXPORT fcml_st_register fcml_reg_R8D;
127 extern LIB_EXPORT fcml_st_register fcml_reg_R8;
128 extern LIB_EXPORT fcml_st_register fcml_reg_XMM8;
129 extern LIB_EXPORT fcml_st_register fcml_reg_YMM8;
130 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM8;
131 
132 extern LIB_EXPORT fcml_st_register fcml_reg_R9L;
133 extern LIB_EXPORT fcml_st_register fcml_reg_R9W;
134 extern LIB_EXPORT fcml_st_register fcml_reg_R9D;
135 extern LIB_EXPORT fcml_st_register fcml_reg_R9;
136 extern LIB_EXPORT fcml_st_register fcml_reg_XMM9;
137 extern LIB_EXPORT fcml_st_register fcml_reg_YMM9;
138 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM9;
139 
140 extern LIB_EXPORT fcml_st_register fcml_reg_R10L;
141 extern LIB_EXPORT fcml_st_register fcml_reg_R10W;
142 extern LIB_EXPORT fcml_st_register fcml_reg_R10D;
143 extern LIB_EXPORT fcml_st_register fcml_reg_R10;
144 extern LIB_EXPORT fcml_st_register fcml_reg_XMM10;
145 extern LIB_EXPORT fcml_st_register fcml_reg_YMM10;
146 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM10;
147 
148 extern LIB_EXPORT fcml_st_register fcml_reg_R11L;
149 extern LIB_EXPORT fcml_st_register fcml_reg_R11W;
150 extern LIB_EXPORT fcml_st_register fcml_reg_R11D;
151 extern LIB_EXPORT fcml_st_register fcml_reg_R11;
152 extern LIB_EXPORT fcml_st_register fcml_reg_XMM11;
153 extern LIB_EXPORT fcml_st_register fcml_reg_YMM11;
154 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM11;
155 
156 extern LIB_EXPORT fcml_st_register fcml_reg_R12L;
157 extern LIB_EXPORT fcml_st_register fcml_reg_R12W;
158 extern LIB_EXPORT fcml_st_register fcml_reg_R12D;
159 extern LIB_EXPORT fcml_st_register fcml_reg_R12;
160 extern LIB_EXPORT fcml_st_register fcml_reg_XMM12;
161 extern LIB_EXPORT fcml_st_register fcml_reg_YMM12;
162 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM12;
163 
164 extern LIB_EXPORT fcml_st_register fcml_reg_R13L;
165 extern LIB_EXPORT fcml_st_register fcml_reg_R13W;
166 extern LIB_EXPORT fcml_st_register fcml_reg_R13D;
167 extern LIB_EXPORT fcml_st_register fcml_reg_R13;
168 extern LIB_EXPORT fcml_st_register fcml_reg_XMM13;
169 extern LIB_EXPORT fcml_st_register fcml_reg_YMM13;
170 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM13;
171 
172 extern LIB_EXPORT fcml_st_register fcml_reg_R14L;
173 extern LIB_EXPORT fcml_st_register fcml_reg_R14W;
174 extern LIB_EXPORT fcml_st_register fcml_reg_R14D;
175 extern LIB_EXPORT fcml_st_register fcml_reg_R14;
176 extern LIB_EXPORT fcml_st_register fcml_reg_XMM14;
177 extern LIB_EXPORT fcml_st_register fcml_reg_YMM14;
178 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM14;
179 
180 extern LIB_EXPORT fcml_st_register fcml_reg_R15L;
181 extern LIB_EXPORT fcml_st_register fcml_reg_R15W;
182 extern LIB_EXPORT fcml_st_register fcml_reg_R15D;
183 extern LIB_EXPORT fcml_st_register fcml_reg_R15;
184 extern LIB_EXPORT fcml_st_register fcml_reg_XMM15;
185 extern LIB_EXPORT fcml_st_register fcml_reg_YMM15;
186 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM15;
187 
188 extern LIB_EXPORT fcml_st_register fcml_reg_XMM16;
189 extern LIB_EXPORT fcml_st_register fcml_reg_YMM16;
190 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM16;
191 
192 extern LIB_EXPORT fcml_st_register fcml_reg_XMM17;
193 extern LIB_EXPORT fcml_st_register fcml_reg_YMM17;
194 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM17;
195 
196 extern LIB_EXPORT fcml_st_register fcml_reg_XMM18;
197 extern LIB_EXPORT fcml_st_register fcml_reg_YMM18;
198 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM18;
199 
200 extern LIB_EXPORT fcml_st_register fcml_reg_XMM19;
201 extern LIB_EXPORT fcml_st_register fcml_reg_YMM19;
202 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM19;
203 
204 extern LIB_EXPORT fcml_st_register fcml_reg_XMM20;
205 extern LIB_EXPORT fcml_st_register fcml_reg_YMM20;
206 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM20;
207 
208 extern LIB_EXPORT fcml_st_register fcml_reg_XMM21;
209 extern LIB_EXPORT fcml_st_register fcml_reg_YMM21;
210 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM21;
211 
212 extern LIB_EXPORT fcml_st_register fcml_reg_XMM22;
213 extern LIB_EXPORT fcml_st_register fcml_reg_YMM22;
214 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM22;
215 
216 extern LIB_EXPORT fcml_st_register fcml_reg_XMM23;
217 extern LIB_EXPORT fcml_st_register fcml_reg_YMM23;
218 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM23;
219 
220 extern LIB_EXPORT fcml_st_register fcml_reg_XMM24;
221 extern LIB_EXPORT fcml_st_register fcml_reg_YMM24;
222 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM24;
223 
224 extern LIB_EXPORT fcml_st_register fcml_reg_XMM25;
225 extern LIB_EXPORT fcml_st_register fcml_reg_YMM25;
226 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM25;
227 
228 extern LIB_EXPORT fcml_st_register fcml_reg_XMM26;
229 extern LIB_EXPORT fcml_st_register fcml_reg_YMM26;
230 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM26;
231 
232 extern LIB_EXPORT fcml_st_register fcml_reg_XMM27;
233 extern LIB_EXPORT fcml_st_register fcml_reg_YMM27;
234 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM27;
235 
236 extern LIB_EXPORT fcml_st_register fcml_reg_XMM28;
237 extern LIB_EXPORT fcml_st_register fcml_reg_YMM28;
238 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM28;
239 
240 extern LIB_EXPORT fcml_st_register fcml_reg_XMM29;
241 extern LIB_EXPORT fcml_st_register fcml_reg_YMM29;
242 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM29;
243 
244 extern LIB_EXPORT fcml_st_register fcml_reg_XMM30;
245 extern LIB_EXPORT fcml_st_register fcml_reg_YMM30;
246 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM30;
247 
248 extern LIB_EXPORT fcml_st_register fcml_reg_XMM31;
249 extern LIB_EXPORT fcml_st_register fcml_reg_YMM31;
250 extern LIB_EXPORT fcml_st_register fcml_reg_ZMM31;
251 
252 extern LIB_EXPORT fcml_st_register fcml_reg_ES;
253 extern LIB_EXPORT fcml_st_register fcml_reg_CS;
254 extern LIB_EXPORT fcml_st_register fcml_reg_SS;
255 extern LIB_EXPORT fcml_st_register fcml_reg_DS;
256 extern LIB_EXPORT fcml_st_register fcml_reg_FS;
257 extern LIB_EXPORT fcml_st_register fcml_reg_GS;
258 
259 extern LIB_EXPORT fcml_st_register fcml_reg_ST0;
260 extern LIB_EXPORT fcml_st_register fcml_reg_ST1;
261 extern LIB_EXPORT fcml_st_register fcml_reg_ST2;
262 extern LIB_EXPORT fcml_st_register fcml_reg_ST3;
263 extern LIB_EXPORT fcml_st_register fcml_reg_ST4;
264 extern LIB_EXPORT fcml_st_register fcml_reg_ST5;
265 extern LIB_EXPORT fcml_st_register fcml_reg_ST6;
266 extern LIB_EXPORT fcml_st_register fcml_reg_ST7;
267 
268 extern LIB_EXPORT fcml_st_register fcml_reg_CR0;
269 extern LIB_EXPORT fcml_st_register fcml_reg_CR2;
270 extern LIB_EXPORT fcml_st_register fcml_reg_CR3;
271 extern LIB_EXPORT fcml_st_register fcml_reg_CR4;
272 extern LIB_EXPORT fcml_st_register fcml_reg_CR8;
273 
274 extern LIB_EXPORT fcml_st_register fcml_reg_DR0;
275 extern LIB_EXPORT fcml_st_register fcml_reg_DR1;
276 extern LIB_EXPORT fcml_st_register fcml_reg_DR2;
277 extern LIB_EXPORT fcml_st_register fcml_reg_DR3;
278 extern LIB_EXPORT fcml_st_register fcml_reg_DR4;
279 extern LIB_EXPORT fcml_st_register fcml_reg_DR5;
280 extern LIB_EXPORT fcml_st_register fcml_reg_DR6;
281 extern LIB_EXPORT fcml_st_register fcml_reg_DR7;
282 
283 extern LIB_EXPORT fcml_st_register fcml_reg_K0;
284 extern LIB_EXPORT fcml_st_register fcml_reg_K1;
285 extern LIB_EXPORT fcml_st_register fcml_reg_K2;
286 extern LIB_EXPORT fcml_st_register fcml_reg_K3;
287 extern LIB_EXPORT fcml_st_register fcml_reg_K4;
288 extern LIB_EXPORT fcml_st_register fcml_reg_K5;
289 extern LIB_EXPORT fcml_st_register fcml_reg_K6;
290 extern LIB_EXPORT fcml_st_register fcml_reg_K7;
291 
292 extern LIB_EXPORT fcml_st_register fcml_reg_IP;
293 extern LIB_EXPORT fcml_st_register fcml_reg_EIP;
294 extern LIB_EXPORT fcml_st_register fcml_reg_RIP;
295 
302 LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_reg(
303  fcml_st_register *reg);
304 
305 /* IMM.*/
306 
312  fcml_uint8_t value);
318  fcml_int8_t value);
324  fcml_uint16_t value);
330  fcml_int16_t value);
336  fcml_uint32_t value);
342  fcml_int32_t value);
348  fcml_uint64_t value);
354  fcml_int64_t value);
355 
356 /* Memory addressing.*/
357 
364  fcml_int16_t seg, fcml_int16_t offset);
371  fcml_int16_t seg, fcml_int32_t offset);
378  fcml_int16_t offset, fcml_usize size_operator);
385  fcml_int32_t offset, fcml_usize size_operator);
394  fcml_int64_t offset, fcml_usize size_operator);
403  fcml_int64_t offset, fcml_usize size_operator);
410  fcml_int16_t disp, fcml_usize size_operator);
417  fcml_int32_t disp, fcml_usize size_operator);
424  fcml_int64_t disp, fcml_usize size_operator);
433  fcml_st_register *base, fcml_int8_t disp, fcml_usize size_operator);
442  fcml_st_register *base, fcml_int16_t disp, fcml_usize size_operator);
451  fcml_st_register *base, fcml_int32_t disp, fcml_usize size_operator);
460  fcml_st_register *base, fcml_int64_t disp, fcml_usize size_operator);
470  fcml_st_register *index, fcml_uint8_t scale_factor, fcml_int8_t disp,
471  fcml_usize size_operator);
481  fcml_st_register *index, fcml_uint8_t scale_factor, fcml_int32_t disp,
482  fcml_usize size_operator);
492  fcml_st_register *index, fcml_uint8_t scale_factor, fcml_int64_t disp,
493  fcml_usize size_operator);
504  fcml_st_register *base, fcml_st_register *index,
505  fcml_uint8_t scale_factor, fcml_int8_t disp, fcml_usize size_operator);
516  fcml_st_register *base, fcml_st_register *index,
517  fcml_uint8_t scale_factor, fcml_int32_t disp, fcml_usize size_operator);
528  fcml_st_register *base, fcml_st_register *index,
529  fcml_uint8_t scale_factor, fcml_int64_t disp, fcml_usize size_operator);
530 
537  fcml_st_operand operand, fcml_hints hints);
538 
549  fcml_st_instruction *instruction);
550 
555 LIB_EXPORT void LIB_CALL fcml_fn_cu_free_instruction(
556  fcml_st_instruction *instruction);
557 
566  fcml_st_instruction *instruction, fcml_en_operand_type operand_type);
567 
568 /* Some shortcuts for those who prefer to use macros instead of functions.*/
569 
570 #define FCML_IMM8_S( x ) fcml_fn_cu_operand_signed_imm_8( x )
571 #define FCML_IMM8( x ) fcml_fn_cu_operand_unsigned_imm_8( x )
572 #define FCML_IMM16_S( x ) fcml_fn_cu_operand_signed_imm_16( x )
573 #define FCML_IMM16( x ) fcml_fn_cu_operand_unsigned_imm_16( x )
574 #define FCML_IMM32_S( x ) fcml_fn_cu_operand_signed_imm_32( x )
575 #define FCML_IMM32( x ) fcml_fn_cu_operand_unsigned_imm_32( x )
576 #define FCML_IMM64_S( x ) fcml_fn_cu_operand_signed_imm_64( x )
577 #define FCML_IMM64( x ) fcml_fn_cu_operand_unsigned_imm_64( x )
578 
579 #ifdef FCML_USE_SHORT_REG
580 #define FCML_REG( x ) fcml_fn_cu_operand_reg( &fcml_reg_##x )
581 #else
582 #define FCML_REG( x ) fcml_fn_cu_operand_reg( &x )
583 #endif
584 
585 #define FCML_FAR_POINTER_16( seg, offset ) \
586  fcml_fn_cu_operand_addr_far_pointer_offset16( seg, offset )
587 #define FCML_FAR_POINTER_32( seg, offset ) \
588  fcml_fn_cu_operand_addr_far_pointer_offset32( seg, offset )
589 #define FCML_OFFSET_16( offset ) \
590  fcml_fn_cu_operand_addr_offset_16( offset )
591 #define FCML_OFFSET_32( offset ) \
592  fcml_fn_cu_operand_addr_offset_32( offset )
593 #define FCML_OFFSET_ABS_64( offset ) \
594  fcml_fn_cu_operand_addr_offset_abs_64( offset )
595 #define FCML_OFFSET_REL_64( offset ) \
596  fcml_fn_cu_operand_addr_offset_rel_64( offset )
597 #define FCML_DISP_16( offset ) \
598  fcml_fn_cu_operand_addr_disp_16( offset )
599 #define FCML_DISP_32( offset ) \
600  fcml_fn_cu_operand_addr_disp_32( offset )
601 #define FCML_DISP_64( offset ) \
602  fcml_fn_cu_operand_addr_disp_64( offset )
603 
604 #ifdef FCML_USE_SHORT_REG
605 #define FCML_B_DISP_8(base, offset) \
606 fcml_fn_cu_operand_addr_b_disp_8( &fcml_reg_##base, offset )
607 #define FCML_B_DISP_16(base, offset) \
608  fcml_fn_cu_operand_addr_b_disp_16( &fcml_reg_##base, offset )
609 #define FCML_B_DISP_32(base, offset) \
610  fcml_fn_cu_operand_addr_b_disp_32( &fcml_reg_##base, offset )
611 #define FCML_B_DISP_64(base, offset) \
612  fcml_fn_cu_operand_addr_b_disp_64( &fcml_reg_##base, offset )
613 #define FCML_IS_DISP_8(index, scale, offset) \
614  fcml_fn_cu_operand_addr_is_disp_8( &fcml_reg_##index, scale, offset )
615 #define FCML_IS_DISP_16(index, scale, offset) \
616  fcml_fn_cu_operand_addr_is_disp_32( &fcml_reg_##index, scale, offset )
617 #define FCML_IS_DISP_32(index, scale, offset) \
618  fcml_fn_cu_operand_addr_is_disp_64( &fcml_reg_##index, scale, offset )
619 #define FCML_BIS_DISP_8(base, index, scale, offset) \
620  fcml_fn_cu_operand_addr_bis_disp_8( &fcml_reg_##base, &fcml_reg_##index, \
621  scale, offset )
622 #define FCML_BIS_DISP_16(base, index, scale, offset) \
623  fcml_fn_cu_operand_addr_bis_disp_32( &fcml_reg_##base, &fcml_reg_##index, \
624  scale, offset )
625 #define FCML_BIS_DISP_32(base, index, scale, offset) \
626  fcml_fn_cu_operand_addr_bis_disp_64( &fcml_reg_##base, &fcml_reg_##index, \
627  scale, offset )
628 #else
629 #define FCML_B_DISP_8(base, offset) \
630  fcml_fn_cu_operand_addr_b_disp_8( &base, offset )
631 #define FCML_B_DISP_16(base, offset) \
632  fcml_fn_cu_operand_addr_b_disp_16( &base, offset )
633 #define FCML_B_DISP_32(base, offset) \
634  fcml_fn_cu_operand_addr_b_disp_32( &base, offset )
635 #define FCML_B_DISP_64(base, offset) \
636  fcml_fn_cu_operand_addr_b_disp_64( &base, offset )
637 #define FCML_IS_DISP_8(index, scale, offset) \
638  fcml_fn_cu_operand_addr_is_disp_8( &index, scale, offset )
639 #define FCML_IS_DISP_16(index, scale, offset) \
640  fcml_fn_cu_operand_addr_is_disp_32( &index, scale, offset )
641 #define FCML_IS_DISP_32(index, scale, offset) \
642  fcml_fn_cu_operand_addr_is_disp_64( &index, scale, offset )
643 #define FCML_BIS_DISP_8(base, index, scale, offset) \
644  fcml_fn_cu_operand_addr_bis_disp_8( &base, &index, scale, offset )
645 #define FCML_BIS_DISP_16(base, index, scale, offset) \
646  fcml_fn_cu_operand_addr_bis_disp_32( &base, &index, scale, offset )
647 #define FCML_BIS_DISP_32(base, index, scale, offset) \
648  fcml_fn_cu_operand_addr_bis_disp_64( &base, &index, scale, offset )
649 #endif
650 
651 #define FCML_IS_INSTRUCTION_GROUP(result, group) \
652  ( result.instruction_details.instruction_group & ( group ) )
653 #define FCML_IS_INSTRUCTION_CODE(result, _ins) \
654  ( result.instruction_details.instruction == _ins )
655 
656 #ifdef __cplusplus
657 }
658 #endif
659 
660 #endif /* FCML_COMMON_UTILS_H_ */
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_bis_disp_64(fcml_st_register *base, fcml_st_register *index, fcml_uint8_t scale_factor, fcml_int64_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 32-bit displacement, base register, scale factor and index register.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_disp_16(fcml_int16_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 16-bit displacement.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_b_disp_32(fcml_st_register *base, fcml_int32_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 32-bit displacement and base register.
LIB_EXPORT fcml_st_instruction *LIB_CALL fcml_fn_cu_clone_instruction(fcml_st_instruction *instruction)
Clones given instruction.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_bis_disp_32(fcml_st_register *base, fcml_st_register *index, fcml_uint8_t scale_factor, fcml_int32_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 16-bit displacement, base register, scale factor and index register.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_offset_abs_64(fcml_int64_t offset, fcml_usize size_operator)
Prepares memory addressing operand for 64-bit absolute offset.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_offset_rel_64(fcml_int64_t offset, fcml_usize size_operator)
Prepares memory addressing operand for 64-bit absolute offset.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_signed_imm_16(fcml_int16_t value)
Prepares immediate operand for signed int16.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_disp_32(fcml_int32_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 32-bit displacement.
fcml_en_operand_type
Supported operand types.
Definition: fcml_common.h:673
fcml_uint16_t fcml_hints
Type used for storing instruction and operand hint masks.
Definition: fcml_common.h:86
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_unsigned_imm_8(fcml_uint8_t value)
Prepares immediate operand for unsigned int8.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_unsigned_imm_64(fcml_uint64_t value)
Prepares immediate operand for unsigned int64.
Definitions of common structures used by FCML components.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_is_disp_64(fcml_st_register *index, fcml_uint8_t scale_factor, fcml_int64_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 32-bit displacement, scale factor and index register...
Generic instruction model.
Definition: fcml_common.h:783
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_far_pointer_offset16(fcml_int16_t seg, fcml_int16_t offset)
Prepares far pointer operand for given segment and offset.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_signed_imm_8(fcml_int8_t value)
Prepares immediate operand for signed int8.
Handles Win32 DLL symbols importing/exporting.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_b_disp_16(fcml_st_register *base, fcml_int16_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 16-bit displacement and base register.
Structure describes x86_64 register.
Definition: fcml_common.h:450
Structures and functions declarations related to FCML disassembler.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_is_disp_8(fcml_st_register *index, fcml_uint8_t scale_factor, fcml_int8_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 8-bit displacement, scale factor and index register...
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_far_pointer_offset32(fcml_int16_t seg, fcml_int32_t offset)
Prepares far pointer operand for given segment and offset.
LIB_EXPORT fcml_st_operand * fcml_fn_cu_find_operand(fcml_st_instruction *instruction, fcml_en_operand_type operand_type)
Gets operand of given type or NULL if there is no such operand.
LIB_EXPORT void LIB_CALL fcml_fn_cu_free_instruction(fcml_st_instruction *instruction)
Frees given instruction.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_is_disp_32(fcml_st_register *index, fcml_uint8_t scale_factor, fcml_int32_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 16-bit displacement, scale factor and index register...
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_bis_disp_8(fcml_st_register *base, fcml_st_register *index, fcml_uint8_t scale_factor, fcml_int8_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 8-bit displacement, base register, scale factor and index register.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_disp_64(fcml_int64_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 64-bit displacement.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_offset_16(fcml_int16_t offset, fcml_usize size_operator)
Prepares memory addressing operand for 16-bit absolute offset.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_unsigned_imm_16(fcml_uint16_t value)
Prepares immediate operand for unsigned int16.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_b_disp_8(fcml_st_register *base, fcml_int8_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 8-bit displacement and base register.
Instruction operand.
Definition: fcml_common.h:735
Instruction codes and addressing modes/instruction forms.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_reg(fcml_st_register *reg)
Prepares register operand for given register.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_add_operand_hints(fcml_st_operand operand, fcml_hints hints)
Adds hints to the operand.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_signed_imm_64(fcml_int64_t value)
Prepares immediate operand for signed int64.
Structures and functions declarations related to one-line FCML assembler.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_signed_imm_32(fcml_int32_t value)
Prepares immediate operand for signed int32.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_offset_32(fcml_int32_t offset, fcml_usize size_operator)
Prepares memory addressing operand for 32-bit absolute offset.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_unsigned_imm_32(fcml_uint32_t value)
Prepares immediate operand for unsigned int32.
LIB_EXPORT fcml_st_operand LIB_CALL fcml_fn_cu_operand_addr_b_disp_64(fcml_st_register *base, fcml_int64_t disp, fcml_usize size_operator)
Prepares effective memory addressing operand for 64-bit displacement and base register.