Mail Archives: djgpp/1999/01/24/14:06:54
Martin Str|mberg wrote:
>
> Wolfy (k6 AT lycosmail DOT com) wrote:
> : I know how to declare and use struct with masm but with gnu as I am in
> : trouble; can anyone help me ?
>
> Declare a struct in C, compile with "-S" and look at the output?
doesn`t help much. the following C code
struct t
{
int a;
long b;
long long c;
};
struct t out_main;
main()
{
out_main.a=5;
out_main.b=654;
out_main.c=13466;
}
gives this:
.file "a.c"
gcc2_compiled.:
___gnu_compiled_c:
.comm _out_main,16
.text
.p2align 2
.globl _main
_main:
pushl %ebp
movl %esp,%ebp
movl $5,_out_main
movl $654,_out_main+4
movl $13466,_out_main+8
movl $0,_out_main+12
leave
ret
The way it declares a struct, only when it is global (if it`s in a
fuction it uses the stack) is by using
.comm name,length:
.comm _out_main,16 declares an out_main struct 16 bytes long.
you access the members by their offset in the struct.
- Raw text -