I am writing a simple C ++ program that contains some asm instructions.
void call(){
__asm__("mov -0x10(%rbp),%eax;"
"add $0x10,%eax;"
"mov %eax,%edx;"
"shr $0x1f,%edx;"
"add %edx,%eax;"
"sar %eax;"
"add %eax,-0x4(%rbp);"
"mov $0x4c,%eax;"
"mov -0x8(%rbp),%eax;"
"add %eax,%eax;"
"sub -0x4(%rbp),%eax;"
"add %eax,-0xc(%rbp);");
}
However, from the execution behavior, I realized that the registers controlled by this asm object are actually used by other variables in the function.
Is there a way to call the compiler to highlight the registers used in the asm tag and make sure they are not running?
OS: Linux Compiler: g ++
Non-compiler approaches are also welcome.
source
share