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:Octocontrabass wrote:Of course there is. You can put as many instructions in a single asm() call as you want.ggodw000 wrote:I wondered if there is a way to fit all the series of instructions in one asm() call making it atomic.
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: Select all
asm( "cpuid" : "=a"(eax_value), "=b"(ebx_value), "=c"(ecx_value), "=d"(edx_value) : "a"(leaf) );
Code: Select all
asm [volatile] ( AssemblerTemplate
: OutputOperands
[ : InputOperands
[ : Clobbers ] ])
Code: Select all
assembler template
Code: Select all
"=a"(eax_value), "=b"(ebx_value), "=c"(ecx_value), "=d"(edx_value)
Code: Select all
a"(leaf)
Once executed, the variable (possibly long int) a, b, c and d will hold the result of CPUID which can safely be used.
thx.