Write a function to check if a machine uses little endian or big endian notation
ID: 3679222 • Letter: W
Question
Write a function to check if a machine uses little endian or big endian notation. The basic structure of the program is given in the attached assembly language file. You are expected to write the function int isLittleEndian(). Complete the function implementation to return the following values from the function. The function int isLittleEndian () should return the following values: 1 if the architecture is "Little Endian" 0 if the architecture is "Big Endian" You may use the Homework2 as reference for the C program logic and implement the same in assembly. Also, pay attention to the return values and make appropriate changes.Explanation / Answer
int x = 0x76543210; char *c = (char*) &x; Big endian format: ------------------ Byte address | 0x01 | 0x02 | 0x03 | 0x04 | +++++++++++++++++++++++++++++ Byte content | 0x76 | 0x54 | 0x32 | 0x10 | Little endian format: --------------------- Byte address | 0x01 | 0x02 | 0x03 | 0x04 | +++++++++++++++++++++++++++++ Byte content | 0x10 | 0x32 | 0x54 | 0x76 | rite a C program to find out if the underlying architecture is little endian or big endian. */ #include int main () { unsigned int x = 0x76543210; char *c = (char*) &x; printf ("*c is: 0x%x ", *c); if (*c == 0x10) { printf ("Underlying architecture is little endian. "); } else { printf ("Underlying architecture is big endian. "); } return 0; } * Function check_for_endianness() returns 1, if architecture is little endian, 0 in case of big endian. */ int check_for_endianness() { unsigned int x = 1; char *c = (char*) &x; return (int)*c; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.