20 #ifdef CAPSTONE_HAS_X86
22 #if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)
23 #pragma warning(disable:4996)
24 #pragma warning(disable:28719)
27 #include <capstone/platform.h>
29 #if defined(CAPSTONE_HAS_OSXKERNEL)
30 #include <Availability.h>
35 #include "../../cs_priv.h"
40 #include "../../MCInst.h"
41 #include "../../utils.h"
44 #define GET_REGINFO_ENUM
45 #define GET_REGINFO_MC_DESC
48 #define GET_INSTRINFO_ENUM
49 #ifdef CAPSTONE_X86_REDUCE
78 #define ENTRY(x) X86_##x,
79 static const uint8_t llvmRegnums[] = {
108 baseRegNo = insn->
isPrefix67 ? X86_ESI : X86_RSI;
110 baseRegNo = insn->
isPrefix67 ? X86_SI : X86_ESI;
113 baseRegNo = insn->
isPrefix67 ? X86_ESI : X86_SI;
132 baseRegNo = insn->
isPrefix67 ? X86_EDI : X86_RDI;
134 baseRegNo = insn->
isPrefix67 ? X86_DI : X86_EDI;
137 baseRegNo = insn->
isPrefix67 ? X86_EDI : X86_DI;
151 static void translateImmediate(
MCInst *mcInst,
uint64_t immediate,
162 if (immediate & 0x80)
163 immediate |= ~(0xffull);
166 if (immediate & 0x8000)
167 immediate |= ~(0xffffull);
170 if (immediate & 0x80000000)
171 immediate |= ~(0xffffffffull);
179 else if (
type == TYPE_IMM8 ||
type == TYPE_IMM16 ||
type == TYPE_IMM32 ||
180 type == TYPE_IMM64 ||
type == TYPE_IMMv) {
187 immediate |= ~(0xffull);
190 if(immediate & 0x8000)
191 immediate |= ~(0xffffull);
194 if(immediate & 0x80000000)
195 immediate |= ~(0xffffffffull);
200 }
else if (
type == TYPE_IMM3) {
201 #ifndef CAPSTONE_X86_REDUCE
203 if (immediate >= 8) {
208 case X86_CMPPDrmi: NewOpc = X86_CMPPDrmi_alt;
break;
209 case X86_CMPPDrri: NewOpc = X86_CMPPDrri_alt;
break;
210 case X86_CMPPSrmi: NewOpc = X86_CMPPSrmi_alt;
break;
211 case X86_CMPPSrri: NewOpc = X86_CMPPSrri_alt;
break;
212 case X86_CMPSDrm: NewOpc = X86_CMPSDrm_alt;
break;
213 case X86_CMPSDrr: NewOpc = X86_CMPSDrr_alt;
break;
214 case X86_CMPSSrm: NewOpc = X86_CMPSSrm_alt;
break;
215 case X86_CMPSSrr: NewOpc = X86_CMPSSrr_alt;
break;
216 case X86_VPCOMBri: NewOpc = X86_VPCOMBri_alt;
break;
217 case X86_VPCOMBmi: NewOpc = X86_VPCOMBmi_alt;
break;
218 case X86_VPCOMWri: NewOpc = X86_VPCOMWri_alt;
break;
219 case X86_VPCOMWmi: NewOpc = X86_VPCOMWmi_alt;
break;
220 case X86_VPCOMDri: NewOpc = X86_VPCOMDri_alt;
break;
221 case X86_VPCOMDmi: NewOpc = X86_VPCOMDmi_alt;
break;
222 case X86_VPCOMQri: NewOpc = X86_VPCOMQri_alt;
break;
223 case X86_VPCOMQmi: NewOpc = X86_VPCOMQmi_alt;
break;
224 case X86_VPCOMUBri: NewOpc = X86_VPCOMUBri_alt;
break;
225 case X86_VPCOMUBmi: NewOpc = X86_VPCOMUBmi_alt;
break;
226 case X86_VPCOMUWri: NewOpc = X86_VPCOMUWri_alt;
break;
227 case X86_VPCOMUWmi: NewOpc = X86_VPCOMUWmi_alt;
break;
228 case X86_VPCOMUDri: NewOpc = X86_VPCOMUDri_alt;
break;
229 case X86_VPCOMUDmi: NewOpc = X86_VPCOMUDmi_alt;
break;
230 case X86_VPCOMUQri: NewOpc = X86_VPCOMUQri_alt;
break;
231 case X86_VPCOMUQmi: NewOpc = X86_VPCOMUQmi_alt;
break;
239 }
else if (
type == TYPE_IMM5) {
240 #ifndef CAPSTONE_X86_REDUCE
242 if (immediate >= 32) {
247 case X86_VCMPPDrmi: NewOpc = X86_VCMPPDrmi_alt;
break;
248 case X86_VCMPPDrri: NewOpc = X86_VCMPPDrri_alt;
break;
249 case X86_VCMPPSrmi: NewOpc = X86_VCMPPSrmi_alt;
break;
250 case X86_VCMPPSrri: NewOpc = X86_VCMPPSrri_alt;
break;
251 case X86_VCMPSDrm: NewOpc = X86_VCMPSDrm_alt;
break;
252 case X86_VCMPSDrr: NewOpc = X86_VCMPSDrr_alt;
break;
253 case X86_VCMPSSrm: NewOpc = X86_VCMPSSrm_alt;
break;
254 case X86_VCMPSSrr: NewOpc = X86_VCMPSSrr_alt;
break;
255 case X86_VCMPPDYrmi: NewOpc = X86_VCMPPDYrmi_alt;
break;
256 case X86_VCMPPDYrri: NewOpc = X86_VCMPPDYrri_alt;
break;
257 case X86_VCMPPSYrmi: NewOpc = X86_VCMPPSYrmi_alt;
break;
258 case X86_VCMPPSYrri: NewOpc = X86_VCMPPSYrri_alt;
break;
259 case X86_VCMPPDZrmi: NewOpc = X86_VCMPPDZrmi_alt;
break;
260 case X86_VCMPPDZrri: NewOpc = X86_VCMPPDZrri_alt;
break;
261 case X86_VCMPPDZrrib: NewOpc = X86_VCMPPDZrrib_alt;
break;
262 case X86_VCMPPSZrmi: NewOpc = X86_VCMPPSZrmi_alt;
break;
263 case X86_VCMPPSZrri: NewOpc = X86_VCMPPSZrri_alt;
break;
264 case X86_VCMPPSZrrib: NewOpc = X86_VCMPPSZrrib_alt;
break;
265 case X86_VCMPSDZrm: NewOpc = X86_VCMPSDZrmi_alt;
break;
266 case X86_VCMPSDZrr: NewOpc = X86_VCMPSDZrri_alt;
break;
267 case X86_VCMPSSZrm: NewOpc = X86_VCMPSSZrmi_alt;
break;
268 case X86_VCMPSSZrr: NewOpc = X86_VCMPSSZrri_alt;
break;
276 }
else if (
type == TYPE_AVX512ICC) {
277 #ifndef CAPSTONE_X86_REDUCE
278 if (immediate >= 8 || ((immediate & 0x3) == 3)) {
282 case X86_VPCMPBZ128rmi: NewOpc = X86_VPCMPBZ128rmi_alt;
break;
283 case X86_VPCMPBZ128rmik: NewOpc = X86_VPCMPBZ128rmik_alt;
break;
284 case X86_VPCMPBZ128rri: NewOpc = X86_VPCMPBZ128rri_alt;
break;
285 case X86_VPCMPBZ128rrik: NewOpc = X86_VPCMPBZ128rrik_alt;
break;
286 case X86_VPCMPBZ256rmi: NewOpc = X86_VPCMPBZ256rmi_alt;
break;
287 case X86_VPCMPBZ256rmik: NewOpc = X86_VPCMPBZ256rmik_alt;
break;
288 case X86_VPCMPBZ256rri: NewOpc = X86_VPCMPBZ256rri_alt;
break;
289 case X86_VPCMPBZ256rrik: NewOpc = X86_VPCMPBZ256rrik_alt;
break;
290 case X86_VPCMPBZrmi: NewOpc = X86_VPCMPBZrmi_alt;
break;
291 case X86_VPCMPBZrmik: NewOpc = X86_VPCMPBZrmik_alt;
break;
292 case X86_VPCMPBZrri: NewOpc = X86_VPCMPBZrri_alt;
break;
293 case X86_VPCMPBZrrik: NewOpc = X86_VPCMPBZrrik_alt;
break;
294 case X86_VPCMPDZ128rmi: NewOpc = X86_VPCMPDZ128rmi_alt;
break;
295 case X86_VPCMPDZ128rmib: NewOpc = X86_VPCMPDZ128rmib_alt;
break;
296 case X86_VPCMPDZ128rmibk: NewOpc = X86_VPCMPDZ128rmibk_alt;
break;
297 case X86_VPCMPDZ128rmik: NewOpc = X86_VPCMPDZ128rmik_alt;
break;
298 case X86_VPCMPDZ128rri: NewOpc = X86_VPCMPDZ128rri_alt;
break;
299 case X86_VPCMPDZ128rrik: NewOpc = X86_VPCMPDZ128rrik_alt;
break;
300 case X86_VPCMPDZ256rmi: NewOpc = X86_VPCMPDZ256rmi_alt;
break;
301 case X86_VPCMPDZ256rmib: NewOpc = X86_VPCMPDZ256rmib_alt;
break;
302 case X86_VPCMPDZ256rmibk: NewOpc = X86_VPCMPDZ256rmibk_alt;
break;
303 case X86_VPCMPDZ256rmik: NewOpc = X86_VPCMPDZ256rmik_alt;
break;
304 case X86_VPCMPDZ256rri: NewOpc = X86_VPCMPDZ256rri_alt;
break;
305 case X86_VPCMPDZ256rrik: NewOpc = X86_VPCMPDZ256rrik_alt;
break;
306 case X86_VPCMPDZrmi: NewOpc = X86_VPCMPDZrmi_alt;
break;
307 case X86_VPCMPDZrmib: NewOpc = X86_VPCMPDZrmib_alt;
break;
308 case X86_VPCMPDZrmibk: NewOpc = X86_VPCMPDZrmibk_alt;
break;
309 case X86_VPCMPDZrmik: NewOpc = X86_VPCMPDZrmik_alt;
break;
310 case X86_VPCMPDZrri: NewOpc = X86_VPCMPDZrri_alt;
break;
311 case X86_VPCMPDZrrik: NewOpc = X86_VPCMPDZrrik_alt;
break;
312 case X86_VPCMPQZ128rmi: NewOpc = X86_VPCMPQZ128rmi_alt;
break;
313 case X86_VPCMPQZ128rmib: NewOpc = X86_VPCMPQZ128rmib_alt;
break;
314 case X86_VPCMPQZ128rmibk: NewOpc = X86_VPCMPQZ128rmibk_alt;
break;
315 case X86_VPCMPQZ128rmik: NewOpc = X86_VPCMPQZ128rmik_alt;
break;
316 case X86_VPCMPQZ128rri: NewOpc = X86_VPCMPQZ128rri_alt;
break;
317 case X86_VPCMPQZ128rrik: NewOpc = X86_VPCMPQZ128rrik_alt;
break;
318 case X86_VPCMPQZ256rmi: NewOpc = X86_VPCMPQZ256rmi_alt;
break;
319 case X86_VPCMPQZ256rmib: NewOpc = X86_VPCMPQZ256rmib_alt;
break;
320 case X86_VPCMPQZ256rmibk: NewOpc = X86_VPCMPQZ256rmibk_alt;
break;
321 case X86_VPCMPQZ256rmik: NewOpc = X86_VPCMPQZ256rmik_alt;
break;
322 case X86_VPCMPQZ256rri: NewOpc = X86_VPCMPQZ256rri_alt;
break;
323 case X86_VPCMPQZ256rrik: NewOpc = X86_VPCMPQZ256rrik_alt;
break;
324 case X86_VPCMPQZrmi: NewOpc = X86_VPCMPQZrmi_alt;
break;
325 case X86_VPCMPQZrmib: NewOpc = X86_VPCMPQZrmib_alt;
break;
326 case X86_VPCMPQZrmibk: NewOpc = X86_VPCMPQZrmibk_alt;
break;
327 case X86_VPCMPQZrmik: NewOpc = X86_VPCMPQZrmik_alt;
break;
328 case X86_VPCMPQZrri: NewOpc = X86_VPCMPQZrri_alt;
break;
329 case X86_VPCMPQZrrik: NewOpc = X86_VPCMPQZrrik_alt;
break;
330 case X86_VPCMPUBZ128rmi: NewOpc = X86_VPCMPUBZ128rmi_alt;
break;
331 case X86_VPCMPUBZ128rmik: NewOpc = X86_VPCMPUBZ128rmik_alt;
break;
332 case X86_VPCMPUBZ128rri: NewOpc = X86_VPCMPUBZ128rri_alt;
break;
333 case X86_VPCMPUBZ128rrik: NewOpc = X86_VPCMPUBZ128rrik_alt;
break;
334 case X86_VPCMPUBZ256rmi: NewOpc = X86_VPCMPUBZ256rmi_alt;
break;
335 case X86_VPCMPUBZ256rmik: NewOpc = X86_VPCMPUBZ256rmik_alt;
break;
336 case X86_VPCMPUBZ256rri: NewOpc = X86_VPCMPUBZ256rri_alt;
break;
337 case X86_VPCMPUBZ256rrik: NewOpc = X86_VPCMPUBZ256rrik_alt;
break;
338 case X86_VPCMPUBZrmi: NewOpc = X86_VPCMPUBZrmi_alt;
break;
339 case X86_VPCMPUBZrmik: NewOpc = X86_VPCMPUBZrmik_alt;
break;
340 case X86_VPCMPUBZrri: NewOpc = X86_VPCMPUBZrri_alt;
break;
341 case X86_VPCMPUBZrrik: NewOpc = X86_VPCMPUBZrrik_alt;
break;
342 case X86_VPCMPUDZ128rmi: NewOpc = X86_VPCMPUDZ128rmi_alt;
break;
343 case X86_VPCMPUDZ128rmib: NewOpc = X86_VPCMPUDZ128rmib_alt;
break;
344 case X86_VPCMPUDZ128rmibk: NewOpc = X86_VPCMPUDZ128rmibk_alt;
break;
345 case X86_VPCMPUDZ128rmik: NewOpc = X86_VPCMPUDZ128rmik_alt;
break;
346 case X86_VPCMPUDZ128rri: NewOpc = X86_VPCMPUDZ128rri_alt;
break;
347 case X86_VPCMPUDZ128rrik: NewOpc = X86_VPCMPUDZ128rrik_alt;
break;
348 case X86_VPCMPUDZ256rmi: NewOpc = X86_VPCMPUDZ256rmi_alt;
break;
349 case X86_VPCMPUDZ256rmib: NewOpc = X86_VPCMPUDZ256rmib_alt;
break;
350 case X86_VPCMPUDZ256rmibk: NewOpc = X86_VPCMPUDZ256rmibk_alt;
break;
351 case X86_VPCMPUDZ256rmik: NewOpc = X86_VPCMPUDZ256rmik_alt;
break;
352 case X86_VPCMPUDZ256rri: NewOpc = X86_VPCMPUDZ256rri_alt;
break;
353 case X86_VPCMPUDZ256rrik: NewOpc = X86_VPCMPUDZ256rrik_alt;
break;
354 case X86_VPCMPUDZrmi: NewOpc = X86_VPCMPUDZrmi_alt;
break;
355 case X86_VPCMPUDZrmib: NewOpc = X86_VPCMPUDZrmib_alt;
break;
356 case X86_VPCMPUDZrmibk: NewOpc = X86_VPCMPUDZrmibk_alt;
break;
357 case X86_VPCMPUDZrmik: NewOpc = X86_VPCMPUDZrmik_alt;
break;
358 case X86_VPCMPUDZrri: NewOpc = X86_VPCMPUDZrri_alt;
break;
359 case X86_VPCMPUDZrrik: NewOpc = X86_VPCMPUDZrrik_alt;
break;
360 case X86_VPCMPUQZ128rmi: NewOpc = X86_VPCMPUQZ128rmi_alt;
break;
361 case X86_VPCMPUQZ128rmib: NewOpc = X86_VPCMPUQZ128rmib_alt;
break;
362 case X86_VPCMPUQZ128rmibk: NewOpc = X86_VPCMPUQZ128rmibk_alt;
break;
363 case X86_VPCMPUQZ128rmik: NewOpc = X86_VPCMPUQZ128rmik_alt;
break;
364 case X86_VPCMPUQZ128rri: NewOpc = X86_VPCMPUQZ128rri_alt;
break;
365 case X86_VPCMPUQZ128rrik: NewOpc = X86_VPCMPUQZ128rrik_alt;
break;
366 case X86_VPCMPUQZ256rmi: NewOpc = X86_VPCMPUQZ256rmi_alt;
break;
367 case X86_VPCMPUQZ256rmib: NewOpc = X86_VPCMPUQZ256rmib_alt;
break;
368 case X86_VPCMPUQZ256rmibk: NewOpc = X86_VPCMPUQZ256rmibk_alt;
break;
369 case X86_VPCMPUQZ256rmik: NewOpc = X86_VPCMPUQZ256rmik_alt;
break;
370 case X86_VPCMPUQZ256rri: NewOpc = X86_VPCMPUQZ256rri_alt;
break;
371 case X86_VPCMPUQZ256rrik: NewOpc = X86_VPCMPUQZ256rrik_alt;
break;
372 case X86_VPCMPUQZrmi: NewOpc = X86_VPCMPUQZrmi_alt;
break;
373 case X86_VPCMPUQZrmib: NewOpc = X86_VPCMPUQZrmib_alt;
break;
374 case X86_VPCMPUQZrmibk: NewOpc = X86_VPCMPUQZrmibk_alt;
break;
375 case X86_VPCMPUQZrmik: NewOpc = X86_VPCMPUQZrmik_alt;
break;
376 case X86_VPCMPUQZrri: NewOpc = X86_VPCMPUQZrri_alt;
break;
377 case X86_VPCMPUQZrrik: NewOpc = X86_VPCMPUQZrrik_alt;
break;
378 case X86_VPCMPUWZ128rmi: NewOpc = X86_VPCMPUWZ128rmi_alt;
break;
379 case X86_VPCMPUWZ128rmik: NewOpc = X86_VPCMPUWZ128rmik_alt;
break;
380 case X86_VPCMPUWZ128rri: NewOpc = X86_VPCMPUWZ128rri_alt;
break;
381 case X86_VPCMPUWZ128rrik: NewOpc = X86_VPCMPUWZ128rrik_alt;
break;
382 case X86_VPCMPUWZ256rmi: NewOpc = X86_VPCMPUWZ256rmi_alt;
break;
383 case X86_VPCMPUWZ256rmik: NewOpc = X86_VPCMPUWZ256rmik_alt;
break;
384 case X86_VPCMPUWZ256rri: NewOpc = X86_VPCMPUWZ256rri_alt;
break;
385 case X86_VPCMPUWZ256rrik: NewOpc = X86_VPCMPUWZ256rrik_alt;
break;
386 case X86_VPCMPUWZrmi: NewOpc = X86_VPCMPUWZrmi_alt;
break;
387 case X86_VPCMPUWZrmik: NewOpc = X86_VPCMPUWZrmik_alt;
break;
388 case X86_VPCMPUWZrri: NewOpc = X86_VPCMPUWZrri_alt;
break;
389 case X86_VPCMPUWZrrik: NewOpc = X86_VPCMPUWZrrik_alt;
break;
390 case X86_VPCMPWZ128rmi: NewOpc = X86_VPCMPWZ128rmi_alt;
break;
391 case X86_VPCMPWZ128rmik: NewOpc = X86_VPCMPWZ128rmik_alt;
break;
392 case X86_VPCMPWZ128rri: NewOpc = X86_VPCMPWZ128rri_alt;
break;
393 case X86_VPCMPWZ128rrik: NewOpc = X86_VPCMPWZ128rrik_alt;
break;
394 case X86_VPCMPWZ256rmi: NewOpc = X86_VPCMPWZ256rmi_alt;
break;
395 case X86_VPCMPWZ256rmik: NewOpc = X86_VPCMPWZ256rmik_alt;
break;
396 case X86_VPCMPWZ256rri: NewOpc = X86_VPCMPWZ256rri_alt;
break;
397 case X86_VPCMPWZ256rrik: NewOpc = X86_VPCMPWZ256rrik_alt;
break;
398 case X86_VPCMPWZrmi: NewOpc = X86_VPCMPWZrmi_alt;
break;
399 case X86_VPCMPWZrmik: NewOpc = X86_VPCMPWZrmik_alt;
break;
400 case X86_VPCMPWZrri: NewOpc = X86_VPCMPWZrri_alt;
break;
401 case X86_VPCMPWZrrik: NewOpc = X86_VPCMPWZrrik_alt;
break;
425 immediate |= ~(0xffull);
429 if(immediate & 0x80000000)
430 immediate |= ~(0xffffffffull);
439 if (
type == TYPE_MOFFS8 ||
type == TYPE_MOFFS16 ||
440 type == TYPE_MOFFS32 ||
type == TYPE_MOFFS64) {
453 if (insn->
eaBase == EA_BASE_sib || insn->
eaBase == EA_BASE_sib64) {
462 #define ENTRY(x) case EA_BASE_##x:
470 MCOperand_CreateReg0(mcInst, X86_##x); break;
503 bool IndexIs512, IndexIs128, IndexIs256;
504 int scaleAmount, indexReg;
505 #ifndef CAPSTONE_X86_REDUCE
509 if (insn->
eaBase == EA_BASE_sib || insn->
eaBase == EA_BASE_sib64) {
514 MCOperand_CreateReg0(mcInst, X86_##x); break;
531 #ifndef CAPSTONE_X86_REDUCE
535 #ifndef CAPSTONE_X86_REDUCE
536 Opcode == X86_VGATHERDPDrm ||
537 Opcode == X86_VGATHERDPDYrm ||
538 Opcode == X86_VGATHERQPDrm ||
539 Opcode == X86_VGATHERDPSrm ||
540 Opcode == X86_VGATHERQPSrm ||
541 Opcode == X86_VPGATHERDQrm ||
542 Opcode == X86_VPGATHERDQYrm ||
543 Opcode == X86_VPGATHERQQrm ||
544 Opcode == X86_VPGATHERDDrm ||
545 Opcode == X86_VPGATHERQDrm ||
550 #ifndef CAPSTONE_X86_REDUCE
551 Opcode == X86_VGATHERQPDYrm ||
552 Opcode == X86_VGATHERDPSYrm ||
553 Opcode == X86_VGATHERQPSYrm ||
554 Opcode == X86_VGATHERDPDZrm ||
555 Opcode == X86_VPGATHERDQZrm ||
556 Opcode == X86_VPGATHERQQYrm ||
557 Opcode == X86_VPGATHERDDYrm ||
558 Opcode == X86_VPGATHERQDYrm ||
563 #ifndef CAPSTONE_X86_REDUCE
564 Opcode == X86_VGATHERQPDZrm ||
565 Opcode == X86_VGATHERDPSZrm ||
566 Opcode == X86_VGATHERQPSZrm ||
567 Opcode == X86_VPGATHERQQZrm ||
568 Opcode == X86_VPGATHERDDZrm ||
569 Opcode == X86_VPGATHERQDZrm ||
574 if (IndexIs128 || IndexIs256 || IndexIs512) {
575 unsigned IndexOffset = insn->
sibIndex -
576 (insn->
addressSize == 8 ? SIB_INDEX_RAX:SIB_INDEX_EAX);
577 SIBIndex IndexBase = IndexIs512 ? SIB_INDEX_ZMM0 :
578 IndexIs256 ? SIB_INDEX_YMM0 : SIB_INDEX_XMM0;
589 case SIB_INDEX_##x: \
590 indexReg = X86_##x; break;
649 MCOperand_CreateReg0(mcInst, X86_##x); break;
652 #define ENTRY(x) case EA_REG_##x:
701 case TYPE_CONTROLREG:
702 return translateRMRegister(mcInst, insn);
719 return translateRMMemory(mcInst, insn);
731 static void translateFPRegister(
MCInst *mcInst,
uint8_t stackPos)
742 static bool translateMaskRegister(
MCInst *mcInst,
uint8_t maskRegNum)
744 if (maskRegNum >= 8) {
765 translateRegister(mcInst, insn->
reg);
767 case ENCODING_WRITEMASK:
768 return translateMaskRegister(mcInst, insn->
writemask);
770 return translateRM(mcInst,
operand, insn);
788 return translateSrcIndex(mcInst, insn);
790 return translateDstIndex(mcInst, insn);
799 translateFPRegister(mcInst, insn->
modRM & 7);
802 translateRegister(mcInst, insn->
vvvv);
805 return translateOperand(mcInst, &insn->
operands[
operand->type - TYPE_DUP0], insn);
826 #ifndef CAPSTONE_X86_REDUCE
839 if (translateOperand(mcInst, &insn->
operands[index], insn)) {
850 if (address -
info->offset >=
info->size)
854 *
byte =
info->code[address -
info->offset];
869 pub->detail->x86.opcode[2] = inter->
opcode;
872 pub->detail->x86.opcode[1] = inter->
opcode;
875 pub->detail->x86.opcode[0] = inter->
opcode;
883 pub->detail->x86.modrm = inter->
orgModRM;
884 pub->detail->x86.encoding.modrm_offset = inter->
modRMOffset;
886 pub->detail->x86.sib = inter->
sib;
888 pub->detail->x86.sib_scale = inter->
sibScale;
898 if (pub->detail->x86.encoding.imm_size == 0 && inter->
immediateOffset != 0)
915 X86MCRegisterClasses, 79,
916 0, 0, X86RegDiffLists, 0,
917 X86SubRegIdxLists, 7,
932 info.size = code_len;
933 info.offset = address;
977 unsigned char b1 = 0,
b2 = 0;
981 if (
b1 == 0x0f &&
b2 == 0xff) {
994 #ifndef CAPSTONE_X86_REDUCE
996 unsigned char b1 = 0,
b2 = 0, b3 = 0, b4 = 0;
1003 if (
b1 == 0xf3 &&
b2 == 0x0f && b3 == 0x1e && b4 == 0xfa) {
1004 instr->
Opcode = X86_ENDBR64;
1006 strncpy(instr->
assembly,
"endbr64", 8);
1010 instr->
flat_insn->detail->x86.opcode[2] = b3;
1011 instr->
flat_insn->detail->x86.opcode[3] = b4;
1014 }
else if (
b1 == 0xf3 &&
b2 == 0x0f && b3 == 0x1e && b4 == 0xfb) {
1015 instr->
Opcode = X86_ENDBR32;
1017 strncpy(instr->
assembly,
"endbr32", 8);
1021 instr->
flat_insn->detail->x86.opcode[2] = b3;
1022 instr->
flat_insn->detail->x86.opcode[3] = b4;
1036 result = (!translateInstruction(instr, &insn)) ?
true :
false;
1040 if (instr->
Opcode == X86_LES16rm || instr->
Opcode == X86_LES32rm)
1043 if (instr->
Opcode == X86_LDS16rm || instr->
Opcode == X86_LDS32rm)
1058 update_pub_insn(instr->
flat_insn, &insn);
unsigned MCInst_getOpcode(const MCInst *inst)
void MCOperand_CreateReg0(MCInst *mcInst, unsigned Reg)
void MCInst_setOpcode(MCInst *inst, unsigned Op)
void MCOperand_CreateImm0(MCInst *mcInst, int64_t Val)
void MCRegisterInfo_InitMCRegisterInfo(MCRegisterInfo *RI, const MCRegisterDesc *D, unsigned NR, unsigned RA, unsigned PC, const MCRegisterClass *C, unsigned NC, uint16_t(*RURoots)[2], unsigned NRU, const MCPhysReg *DL, const char *Strings, const uint16_t *SubIndices, unsigned NumIndices, const uint16_t *RET)
int decodeInstruction(struct InternalInstruction *insn, byteReader_t reader, const void *readerArg, uint64_t startLoc, DisassemblerMode mode)
void X86_init(MCRegisterInfo *MRI)
bool X86_getInstruction(csh handle, const uint8_t *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *info)
x86_reg x86_map_sib_index(int r)
x86_reg x86_map_sib_base(int r)
static mcore_handle handle
RzBinInfo * info(RzBinFile *bf)
@ CS_MODE_64
64-bit mode (X86, PPC)
@ CS_MODE_32
32-bit mode (X86)
@ CS_MODE_16
16-bit mode (X86)
#define offsetof(type, member)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
_W64 unsigned int uintptr_t
EADisplacement eaDisplacement
const struct InstructionSpecifier * spec
uint8_t displacementOffset
uint8_t numImmediatesTranslated
VectorExtensionType vectorExtensionType
uint8_t vectorExtensionPrefix[4]
const struct OperandSpecifier * operands
bool consumedDisplacement
SegmentOverride segmentOverride
if(dbg->bits==RZ_SYS_BITS_64)