delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/12/19/17:15:07

From: "Lars O. Hansen" <lars DOT o DOT hansen AT gmx DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: inline assembly syntax for accessing variables ?
Date: Thu, 19 Dec 2002 23:03:34 +0100
Organization: 1&1 Internet AG
Lines: 44
Message-ID: <attfnk$u3j$1@news.online.de>
References: <atses9$d2v$1 AT news DOT online DOT de> <atshbq$rji$1 AT antares DOT lu DOT erisoft DOT se> <atshdq$rji$2 AT antares DOT lu DOT erisoft DOT se>
NNTP-Posting-Host: p5083822a.dip0.t-ipconnect.de
X-Trace: news.online.de 1040335412 30835 80.131.130.42 (19 Dec 2002 22:03:32 GMT)
X-Complaints-To: abuse AT online DOT de
NNTP-Posting-Date: 19 Dec 2002 22:03:32 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> Martin Stromberg (eplmst AT lu DOT erisoft DOT se) wrote:
> : : int a,b;
> : : a=4;
> : : b=8;
> : : asm ADD b,a
>
> : : this should result in b being 12 (a+b);
>
> : asm ("add %1, %0"
> :     : "=r" (b)
> :     : "r" (a)
> :      );
>
> I forgot to say that this is untested code.


thanks; with this and http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html I think
i understand.


still, I wanted to use the XCHG instruction, so is one or both of the used variables an output
register candidate ("=r")?

Or is using XCHG for variable swapping instead of direct translation of
int tmp;
tmp=a;
a=b;
b=tmp;
part of djgpps optimization routines?

Or is there a predefined macro/function for "swapping" in djgpp?

Or is XCHG a "mnemonic macro" itself or are there reasons not to use XCHG or pay speacial attention
to sth. when using it?


btw. links in the assembly section in djgpps FAQ as well as on the documentation site need updating!
(so if someone who can do sth. about that reads this...   (ch. 17.1  and
http://www.delorie.com/djgpp/doc ... guide by Avly))


thanks for any comments, Lars


- Raw text -


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