简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM