{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

s03exam2_sol

# s03exam2_sol - Name CprE 211 Spring 2003 Exam 2 Solution...

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

Name: ______________________ # 1 CprE 211 – Spring 2003 Exam 2 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. RCPU Reference Manual 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 30 2 40 3 30 Total 100 NOTE: Unless specified otherwise, you should assume that for questions involving C or assembly code, the target is the MPC555 used in the lab.

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

View Full Document
Name: ______________________ # 2 1. Embedded Programming using Assembly (30 points) “What is the result” means what registers/memory are affected and what are the values. a. Assume the contents of register r6 is (r6)= 0x0000FFFF, and r23 is (r23)= 0x00FFFFA3. i. What is the result of the instruction: or r23, r23, r6 r23 ! (r23) | (r6) = 0x00FFFFA3 | 0x0000FFFF = 0x00FFFFFF Changes register contents: R23 00FFFFFF 3 pts. ii. What is the result of adding the period: or . r23, r23, r6 (be specific) Changes the Condition Register, depending on whether result is less than, greater than, or equal to 0. In this case, the result is greater than 0. So the GT bit of CR0 is set to true (1). CR0 [LT GT EQ SO] ! 0100 3 pts. b. Consider the following memory dump and PowerPC registers. Assume that byte-ordering is big endian (big byte first, i.e., MSB at lower address) and memory addresses are 32 bits wide. Each question is independent. Address Memory Contents 30001FF8 25 24 5B 1A AC 57 9C 8D 30002000 00 FE 25 24 5B 1A EE 05 30002008 AC AE 81 83 45 67 89 25 30002010 01 23 55 3F AC CB F0 8D Register Register Contents R20 30002000 R21 30001FFF R22 0000000A R23 FFFFFFEE i. What is the result of the instruction: lbz r22, 5 (r21) M b [5+0x30001FFF] = M b [0x30002004] = 0x5B, so r22 ! 0x0000005B Changes register contents: R22 0000005B 3 pts. ii. What is the result of the instruction: sthx r21, r20, r22 r21 = 0x30001FFF M h [r20 + r22] = M h [0x30002000+0x0000000A] = M h [0x3000200A] ! 0x1FFF Changes memory contents: 30002008 AC AE 1F FF 45 67 89 25 3 pts. iii. Is the branch to “next” taken? YES or NO This checks the value in r22. cmpwi r22, 0x0A 0x0000000A – 0x0A = 0
Name: ______________________ # 3 beq next = 0? YES 3 pts. iv. Is the branch to “next” taken? YES or NO cmpw r23, r22 0xFFFFFFEE-0x0000000A = -18 -(+10) = -28 = 0xFFFFFFE4 blt next < 0? YES This treats the contents of r22 and r23 as signed numbers. Since r23 is a negative number (-18) and r22 is a positive number (+10), r23 is less than r22. 2 pts. c. Write assembly code to place the address IO_DIGITAL_INPUT_ DIP_1 into register R6. Refer to the defines.h file at the end of the exam packet.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 13

s03exam2_sol - Name CprE 211 Spring 2003 Exam 2 Solution...

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

View Full Document
Ask a homework question - tutors are online