Duane Royed Dsilva
Duane Royed Dsilva

Reputation: 101

Does PIC16f877a microcontroller follow little endian byte ordering system?

I have compiled this simple code on XC8 compiler and loaded the hex file into Picsimlab - simulator board (board 4) having PIC16f877a microcontroller.

    unsigned int x = 1;
    char *ptr = (char *) &x;

    if (*ptr == 1)
    {

        clcd_print("little Endian", LINE1(0));
    }
    else
    {
        clcd_print("big Endian", LINE1(0));
    } 

output: little endian

So can we deducde that Xc8 compiler follows little endian byte ordering system to program PIC16f877a?
Does that also mean that PIC16f877a stores variables into its data memory using little endian byte ordering system?

Can you please provide link to documentation mentioning about the byte ordering system followed by PIC16f877a and XC8 compiler?

Upvotes: 2

Views: 1623

Answers (1)

Mike
Mike

Reputation: 4288

Have a look at the user guide of the XC8 compiler. In chapter 5.4.2 you could read about the endianism of integer variables:

All integer values are represented in little endian format with the Least Significant Byte (LSB) at the lower address

Little endian is the default and only used endianism for all xc compilers.

The PIC16 family is a 8 Bit controller, so the controller itself don't had to care about endianess.

Upvotes: 7

Related Questions