s03exam1_sol - Name: _ # CprE 211 Spring 2003 Exam 1...

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

View Full Document Right Arrow Icon
Name: ______________________ # 1 CprE 211 – Spring 2003 Exam 1 Solution Last Name (printed) _________________________ First Name (printed) _________________________ Signature _________________________ ISU ID Number _________________________ Lab Section _____________________ Instructions: Do not open this exam booklet until told to do so. Closed book. Closed notes. Calculator allowed. One-page, two-sided help sheet allowed. Be prepared to show this sheet to the instructor or submit it with your exam packet. Do all work in space provided. You must show your work to receive credit. Clearly indicate the answer you want counted. Make assumptions if necessary to work problems. Be sure to complete the five lines above. Cheating will not be tolerated by the instructor or your classmates and will result in a severe penalty. This is a 75-minute exam. Question Points Possible Points 1 45 2 35 3 20 Total 100
Background image of page 1

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

View Full DocumentRight Arrow Icon
Name: ______________________ # 2 1. Embedded Programming using C (45 points) a. You are given the following pointer variable declarations: pLED1 is a pointer to an 8-bit output port connected to an LED bargraph; pSw1 is a pointer to an 8-bit input port connected to a DIP switch. char * pLED1; // 1 is ON, 0 is OFF char * pSw1; These are C statements and expressions that access the I/O ports, where the blanks refer to operand values in hex. A. *pLED1 = *pLED1 | 0x _______; B. *pLED1 = *pLED1 & 0x _______; C. *pSw1 | 0x _______ D. *pSw1 & 0x _______ E. *pSw1 = *pSw1 | 0x _______; F. *pSw1 = *pSw1 & 0x _______; G. (*pSw1 & 0x _______) == 0x ________ // 2 values Each row of the table below gives an I/O operation to be performed using one of the statements. Fill in the table as follows: select the appropriate statement (A-G) and determine the operand value(s) to perform each operation listed in the right-hand column. Only the bit(s) listed should be affected (do not change the values of unaffected bits). Statement A – G Hex Value in blank(s) Operation Performed by Statement i. B EF Turn off Bit 4 of LED & 11101111 ii. A 20 Turn on Bit 5 of LED | 00100000 iii. A 84 Turn on Bits 2 and 7 of LED | 10000100 iv. D G 80 80, 80 Test whether Bit 7 of Sw is 1 v. G 60, 60 Test whether Bit 5 and Bit 6 of Sw are both 1 vi. G 08, 00 Test whether Bit 3 of Sw is 0 vii. G 1C, 0C Test whether bit field [4:2] in Sw equals (0,1,1) (i.e., Bit 4 = 0, Bit 3 = 1, Bit 2 = 1) & 00011100
Background image of page 2
Name: ______________________ # 3 b. Write a C expression that will yield a word consisting of the most significant byte of x , and the remaining bytes of y . For operands x = 0x89ABCDEF and y = 0x76543210 , this would give 0x89543210 . ( (x & 0xFF000000) | (y & 0x00FFFFFF) )
Background image of page 3

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

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

Page1 / 11

s03exam1_sol - Name: _ # CprE 211 Spring 2003 Exam 1...

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

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