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=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d778a4f52acd9d43 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.190.2 with SMTP id gm2mr19392979pbc.4.1324985461578; Tue, 27 Dec 2011 03:31:01 -0800 (PST) Path: lh20ni69823pbb.0!nntp.google.com!news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 27 Dec 2011 12:23:25 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Representation clauses for base-64 encoding References: <4ef31672$0$6574$9b4e6d93@newsspool3.arcor-online.net> <9lgls6FticU1@mid.individual.net> <4ef34839$0$7623$9b4e6d93@newsspool1.arcor-online.net> <4ef3acd0$0$6642$9b4e6d93@newsspool2.arcor-online.net> <9lobhaF9adU1@mid.individual.net> In-Reply-To: <9lobhaF9adU1@mid.individual.net> Message-ID: <4ef9aaad$0$6643$9b4e6d93@newsspool2.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 27 Dec 2011 12:23:25 CET NNTP-Posting-Host: b9da6163.newsspool2.arcor-online.net X-Trace: DXC=Xfo9QL7VW6C2:OR3:3gaE@A9EHlD;3YcB4Fo<]lROoRA8kFJLh>_cHTX3jM>6Oc6gbhVY@ X-Complaints-To: usenet-abuse@arcor.de Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Date: 2011-12-27T12:23:25+01:00 List-Id: On 25.12.11 11:17, Niklas Holsti wrote: >> There is middle ground, I think, insofar as it is possible >> to extract bits in Ada without thinking about shifts and masks, >> or logical operations. Just saying that using Ada, one may write operations involving single bits or slices of single bits simply by using arrays of Booleans that are packed. I think I didn't say that one may read portably from I/O ports? >> Without claiming [...] portability of bit indexing >> of bits in a single octet [...] Thanks for illustrating my words in my code. ;-) > What are these "desirable properties" on which you rely, and where in the LRM > are they guaranteed? Everything (the "desirable properties") that an interested party might conclude after reading LRM 13.2. Yes, on some planet there might be an Ada compiler that does not handle packed bits reasonably well. ;-) 13.2 drops alignment requirements dropped, in particular, so that I do not need to think about boundaries of storage element size groups of bits. The BIT_VECTOR in the Rationale of Ada 83 indicates awareness of Pascals SET type, too, I should think. (Don't know if Wirth's paper on representation of sets is an influence, or just a summary of existing practice.) The Ada 85 Quality and Style Guide has this to say, in Chapter 10, http://www.adaic.org/resources/add_content/docs/95style/html/sec_10/10-6-3.html "Use modular types rather than packed Boolean arrays when measured performance indicates." "Measured performance indicates", then , whether or not to resort to explicit shifting and logical operations. I looked at how compilers will translate operations on slices of Booleans (-Os is an interesting option with GNAT). They will emit instructions for shifting and logical operations; no surprise. So, would there be a portable Base64 algorithm that reads from a stream of storage elements, perhaps from a typical controller's 8-bit I/O port, that (*) shifts and "reasons" more reliably, readably, and portably, (*) performs shifts and logical operations much faster than the shifts and logical operations generated by typical compilers for bit slices or representations, (*) runs on heterogeneous hardware with word size <= 16 bits?