Upload
nilesh-agrawal
View
221
Download
0
Embed Size (px)
Citation preview
7/29/2019 Lect 7 : IIT Computer Architecture
1/33
CS222:
(b)Architecture
Space
RISC/CISC
Dr.A.Sahu
De t of Com . Sc. & En .
IndianInstituteofTechnologyGuwahati
1
7/29/2019 Lect 7 : IIT Computer Architecture
2/33
ActivationRecordinRecursion:
MergeSort
Activation
Record
Features
of
MIPS
ISA Otherarchitecturalvariations
Examples
7/29/2019 Lect 7 : IIT Computer Architecture
3/33
localdata
$sp
saveds re isters
(ifany)
returnaddr
arguments$fp
7/29/2019 Lect 7 : IIT Computer Architecture
4/33
constm=20;
int N,i;int X[m],Y[m];
cou ;
cout X[i];
sort(X,Y,N);
cout
7/29/2019 Lect 7 : IIT Computer Architecture
5/33
Recursivemergesortprocedure
voidsort(int A[],int B[],int n){
, ,
if(n
==
1)
B[0]
=A[0];
e se
n1=n/2;
n2
=n
n1;
sort(A,A1,n1);
+
merge(A1,A2,B,n1,n2);
}
7/29/2019 Lect 7 : IIT Computer Architecture
6/33
voidmerge(int P[],int Q[],int R[],int p,int q){
int i,
j,
;
i =j=k=0;
while(i
7/29/2019 Lect 7 : IIT Computer Architecture
7/33
$sp ij c
als
voi merge int P ,
int Q[],int R[],
returnaddr
P
k lo
s
n p, n q
{
R
Q
meterint i,j,k;
..
q par}
7/29/2019 Lect 7 : IIT Computer Architecture
8/33
$sp ij
returna r
qp
returnaddr
P
k
Pa0 P
R
QR
a
a2 R
q ij
t0t1
ij
7/29/2019 Lect 7 : IIT Computer Architecture
9/33
spA1
voidsort(intA[],
intB[
],
int
n)
A2
n1lo
cal
intA1[m],A2[m];
intn1,
n2;
returnaddr
n2
ers
}
n
B
rame
p
7/29/2019 Lect 7 : IIT Computer Architecture
10/33
..
while(i
7/29/2019 Lect 7 : IIT Computer Architecture
11/33
Callingmerge
addi $a0,$sp,0returnaddr
merge(A1,A2,B,n1,n2);
a a , sp,
lw $a2,176($sp)qp
w , sp
sw $t8,
8($sp)A2 Pa0w , sp
sw $t8, 4($sp)n2
n1 R
a
a2
a sp,
sp,
jal mergereturn
addr
B
Ai
jt0t1
.
merge:sw $ra,
0($sp)
n
7/29/2019 Lect 7 : IIT Computer Architecture
12/33
returnaddr
w ra,0 sp
addi $sp,$sp,12q
p
jr $ra
A2 Pa0
n2
n1 R
a
a2
returnaddr
B
Ai
jt0t1
n
7/29/2019 Lect 7 : IIT Computer Architecture
13/33
sort(A,A1,n1);A
sort:sw $ra,168($sp)
.n
B
w t , sp
sw $t8, 12($sp)A2 , ,
sw $t8, 8($sp)
lw $t8 160 $sn2
n1
sw $t8, 4($sp)
addi $sp,$sp, 184
returnaddr
B
A
jal sortn
7/29/2019 Lect 7 : IIT Computer Architecture
14/33
A
w ra,168 sp
addi$sp,$sp,184n
B
jr$ra
A2
n2
n1
returnaddr
B
A
n
7/29/2019 Lect 7 : IIT Computer Architecture
15/33
sort Writea ointerversion Candassembl
Includecodetotrackthemaxstacksize
Writemorespaceefficientprogram(Cand
assembl stillrecursive
7/29/2019 Lect 7 : IIT Computer Architecture
16/33
RISC
and
CISC
Examples
16
7/29/2019 Lect 7 : IIT Computer Architecture
17/33
Setofbasic/primitiveoperations
Storagestructure registers/memory
Howinstructionsareencoded
7/29/2019 Lect 7 : IIT Computer Architecture
18/33
Logical
Re ationa
Branch/jump
Datamovement
7/29/2019 Lect 7 : IIT Computer Architecture
19/33
Memory
0
0
4Registers
1
31
2304
7/29/2019 Lect 7 : IIT Computer Architecture
20/33
ImmediateP r
Register
Operandsources
PCrelative
ResultDestinations
(pseudo)Direct
eg s er n rec
7/29/2019 Lect 7 : IIT Computer Architecture
21/33
Immediateaddressing
Registeraddressing
op rs rt rd func0
1
Registers
7/29/2019 Lect 7 : IIT Computer Architecture
22/33
Memory
op rs rt constant
0
4
register + data
op rs rt constant
PCrelativeaddressing
PC + instruction
7/29/2019 Lect 7 : IIT Computer Architecture
23/33
Memory
op constant
0
4
PC + instruction
op rs rt
Registerindirectaddressing
rd func
Register instruction
7/29/2019 Lect 7 : IIT Computer Architecture
24/33
addi,lui,
beq,
bne,
lw,
sw I
format
j,jal J format
op 26bitnumber
add,jr R format
op
rs rt rd
shamt funct
7/29/2019 Lect 7 : IIT Computer Architecture
25/33
Only3formats
FairnumberofGPregisters
ormemoryaccessorcontroltransfer
Limitedaddressing
modes
,
7/29/2019 Lect 7 : IIT Computer Architecture
26/33
Providemorepowerfuloperations
e.g.J++
and
branch
to
Lif
J>N,
where
Jis
in
Goal
is
to
reduce
number
of
instructions
executed
Dangeris
aslower
cycle
time
and or
a
hi her CPI
7/29/2019 Lect 7 : IIT Computer Architecture
27/33
RM one
operand
in
register
and
one
inmemory
R+M CombinesRR,RMandMM
7/29/2019 Lect 7 : IIT Computer Architecture
28/33
2address
machine r1
=r1
+r2
1addressmachine Acc=Acc+x
0addressmachine addvalueson
topof
stack
7/29/2019 Lect 7 : IIT Computer Architecture
29/33
Accumulatorbasedmachine
Afewspecialpurposeregisters
Severalgeneralpurposeregisters
windows
7/29/2019 Lect 7 : IIT Computer Architecture
30/33
Indirect
Basevs.Index
Pre(post)increment/decrement
Stack
7/29/2019 Lect 7 : IIT Computer Architecture
31/33
Reduced vs.Com lex InstructionSet
Computer
Uniformityofinstructions
modes
Registerbasedarchitecturewith3address
instructions
7/29/2019 Lect 7 : IIT Computer Architecture
32/33
1970sJohnCocke atIBM
Majorityof
combinations
of
orthogonal
notused
ymos programsgenera e ycomp ers
Difficultinmanycasestowritea
compiler
by
conventional
CPUs. 32
7/29/2019 Lect 7 : IIT Computer Architecture
33/33
Virtuallyallnewinstructionsetssince1982have
beenRISC
SUNsSPARC(Scalable ProcessorARChitecture)
HPsPARISC
ARM(Advance
RISC
Machine)
MotorolasPowerPC(Performance Optimization
With EnhancedRISCPerformanceComputing,) DECs
Alpha
MIPS
CDC6600(1960s)