Unformatted text preview: ... ._.._...J CS 310B Spring 2007 4. P&P 5.12 We can trust the result in R2 if the addition of R0 and R1 give us a number that can be represented in 16
bits. That is, if the two numbers, when added, give us a number less than or equal to 2”  1 .. 65,535.
If the sum is greater than 65,535, we have overﬂow. We are given that R0{15] equals R1[15], but is
different from R2 5], which leads to the following two cases (Notice that bit 15 is the most signiﬁcant
bit and the numbers are unsigned): 1. ROIIS] = mus} = o; R2[15] = 1
In this case, RD and R1 contain numbers las than or equal to 2“ — 1 = 32,767 (sinoe RD[15] =
Rillﬁ] = 0), and their sum contained in R2 is greater than 32,767 (since R2[15] = l) and utmost
65,534 (since 32,767 + 32,767 = 65,534). Since the sum is less than 65,535, there is no overﬂow
and we can trust the result in R2. 2. ROIIS] = Rl[15} = l; R2[15] = 0
In this case, RB and 111 both contain numbers greater than 215 — 1 = 32, 767 (since R0[15] = Rl[15]
= l), and their sum is at least 65,536 (since 32,768 + 32,768 = 65,536), causing an overﬂow result
that cannot be fully represented in the 16bit register R2. Therefore, the result in R2 cannot be
trusted. [E 5. Hz? 5.14 Writing a sequence of instructions to implement the OR operation: 0R R3, R1, R2. Remember that
(A' AND B’)’ = A OR. B by DeMorgan’s Law. (1) 1001 100 001 111111 HOT M, 31 (2) 1001 101 010 111111 1101' R5, R2 (3) 0101 110 100 000 101 AND M. M. R5 (4) 1001 011 110 111111 1101' RS, 116 6. PSLP 5.22 As was mentioned in the email to the class, use the following errata from the book's website:
Replace : 13010 1110 1110 0011 0001
Hit]: : $3010 1110 0110 0011 1111 The disassembly of the instructions and what each instruction does is shown below: x3010 1110 0110 0011 1111 LEA Ra, 23F 3 RS It 13011 + 20033  13050
13011 0110 1000 1100 0000 1.0!! R4, B3, #0 3 lid = meSOSO] I 17014
13012 0110 1101 0000 0000 [.03 RE, M, #0 3 R6 = m[:7014] = 11233 Therefore, the value in R6 after the execution of the instructions is x1238. We could replace the above
sequence of instructions with the following single instruction: x3010 1010 1100 0011 1111 1.01 R6. 33F ; B6 = mmhenExSO11 + x003F] 7. P85? 5.26 (a) The total memory size is 64K bytes, which means there are 2" bytes. Therefore, we need 16 bits
in the PC to be able to address all of memory. Note: In reality, however, although our memory is byte addressable, we know every instruction will
be 2 bytes, so the PC will always point to an even address (see the table below). Since we only
need our PC to point to every other address, we only really need 15 bits for the PC. The address
of instructions can then be obtained by multiplying the contents of PC by 2, or equivalently by Paee'an'S ...
View
Full Document
 Spring '08
 Fussell

Click to edit the document details