The problem with that is, whenever I try to compile it...
Code: Select all
gcc -nostdlib -nostdinc -fno-builtin -fno-stack-protector -I../include -O0 -c cpuid.c -o cpuid.o
cpuid.c: In function ‘cpuid_print_features’:
cpuid.c:32: error: can't find a register in class ‘Q_REGS’ while reloading ‘asm’
cpuid.c:32: error: ‘asm’ operand has impossible constraints
Here's the code for cpuid.c:
Code: Select all
#include "video.h"
#include "common.h"
void cpuid_print_features(){
u8int fpu;
u8int vme;
u8int de;
u8int pse;
u8int tsc;
u8int msr;
u8int pae;
u8int mce;
u8int cx8;
u8int apic;
//Bit 10 is reserved
u8int sep;
u8int mtrr;
u8int pge;
u8int mca;
u8int cmov;
u8int pat;
u8int pse36;
//Bits 18 to 22 not used for this purpose
u8int mmx;
u8int fxsr;
u8int sse;
u8int sse2;
u8int sse3;
u8int sse4_1;
u8int sse4_2;
printf("[INFO]-CPU Features: (");
__asm__ volatile(".intel_syntax noprefix \
mov eax, 1 \
cpuid \
and edx, 1 \
cmp edx, 0 \
jne fpu \
pop edx \
\
push edx \
shr edx, 1 \
and edx, 1 \
cmp edx, 0 \
jne vme \
pop edx \
\
push edx \
shr edx, 2 \
and edx, 1 \
cmp edx, 0 \
jne de \
pop edx \
\
push edx \
shr edx, 3 \
and edx, 1 \
cmp edx, 0 \
jne pse \
pop edx \
\
push edx \
shr edx, 4 \
and edx, 1 \
cmp edx, 0 \
jne tsc \
pop edx \
\
push edx \
shr edx, 5 \
and edx, 1 \
cmp edx, 0 \
jne msr \
pop edx \
\
push edx \
shr edx, 6 \
and edx, 1 \
cmp edx, 0 \
jne pae \
pop edx \
\
push edx \
shr edx, 7 \
and edx, 1 \
cmp edx, 0 \
jne mce \
pop edx \
\
push edx \
shr edx, 8 \
and edx, 1 \
cmp edx, 0 \
jne cx8 \
pop edx \
\
push edx \
shr edx, 9 \
and edx, 1 \
cmp edx, 0 \
jne apic \
pop edx \
\
push edx \
shr edx, 11 \
and edx, 1 \
cmp edx, 0 \
jne sep \
pop edx \
\
push edx \
shr edx, 12 \
and edx, 1 \
cmp edx, 0 \
jne mtrr \
pop edx \
\
push edx \
shr edx, 13 \
and edx, 1 \
cmp edx, 0 \
jne pge \
pop edx \
\
push edx \
shr edx, 14 \
and edx, 1 \
cmp edx, 0 \
jne mca \
pop edx \
\
push edx \
shr edx, 15 \
and edx, 1 \
cmp edx, 0 \
jne cmov \
pop edx \
\
push edx \
shr edx, 16 \
and edx, 1 \
cmp edx, 0 \
jne pat \
pop edx \
\
push edx \
shr edx, 17 \
and edx, 1 \
cmp edx, 0 \
jne pse36 \
pop edx \
\
push edx \
shr edx, 23 \
and edx, 1 \
cmp edx, 0 \
jne mmx \
pop edx \
\
push edx \
shr edx, 24 \
and edx, 1 \
cmp edx, 0 \
jne fxsr \
pop edx \
\
fpu:\
mov %0, 1\
\
vme:\
mov %1, 1\
\
de:\
mov %2, 1\
\
pse:\
mov %3, 1\
\
tsc:\
mov %4, 1\
\
msr:\
mov %5, 1\
\
pae:\
mov %6, 1\
\
mce:\
mov %7, 1\
\
cx8:\
mov %8, 1\
\
apic:\
mov %9, 1\
\
sep:\
mov %10, 1\
\
mtrr:\
mov %11, 1\
\
pge:\
mov %12, 1\
\
mca:\
mov %13, 1\
\
cmov:\
mov %14, 1\
\
pat:\
mov %15, 1\
\
pse36:\
mov %16, 1\
\
mmx:\
mov %17, 1\
\
fxsr:\
mov %18, 1\
\
sse:\
mov %19, 1\
\
sse2:\
mov %20, 1\
\
sse3:\
mov %21, 1\
\
sse4_1:\
mov %22, 1\
\
sse4_2:\
mov %23, 1\
\
.att_syntax prefix\
" : "=r"(fpu), "=r"(vme), "=r"(de), "=r"(pse), "=r"(tsc), "=r"(msr), "=r"(pae), "=r"(mce), "=r"(cx8),
"=r"(apic), "=r"(sep), "=r"(mtrr), "=r"(pge), "=r"(mca), "=r"(cmov), "=r"(pat), "=r"(pse36), "=r"(mmx),
"=r"(fxsr), "=r"(sse), "=r"(sse2), "=r"(sse3), "=r"(sse4_1), "=r"(sse4_2) : : "edx" );
if(fpu == 1){
printf(" FPU ");
}
printf(" )");
}
Any help would be appreciated.
EDIT: Adding a "%" before "edx" in the clobbered registers changes nothing.