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:6214:21e5:b0:46d:82b5:b1a2 with SMTP id p5-20020a05621421e500b0046d82b5b1a2mr7590816qvj.116.1654863832993; Fri, 10 Jun 2022 05:23:52 -0700 (PDT) X-Received: by 2002:a25:4142:0:b0:664:6927:7b87 with SMTP id o63-20020a254142000000b0066469277b87mr2023728yba.100.1654863832777; Fri, 10 Jun 2022 05:23:52 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!paganini.bofh.team!pasdenom.info!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!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:23:52 -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: <1eb8caa1-60e0-4e30-bb7b-c06969129970n@googlegroups.com> Subject: Re: Using pointers with inline assembly in Ada From: NiGHTS Injection-Date: Fri, 10 Jun 2022 12:23:52 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:63962 List-Id: On Friday, June 10, 2022 at 3:15:38 AM UTC-4, ldries46 wrote: > Op 10-6-2022 om 7:24 schreef Rod Kay: > 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_Addres= s),=20 > Clobber =3D> "eax",=20 > Volatile =3D> true=20 > );=20 > Put_Line ("Output:" & Flags(0)'Img);=20 > end;=20 >=20 >=20 > If you are on a 64 bit machine, then I expect 'pragma Pack' might be t= he problem, as 2 consecutive array elements will fir into a single address.= =20 >=20 >=20 > Also, possibly use ...=20 >=20 > Flag_Address : System.Address :=3D Flags (Flags'First)'Address;=20 >=20 >=20 > Regards. > There maybe a a way around this problem, if there is a compiler that can = create assembly code. I have used that method in the past with Pascal progr= ams where I wanted to avoid internal checks on errors that could not occur = in that part of the program. >=20 > Warning: Programming the way you want to means that your program will mea= n that your program can become depending on the system you are working on. = Meaning for instance not only recompiling when migrating from Windows to Li= nux but also reprogramming that part of your work Ada does a good job generating efficient machine code, and there are lots o= f ways to get around compiler checks (unlike Pascal). In this situation I w= as trying to make use of a very specific set of uncommon CPU instructions b= ut required passing an array to it that allows side-effects. I'm a bit peev= ed that there is so little in the way of documentation for the Asm command.