Exam 3B and Solutions

# Register initial value final value mar 0x300b 0x300d

• Test Prep
• 9

This preview shows page 6 - 9 out of 9 pages.

Register Initial Value Final Value MAR 0X300B 0x300D (Also accepted 0x300E assuming you would have fetched HALT instruction) MDR 0xDCBA 0x4444 (Also accepted F025 for the same reason above) R0 0x4444 0x4444 R1 0x300D 0x300D R2 0x300A 0x4444

Subscribe to view the full document.

7 Problem 7 (3 points) Assume that you wrote a program which asks the user to enter a number and then identifies whether it is a prime number or a composite number. When you run the program, you see that it created an illegal operation. (a) (1 point) What kind of error have you committed? Explain. Syntax error (accepted other errors as long as the explanation was valid) (b) (1 point) What are the different options available to you to trace this program and identify the wrong instruction? Explain the options. Breakpoints, Watchpoints, etc (c) (1 point) Now assume that you were able to trace the bug in the program and after you modified it, assume that it ran successfully (without creating any illegal instructions) and gave the correct output when the user input was 5. However, when the user then gave an input of 50000, it did not give the correct answer. What kind of error do you think you have committed now? Explain the error. Data error (accepted other errors as long as the explanation was valid)
8 Problem 8 (4 points) Assume that your friend John has written a large LC-3 program which is working correctly. Column A in the table below shows 4 sets of instructions which are part of his working program. Now, suppose you replaced one set of instructions in Column A with the corresponding set of instructions in Column B. Without making assumptions about any register or memory location, specify if the program is still guaranteed to work correctly. Justify your answer. Set # Column A Column B 1 0101 001 001 1 00000 (R1 <- R1 AND 0) 0101 010 010 1 00000 (R2 <- R2 AND 0) 0000 010 000000010 (Branch if Z to PC’+2) 0101 010 010 1 00000 (R2 <- R2 AND 0) 0101 001 001 1 00000 (R1 <- R1 AND 0) 0000 010 000000010 (Branch if Z to PC’+2) Answer/Justification: Yes, they are identical 2 0001 001 001 1 11111 (R1 <- R1 - 1) 0001 010 010 1 11111 (R2 <- R2 -1 ) 0000 010 000000010 (Branch if Z to PC’+2) 0001 010 010 1 11111 (R2 <- R2 -1 ) 0001 001 001 1 11111 (R1 <- R1 - 1) 0000 010 000000010 (Branch if Z to PC’+2) Answer/Justification: No because condition flags on the left column are set based on value of R1. But condition flags on right are set based on the value of R0. So branch could happen on one and not happen on the other. So there

Subscribe to view the full document.

• Spring '08
• Wood
• Computer Architecture, SEPTA Regional Rail, Machine code, Jaguar Racing, Addressing mode

{[ snackBarMessage ]}

###### "Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern