1 / 31

Branch Addressing

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

keck
Download Presentation

Branch Addressing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Branch Addressing beq $s1, $s2, Label if ($s1 = =$s2) go to Label op rs rt address 17 18 4 address 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 address * 4 = address : 00 This is PC-relative addressing

  2. Addressing in Jumps jump j Label go to Label op address 2 address 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 address * 4 = address:00 This is Pseudodirect Addressing. Note: 256 MB word boundaries – 64M Instructions

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

  4. Possible Representations of Negative Numbers Sign Magnitude: One's Two's Complement Complement 000 = +0 000 = +0 000 = +0 001 = +1 001 = +1 001 = +1 010 = +2 010 = +2 010 = +2 011 = +3 011 = +3 011 = +3 100 = -0 100 = -3 100 = -4 101 = -1 101 = -2 101 = -3 110 = -2 110 = -1 110 = -2 111 = -3 111 = -0 111 = -1 • Issues: balance, number of zeros, ease of operations • Which one is best? Why?

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

  6. 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

  7. Representing Numbers in Binary For negative numbers, use Two’s Complement, defined as Two's Complement 000 = +0 001 = +1 010 = +2 Binary 011 = +3 100 = -4 8 – 4= 4 100 101 = -3 8 – 3= 5 101 110 = -2 8 – 2= 6 110 111 = -1 8 – 1= 7 111

  8. 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

  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

  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 Two’s Complement can be formed by Complementing each bit and adding 1.

  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 What is the Two’s Complement of a Negative Number?

  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? 2n – 2n – c = 2n – 2n + c = c Since

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

  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 For x < 0 and y < 0 Normal addition works!

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

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

  21. 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

  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 15 = 001111 110000 complement -15 = 110001 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 = 64 – 15 = 49 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 + 15 100111 001111 110110

  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 001010 -10

  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 39 001111 15 110110 54 001010 64 - 54 -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 001111 110110 001010 -10 25 +(-15) 011001 110001 001010 +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 (-15)+(-14) 110001 110010 100011

  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 011101 - 29

  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) 100111 110001 011000 + 24??? 25 +(-15) 011001 110001 001010 +10 (-15)+(-14) 110001 110010 100011 011101 - 29

More Related