delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/14/04:25:34

Date: Thu, 14 May 1998 11:25:00 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Herman Schoenfeld <you AT somehost DOT somedomain>
cc: djgpp AT delorie DOT com
Subject: Re: Inline assembly in djgpp
In-Reply-To: <6je51h$h46$1@grissom.powerup.com.au>
Message-ID: <Pine.SUN.3.91.980514112155.287L-100000@is>
MIME-Version: 1.0

On 14 May 1998, Herman Schoenfeld wrote:

> Is there any possible way to use variable names in inline assembly?

But of course!  That's one of the main features of GCC's inline assembly.

> int i=10, j=20;
> asm ("movw %_i, %%eax": : "eax");
> asm ("movw %_j, %%ebx": : "ebx");
> 
> I know that works, however if the above assembly is in a function and 
> the variables i,j are declared publically, then it decides to load those 
> not the ones declared inside the function. Why doesn't the scope rules 
> seem to affect djgpp inline asm? Or, is there a way around this?

The ``way around this'' is to read the documentation and use inline 
assembly like GCC Gods intended ;-).

You are using inline assembly incorrectly: you shouldn't say %_j to mean 
the variable j.  Please read the extended asm docs by typing 
"info gcc 'C Extensions' 'Extended asm'" from the DOS prompt (the issue 
is too complex to explain in a short message).

- Raw text -


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