package binsec

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type simd_size =
  1. | S32
  2. | S64
  3. | S128
type xmm_mm =
  1. | XMM
  2. | MM
type xmm_pos =
  1. | Left
  2. | Right
type mode = [
  1. | `M32
  2. | `M16
]
type sizeMode = [
  1. | mode
  2. | `M8
]
type address_size_mode =
  1. | A16
  2. | A32
type rep =
  1. | NoRep
  2. | Rep
  3. | RepE
  4. | RepNE
Register sets
type reg8 =
  1. | AL
  2. | CL
  3. | DL
  4. | BL
  5. | AH
  6. | CH
  7. | DH
  8. | BH

General-purpose 8-bit registers

type reg16 =
  1. | AX
  2. | CX
  3. | DX
  4. | BX
  5. | SP
  6. | BP
  7. | SI
  8. | DI

General-purpose 16-bit registers

type reg32 =
  1. | EAX
  2. | ECX
  3. | EDX
  4. | EBX
  5. | ESP
  6. | EBP
  7. | ESI
  8. | EDI

General-purpose 32-bit registers

type segment_reg =
  1. | ES
  2. | CS
  3. | SS
  4. | DS
  5. | FS
  6. | GS

Segment registers

type float_reg =
  1. | ST0
  2. | ST1
  3. | ST2
  4. | ST3
  5. | ST4
  6. | ST5
  7. | ST6
  8. | ST7

Floating-point registers

type mmx_reg =
  1. | MM0
  2. | MM1
  3. | MM2
  4. | MM3
  5. | MM4
  6. | MM5
  7. | MM6
  8. | MM7

MMX registers

type xmm_reg =
  1. | XMM0
  2. | XMM1
  3. | XMM2
  4. | XMM3
  5. | XMM4
  6. | XMM5
  7. | XMM6
  8. | XMM7

XMM registers

type control_reg =
  1. | CR0
  2. | CR2
  3. | CR3
  4. | CR4

Control registers

type debug_reg =
  1. | DR0
  2. | DR1
  3. | DR2
  4. | DR3
  5. | DR6
  6. | DR7

Debug registers

type test_reg =
  1. | TR3
  2. | TR4
  3. | TR5
  4. | TR6
  5. | TR7

Test registers

Flags
Condition codes
type flag =
  1. | ID
  2. | VIP
  3. | VIF
  4. | AC
  5. | VM
  6. | RF
  7. | NT
  8. | IOPL
  9. | OF
  10. | DF
  11. | IF
  12. | TF
  13. | SF
  14. | ZF
  15. | AF
  16. | PF
  17. | CF

Flags

type condition =
  1. | O
  2. | B
  3. | Z
  4. | BE
  5. | S
  6. | P
  7. | L
  8. | LE

Basic conditions

type cc = {
  1. truth_value : bool;
  2. condition : condition;
}

A condition code is a pair of a basic condition and a boolean indicating whether that condition is true.

type sse =
  1. | SseEQ
  2. | SseLT
  3. | SseLE
  4. | SseUNORD
  5. | SseNEQ
  6. | SseNLT
  7. | SseNLE
  8. | SseORD

SSE tests

Addresses
type scale =
  1. | Scale1
  2. | Scale2
  3. | Scale4
  4. | Scale8

Scales for integer operations

type address = {
  1. addrMode : address_size_mode;
    (*

    Address size attribute

    *)
  2. addrDisp : int64;
    (*

    Constant displacement

    *)
  3. addrBase : reg32 option;
    (*

    Optional base register

    *)
  4. addrIndex : (scale * reg32) option;
    (*

    Optional index register, along with a scaling factor by which to multiply it

    *)
}

The memory address format supported by the machine language

Operands
type 'a genop =
  1. | Imm of int64
    (*

    A constant machine integer -no immediate values of more than 64 bits-

    *)
  2. | Reg of 'a
    (*

    A register

    *)
  3. | Address of address
    (*

    A memory dereference

    *)

Generic instruction operands, indexed by the relevant register set

type genopxmm = xmm_reg genop
type genop32 = reg32 genop
type genop16 = reg16 genop
type genop8 = reg8 genop

Specializations to particular register sets

Operations
type arith_op =
  1. | Add
  2. | Adc
  3. | And
  4. | Or
  5. | Xor
  6. | Sub
  7. | Sbb

Arithmetic operations

type shift_op =
  1. | Shl
  2. | Shr
  3. | Sar

Bitwise shift operations

type shiftd_op =
  1. | Shld
  2. | Shrd
type rotate_op =
  1. | Rol
  2. | Ror
  3. | Rcl
  4. | Rcr

Rotate operations

type ('a, 'b) ar2 = {
  1. mode : sizeMode;
  2. dst : 'a;
  3. src : 'b;
}
type instruction_kind =
  1. | Arith of sizeMode * arith_op * genop32 * genop32
  2. | Call of int64
  3. | DCall of genop32
  4. | Cmp of sizeMode * genop32 * genop32
  5. | CmpXchg of sizeMode * genop32 * genop32
  6. | CmpXchg8b of xmm_mm * simd_size * genopxmm
  7. | Test of sizeMode * genop32 * genop32
  8. | Inc of sizeMode * genop32
  9. | Dec of sizeMode * genop32
  10. | Jcc of cc * int64
  11. | Jcxz of mode * int64
  12. | Jmp of int64
  13. | Jmpf of int * int64
  14. | DJmp of genop32
  15. | Lea of sizeMode * reg32 * address
  16. | LoadFarPointer of mode * segment_reg * reg32 * address
  17. | Enter of mode * int * int
  18. | Leave of mode
  19. | CMovcc of sizeMode * cc * genop32 * genop32
  20. | CBW of mode
  21. | CWD of mode
  22. | Cmps of rep * sizeMode
  23. | Mov of sizeMode * genop32 * genop32
  24. | MovSegRight of genop16 * segment_reg
  25. | MovSegLeft of segment_reg * genop16
  26. | Movzx of mode * reg32 * genop8
  27. | Movzx16 of mode * reg32 * genop16
  28. | Movsx of mode * reg32 * genop8
  29. | Movsx16 of mode * reg32 * genop16
  30. | Xadd of sizeMode * genop32 * genop32
  31. | Movs of rep * sizeMode
  32. | Lods of rep * sizeMode
  33. | Stos of rep * sizeMode
  34. | Scas of rep * sizeMode
  35. | Bt of (genop32, genop32) ar2
  36. | Bts of (genop32, genop32) ar2
  37. | Btr of (genop32, genop32) ar2
  38. | Btc of (genop32, genop32) ar2
  39. | Nop
  40. | Not of sizeMode * genop32
  41. | Neg of sizeMode * genop32
  42. | Pop of sizeMode * genop32
  43. | PopS of segment_reg
  44. | PopA of mode
  45. | Push of sizeMode * genop32
  46. | PushS of segment_reg
  47. | PushA of mode
  48. | Pushfd of mode
  49. | Popfd of mode
  50. | Bswap of mode * reg32
  51. | Bsr of mode * reg32 * genop32
  52. | Bsf of mode * reg32 * genop32
  53. | Ret
  54. | Reti of int
  55. | Retf
  56. | Retfi of int
  57. | Shift of sizeMode * shift_op * genop32 * genop8
  58. | Rotate of sizeMode * rotate_op * genop32 * genop8
  59. | Shiftd of sizeMode * shiftd_op * genop32 * genop32 * genop8
  60. | SetCc of cc * genop8
  61. | Halt
  62. | Clc
  63. | Stc
  64. | Cld
  65. | Std
  66. | Cmc
  67. | Xchg of sizeMode * genop32 * genop32
  68. | Mul of sizeMode * genop32
  69. | IMul of sizeMode * genop32 option * genop32 * genop32
  70. | Div of sizeMode * genop32
  71. | IDiv of sizeMode * genop32
  72. | Unsupported of string
  73. | Undecoded
  74. | Loopnz of mode * address_size_mode * int64
  75. | Loopz of mode * address_size_mode * int64
  76. | Loop of mode * address_size_mode * int64
  77. | Pshufw of xmm_mm * simd_size * xmm_reg * genopxmm * int
  78. | Pshuflw of xmm_mm * simd_size * xmm_reg * genopxmm * int
  79. | Pshufhw of xmm_mm * simd_size * xmm_reg * genopxmm * int
  80. | Pshufd of xmm_mm * simd_size * xmm_reg * genopxmm * int
  81. | Movaps of simd_size * genopxmm * genopxmm
  82. | Movlpd of simd_size * genopxmm * genopxmm
  83. | Movhpd of simd_size * genopxmm * genopxmm
  84. | Movlps of simd_size * genopxmm * genopxmm
  85. | Movhps of simd_size * genopxmm * genopxmm
  86. | Movhlps of simd_size * genopxmm * genopxmm
  87. | Movlhps of simd_size * genopxmm * genopxmm
  88. | Movsldup of simd_size * genopxmm * genopxmm
  89. | Movshdup of simd_size * genopxmm * genopxmm
  90. | Movddup of simd_size * genopxmm * genopxmm
  91. | Movntq of xmm_mm * simd_size * genopxmm * genopxmm
  92. | Movd of xmm_mm * xmm_pos * genopxmm * genop32
  93. | MovQ of xmm_mm * simd_size * genopxmm * genopxmm
  94. | MovdQA of xmm_mm * simd_size * genopxmm * genopxmm
  95. | MovdQU of xmm_mm * simd_size * genopxmm * genopxmm
  96. | Palignr of xmm_mm * simd_size * genopxmm * genopxmm * int
  97. | Pcmpeqb of xmm_mm * simd_size * genopxmm * genopxmm
  98. | Pcmpeqw of xmm_mm * simd_size * genopxmm * genopxmm
  99. | Pcmpeqd of xmm_mm * simd_size * genopxmm * genopxmm
  100. | Pcmpgtb of xmm_mm * simd_size * genopxmm * genopxmm
  101. | Pcmpgtw of xmm_mm * simd_size * genopxmm * genopxmm
  102. | Pcmpgtd of xmm_mm * simd_size * genopxmm * genopxmm
  103. | PmovMSKB of xmm_mm * simd_size * genop32 * genopxmm
  104. | Pminu of xmm_mm * simd_size * genopxmm * genopxmm * int
  105. | Pmins of xmm_mm * simd_size * genopxmm * genopxmm * int
  106. | Pxor of xmm_mm * simd_size * genopxmm * genopxmm
  107. | Por of xmm_mm * simd_size * genopxmm * genopxmm
  108. | Pand of xmm_mm * simd_size * genopxmm * genopxmm
  109. | Pandn of xmm_mm * simd_size * genopxmm * genopxmm
  110. | Pmaxu of xmm_mm * simd_size * genopxmm * genopxmm * int
  111. | Pmaxs of xmm_mm * simd_size * genopxmm * genopxmm * int
  112. | Punpckl of xmm_mm * simd_size * genopxmm * genopxmm * int
  113. | Punpckh of xmm_mm * simd_size * genopxmm * genopxmm * int
  114. | Packus of xmm_mm * simd_size * genopxmm * genopxmm * int
  115. | Packss of xmm_mm * simd_size * genopxmm * genopxmm * int
  116. | Pmaddwd of xmm_mm * simd_size * genopxmm * genopxmm
  117. | Pmaddusbsw of xmm_mm * simd_size * genopxmm * genopxmm
  118. | Padd of xmm_mm * simd_size * genopxmm * genopxmm * int
  119. | Padds of xmm_mm * simd_size * genopxmm * genopxmm * int
  120. | Paddus of xmm_mm * simd_size * genopxmm * genopxmm * int
  121. | Psub of xmm_mm * simd_size * genopxmm * genopxmm * int
  122. | Psubs of xmm_mm * simd_size * genopxmm * genopxmm * int
  123. | Psubus of xmm_mm * simd_size * genopxmm * genopxmm * int
  124. | Pavgu of xmm_mm * simd_size * genopxmm * genopxmm * int
  125. | Pmulhw of xmm_mm * simd_size * genopxmm * genopxmm
  126. | Pmulhrw of xmm_mm * simd_size * genopxmm * genopxmm
  127. | Pmullw of xmm_mm * simd_size * genopxmm * genopxmm
  128. | Pmuludq of xmm_mm * simd_size * genopxmm * genopxmm
  129. | Psrl of xmm_mm * simd_size * genopxmm * genopxmm * int
  130. | Psll of xmm_mm * simd_size * genopxmm * genopxmm * int
  131. | Psra of xmm_mm * simd_size * genopxmm * genopxmm * int
  132. | Psrldq of genopxmm * int
  133. | Pslldq of genopxmm * int
  134. | Pclmulqdq of xmm_mm * simd_size * genopxmm * genopxmm * int
  135. | Ptest of xmm_mm * simd_size * genopxmm * genopxmm
  136. | Movups of genopxmm * genopxmm
  137. | Movupd of genopxmm * genopxmm
  138. | Xlat of address_size_mode
  139. | Aas
  140. | Aam of int
  141. | Aad of int
  142. | Lsl of sizeMode * genop32 * genop32
  143. | Fld
  144. | Fxch of float_reg
  145. | Lahf
  146. | Sahf
  147. | Salc
  148. | Wait
  149. | Emms
  150. | Popcnt of sizeMode * genop32 * genop32
  151. | Lzcnt of sizeMode * genop32 * genop32
  152. | Prefetch of string
  153. | Lgdt of sizeMode * genop32
  154. | Lidt of sizeMode * genop32
  155. | Ltr of genop16
  156. | Iret of sizeMode
  157. | OutPortImm of int
  158. | OutPortDx

Standard x86 instruction set

OCaml

Innovation. Community. Security.