Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带内联汇编的Rust中ebx寄存器的读取值(“rbx由LLVM内部使用,不能用作内联asm的操作数”)_Rust - Fatal编程技术网

带内联汇编的Rust中ebx寄存器的读取值(“rbx由LLVM内部使用,不能用作内联asm的操作数”)

带内联汇编的Rust中ebx寄存器的读取值(“rbx由LLVM内部使用,不能用作内联asm的操作数”),rust,Rust,我正在编写Rust代码,需要获取当前存储在“ebx”寄存器(x86)中的值 我的代码[0]如下所示: #![feature(asm)] fn main() { let ebx: u32; unsafe { asm!("", out("ebx") ebx) }; println!("current value of register ebx is: {}", ebx); } rustc 1.54.0-night

我正在编写Rust代码,需要获取当前存储在“ebx”寄存器(x86)中的值

我的代码[0]如下所示:

#![feature(asm)]

fn main() {
    let ebx: u32;
    unsafe { asm!("", out("ebx") ebx) };
    println!("current value of register ebx is: {}", ebx);
}
rustc 1.54.0-nightly中的错误代码为:

invalid register `ebx`: rbx is used internally by LLVM and cannot be used as an operand for inline asm
我发现的唯一可行方法是传统方法:

unsafe {
    llvm_asm!("" : "={ebx}"(ebx) : :);
}
是否有办法通过新的
asm实现所需的功能

PS:由于我的研究,我遇到了这个:。但它仍然不能提供一个简单的解决方案


[0]

您可以将其移动到另一个寄存器

#![功能(asm)]
fn main(){
设ebx:u32;
不安全的{asm!(“mov{:e},ebx”,out(reg)ebx)};
println!(“寄存器ebx的当前值为:{}”,ebx);
}