Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem #2. C language, Stack Data Placement, Pointers Consider the following program. Assume that the register SP at the beginning points to Ox0900. Answer the

image text in transcribed

Problem #2. C language, Stack Data Placement, Pointers Consider the following program. Assume that the register SP at the beginning points to Ox0900. Answer the following questions. Assume all variables are allocated on the stack, and in the order as they appear in the program. ASCII code for character 'O' is 48. int main( void ) { volatile unsigned long int a = 67; volatile int c = -6, d = 5; volatile char mych = { 'o', '2', '4', '8' }; volatile unsigned long int *lpa = &a; volatile int *pi = &d; lpa = lpa - 2; // *lpa = *lpa + 513;// pi++; *pi = *pi + c; // Value/Address Fill in the following table by determining the values/addresses given below. Question? The number of bytes allocated on the stack for the variable declared in line 2. The number of bytes allocated on the stack for the character array declared in line 4. 3 The number of bytes allocated on the stack for all variables declared in lines 2-6. Value of mych[O] after initialization performed in line 4. Address of variable a (&a). Value of Ipa at the moment after the statement in line 7 is executed. Value of *Ipa at the moment after the statement in line 8 is executed. 9 10 Value of mych[O) at the moment after the statement in line 8 is executed. Value of pi at the moment after the statement in line 9 is executed. Value of *pi at the moment after the statement in line 10 is executed. Ox0900 TOS Comments Problem #2. C language, Stack Data Placement, Pointers Consider the following program. Assume that the register SP at the beginning points to Ox0900. Answer the following questions. Assume all variables are allocated on the stack, and in the order as they appear in the program. ASCII code for character 'O' is 48. int main( void ) { volatile unsigned long int a = 67; volatile int c = -6, d = 5; volatile char mych = { 'o', '2', '4', '8' }; volatile unsigned long int *lpa = &a; volatile int *pi = &d; lpa = lpa - 2; // *lpa = *lpa + 513;// pi++; *pi = *pi + c; // Value/Address Fill in the following table by determining the values/addresses given below. Question? The number of bytes allocated on the stack for the variable declared in line 2. The number of bytes allocated on the stack for the character array declared in line 4. 3 The number of bytes allocated on the stack for all variables declared in lines 2-6. Value of mych[O] after initialization performed in line 4. Address of variable a (&a). Value of Ipa at the moment after the statement in line 7 is executed. Value of *Ipa at the moment after the statement in line 8 is executed. 9 10 Value of mych[O) at the moment after the statement in line 8 is executed. Value of pi at the moment after the statement in line 9 is executed. Value of *pi at the moment after the statement in line 10 is executed. Ox0900 TOS Comments

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions