package ocaml-base-compiler

  1. Overview
  2. Docs

Structured representation of Intel assembly language (32 and 64 bit).

type condition =
  1. | L
  2. | GE
  3. | LE
  4. | G
  5. | B
  6. | AE
  7. | BE
  8. | A
  9. | E
  10. | NE
  11. | O
  12. | NO
  13. | S
  14. | NS
  15. | P
  16. | NP
type rounding =
  1. | RoundUp
  2. | RoundDown
  3. | RoundNearest
  4. | RoundTruncate
type constant =
  1. | Const of int64
  2. | ConstThis
  3. | ConstLabel of string
  4. | ConstAdd of constant * constant
  5. | ConstSub of constant * constant
type data_type =
  1. | NONE
  2. | REAL4
  3. | REAL8
  4. | BYTE
  5. | WORD
  6. | DWORD
  7. | QWORD
  8. | OWORD
  9. | NEAR
  10. | PROC
type reg64 =
  1. | RAX
  2. | RBX
  3. | RCX
  4. | RDX
  5. | RSP
  6. | RBP
  7. | RSI
  8. | RDI
  9. | R8
  10. | R9
  11. | R10
  12. | R11
  13. | R12
  14. | R13
  15. | R14
  16. | R15
type reg8h =
  1. | AH
  2. | BH
  3. | CH
  4. | DH
type registerf =
  1. | XMM of int
  2. | TOS
  3. | ST of int
type arch =
  1. | X64
  2. | X86
type addr = {
  1. arch : arch;
  2. typ : data_type;
  3. idx : reg64;
  4. scale : int;
  5. base : reg64 option;
  6. sym : string option;
  7. displ : int;
}

Addressing modes: displ + sym + base + idx * scale (if scale = 0, idx is ignored and base must be None)

type arg =
  1. | Imm of int64
    (*

    Operand is an immediate constant integer

    *)
  2. | Sym of string
    (*

    Address of a symbol (absolute address except for call/jmp target where it is interpreted as a relative displacement

    *)
  3. | Reg8L of reg64
  4. | Reg8H of reg8h
  5. | Reg16 of reg64
  6. | Reg32 of reg64
  7. | Reg64 of reg64
  8. | Regf of registerf
  9. | Mem of addr
  10. | Mem64_RIP of data_type * string * int
type instruction =
  1. | ADD of arg * arg
  2. | ADDSD of arg * arg
  3. | AND of arg * arg
  4. | ANDPD of arg * arg
  5. | BSWAP of arg
  6. | CALL of arg
  7. | CDQ
  8. | CMOV of condition * arg * arg
  9. | CMP of arg * arg
  10. | COMISD of arg * arg
  11. | CQO
  12. | CVTSD2SI of arg * arg
  13. | CVTSD2SS of arg * arg
  14. | CVTSI2SD of arg * arg
  15. | CVTSS2SD of arg * arg
  16. | CVTTSD2SI of arg * arg
  17. | DEC of arg
  18. | DIVSD of arg * arg
  19. | FABS
  20. | FADD of arg
  21. | FADDP of arg * arg
  22. | FCHS
  23. | FCOMP of arg
  24. | FCOMPP
  25. | FCOS
  26. | FDIV of arg
  27. | FDIVP of arg * arg
  28. | FDIVR of arg
  29. | FDIVRP of arg * arg
  30. | FILD of arg
  31. | FISTP of arg
  32. | FLD of arg
  33. | FLD1
  34. | FLDCW of arg
  35. | FLDLG2
  36. | FLDLN2
  37. | FLDZ
  38. | FMUL of arg
  39. | FMULP of arg * arg
  40. | FNSTCW of arg
  41. | FNSTSW of arg
  42. | FPATAN
  43. | FPTAN
  44. | FSIN
  45. | FSQRT
  46. | FSTP of arg
  47. | FSUB of arg
  48. | FSUBP of arg * arg
  49. | FSUBR of arg
  50. | FSUBRP of arg * arg
  51. | FXCH of arg
  52. | FYL2X
  53. | HLT
  54. | IDIV of arg
  55. | IMUL of arg * arg option
  56. | INC of arg
  57. | J of condition * arg
  58. | JMP of arg
  59. | LEA of arg * arg
  60. | LEAVE
  61. | MOV of arg * arg
  62. | MOVAPD of arg * arg
  63. | MOVLPD of arg * arg
  64. | MOVSD of arg * arg
  65. | MOVSS of arg * arg
  66. | MOVSX of arg * arg
  67. | MOVSXD of arg * arg
  68. | MOVZX of arg * arg
  69. | MULSD of arg * arg
  70. | NEG of arg
  71. | NOP
  72. | OR of arg * arg
  73. | POP of arg
  74. | PUSH of arg
  75. | RET
  76. | ROUNDSD of rounding * arg * arg
  77. | SAL of arg * arg
  78. | SAR of arg * arg
  79. | SET of condition * arg
  80. | SHR of arg * arg
  81. | SQRTSD of arg * arg
  82. | SUB of arg * arg
  83. | SUBSD of arg * arg
  84. | TEST of arg * arg
  85. | UCOMISD of arg * arg
  86. | XCHG of arg * arg
  87. | XOR of arg * arg
  88. | XORPD of arg * arg
type asm_line =
  1. | Ins of instruction
  2. | Align of bool * int
  3. | Byte of constant
  4. | Bytes of string
  5. | Comment of string
  6. | Global of string
  7. | Long of constant
  8. | NewLabel of string * data_type
  9. | Quad of constant
  10. | Section of string list * string option * string list
  11. | Space of int
  12. | Word of constant
  13. | External of string * data_type
  14. | Mode386
  15. | Model of string
  16. | Cfi_adjust_cfa_offset of int
  17. | Cfi_endproc
  18. | Cfi_startproc
  19. | File of int * string
  20. | Indirect_symbol of string
  21. | Loc of int * int * int
  22. | Private_extern of string
  23. | Set of string * constant
  24. | Size of string * constant
  25. | Type of string * string
type asm_program = asm_line list
OCaml

Innovation. Community. Security.