Question 1: Pointers (20 pts) Complete the table below (i.e. fill in the memory
ID: 1930613 • Letter: Q
Question
Question 1: Pointers (20 pts)Complete the table below (i.e. fill in the memory map) to show the state of memory after the following C fragment has been executed. Assume the ATmega128 platform, and all the variables are in the stack (and thus the storage is allocated from high address to low address).
typedef struct pixel
Address Variable Name Value
1000 num_array[2]
999 num_array[1]
998 num_array[0]
997 ptr_array
996
995 x
994 y
993 my_pixel.psize
992 my_pixel.blue
991 my_pixel.green
990 my_pixel.red
989 pixel_ptr
988
{
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char psize;
} pixel_t;
char num_array[3] = {5, 10, 15};
unsigned char* ptr_array;
unsigned char x;
unsigned char y;
pixel_t my_pixel = {25, 15, 55, 40};
pixel_t *pixel_ptr = &my_pixel;
ptr_array = num_array;
x = *ptr_array;
ptr_array++;
y = *ptr_array;
ptr_array = &num_array[2];
pixel_ptr++;
pixel_ptr++;
(*pixel_ptr).green = 5;
Explanation / Answer
The stack. This is never stored in a program file but is an area of memory used ... When you call a method the chip will first of all store the return address (ie ... point to a piece of code that behaves as if the power has been switched off then back on. ... This memory will be zapped to zeroes so that all these unitialised variables ...
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.