Register initial value final value mar 0x300b 0x300d

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
Image of page 6

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)
Image of page 7
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
Image of page 8

Subscribe to view the full document.

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

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"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

Ask a question for free

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern