I am trying to use inline assembly in Rust. The code I'm including is supposed to query Intel CPU capabilities and right now I just want to get the ebx
register state after the system call.
Using an nightly build of Rust compiler (required to use the asm!
macro) the code compiles. When I run the program, I get random values for the ebx
register and a segmentation fault. I'm pretty sure my asm!
macro syntax is just wrong but the documentation of this feature is very weak. Does anyone have any pointers as to what I could improve?
#![feature(asm)]
fn main() {
let result: u32;
unsafe {
asm!("mov eax, 07H;
mov ecx, 0;
cpuid;"
: "={ebx}"(result)
:
: "eax, ebx, ecx, edx"
: "intel"
)
}
println!("ebx from cpuid is {}", result);
}