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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!eu.feeder.erje.net!lightspeed!lightspeed.eweka.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Mon, 07 Jul 2014 15:34:48 +0200 From: "G.B." User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Array slicing question References: <91b81cfc-2faa-4cc5-9c9c-0dc663b67a68@googlegroups.com> In-Reply-To: <91b81cfc-2faa-4cc5-9c9c-0dc663b67a68@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <53baa1f7$0$6666$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 07 Jul 2014 15:34:48 CEST NNTP-Posting-Host: 3a03c940.newsspool3.arcor-online.net X-Trace: DXC=S?ROl;9iLJ5i6K;>iZ]763McF=Q^Z^V384Fo<]lROoR18kF:Lh>_cHTX3j=:56R@@E19[; X-Complaints-To: usenet-abuse@arcor.de X-Received-Bytes: 2144 X-Received-Body-CRC: 2788985107 Xref: news.eternal-september.org comp.lang.ada:20772 Date: 2014-07-07T15:34:48+02:00 List-Id: On 07.07.14 09:31, Mike Silva wrote: > I (I being an Ada novice) am still fiddling around with writing 4 bits of LCD display data into a 32-bit GPIO register. I have this: > > type Bits_1 is mod 2**1 with Size => 1; > type Bits_32x1 is array (0 .. 31) of Bits_1 with Pack, Size => 32; > type Bits_8x1 is array (0 .. 7) of Bits_1 with Pack, Size => 8; > > and I want to do things like this: > > a32 : Bits_32x1; > a8 : Bits_8x1; > ... > a32(4..7) := a8(4..7); Since this expression stays brief only as long as the slices have no holes in them – and if atomicity of the update is required, not touching the other bits in a32 – creating a temporary doesn't seem so bad, perhaps hidden behind a subprogram serving as abstraction. The assignment could not use a simple loop then, either, so a bit-wise assignment from the components of a8 to components of a32 seems still more direct than shifts and masks. My 2¢ (for what might be too general a scheme)