Write a function to check if a machine uses little endian or big endian notation
ID: 3679155 • 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 isl_ittleEndian(). 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
#include <stdio.h>
unsigned int n = 0x9876543210;
char *c = (char*) &n;
int isLittleEndian(){
return (int)*c;
}
int main(void) {
if (isLittleEndian(n))
{
printf ("Underlying architecture is little endian. ");
}
else
{
printf ("Underlying architecture is big endian. ");
}
return 0;
}
Assembly level language code:
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.