www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/30/00:48:54

From: George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Inline asm
Date: 30 Nov 1997 04:46:54 GMT
Organization: Oxford University, England
Lines: 25
Message-ID: <65qr3u$koq$2@news.ox.ac.uk>
References: <347A974A DOT 91C9FBC5 AT mail DOT htk DOT fi>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Tue, 25 Nov 1997 11:15:54 +0200 in comp.os.msdos.djgpp Henri Ossi <henri DOT ossi AT mail DOT htk DOT fi> wrote:

: A quick question.
: Do I have to push and pop all the registers, which I use in inline asm?
: What about return values?
: Can I leave a number in ax to tell the calling function, if there was
: any errors (etc)?
: Or do I have to use a variable to store the number and then use
: "return"?

I suggest you refer to Brennan's Guide to AT&T Inline Assembler:

http://brennan.home.ml.org/djgpp/djgpp_asm.html

In basic assembler you need to preserve all registers.  In extended
assembler you can clobber them if you like, but you must tell gcc that
you're doing it -- see Brennan's section on extended assembler, or the
documentation for gcc.

To return a value I think you should go via a variable -- I don't
think gcc guarrantees that it won't change the value of %ax.  The
simplest way to do this is, again, through extended assembler.

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019