Question: For this problem, consider following C code 0 uint64_t y; 1 int main (int argc , char argv[]) uint64 t z 5: my-funct(44); y

 For this problem, consider following C code 0 uint64_t y; 1

For this problem, consider following C code 0 uint64_t y; 1 int main (int argc , char argv[]) \ uint64 t z 5: my-funct(44); y z=z+y ; = 5 8 uint64_t my_funct (uint64_t x) [ if (x == 0) { return 0; 12 return (x + my_funct (x>>2)); 13 1) What value is left in z at the end of main ()? 2) Compile the function my_funct ) into LEGv8 assembly (do not compile main)). Be sure to use the calling conventions discussed in lecture and used in lab. Note, converting the function into a simple, non recursive loop will yield 0 points 3) Draw a small diagram of the application's memory map. On the diagram mark (approximately) where the following data and instructions would be located. Be sure to also label these regions of memory by their conventional names. Assume the compiler allocates memory for C variables y and z instead of optimizing to temporary registers or constants a) The application's instructions. b) The variable "uint64_t y". c) The variable "uint64_t z". d) The return address back to the main () routine after my_funct () has been called 4) Assuming your function is called by main with an argument of x-9 (ie. my_funct (9)). How many words are stored on the stack at its deepest point? Note, you do not have to account for ARMv8's stack pointer alignment requirement for this question 5) Draw a diagram showing the full contents of the stack at this point. Assume that the BL instruction is used to call my funct() from main() is at address 0x30100 and that my funct() starts at address 0x40000 in memory. You may also assume that the $SP register is set to OxOFFF3000 when the BL instruction is called the first time For this problem, consider following C code 0 uint64_t y; 1 int main (int argc , char argv[]) \ uint64 t z 5: my-funct(44); y z=z+y ; = 5 8 uint64_t my_funct (uint64_t x) [ if (x == 0) { return 0; 12 return (x + my_funct (x>>2)); 13 1) What value is left in z at the end of main ()? 2) Compile the function my_funct ) into LEGv8 assembly (do not compile main)). Be sure to use the calling conventions discussed in lecture and used in lab. Note, converting the function into a simple, non recursive loop will yield 0 points 3) Draw a small diagram of the application's memory map. On the diagram mark (approximately) where the following data and instructions would be located. Be sure to also label these regions of memory by their conventional names. Assume the compiler allocates memory for C variables y and z instead of optimizing to temporary registers or constants a) The application's instructions. b) The variable "uint64_t y". c) The variable "uint64_t z". d) The return address back to the main () routine after my_funct () has been called 4) Assuming your function is called by main with an argument of x-9 (ie. my_funct (9)). How many words are stored on the stack at its deepest point? Note, you do not have to account for ARMv8's stack pointer alignment requirement for this question 5) Draw a diagram showing the full contents of the stack at this point. Assume that the BL instruction is used to call my funct() from main() is at address 0x30100 and that my funct() starts at address 0x40000 in memory. You may also assume that the $SP register is set to OxOFFF3000 when the BL instruction is called the first time

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!