delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/12/19/08:45:06.1

From: eplmst AT lu DOT erisoft DOT se (Martin Stromberg)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: inline assembly syntax for accessing variables ?
Date: 19 Dec 2002 13:25:14 GMT
Organization: Ericsson Erisoft AB, Sweden
Lines: 35
Message-ID: <atshbq$rji$1@antares.lu.erisoft.se>
References: <atses9$d2v$1 AT news DOT online DOT de>
NNTP-Posting-Host: lws256.lu.erisoft.se
X-Newsreader: TIN [version 1.2 PL2]
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Lars O. Hansen (lars DOT o DOT hansen AT gmx DOT de) wrote:
: I have
: INTEGERVARIABLES a,b;

: I like to do
: asm OPCODE-MNEMONIC a,b

: how do I do it in djgpp?

: for example:

: 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)
     );

You may change one of the "r"s to "g" if you want, but I'm not sure it
will add (pun intended) anything to gcc's optimising.

: I am using C and am used to Intel syntax.

The most important difference is the the source and destination are
swapped.


Right,

						MartinS

- Raw text -


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