Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

Problem #2. C language, Stack Data Placement, Pointers Consider the following C program. Assume that the register SP at the beginning points to 0x0800. 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 '0' is 48 (x30 are allecated on the stacka volatile unsigned long int a 27; volatile volatilechar volatile unsigned lon volatile char *pcmych: 4 6 7 + 513 9 cpc+3 10 Value/Address HQuestion? 1 The number of bytes allocated on the stack for the variable declared in line 2. 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. 4Value of mychIO] after initialization performed in line 4. 5 Address of variable a (&a) 6 Address of character array mych 7 Address of variable c 8 Value of lpa at the momentafterthe statement in line 7 is executed. 9 Value of *lpa at the moment after the statement in line 8 is executed. 10 Value of mychlo] at the moment after the statement in line 8 is executed. 11 Value of pi at the moment afterthe statement in line 9 is executed. 12 Value of piat the moment after the statement in line 10 is executed Stack (the table may be used to sketch the stack, but will not be graded) Problem #2. C language, Stack Data Placement, Pointers Consider the following C program. Assume that the register SP at the beginning points to 0x0800. 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 '0' is 48 (x30 are allecated on the stacka volatile unsigned long int a 27; volatile volatilechar volatile unsigned lon volatile char *pcmych: 4 6 7 + 513 9 cpc+3 10 Value/Address HQuestion? 1 The number of bytes allocated on the stack for the variable declared in line 2. 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. 4Value of mychIO] after initialization performed in line 4. 5 Address of variable a (&a) 6 Address of character array mych 7 Address of variable c 8 Value of lpa at the momentafterthe statement in line 7 is executed. 9 Value of *lpa at the moment after the statement in line 8 is executed. 10 Value of mychlo] at the moment after the statement in line 8 is executed. 11 Value of pi at the moment afterthe statement in line 9 is executed. 12 Value of piat the moment after the statement in line 10 is executed Stack (the table may be used to sketch the stack, but will not be graded)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions