Tuesday, April 15, 2008

Endianness... C'mon now....

I have forever loved x86. However if I had to nitpick one thing I think the Intel engineers should change (but now it is not even practical to do so) is the computer architecture's Endianness.

For those of you unfamiliar with the term Endianness, it refers to how any given microprocessor stores more than one byte in memory. There are two forms of Endianness, Little Endian and Big Endian (aka network byte order). In Little Endian processors, the little end comes first, when I say little end I mean the byte furthest to the right. For example, take the following two bytes 12h 34h (h denotes hex), in memory it would be backwards 34h 12h. In Big Endianness the order would have stayed the same. Some Big Endian processors include: MIPS and SPARC.

The following code in C displays the endianness of your machine:



#include <stdio.h>

int main()
{

unsigned short word = 0x1234;
unsigned char * ptr = (unsigned char *)&word;

if(ptr[0] == 0x12)
printf("Big Endian\n");
else
printf("Little Endian\n");

return(0);

}



Now some of your are probably asking yourself... "What the hell is the point of using Little Endian format if it just confuses things more? Isn't it harder to implement in a processor?" The fact is there are no clear advantages to using either format, and it does not matter at all to the chip, because it is not aware of its own circuitry. The only immediate benefits to changing over to a standard uniform endianness (all big endianness) is that we wouldn't have to worry about endian portability issues (things like using htons() and whatnot). It is the fact that these worries along exist that pisses me off :-\

So now that you heard my rant on endianness and how It pisses me off sometimes. Tell me what you think..

Sunday, April 13, 2008

Introduction

Hi, I go by the name in70x... The content you find here will be mostly my rants about computer related shit... you probably won't find anything useful here but... screw it... I am bored...