Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Edit question Hi there! just some notes. -This is in ARM assembly architecture -

ID: 3591120 • Letter: E

Question

Edit question

Hi there! just some notes.

-This is in ARM assembly architecture

-i also do not mind if you provide the code in C i can translate it. just confused since teacher didnt teach us how to work with little endian and big endian. thank you :)

QUESTION: Write a function to change variable from little endian to big endian notation in assembly. The basic structure of the function is given in the attached assembly language file. You are expected to complete the function int toBigEndian(int variable) which converts an integer variable passed from little endian to big endian notation. The conversion function should simply accept the number variable and flip the order of the bytes and return the resulting value.

For example Variable passed to function 0xAABBCCDD

The value returned from the function 0xDDCCBBAA

Complete the function implementation which takes a little endian notation as input and returns the big endian notation of the given value from the function as given in the above example.

The function with the basic commands for the function entry and exit / return are already given. Use the given function and fill in your implementation where it is specified as below:

TO DO: Your implementation /*

should be here

*/

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"

Explanation / Answer

To answer both the given guestion, I have used C-programming language.

Answer for QUESTION 1.

#include <stdio.h>

int toBigEndian(int variable[ ], int n)
{
    int *v, i, j=0;
    for(i=n-1;i>=0;i++)
    {
        v[j] = variable[i];
        j++;
    }
    variable = v;
}

int main(void) {
   int i, n, *variable, num;
   printf(" Enter the length of variable: ");
   scanf("%d", &n);
   printf(" Enter the variable in Little Endian : ");
   for(i=0;i<n;i++)
    {
        scanf("%d",&num);
        variable[i] = num;
    }
    toBigEndian(variable, n);
    printf(" The variable in Big Endian : ");
    for(i=0;i<n;i++)
    {
        printf("%c",variable[i]);
    }
   return 0;
}

Answer for QUESTION 2.

#include <stdio.h>

int isLittleEndian(int variable[], int n)
{
    int i, j=0, check=1;
    for(i=1;i<n;i++)
    {
        if(variable[j]>variable[i])
        {
            check = 0;
        }
        j++;
    }
    return check;
}

int main(void) {
   int i, n, *variable, num, check;
   printf(" Enter the length of variable: ");
   scanf("%d", &n);
   printf(" Enter the variable in Little Endian : ");
   for(i=0;i<n;i++)
    {
        scanf("%d",&num);
        variable[i] = num;
    }
    check = isLittleEndian(variable, n);
    if(check == 0)
    {
        printf(" The variable is in Big Endian.");
    }
    else
    {
        printf(" The variable is in Little Endian.");
    }
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote