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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.43.153.196 with SMTP id lb4mr27322995icc.2.1406576896968; Mon, 28 Jul 2014 12:48:16 -0700 (PDT) X-Received: by 10.182.204.106 with SMTP id kx10mr16626obc.29.1406576896770; Mon, 28 Jul 2014 12:48:16 -0700 (PDT) Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!h18no5772949igc.0!news-out.google.com!px9ni0igc.0!nntp.google.com!h18no9483651igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 28 Jul 2014 12:48:16 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.57.209.48; posting-account=zwxLlwoAAAChLBU7oraRzNDnqQYkYbpo NNTP-Posting-Host: 173.57.209.48 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <90305214-9a02-4684-8521-847e8ba38f79@googlegroups.com> Subject: Re: What is a byte? From: "Dan'l Miller" Injection-Date: Mon, 28 Jul 2014 19:48:16 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:187968 Date: 2014-07-28T12:48:16-07:00 List-Id: On Monday, July 28, 2014 2:09:17 PM UTC-5, Victor Porton wrote: > When I need to pass a byte to a C function, which Ada type should I use? That depends on the hardware processor for which the C compiler is generati= ng code. The vast majority of modern* processors have 8-bit bytes, but FPG= As are typically configurable to have 9-bit bytes with all 9 bits usable to= represent 0 to 511 or -256 to 255 (or to have 8-bit bytes plus one parity = bit, to represent 0 to 255 or -128 to 127) and many DSPs have 32-bit bytes.= Ultimately, a byte is the amount of bits that have been traversed when a = char* (or void*) is incremented by one. Also, you must consider whether th= e processor uses twos-complement for negative numbers (e.g., -128 to 127) o= r sign-magnitude (e.g., -127 to -0 and +0 to +127, where typically C is obl= ivious to -0 on sign-magnitude processors). of notable historical interest: a) The MIT/GE/Honeywell Multics machines had 9-bit bytes. b) The Control Data mainframes had 6-bit bytes. c) Prime 50 series had natively 16-bit bytes (which Prime strictly called w= ords, not bytes), using C's definition of how many bits are traversed when = incrementing void*. But Prime 50 Series was one of the rare processors tha= t also had bit-pointers in addition to word-pointers, so conceivably Prime = 50 series could have any number of bits per increment of char* or void* (e.= g., the language designer's choice of 1-bit bytes through 16-bit bytes), so= Prime 50 Series C compilers had a mode that used a particular configuratio= n of bit-pointers to supplement word-pointers to emulate 8-bit bytes, but t= his caused C pointers to be bigger than a C int, which violated the de fact= o idiom back then. Hence, the C community on Prime 50 Series was split int= o 2 camps: c.1) those shops that demanded pointers be the same size as integers (and f= orego the use of slower-executing bit-pointers to emulate 8-bit bytes in C) versus c.2) those shops that demanded 8-bit bytes (and forego the use of int as in= terchangeable with pointer in C).