c109f02t1 - CSE 109 Test 1 Wednesday 9 October 2002...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 109 Test 1 Wednesday 9 October 2002 ====================SUGGESTED ANSWERS================================ 1. For each of (a), (b), and (c), provide fragments of OP2 code (lines of instructions) to accomplish the given task. In each case, assume the first line of the fragment is placed in memory location 35. Recall the op-codes: read (0), write (1), load immediate (2), store (3), add (4), subtract (5), multiply (6), divide (7), jump (8), compare and jump (9). (a) halt if the contents of location 3 is greater than 0 (b) halt if the contents of location 3 is greater than 2 (c) write out the number 1 if the contents of location 3 is the number 3 ---------------------------------------------------------------------- (a) 2000000 [35] clear 4003000 [36] load contents of 3 9038000 [37] jump to 0 if positive, otherwise goto next line [38] (b) 2000002 [35] put 2 in accumulator 5003000 [36] subtract 2 from contents of location 3 9038000 [37] go to 0 if number is > 0 (c) 2000003 [35] put 3 in the accumulator 5003000 [36] subtract 3 from contents of location 3 9040040 [37] skip next 2 instructions if not 0 2000001 [38] put 1 in accum 1000000 [39] write contents 2. Write a program which does nothing unless it is called with command
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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