Play and learn 300 000+ tabs online

Wednesday, August 11, 2010

Little Endian Big Endian OS

A beginner introduction to Endianness.

Introduction

A long time ago, in a very remote island known as Lilliput, society was split into two factions: Big-Endians who opened their soft-boiled eggs at the larger end ("the primitive way") and Little-Endians who broke their eggs at the smaller end. As the Emperor commanded all his subjects to break the smaller end, this resulted in a civil war with dramatic consequences: 11.000 people have, at several times, suffered death rather than submitting to breaking their eggs at the smaller end. Eventually, the 'Little-Endian' vs. 'Big-Endian' feud carried over into the world of computing as well, where it refers to the order in which bytes in multi-byte numbers should be stored, most-significant first (Big-Endian) or least-significant first (Little-Endian) to be more precise

  • Big-Endian means that the most significant byte of any multibyte data field is stored at the lowest memory address, which is also the address of the larger field.
  • Little-Endian means that the least significant byte of any multibyte data field is stored at the lowest memory address, which is also the address of the larger field.

For example, consider the 32-bit number, 0xDEADBEEF. Following the Big-Endian convention, a computer will store it as follows:

clip_image001[4]

Figure 1. Big-Endian: The most significant byte is stored at the lowest byte address.

Whereas architectures that follow the Little-Endian rules will store it as depicted in Figure 2:

clip_image002[4]

Figure 2. Little-endian: Least significant byte is stored at the lowest byte address.

The Intel x86 family and Digital Equipment Corporation architectures (PDP-11, VAX, Alpha) are representatives of Little-Endian, while the Sun SPARC, IBM 360/370, and Motorola 68000 and 88000 architectures are Big-Endians. Still, other architectures such as PowerPC, MIPS, and Intel�s 64 IA-64 are Bi-Endian, i.e. they are capable of operating in either Big-Endian or Little-Endian mode. [1].

Endianess is also referred to as the NUXI problem. Imagine the word UNIX stored in two 2-byte words. In a Big-Endian system, it would be stored as UNIX. In a little-endian system, it would be stored as NUXI.

Function

Purpose

ntohs

Convert a 16-bit quantity from network byte order to host byte order (Big-Endian to Little-Endian).

ntohl

Convert a 32-bit quantity from network byte order to host byte order (Big-Endian to Little-Endian).

htons

Convert a 16-bit quantity from host byte order to network byte order (Little-Endian to Big-Endian).

htonl

Convert a 32-bit quantity from host byte order to network byte order (Little-Endian to Big-Endian).

Linux is Little endian

Solaris is Big endian

A) Little-Endian is low emissions byte address in the low-memory, high emissions bytes in the memory address of the high end.
  B) is the Big-Endian emissions in the high-byte memory address low-, and low emissions in memory byte address the high end.
  C) network byte order: TCP / IP protocol layers byte sequence will be defined as the Big-

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.