comp.lang.ada
 help / color / mirror / Atom feed
From: "Dan'l Miller" <optikos@verizon.net>
Subject: Re: What is a byte?
Date: Mon, 28 Jul 2014 12:48:16 -0700 (PDT)
Date: 2014-07-28T12:48:16-07:00	[thread overview]
Message-ID: <90305214-9a02-4684-8521-847e8ba38f79@googlegroups.com> (raw)
In-Reply-To: <lr674v$34l$1@speranza.aioe.org>

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 generating code.  The vast majority of modern* processors have 8-bit bytes, but FPGAs 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 the processor uses twos-complement for negative numbers (e.g., -128 to 127) or sign-magnitude (e.g., -127 to -0 and +0 to +127, where typically C is oblivious 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 words, 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 that 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 configuration of bit-pointers to supplement word-pointers to emulate 8-bit bytes, but this caused C pointers to be bigger than a C int, which violated the de facto idiom back then.  Hence, the C community on Prime 50 Series was split into 2 camps:
c.1) those shops that demanded pointers be the same size as integers (and forego 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 interchangeable with pointer in C).


  reply	other threads:[~2014-07-28 19:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28 19:09 What is a byte? Victor Porton
2014-07-28 19:48 ` Dan'l Miller [this message]
2014-07-28 20:05   ` Dan'l Miller
2014-07-28 22:38   ` Randy Brukardt
2014-07-28 21:15 ` Simon Wright
2014-07-29 10:53 ` Jeffrey Carter
2014-07-29 12:26   ` Dan'l Miller
2014-07-29 18:40     ` Simon Wright
2014-07-29 21:15       ` Dan'l Miller
2014-07-29 23:08         ` Simon Clubley
2014-07-30  4:11       ` Dan'l Miller
2014-07-30  7:47       ` Simon Wright
2014-08-02 21:01   ` Keith Thompson
replies disabled

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