26. December 2024, 19:59
#include <iostream>#include <ostream>int main(){ char cpuidstring[48]; asm ("mov $0x80000002,%eax;" "cpuid;" "mov %eax,(cpuidstring)"); /* hier scheint was nicht zu stimmen */ std::cout << cpuidstring;}
cpuid.cpp:(.text+0x12): undefined reference to `cpuidstring'collect2: ld returned 1 exit status
asm ("mov $0x80000002,%eax;" "cpuid;" "mov %eax":"m"(cpuidstring));
asm("mov $0x80000002, %%eax;" "cpuid; " : "=a" (cpuidstring[0]), "=b" (cpuidstring[4]), "=c" (cpuidstring[8], "=d" (cpuidstring[12]));
cpuid.cpp: In function ‘int main()’:cpuid.cpp:10: error: invalid 'asm': operand number missing after %-letter
Meine Variante funktioniert, wenn man die fehlende Klammer ergänzt.
asm("mov %%eax,%0" : "=m" (cpuidstring[0]));