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

From: bywale-t AT zszosw DOT petex DOT com DOT pl (Tomasz Bywalec)
Newsgroups: comp.os.msdos.djgpp
Subject: Newbie's question about big- and little-endians
Date: 12 Oct 2001 01:54:54 -0700
Organization: http://groups.google.com/
Lines: 28
Message-ID: <8af9182.0110120054.62e8c03@posting.google.com>
NNTP-Posting-Host: 195.164.188.17
X-Trace: posting.google.com 1002876895 15349 127.0.0.1 (12 Oct 2001 08:54:55 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: 12 Oct 2001 08:54:55 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Suppose that we have two machines: first with big-endian byte-order
and second with little-endian. We're running the same program written
in C on them:

1. a=0x1234.

   So on one machine it will be stored as 0x12 0x34 and on second as
0x34 0x12.

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

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

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, however i've
heard that it's not true (because big-endian maybe means that it has
"biggest (highest in order) byte" at end - so 0x34 0x12). How it
really is?

Thanks for any help, and again sorry for my poor english. :-)

- Raw text -


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