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

Logic : notq, andq, orq, xorq

Shifts : shlq, shrq, sarq

Jumps : call, call_star, leave, ret, jmp, jmp_star, jcc

Conditions : cmpb, testq, set, cmovq

Stack : pushq, popq

Various others : label, comment

Modules

Define data segment
Define structure for whole file
Defines instructions
Defines registers and operands

Macros

Create an Operand (for any type R) to access memory
Macro to convert an element of type R with the trait Reg to an element of type Operand

Enums

Data structure representing assembly

Constants

8-bits registers (1 byte)
8-bits registers (1 byte)
16-bits registers (2 bytes)
8-bits registers (1 byte)
8-bits registers (1 byte)
16-bits registers (2 bytes)
8-bits registers (1 byte)
16-bits registers (2 bytes)
8-bits registers (1 byte)
8-bits registers (1 byte)
16-bits registers (2 bytes)
8-bits registers (1 byte)
16-bits registers (2 bytes)
8-bits registers (1 byte)
8-bits registers (1 byte)
16-bits registers (2 bytes)
32-bits registers (4 bytes)
32-bits registers (4 bytes)
32-bits registers (4 bytes)
32-bits registers (4 bytes)
32-bits registers (4 bytes)
32-bits registers (4 bytes)
32-bits registers (4 bytes)
32-bits registers (4 bytes)
64-bits registers (8 bytes)
8-bits registers (1 byte)
32-bits registers (4 bytes)
16-bits registers (2 bytes)
64-bits registers (8 bytes)
8-bits registers (1 byte)
32-bits registers (4 bytes)
16-bits registers (2 bytes)
64-bits registers (8 bytes)
8-bits registers (1 byte)
32-bits registers (4 bytes)
16-bits registers (2 bytes)
64-bits registers (8 bytes)
8-bits registers (1 byte)
32-bits registers (4 bytes)
16-bits registers (2 bytes)
64-bits registers (8 bytes)
8-bits registers (1 byte)
32-bits registers (4 bytes)
16-bits registers (2 bytes)
64-bits registers (8 bytes)
8-bits registers (1 byte)
32-bits registers (4 bytes)
16-bits registers (2 bytes)
64-bits registers (8 bytes)
8-bits registers (1 byte)
32-bits registers (4 bytes)
16-bits registers (2 bytes)
64-bits registers (8 bytes)
8-bits registers (1 byte)
32-bits registers (4 bytes)
16-bits registers (2 bytes)
64-bits registers (8 bytes)
64-bits registers (8 bytes)
64-bits registers (8 bytes)
64-bits registers (8 bytes)
64-bits registers (8 bytes)
64-bits registers (8 bytes)
64-bits registers (8 bytes)
64-bits registers (8 bytes)
16-bits registers (2 bytes)
8-bits registers (1 byte)
16-bits registers (2 bytes)
8-bits registers (1 byte)

Functions

Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands
Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands
Call label
Call address
sign extend EAX into EDX::EAX
Conditional move of 4-bytes operands
Conditional move of 8-bytes operands
Conditional move of 2-bytes operands
Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands
Add comment to Assembly (should not contain de line break!)
sign extend RAX into RDX::RAX
Instructions on 1-bytes operands
Instructions on 4-bytes operands
Instructions on 8-bytes operands
Instructions on 2-bytes operands
Move address of label in register (implementation is OS dependant)
Instructions on 4-bytes operands
Instructions on 8-bytes operands
Instructions on 4-bytes operands
Instructions on 8-bytes operands
Immediate operand for 8-bits instructions
Immediate operand for 32-bits instructions
Operands Immediate operand for 64-bits instructions
Immediate operand for 16-bits instructions
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands
Instructions on 1-bytes operands
Instructions on 4-bytes operands
Instructions on 8-bytes operands
Instructions on 2-bytes operands
Conditional jump if above equal
Conditional jump
Jump to label
Jump to address
Conditional jump if not zero
Conditional jump if zero
Place a label
Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Leave instruction
Instructions between 2-bytes operands
Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands
Instructions on 1-bytes operands
Instructions on 4-bytes operands
Instructions on 8-bytes operands
Instructions on 2-bytes operands
Convert str to label name
nop instruction (does nothing)
Instructions on 1-bytes operands
Instructions on 4-bytes operands
Instructions on 8-bytes operands
Instructions on 2-bytes operands
Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands
Pop 8-bytes from stack
Push 8-bytes on stack
Equivalent to popq %rip
Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands
Conditionnal set
Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands
Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands
Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands
Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands
Instructions between 1-bytes operands
Instructions between 4-bytes operands
Instructions between 8-bytes operands
Instructions between 2-bytes operands