Branch Addressing op rs rt address 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
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
Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: –Implementing the Architecture
Sign Magnitude : One's Two's Complement Complement 000 = = = = = = = = = = = = = = = = = = = = = = = = -1 Issues: balance, number of zeros, ease of operations Which one is best? Why? Possible Representations of Negative Numbers
Representing Numbers in Binary Consider n-1 bits n-1, n-2..., 3, 2, 1. ( bit n will be sign bit)
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
Representing Numbers in Binary For negative numbers, use Two’s Complement, defined as Two's Complement 000 = = = +2Binary 011 = = -48 – 4= = -38 – 3= = -28 – 2= = -18 – 1= 7111
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
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
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
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
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.
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?
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
Two’s Complement Addition For x > 0 and y < 0
Two’s Complement Addition For x > 0 and y < 0
Two’s Complement Addition For x > 0 and y < 0
Two’s Complement Addition For x > 0 and y < 0 For x < 0 and y < 0 Normal addition works!
For n = 6 : weights : 32, 16, 8, 4, 2, < numbers < = complement
For n = 6 : weights : 32, 16, 8, 4, 2, < numbers < = complement -25 =
For n = 6 : weights : 32, 16, 8, 4, 2, < numbers < = complement -25 = = = 64 – 25 = 39 6
For n = 6 : weights : 32, 16, 8, 4, 2, < numbers < = complement -25 = = = 64 – 25 = = complement -15 =
For n = 6 : weights : 32, 16, 8, 4, 2, < numbers < = complement -25 = = = 64 – 25 = = complement -15 = = 64 – 15 = 49 6
For n = 6 : weights 32, 16, 8, 4, 2, < numbers < = complement -25 = = = 64 – 25 = = complement -15 = = 64 – 15 =
For n = 6 : weights 32, 16, 8, 4, 2, < numbers < = complement -25 = = = 64 – 25 = = complement -15 = = 64 – 15 =
For n = 6 : weights 32, 16, 8, 4, 2, < numbers < = complement -25 = = = 64 – 25 = = complement -15 = = 64 – 15 =
For n = 6 : weights 32, 16, 8, 4, 2, < numbers < = complement -25 = = = 64 – 25 = = complement -15 = = 64 – 15 = (-15)
For n = 6 : weights 32, 16, 8, 4, 2, < numbers < = complement -25 = = = 64 – 25 = = complement -15 = = 64 – 15 = (-15) (-15)+(-14)
For n = 6 : weights 32, 16, 8, 4, 2, < numbers < = complement -25 = = = 64 – 25 = = complement -15 = = 64 – 15 = (-15) (-15)+(-14)
For n = 6 : weights 32, 16, 8, 4, 2, < numbers < = complement -25 = = = 64 – 25 = = complement -15 = = 64 – 15 = (-15) (-15)+(-14) (-25)+(-15) ???