Presentation is loading. Please wait.

Presentation is loading. Please wait.

Branch Addressing op rs rt address 4 1718 address beq $s1, $s2, Label if ($s1 = =$s2) go to Label 6 bits 5 bits 5 bits 16 bits effective 32 bit address.

Similar presentations


Presentation on theme: "Branch Addressing op rs rt address 4 1718 address beq $s1, $s2, Label if ($s1 = =$s2) go to Label 6 bits 5 bits 5 bits 16 bits effective 32 bit address."— Presentation transcript:

1

2 Branch Addressing op rs rt address 4 1718 address beq $s1, $s2, Label if ($s1 = =$s2) go to Label 6 bits 5 bits 5 bits 16 bits effective 32 bit address = ( PC + 4 ) + ( address * 4 ) Next Instruction address is the relative number of instructions This is PC-relative addressing address * 4 = address : 00

3 Addressing in Jumps op address 2address jump j Label go to Label 6 bits 26 bits The complete 32 bit address is : address 00 4 bits 26 bits 2 bits Upper 4 bits of the Program Counter, PC jump uses word addresses This is Pseudodirect Addressing. Note: 256 MB word boundaries – 64M Instructions address * 4 = address:00

4 Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: –Implementing the Architecture

5 Sign Magnitude : One's Two's Complement Complement 000 = +0000 = +0000 = +0 001 = +1001 = +1001 = +1 010 = +2010 = +2010 = +2 011 = +3011 = +3011 = +3 100 = -0100 = -3100 = -4 101 = -1101 = -2101 = -3 110 = -2110 = -1110 = -2 111 = -3111 = -0111 = -1 Issues: balance, number of zeros, ease of operations Which one is best? Why? Possible Representations of Negative Numbers

6 Representing Numbers in Binary Consider n-1 bits n-1, n-2..., 3, 2, 1. ( bit n will be sign bit)

7 Representing Numbers in Binary Consider n-1 bits n-1, n-2..., 3, 2, 1. ( bit n will be sign bit) For positive numbers For negative numbers, use Two’s Complement, defined as

8 Representing Numbers in Binary For negative numbers, use Two’s Complement, defined as Two's Complement 000 = +0 001 = +1 010 = +2Binary 011 = +3 100 = -48 – 4= 4100 101 = -38 – 3= 5101 110 = -28 – 2= 6110 111 = -18 – 1= 7111

9 Representing Numbers in Binary Consider n-1 bits n-1, n-2..., 3, 2, 1. ( bit n will be sign bit) For negative numbers, use Two’s Complement 1 0 0 0... 0 - 1 0 1 1 1... 1

10 Representing Numbers in Binary Consider n-1 bits n-1, n-2..., 3, 2, 1. ( bit n will be sign bit) For negative numbers, use Two’s Complement

11 Representing Numbers in Binary Consider n-1 bits n-1, n-2..., 3, 2, 1. ( bit n will be sign bit) For negative numbers, use Two’s Complement

12 Representing Numbers in Binary Consider n-1 bits n-1, n-2..., 3, 2, 1. ( bit n will be sign bit) For negative numbers, use Two’s Complement

13 Representing Numbers in Binary Consider n-1 bits n-1, n-2..., 3, 2, 1. ( bit n will be sign bit) For negative numbers, use Two’s Complement Two’s Complement can be formed by Complementing each bit and adding 1.

14 Representing Numbers in Binary Consider n-1 bits n-1, n-2..., 3, 2, 1. ( bit n will be sign bit) For negative numbers, use Two’s Complement What is the Two’s Complement of a Negative Number?

15 Representing Numbers in Binary Consider n-1 bits n-1, n-2..., 3, 2, 1. ( bit n will be sign bit) For negative numbers, use Two’s Complement What is the Two’s Complement of a Negative Number? 2 n – 2 n – c = 2 n – 2 n + c = c Since

16 Two’s Complement Addition For x > 0 and y < 0

17 Two’s Complement Addition For x > 0 and y < 0

18 Two’s Complement Addition For x > 0 and y < 0

19 Two’s Complement Addition For x > 0 and y < 0 For x < 0 and y < 0 Normal addition works!

20 For n = 6 : weights : 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement

21 For n = 6 : weights : 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement -25 = 100111

22 For n = 6 : weights : 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement -25 = 100111 = 2 -25 = 64 – 25 = 39 6

23 For n = 6 : weights : 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement -25 = 100111 = 2 -25 = 64 – 25 = 39 15 = 001111 110000 complement -15 = 110001 6

24 For n = 6 : weights : 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement -25 = 100111 = 2 -25 = 64 – 25 = 39 15 = 001111 110000 complement -15 = 110001 = 64 – 15 = 49 6

25 For n = 6 : weights 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement -25 = 100111 = 2 -25 = 64 – 25 = 39 15 = 001111 110000 complement -15 = 110001 = 64 – 15 = 49 6 -25 + 15 100111 001111 110110

26 For n = 6 : weights 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement -25 = 100111 = 2 -25 = 64 – 25 = 39 15 = 001111 110000 complement -15 = 110001 = 64 – 15 = 49 6 -25 + 15 100111 001111 110110 001010 -10

27 For n = 6 : weights 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement -25 = 100111 = 2 -25 = 64 – 25 = 39 15 = 001111 110000 complement -15 = 110001 = 64 – 15 = 49 6 -25 + 15 100111 39 001111 15 110110 54 001010 64 - 54 -10

28 For n = 6 : weights 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement -25 = 100111 = 2 -25 = 64 – 25 = 39 15 = 001111 110000 complement -15 = 110001 = 64 – 15 = 49 6 -25 + 15 100111 001111 110110 001010 -10 25 +(-15) 011001 110001 001010 +10

29 For n = 6 : weights 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement -25 = 100111 = 2 -25 = 64 – 25 = 39 15 = 001111 110000 complement -15 = 110001 = 64 – 15 = 49 6 -25 + 15 100111 001111 110110 001010 -10 25 +(-15) 011001 110001 001010 +10 (-15)+(-14) 110001 110010 100011

30 For n = 6 : weights 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement -25 = 100111 = 2 -25 = 64 – 25 = 39 15 = 001111 110000 complement -15 = 110001 = 64 – 15 = 49 6 -25 + 15 100111 001111 110110 001010 -10 25 +(-15) 011001 110001 001010 +10 (-15)+(-14) 110001 110010 100011 011101 - 29

31 For n = 6 : weights 32, 16, 8, 4, 2, 1 - 31 < numbers < +31 25 = 011001 100110 complement -25 = 100111 = 2 -25 = 64 – 25 = 39 15 = 001111 110000 complement -15 = 110001 = 64 – 15 = 49 6 -25 + 15 100111 001111 110110 001010 -10 25 +(-15) 011001 110001 001010 +10 (-15)+(-14) 110001 110010 100011 011101 - 29 (-25)+(-15) 100111 110001 011000 + 24???


Download ppt "Branch Addressing op rs rt address 4 1718 address beq $s1, $s2, Label if ($s1 = =$s2) go to Label 6 bits 5 bits 5 bits 16 bits effective 32 bit address."

Similar presentations


Ads by Google