Sender: nate AT cartsys DOT com Message-ID: <36F2F6E6.874206F7@cartsys.com> Date: Fri, 19 Mar 1999 17:16:22 -0800 From: Nate Eldredge X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.3 i586) MIME-Version: 1.0 To: mert0407 AT sable DOT ox DOT ac DOT uk, djgpp AT delorie DOT com Subject: Re: Some assembly questions References: <199903200102 DOT RAA29841 AT unixbox DOT bitbucket> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com George Foot wrote: > > On 18 Mar 99 at 17:24, Nate Eldredge wrote: > > > Alternatively, if you want to leave GCC out of the function entirely, > > you can use `asm' at the top level. For instance: > > > > static int bar(void); > > > > asm("_bar: movl $42, %eax; ret"); > > Doesn't this create segment problems, i.e. code is meant to be > in a text segment, data in a data segment? ISTR running into a > problem with this once, but it may have been on RSXNTDJ, not > djgpp. The problem with just being explicit and forcing it > with `.code' is that I think gcc might not notice you doing > this, and so it can't put it back afterwards itself -- so again > you end up guessing which segment it left it in. Hmm... you're right. It looks like GCC generates .text and .data before definitions of functions and variables, which should allow explicit .code, but it's probably bad to count on. > IMHO the safest thing is to put such assembly code in a > separate .S or .s file -- I can't see any real disadvantages > with this, but maybe wiser people can or I'm worrying about > nothing. It means that symbols shared between the two must be global, which causes some namespace pollution if you're writing a library, but it's probably not significant if you use underscores appropriately. -- Nate Eldredge nate AT cartsys DOT com