Presentation is loading. Please wait.

Presentation is loading. Please wait.

Solutions and Examples. 2.36 or $t0, $zero, $zero# i = 0 li $t1, 101# $t1 = 101 for:beq $t0, $t1, exit# if (i==101) exit add $t2, $t0, $a1 lw $s1, 0($t2)#

Similar presentations


Presentation on theme: "Solutions and Examples. 2.36 or $t0, $zero, $zero# i = 0 li $t1, 101# $t1 = 101 for:beq $t0, $t1, exit# if (i==101) exit add $t2, $t0, $a1 lw $s1, 0($t2)#"— Presentation transcript:

1 Solutions and Examples

2 2.36 or $t0, $zero, $zero# i = 0 li $t1, 101# $t1 = 101 for:beq $t0, $t1, exit# if (i==101) exit add $t2, $t0, $a1 lw $s1, 0($t2)# $s1=b[i] add $s1, $s1, $s0 # $s1=b[i]+c add $t2, $t0, $a0 sw $s1, 0($t2)# a[i]=$s1 addi $t0, $t0, 1# i=i+1 j for exit:

3 2.36 Number of instructions executed: 2 + 101*8 = 810 Memory data reference: 101 reads + 101 writes

4 3.27 Add & Sub (16 bits) x=0000000001011011# 91 y=0000000000001101# 13 a) addition x+y=0000000001101000# 104 b) subtraction -y=1111111111110011# 2’s complement x-y=0000000001001110# 78

5 3.27 Multiplication (16 bits) productmultiplier Init0000000000000000 0000000000001101 +x*10000000001011011 =0000000001011011 Shift right0000000000101101 1000000000000110 +x*00000000000000000 =0000000000101101 Shift right0000000000010110 1100000000000011 +x*10000000001011011 =0000000001110001 Shift right0000000000111000 1110000000000001 +x*10000000001011011 =0000000010010011 Shift right0000000001001001 1111000000000000... Final0000000000000000 0000010010011111

6 3.27 Division (16 bits) remainder dividend & quotient Init0000000000000000 0000000001011011 –divisor1111111111110011 =1111111111110011 Restore0000000000000000 0000000001011011 0 Shift left0000000000000000 0000000010110110 –divisor 1111111111110011 =1111111111110011 Restore0000000000000000 0000000010110110 0 Shift left0000000000000000 0000000101101100... Shift left 0000000000001011 0110000000000000 –divisor 1111111111110011 =1111111111110011 Restore0000000000001011 0110000000000000 0

7 3.27 Division (cont’d) remainder dividend & quotient Shift left 0000000000010110 1100000000000000 –divisor 1111111111110011 =0000000000001001 Ok0000000000001001 1100000000000000 1 Shift left0000000000010011 1000000000000001 –divisor 1111111111110011 =0000000000000110 Ok0000000000000110 1000000000000001 1 Shift left0000000000001101 0000000000000011 –divisor 1111111111110011 =0000000000000000 Ok0000000000000000 00000000000000111

8 3.42 Floating-point Addition X=0101 1111 1011 1110 0100 0000 0000 0000 ExponentFraction 1011 11111011 1110 0100 0000 0000 0000 Y=1011 1110 1110 0000 0000 0000 0000 0000 ExponentFraction 0111 11011110 0000 0000 0000 0000 0000 Srl:0111 11100111 0000 0000 0000 0000 0000 Srl:0111 11110011 1000 0000 0000 0000 0000... Srl:1011 11110000 0000 0000 0000 0000 0000 X+Y=1011 11111011 1110 0100 0000 0000 0000 IEEE:0101 1111 1011 1110 0100 0000 0000 0000

9 3.42 FP Multiplication X=0101 1111 1011 1110 0100 0000 0000 0000 ExponentFraction 1011 11111011 1110 0100 0000 0000 0000 Y=1011 1110 1110 0000 0000 0000 0000 0000 ExponentFraction 0111 11011110 0000 0000 0000 0000 0000 X*Y= Exponent1011 1111 + 0111 1101 – 0111 1111 = 1011 1101 Fraction1 0110 1100 1111 0000 0000 0000 Normalize0 1011 0110 0111 1000 0000 0000, exp=1011 1110 IEEE=1101 1111 0011 0110 0111 1000 0000 0000


Download ppt "Solutions and Examples. 2.36 or $t0, $zero, $zero# i = 0 li $t1, 101# $t1 = 101 for:beq $t0, $t1, exit# if (i==101) exit add $t2, $t0, $a1 lw $s1, 0($t2)#"

Similar presentations


Ads by Google