Ask your own question, for FREE!
Mathematics 8 Online
OpenStudy (anonymous):

What does the following C code do? void id(unsigned info, unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx) { *eax = info; asm volatile( "mov %%ebx, %%edi;" "cpuid;" "mov %%ebx, %%esi;" "mov %%edi, %%ebx;" :"+a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx) : :"edi"); }

OpenStudy (anonymous):

that look like things I see in assembly language

OpenStudy (anonymous):

Yeah C often supports inline assembly

OpenStudy (anonymous):

esi and edi are used often for memeory to memory transfer

OpenStudy (anonymous):

I have 0% knowledge of assembly, so I don't know how that code ended up there :(

OpenStudy (anonymous):

from what I can see , you are just moving data around the register

OpenStudy (anonymous):

what's the cpuid statement do?

OpenStudy (anonymous):

figure out information about processor , I suppose

OpenStudy (anonymous):

http://ideone.com/cPBS3

OpenStudy (anonymous):

typical output

OpenStudy (anonymous):

almost meaningless to me though :(

OpenStudy (anonymous):

If you haven't http://en.wikipedia.org/wiki/CPUID

OpenStudy (anonymous):

everything makes sense now

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!