{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw3.s10 - CPE/EE 323 Introduction to Embedded Computer...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CPE/EE 323 Introduction to Embedded Computer Systems Homework III 1(40) 2(30) 3(30) Total __ __ __ ____ Problem #1 (40 points) Consider the following C program. Assume all variables are allocated on the stack in the order as they appear in the program (e.g., the last variable will be on the top of the stack). 1 #include "io430.h" 2 #include "stdio.h" 3 4 int main(void) { 5 // Stop watchdog timer to prevent time out reset 6 WDTCTL = WDTPW + WDTHOLD; 7 int x = 5; // an integer x 8 int *p_x; // a pointer to int 9 int y1; // an integer y1 (uninitialized) 10 long int y2, y3; // long integers y2, y3 11 long int *p_y2; // a pointer to long integer 12 char mya[10] = "Hello!"; // character array 13 char *p_mya; // pointer to character 14 15 p_x = &x; // p_x points to x 16 *p_x = 7; 17 *p_x = *p_x + 2; 18 y1 = 10 + x; // new value to y1 19 y2 = -1; 20 p_y2 = &y2; // pointer p_y2 points to y2 21 *p_y2 = y2 + 3; 22 y3 = 10 + *p_y2; 23 p_mya = mya; // p_mya points to array mya 24 p_mya = p_mya + 3; 25 *p_mya = 'L'; 26 27 // display addresses and variables in terminal i/o 28 printf("a.x=%x, x=%x\n", &x, x); 29 printf("a.p_x=%x, p_x=%x\n", &p_x, p_x); 30 printf("a.y1=%x, y1=%x\n", &y1, y1); 31 printf("a.y2=%x, y2=%lx\n", &y2, y2);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}