From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4ac8a7e7d3e637dc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-23 11:30:48 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: snarflemike@yahoo.com (Mike Silva) Newsgroups: comp.lang.ada Subject: Re: Is there a better (Ada) way? Date: 23 Oct 2003 11:30:47 -0700 Organization: http://groups.google.com Message-ID: <20619edc.0310231030.431acd33@posting.google.com> References: <20619edc.0310221056.4c92d10c@posting.google.com> <%GHlb.1106$mZ5.9467@attbi_s54> NNTP-Posting-Host: 154.6.152.68 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1066933848 23003 127.0.0.1 (23 Oct 2003 18:30:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 23 Oct 2003 18:30:48 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:1531 Date: 2003-10-23T11:30:47-07:00 List-Id: "Steve" 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