lkml.org 
[lkml]   [2011]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
Subjecta problem in cpucheck.c on x86
From
Hi,all:

In arch/x86/boot/cpucheck.c
static int has_eflag(u32 mask)
{
u32 f0, f1;

asm("pushfl ; "
"pushfl ; "
"popl %0 ; "
"movl %0,%1 ; "
"xorl %2,%1 ; "
"pushl %1 ; "
"popfl ; "
"pushfl ; "
"popl %1 ; "
"popfl"
: "=&r" (f0), "=&r" (f1)
: "ri" (mask));

return !!((f0^f1) & mask);
}

"pushl %1 ; "
"popfl ; "
"pushfl ; "
"popl %1 ; "
I don't know what does above 4 instructions do, and I rewirte it like this:

static int has_eflag(u32 mask)
{
u32 f0;

asm("pushfl ; "
"pushfl ; "
"popl %0 ; "
"popfl"
: "=&r" (f0));

return ~f0 & mask;

}
It works well, and I just want to know is there some special meanings
of the 4 instructions?
"pushl %1 ; "
"popfl ; "
"pushfl ; "
"popl %1 ; "


\
 
 \ /
  Last update: 2011-12-15 08:55    [W:0.032 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site