delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/07/01:58:39

Date: Thu, 7 Jan 1999 08:59:02 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Ng Wei Yang <wyng AT mimos DOT my>
cc: djgpp AT delorie DOT com
Subject: Re: problems porting ms inline assembly codes to linux (gnu - AT&T syntax)
In-Reply-To: <771ai0$9kd$1@news5.jaring.my>
Message-ID: <Pine.SUN.3.91.990107085841.16723H-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Thu, 7 Jan 1999, Ng Wei Yang wrote:

> void initPermute(unsigned long *arg)
> {
>         unsigned long temparray[arraysize];
>         unsigned long *temp = temparray;
>         unsigned char *table = tInitPermute;
> 
>         __asm__
>         (
>                 //Initializes temp.
>                 "movl arraysize, %ecx \n"
>                 "movl temp, %esi \n"
>                 "movl $0, %eax \n"

You cannot directly reference local variables from inside inline
assembly.  You need to reference them using the %N method (where N is
the ordinal number of the variable in the parameter list you put at
the end of the __asm__() pseudo-function.  See the section "Extended
Asm" in the GCC docs and the header file sys/farptr.h, for examples.

One other thing: DJGPP prepends an underscore to C identifiers when it
generates assembly, so if you want to reference a global variable that
is declared in C as `foo', you generally need to write `_foo' in
assembly.  (I'd guess that arraysize worked for you without an
underscore only because it was declared in the same source file.)

- Raw text -


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