* strange behavior while compiling code with asm()
@ 2011-05-26 15:10 milouz
2011-05-26 16:50 ` Simon Wright
0 siblings, 1 reply; 3+ messages in thread
From: milouz @ 2011-05-26 15:10 UTC (permalink / raw)
Hi all,
There's an unexpected behavior I can't understand when I compile some
Ada code with Asm() directive. In the following example, code compile
with no problem :
...
procedure Main is
Foo : Integer;
begin
Foo := 1; -- Foo is initialized here !
System.Machine_Code.Asm(
"movl %0, %%eax",
Inputs => Integer'Asm_Input("m", Foo),
Volatile => True
);
...
Why no trying to initialize `Foo' variale during its declaration ? The
code is exactly the same except for `Foo' :
procedure Main is
Foo : Integer := 1; -- Foo is initialized here !
begin
But then, compilation fails with that message : "error: memory input 0
is not directly addressable"
Someone have an explanation ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: strange behavior while compiling code with asm()
2011-05-26 15:10 strange behavior while compiling code with asm() milouz
@ 2011-05-26 16:50 ` Simon Wright
2011-05-27 11:50 ` milouz
0 siblings, 1 reply; 3+ messages in thread
From: Simon Wright @ 2011-05-26 16:50 UTC (permalink / raw)
milouz <a.michelizza@gmail.com> writes:
> procedure Main is
> Foo : Integer;
> begin
> Foo := 1; -- Foo is initialized here !
> System.Machine_Code.Asm(
> "movl %0, %%eax",
> Inputs => Integer'Asm_Input("m", Foo),
> Volatile => True
> );
> ...
>
> Why no trying to initialize `Foo' variale during its declaration ? The
> code is exactly the same except for `Foo' :
>
> procedure Main is
> Foo : Integer := 1; -- Foo is initialized here !
> begin
>
>
> But then, compilation fails with that message : "error: memory input 0
> is not directly addressable"
Here (GCC 4.6.0) I get
gnatmake -c -u -f milouz.adb
gcc -c milouz.adb
milouz.adb: In function 'Milouz':
milouz.adb:13:23: warning: use of memory input without lvalue in asm operand 0 is deprecated [enabled by default]
but this goes away if instead of "m" I use "g". I suppose that the first
form places Foo in memory, while the second places it in a register,
which won't work with the "m" constraint
(http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Simple-Constraints.html)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: strange behavior while compiling code with asm()
2011-05-26 16:50 ` Simon Wright
@ 2011-05-27 11:50 ` milouz
0 siblings, 0 replies; 3+ messages in thread
From: milouz @ 2011-05-27 11:50 UTC (permalink / raw)
Thank you very much for the explanation and the useful link !
It's very clear now :-D
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-27 11:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-26 15:10 strange behavior while compiling code with asm() milouz
2011-05-26 16:50 ` Simon Wright
2011-05-27 11:50 ` milouz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox