Assembler toolkit: encoding and decoding of various architectures
Rust
46
62 commits
updated Sep 16, 2026
#![no_std] assembler library for x86/x64, RISC-V (rv32/rv64), and AArch64, built around an
AsmJit-style instruction-database model. The x86 and
AArch64 instruction databases and APIs are direct ports of AsmJit's; credit for that design
goes to the AsmJit authors.
MSRV: Rust 1.85 (edition 2024).
use asmkit::{Arch, CodeBuffer, Environment, JitAllocator};
use asmkit::x86::*;
let mut buf = CodeBuffer::new(Environment::new(Arch::X64));
{
let mut asm = Assembler::new(&mut buf);
asm.mov(RAX, 5);
asm.add(RAX, 37);
asm.ret();
}
let result = buf.finish().expect("assembly failed");
let mut jit = JitAllocator::new(Default::default());
let span = result.allocate(&mut jit).expect("failed to allocate JIT code");
let f: extern "C" fn() -> u64 = unsafe { std::mem::transmute(span.rx()) };
assert_eq!(f(), 42);
More examples live in examples/: factorial.rs (x86/RISC-V/AArch64 + JIT + disassembly),
reloc.rs (relocations), a64.rs (AArch64), patch.rs (JSC-style patching).
asm.mov(RAX, 42)), generated from the instruction
database, with a shared emit_n entry point underneathquery_rw_infoBuilder + InstSink for recording, inspecting, and replaying instructionsSection + Linker)See PORTING.md for backend structure and meta/README.md for the code-generation pipeline.
x86, riscv, aarch64: per-architecture backends (enabled by default)jit: JIT allocator, for allocating and executing generated codeasmkit itself is MIT OR Apache-2.0.
_emit/encoder logic are
ported from AsmJit. Derived files carry the Zlib notice as required.See meta/README.md for the exact pins and licensing obligations of generated files.
Rust
95.1%
Python
4.9%
Assembler toolkit: encoding and decoding of various architectures
Rust
46
62 commits
updated Sep 16, 2026
#![no_std] assembler library for x86/x64, RISC-V (rv32/rv64), and AArch64, built around an
AsmJit-style instruction-database model. The x86 and
AArch64 instruction databases and APIs are direct ports of AsmJit's; credit for that design
goes to the AsmJit authors.
MSRV: Rust 1.85 (edition 2024).
use asmkit::{Arch, CodeBuffer, Environment, JitAllocator};
use asmkit::x86::*;
let mut buf = CodeBuffer::new(Environment::new(Arch::X64));
{
let mut asm = Assembler::new(&mut buf);
asm.mov(RAX, 5);
asm.add(RAX, 37);
asm.ret();
}
let result = buf.finish().expect("assembly failed");
let mut jit = JitAllocator::new(Default::default());
let span = result.allocate(&mut jit).expect("failed to allocate JIT code");
let f: extern "C" fn() -> u64 = unsafe { std::mem::transmute(span.rx()) };
assert_eq!(f(), 42);
More examples live in examples/: factorial.rs (x86/RISC-V/AArch64 + JIT + disassembly),
reloc.rs (relocations), a64.rs (AArch64), patch.rs (JSC-style patching).
asm.mov(RAX, 42)), generated from the instruction
database, with a shared emit_n entry point underneathquery_rw_infoBuilder + InstSink for recording, inspecting, and replaying instructionsSection + Linker)See PORTING.md for backend structure and meta/README.md for the code-generation pipeline.
x86, riscv, aarch64: per-architecture backends (enabled by default)jit: JIT allocator, for allocating and executing generated codeasmkit itself is MIT OR Apache-2.0.
_emit/encoder logic are
ported from AsmJit. Derived files carry the Zlib notice as required.See meta/README.md for the exact pins and licensing obligations of generated files.
Rust
95.1%
Python
4.9%