Skip to contentSkip to conversation

char type is unsigned with PPC gcc?

DISCUSSION Dan Malek 2 participants 3 messages Apr 20, 2000 1 message not in the archive

lore
Share & tools
lore

Dan Malek

author
#1 lore raw
In reply to a message not in the archive
Quoted 5 lines · [email protected] 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?

Quoted 1 line

... 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.

Quoted 2 lines

.... 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/

#2 lore raw
Quoted 5 lines · Dan Malek
Quoted 2 lines · [email protected] wrote:

How about:

Quoted 7 lines
Quoted 3 lines
#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...)

Quoted 7 lines

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.

Quoted 3 lines

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.

Quoted 5 lines
Quoted 3 lines

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

Quoted 7 lines

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 ;-)

Quoted 4 lines

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/

author
#3 lore raw
Quoted 3 lines · Gabriel Paubert

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/