Tutorial by Examples

Inline assembly will only be supported in nightly versions of Rust until it is stabilized. To enable usage of the asm! macro, use the following feature attribute at the top of the main file (a feature gate): #![feature(asm)] Then use the asm! macro in any unsafe block: fn do_nothing() { u...
Use conditional compilation to ensure that code only compiles for the intended instruction set (such as x86). Otherwise code could become invalid if the program is compiled for another architecture, such as ARM processors. #![feature(asm)] // Any valid x86 code is valid for x86_64 as well. Be ca...
#![feature(asm)] #[cfg(any(target_arch="x86", target_arch="x86_64"))] fn subtract(first: i32, second: i32) { unsafe { // Output values must either be unassigned (let result;) or mutable. let result: i32; // Each value that you pass in will b...

Page 1 of 1