Question: 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
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
*/
.global toBigEndian
.data
// declare any global variables here
.text
toBigEndian:
mov r12,r13 // save stack pointer into register r12
sub sp,#32 // reserve 32 bytes of space for local variables
push {lr} // push link register onto stack -- make sure you pop it out before you return
// Your solution here
pop {lr} // pop link register from stack
mov sp,r12 // restore the stack pointer -- Please note stack pointer should be equal to the
// value it had when you entered the function .
mov pc,lr // return from the function by copying link register into program counter
/*
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
