linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Re: Re^2: char type is unsigned with PPC gcc?
       [not found] <c9.39dbd77.262faf77@aol.com>
@ 2000-04-20 15:34 ` Dan Malek
  2000-04-20 21:38   ` Gabriel Paubert
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Malek @ 2000-04-20 15:34 UTC (permalink / raw)
  To: W4OQM; +Cc: linuxppc-embedded


W4OQM@aol.com wrote:

> How about:
>
> #define BIT_8_OF_BYTE   (1<<0)
> #define BIT_8_OF_WORD   (1<<8)
> #define BIT_8_OF_LONG   (1<<24)

Whoa there, youngster.....let the old man tell you a story.
There is computing equipment in the world where a byte is not
eight bits, a word is not two bytes, and so on.

Left to right (big endian) bit numbering works just fine on
these computers, as it does on all big endian machines.

On big endian byte ordered machines, you also want big endian
bit ordering.  If I load some address as a byte, word, long word
or whatever, bit 6 is still bit 6.  You probably don't remember
the bit instruction mess when Motorola added that to the '020......

If you had a programming language that supported bit array objects,
how would you index the array?  How would that map into larger
objects?


> ...  Personally, the left-to-right bit numbering drives me nuts.


That's because you are worried about the implementation details and
not solving the data communication application.  Look at flow of
bits through a data communication system.  Serial stream, left to
right.  Start numbering bits anywhere, stop anywhere, left to right
makes perfect sense.  Map any aribitary object on top of the bits,
still makes sense.  Look at coding theory and the algorithms they
write...left to right bit ordering.

The 2^n bit numbering is a mathematical convenience that can be
easily hidden behind programming language macros or functions.  I have
seen very little code make use of this convenience, while the real
world data, mathematics, and computer science theory usually use
big endian bit numbering.

> ....  If God
> meant bit numbering to start on the left, she'd have started with 1.

You better read some of the bibles from the beginning of computer time.
Lots of smart people provided insights into these discussions a very
long time ago.


	-- Dan

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Re^2: char type is unsigned with PPC gcc?
  2000-04-20 15:34 ` Re^2: char type is unsigned with PPC gcc? Dan Malek
@ 2000-04-20 21:38   ` Gabriel Paubert
  2000-04-20 21:50     ` Dan Malek
  0 siblings, 1 reply; 3+ messages in thread
From: Gabriel Paubert @ 2000-04-20 21:38 UTC (permalink / raw)
  To: Dan Malek; +Cc: W4OQM, linuxppc-embedded


On Thu, 20 Apr 2000, Dan Malek wrote:

>
> W4OQM@aol.com wrote:
>
> > How about:
> >
> > #define BIT_8_OF_BYTE   (1<<0)
> > #define BIT_8_OF_WORD   (1<<8)
> > #define BIT_8_OF_LONG   (1<<24)
>
> Whoa there, youngster.....let the old man tell you a story.
> There is computing equipment in the world where a byte is not
> eight bits, a word is not two bytes, and so on.

Indeed, AFAICT the only way in (ISO?) C to know the bit size of an item is
to use CHAR_BIT*sizeof(type) (on Texas DSPs for example sizeif(int) is 1
and CHAR_BIT is 32, but it is only safe to assume 8 for portability).

There were (are?) machines baroque enough to not permit C to be
implemented with the usual conventions used for the other (FORTRAN, COBOL,
PL/1, whatever) languages (down to having to use a different character
size...)

> Left to right (big endian) bit numbering works just fine on
> these computers, as it does on all big endian machines.
>
> On big endian byte ordered machines, you also want big endian
> bit ordering.  If I load some address as a byte, word, long word
> or whatever, bit 6 is still bit 6.  You probably don't remember
> the bit instruction mess when Motorola added that to the '020......

That's the biggest blunder in the whole 68000 family design IMHO.

> If you had a programming language that supported bit array objects,
> how would you index the array?  How would that map into larger
> objects?

Exactly.

>
>
> > ...  Personally, the left-to-right bit numbering drives me nuts.
>
>
> That's because you are worried about the implementation details and
> not solving the data communication application.  Look at flow of
> bits through a data communication system.  Serial stream, left to
> right.  Start numbering bits anywhere, stop anywhere, left to right
> makes perfect sense.  Map any aribitary object on top of the bits,
> still makes sense.  Look at coding theory and the algorithms they
> write...left to right bit ordering.

Dan, brother ;-) I have the impression we are the only 2 people on this
planet (aliens anywhere ?)^W^W^W^Wmailing list thinking this way. But of
course we know that we are right ;-)

>
> The 2^n bit numbering is a mathematical convenience that can be
> easily hidden behind programming language macros or functions.  I have
> seen very little code make use of this convenience,

100% agreed...

	Regards,
	Gabriel.


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Re^2: char type is unsigned with PPC gcc?
  2000-04-20 21:38   ` Gabriel Paubert
@ 2000-04-20 21:50     ` Dan Malek
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Malek @ 2000-04-20 21:50 UTC (permalink / raw)
  To: Gabriel Paubert; +Cc: linuxppc-embedded


Gabriel Paubert wrote:

> Dan, brother ;-) I have the impression we are the only 2 people on this
> planet (aliens anywhere ?)^W^W^W^Wmailing list thinking this way. But of
> course we know that we are right ;-)

I think it is a secret club because there were a limited number of
secrect decoder rings :-).  I received lots of e-mail that didn't
copy the embedded list.....

I am just disappointed that Darwin hasn't had time to work on
the extinction of little endian in our predominantly left-to-right
world.

Anyway, this has been fun and I have to get back to real work......


	-- Dan

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-04-20 21:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <c9.39dbd77.262faf77@aol.com>
2000-04-20 15:34 ` Re^2: char type is unsigned with PPC gcc? Dan Malek
2000-04-20 21:38   ` Gabriel Paubert
2000-04-20 21:50     ` Dan Malek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).