From: Vic Newsgroups: comp.os.msdos.djgpp Subject: Re: OT: how can I declare and use struct with as.exe ? Date: Sun, 24 Jan 1999 12:49:42 -0500 Organization: Communications Accessibles Montreal, Quebec Canada Lines: 54 Message-ID: <36AB5D36.389B@cam.org> References: <789639$att$1 AT nslave1 DOT tin DOT it> <78e00r$msl$1 AT news DOT luth DOT se> NNTP-Posting-Host: dialup-965.hip.cam.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (Win95; I) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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.