64,654
社区成员
发帖
与我相关
我的任务
分享
#define DWORD unsigned int
bool has_eflag(const DWORD mask)
{
DWORD f0, f1;
_asm
{
pushf; // GCC: pushfl 标志寄存器值进栈,对应 VC++: pushf
pushf;
pop f0 ; // GCC: popl %0 占位符,按下面 : 后的顺序指定,即 f0
//movl f0, f1; // GCC 使用 AT&T 汇编语法,源在左
// VC++使用 Intel 汇编语法,源在右
mov eax, f0; // VC++内嵌汇编中,mov指令的参数不内全为内存变量
mov f1, eax;
//xorl %2,%1
mov eax, f1;
xor eax, mask;
mov f1, eax;
push f1;
popf; // GCC: popfl 标志寄存器值出栈,对应 VC++: popf
pushf;
pop f1;
popf;
}
return ((f0^f1) & mask);
}
void main(int argc, char** argv)
{
bool is_support = has_eflag((DWORD)0x00040000);
}