C109f02t1 - 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

Info iconThis 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
Background image of page 1

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

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

This note was uploaded on 03/09/2008 for the course CSE 109 taught by Professor Kay during the Spring '08 term at Lehigh University .

Page1 / 2

C109f02t1 - 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

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

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