delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/19/20:45:42.1

Sender: nate AT cartsys DOT com
Message-ID: <367C54D3.7BF4887D@cartsys.com>
Date: Sat, 19 Dec 1998 17:37:23 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.0.35 i486)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Need ASM-Syntax to put code into one asm-instruction
References: <367BA58D DOT 2E6C06D3 AT gmx DOT net>
Reply-To: djgpp AT delorie DOT com

Christian Hofrichter wrote:
> 
> Let's say I have the following code :
> 
> asm("movw  %0,%%es":
>                    :"r"((unsigned short) vesa_framebuffer) )
> asm("movl  %0,%%edi" :
>                      :"r"(address) );
> 
> How can I put it into one asm-instruction  ?
> If I use the "normal" asm-syntax I can use "\n\t" but in extended
> asm-syntax this doesn't seem to work.

asm ("movw %0, %%es \n\t"
     "movl %1, %%edi"
     : /* no outputs */
     : "r" ((unsigned short) vesa_framebuffer), "r" (address));

Operands are numbered in the order defined.  You should read (or reread)
the "Extended Asm" section of the GCC docs, which explains all this.

Note that you will of course want to add some instructions that actually
do something, and set the clobber list appropriately.

Also, you can use "\n", "\n\t" or ";" (a semicolon) as you wish.  "\n\t"
looks a little better if you ever have to read the generated asm, but is
less convenient to type.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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