www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/07/21/20:22:36

Date: Fri, 21 Jul 95 17:39 MDT
From: mat AT ardi DOT com (Mat Hostetter)
To: Roberto Alsina <ralsina AT ultra4 DOT unl DOT edu DOT ar>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Inline assembler
References: <9507211256 DOT AA29805 AT sun DOT soe DOT clarkson DOT edu DOT soe> <Pine DOT LNX DOT 3 DOT 91 DOT 950721103820 DOT 833A-100000 AT ultra4 DOT unl DOT edu DOT ar>

>>>>> "Roberto" == Roberto Alsina <ralsina AT ultra4 DOT unl DOT edu DOT ar> writes:

    Roberto> 1) The routine makes a jump to a label, that's ok, but
    Roberto> when compiling whit -O3, it gets inlined, so the label
    Roberto> gets duplicated everywhere the function is called, and
    Roberto> the program won't compile. Is there something like a
    Roberto> "not_inline" directive to tell the compiler NOT to inline
    Roberto> that function?, or a way to define a local label? (i saw
    Roberto> it on the info files, but i couldn't make it work, if
    Roberto> somebody has, please send me an example).

Sure.  Local labels are of the form 1:, 2:, 3:, etc.  When you want to
reference a local label, you say either "2f" or "2b" (for example),
which means "the next `2:' forward" and "the previous `2:' backward",
respectively.  So:

asm ("jmp 2f\n"
     "1:\n\t"
     "nop\n"
     "2:\n\t"
     "jmp 1b");

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

List it in the input or output operands to the asm.  The syntax for
doing this is explained in the gcc info pages.

-Mat

- Raw text -


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