From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.3 required=3.0 tests=BAYES_00,SCC_BODY_URI_ONLY, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Received: by 2002:a05:622a:1011:b0:304:fdc6:411b with SMTP id d17-20020a05622a101100b00304fdc6411bmr17101380qte.307.1654912263275; Fri, 10 Jun 2022 18:51:03 -0700 (PDT) X-Received: by 2002:a25:6744:0:b0:65d:46d6:d9a0 with SMTP id b65-20020a256744000000b0065d46d6d9a0mr47724451ybc.467.1654912263095; Fri, 10 Jun 2022 18:51:03 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 10 Jun 2022 18:51:02 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=73.205.150.94; posting-account=Ru7E4QoAAAC_HiQ2D8LjZ7rh1mbTNcVn NNTP-Posting-Host: 73.205.150.94 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Using pointers with inline assembly in Ada From: NiGHTS Injection-Date: Sat, 11 Jun 2022 01:51:03 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 2635 Xref: reader02.eternal-september.org comp.lang.ada:63968 List-Id: On Friday, June 10, 2022 at 9:39:44 AM UTC-4, Jeffrey R.Carter wrote: > On 2022-06-09 23:30, NiGHTS wrote: > > > > declare > > type ff is array (0 .. 10) of Unsigned_32; > > pragma Pack(ff); > > Flags : aliased ff := (others => 0); > > Flag_Address : System.Address := Flags'Address; > > begin > > Asm ( "movl %0, %%eax" & > > "movl $1, (%%eax)" , > > Inputs => System.Address'Asm_Input ("g", Flag_Address), > > Clobber => "eax", > > Volatile => true > > ); > > Put_Line ("Output:" & Flags(0)'Img); > > end; > Have you looked at the GNAT User's Guide section on this > (https://docs.adacore.com/live/wave/gnat_ugn/html/gnat_ugn/gnat_ugn/inline_assembler.html)? > I have never used this, but the first thing I notice is that the examples in the > User's Guide put an LF-HT pair between statements: > > Asm ("pushfl" & LF & HT & -- push flags on stack > "popl %%eax" & LF & HT & -- load eax with flags > "movl %%eax, %0", -- store flags in variable > Outputs => Unsigned_32'Asm_Output ("=g", Flags)); > > It is also legal to separate the statements with spaces, but what you have would > seem to be > > movl %0, %%eaxmovl $1, (%%eax) > > which may be a problem. > -- > Jeff Carter > "I'm a lumberjack and I'm OK." > Monty Python's Flying Circus > 54 On my side I had the LF HT characters. I copied the code badly to this posting. So though you are right, my post lied a little bit by accident. This didn't end up being the main problem.