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=-1.9 required=3.0 tests=BAYES_00,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:620a:258e:b0:680:f33c:dbcd with SMTP id x14-20020a05620a258e00b00680f33cdbcdmr31079667qko.542.1654863401367; Fri, 10 Jun 2022 05:16:41 -0700 (PDT) X-Received: by 2002:a0d:eacc:0:b0:30c:30cc:e161 with SMTP id t195-20020a0deacc000000b0030c30cce161mr47364215ywe.375.1654863401122; Fri, 10 Jun 2022 05:16:41 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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 05:16:40 -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: Fri, 10 Jun 2022 12:16:41 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2438 Xref: reader02.eternal-september.org comp.lang.ada:63961 List-Id: On Friday, June 10, 2022 at 1:28:17 AM UTC-4, roda...@gmail.com wrote: > On 10/6/22 07:30, NiGHTS wrote:=20 > > declare=20 > > type ff is array (0 .. 10) of Unsigned_32;=20 > > pragma Pack(ff);=20 > > Flags : aliased ff :=3D (others =3D> 0);=20 > > Flag_Address : System.Address :=3D Flags'Address;=20 > > begin=20 > > Asm ( "movl %0, %%eax" &=20 > > "movl $1, (%%eax)" ,=20 > > Inputs =3D> System.Address'Asm_Input ("g", Flag_Address),=20 > > Clobber =3D> "eax",=20 > > Volatile =3D> true=20 > > );=20 > > Put_Line ("Output:" & Flags(0)'Img);=20 > > end;=20 > > > If you are on a 64 bit machine, then I expect 'pragma Pack' might be=20 > the problem, as 2 consecutive array elements will fir into a single addre= ss.=20 >=20 >=20 > Also, possibly use ...=20 >=20 > Flag_Address : System.Address :=3D Flags (Flags'First)'Address;=20 >=20 >=20 > Regards. Thank you for your response. Unfortunately this didn't seem to work. I agre= e that the pragma was misused, though that shouldn't have caused the error = accessing the first element. I also am not entirely sure why there would be= a difference between the address of the first element versus the address o= f the array itself (maybe that's just my C instincts kicking in).