From: snarflemike@yahoo.com (Mike Silva)
Subject: Re: Is there a better (Ada) way?
Date: 23 Oct 2003 11:30:47 -0700
Date: 2003-10-23T11:30:47-07:00 [thread overview]
Message-ID: <20619edc.0310231030.431acd33@posting.google.com> (raw)
In-Reply-To: %GHlb.1106$mZ5.9467@attbi_s54
"Steve" <nospam_steved94@comcast.net> wrote in message news:<%GHlb.1106$mZ5.9467@attbi_s54>...
> I don't know if its really more "Ada like" but here is the approach I would
> take.
>
> Rougly following your conventions I would add a type definition:
>
> type SReg16_T is range -2**15..2**15-1;
> for SReg16_T'size use 16;
>
> Then use a type conversion for a sign extend:
> SReg16_T( PB.Offset5 )
>
> And an instance of unchecked conversion to convert to a SReg16_T to a
> Reg16_T:
>
> function To_Reg16_T is new Ada.Unchecked_Conversion( SReg16_T, Reg16_T );
>
> Then the expression in your example would read:
>
> R16 := R16 + To_Reg16_T( SReg16_T( PB.Offset5 ) );
>
Yes, I like this better -- in fact, I came up with the same thing
myself last night in trying various alternatives. Thanks for
confirming my instincts!
(I also have to deal with signed 8-bit offsets, which pretty much puts
the array method out of the running for me...)
Mike
next prev parent reply other threads:[~2003-10-23 18:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-22 18:56 Is there a better (Ada) way? Mike Silva
2003-10-22 19:33 ` sk
2003-10-23 18:33 ` Mike Silva
2003-10-22 20:50 ` Robert I. Eachus
2003-10-23 16:57 ` Mike Silva
2003-10-23 21:42 ` Robert I. Eachus
2003-10-24 1:42 ` Mike Silva
2003-10-23 3:12 ` Steve
2003-10-23 18:30 ` Mike Silva [this message]
2003-10-24 22:20 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox