PDP-endian
By chys on January 13th, 2010Today I checked <endian.h> and found an unfamiliar line:
#define __PDP_ENDIAN 3412
I knew there were little-endian machines (e.g. all Intel CPUs*) and big-endian machines (e.g. PowerPC†), but was really unaware of the so-called PDP-endian. It’s word-wise big-endian, and within a word‡, little-endian.
char c[5] = {};
*(int32_t *)c = 0x61626364;
puts (c);
ASCII supposed, this program segment produces “ABCD” on a big-endian machine, and “DCBA” on a little-endian machine. It seems, on a PDP-11, it should output “BADC”.
Little-endian is friendly to programmers (in some sense). Big-endian is intuitive. But what’s PDP-endian for?
* Itanium supports both little-endian and big-endian. Windows and Linux for Itanium both use little endian.
† PowerPC supports both little-endian and big-endian. Macintosh used big endian.
‡ The term “word” here stands for two bytes. This usage is believed to be wrong though used by Intel, but I just don’t find a good substitute.
No related posts.
Tags: dev

PDP-endian was a compatibility hack for the VAX, iirc.
PDP-endian is for a PDP-11 :). That’s what you get for manipulating 32-bit values in a 16-bit architecture.