hellisher
Mar 24th, 2008, 05:40 PM
Hello, been looking at tutorial on the web about using local variables with AT&T inline assembly in gcc. And i cant figure it out how to use the output/input/clobber operators..
The code below works fine when declaring the variables as globals. But i would prefer them as local. So if anyone can fix the below code to work with local variable would hopefully help me draw a logical conclusion to get me understand how to use local variable.
Cheers!
unsigned int cpu_info, cpu_sse3, cpu_info_amd;
asm
(
"movl $0x1, %eax\n"
"cpuid\n"
"movl %edx, _cpu_info\n" //test
"movl %ecx, _cpu_sse3\n"
"movl $0x80000001, %eax\n"
"cpuid\n"
"movl %edx, _cpu_info_amd\n"
);
The code below works fine when declaring the variables as globals. But i would prefer them as local. So if anyone can fix the below code to work with local variable would hopefully help me draw a logical conclusion to get me understand how to use local variable.
Cheers!
unsigned int cpu_info, cpu_sse3, cpu_info_amd;
asm
(
"movl $0x1, %eax\n"
"cpuid\n"
"movl %edx, _cpu_info\n" //test
"movl %ecx, _cpu_sse3\n"
"movl $0x80000001, %eax\n"
"cpuid\n"
"movl %edx, _cpu_info_amd\n"
);