From: "clusty" Newsgroups: comp.os.msdos.djgpp Subject: Re: inline assembly and c struct Date: Thu, 8 Feb 2001 19:55:05 +0100 Organization: news.onet.pl Lines: 58 Sender: [clusty.friko4.onet.pl]@ppp-40.cuprum.com.pl Message-ID: <95uq97$5vf$1@news.onet.pl> References: <957ghs$kl$1 AT news DOT onet DOT pl> <959619$f3k$1 AT murdoch DOT acc DOT Virginia DOT EDU> <95f5mk$cug$1 AT news DOT onet DOT pl> <83lmro7fs6 DOT fsf AT mercury DOT st DOT hmc DOT edu> NNTP-Posting-Host: ppp-40.cuprum.com.pl X-Trace: news.onet.pl 981658727 6127 195.117.119.168 (8 Feb 2001 18:58:47 GMT) X-Complaints-To: abuse AT onet DOT pl NNTP-Posting-Date: 8 Feb 2001 18:58:47 GMT X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MSMail-Priority: Normal X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com ----- Original Message ----- From: "Nate Eldredge" Newsgroups: comp.os.msdos.djgpp Sent: Saturday, February 03, 2001 1:48 AM Subject: Re: inline assembly and c struct > "clusty" writes: > > > I want compiler to print y_offset in my piece of inline assembly code. > > In above example i will get y_offset in variable and i.e instead of writing > > > > asm(... > > mov (%%eax),%%edx > > ...) > > > > I would have to write > > > > asm(... > > mov _y_offset,%%eax > > mov (%%eax),%%edx > > ...) > > > > see the difference > > > > i tried something like this > > > > asm(... > > "%0(%%eax),%%edx \n" > > ... > > ::"m"(*(&some_struct.member-&some_struct)) /*this thing gives*/ > > /*variable at offset of*/ > > /*offset of member */ > > ); > > but it won't work > > I think what you want is (untested) > > asm("movl %0(%%eax),%%edx" > :: "i" (offsetof(some_struct, member)) > ); > > The "i" constraint specifies that this operand is an immediate value, > and hence will be inserted as a constant. > > Note that you should always use the standard `offsetof' macro instead > of trying to calculate the offseet yourself. > ok but i wont be able to do that > > "%0(%%eax),%%edx \n" because the constraint will be "i". The constraint must be "m" or "o" in order to above line to compile.