Question: Hello! Can you help me with this assignment? Translate these functions in C to ARM assembly using the given template: 1) This function isLittleEndian returns
Hello! Can you help me with this assignment?
Translate these functions in C to ARM assembly using the given template:
1) This function isLittleEndian returns 1 if the architecture is Little Endian and 0 if it is Big Endian
int isLittleEndian(int variable[], int n) { int i, j=0, check=1; for(i=1;i
Use this template and complete the translation from C to assembly.
.global isLittleEndian
.data // declare any global variables here .text isLittleEndian: 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
2) This function 'toBigEndian(int variable)' 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.
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; }
Use this template and complete the translation from C to assembly.
.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
Get step-by-step solutions from verified subject matter experts
