delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/07/23/00:27:51

Date: Sat, 22 Jul 95 21:44 MDT
From: mat AT ardi DOT com (Mat Hostetter)
To: ld AT netrix DOT com
Cc: Roberto Alsina <ralsina AT ultra4 DOT unl DOT edu DOT ar>, djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Inline assembler
Newsgroups: comp.os.msdos.djgpp
References: <DC2Kw5 DOT ns AT jade DOT mv DOT net> <DC34IB DOT 3AM AT netrix DOT com>

>>>>> "Long" == Long Doan <ld AT jasmine DOT netrix DOT com> writes:

    Long> |> 2) How do i reference a local variable (or label) or an
    Long> argument passed to a |> function from an asm? _varname only
    Long> seems to work with globals.

    Long> You'll have to look at their orders (some might be optimized
    Long> away!), and the offset them from %ebp.

This is _extremely_ bad advice, especially for local variables!  I
can't believe you're suggesting it.  Use gcc's asm operands to specify
input and output values, e.g.

void
foo (int a)
{
  int x;
  asm ("movl %1,%0"
       : "=r" (x)  /* Outputs */
       : "g" (a)   /* Inputs */);
  printf ("%d\n", x);
}

This is all explained in the gcc docs.

-Mat

- Raw text -


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