This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc inline assembler - filling a structure
- From: Ian Lance Taylor <iant at google dot com>
- To: Vincent De Groote <list dot encelade at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 02 Apr 2009 14:42:43 -0700
- Subject: Re: gcc inline assembler - filling a structure
- References: <1400d6020904020923t5d24d7b4p22d3262dc33fbcc4@mail.gmail.com>
Vincent De Groote <list.encelade@gmail.com> writes:
> I would like to execute the cpuid instruction on a x86
>
> So I declared
>
> typedef unsigned long int register_t;
>
> struct response_t {
> Â register_t eax;
> Â register_t ebx;
> ÂÂ register_t ecx;
> ÂÂ register_t edx;
> };
>
> void cpuid ( register_t command, struct response_t * response )Â {
>
> ...
>
> }
>
> How can I, in assembler, assign the value of a register (for example
> ebx) to the response->ebx field ?
The gcc sources call cpuid themselves. Look at gcc/config/i386/cpuid.h
for examples.
Ian