In AT&T syntax you can do something like asm(“mov %%eax, %0nt”:”=r” (a[0])); but not in intel syntax.
I want to translate this AT&T syntax to intel syntax, it gets the cpu brand name and print it.
int a[10];
void brandString(int eaxValues)
{
if (eaxValues == 1) {
__asm__("mov $0x80000002 , %eaxnt");
}
else if (eaxValues == 2) {
__asm__("mov $0x80000003 , %eaxnt");
}
else if (eaxValues == 3) {
__asm__("mov $0x80000004 , %eaxnt");
}
__asm__("cpuidnt");
__asm__("mov %%eax, %0nt":"=r" (a[0]));
__asm__("mov %%ebx, %0nt":"=r" (a[1]));
__asm__("mov %%ecx, %0nt":"=r" (a[2]));
__asm__("mov %%edx, %0nt":"=r" (a[3]));
printf("%s", &a[0]);
}
void getCpuID()
{
__asm__("xor %eax , %eaxnt");
__asm__("xor %ebx , %ebxnt");
__asm__("xor %ecx , %ecxnt");
__asm__("xor %edx , %edxnt");
printf("Brand string is ");
brandString(1);
brandString(2);
brandString(3);
printf("n");
}
int main(){
getCpuID();
}
and, so far, I have done:
char a[10];
void brandString(int eaxValues)
{
if (eaxValues == 1) {
__asm {
mov eax, 0x80000002
}
}
else if (eaxValues == 2) {
__asm {
mov eax, 0x80000003
}
}
else if (eaxValues == 3) {
__asm {
mov eax, 0x80000004
}
}
__asm {
cpuid
mov a[0], eax
mov a[1], ebx
mov a[2], ecx
mov a[3], edx
}
printf("%s", &a[0]);
}
void getCpuID() {
__asm {
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
}
printf("Brand string is ");
brandString(1);
brandString(2);
brandString(3);
printf("n");
}
but obviously you can not do mov a[0], eax so I’m stuck, I do not know how to do it.