Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem #1. (25 points) Clanguage, Stack Data Placement, Pointers Consider the following C program. Assume that the register SP at the beginning points to OXOE00.

image text in transcribedimage text in transcribed

Problem #1. (25 points) Clanguage, Stack Data Placement, Pointers Consider the following C program. Assume that the register SP at the beginning points to OXOE00. Answer the following questions. Assume all variables are allocated on the stack, and in the order as they appear in the program. A. (10 points) Illustrate the content of the stack at the moment before the statement at line 7 is executed. B. (10 points) Comment the code (lines 7-11) indicating the result of each statement. Illustrate the content of the stack at the end of execution of the statement in line 11. What are the contents of arrays x and carr? C. (5 points) Show assembly language implementation of the statement at lines 5, 7, and 8 (think like compiler would do; it knows where the variables are placed relatively to the current top of the stack). NOWN volatile unsigned int x[4]={1, -32768, 0, -3) volatile char carr[4]={'A', '1', '2', 'a'}; volatile long int z = 65536; volatile char *P_C = carr; // volatile int *p_i = x; 8 9 *(_C + 2) += 'b'; p_i = p i + 3; *p_i += *(p_i -6); P_C = P_C + 3; * _C = A'; // // // // // 10 11 Address M[15..O] Comment volatile unsigned int x[4]={1, -32768, 0, -3}; volatile char carr[4]={'A', '1', '2', 'a'); volatile long int z = 65536; volatile char *p_c = carr; volatile int *p_i = x; // *(_C + 2) += "6'; p_i = pi + 3; *p_i += *(p_i -6); P_C = P_C + 3; *P_C = 'A'; // // // // // Address M[15..O] Comment ; line 5: long int - p_= x; ; * (p_c + 2) == 167 ; line 8: p_i = P_3 + 3; Problem #1. (25 points) Clanguage, Stack Data Placement, Pointers Consider the following C program. Assume that the register SP at the beginning points to OXOE00. Answer the following questions. Assume all variables are allocated on the stack, and in the order as they appear in the program. A. (10 points) Illustrate the content of the stack at the moment before the statement at line 7 is executed. B. (10 points) Comment the code (lines 7-11) indicating the result of each statement. Illustrate the content of the stack at the end of execution of the statement in line 11. What are the contents of arrays x and carr? C. (5 points) Show assembly language implementation of the statement at lines 5, 7, and 8 (think like compiler would do; it knows where the variables are placed relatively to the current top of the stack). NOWN volatile unsigned int x[4]={1, -32768, 0, -3) volatile char carr[4]={'A', '1', '2', 'a'}; volatile long int z = 65536; volatile char *P_C = carr; // volatile int *p_i = x; 8 9 *(_C + 2) += 'b'; p_i = p i + 3; *p_i += *(p_i -6); P_C = P_C + 3; * _C = A'; // // // // // 10 11 Address M[15..O] Comment volatile unsigned int x[4]={1, -32768, 0, -3}; volatile char carr[4]={'A', '1', '2', 'a'); volatile long int z = 65536; volatile char *p_c = carr; volatile int *p_i = x; // *(_C + 2) += "6'; p_i = pi + 3; *p_i += *(p_i -6); P_C = P_C + 3; *P_C = 'A'; // // // // // Address M[15..O] Comment ; line 5: long int - p_= x; ; * (p_c + 2) == 167 ; line 8: p_i = P_3 + 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

Please help me solve it all

Answered: 1 week ago