comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not>
Subject: Re: Using pointers with inline assembly in Ada
Date: Fri, 10 Jun 2022 15:39:41 +0200	[thread overview]
Message-ID: <t7vhit$ar$1@dont-email.me> (raw)
In-Reply-To: <db04b8e7-ba96-4f4a-afb1-575e446ace64n@googlegroups.com>

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

  parent reply	other threads:[~2022-06-10 13:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09 21:30 Using pointers with inline assembly in Ada NiGHTS
2022-06-10  5:24 ` Rod Kay
2022-06-10 11:16   ` Luke A. Guest
2022-06-10 12:26     ` NiGHTS
2022-06-10 12:16   ` NiGHTS
2022-06-10 13:19     ` Jeffrey R.Carter
     [not found]   ` <nnd$727405a5$1c8a5b81@aedbf58048bf777d>
2022-06-10 12:23     ` NiGHTS
2022-06-11  1:43   ` Rod Kay
2022-06-10 13:39 ` Jeffrey R.Carter [this message]
2022-06-11  1:51   ` NiGHTS
2022-06-11 12:28 ` Simon Wright
2022-06-11 12:32   ` NiGHTS
2022-06-13 20:33 ` Gabriele Galeotti
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox