How to Decide Given Processor Is Little Endian or Big Endian

 What are Little Endian and Big Endian

Big endian and little endian are the  terms,that tells the order in which sequence bytes are stored in memory.

Big Endian

Big Endian-Most Significant byte is stored at the lowest address.

Little Endian 

Little Endian-lest Significant byte is stored at he lowest address.

The binary representation of integer 5193 in 2 bytes is



0001  0100       0100 1001
 MS byte            LS byte


The following  figure show how this integer is stored in different byte order

Little Endian 

 Address:-


 2000            0100    1001  LSB
 2001            0001    0100  MSB


Big Endian 

Address:-


2000         0001 0100  LSB
2001         0100 1001  MSB

By write a below program we can find little Endian machine and Big Endian machine.


#include<stdio.h>
int main()
{
    unsigned int k=1;
    char*c=(char*)&k;
    if(*c)
    printf("Little endian");
    else
    printf("Big endian");
    getchar();
    return(0);
    system("pause");
}         
                                       
                                              

  

0 comments:

Post a Comment

Don't Forget to comment

About Me

My photo

HI i am mohammed  a Embedded Software Developer ,SEO specialist,Electronic engineer   Read more

ads