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=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, 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!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: Using pointers with inline assembly in Ada Date: Fri, 10 Jun 2022 15:39:41 +0200 Organization: A noiseless patient Spider Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 10 Jun 2022 13:39:41 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="57e2f04b319b314c1505a3472859f8ad"; logging-data="347"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18VrtursUDLPobWQizBRm123Q/F+/Ja98Y=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Cancel-Lock: sha1:PhTwNbmh76ASok1uqOIAl2vhlcY= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63965 List-Id: 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