delorie.com/archives/browse.cgi | search |
From: | "clusty" <clusty AT poland DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: inline assembly and c struct |
Date: | Thu, 1 Feb 2001 17:51:38 +0100 |
Organization: | news.onet.pl |
Lines: | 56 |
Sender: | [clusty.friko4.onet.pl]@ppp-12.cuprum.com.pl |
Message-ID: | <95f5mk$cug$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> |
NNTP-Posting-Host: | ppp-12.cuprum.com.pl |
X-Trace: | news.onet.pl 981146132 13264 195.117.119.140 (2 Feb 2001 20:35:32 GMT) |
X-Complaints-To: | abuse AT onet DOT pl |
NNTP-Posting-Date: | 2 Feb 2001 20:35:32 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 |
In article news:959619$f3k$1 AT murdoch DOT acc DOT Virginia DOT EDU , "Clark L. Coleman" clc5q AT cobra DOT cs DOT Virginia DOT EDU>... wrote: > In article <957ghs$kl$1 AT news DOT onet DOT pl>, aiur9 <aiur9 AT kki DOT net DOT pl> wrote: > >How can I get a structure member offset from inline assembly > > Who says it has to be assembly? Why not just take the address of > fields in C, using the "&" operator? > > struct foo ( > int x; > int y; > } > > struct foo bar; > > long y_offset = &(bar.y) - &bar; > > Can't you make something like that work? > > > > no 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 <y_offset>(%%eax),%%edx ...) I would have to write asm(... mov _y_offset,%%eax mov <y_offset>(%%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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |