1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Bài tập Kỹ thuật vi xử lý - DTVT - BKDN (bài07)

2 9 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Bài tập Kỹ thuật vi xử lý - DTVT - BKDN

Homework #7 C Language (Ch 12) and Types, Operators, and Expression (Ch 13) In order to automate the grading process, please follow the exact instructions for each questions and don’t use extra or unnecessary words (8 points) Create a C project in Code Composer Essentials using the eZ430X board (MSP430F2274 device) Compile the C code below and check the disassembly list, registers, and memory contents to answer the following questions Use Code Composer Essentials’ debugging tool if needed (Give your answers in hexadecimal with “0x”.) a What is the initial value loaded in the stack pointer (R1) when main() starts ? b In which memory location is the return address of the main() function stored? c Where (memory address) on the stack is the variable a stored ? d Where (memory address) on the stack is the variable b stored ? e Where (memory address) on the stack is the variable c stored ? f Where (memory address) in the memory is the global variable g stored ? g What address mode is used to access the local variables a, b, and c? h What address mode is used to access the global variable g? #include "msp430x22x4.h" int g; void main(void) { int a, b, c; } a b g c = = = = 2; 3; 5; a + b + g; (2 points) a If x = and y = 2, what is assigned to the variable x when the statement x = y; is executed? (2 points) a What is the statement to reset bits and of a variable x to 0? (Use a 4-digit hexadecimal number to represent the mask) b What is the statement to set bits and of a variable x to 1? (Use a 4-digit hexadecimal number to represent the mask) (4 points) a If x=10, y=2, and z=3, what is assigned to the variable x when the statement x *= y + 1; is executed? b If x=10, y=2, and z=3, what is assigned to the variable x when the statement x *= ++y * z + is executed? c What is assigned to the variable y in part b? d What is assigned to the variable z in part b? BYU, ECEn/CS 124 Homework #7 Page 1/2 (4 points) The following C code has syntax errors Use Code Composer Essentials to compile this code if you cannot find all errors Give the line numbers where these errors locate 10 11 12 13 14 15 16 17 /************************************ blinky.c: Software Toggle P1.0 ************************************ #include "msp430x22x4.h" #define MAX_LENGTH 80; void main(void) { int i = for (i=0; i b ){ printf(“%d %d\n”, a++, b ); } else { printf(“%d %d\n”, c , ++b); } if (a

Ngày đăng: 06/09/2021, 17:29

Xem thêm:

TỪ KHÓA LIÊN QUAN

w