Untitled-2 - .J CS 310B Spring 2007 4 P&P 5.12 We can...

Info icon This preview shows page 1. Sign up to view the full content.

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

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 overflow. 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 significant 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] = Rillfi] = 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 overflow 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 overflow result that cannot be fully represented in the 16-bit 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 11111-1 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 e-mail 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

{[ 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