comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Representation clauses for base-64 encoding
Date: Tue, 27 Dec 2011 12:23:25 +0100
Date: 2011-12-27T12:23:25+01:00	[thread overview]
Message-ID: <4ef9aaad$0$6643$9b4e6d93@newsspool2.arcor-online.net> (raw)
In-Reply-To: <9lobhaF9adU1@mid.individual.net>

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?





  reply	other threads:[~2011-12-27 11:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-22  9:41 Representation clauses for base-64 encoding Natasha Kerensikova
2011-12-22 11:20 ` Niklas Holsti
2011-12-23  1:30   ` Randy Brukardt
2011-12-26  8:33     ` Niklas Holsti
2011-12-28  0:09       ` Randy Brukardt
2011-12-22 11:37 ` Georg Bauhaus
2011-12-22 12:24   ` Niklas Holsti
2011-12-22 15:09     ` Georg Bauhaus
2011-12-22 16:00       ` Natasha Kerensikova
2011-12-22 22:18         ` Georg Bauhaus
2011-12-25 10:17           ` Niklas Holsti
2011-12-27 11:23             ` Georg Bauhaus [this message]
2011-12-27 19:37               ` Niklas Holsti
2011-12-27 20:49                 ` Robert A Duff
2011-12-27 23:47                   ` Niklas Holsti
2011-12-29  0:50                     ` Robert A Duff
2011-12-30 20:54                       ` anon
2011-12-30 20:56                       ` Niklas Holsti
2011-12-23  1:42     ` Randy Brukardt
2011-12-28  8:59       ` Niklas Holsti
2011-12-29  5:41         ` Randy Brukardt
2011-12-29 10:10           ` Dmitry A. Kazakov
2011-12-23  1:33 ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox