Mail Archives: djgpp/1998/03/16/20:57:47
At 02:00 3/16/1998 +0100, Fabrice ILPONSE wrote:
>Hi!
>
> I'd like to specify a memory reference in assembly. I mean, for eg.,
>I go a variable 'O'. I use it in inline assembly modifying its value and
>than return it.
See GCC's info node "Extended Asm". It's a bit complicated but works really
well. In this case:
asm("addl $4, %0" : "=g" (O) : "0" (O));
adds 4 to O. (Make sure you distinguish between zeros (0) and O's (O) here!)
>Pb: when -O, there's no more variable O but a register.
>As i push and pop all the registers,
Btw: You shouldn't push and pop things in inline asm. It leads to problems
when you use -fomit-frame-pointer (GCC doesn't expect %esp to change).
> the good value is not kept. How can
>i specify to gcc not to put O in a register but keep it as a memory
>cell?
The method above will work regardless of where O is. But if, for some
reason, it *must* be in memory, you can do:
(void)&O;
Nate Eldredge
eldredge AT ap DOT net
- Raw text -