www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/07/22/00:07:25

Date: Fri, 21 Jul 1995 23:49:34 -0400
From: dj (DJ Delorie)
To: ralsina AT ultra4 DOT unl DOT edu DOT ar
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Inline assembler

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

Put the function after the usage of it.  Then, the compiler doesn't
know that it can inline it at that time.

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

If you mean a .s file, you need to use an [ebp] relative indirect, like
this:

	.global	_foo
_foo:
	pushl	%ebp
	movl	%esp, %ebp
	movl	8(%ebp), %eax	// first param
	movl	12(%ebp), %ebx	// second param (etc)
	...
	popl	%ebp
	ret

- Raw text -


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