Module X86_types

module BV = Bap.Std.Bitvector
type mode =
  1. | X86
  2. | X8664
val compare_mode : mode -> mode -> int
type order =
  1. | Low
  2. | High
type direction =
  1. | Forward
  2. | Backward
type operand =
  1. | Oreg of int
  2. | Ovec of int
  3. | Oseg of int
  4. | Oaddr of Bap.Std.Exp.t
  5. | Oimm of Bap.Std.addr
val compare_operand : operand -> operand -> int
type jumptarget =
  1. | Jabs of operand
  2. | Jrel of Bap.Std.addr * Bap.Std.addr
module Pcmpstr : sig ... end

See section 4.1 of the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volumes 2A & 2B: Instruction Set Reference (order numbers 253666 and 253667)

type offsetinfo = {
  1. offlen : Bap.Std.typ;
  2. offtyp : Bap.Std.typ;
  3. offop : operand;
  4. offsrcoffset : int;
  5. offdstoffset : int;
}
type cast_type = Bap.Std.cast
type opcode =
  1. | Bswap of Bap.Std.typ * operand
  2. | Retn of (Bap.Std.typ * operand) option * bool
    (*

    bytes to release, far/near ret

    *)
  3. | Nop
  4. | Mov of Bap.Std.typ * operand * operand * Bap.Std.Exp.t option
    (*

    dst, src, condition

    *)
  5. | Movs of Bap.Std.typ
  6. | Movzx of Bap.Std.typ * operand * Bap.Std.typ * operand
    (*

    dsttyp, dst, srctyp, src

    *)
  7. | Movsx of Bap.Std.typ * operand * Bap.Std.typ * operand
    (*

    dsttyp, dst, srctyp, src

    *)
  8. | Movdq of Bap.Std.typ * operand * Bap.Std.typ * operand * bool
    (*

    dst type, dst op, src type, src op, aligned

    *)
  9. | Movoffset of Bap.Std.typ * operand * offsetinfo list
    (*

    dest type, dest, (src copy length, src type, src, src src offset, src dest offset)*

    *)
  10. | Lea of Bap.Std.typ * operand * Bap.Std.Exp.t
  11. | Call of operand * Bap.Std.addr
    (*

    addr is RA

    *)
  12. | Shift of Bap.Std.binop * Bap.Std.typ * operand * operand
  13. | Shiftd of Bap.Std.binop * Bap.Std.typ * operand * operand * operand
  14. | Rotate of Bap.Std.binop * Bap.Std.typ * operand * operand * bool
    (*

    left or right, type, src/dest op, shift op, use carry flag

    *)
  15. | Bt of Bap.Std.typ * operand * operand
  16. | Bs of Bap.Std.typ * operand * operand * direction
  17. | Jump of jumptarget
  18. | Jcc of jumptarget * Bap.Std.Exp.t
  19. | Setcc of Bap.Std.typ * operand * Bap.Std.Exp.t
  20. | Hlt
  21. | Cmps of Bap.Std.typ
  22. | Scas of Bap.Std.typ
  23. | Stos of Bap.Std.typ
  24. | Push of Bap.Std.typ * operand
  25. | Pop of Bap.Std.typ * operand
  26. | Pushf of Bap.Std.typ
  27. | Popf of Bap.Std.typ
  28. | Popcnt of Bap.Std.typ * operand * operand
    (*

    size, src, dest

    *)
  29. | Sahf
  30. | Lahf
  31. | Add of Bap.Std.typ * operand * operand
  32. | Adc of Bap.Std.typ * operand * operand
  33. | Inc of Bap.Std.typ * operand
  34. | Dec of Bap.Std.typ * operand
  35. | Sub of Bap.Std.typ * operand * operand
  36. | Sbb of Bap.Std.typ * operand * operand
  37. | Cmp of Bap.Std.typ * operand * operand
  38. | Cmpxchg of Bap.Std.typ * operand * operand
  39. | Cmpxchg8b of operand
  40. | Xadd of Bap.Std.typ * operand * operand
  41. | Xchg of Bap.Std.typ * operand * operand
  42. | And of Bap.Std.typ * operand * operand
  43. | Or of Bap.Std.typ * operand * operand
  44. | Xor of Bap.Std.typ * operand * operand
  45. | Test of Bap.Std.typ * operand * operand
  46. | Ptest of Bap.Std.typ * operand * operand
  47. | Not of Bap.Std.typ * operand
  48. | Neg of Bap.Std.typ * operand
  49. | Mul of Bap.Std.typ * operand
    (*

    typ, src

    *)
  50. | Imul of Bap.Std.typ * bool * operand * operand * operand
    (*

    typ, (true if one operand form, dst operand), src1, src2

    *)
  51. | Div of Bap.Std.typ * operand
    (*

    typ, src

    *)
  52. | Idiv of Bap.Std.typ * operand
    (*

    typ, src

    *)
  53. | Cld
  54. | Rdtsc
  55. | Cpuid
  56. | Xgetbv
  57. | Stmxcsr of operand
  58. | Ldmxcsr of operand
  59. | Fnstcw of operand
  60. | Fldcw of operand
  61. | Fld of operand
  62. | Fst of operand * bool
  63. | Punpck of Bap.Std.typ * Bap.Std.typ * order * operand * operand * operand option
    (*

    dest size, element size, low/high elements, dest, src, optional VEX src

    *)
  64. | Ppackedbinop of Bap.Std.typ * Bap.Std.typ * binopf * string * operand * operand * operand option
    (*

    Perform a generic packed binary operation. dest size, element size, binop, assembly string, dest, src, optional VEX src

    *)
  65. | Pbinop of Bap.Std.typ * binopf * string * operand * operand * operand option
  66. | Pmov of Bap.Std.typ * Bap.Std.typ * Bap.Std.typ * operand * operand * cast_type * string
    (*

    Packed move. dest size, dest elt size, src elt size, dest, src, ext(signed/zero), name

    *)
  67. | Pmovmskb of Bap.Std.typ * operand * operand
  68. | Pcmp of Bap.Std.typ * Bap.Std.typ * Bap.Std.binop * string * operand * operand * operand option
  69. | Palignr of Bap.Std.typ * operand * operand * operand option * operand
  70. | Pcmpstr of Bap.Std.typ * operand * operand * operand * Pcmpstr.imm8cb * Pcmpstr.pcmpinfo
  71. | Pshufb of Bap.Std.typ * operand * operand * operand option
  72. | Pshufd of Bap.Std.typ * operand * operand * operand option * operand
  73. | Leave of Bap.Std.typ
  74. | Interrupt of operand
  75. | Interrupt3
    (*

    Trap to debugger

    *)
  76. | Sysenter
  77. | Syscall
type rex = {
  1. rex_w : bool;
    (*

    Bit 3: 1 = 64-bit operand size

    *)
  2. rex_r : bool;
    (*

    Bit 2: Extension of ModR/M reg field

    *)
  3. rex_x : bool;
    (*

    Bit 1: Extension of SIB index field

    *)
  4. rex_b : bool;
    (*

    Bit 0: Extension of ModR/M r/m field, SIB base field, or opcode reg field

    *)
}

See Table 2-4: REX Prefix Fields.

type vex = {
  1. vex_nr : bool;
    (*

    inverted rex_r bit

    *)
  2. vex_nx : bool;
    (*

    inverted rex_x bit

    *)
  3. vex_nb : bool;
    (*

    inverted rex_b bit

    *)
  4. vex_map_select : int;
    (*

    Specifies the opcode map to use

    *)
  5. vex_we : bool;
    (*

    For int instructions, equivalent to rex.w. For non-int instructions, opcode extension bit.

    *)
  6. vex_v : int;
    (*

    additional instruction operand (XMM or YMM register)

    *)
  7. vex_l : bool;
    (*

    0 = 128-bit operands (xmm), 1 = 256-bit vector operands (ymm)

    *)
  8. vex_pp : int;
    (*

    Specifies mandatory prefix (0=none, 1=pref_opsize 2=repz 3=repnz)

    *)
}
type prefix = {
  1. addrsize : Bap.Std.typ;
  2. opsize : Bap.Std.typ;
    (*

    General operand size

    *)
  3. bopsize : Bap.Std.typ;
    (*

    Operand size that defaults to machine size (e.g. for pop)

    *)
  4. mopsize : Bap.Std.typ;
    (*

    Multi-scalar operand size

    *)
  5. repeat : bool;
  6. nrepeat : bool;
  7. addrsize_override : bool;
  8. opsize_override : bool;
  9. rex : rex option;
  10. vex : vex option;
  11. r_extend : int;
    (*

    extended r bit

    *)
  12. rm_extend : int;
    (*

    extended rm bit or sib base

    *)
  13. sib_extend : int;
    (*

    extended sib index bit

    *)
}