From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c0df3c528abb570a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: strange behavior while compiling code with asm() Date: Thu, 26 May 2011 17:50:43 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="27531"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18TSzD1hIgZHBEBubcmPhZtP8Kl+QknNb0=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:YttvTP5P40ZDh6if2qHks+D4AYc= sha1:sSj87uL6m+RC8DoNMYCI74Xzl3M= Xref: g2news1.google.com comp.lang.ada:19495 Date: 2011-05-26T17:50:43+01:00 List-Id: milouz 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)