From 1430406399618877486
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,738ae3371beb3408
X-Google-Attributes: gidf78e5,public
From: Ron Natalie <ron@sensor.com>
Subject: Re: portable method of determining endianness byte order.
Date: 1999/12/07
Message-ID: <384D2A84.5C743996@sensor.com>#1/1
X-Deja-AN: 557760543
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <38329967.470B6CED@hqs.mid.gmeds.com> <38359FF5.AB0B77E9@zetec.com> <t73dtnacpa.fsf@calumny.jyacc.com> <g1pNRNAk6GR4Ew21@robinton.demon.co.uk> <t7ln7e8spx.fsf@calumny.jyacc.com> <3846CA71.5792390E@tribble.com> <t7n1rn7h1w.fsf@calumny.jyacc.com>
X-Original-Date: Tue, 07 Dec 1999 10:40:52 -0500
X-Accept-Language: en
Content-Type: text/plain; charset=x-user-defined
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: ariel.ucs.unimelb.edu.au 944585077 26762 128.250.37.153 (7 Dec 1999 16:44:37 GMT)
Organization: Sensor Systems
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAOE05h+EDnX0m9pzZAQE3dQF/bwX+WcRUofLhQxnrBo3JKSKuV2X5J8RL YLnHOqUxVsSXlgrjUIZBY/lUqgN8kZ9a =js9T
Mime-Version: 1.0
NNTP-Posting-Date: 7 Dec 1999 16:44:37 GMT
Newsgroups: comp.std.c++

Hyman Rosen wrote:
> 
> David R Tribble <david@tribble.com> writes:
> > No, you're thinking of its predecessor, the PDP-11.
> > VAX integers (32 bits) were little-endian (e.g., 0x11223344 was
> > <0x44,0x33,0x22,0x11>), while PDP-11 long ints (32 bits) were
> > mixed-endian (e.g., 0x11223344 was <0x22,0x11,0x44,0x33>).
> 
> Sounds right. When I first started programming in C, it was on a
> PDP-11/45, using a compiler which didn't implement longs or unions,
> and which represented structure fields as absolute offsets, so that
> no two structures could have the same field names unless the fields
> were at the same offset in each structure. That was around 1979.
> 

Ah yes, those were the days.  That's why most system code from
UNIX uses structure members with the type uniquer (u_uid) at the
beginning as the tags needed to be unique.

I still remember the following construct in the kernel:

#define	PS	0177776

struct {
   int integ;
}

   if(PS->integ) ...


The problem is that the PDP-11 didn't really support 32 bit math.
The implementation put the high order word of a long into the second
place word in memory because that way it would be compatibile with
16 bit values when sloppily mixed.

-Ron p&P6
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



