delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/10/12/05:34:16

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Newbie's question about big- and little-endians
Date: 12 Oct 2001 09:16:28 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 30
Message-ID: <9q6cdc$b91$1@nets3.rz.RWTH-Aachen.DE>
References: <8af9182 DOT 0110120054 DOT 62e8c03 AT posting DOT google DOT com>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1002878188 11553 137.226.32.75 (12 Oct 2001 09:16:28 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 12 Oct 2001 09:16:28 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Tomasz Bywalec <bywale-t AT zszosw DOT petex DOT com DOT pl> wrote:
> 2. a<<4.

>    And here is my first question: will the result be 0x23 0x40
> (0x2340) on first and 0x41 0x20 (0x2041) on second machine (just
> contents of memory were shifted)  or byte-order doesn't mean, and the
> result will be always 0x2340 (0x23 0x40 on first and 0x40 0x23 on
> second).

No. The results of C operators are defined based on *values*, not bit
patterns.  I.e. " << 4" is required to do exactly the same as " * 16".
Endianness doesn't change that.

> 3. Some boolean-logic operation: for example a & 0xFF00 - will it be
> always 0x1200 or 0x1200 on first and 0x3400 on second machine?

The FF of 0xFF will always end up in the same place as the 0x12 of
0x1234, by definition.  So again, no endianness problem.

> 4. And now really fool question - 0x12 0x34 and 0x34 0x12 - which one
> is big-endian and which is little-endian. According to Ralph Brown's
> Interrupt List Glossary the first one is big-endian, 

Correct. The meaning comes from "Gulliver's Travels", where the giants
had a religious war about whether to crack open an egg at the big end
or the little end of it.  I.e. 'big-endian' means: big end first.

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019