Octocontrabass wrote:
ggodw000 wrote:
I wondered if there is a way to fit all the series of instructions in one asm() call making it atomic.
Of course there is. You can put as many instructions in a single asm() call as you want.
But, for CPUID, you don't need more than one instruction. If you use the correct input and output constraints, GCC will automatically generate the instructions to load EAX before CPUID and read the outputs afterwards.
In fact, I already showed you one possible way to write it.
Code:
asm( "cpuid" : "=a"(eax_value), "=b"(ebx_value), "=c"(ecx_value), "=d"(edx_value) : "a"(leaf) );
Reviving the long lost thread, looking at extended asm section of this doc:
https://gcc.gnu.org/onlinedocs/gcc/Exte ... tended-Asm, it looks like it fits into the call convention:
Code:
asm [volatile] ( AssemblerTemplate
: OutputOperands
[ : InputOperands
[ : Clobbers ] ])
With that, it appears cpuid is
Code:
assembler template
, output operands are
Code:
"=a"(eax_value), "=b"(ebx_value), "=c"(ecx_value), "=d"(edx_value)
: and inputs operands are "
Code:
a"(leaf)
, correct?
Once executed, the variable (possibly long int) a, b, c and d will hold the result of CPUID which can safely be used.
thx.