Skip to content

nicolasbauw/rust-asm-ffi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using FFI to Call Assembly Functions from Rust

This is a mini-howto for people wanting to call assembly functions from their Rust code.

  • assembly is not inline assembly, but a separate .s source file
  • just replace mnemonics to fit your target CPU (here, three examples for armv6, aarch64 and riscv64)

Cross-compilation for Raspberry Pi 1B:

rustup target add arm-unknown-linux-musleabihf  
brew install arm-linux-gnueabihf-binutils  
cargo build --target="arm-unknown-linux-musleabihf" --release

Linux users could replace musleabihf by gnueabihf.