comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com>
Subject: Re: Problem trying to implement generics.
Date: Thu, 19 Apr 2001 10:20:08 -0400
Date: 2001-04-19T14:20:09+00:00	[thread overview]
Message-ID: <9bms6p$2ia$1@nh.pace.co.uk> (raw)
In-Reply-To: 9bi4g4$97m$1@nh.pace.Organization: LJK Software <YlSyXUaQmD+$@eisner.encompasserve.org

Most of the conditions in which I've seen people doing bitwise operations
(shifts, xors, etc.) seem to be handled in Ada by proper use of
representation clauses. You create records that match the bit layout of
registers or packed arrays of boolean & similar things. Unless the Ada
implementation of access to these fields is pathetically slow, it usually is
going to handle things much more cleanly. Need a three bit integer from the
center of a machine word? Put it in a rep claused record and just use
assignment!

Still, its handy to have the logical operations. One really great use I had
for them was when reading/writing various A/D and Discrete values from
hardware. By always doing an XOR of the input with a constant in memory, you
could plug the constant at runtime with a monitor program and toggle the
input bits. This was invaluable for testing. (Same trick works with always
adding a constant to a mathematical input - "tuning" constants, as it were.)
So having logical operations is very useful in many spots. But I think
you're right about them being used to compensate for a lack of language
facilities in most cases.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/


"Larry Kilgallen" <Kilgallen@eisner.decus.org.nospam> wrote in message
news:YlSyXUaQmD+$@eisner.encompasserve.org...
> In article <9bkfk4$6a2$1@nh.pace.co.uk>, "Marin David Condic"
<marin.condic.auntie.spam@pacemicro.com> writes:
>
> Thinking about device drivers I have written (not in C or Ada) it seems
> to me that bit shifting is most likely to be the "manual" operation used
> in low-level languages where the conceptually desired operation is not
> supported.
>
> For instance, if one has a numeric field that is supposed to be
> positioned three bits left in a register the low-level approach
> (at the source level) would be to "shift" and "or" it together
> with the other bits before setting it into the register.
>
> The conceptual operation is to store a field into a register-format
> record before setting it into a record.  The Ada method is much
> more logical, except for those with lots of experience writing
> drivers in lesser languages.





  parent reply	other threads:[~2001-04-19 14:20 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-11 15:04 Problem trying to implement generics Ayende Rahien
2001-04-12  1:41 ` tmoran
2001-04-12 13:15   ` Ayende Rahien
2001-04-12 18:15     ` tmoran
2001-04-13 11:18       ` Ayende Rahien
2001-04-13 10:35         ` chris.danx
2001-04-13 11:54           ` Ayende Rahien
2001-04-13 11:49             ` chris.danx
2001-04-13 23:03               ` Ayende Rahien
2001-04-13 23:01                 ` Robert A Duff
2001-04-14  0:05                   ` Brian Rogoff
2001-04-14  1:12                     ` Ayende Rahien
2001-04-14  1:44                       ` Brian Rogoff
2001-04-14 14:03                         ` Dmitry A. Kazakov
2001-04-14 16:30                           ` Ayende Rahien
2001-04-14 16:28                             ` Michael Erdmann
2001-04-15  3:27                             ` James Rogers
2001-04-15 12:20                               ` Ayende Rahien
2001-04-15 14:09                               ` Dmitry A. Kazakov
2001-04-15 18:22                                 ` tmoran
2001-04-15 13:48                             ` Dmitry A. Kazakov
2001-04-15 20:44                               ` Ayende Rahien
2001-04-16 14:34                                 ` Dmitry A. Kazakov
2001-04-14  1:33                     ` Robert A Duff
2001-04-17  8:50                     ` Jean-Pierre Rosen
2001-04-17 13:20                   ` Tucker Taft
2001-04-17 16:51                     ` Ayende Rahien
2001-04-17 17:16                       ` Larry Hazel
2001-04-17 18:11                         ` Brian Rogoff
2001-04-17 19:10                           ` Marin David Condic
2001-04-17 21:08                             ` Brian Rogoff
2001-04-18 15:16                               ` Chad R. Meiners
2001-04-18 16:33                                 ` Marin David Condic
2001-04-17 21:09                             ` chris.danx
2001-04-17 21:11                             ` chris.danx
2001-04-17 21:17                             ` chris.danx
2001-05-08  5:40                             ` Lao Xiao Hai
2001-05-11  9:43                               ` John English
2001-05-12 19:16                                 ` Lao Xiao Hai
2001-04-17 19:32                           ` Larry Hazel
2001-04-17 21:03                           ` Ayende Rahien
2001-04-18 15:48                             ` Brian Rogoff
2001-04-20 12:34                               ` Georg Bauhaus
2001-04-20 12:42                                 ` Lutz Donnerhacke
2001-04-20 12:45                                 ` Lutz Donnerhacke
2001-04-20 19:48                                 ` Brian Rogoff
2001-04-20 20:36                                   ` David Starner
2001-04-20 23:02                                   ` Robert A Duff
2001-04-23  2:45                                     ` Brian Rogoff
2001-04-24  1:15                                       ` Robert A Duff
2001-04-24  2:00                                         ` Brian Rogoff
2001-04-24 15:12                                           ` Georg Bauhaus
2001-04-24 15:09                                         ` Georg Bauhaus
2001-04-24 18:36                                           ` Marius Amado Alves
2001-04-19 13:08                           ` Larry Kilgallen
     [not found]                           ` <9bi4g4$97m$1@nh.pace.Organization: LJK Software <YlSyXUaQmD+$@eisner.encompasserve.org>
2001-04-19 14:20                             ` Marin David Condic [this message]
2001-04-18  5:34                       ` Mike Silva
2001-04-18 16:55                       ` Ray Blaak
2001-04-24 16:00                       ` Tucker Taft
2001-04-12 13:57 ` Andy
2001-04-13  6:34   ` Simon Wright
2001-04-13 11:11   ` Ayende Rahien
2001-04-12 18:06 ` Stephen Leake
replies disabled

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