Coverage Report

Created: 2023-09-25 06:24

/src/capstonev5/arch/X86/X86IntelInstPrinter.c
Line
Count
Source (jump to first uncovered line)
1
//===-- X86IntelInstPrinter.cpp - Intel assembly instruction printing -----===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file includes code for rendering MCInst instances as Intel-style
11
// assembly.
12
//
13
//===----------------------------------------------------------------------===//
14
15
/* Capstone Disassembly Engine */
16
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
17
18
#ifdef CAPSTONE_HAS_X86
19
20
#if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)
21
#pragma warning(disable:4996)     // disable MSVC's warning on strncpy()
22
#pragma warning(disable:28719)    // disable MSVC's warning on strncpy()
23
#endif
24
25
#if !defined(CAPSTONE_HAS_OSXKERNEL)
26
#include <ctype.h>
27
#endif
28
#include <capstone/platform.h>
29
30
#if defined(CAPSTONE_HAS_OSXKERNEL)
31
#include <Availability.h>
32
#include <libkern/libkern.h>
33
#else
34
#include <stdio.h>
35
#include <stdlib.h>
36
#endif
37
#include <string.h>
38
39
#include "../../utils.h"
40
#include "../../MCInst.h"
41
#include "../../SStream.h"
42
#include "../../MCRegisterInfo.h"
43
44
#include "X86InstPrinter.h"
45
#include "X86Mapping.h"
46
#include "X86InstPrinterCommon.h"
47
48
#define GET_INSTRINFO_ENUM
49
#ifdef CAPSTONE_X86_REDUCE
50
#include "X86GenInstrInfo_reduce.inc"
51
#else
52
#include "X86GenInstrInfo.inc"
53
#endif
54
55
#define GET_REGINFO_ENUM
56
#include "X86GenRegisterInfo.inc"
57
58
#include "X86BaseInfo.h"
59
60
static void printMemReference(MCInst *MI, unsigned Op, SStream *O);
61
static void printOperand(MCInst *MI, unsigned OpNo, SStream *O);
62
63
64
static void set_mem_access(MCInst *MI, bool status)
65
38.9k
{
66
38.9k
  if (MI->csh->detail != CS_OPT_ON)
67
0
    return;
68
69
38.9k
  MI->csh->doing_mem = status;
70
38.9k
  if (!status)
71
    // done, create the next operand slot
72
19.4k
    MI->flat_insn->detail->x86.op_count++;
73
74
38.9k
}
75
76
static void printopaquemem(MCInst *MI, unsigned OpNo, SStream *O)
77
2.49k
{
78
  // FIXME: do this with autogen
79
  // printf(">>> ID = %u\n", MI->flat_insn->id);
80
2.49k
  switch(MI->flat_insn->id) {
81
829
    default:
82
829
      SStream_concat0(O, "ptr ");
83
829
      break;
84
609
    case X86_INS_SGDT:
85
667
    case X86_INS_SIDT:
86
917
    case X86_INS_LGDT:
87
1.20k
    case X86_INS_LIDT:
88
1.21k
    case X86_INS_FXRSTOR:
89
1.34k
    case X86_INS_FXSAVE:
90
1.50k
    case X86_INS_LJMP:
91
1.66k
    case X86_INS_LCALL:
92
      // do not print "ptr"
93
1.66k
      break;
94
2.49k
  }
95
96
2.49k
  switch(MI->csh->mode) {
97
956
    case CS_MODE_16:
98
956
      switch(MI->flat_insn->id) {
99
412
        default:
100
412
          MI->x86opsize = 2;
101
412
          break;
102
85
        case X86_INS_LJMP:
103
154
        case X86_INS_LCALL:
104
154
          MI->x86opsize = 4;
105
154
          break;
106
122
        case X86_INS_SGDT:
107
141
        case X86_INS_SIDT:
108
200
        case X86_INS_LGDT:
109
390
        case X86_INS_LIDT:
110
390
          MI->x86opsize = 6;
111
390
          break;
112
956
      }
113
956
      break;
114
995
    case CS_MODE_32:
115
995
      switch(MI->flat_insn->id) {
116
382
        default:
117
382
          MI->x86opsize = 4;
118
382
          break;
119
73
        case X86_INS_LJMP:
120
141
        case X86_INS_JMP:
121
183
        case X86_INS_LCALL:
122
481
        case X86_INS_SGDT:
123
501
        case X86_INS_SIDT:
124
567
        case X86_INS_LGDT:
125
613
        case X86_INS_LIDT:
126
613
          MI->x86opsize = 6;
127
613
          break;
128
995
      }
129
995
      break;
130
995
    case CS_MODE_64:
131
545
      switch(MI->flat_insn->id) {
132
105
        default:
133
105
          MI->x86opsize = 8;
134
105
          break;
135
10
        case X86_INS_LJMP:
136
57
        case X86_INS_LCALL:
137
246
        case X86_INS_SGDT:
138
265
        case X86_INS_SIDT:
139
390
        case X86_INS_LGDT:
140
440
        case X86_INS_LIDT:
141
440
          MI->x86opsize = 10;
142
440
          break;
143
545
      }
144
545
      break;
145
545
    default:  // never reach
146
0
      break;
147
2.49k
  }
148
149
2.49k
  printMemReference(MI, OpNo, O);
150
2.49k
}
151
152
static void printi8mem(MCInst *MI, unsigned OpNo, SStream *O)
153
31.7k
{
154
31.7k
  SStream_concat0(O, "byte ptr ");
155
31.7k
  MI->x86opsize = 1;
156
31.7k
  printMemReference(MI, OpNo, O);
157
31.7k
}
158
159
static void printi16mem(MCInst *MI, unsigned OpNo, SStream *O)
160
5.70k
{
161
5.70k
  MI->x86opsize = 2;
162
5.70k
  SStream_concat0(O, "word ptr ");
163
5.70k
  printMemReference(MI, OpNo, O);
164
5.70k
}
165
166
static void printi32mem(MCInst *MI, unsigned OpNo, SStream *O)
167
12.2k
{
168
12.2k
  MI->x86opsize = 4;
169
12.2k
  SStream_concat0(O, "dword ptr ");
170
12.2k
  printMemReference(MI, OpNo, O);
171
12.2k
}
172
173
static void printi64mem(MCInst *MI, unsigned OpNo, SStream *O)
174
2.36k
{
175
2.36k
  SStream_concat0(O, "qword ptr ");
176
2.36k
  MI->x86opsize = 8;
177
2.36k
  printMemReference(MI, OpNo, O);
178
2.36k
}
179
180
static void printi128mem(MCInst *MI, unsigned OpNo, SStream *O)
181
1.42k
{
182
1.42k
  SStream_concat0(O, "xmmword ptr ");
183
1.42k
  MI->x86opsize = 16;
184
1.42k
  printMemReference(MI, OpNo, O);
185
1.42k
}
186
187
static void printi512mem(MCInst *MI, unsigned OpNo, SStream *O)
188
703
{
189
703
  SStream_concat0(O, "zmmword ptr ");
190
703
  MI->x86opsize = 64;
191
703
  printMemReference(MI, OpNo, O);
192
703
}
193
194
#ifndef CAPSTONE_X86_REDUCE
195
static void printi256mem(MCInst *MI, unsigned OpNo, SStream *O)
196
991
{
197
991
  SStream_concat0(O, "ymmword ptr ");
198
991
  MI->x86opsize = 32;
199
991
  printMemReference(MI, OpNo, O);
200
991
}
201
202
static void printf32mem(MCInst *MI, unsigned OpNo, SStream *O)
203
1.81k
{
204
1.81k
  switch(MCInst_getOpcode(MI)) {
205
1.44k
    default:
206
1.44k
      SStream_concat0(O, "dword ptr ");
207
1.44k
      MI->x86opsize = 4;
208
1.44k
      break;
209
141
    case X86_FSTENVm:
210
370
    case X86_FLDENVm:
211
      // TODO: fix this in tablegen instead
212
370
      switch(MI->csh->mode) {
213
0
        default:    // never reach
214
0
          break;
215
155
        case CS_MODE_16:
216
155
          MI->x86opsize = 14;
217
155
          break;
218
62
        case CS_MODE_32:
219
215
        case CS_MODE_64:
220
215
          MI->x86opsize = 28;
221
215
          break;
222
370
      }
223
370
      break;
224
1.81k
  }
225
226
1.81k
  printMemReference(MI, OpNo, O);
227
1.81k
}
228
229
static void printf64mem(MCInst *MI, unsigned OpNo, SStream *O)
230
1.29k
{
231
  // TODO: fix COMISD in Tablegen instead (#1456)
232
1.29k
  if (MI->op1_size == 16) {
233
    // printf("printf64mem id = %u\n", MCInst_getOpcode(MI));
234
716
    switch(MCInst_getOpcode(MI)) {
235
565
      default:
236
565
        SStream_concat0(O, "qword ptr ");
237
565
        MI->x86opsize = 8;
238
565
        break;
239
0
      case X86_MOVPQI2QImr:
240
151
      case X86_COMISDrm:
241
151
        SStream_concat0(O, "xmmword ptr ");
242
151
        MI->x86opsize = 16;
243
151
        break;
244
716
    }
245
716
  } else {
246
574
    SStream_concat0(O, "qword ptr ");
247
574
    MI->x86opsize = 8;
248
574
  }
249
250
1.29k
  printMemReference(MI, OpNo, O);
251
1.29k
}
252
253
static void printf80mem(MCInst *MI, unsigned OpNo, SStream *O)
254
337
{
255
337
  switch(MCInst_getOpcode(MI)) {
256
62
    default:
257
62
      SStream_concat0(O, "xword ptr ");
258
62
      break;
259
174
    case X86_FBLDm:
260
275
    case X86_FBSTPm:
261
275
      break;
262
337
  }
263
264
337
  MI->x86opsize = 10;
265
337
  printMemReference(MI, OpNo, O);
266
337
}
267
268
static void printf128mem(MCInst *MI, unsigned OpNo, SStream *O)
269
1.17k
{
270
1.17k
  SStream_concat0(O, "xmmword ptr ");
271
1.17k
  MI->x86opsize = 16;
272
1.17k
  printMemReference(MI, OpNo, O);
273
1.17k
}
274
275
static void printf256mem(MCInst *MI, unsigned OpNo, SStream *O)
276
613
{
277
613
  SStream_concat0(O, "ymmword ptr ");
278
613
  MI->x86opsize = 32;
279
613
  printMemReference(MI, OpNo, O);
280
613
}
281
282
static void printf512mem(MCInst *MI, unsigned OpNo, SStream *O)
283
342
{
284
342
  SStream_concat0(O, "zmmword ptr ");
285
342
  MI->x86opsize = 64;
286
342
  printMemReference(MI, OpNo, O);
287
342
}
288
#endif
289
290
static const char *getRegisterName(unsigned RegNo);
291
static void printRegName(SStream *OS, unsigned RegNo)
292
219k
{
293
219k
  SStream_concat0(OS, getRegisterName(RegNo));
294
219k
}
295
296
// for MASM syntax, 0x123 = 123h, 0xA123 = 0A123h
297
// this function tell us if we need to have prefix 0 in front of a number
298
static bool need_zero_prefix(uint64_t imm)
299
0
{
300
  // find the first hex letter representing imm
301
0
  while(imm >= 0x10)
302
0
    imm >>= 4;
303
304
0
  if (imm < 0xa)
305
0
    return false;
306
0
  else  // this need 0 prefix
307
0
    return true;
308
0
}
309
310
static void printImm(MCInst *MI, SStream *O, int64_t imm, bool positive)
311
61.0k
{
312
61.0k
  if (positive) {
313
    // always print this number in positive form
314
51.6k
    if (MI->csh->syntax == CS_OPT_SYNTAX_MASM) {
315
0
      if (imm < 0) {
316
0
        if (MI->op1_size) {
317
0
          switch(MI->op1_size) {
318
0
            default:
319
0
              break;
320
0
            case 1:
321
0
              imm &= 0xff;
322
0
              break;
323
0
            case 2:
324
0
              imm &= 0xffff;
325
0
              break;
326
0
            case 4:
327
0
              imm &= 0xffffffff;
328
0
              break;
329
0
          }
330
0
        }
331
332
0
        if (imm == 0x8000000000000000LL)  // imm == -imm
333
0
          SStream_concat0(O, "8000000000000000h");
334
0
        else if (need_zero_prefix(imm))
335
0
          SStream_concat(O, "0%"PRIx64"h", imm);
336
0
        else
337
0
          SStream_concat(O, "%"PRIx64"h", imm);
338
0
      } else {
339
0
        if (imm > HEX_THRESHOLD) {
340
0
          if (need_zero_prefix(imm))
341
0
            SStream_concat(O, "0%"PRIx64"h", imm);
342
0
          else
343
0
            SStream_concat(O, "%"PRIx64"h", imm);
344
0
        } else
345
0
          SStream_concat(O, "%"PRIu64, imm);
346
0
      }
347
51.6k
    } else { // Intel syntax
348
51.6k
      if (imm < 0) {
349
571
        if (MI->op1_size) {
350
141
          switch(MI->op1_size) {
351
141
            default:
352
141
              break;
353
141
            case 1:
354
0
              imm &= 0xff;
355
0
              break;
356
0
            case 2:
357
0
              imm &= 0xffff;
358
0
              break;
359
0
            case 4:
360
0
              imm &= 0xffffffff;
361
0
              break;
362
141
          }
363
141
        }
364
365
571
        SStream_concat(O, "0x%"PRIx64, imm);
366
51.0k
      } else {
367
51.0k
        if (imm > HEX_THRESHOLD)
368
47.9k
          SStream_concat(O, "0x%"PRIx64, imm);
369
3.11k
        else
370
3.11k
          SStream_concat(O, "%"PRIu64, imm);
371
51.0k
      }
372
51.6k
    }
373
51.6k
  } else {
374
9.41k
    if (MI->csh->syntax == CS_OPT_SYNTAX_MASM) {
375
0
      if (imm < 0) {
376
0
        if (imm == 0x8000000000000000LL)  // imm == -imm
377
0
          SStream_concat0(O, "8000000000000000h");
378
0
        else if (imm < -HEX_THRESHOLD) {
379
0
          if (need_zero_prefix(imm))
380
0
            SStream_concat(O, "-0%"PRIx64"h", -imm);
381
0
          else
382
0
            SStream_concat(O, "-%"PRIx64"h", -imm);
383
0
        } else
384
0
          SStream_concat(O, "-%"PRIu64, -imm);
385
0
      } else {
386
0
        if (imm > HEX_THRESHOLD) {
387
0
          if (need_zero_prefix(imm))
388
0
            SStream_concat(O, "0%"PRIx64"h", imm);
389
0
          else
390
0
            SStream_concat(O, "%"PRIx64"h", imm);
391
0
        } else
392
0
          SStream_concat(O, "%"PRIu64, imm);
393
0
      }
394
9.41k
    } else { // Intel syntax
395
9.41k
      if (imm < 0) {
396
1.37k
        if (imm == 0x8000000000000000LL)  // imm == -imm
397
0
          SStream_concat0(O, "0x8000000000000000");
398
1.37k
        else if (imm < -HEX_THRESHOLD)
399
1.20k
          SStream_concat(O, "-0x%"PRIx64, -imm);
400
173
        else
401
173
          SStream_concat(O, "-%"PRIu64, -imm);
402
403
8.03k
      } else {
404
8.03k
        if (imm > HEX_THRESHOLD)
405
7.11k
          SStream_concat(O, "0x%"PRIx64, imm);
406
919
        else
407
919
          SStream_concat(O, "%"PRIu64, imm);
408
8.03k
      }
409
9.41k
    }
410
9.41k
  }
411
61.0k
}
412
413
// local printOperand, without updating public operands
414
static void _printOperand(MCInst *MI, unsigned OpNo, SStream *O)
415
79.2k
{
416
79.2k
  MCOperand *Op  = MCInst_getOperand(MI, OpNo);
417
79.2k
  if (MCOperand_isReg(Op)) {
418
79.2k
    printRegName(O, MCOperand_getReg(Op));
419
79.2k
  } else if (MCOperand_isImm(Op)) {
420
0
    int64_t imm = MCOperand_getImm(Op);
421
0
    printImm(MI, O, imm, MI->csh->imm_unsigned);
422
0
  }
423
79.2k
}
424
425
#ifndef CAPSTONE_DIET
426
// copy & normalize access info
427
static void get_op_access(cs_struct *h, unsigned int id, uint8_t *access, uint64_t *eflags)
428
410k
{
429
410k
#ifndef CAPSTONE_DIET
430
410k
  uint8_t i;
431
410k
  const uint8_t *arr = X86_get_op_access(h, id, eflags);
432
433
410k
  if (!arr) {
434
0
    access[0] = 0;
435
0
    return;
436
0
  }
437
438
  // copy to access but zero out CS_AC_IGNORE
439
1.14M
  for(i = 0; arr[i]; i++) {
440
738k
    if (arr[i] != CS_AC_IGNORE)
441
617k
      access[i] = arr[i];
442
121k
    else
443
121k
      access[i] = 0;
444
738k
  }
445
446
  // mark the end of array
447
410k
  access[i] = 0;
448
410k
#endif
449
410k
}
450
#endif
451
452
static void printSrcIdx(MCInst *MI, unsigned Op, SStream *O)
453
6.86k
{
454
6.86k
  MCOperand *SegReg;
455
6.86k
  int reg;
456
457
6.86k
  if (MI->csh->detail) {
458
6.86k
#ifndef CAPSTONE_DIET
459
6.86k
    uint8_t access[6];
460
6.86k
#endif
461
462
6.86k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM;
463
6.86k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize;
464
6.86k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID;
465
6.86k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_REG_INVALID;
466
6.86k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = X86_REG_INVALID;
467
6.86k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = 1;
468
6.86k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0;
469
470
6.86k
#ifndef CAPSTONE_DIET
471
6.86k
    get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
472
6.86k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
473
6.86k
#endif
474
6.86k
  }
475
476
6.86k
  SegReg = MCInst_getOperand(MI, Op + 1);
477
6.86k
  reg = MCOperand_getReg(SegReg);
478
479
  // If this has a segment register, print it.
480
6.86k
  if (reg) {
481
396
    _printOperand(MI, Op + 1, O);
482
396
    if (MI->csh->detail) {
483
396
      MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_register_map(reg);
484
396
    }
485
396
    SStream_concat0(O, ":");
486
396
  }
487
488
6.86k
  SStream_concat0(O, "[");
489
6.86k
  set_mem_access(MI, true);
490
6.86k
  printOperand(MI, Op, O);
491
6.86k
  SStream_concat0(O, "]");
492
6.86k
  set_mem_access(MI, false);
493
6.86k
}
494
495
static void printDstIdx(MCInst *MI, unsigned Op, SStream *O)
496
12.6k
{
497
12.6k
  if (MI->csh->detail) {
498
12.6k
#ifndef CAPSTONE_DIET
499
12.6k
    uint8_t access[6];
500
12.6k
#endif
501
502
12.6k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM;
503
12.6k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize;
504
12.6k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID;
505
12.6k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_REG_INVALID;
506
12.6k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = X86_REG_INVALID;
507
12.6k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = 1;
508
12.6k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0;
509
510
12.6k
#ifndef CAPSTONE_DIET
511
12.6k
    get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
512
12.6k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
513
12.6k
#endif
514
12.6k
  }
515
516
  // DI accesses are always ES-based on non-64bit mode
517
12.6k
  if (MI->csh->mode != CS_MODE_64) {
518
9.09k
    SStream_concat0(O, "es:[");
519
9.09k
    if (MI->csh->detail) {
520
9.09k
      MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_ES;
521
9.09k
    }
522
9.09k
  } else
523
3.51k
    SStream_concat0(O, "[");
524
525
12.6k
  set_mem_access(MI, true);
526
12.6k
  printOperand(MI, Op, O);
527
12.6k
  SStream_concat0(O, "]");
528
12.6k
  set_mem_access(MI, false);
529
12.6k
}
530
531
static void printSrcIdx8(MCInst *MI, unsigned OpNo, SStream *O)
532
2.84k
{
533
2.84k
  SStream_concat0(O, "byte ptr ");
534
2.84k
  MI->x86opsize = 1;
535
2.84k
  printSrcIdx(MI, OpNo, O);
536
2.84k
}
537
538
static void printSrcIdx16(MCInst *MI, unsigned OpNo, SStream *O)
539
736
{
540
736
  SStream_concat0(O, "word ptr ");
541
736
  MI->x86opsize = 2;
542
736
  printSrcIdx(MI, OpNo, O);
543
736
}
544
545
static void printSrcIdx32(MCInst *MI, unsigned OpNo, SStream *O)
546
2.76k
{
547
2.76k
  SStream_concat0(O, "dword ptr ");
548
2.76k
  MI->x86opsize = 4;
549
2.76k
  printSrcIdx(MI, OpNo, O);
550
2.76k
}
551
552
static void printSrcIdx64(MCInst *MI, unsigned OpNo, SStream *O)
553
516
{
554
516
  SStream_concat0(O, "qword ptr ");
555
516
  MI->x86opsize = 8;
556
516
  printSrcIdx(MI, OpNo, O);
557
516
}
558
559
static void printDstIdx8(MCInst *MI, unsigned OpNo, SStream *O)
560
5.26k
{
561
5.26k
  SStream_concat0(O, "byte ptr ");
562
5.26k
  MI->x86opsize = 1;
563
5.26k
  printDstIdx(MI, OpNo, O);
564
5.26k
}
565
566
static void printDstIdx16(MCInst *MI, unsigned OpNo, SStream *O)
567
1.59k
{
568
1.59k
  SStream_concat0(O, "word ptr ");
569
1.59k
  MI->x86opsize = 2;
570
1.59k
  printDstIdx(MI, OpNo, O);
571
1.59k
}
572
573
static void printDstIdx32(MCInst *MI, unsigned OpNo, SStream *O)
574
4.82k
{
575
4.82k
  SStream_concat0(O, "dword ptr ");
576
4.82k
  MI->x86opsize = 4;
577
4.82k
  printDstIdx(MI, OpNo, O);
578
4.82k
}
579
580
static void printDstIdx64(MCInst *MI, unsigned OpNo, SStream *O)
581
917
{
582
917
  SStream_concat0(O, "qword ptr ");
583
917
  MI->x86opsize = 8;
584
917
  printDstIdx(MI, OpNo, O);
585
917
}
586
587
static void printMemOffset(MCInst *MI, unsigned Op, SStream *O)
588
1.54k
{
589
1.54k
  MCOperand *DispSpec = MCInst_getOperand(MI, Op);
590
1.54k
  MCOperand *SegReg = MCInst_getOperand(MI, Op + 1);
591
1.54k
  int reg;
592
593
1.54k
  if (MI->csh->detail) {
594
1.54k
#ifndef CAPSTONE_DIET
595
1.54k
    uint8_t access[6];
596
1.54k
#endif
597
598
1.54k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM;
599
1.54k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize;
600
1.54k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID;
601
1.54k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_REG_INVALID;
602
1.54k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = X86_REG_INVALID;
603
1.54k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = 1;
604
1.54k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0;
605
606
1.54k
#ifndef CAPSTONE_DIET
607
1.54k
    get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
608
1.54k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
609
1.54k
#endif
610
1.54k
  }
611
612
  // If this has a segment register, print it.
613
1.54k
  reg = MCOperand_getReg(SegReg);
614
1.54k
  if (reg) {
615
14
    _printOperand(MI, Op + 1, O);
616
14
    SStream_concat0(O, ":");
617
14
    if (MI->csh->detail) {
618
14
      MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_register_map(reg);
619
14
    }
620
14
  }
621
622
1.54k
  SStream_concat0(O, "[");
623
624
1.54k
  if (MCOperand_isImm(DispSpec)) {
625
1.54k
    int64_t imm = MCOperand_getImm(DispSpec);
626
1.54k
    if (MI->csh->detail)
627
1.54k
      MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = imm;
628
629
1.54k
    if (imm < 0)
630
185
      printImm(MI, O, arch_masks[MI->csh->mode] & imm, true);
631
1.35k
    else
632
1.35k
      printImm(MI, O, imm, true);
633
1.54k
  }
634
635
1.54k
  SStream_concat0(O, "]");
636
637
1.54k
  if (MI->csh->detail)
638
1.54k
    MI->flat_insn->detail->x86.op_count++;
639
640
1.54k
  if (MI->op1_size == 0)
641
1.54k
    MI->op1_size = MI->x86opsize;
642
1.54k
}
643
644
static void printU8Imm(MCInst *MI, unsigned Op, SStream *O)
645
7.56k
{
646
7.56k
  uint8_t val = MCOperand_getImm(MCInst_getOperand(MI, Op)) & 0xff;
647
648
7.56k
  printImm(MI, O, val, true);
649
650
7.56k
  if (MI->csh->detail) {
651
7.56k
#ifndef CAPSTONE_DIET
652
7.56k
    uint8_t access[6];
653
7.56k
#endif
654
655
7.56k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_IMM;
656
7.56k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].imm = val;
657
7.56k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = 1;
658
659
7.56k
#ifndef CAPSTONE_DIET
660
7.56k
    get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
661
7.56k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
662
7.56k
#endif
663
664
7.56k
    MI->flat_insn->detail->x86.op_count++;
665
7.56k
  }
666
7.56k
}
667
668
static void printMemOffs8(MCInst *MI, unsigned OpNo, SStream *O)
669
800
{
670
800
  SStream_concat0(O, "byte ptr ");
671
800
  MI->x86opsize = 1;
672
800
  printMemOffset(MI, OpNo, O);
673
800
}
674
675
static void printMemOffs16(MCInst *MI, unsigned OpNo, SStream *O)
676
238
{
677
238
  SStream_concat0(O, "word ptr ");
678
238
  MI->x86opsize = 2;
679
238
  printMemOffset(MI, OpNo, O);
680
238
}
681
682
static void printMemOffs32(MCInst *MI, unsigned OpNo, SStream *O)
683
460
{
684
460
  SStream_concat0(O, "dword ptr ");
685
460
  MI->x86opsize = 4;
686
460
  printMemOffset(MI, OpNo, O);
687
460
}
688
689
static void printMemOffs64(MCInst *MI, unsigned OpNo, SStream *O)
690
45
{
691
45
  SStream_concat0(O, "qword ptr ");
692
45
  MI->x86opsize = 8;
693
45
  printMemOffset(MI, OpNo, O);
694
45
}
695
696
static void printInstruction(MCInst *MI, SStream *O);
697
698
void X86_Intel_printInst(MCInst *MI, SStream *O, void *Info)
699
164k
{
700
164k
  x86_reg reg, reg2;
701
164k
  enum cs_ac_type access1, access2;
702
703
  // printf("opcode = %u\n", MCInst_getOpcode(MI));
704
705
  // perhaps this instruction does not need printer
706
164k
  if (MI->assembly[0]) {
707
0
    strncpy(O->buffer, MI->assembly, sizeof(O->buffer));
708
0
    return;
709
0
  }
710
711
164k
  X86_lockrep(MI, O);
712
164k
  printInstruction(MI, O);
713
714
164k
  reg = X86_insn_reg_intel(MCInst_getOpcode(MI), &access1);
715
164k
  if (MI->csh->detail) {
716
164k
#ifndef CAPSTONE_DIET
717
164k
    uint8_t access[6] = {0};
718
164k
#endif
719
720
    // first op can be embedded in the asm by llvm.
721
    // so we have to add the missing register as the first operand
722
164k
    if (reg) {
723
      // shift all the ops right to leave 1st slot for this new register op
724
16.5k
      memmove(&(MI->flat_insn->detail->x86.operands[1]), &(MI->flat_insn->detail->x86.operands[0]),
725
16.5k
          sizeof(MI->flat_insn->detail->x86.operands[0]) * (ARR_SIZE(MI->flat_insn->detail->x86.operands) - 1));
726
16.5k
      MI->flat_insn->detail->x86.operands[0].type = X86_OP_REG;
727
16.5k
      MI->flat_insn->detail->x86.operands[0].reg = reg;
728
16.5k
      MI->flat_insn->detail->x86.operands[0].size = MI->csh->regsize_map[reg];
729
16.5k
      MI->flat_insn->detail->x86.operands[0].access = access1;
730
16.5k
      MI->flat_insn->detail->x86.op_count++;
731
147k
    } else {
732
147k
      if (X86_insn_reg_intel2(MCInst_getOpcode(MI), &reg, &access1, &reg2, &access2)) {
733
2.91k
        MI->flat_insn->detail->x86.operands[0].type = X86_OP_REG;
734
2.91k
        MI->flat_insn->detail->x86.operands[0].reg = reg;
735
2.91k
        MI->flat_insn->detail->x86.operands[0].size = MI->csh->regsize_map[reg];
736
2.91k
        MI->flat_insn->detail->x86.operands[0].access = access1;
737
2.91k
        MI->flat_insn->detail->x86.operands[1].type = X86_OP_REG;
738
2.91k
        MI->flat_insn->detail->x86.operands[1].reg = reg2;
739
2.91k
        MI->flat_insn->detail->x86.operands[1].size = MI->csh->regsize_map[reg2];
740
2.91k
        MI->flat_insn->detail->x86.operands[1].access = access2;
741
2.91k
        MI->flat_insn->detail->x86.op_count = 2;
742
2.91k
      }
743
147k
    }
744
745
164k
#ifndef CAPSTONE_DIET
746
164k
    get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
747
164k
    MI->flat_insn->detail->x86.operands[0].access = access[0];
748
164k
    MI->flat_insn->detail->x86.operands[1].access = access[1];
749
164k
#endif
750
164k
  }
751
752
164k
  if (MI->op1_size == 0 && reg)
753
12.6k
    MI->op1_size = MI->csh->regsize_map[reg];
754
164k
}
755
756
/// printPCRelImm - This is used to print an immediate value that ends up
757
/// being encoded as a pc-relative value.
758
static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
759
12.0k
{
760
12.0k
  MCOperand *Op = MCInst_getOperand(MI, OpNo);
761
12.0k
  if (MCOperand_isImm(Op)) {
762
12.0k
    int64_t imm = MCOperand_getImm(Op) + MI->flat_insn->size + MI->address;
763
12.0k
    uint8_t opsize = X86_immediate_size(MI->Opcode, NULL);
764
765
    // truncat imm for non-64bit
766
12.0k
    if (MI->csh->mode != CS_MODE_64) {
767
8.64k
      imm = imm & 0xffffffff;
768
8.64k
    }
769
770
12.0k
    printImm(MI, O, imm, true);
771
772
12.0k
    if (MI->csh->detail) {
773
12.0k
#ifndef CAPSTONE_DIET
774
12.0k
      uint8_t access[6];
775
12.0k
#endif
776
777
12.0k
      MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_IMM;
778
      // if op_count > 0, then this operand's size is taken from the destination op
779
12.0k
      if (MI->flat_insn->detail->x86.op_count > 0)
780
0
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->flat_insn->detail->x86.operands[0].size;
781
12.0k
      else if (opsize > 0)
782
604
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = opsize;
783
11.4k
      else
784
11.4k
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->imm_size;
785
12.0k
      MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].imm = imm;
786
787
12.0k
#ifndef CAPSTONE_DIET
788
12.0k
      get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
789
12.0k
      MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
790
12.0k
#endif
791
792
12.0k
      MI->flat_insn->detail->x86.op_count++;
793
12.0k
    }
794
795
12.0k
    if (MI->op1_size == 0)
796
12.0k
      MI->op1_size = MI->imm_size;
797
12.0k
  }
798
12.0k
}
799
800
static void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
801
160k
{
802
160k
  MCOperand *Op  = MCInst_getOperand(MI, OpNo);
803
804
160k
  if (MCOperand_isReg(Op)) {
805
140k
    unsigned int reg = MCOperand_getReg(Op);
806
807
140k
    printRegName(O, reg);
808
140k
    if (MI->csh->detail) {
809
140k
      if (MI->csh->doing_mem) {
810
19.4k
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_register_map(reg);
811
120k
      } else {
812
120k
#ifndef CAPSTONE_DIET
813
120k
        uint8_t access[6];
814
120k
#endif
815
816
120k
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_REG;
817
120k
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].reg = X86_register_map(reg);
818
120k
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->csh->regsize_map[X86_register_map(reg)];
819
820
120k
#ifndef CAPSTONE_DIET
821
120k
        get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
822
120k
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
823
120k
#endif
824
825
120k
        MI->flat_insn->detail->x86.op_count++;
826
120k
      }
827
140k
    }
828
829
140k
    if (MI->op1_size == 0)
830
72.5k
      MI->op1_size = MI->csh->regsize_map[X86_register_map(reg)];
831
140k
  } else if (MCOperand_isImm(Op)) {
832
20.0k
    uint8_t encsize;
833
20.0k
    int64_t imm = MCOperand_getImm(Op);
834
20.0k
    uint8_t opsize = X86_immediate_size(MCInst_getOpcode(MI), &encsize);
835
836
20.0k
    if (opsize == 1)    // print 1 byte immediate in positive form
837
7.47k
      imm = imm & 0xff;
838
839
    // printf(">>> id = %u\n", MI->flat_insn->id);
840
20.0k
    switch(MI->flat_insn->id) {
841
9.41k
      default:
842
9.41k
        printImm(MI, O, imm, MI->csh->imm_unsigned);
843
9.41k
        break;
844
845
92
      case X86_INS_MOVABS:
846
2.76k
      case X86_INS_MOV:
847
        // do not print number in negative form
848
2.76k
        printImm(MI, O, imm, true);
849
2.76k
        break;
850
851
0
      case X86_INS_IN:
852
0
      case X86_INS_OUT:
853
0
      case X86_INS_INT:
854
        // do not print number in negative form
855
0
        imm = imm & 0xff;
856
0
        printImm(MI, O, imm, true);
857
0
        break;
858
859
186
      case X86_INS_LCALL:
860
990
      case X86_INS_LJMP:
861
990
      case X86_INS_JMP:
862
        // always print address in positive form
863
990
        if (OpNo == 1) { // ptr16 part
864
495
          imm = imm & 0xffff;
865
495
          opsize = 2;
866
495
        } else
867
495
          opsize = 4;
868
990
        printImm(MI, O, imm, true);
869
990
        break;
870
871
1.53k
      case X86_INS_AND:
872
3.38k
      case X86_INS_OR:
873
4.27k
      case X86_INS_XOR:
874
        // do not print number in negative form
875
4.27k
        if (imm >= 0 && imm <= HEX_THRESHOLD)
876
430
          printImm(MI, O, imm, true);
877
3.84k
        else {
878
3.84k
          imm = arch_masks[opsize? opsize : MI->imm_size] & imm;
879
3.84k
          printImm(MI, O, imm, true);
880
3.84k
        }
881
4.27k
        break;
882
883
2.05k
      case X86_INS_RET:
884
2.61k
      case X86_INS_RETF:
885
        // RET imm16
886
2.61k
        if (imm >= 0 && imm <= HEX_THRESHOLD)
887
447
          printImm(MI, O, imm, true);
888
2.17k
        else {
889
2.17k
          imm = 0xffff & imm;
890
2.17k
          printImm(MI, O, imm, true);
891
2.17k
        }
892
2.61k
        break;
893
20.0k
    }
894
895
20.0k
    if (MI->csh->detail) {
896
20.0k
      if (MI->csh->doing_mem) {
897
0
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = imm;
898
20.0k
      } else {
899
20.0k
#ifndef CAPSTONE_DIET
900
20.0k
        uint8_t access[6];
901
20.0k
#endif
902
903
20.0k
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_IMM;
904
20.0k
        if (opsize > 0) {
905
15.7k
          MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = opsize;
906
15.7k
          MI->flat_insn->detail->x86.encoding.imm_size = encsize;
907
15.7k
        } else if (MI->flat_insn->detail->x86.op_count > 0) {
908
1.11k
          if (MI->flat_insn->id != X86_INS_LCALL && MI->flat_insn->id != X86_INS_LJMP) {
909
1.11k
            MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size =
910
1.11k
              MI->flat_insn->detail->x86.operands[0].size;
911
1.11k
          } else
912
0
            MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->imm_size;
913
1.11k
        } else
914
3.22k
          MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->imm_size;
915
20.0k
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].imm = imm;
916
917
20.0k
#ifndef CAPSTONE_DIET
918
20.0k
        get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
919
20.0k
        MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
920
20.0k
#endif
921
922
20.0k
        MI->flat_insn->detail->x86.op_count++;
923
20.0k
      }
924
20.0k
    }
925
20.0k
  }
926
160k
}
927
928
static void printMemReference(MCInst *MI, unsigned Op, SStream *O)
929
64.3k
{
930
64.3k
  bool NeedPlus = false;
931
64.3k
  MCOperand *BaseReg  = MCInst_getOperand(MI, Op + X86_AddrBaseReg);
932
64.3k
  uint64_t ScaleVal = MCOperand_getImm(MCInst_getOperand(MI, Op + X86_AddrScaleAmt));
933
64.3k
  MCOperand *IndexReg  = MCInst_getOperand(MI, Op + X86_AddrIndexReg);
934
64.3k
  MCOperand *DispSpec = MCInst_getOperand(MI, Op + X86_AddrDisp);
935
64.3k
  MCOperand *SegReg = MCInst_getOperand(MI, Op + X86_AddrSegmentReg);
936
64.3k
  int reg;
937
938
64.3k
  if (MI->csh->detail) {
939
64.3k
#ifndef CAPSTONE_DIET
940
64.3k
    uint8_t access[6];
941
64.3k
#endif
942
943
64.3k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].type = X86_OP_MEM;
944
64.3k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].size = MI->x86opsize;
945
64.3k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_REG_INVALID;
946
64.3k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.base = X86_register_map(MCOperand_getReg(BaseReg));
947
64.3k
        if (MCOperand_getReg(IndexReg) != X86_EIZ) {
948
64.0k
            MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.index = X86_register_map(MCOperand_getReg(IndexReg));
949
64.0k
        }
950
64.3k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.scale = (int)ScaleVal;
951
64.3k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = 0;
952
953
64.3k
#ifndef CAPSTONE_DIET
954
64.3k
    get_op_access(MI->csh, MCInst_getOpcode(MI), access, &MI->flat_insn->detail->x86.eflags);
955
64.3k
    MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].access = access[MI->flat_insn->detail->x86.op_count];
956
64.3k
#endif
957
64.3k
  }
958
959
  // If this has a segment register, print it.
960
64.3k
  reg = MCOperand_getReg(SegReg);
961
64.3k
  if (reg) {
962
1.81k
    _printOperand(MI, Op + X86_AddrSegmentReg, O);
963
1.81k
    if (MI->csh->detail) {
964
1.81k
      MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.segment = X86_register_map(reg);
965
1.81k
    }
966
1.81k
    SStream_concat0(O, ":");
967
1.81k
  }
968
969
64.3k
  SStream_concat0(O, "[");
970
971
64.3k
  if (MCOperand_getReg(BaseReg)) {
972
62.8k
    _printOperand(MI, Op + X86_AddrBaseReg, O);
973
62.8k
    NeedPlus = true;
974
62.8k
  }
975
976
64.3k
  if (MCOperand_getReg(IndexReg) && MCOperand_getReg(IndexReg) != X86_EIZ) {
977
14.1k
    if (NeedPlus) SStream_concat0(O, " + ");
978
14.1k
    _printOperand(MI, Op + X86_AddrIndexReg, O);
979
14.1k
    if (ScaleVal != 1)
980
1.50k
      SStream_concat(O, "*%u", ScaleVal);
981
14.1k
    NeedPlus = true;
982
14.1k
  }
983
984
64.3k
  if (MCOperand_isImm(DispSpec)) {
985
64.3k
    int64_t DispVal = MCOperand_getImm(DispSpec);
986
64.3k
    if (MI->csh->detail)
987
64.3k
      MI->flat_insn->detail->x86.operands[MI->flat_insn->detail->x86.op_count].mem.disp = DispVal;
988
64.3k
    if (DispVal) {
989
19.8k
      if (NeedPlus) {
990
18.7k
        if (DispVal < 0) {
991
7.41k
          SStream_concat0(O, " - ");
992
7.41k
          printImm(MI, O, -DispVal, true);
993
11.3k
        } else {
994
11.3k
          SStream_concat0(O, " + ");
995
11.3k
          printImm(MI, O, DispVal, true);
996
11.3k
        }
997
18.7k
      } else {
998
        // memory reference to an immediate address
999
1.04k
        if (MI->csh->mode == CS_MODE_64)
1000
44
          MI->op1_size = 8;
1001
1.04k
        if (DispVal < 0) {
1002
332
          printImm(MI, O, arch_masks[MI->csh->mode] & DispVal, true);
1003
714
        } else {
1004
714
          printImm(MI, O, DispVal, true);
1005
714
        }
1006
1.04k
      }
1007
1008
44.5k
    } else {
1009
      // DispVal = 0
1010
44.5k
      if (!NeedPlus)  // [0]
1011
74
        SStream_concat0(O, "0");
1012
44.5k
    }
1013
64.3k
  }
1014
1015
64.3k
  SStream_concat0(O, "]");
1016
1017
64.3k
  if (MI->csh->detail)
1018
64.3k
    MI->flat_insn->detail->x86.op_count++;
1019
1020
64.3k
  if (MI->op1_size == 0)
1021
44.5k
    MI->op1_size = MI->x86opsize;
1022
64.3k
}
1023
1024
static void printanymem(MCInst *MI, unsigned OpNo, SStream *O)
1025
1.09k
{
1026
1.09k
  switch(MI->Opcode) {
1027
10
    default: break;
1028
158
    case X86_LEA16r:
1029
158
         MI->x86opsize = 2;
1030
158
         break;
1031
79
    case X86_LEA32r:
1032
118
    case X86_LEA64_32r:
1033
118
         MI->x86opsize = 4;
1034
118
         break;
1035
12
    case X86_LEA64r:
1036
12
         MI->x86opsize = 8;
1037
12
         break;
1038
22
    case X86_BNDCL32rm:
1039
186
    case X86_BNDCN32rm:
1040
289
    case X86_BNDCU32rm:
1041
457
    case X86_BNDSTXmr:
1042
530
    case X86_BNDLDXrm:
1043
537
    case X86_BNDCL64rm:
1044
637
    case X86_BNDCN64rm:
1045
798
    case X86_BNDCU64rm:
1046
798
         MI->x86opsize = 16;
1047
798
         break;
1048
1.09k
  }
1049
1050
1.09k
  printMemReference(MI, OpNo, O);
1051
1.09k
}
1052
1053
#ifdef CAPSTONE_X86_REDUCE
1054
#include "X86GenAsmWriter1_reduce.inc"
1055
#else
1056
#include "X86GenAsmWriter1.inc"
1057
#endif
1058
1059
#include "X86GenRegisterName1.inc"
1060
1061
#endif