comp.lang.ada
 help / color / mirror / Atom feed
From: NiGHTS <nights@unku.us>
Subject: Re: Using pointers with inline assembly in Ada
Date: Fri, 10 Jun 2022 05:16:40 -0700 (PDT)	[thread overview]
Message-ID: <cb332860-e55d-48a7-81b2-1ed1edf45dcan@googlegroups.com> (raw)
In-Reply-To: <t7ukpe$759$1@dont-email.me>

On Friday, June 10, 2022 at 1:28:17 AM UTC-4, roda...@gmail.com 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.

Thank you for your response. Unfortunately this didn't seem to work. I agree 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 of the array itself (maybe that's just my C instincts kicking in).

  parent reply	other threads:[~2022-06-10 12:16 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 [this message]
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
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