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:26:56 -0700 (PDT)	[thread overview]
Message-ID: <b9e88f0b-5af7-4939-aef1-e054fd158fc9n@googlegroups.com> (raw)
In-Reply-To: <t7v995$4lk$1@gioia.aioe.org>

On Friday, June 10, 2022 at 7:18:03 AM UTC-4, Luke A. Guest wrote:
> 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.

Though that wouldn't be a bad idea, I've decided to do this another way. I have a limited time to work on this project and I'm just not feeling it. Too risky to work on something this important with so little documentation. I figured I'd give the problem the due-diligence of posting the question on here but I've made up my mind that at least with the project I am working on that I write the code in C/Asm instead. Thank you for your help though.

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