Maybe you can help, because i am flabbergasted by this.
i have the following code for CPUID:
Code: Select all
inline void cpuid(int32u fnc, int32u * regs) {
asm volatile ("cpuid;"
: "=a"(regs[0]), "=b"(regs[1]), "=c"(regs[2]), "=d"(regs[3])
: "a"(fnc)
);
}
Code: Select all
int32u regs[4];
cpuid(1,regs);
f_capabilities = regs[2];
Code: Select all
170: 53 push %rbx
171: b8 01 00 00 00 mov $0x1,%eax
176: 0f a2 cpuid
178: 89 4c 24 f8 mov %ecx,0xfffffffffffffff8(%rsp)
17c: 89 c8 mov %ecx,%eax
17e: 5b pop %rbx
17f: 48 89 07 mov %rax,(%rdi)
how can i get rid of the stupid 'mov %ecx,0xfffffffffffffff8(%rsp)' statement as it is not needed at all.
edit:
changing the implementation of cpuid fixed everything way less generated code:
Code: Select all
nline void cpuid(int32u fnc, int32u eax, int32u ebx, int32u ecx, int32u edx) {
asm volatile ("cpuid;"
: "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
: "a"(fnc)
);
}