text stringlengths 0 601k |
|---|
let leaq = bicmd " leaq " |
let sete = slcmd " sete " |
let setne = slcmd " setne " |
let setl = slcmd " setl " |
let setle = slcmd " setle " |
let setg = slcmd " setg " |
let setge = slcmd " setge " |
let cmpl = bicmd " cmpl " |
let addl = bicmd " addl " |
let addq = bicmd " addq " |
let subl = bicmd " subl " |
let subq = bicmd " subq " |
let imul = bicmd " imul " |
let imulq = bicmd " imulq " |
let mulq = bicmd " mulq " |
let idivl = slcmd " idivl " |
let idivq = slcmd " idivq " |
let divq = slcmd " divq " |
let ands = bicmd " and " |
let andb = bicmd " andb " |
let ors = bicmd " or " |
let orl = bicmd " orl " |
let xor = bicmd " xor " |
let sall = bicmd " sall " |
let sarl = bicmd " sarl " |
let neg = slcmd " neg " |
let nnot = slcmd " nnot " |
let jz = slcmd " jz " |
let je = slcmd " je " |
let jmp = slcmd " jmp " |
let call = slcmd " call " |
let nop = nacmd " nop " |
let enter = bicmd " enter " |
let leave = nacmd " leave " |
let ret = nacmd " ret " |
let retq = nacmd " retq " |
type condition = X86_ast . condition = | L | GE | LE | G | B | AE | BE | A | E | NE | O | NO | S | NS | P | NP |
type rounding = X86_ast . rounding = | RoundUp | RoundDown | RoundNearest | RoundTruncate |
type constant = X86_ast . constant = | Const of int64 | ConstThis | ConstLabel of string | ConstAdd of constant * constant | ConstSub of constant * constant |
type data_type = X86_ast . data_type = | NONE | REAL4 | REAL8 | BYTE | WORD | DWORD | QWORD | OWORD | NEAR | PROC |
type reg64 = X86_ast . reg64 = | RAX | RBX | RCX | RDX | RSP | RBP | RSI | RDI | R8 | R9 | R10 | R11 | R12 | R13 | R14 | R15 |
type reg8h = X86_ast . reg8h = AH | BH | CH | DH [ @@ deriving eq , ord , show ] |
type registerf = X86_ast . registerf = XMM of int | TOS | ST of int |
type arch = X86_ast . arch = X64 | X86 [ @@ deriving eq , ord , show ] |
type addr = X86_ast . addr = { arch : arch ; typ : data_type ; idx : reg64 ; scale : int ; base : reg64 option ; sym : string option ; displ : int ; } |
type arg = X86_ast . arg = | Imm of int64 | Sym of string | Reg8L of reg64 | Reg8H of reg8h | Reg16 of reg64 | Reg32 of reg64 | Reg64 of reg64 | Regf of registerf | Mem of addr | Mem64_RIP of data_type * string * int |
type instruction = X86_ast . instruction = | ADD of arg * arg | ADDSD of arg * arg | AND of arg * arg | ANDPD of arg * arg | BSWAP of arg | CALL of arg | CDQ | CMOV of condition * arg * arg | CMP of arg * arg | COMISD of arg * arg | CQO | CVTSD2SI of arg * arg | CVTSD2SS of arg * arg | CVTSI2SD of arg * arg | CVTSS2SD ... |
type asm_line = X86_ast . asm_line = | Ins of instruction | Align of bool * int | Byte of constant | Bytes of string | Comment of string | Global of string | Long of constant | NewLabel of string * data_type | Quad of constant | Section of string list * string option * string list | Space of int | Word of constant | Ex... |
type asm_program = asm_line list [ @@ deriving eq , ord , show ] |
let sym s = Sym s |
let nat n = Imm ( Int64 . of_nativeint n ) |
let int n = Imm ( Int64 . of_int n ) |
let const_32 n = Const ( Int64 . of_int32 n ) |
let const_nat n = Const ( Int64 . of_nativeint n ) |
let const n = Const ( Int64 . of_int n ) |
let al = Reg8L RAX |
let ah = Reg8H AH |
let cl = Reg8L RCX |
let ax = Reg16 RAX |
let rax = Reg64 RAX |
let r10 = Reg64 R10 |
let r11 = Reg64 R11 |
let r13 = Reg64 R13 |
let r14 = Reg64 R14 |
let r15 = Reg64 R15 |
let rsp = Reg64 RSP |
let rbp = Reg64 RBP |
let xmm15 = Regf ( XMM 15 ) |
let eax = Reg32 RAX |
let ebx = Reg32 RBX |
let ecx = Reg32 RCX |
let edx = Reg32 RDX |
let ebp = Reg32 RBP |
let esp = Reg32 RSP |
let st0 = Regf ( ST 0 ) |
let st1 = Regf ( ST 1 ) |
let mem32 typ ( ? scale = 1 ) ? base ? sym displ idx = assert ( scale >= 0 ) ; Mem { arch = X86 ; typ ; idx ; scale ; base ; sym ; displ } |
let mem64 typ ( ? scale = 1 ) ? base ? sym displ idx = assert ( scale > 0 ) ; Mem { arch = X64 ; typ ; idx ; scale ; base ; sym ; displ } |
let mem64_rip typ ( ? ofs = 0 ) s = Mem64_RIP ( typ , s , ofs ) |
module D = struct let section segment flags args = directive ( Section ( segment , flags , args ) ) let align n = directive ( Align ( false , n ) ) let byte n = directive ( Byte n ) let bytes s = directive ( Bytes s ) let cfi_adjust_cfa_offset n = directive ( Cfi_adjust_cfa_offset n ) let cfi_endproc ( ) = directive Cf... |
module I = struct let add x y = emit ( ADD ( x , y ) ) let addsd x y = emit ( ADDSD ( x , y ) ) let and_ x y = emit ( AND ( x , y ) ) let andpd x y = emit ( ANDPD ( x , y ) ) let bswap x = emit ( BSWAP x ) let call x = emit ( CALL x ) let cdq ( ) = emit CDQ let cmp x y = emit ( CMP ( x , y ) ) let comisd x y = emit ( C... |
type section = { sec_name : string ; mutable sec_instrs : X86_ast_helpers . asm_line array ; } |
type data_size = B8 | B16 | B32 | B64 [ @@ deriving eq , ord , show ] |
module IntSet = Set . Make ( struct type t = int let compare : t -> t -> int = compare end ) |
let print_old_arg ppf = function | Imm _ -> Format . fprintf ppf " Imm " | Reg8L _ -> Format . fprintf ppf " Reg8L " | Reg8H _ -> Format . fprintf ppf " Reg8H " | Reg16 _ -> Format . fprintf ppf " Reg16 " | Reg32 _ -> Format . fprintf ppf " Reg32 " | Reg64 _ -> Format . fprintf ppf " Reg64 " | Regf _ -> Format . fprint... |
module Relocation = struct module Kind = struct type t = | REL32 of string * int64 | DIR32 of string * int64 | DIR64 of string * int64 [ @@ deriving eq , ord , show ] end type t = { offset_from_section_beginning : int ; kind : Kind . t } [ @@ deriving eq , ord , show ] end |
type symbol = { sy_name : string ; mutable sy_type : string option ; mutable sy_size : int option ; mutable sy_global : bool ; mutable sy_sec : section ; [ @ printer fun fmt _ -> Format . fprintf fmt " . . . " ] mutable sy_pos : int option ; mutable sy_num : int option ; } |
type buffer = { sec : section ; buf : Buffer . t ; mutable labels : symbol String . Map . t ; mutable patches : ( int * data_size * int64 ) list ; mutable relocations : Relocation . t list ; } |
type local_reloc = | RelocCall of string | RelocShortJump of string * int | RelocLongJump of string | RelocConstant of X86_ast_helpers . constant * data_size |
type result = | Rint of int64 | Rabs of string * int64 | Rrel of string * int64 |
let get_symbol b s = try String . Map . find s b . labels with Not_found -> let sy = { sy_name = s ; sy_type = None ; sy_size = None ; sy_pos = None ; sy_global = false ; sy_num = None ; sy_sec = b . sec ; } in b . labels <- String . Map . add ~ key : s ~ data : sy b . labels ; sy |
let buf_int8 b i = Buffer . add_char b . buf ( char_of_int ( i land 0xff ) ) |
let buf_int8L b iL = buf_int8 b ( Int64 . to_int iL ) |
let buf_int16L b iL = buf_int8L b iL ; buf_int8L b ( Int64 . shift_right iL 8 ) |
let buf_int32L b iL = buf_int16L b iL ; buf_int16L b ( Int64 . shift_right iL 16 ) |
let buf_int64L b iL = buf_int32L b iL ; buf_int32L b ( Int64 . shift_right iL 32 ) |
let str_int8L s pos v = Bytes . set s pos ( char_of_int ( Int64 . to_int v land 0xff ) ) |
let str_int16L s pos v = str_int8L s pos v ; str_int8L s ( pos + 1 ) ( Int64 . shift_right_logical v 8 ) |
let str_int32L s pos v = str_int16L s pos v ; str_int16L s ( pos + 2 ) ( Int64 . shift_right_logical v 16 ) |
let str_int64L s pos v = str_int32L s pos v ; str_int32L s ( pos + 4 ) ( Int64 . shift_right_logical v 32 ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.