Upload
marcus-mills
View
220
Download
0
Embed Size (px)
DESCRIPTION
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
Citation preview
Computer Architecture CSE 3322Lecture 9
TEST 1 – Tuesday March 3Lectures 1 - 8, Ch 1,2
Web Sitecrystal.uta.edu/~cse3322
Branch Addressing
op rs rt address
4 17 18 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
2 address
jump j Label go to Label
6 bits 26 bitsThe complete 32 bit address is :
address 00
4 bits 26 bits 2 bits
Upper 4 bits of the Program Counter, PCjump 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 = +0 000 = +0 000 = +0001 = +1 001 = +1 001 = +1010 = +2 010 = +2 010 = +2011 = +3 011 = +3 011 = +3100 = -0 100 = -3 100 = -4101 = -1 101 = -2 101 = -3110 = -2 110 = -1 110 = -2111 = -3 111 = -0 111 = -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)
01
12
32
21
11
1
22...222 cccccc nn
nn
in
ii
Representing Numbers in Binary
Consider n-1 bits n-1, n-2 ..., 3, 2, 1. ( bit n will be sign bit)
01
12
32
21
11
1
22...222 cccccc nn
nn
in
ii
12 1max nc For positive numbers 0nc
For negative numbers, use Two’s Complement, defined as
cn 2
Representing Numbers in Binary
For negative numbers, use Two’s Complement, defined as
cn 2 Two's Complement 000 = +0
001 = +1010 = +2 Binary011 = +3100 = -4 8 – 4= 4 100
101 = -3 8 – 3= 5 101110 = -2 8 – 2= 6 110111 = -1 8 – 1= 7 111
cn 2
Representing Numbers in Binary
Consider n-1 bits n-1, n-2 ..., 3, 2, 1. ( bit n will be sign bit)
01
12
32
21
11
1
22...222 cccccc nn
nn
in
ii
For negative numbers, use Two’s Complement
c)(c nn 1122
cn 2
1 0 0 0 . . . 0- 10 1 1 1 . . . 1
Representing Numbers in Binary
Consider n-1 bits n-1, n-2 ..., 3, 2, 1. ( bit n will be sign bit)
01
12
32
21
11
1
22...222 cccccc nn
nn
in
ii
For negative numbers, use Two’s Complement
)c...c...c()...(c)(c innn 111111122 2112
cn 2
Representing Numbers in Binary
Consider n-1 bits n-1, n-2 ..., 3, 2, 1. ( bit n will be sign bit)
01
12
32
21
11
1
22...222 cccccc nn
nn
in
ii
For negative numbers, use Two’s Complement
110
111111122 2112
ii
innn
c , c if
)c...c...c()...(c)(c
cn 2
Representing Numbers in Binary
Consider n-1 bits n-1, n-2 ..., 3, 2, 1. ( bit n will be sign bit)
01
12
32
21
11
1
22...222 cccccc nn
nn
in
ii
For negative numbers, use Two’s Complement
1 so, 01 , 1 if
11 , 0 if
1)......()1...111(1)12(2 2112
iiii
ii
innn
cccc
cc
ccccc
cn 2
Representing Numbers in Binary
Consider n-1 bits n-1, n-2 ..., 3, 2, 1. ( bit n will be sign bit)
01
12
32
21
11
1
22...222 cccccc nn
nn
in
ii
For negative numbers, use Two’s Complement
1 so, 01 , 1 if
11 , 0 if
1)......()1...111(1)12(2 2112
iiii
ii
innn
cccc
cc
ccccc
Two’s Complement can be formed by Complementingeach bit and adding 1.
cn 2
Representing Numbers in Binary
Consider n-1 bits n-1, n-2 ..., 3, 2, 1. ( bit n will be sign bit)
01
12
32
21
11
1
22...222 cccccc nn
nn
in
ii
For negative numbers, use Two’s Complement cn 2What 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)
01
12
32
21
11
1
22...222 cccccc nn
nn
in
ii
For negative numbers, use Two’s Complement cn 2What is the Two’s Complement of a Negative Number?
2n – 2n – c = 2n – 2n + c = c
Since 12 1max nc
Two’s Complement Addition
For x > 0 and y < 0
yxyxyx nn 22
cn 2
Two’s Complement Addition
For x > 0 and y < 0
left is yx so, c requires then yx if
yxyxyx
nn
nn
12
22
cn 2
Two’s Complement Addition
For x > 0 and y < 0
xy of complement s two' the)xy(2 y then xif
left is yx so, c requires2 y then xif
yx2y2xyx
n
1nn
nn
cn 2
Two’s Complement Addition
For x > 0 and y < 0
xy of complement s two' the)xy(2 y then xif
left is yx so, c requires2 y then xif
yx2y2xyx
n
1nn
nn
cn 2
For x < 0 and y < 0
remains yx of complement s two' theandlost is c requires 2
)]yx(2[2y2x2yx
1nn
nnnn
Normal addition works!
For n = 6 : weights : 32, 16, 8, 4, 2, 1 - 31 < numbers < +31
25 = 011001 100110 complement
For n = 6 : weights : 32, 16, 8, 4, 2, 1 - 31 < numbers < +31
25 = 011001 100110 complement-25 = 100111
For n = 6 : weights : 32, 16, 8, 4, 2, 1 - 31 < numbers < +31
25 = 011001 100110 complement-25 = 100111 = 2 -25 = 64 – 25 = 396
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
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
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 + 15100111001111110110
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 + 15100111001111110110001010 -10
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 + 15100111 39001111 15110110 54001010 64 - 54 -10
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 + 15100111001111110110001010 -10
25 +(-15)011001110001001010 +10
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 + 15100111001111110110001010 -10
25 +(-15)011001110001001010 +10
(-15)+(-14)110001110010100011
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 + 15100111001111110110001010 -10
25 +(-15)011001110001001010 +10
(-15)+(-14)110001110010100011011101 - 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 + 15100111001111110110001010 -10
25 +(-15)011001110001001010 +10
(-15)+(-14)110001110010100011011101 - 29
(-25)+(-15)100111110001011000 + 24???