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-Thread: 103376,379f9c2a66a5ddc8,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!transit3.readnews.com!news-xxxfer.readnews.com!textspool1.readnews.com!news-out.readnews.com!postnews3.readnews.com!not-for-mail Date: Sun, 12 Sep 2010 21:10:50 -0400 From: "Peter C. Chapin" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.9) Gecko/20100825 Lightning/1.0b2 Thunderbird/3.1.3 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Question about package Interfaces. Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4c8d7a8e$0$2408$4d3efbfe@news.sover.net> Organization: SoVerNet (sover.net) NNTP-Posting-Host: b944de4b.news.sover.net X-Trace: DXC=LiRVWUg4jnh_8Tb1O14ZMmK6_LM2JZB_cPbjgGOc=aCe:WUUlR<856oH6Y79mcjhLen X-Complaints-To: abuse@sover.net Xref: g2news1.google.com comp.lang.ada:14030 Date: 2010-09-12T21:10:50-04:00 List-Id: Really two questions... My first question is about the types in package Interfaces such as Integer_8, Unsigned_8, etc (I understand that the precise numbers available depend on the implementation). The reference manual says this: "[They are] signed and modular types of n bits, if supported by the target architecture, for each n that is at least the size of a storage element and that is a factor of the word size." This is fine. However, I don't see anything in the reference manual that requires these types to be represented by a specific number of bits. The phrase "signed and modular types of n bits" is suggestive, I admit, but does that also mean they are represented by exactly n bits in the generated code? Would it be legal for a compiler to to store something of type Unsigned_8 in a 16 bit object? I guess I'm asking if the implementation required to behave as if the representation clause for Unsigned_8'Size use 8; was in effect? My second question is about the intrinsic Shift and Rotate functions in package Interfaces. For example: function Shift_Left (Value : Unsigned_8; Amount : Natural) return Unsigned_8; About these functions the reference manual says: "They operate on a bit-by-bit basis, using the binary representation of the value of the operands to yield a binary representation for the result." I don't see any description of what happens when the shift amount is larger than the size of the object being shifted. For example; Value : Interfaces.Unsigned_8; ... Value := Interfaces.Shift_Left(Value, 1_000); The reference manual does say, "For shifting, zero bits are shifted in..." However, it has recently come to my attention that some processors, such as Intel architecture machines, have shift instructions that mask the shift count. For example, shifting a 32 bit operand by 32 bits results in an actual shift of 0 bits. Does that mean implementations for such a system can't compile Interfaces.Shift_Left into a single instruction but instead have to force "unlimited" shift semantics on top of a hardware facility that doesn't do it that way? The C standards says that attempting to shift an object of n bits by an amount greater than or equal to n results in "undefined behavior." Thus C compilers can just do what the hardware does in this situation. I can see the potential efficiency advantage there. Peter