Expand description
Module to help people generate x86_64 code in Rust
Inspired from https://www.lri.fr/~filliatr/ens/compil/lib/x86_64.ml.html
This crate wants to be an equivalent of the above code
For writting files see
[data::Data], file::File and Text data structures
Registers %rax -> %r15 are all accessible for 8, 16, 32 and 64 bits. Write name in capital letters to access them
Operands can be obtained with lab, ilab, addr, reg! and immb to immq.
All instruction are available for various sizes.
Transfert instruction : movq
Arithmetic : leaq, incq, decq, negq, addq, subq, imulq, cqto, idivq, divq
Jumps : call, call_star, leave, ret, jmp, jmp_star, jcc
Conditions : cmpb, testq, set, cmovq
Various others : [label], comment
Modules§
- data
- Define data segment
- debug
- Defines debug symbols
- directives
- Defines directives
- file
- Define structure for whole file
- instr
- Defines instructions
- reg
- Defines registers and operands
- traits
- Defines various traits
Macros§
- addr
- Create an Operand
(for any type R) to access memory - ilab
- ilab operator from https://www.lri.fr/~filliatr/ens/compil/lib/x86_64.ml.html
- lab
- lab operator from https://www.lri.fr/~filliatr/ens/compil/lib/x86_64.ml.html
- reg
- Macro to convert an element of type R with the trait Reg
to an element of type Operand
Structs§
- Named
Segment - Named Segment
- Segment
- Segment
- SegmentEL
Wrapper - Wrapper around a segment element to store a potential comment
Enums§
- SegmentEL
- Structure representing a segment element
Constants§
- AH
- 8-bits registers (1 byte)
- AL
- 8-bits registers (1 byte)
- AX
- 16-bits registers (2 bytes)
- BH
- 8-bits registers (1 byte)
- BL
- 8-bits registers (1 byte)
- BP
- 16-bits registers (2 bytes)
- BPL
- 8-bits registers (1 byte)
- BX
- 16-bits registers (2 bytes)
- CH
- 8-bits registers (1 byte)
- CL
- 8-bits registers (1 byte)
- CX
- 16-bits registers (2 bytes)
- DH
- 8-bits registers (1 byte)
- DI
- 16-bits registers (2 bytes)
- DIL
- 8-bits registers (1 byte)
- DL
- 8-bits registers (1 byte)
- DX
- 16-bits registers (2 bytes)
- EAX
- 32-bits registers (4 bytes)
- EBP
- 32-bits registers (4 bytes)
- EBX
- 32-bits registers (4 bytes)
- ECX
- 32-bits registers (4 bytes)
- EDI
- 32-bits registers (4 bytes)
- EDX
- 32-bits registers (4 bytes)
- ESI
- 32-bits registers (4 bytes)
- ESP
- 32-bits registers (4 bytes)
- R8
- 64-bits registers (8 bytes)
- R9
- 64-bits registers (8 bytes)
- R8B
- 8-bits registers (1 byte)
- R8D
- 32-bits registers (4 bytes)
- R8W
- 16-bits registers (2 bytes)
- R9B
- 8-bits registers (1 byte)
- R9D
- 32-bits registers (4 bytes)
- R9W
- 16-bits registers (2 bytes)
- R10
- 64-bits registers (8 bytes)
- R11
- 64-bits registers (8 bytes)
- R12
- 64-bits registers (8 bytes)
- R13
- 64-bits registers (8 bytes)
- R14
- 64-bits registers (8 bytes)
- R15
- 64-bits registers (8 bytes)
- R10B
- 8-bits registers (1 byte)
- R10D
- 32-bits registers (4 bytes)
- R10W
- 16-bits registers (2 bytes)
- R11B
- 8-bits registers (1 byte)
- R11D
- 32-bits registers (4 bytes)
- R11W
- 16-bits registers (2 bytes)
- R12B
- 8-bits registers (1 byte)
- R12D
- 32-bits registers (4 bytes)
- R12W
- 16-bits registers (2 bytes)
- R13B
- 8-bits registers (1 byte)
- R13D
- 32-bits registers (4 bytes)
- R13W
- 16-bits registers (2 bytes)
- R14B
- 8-bits registers (1 byte)
- R14D
- 32-bits registers (4 bytes)
- R14W
- 16-bits registers (2 bytes)
- R15B
- 8-bits registers (1 byte)
- R15D
- 32-bits registers (4 bytes)
- R15W
- 16-bits registers (2 bytes)
- RAX
- 64-bits registers (8 bytes)
- RBP
- 64-bits registers (8 bytes)
- RBX
- 64-bits registers (8 bytes)
- RCX
- 64-bits registers (8 bytes)
- RDI
- 64-bits registers (8 bytes)
- RDX
- 64-bits registers (8 bytes)
- RSI
- 64-bits registers (8 bytes)
- RSP
- 64-bits registers (8 bytes)
- SI
- 16-bits registers (2 bytes)
- SIL
- 8-bits registers (1 byte)
- SP
- 16-bits registers (2 bytes)
- SPL
- 8-bits registers (1 byte)
Functions§
- addb
- Instructions between 1-bytes operands
- addl
- Instructions between 4-bytes operands
- addq
- Instructions between 8-bytes operands
- addw
- Instructions between 2-bytes operands
- andb
- Instructions between 1-bytes operands
- andl
- Instructions between 4-bytes operands
- andq
- Instructions between 8-bytes operands
- andw
- Instructions between 2-bytes operands
- call
- Call label
- call_
star - Call address
- cltd
- sign extend EAX into EDX::EAX
- cmovl
- Conditional move of 4-bytes operands
- cmovq
- Conditional move of 8-bytes operands
- cmovw
- Conditional move of 2-bytes operands
- cmpb
- Instructions between 1-bytes operands
- cmpl
- Instructions between 4-bytes operands
- cmpq
- Instructions between 8-bytes operands
- cmpw
- Instructions between 2-bytes operands
- comment
- Add comment to Assembly (should not contain de line break!)
- cqto
- sign extend RAX into RDX::RAX
- decb
- Instructions on 1-bytes operands
- decl
- Instructions on 4-bytes operands
- decq
- Instructions on 8-bytes operands
- decw
- Instructions on 2-bytes operands
- deplq
- Move address of label in register (implementation is OS dependant)
- divl
- Instructions on 4-bytes operands
- divq
- Instructions on 8-bytes operands
- idivl
- Instructions on 4-bytes operands
- idivq
- Instructions on 8-bytes operands
- immb
- Immediate operand for 8-bits instructions
- imml
- Immediate operand for 32-bits instructions
- immq
- Operands Immediate operand for 64-bits instructions
- immw
- Immediate operand for 16-bits instructions
- imull
- Instructions between 4-bytes operands
- imulq
- Instructions between 8-bytes operands
- imulw
- Instructions between 2-bytes operands
- incb
- Instructions on 1-bytes operands
- incl
- Instructions on 4-bytes operands
- incq
- Instructions on 8-bytes operands
- incw
- Instructions on 2-bytes operands
- inline
- Directly inline assembly code
- jae
- Conditional jump if above equal
- jcc
- Conditional jump
- jmp
- Jump to label
- jmp_
star - Jump to address
- jnz
- Conditional jump if not zero
- jz
- Conditional jump if zero
- leab
- Instructions between 1-bytes operands
- leal
- Instructions between 4-bytes operands
- leaq
- Instructions between 8-bytes operands
- leave
- Leave instruction
- leaw
- Instructions between 2-bytes operands
- movb
- Instructions between 1-bytes operands
- movl
- Instructions between 4-bytes operands
- movq
- Instructions between 8-bytes operands
- movsbl
- Sign extend for 1-byte to 4-bytes
- movsbq
- Sign extend for 1-byte to 8-bytes
- movsbw
- Sign extend for 1-byte to 2-bytes
- movslq
- Sign extend for 4-byte to 8-bytes
- movswl
- Sign extend for 2-byte to 4-bytes
- movswq
- Sign extend for 2-byte to 8-bytes
- movw
- Instructions between 2-bytes operands
- movzbl
- Extension with zeros for 1-byte to 4-bytes
- movzbq
- Extension with zeros for 1-byte to 8-bytes
- movzbw
- Extension with zeros for 1-byte to 2-bytes
- movzwl
- Extension with zeros for 2-byte to 4-bytes
- movzwq
- Extension with zeros for 2-byte to 8-bytes
- negb
- Instructions on 1-bytes operands
- negl
- Instructions on 4-bytes operands
- negq
- Instructions on 8-bytes operands
- negw
- Instructions on 2-bytes operands
- new_
label - Convert str to label name
- nop
- nop instruction (does nothing)
- notb
- Instructions on 1-bytes operands
- notl
- Instructions on 4-bytes operands
- notq
- Instructions on 8-bytes operands
- notw
- Instructions on 2-bytes operands
- orb
- Instructions between 1-bytes operands
- orl
- Instructions between 4-bytes operands
- orq
- Instructions between 8-bytes operands
- orw
- Instructions between 2-bytes operands
- popq
- Pop 8-bytes from stack
- pushq
- Push 8-bytes on stack
- ret
- Equivalent to popq %rip
- sarb
- Instructions between 1-bytes operands
- sarl
- Instructions between 4-bytes operands
- sarq
- Instructions between 8-bytes operands
- sarw
- Instructions between 2-bytes operands
- set
- Conditionnal set
- shlb
- Instructions between 1-bytes operands
- shlb_
reg - logical shift of register by value in CL
- shll
- Instructions between 4-bytes operands
- shll_
reg - logical shift of register by value in CL
- shlq
- Instructions between 8-bytes operands
- shlq_
reg - logical shift of register by value in CL
- shlw
- Instructions between 2-bytes operands
- shlw_
reg - logical shift of register by value in CL
- shrb
- Instructions between 1-bytes operands
- shrb_
reg - logical shift of register by value in CL
- shrl
- Instructions between 4-bytes operands
- shrl_
reg - logical shift of register by value in CL
- shrq
- Instructions between 8-bytes operands
- shrq_
reg - logical shift of register by value in CL
- shrw
- Instructions between 2-bytes operands
- shrw_
reg - logical shift of register by value in CL
- subb
- Instructions between 1-bytes operands
- subl
- Instructions between 4-bytes operands
- subq
- Instructions between 8-bytes operands
- subw
- Instructions between 2-bytes operands
- testb
- Instructions between 1-bytes operands
- testl
- Instructions between 4-bytes operands
- testq
- Instructions between 8-bytes operands
- testw
- Instructions between 2-bytes operands
- xorb
- Instructions between 1-bytes operands
- xorl
- Instructions between 4-bytes operands
- xorq
- Instructions between 8-bytes operands
- xorw
- Instructions between 2-bytes operands