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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ded6ba3fc5b87b66 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-10-26 14:46:59 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!europa.netcrusader.net!152.163.239.129!portc01.blue.aol.com!newsfeed.mathworks.com!nycmny1-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!inmet!not-for-mail From: Tucker Taft Newsgroups: comp.lang.ada Subject: Re: First time Ada has let me down Date: Thu, 26 Oct 2000 17:46:58 -0400 Organization: AverStar (formerly Intermetrics) Burlington, MA USA Message-ID: <39F8A652.96835CB7@averstar.com> References: <8FD7DEBEEsynoptikdamudderfuck@news> NNTP-Posting-Host: nebula.burl.averstar.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: inmet2.burl.averstar.com 972596818 13411 141.199.8.77 (26 Oct 2000 21:46:58 GMT) X-Complaints-To: usenet@inmet2.burl.averstar.com NNTP-Posting-Date: 26 Oct 2000 21:46:58 GMT X-Mailer: Mozilla 4.75 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:1586 Date: 2000-10-26T21:46:58+00:00 List-Id: You have received a bunch of answers, not all relevant to Ada 83. It is true that Ada 83 doesn't have support for bit-wise "and"/"or" on integers. However, it has several other features that make that unnecessary. Defining a record type with fields of a 4-bit type (such as "type Bit4 is range 0..15;") and then putting a record representation clause on it would seem to be a good starting point. If you really want to manipulate bits, a packed array of boolean does have "and" and "or", and gives you complete access to individual bits. Finally, you could define a packed array of the 4-bit type (such as the one defined above), and use that to get at individual "nibbles". Unchecked conversion may be necessary somewhere along the way, unless you can use an appropriate rep-spec'ed record or a packed array to represent the entire packet. Although a packed boolean array most directly matches the (limited ;-) capabilities of C, the other mechanisms (such as rep-speced records, or packed array of 4-bit elements) are probably a better fit for the problem. Shifty wrote: > > OK, here's the story: > > I had a problem at work where I needed to calculate the offset of a > "magic number" within a buffer containing an IP datagram. > > The magic number is 3 protocol headers deep within the datagram, and > all three headers are variable length. I needed to find the HLEN > fields of the IP and TCP headers in memory. Turns out both of these > are stored in 4 bits. The data in the other 4 bits of the octet > belong to another field in the header. > ... I can't believe Ada (83) doesn't have native > language support for these!!! Please tell me that I am hopelessly > confused and dead wrong! > > Cheers, > Andrew. -- -Tucker Taft stt@averstar.com http://www.averstar.com/~stt/ Technical Director, Commercial Division, AverStar (formerly Intermetrics) (http://www.averstar.com/services/IT_consulting.html) Burlington, MA USA