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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!aioe.org!Lx7EM+81f32E0bqku+QpCA.user.46.165.242.75.POSTED!not-for-mail From: "Luke A. Guest" Newsgroups: comp.lang.ada Subject: Re: Using pointers with inline assembly in Ada Date: Fri, 10 Jun 2022 12:16:27 +0100 Organization: Aioe.org NNTP Server Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gioia.aioe.org; logging-data="4788"; posting-host="Lx7EM+81f32E0bqku+QpCA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Content-Language: en-GB X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:63960 List-Id: On 10/06/2022 06:24, Rod Kay wrote: > On 10/6/22 07: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; >> > >    If you are on a 64 bit machine, then I expect 'pragma Pack' might be > the problem, as 2 consecutive array elements will fir into a single > address. > > >    Also, possibly use ... > >    Flag_Address : System.Address := Flags (Flags'First)'Address; > > > Regards. Dump the xpanded (generated code) and the assembly from gnat.