hw7_sol - Loop: compare, adrCurr, adrEnd, adrC cjump, adrC,...

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

View Full Document Right Arrow Icon
Homework #7 Solutions EECS203 TA: Jing Xin 1. The possible encodings vary. Following is one example: instruction 0-3 4-7 8-11 12-15 add 0000 adr1 adr2 adr3 substract 0001 adr1 adr2 adr3 compare 0010 adr1 adr2 adr3 cjump 0011 adr1 adr2 adr3 jump 0100 adr xxxx xxxx halt 0101 xxxx xxxx xxxx input 0110 adr xxxx xxxx output 0111 adr xxxx xxxx 2. See below: start: input, adrX input, adrY add, adrU, adrX, 0 add, adrV, adrY, 0 jump, LCM LCM: compare, adrX, adrY, adrC cjump, adrC, xEqualGreater, yGreater xEqualGreater: compare, adrY, adrX, adrC cjump, adrC, report, xGreater xGreater: substract, adrX, adrX, adrY add, adrV, adrU, adrV jump, LCM yGreater: substract, adrY, adrY, adrX add, adrV, adrU, adrV jump, LCM report: add, adrU, adrU, adrV RightShift, adrU, adrU, 1 output, adrU halt 3. Assume the array is stored in [adrA, adrA+1, . .., adrA+9] and the result is stored in adrMax. See below: start: input, adrA add, adrCurr, adrA, 0 add, adrEnd, adrA, 9
Background image of page 1

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

View Full DocumentRight Arrow Icon
add, adrMax, adrA, 0
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Loop: compare, adrCurr, adrEnd, adrC cjump, adrC, report, continue ;; check if we reach the end continue: add, adrCurr, adrCurr, 1 compare, adrCurr, adrMax, adrC cjump, adrC, updateMax, Loop updateMax: add adrMax, adrCurr, 0 ;; update the maximum value jump Loop report: output, adrMax halt 4. For the width of PC, it depends on several factors: first, whether there is any instruction which will use the PC address. Second, whether the designer gives the specification on how big the memory is. In our case, since we’re told that our memory is limited to 255 addresses, we can use 8-bits for the PC. 5. Again, this answer is open to some variation, but some of the better ideas to change RSE would be to add extra instructions. For example, we can add useful operations including a branch when greater than zero....
View Full Document

This note was uploaded on 01/12/2011 for the course EECS 203 taught by Professor Wu during the Winter '08 term at Northwestern.

Page1 / 2

hw7_sol - Loop: compare, adrCurr, adrEnd, adrC cjump, adrC,...

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