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

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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);printf("a....
View Full Document

This note was uploaded on 12/04/2011 for the course CPE 323 taught by Professor Milenkovic during the Spring '10 term at University of Alabama - Huntsville.

Page1 / 5

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online