Skip to main content

Crate asm_rs_macros

Crate asm_rs_macros 

Source
Expand description

Compile-time assembly proc-macros for asm-rs.

Provides the asm_bytes! macro that assembles source text at compile time, producing a &'static [u8] constant with zero runtime overhead.

§Usage

use asm_rs_macros::asm_bytes;

// x86-64 shellcode assembled at compile time
const SHELLCODE: &[u8] = asm_bytes!(x86_64, "mov rax, 1\nret");

// AArch64
const A64_CODE: &[u8] = asm_bytes!(aarch64, "add x0, x1, x2\nret");

// ARM32
const ARM_CODE: &[u8] = asm_bytes!(arm, "add r0, r1, r2\nbx lr");

// RISC-V 64-bit
const RV_CODE: &[u8] = asm_bytes!(rv64, "add a0, a1, a2\nret");

Macros§

asm_array
Assemble source text at compile time, producing a fixed-size array [u8; N].
asm_bytes
Assemble source text at compile time, producing a &'static [u8] byte slice.