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=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ad988eb0a9545c86 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-19 07:36:52 PST Path: supernews.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!isdnet!psinet-france!psiuk-f4!psiuk-p4!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: Problem trying to implement generics. Date: Thu, 19 Apr 2001 10:20:08 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9bms6p$2ia$1@nh.pace.co.uk> References: <9b6jtu$4is$2@taliesin.netcom.net.uk> <9b6m27$68e$1@taliesin.netcom.net.uk> <0JBB6.10484$FD1.1197250@news6-win.server.ntlworld.com> <9b7tce$laf$2@taliesin.netcom.net.uk> <3ADC4320.7ACA3DEC@averstar.com> <9bhoup$h9k$1@taliesin.netcom.net.uk> <3ADC7A79.8E853905@mindspring.com> <9bi4g4$97m$1@nh.pace.Organization: LJK Software NNTP-Posting-Host: 136.170.200.133 X-Trace: nh.pace.co.uk 987690009 2634 136.170.200.133 (19 Apr 2001 14:20:09 GMT) X-Complaints-To: newsmaster@pace.co.uk NNTP-Posting-Date: 19 Apr 2001 14:20:09 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: supernews.google.com comp.lang.ada:7001 Date: 2001-04-19T14:20:09+00:00 List-Id: 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" wrote in message news:YlSyXUaQmD+$@eisner.encompasserve.org... > In article <9bkfk4$6a2$1@nh.pace.co.uk>, "Marin David Condic" 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.