Document 10805467

advertisement
Practice Exam Name Personal Number Question 1: We had discussed magnetic tape data storage in previous lecture. In
mainframe computers, IBM tape drives product number 3592, was introduced
under the nickname Jaguar. The next drive was the TS1120, also having the
nickname Jaguar. As of June, 2011, the latest and current drive is the TS1140.
1) Above figure shows TS1140 drive, cartridge, tapes, and format for one track.
Now, we know there is a tape has been formatted for TS1140, having 500,000 bits
per inch on one track, 2560 tracks, 880 meters long, please calculate the capacity
for the tape in terms of byte( 1 inch = 2.54 centimeter) (5pts)
Capacity = density * length * num_tracks
=
=
(500, 000 bits/inch. track) * ( (880 * 100 / 2.54 ) inch) * (2560 tracks )
44,346,456,692,913.385
bits
The capacity is about 44TB, so in terms of byte, it is about 5.5 TB.
2) Please first briefly explain similarity between tape drives and hard drives, and
based on following data: Seagate Barracuda ST380021A, 8 platters, 16 headers,
number of cylinder is 158816, 63 sectors, Block size is 512.
calculate capacity (5pts)
Similar to the previous question Capacity = density * length * num_tracks = ((63 sectors*(512bytes/sector))/2pi * (2pi radians) ( 1between
58816 chard
ylinders/header 16 header) 2) Please first 2)briefly
Please
explain
firstradians) similarity
2)briefly
Please
explain
between
first
briefly
similarity
tape
explain
drives
between
similarity
and* tape
hard
drives
drives,
and
and
tape
drives
drives,
andand
hard drives,*and
2) Please first briefly explain
between
tape
drives
andBarracuda
hard
and
basedsimilarity
on following
based
data:
on following
Seagate
based
Barracuda
data:
on following
Seagate
ST380021A,
data:
Seagate
8drives,
platters,
ST380021A,
Barracuda
16 headers,
8ST380021A,
platters, 16 8headers,
platters, 16 headers,
= 81,964,302,336 bytes approximately 80GB based on following data: Seagate
8 platters,
16
number ofBarracuda
cylinder
number
is 158816,
ofST380021A,
cylinder
number
63 sectors,
is 158816,
of cylinder
Block
63size
sectors,
is 158816,
is 512.
Block
63headers,
sectors,
size is 512.
Block size is 512.
2)
Please
first
2)
briefly
Please
explain
first
similarity
briefly between
explaintape
similarity
drives and
between
hard drives,
tapeanddrives and hard drives, and
number
of cylinder is 158816, 63 sectors, Block size is 512.
based(5pts)
on following
baseddata:
on following
Seagate Barracuda
data: Seagate
ST380021A,Barracuda
8 platters, 16
ST380021A,
headers, 8 platters, 16 headers,
calculate capacity
calculate
(5pts) capacity
calculate
(5pts)capacity
calculate
capacity
(5pts)
of cylinder
number
is 158816,
of cylinder
63 sectors,
is 158816,
Block size63and
issectors,
512. each
Block size is 512.
3) IBM S54 frame support up to 1,320 number
TS1140
LTO
cartridges,
!
!
!
!
!
!
!
!
!
!
!
!
!
cartridge has 4TB. Please use Egyptian Hieroglyphics system to calculate S54
calculate capacity
calculate
(5pts) capacity (5pts)
frame’s capacity
! in terms
! of TB.
! (5pts)
!
!
!
!
!
!
3) IBM S54 frame
3) IBM
support
S54 up
frame
3)to 1,320
IBM
support
S54
TS1140
frame
up toLTO
1,320
support
cartridges,
TS1140
up to 1,320
LTO
and each
cartridges,
TS1140 LTOandcartridges,
each and each
3) IBM S54 frame support up to 1,320 TS1140 LTO cartridges, and each
cartridge has 4TB.
cartridge
Pleasehas
use4TB.
cartridge
Egyptian
Pleasehas
Hieroglyphics
use4TB.
Pleasesystem
Hieroglyphics
use
to calculate
Hieroglyphics
system
S54 to calculate
systemS54
to calculate S54
! Egyptian
! Egyptian
has 4TB.similarity
Please use
Egyptiantape
Hieroglyphics
to calculate
explain
Please firstcartridge
briefly
between
drives andsystem
hard drives,
and S54
frame’s
capacity
frame’s
in
terms
capacity
of
TB.
frame’s
in
(5pts)
terms
capacity
of
TB.
in
(5pts)
terms
of
TB.
(5pts)
sed on following
data:
Seagate
Barracuda
ST380021A, 8 platters, 16 headers,
frame’s
capacity
in terms
of TB. (5pts)
3) IBM S54 frame
3) IBM
support
S54upframe
to 1,320support
TS1140 up
LTOtocartridges,
1,320 TS1140
and eachLTO cartridges, and each
mber of cylinder is 158816, 63 sectors, Block size is 512.
cartridge hascartridge
4TB. Pleasehas
use 4TB.
Egyptian
Please
Hieroglyphics
use Egyptian
system toHieroglyphics
calculate S54 system to calculate S54
culate capacity (5pts)
frame’s capacity
frame’s
in terms
capacity
of TB. (5pts)
in terms of TB. (5pts)
!
!
!
!
!
!
!
!
!
Firstly, represent multiplicand 1320 and multiplier ! 4 in H!ieroglyphics: !
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
IBM S54 frame support up to 1,320 TS1140 LTO cartridges, and each
!
!
tridge has 4TB.
Please use Egyptian
system
to calculate S54
! Hieroglyphics
!
!
!
me’s capacity in terms of TB. (5pts)
!
1320 = 4 = !
!
!
!
!
!
!
!
! *2, then ! multiply result by 2 Secondly, 1320 * 4 = 1320 * 2 , we calculate 1320 4) Do a calculation 123nine 4)- Do456
two’s
complement
number
and
123
456 123
nine 4)using
a calculation
Do123
a calculation
- 456
4) Do
a calculation
using- two’s
complement
using
- 456
two’s
number
complement
using
andtwo’snumber
complement
and number and
nine
nine nine
nine nine
nine
!
!
represent result using 10 bit
base-2result
abacus(5pts)
!usingabacus(5pts)
represent
represent
using 10 result
bit base-2
represent
10result
bit base-2
using
! abacus(5pts)
10 bit base-2 !abacus(5pts) !
!
!
!
!
!
!
!
!
4) Do a calculation
4) Do123
a calculation
usingninetwo’s
- 456
complement
number
two’s
andcomplement number and
nine - 456 nine 123
nine using
represent result
represent
using 10 bit
result
base-2using
abacus(5pts)
10 bit base-2
!
abacus(5pts) !
!
!
!
!
2) Please first brieframe’
fly explsaicapaci
n simframe’s
ilatyritiyn between
dri(5pts)
vesinandterms
hard driframe’s
vofes, TB.
andin terms
termscapacity
oftapeTB.frame’s
capacity
(5pts)
capacity
of TB.
in terms
(5pts)of TB. (5pts)
!
!
!
!
!
!
y a(5pts)
te capaci
tengcapaci
tuly a(5pts)
te capaci
cal! ctuly a(5pts)
teST380021A,
capaci
cal! ctuly a(5pts)
te8capaci
teheaders,
capaci
calc! tuly a(5pts)
te capacity (5pts)
!
!
!
oncal! folcltuloywia(5pts)
data:cal! cSeagate
Barracuda
placaltters,!ctuly16a(5pts)
!calculate capaci
!calctulbased
! !
!
!
!
!
!
number of cylinder2)isPlease
158816, 63first
sectors,briefly
Block siexplain
ze is 512. similarity between tape drives and hard drives, and
!
!
!
!
!
!
!
! 3)! IBM! S54 frame
! S54 frame
! IBsupport
!3) toIBsupport
!up3) toIBsupport
!frame
!each
! each
!TS1140
!
3)
M
up
1,
M
3
20
S54
TS1140
frame
1,
LTO
M
3
20
S54
cartri
TS1140
up
3)
d
to
ges,
I
B
support
1,
LTO
M
3
and
20
S54
cartri
TS1140
frame
up3)dtoges,
IBsupport
1,LTO
M3and
20S54cartri
TS1140
frame
up3)dtoges,
IBsupport
1,LTO
M3and
20S54cartri
each
frame
up3)dtoges,
IBsupport
1,LTO
M3and
20S54cartri
TS1140
each
frame
updtoges,support
1,LTO3and
20cartri
TS1140
each
updtoges,1,LTO3and
20cartri
TS1140
eachdges,LTOandcartri
eachdges, and each
!
based on following data: Seagate Barracuda ST380021A, 8 platters, 16 headers,
!
!
!
!
!(5pts)
!nsHiuse
!rogl
!gephi
cal
c
ul
a
te
capaci
t
y
cartri
d
ge
has
4TB.
cartri
Pl
d
ge
e
ase
has
use
4TB.
cartri
Egypti
Pl
d
ge
e
ase
a
has
n
Hi
use
4TB.
cartri
e
rogl
Egypti
Pl
y
d
phi
ge
e
ase
a
c
has
system
4TB.
cartri
e
rogl
Egypti
Pl
y
d
phi
to
ge
e
ase
cal
a
c
has
n
s
c
Hi
use
system
ul
4TB.
cartri
e
a
te
Egypti
S54
Pl
d
y
to
ge
phi
e
ase
cal
a
has
c
n
s
c
Hi
use
system
ul
4TB.
cartri
e
a
rogl
te
Egypti
S54
Pl
d
y
to
e
ase
a
cal
has
c
n
s
Hi
c
use
system
ul
4TB.
cartri
e
a
rogl
te
Egypti
S54
Pl
d
y
ge
phi
to
e
ase
a
cal
has
c
n
s
Hi
c
use
system
ul
4TB.
e
a
rogl
te
Egypti
S54
Pl
y
phi
to
e
ase
a
cal
c
n
s
Hi
c
use
system
ul
e
a
rogl
te
Egypti
S54
y
phi
to
a
cal
c
n
s
Hi
c
system
ul
e
a
rogl
te
S54
y
phi
to
cal
c
s
csystem
ulate S54to calculate S54
3) IBM S543) frame
IBM !S54
support
3) frame
IBMupS54
to3) frame
1,320
IBMupS54
TS1140
support
1,320LTO
upTS1140
support
to! cartridges,
1,320! LTO
upTS1140
1,320
and! LTO
each
TS1140
and! LTO
eachnumber
cartridges,
and
each
and
eachis 158816,
!support
!to frame
!tocartridges,
! cartridges,
of cylinder
63! sectors,! Block size is 512.
!
!
!
!
!
frame’
sEgyptian
capaci
frame’
ty in terms
s capaci
frame’
TB.ty in(5pts)
terms
s capaci
frame’
TB.ty in(5pts)
terms
s capaci
frame’
TB.ty in(5pts)
terms
s capaciofS54
frame’
TB.ty in(5pts)
terms
s capaciofframe’
TB.ty in(5pts)
terms
s capaciofframe’
TB.ty in(5pts)
terms
s capaciof TB.ty in(5pts)
terms of TB. (5pts)
! Please
! Please
! Please
cartridge has
cartridge
4TB.! Please
has
cartridge
4TB.
use
has
cartridge
Egyptian
4TB.
use
has
Hieroglyphics
Egyptian
4TB.
use
Hieroglyphics
Egyptian
system
useHieroglyphics
to system
calculate
Hieroglyphics
toofS54
system
calculate
toofS54
system
calculate
toofS54
calculate
!
!
!
!
!
ease(5pts)
firstof2)briincapacity
Pleterms
fl!eyaseexpl
firastiofnbriinsiTB.
meflterms
ily!ariexplt(5pts)
y between
ainof! simTB.
il!ataperit(5pts)
y dribetween
v! es andtape
hard!drives, andcapacity
! Plterms
! harddri!drivesves,andandcalculate
frame’sin!capacity
terms
frame’sof2)incapacity
TB.
frame’s
TB.
(5pts)
! frame’s capacity
! (5pts)
!
!
!
!
3) IBM S54 frame
3)basedIBsupport
MonS54folloframe
upbased
3)wintogIBdata:
support
1,onM320S54folSeagate
TS1140
frame
up
3)
to
I
B
support
1,
LTO
M
3
20
S54
cartri
TS1140
frame
up
d
to
ges,
support
1,
LTO
3
and
20
cartri
TS1140
each
up
d
to
ges,
1,
LTO
3
and
20
cartri
TS1140
each
d
ges,
LTO
and
cartri
each
d
ges,
and
lowing data:
Barracuda
SeagateST380021A,
Barracuda8ST380021A,
pl!atters, 16 headers,
8 platters,! 16 headers,! each
!
!
!
! dge hasnumber
! Pldgeeofasehas
! iPlsdge158816,
!yphi
!phi
!
cartri
cartri
useinumber
cartri
eofaseahas
Hiusein4TB.
cartri
ederand
Plsd!yand
gephi158816,
easeahas
cndrives
shard
Hiusesystem
Plsidrives,
tozeeaseacalicns 512.
Hicuse
system
S54
tozeacalicns 512.
Hicsystem
teandS54yphito calcsc!system
ulate S54to cal!culate S54 !
!
!eo63rogl
!ulearogl
!
!
cylhard
n4TB.
derEgypti
cylnhard
63roglEgypti
sectors,
idrives,
Bl4TB.
ckEgypti
sectors,
Blul! eoarogl
ckteEgypti
siydrives,
2) Please 2)firstPlease
briefly2)first
explain
Please
brieflysimilarity
2)first
explain
Please
brieflybetween
similarity
2)first
explain
Please
briefly
tape
between
similarity
first
explain
drives
briefly
tape
between
similarity
andexplain
drives
hard4TB.
tape
drives,
between
similarity
anddrives
and
tape
drives,
between
and
drives
tape
and
and
hard
and
! briPlease
! ibriPln siease
!between
!ibriPlndrisiease
!Plndrisiease
! drisiease
!drisiease
2)
Pl
e
ase
fi
r
2)
st
fl
y
expl
fi
r
2)
st
a
fl
m
y
i
l
expl
a
fi
ri
r
2)
t
st
y
a
i
bri
Pl
n
si
e
ase
fl
m
y
i
l
expl
a
fi
ri
tape
r
2)
t
st
y
a
between
fl
m
v
y
es
i
l
expl
a
fi
and
ri
tape
r
2)
t
st
y
a
between
i
bri
hard
fl
m
v
y
es
dri
i
l
expl
a
fi
v
and
ri
tape
r
es,
2)
t
st
y
a
between
i
bri
hard
Pl
n
and
fl
m
v
y
es
dri
i
l
expl
a
fi
v
and
ri
tape
r
es,
2)
t
st
y
a
between
i
bri
hard
Pl
n
and
fl
m
v
y
es
dri
i
l
expl
a
fi
v
and
ri
tape
r
es,
t
st
y
a
ibrihard
nanddri!sieflmvyesdriilexpl
avand
ritape
es,tyabetween
ihard
nanddrisimvesdriilavand
ritape
es,ty between
hard
anddrivesdrivand
tape
es, hard
anddrivesdrivandes, hard
and drives, and
frame’
s capaci
frame’
t8y16iplatters,
n! terms
s capaci
offrame’
TB.ty816inplatters,
(5pts)
terms
sheaders,
capaciofST380021A,
frame’
TB.ty816in(5pts)
terms
sheaders,
capaciof TB.ty 8i16n(5pts)
terms
of TB.16!(5pts)headers, ! !
!
!
! between
based on following
based on data:
following
based
Seagate
on
data:
following
based
Barracuda
Seagate
on
data:
following
based
Barracuda
ST380021A,
Seagate
on
data:
following
Barracuda
ST380021A,
Seagate
8
platters,
data:
Barracuda
ST380021A,
Seagate
headers,
Barracuda
ST380021A,
platters,
platters,
headers,
!
!
!
!
!calculate capacicaltcyul(5pts)
! ate capacibased
!
!
!
!
!
support
S54
support
S54
1,fol3based
upnIgBontoMdata:
support
S54
1,folpl 3LTO
3)frame
upncartri
IgBon16toMdata:
support
S54
d1,folheaders,
3LTO
3)frame
and
upncartri
IgBon16toMdata:
each
support
S54
d1,folheaders,
3LTO
3)frame
and
upncartri
IgBon16toMdata:
each
support
S54
d1,folheaders,
3LTO
3)frame
and
upncartri
IgB16toMdata:
each
support
S54
d1,headers,
3LTO
frame
TS1140
and
upcartri16toeach
support
d1,headers,
3LTO
and
upcartri16toeach
3LTO
andcartri16each
LTO
ges, and each
lo3)winIgBonMdata:S54
folbased
lSeagate
o3)frame
winIgBonMdata:
Barracuda
folbased
lSeagate
o3)frame
wiupnIgBontoMdata:
ST380021A,
Barracuda
l20Seagate
o3)frame
wiTS1140
ST380021A,
8Barracuda
based
al20Seagate
otters,
wiTS1140
ST380021A,
8Barracuda
plges,
based
al20Seagate
otters,
wiTS1140
ST380021A,
8Barracuda
plges,
based
al20Seagate
otters,
wiTS1140
ST380021A,
8Barracuda
plges,
al20Seagate
otters,
wiTS1140
ST380021A,
8Barracuda
plges,
a20Seagate
tters,
ST380021A,
8Barracuda
plges,
a20tters,TS1140
ST380021A,
8d1,headers,
plges,
a20tters,TS1140
8dheaders,
plges,
atters,andcartri16eachdheaders,
ty (5pts)
1320*
= ofis63number
size
Block
on isfolbased
number ofnumber
cylinder
ofisnumber
cylinder
158816,ofis2
63number
cylinder
158816,
sectors,
cylinder
Block
158816,
sectors,
ofis63cylinder
Block
158816,
issectors,
512.size
is63Block
158816,
issectors,
512.size63Block
issectors,
512.size
is 512.size
512.
!
!
! !
!
!
!
!
!
!
!
!
!
!
cartri
cartri
ecylhas
asenumber
cartri
use
ecylsihas
asenumber
use
edoiEgypti
rogl
ecylsihas
ase
ynumber
use
esystem
doiEgypti
rogl
ecylsihas
ase
ynumber
use
esystem
doiEgypti
crogl
ul158816,
eacylsihas
ase
ytenumber
use
esystem
doiEgypti
crogl
ul158816,
eacylsihas
ase
ytezphiacartri
use
esystem
doiEgypti
crogl
ul158816,
easihas
ase
ytezphiaeS54
ton4TB.
use
esystem
crogl
Plcksectors,
uleasiase
ytezphiaeS54
tonuse
esystem
crogl
tonicsHicals512.
esystem
croglulaytephiS54
toccals system
culate S54
to calculate S54
inder!disgeof158816,
cylhasnumber
in4TB.
der63dis!gePlofsectors,
158816,
in4TB.
derBl63doiEgypti
sgePlckofsectors,
158816,
zacartri
ien4TB.
idersHiBl63512.
sgePlckofsectors,
158816,
zphiacartri
ien4TB.
idercsHiBls63512.
sgePlckofsectors,
158816,
zphiacartri
iento4TB.
idercsHiBlcals63512.
sgePlckofsectors,
zphiacartri
ieS54
nto4TB.
idercsHiBlcals63512.
sgePlckofsectors,
ieS54
nto4TB.
idercsHiBlcals63512.
sgePlcksectors,
icsHiBlcals63512.
oEgypti
icsHiBlcals512.
oEgypti
ckulasiytezphiaeS54
!
!
! !
! !
! ! ! ! number! of cylnumber
= 2640
calculate capacity
calculate(5pts)
capacity
calculate(5pts)
capacity
calculate
(5pts)
capacity
calculate(5pts)
capacity (5pts) !
frame’
s
capaci
frame’
t
y
i
n
s
terms
capaci
frame’
of
t
y
TB.
i
n
s
terms
(5pts)
capaci
frame’
of
t
y
TB.
i
n
s
terms
(5pts)
capaci
frame’
of
t
y
TB.
i
n
s
terms
(5pts)
capaci
frame’
of
t
y
TB.
i
n
s
terms
(5pts)
capaci
frame’
of
t
y
TB.
i
n
s
terms
(5pts)
capaci
frame’
of
t
y
TB.
i
n
s
terms
(5pts)
capaci
of
t
y
TB.
i
n
terms
(5pts)
of
TB.
(5pts)
!
!
! ! !
!
!
!
!
!
!
!support
! ty (5pts)
! !
! !
!
BMcalS54ctulyframe
upte tocapaci
1,!cal320ctulyTS1140
ges,caland
each
cal! cul!ate capaci
calctuly a(5pts)
te capaci
calctuly 3)a(5pts)
te! Icapaci
a(5pts)
te capaci
calctuly a(5pts)
a(5pts)
te capaci
calLTOctul!ycartri
a(5pts)
te dcapaci
ctuly a(5pts)
te capaci
!
!
!
!!
!
!
!
!
!
!
!
!
Egyptiframe
a! n Hieroglsupport
yphi!cs system
S54 ! LTO cartridges, and each
!
! cartridge!has 4TB.3)Please
! useS54
!calculateTS1140
IBM
up toto1,320
!
!
!
!
!
!
!
!
!!
!!
! !
!
!
!
!
!
!
!
!
!
!
!
! s capacity cartridge
frame’
in terms of TB.has
(5pts)4TB. Please use Egyptian Hieroglyphics system to calculate S54
!!
! !
!
!
!
!
!
!
!!
!!
!!
!!
! !
!!
!
!
!
!
!
frame’s
! using two’s
! complement
!
! and!
! ! capacity
!! in terms
! of TB.! (5pts)!
!
!
!
!
123
456
4)
Do
a
calculation
number
nine 123nine - 456 using two’s complement number and
!
!
!
! 4) Do a !calculation
nine4) Do a calninecul! a4)tioDon 123
a calc! ul-ati456
4)onDo123a calusicul-nag456
ti4)otwo’
nDo123sa compl
calusic-ulna456
4)getiment
two’
oDon 123
asnumber
calcompl
usicnul-ga4)456
etwo’
tiand
ment
oDons 123
compl
anumber
calusicenulment
g-atwo’
ti456
andonnumber
s123
complusiand
e-ment
ng456two’number
s compl
usiandngement
two’snumber
compl! eand
ment
! number
! !and
!
!base-2 abacus(5pts)
!
! ! nine nine nine nine !ni! ne nine ! nine nin!e nine ! !nine nine ! ! nine ! !
represent
result
using
10
bit
Thirdly, represent
2640*2
= 10 bit! base-2 abacus(5pts)
!
! ! !!
!!
!!
! !
!
result
using
!
!
!
!
represent resul
represent
tBusiM S54
ng 10frame
resul
bitIBbase-2
trepresent
usiS54ngabacus(5pts)
10upresul
bitotsupport
base-2
trepresent
usi20 nTS1140
g!upabacus(5pts)
10 toresul
bit1,LTO
base-2
represent
t20usicartri
nabacus(5pts)
g! 10dges,
resul
bi!LTO
t base-2
represent
t usicartri
! nabacus(5pts)
gdges,
10resul
biand
t base-2
t usieach!ngabacus(5pts)
10 bit base-2 !abacus(5pts) !
!
!
!
!
!
3)
I
3)
support
M
frame
1,
3
3
TS1140
and
each
!
!
!
!
!!
!
! ! !!
!!
!!
!!
! !
!
!
! dge has 4TB.
! Pldgeeasehasuse4TB.
! Egypti
!IBMupS54
cartri
cartri
Pl
e
ase
a
n
Hi
use
e
rogl
Egypti
y
phi
a
c
n
s
Hi
system
e
rogl
y
phi
to
cal
c
s
c
system
ul
a
te
S54
to
cal
c
ul
a
te
S54
!
!
!
!
!
!
!
!
3) IBM S543) frame
IBM S54
support
3) frame
IBMupS54
support
to3) frame
1,320
TS1140
support
to3) frame
1,320
IBMLTO
upS54
TS1140
support
tocartridges,
frame
1,320LTO
up
TS1140
support
to
cartridges,
1,320
and
LTO
up
each
TS1140
to
cartridges,
1,320
and
LTO
each
TS1140
cartridges,
and
LTO
each
cartridges,
and
each
and
each
123
456123
!
!
!
!
!
4) Do a calcul4)atioDo
n 123a ninecalculation
- 4564)nineDousia123
ncalculation
g two’nine4)s compl
-Do456
aement
calculation
- and
two’s
using
- 456two’s
using
numbertwo’s
andcomplement
number and
!!
nineusing
ninenumber
nineninecomplement
nine complement
!
!
!
! s capaciframe’
! 4TB.
!TB.! (5pts)toS54
!
! ! !!
frame’
ty in terms
s capaci
ofS54
TB.ty in(5pts)
termstoofS54
!!
!!
!!
! !
cartridge has
cartridge
4TB. Please
has
cartridge
usePlease
has
cartridge
Egyptian
4TB.
usePlease
has
Hieroglyphics
cartridge
Egyptian
4TB.
usePlease
has
Hieroglyphics
Egyptian
4TB.
system
use
Please
Hieroglyphics
Egyptian
to
system
calculate
use
Hieroglyphics
Egyptian
to
S54
system
calculate
Hieroglyphics
to
system
calculate
system
calculate
calculate
S54
!
!
!
!
!
represent
tTS1140
gS54
tresult
abacus(5pts)
using
result
10S54
represent
!bit
base-2
using
10abacus(5pts)
bittoeachd1,base-2
using
10each
abacus(5pts)
! and each !
S54 3)frame
upIBtoM!support
1,3203)frame
TS1140
upIBtoMsupport
S54
1,3LTO
203)frame
TS1140
upcartri
IBtoMsupport
S54
d1,resul
ges,
3LTO
20represent
3)frame
and
upusicartri
IBntoMeach
support
d1,10ges,
3LTO
20bi3)frame
TS1140
and
upbase-2
cartri
IBrepresent
toMeach
support
S54
d1,ges,
3LTO
203)frame
TS1140
and
upcartri
IBtoMeach
support
d1,ges,
3LTO
20frame
TS1140
and
upcartri
toeach
support
d1,ges,
3LTO
20result
TS1140
and
upcartri
ges,
3LTO
20 TS1140
andcartri
d! bit
ges,
LTObase-2
andcartrieachdges,abacus(5pts)
!S54
terms
of in capacity
terms
frame’s
(5pts)
of in capacity
! terms
(5pts)
of in capacity
!terms
(5pts)
of in! TB.
frame’s capacity
frame’s in capacity
frame’s
TB.
TB.
frame’s
TB.
terms
(5pts)
of! TB.
(5pts) ! 3) IBM! S54 3)frameIBM!support
!
!
!
!
!!4TB.dgePlehas
!4TB.
cartri
dge hascartri
asecartri
usedEgypti
gePlehas
aseacartri
n!4TB.
useHiedEgypti
rogl
gePlehas
ase
yphiacartri
n!4TB.
usec!His esystem
dEgypti
rogl
gePlehas
ase
yphiacartri
ton!4TB.
usecHi!cals esystem
dEgypti
crogl
gePluleahas
ase
ytephiacartri
S54
ton!4TB.
usecHicals! esystem
dEgypti
crogl
gePluleahas
ase
ytephiacartri
S54
ton!4TB.
usecHicals! esystem
dEgypti
crogl
gePluleahas
ase
ytephiaS54
ton!4TB.
usecHicals! esystem
Egypti
crogl
Pluleaase
ytephiaS54
tonusecHicals esystem
Egypti
croglulaytephiaS54
toncHicals esystem
croglulaytephiS54
toccals system
culate S54
to calculate S54
!
!
!
!
!
!
!
!
!
!
!
! frame’!s capaciframe’
!
!
ty i456
nscomplement
terms
capaci
frame’
oftyTB.iusing
n!sterms
(5pts)
capaci
frame’
oftyTB.insterms
(5pts)
capaci
frame’
oftyTB.insterms
(5pts)
capaciframe’
oftyTB.insterms
(5pts)
capaciframe’
oftyTB.insterms
(5pts)
capaciframe’
oftyTB.insterms
(5pts)
capacioftyTB.in terms
(5pts)of TB. (5pts)
! and
!
123
123
123nineninetwo’s- using
123
456
456
456
4) Do a calculation
4) Do a calculation
4) Doninea-! calculation
4) Do
using
complement
two’s
number
two’s
andnumber
two’s
number
ninea!- calculation
nine
nine
nine
nine
!- using
! 123complement
! 456123complement
! 456123andnumber
! 456123 and
! 456123 ! 456123 ! 456123 456123 456
4) Do a calcula4)tioDon a calnicnule -a4)tioDon nianecal!niusicneul-na4)gtioDotwo’
n niansecalcompl
cnule -na4)getiment
oDotwo’
n niasnenumber
calcompl
cnule -na4)egti! and
ment
oDotwo’
n niansenumber
calcompl
cnule -na4)gtieand
ment
oDotwo’
n nia!nsecalnumber
compl
cnule -na4)gtieand
ment
oDotwo’
n niansecalnumber
compl
cnule -nagtieand
ment
otwo’
n ninsenumber
compl
ment
two’ninsenumber
compl
usingeand
ment
two’snumber
compleand
ment number and
!
!
!
!
!
ni!usi
niusi
niusi
niusi
niusi
niusine -ngeand
!
!
!
!
!
! represent
!base-2
! result
represent
represent
result using
result
10 bitusing
represent
result
10 bit
abacus(5pts)
using
base-2
10 bit
abacus(5pts)
using
base-2
! ! 10 bit
abacus(5pts)
base-2
! ! abacus(5pts)
!!
!! !
represent
resulrepresent
bi!trepresent
base-2
t usingabacus(5pts)
10resul
bi!trepresent
base-2
t using!abacus(5pts)
10resul
bi! trepresent
base-2
t using!abacus(5pts)
10resul
bi! trepresent
base-2
t using!abacus(5pts)
10resul
base-2
t using!abacus(5pts)
10resul
base-2
t using!abacus(5pts)
10resul
bit base-2
t using!abacus(5pts)
10 bit base-2 !abacus(5pts) !
!
!
!
! t using 10resul
!bitrepresent
! bitrepresent
!
!
!
!
!
!
!
!
!
!
!
!
!!
!
!
!
!
! ten
! ! ! ! with
!
! a ! : ! Fourthly, translate carry
!!
!
! by! replacing
!
!!
!!
!!
!!
! !
!
!
!
!
! eand
! and !
!
!!
!
456
!
4) Do! a calcula4)tioDon! 123
a calnicnule -a4)ti456oDon 123
aninecalniusicnule !-na4)gti456oDotwo’
n 123
aninsecalcompl
cninule!-nagtie456ment
usi
otwo’
n 123
sninenumber
compl
usi
n
g
e
and
ment
two’
s
number
compl
usi
n
g
e
and
ment
two’
s
number
compl
ment
number
!
nin!e nine !
!
!
!
!
!!
!
!
!
!
!!
!!
!!
!!
! !
!
!
!
!
!!
represent
t usi! ng 10resul
bitrepresent
base-2
t usingabacus(5pts)
10resul
bitrepresent
base-2
t using!abacus(5pts)
10resul
bit base-2
t using!abacus(5pts)
10 bit base-2 !abacus(5pts)!!
!
! resulrepresent
!
!
! ! !
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!!
!
! !
! !
!
!
4) Do a calcul4)atiDoona123
calcnineul4)a-tiDoo456
na123
cal! ninecnineul4)ausi-tiDoon456
nga123
two’
calninecnineuls4)compl
ausi-tiDoon456
nga123
etwo’
calment
cninenineuls4)compl
ausinumber
-tiDoon456
nga123
etwo’
calment
cninenineuls4)compl
and
ausinumber
-tiDoon456
nga123
etwo’
calment
and
cnineuls4)compl
ausinumber
-tiDoon456
nga123
etwo’
calment
cnineuls compl
ausinumber
-tion456
ng123
etwo’
ment
usinumber
- n456g etwo’
ment
usinumber
ng etwo’
ment
ands compl
numberement
and number and
nines compl
nine
nineand
nineand
nineands compl
!
!
! ! !
!
!
!
!
!represent resul
!represent
!bit base-2
!
!
!
!
!
!
!
t using resul
10represent
using resul
10abacus(5pts)
represent
bi! t base-2
using resul
10abacus(5pts)
represent
! bi! t base-2
using resul
10abacus(5pts)
represent
! bi! t base-2
using resul
10abacus(5pts)
represent
! bi!t base-2
using resul
10abacus(5pts)
represent
! bit! base-2
using resul
10abacus(5pts)
! bit base-2
using 10abacus(5pts)
! bit base-2 abacus(5pts)
!
!
!
!
!
!
4) Do a calculation 123nine - 456 nine using two’s complement number and
!
!
! 4) Do a! calculation 123
! nine - 456 ! using two’! s complement! number and
!
!
!
!
!
nin!e
!
!
!
!
!
!
! abacus(5pts)
!
represent
result
using! 10 bit base-2
!
which is 5280 !
!
!
!
represent
resul
t
usi
n
g
10
bi
t
base-2
abacus(5pts)
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
! ! !
!
!
!
!
!
!
!
!
4) Do a calculation 123nine - 456 nine using
two’s complement number and
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
! ! !
!
!
!
!
represent result using !10 bit
base-2 abacus(5pts)
! complement
!
! ! and!
!
!
!
123
123
123
123
123
456
456
456
456
456
! !!
4) Do a calculation
4) Do a calculation
4) Doninea- calculation
4) Do
using
4) Do
two’s
a- calculation
using
complement
two’s
- using
complement
number
two’s
- using
complement
andnumber
two’susing
complement
andnumber
two’s
andnumber
andnumber
ninea- calculation
nine
nine
nine
nine
nine
nine
nine
nine
!
!gement
! eand
!
!
!
!
123
123
456
456
4)
Do
a
cal
c
ul
a
4)
ti
o
Do
n
a
cal
c
ul
a
ti
o
n
usi
n
g
two’
s
compl
usi
n
two’
s
number
compl
ment
number
and
nine nine nine nine
123
456
123
!
433nine )
=base-2
!
represent represent
result using
represent
result
10 bitusing
base-2
represent
result
10- bit
abacus(5pts)
using
base-2
represent
result
10 bit
abacus(5pts)
using
base-2
! result
10 bit
abacus(5pts)
using
! 10 bit
abacus(5pts)
base-2
! nine
abacus(5pts)
! - ! ( 1000
! ! nine
nine
nine
!
!
!
!
!
! !
represent resulrepresent
t using 10resul
bit base-2
t usingabacus(5pts)
10 bit base-2 !abacus(5pts) !
!
!
!
!
!
!
+4)433
!1000
= 123
nine
nine
!
!
Do a calcul4)nine
atiDoona123
calcnineul4)a-tiDoo456
na123
calninecnineul4)ausi-tiDoon456
nga123
two’
calninecnineuls4)compl
ausi-tiDoon456
nga123
etwo’
calment
ausinumber
-tiDoon456
nga123
etwo’
calment
cnineuls4)compl
ausinumber
-tiDoon456
nga123
etwo’
calment
cnineuls4)compl
ausinumber
-tiDoon456
nga123
etwo’
calment
cnineuls compl
ausinumber
-tion456
ng123
etwo’
ment
usinumber
- n456g etwo’
ment
usinumber
ng etwo’
ment
ands compl
numberement
and number and
nines compl
ninecnineuls4)compl
nineand
nineand
nineand
nineand
nineands compl
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
=
=
! 566!
!
!
represent resulrepresent
t using resul
10represent
bit base-2
using resul
10abacus(5pts)
represent
bit base-2
using resul
10abacus(5pts)
represent
! bit base-2
using resul
10abacus(5pts)
represent
! bit base-2
using resul
10abacus(5pts)
represent
! bit base-2
using resul
10abacus(5pts)
represent
! bit base-2
using resul
10abacus(5pts)
! bit base-2
using 10abacus(5pts)
! bit base-2 abacus(5pts)
!
!
nine
!1000 nine
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!333nine
since
2
333nine = 3ten ! 9 ten
+ 3ten ! 9 ten + 3ten = 273ten = 0100010001two
So we can represent the -273 number using base-2 using two’s complement
number:
invert(0100010001two ) +1two = 1011101110 two +1two = 1011101111two Question 2: Please read following C program and Perl regular expression: Character
Description
.
a single character
\s
a whitespace character (space, tab, newline)
\S
non-whitespace character
\d
a digit (0-9)
\D
a non-digit
\w
a word character (a-z, A-Z, 0-9, _)
\W
a non-word character
[aeiou]
matches a single character in the given set [^aeiou]
matches a single character outside the given set (foo|bar|baz)
matches any of the alternatives specified
#include<stdio.h>
int Fibonacci(int);
main()
{
int n, i = 0, c;
scanf("%d",&n);
printf("Fibonacci series\n");
for ( c = 1 ; c <= n ; c++ )
{
printf("%d\n", Fibonacci(i));
i++;
}
return 0;
}
int Fibonacci(int n)
{
if ( n == 0 )
return 0;
else if ( n == 1 )
return 1;
else
return ( Fibonacci(n-1) + Fibonacci(n-2) );
} 1) Following Perl program is a lexer, which group tokens and assign the group’s
name. Please fill out the program to print out two groups: firstly, all type
declarations, such as “int:=type”; secondly, all so called ‘if else’ clause, e.g.,
“if:=if clause” (5pts)
# Read the file one line at a time.
while(my $line = <FILE>) {
@tokens = split(/\s+/, $line );
foreach
{
my $token (
@tokens )
# print $token;
if ($token eq "int" || $token =~ m/void/ )
{
print $token;
print ":=type\n";
}
if ($token =~ m/else\s+if/ )
{
print $token;
print ":=else if clause\n";
}
elsif ($token =~ m/if/)
{
print $token;
print ":=if clause\n";
}
elsif ($token =~ m/else/)
{
print $token;
print ":=else clause\n";
}
}
}
2) Please construct a Definite Finite Automata(DFA) according to above
question. (7pts)
Any char other
Any char other
than t
than n
any char other
Any char other
than \s
n
than i, v, e
i
t
f
Epslon
d
v
o
i
e
e
\s +
i
\s
Any char other
than l
l
Any char
other than s
Any char other
than e
s
Epslon
Epslon
3) Answer the following Perl Regular Expression questions (9pts)
(a) does following program print yes?
my $mystring;
$mystring = “Hello world!”;
if ($mystring =~ m/World/) {print “Yes”}
No, Perl is Case Sensitive
Any char
other than l
Any char
other than \s
(b) does following program print “The first digit is $1” ?
$mystring = “[2013/06/25] The date of this exam paper.”;
if
($mystring = ~ m/(\d)/) {
print “The first digit is $1.”
}
Prints "The first digit is 2." In order to designate a pattern for extraction,
one places parenthesis around the pattern. If the pattern is matched, it is
returned in the Perl special variable called $1. If there are multiple
parenthesized expressions, then they will be in variables $1, $2, $3, etc.
(c ) What is the output of following program?
$mystring = “The start text always precedes the end of the end text.”
If ($mystring =~ m/start(.*)end/) {
print $1;
}
Prints “text always precedes the end of the”. The pattern .* is two different
metacharacters that tell Perl to match everything between the start and end. Specifically,
the metacharacter . means match any symbol except new line. The pattern
quantifier * means match zero or more of the preceding symbol. By default, the
quantifiers are greedy. This means that when you say .*, Perl matches every character
(except new line) all the way to the end of the string, and then works backward until it
finds end. To make the pattern quantifier miserly, you use the pattern quantifier limiter ?.
This tells Perl to match as few as possible of the preceding symbol before continuing to
the next part of the pattern.
Question 3: Please refer to the C grammar program in question2 (Fibonacci.c) .
1) Please parse following statement using parse tree(Notice the leave element
could be expression) (6pts)
if ( n == 0 )
return 0;
else if ( n == 1 )
return 1;
else
return ( Fibonacci(n-1) + Fibonacci(n-2) );
Selection-­‐Statement if expression n == 0
Statement else Statement return 0
Selection-­‐statement if !
expression Statement else statement n == 1
return 1
jump-­‐statement Notice: we will not expand all return
statement further
Freturn Fibonacci(n-1) + Fibonacci(n-2)
2) Please show how the tree is parsed using right-derivation using Push-Down
Automata (Stack)
Selection-­‐stmt stmt Pop it, Pop it, Push new rule Push new rule Pop it, Push new rule stmt Pop it, Jump-­‐stmt Push new rule Notice: we will not expand jump-statement further
Selection-­‐stmt 3) Usually, in order to generate assembly code, the grammar-tree or parse-tree
need to be gone through several times. Briefly explain how MIPS assembly code
is generated for the question3 part 1, and write the code below.
If_label1: J finish Else_label1: If_label2: J finish Else_label2: finish: Question 4:
1) Briefly explain lazy evaluation and eager evaluation in lambda-calculus
In programming language theory, lazy evaluation or call-by-need is an evaluation
strategy which delays the evaluation of an expression until its value is needed
(non-strict evaluation) and which also avoids repeated evaluations (sharing).
The sharing can reduce the running time of certain functions by an exponential
factor over other non-strict evaluation strategies, such as call-by-name.
In eager evaluation, an expression is evaluated as soon as it is bound to
a variable
culus (20 points):
Solution:
olution:
(λa b.b) Use
((λz.z
z)((λf.f)(λg.g)))
→β evaluation order to reduce the follo
(a) (5 points)
β-reduction
with am lazy
β
a b.b) ((λz.z z)((λf.f)(λg.g)))
→β
(λb.b)
mmevaluation
→
fully
possible:
) Use β-reduction
with
a as
lazy
order to reduce the following term as
β
b.b) m →
m
ossible:
2) Use lazy evaluation order to reduce the
term as
fully as possible:
(λafollowing
b.b) ((λz.z
z)((λf.f)(λg.g)))
m
(λa b.b) ((λz.z z)((λf.f)(λg.g))) m
Solution:
n:
(λa b.b) ((λz.z z)((λf.f)(λg.g))) m →β
β β
(λb.b)m m
((λz.z z)((λf.f)(λg.g)))
→→
→β
m
(b) (5 points) Use β-reduction with an eager evaluation order to reduce the followi
as fullyanaseager
possible:
points) Use 3)
β-reduction
evaluation
to reduce
theasfollowing
term
Use eagerwith
evaluation order
to reduceorder
the following
term
fully as possible:
fully as possible:
(λf.f g h) (((λa.a a) (λb.b)) (λc d.d))
(λf.f g h) (((λa.a a) (λb.b)) (λc d.d))
Solution:
(λf.f g h) (((λa.a a) (λb.b)) (λc d.d)) →β
olution:
(λf.f g h) (((λb.b)(λb.b)) (λc d.d)) →β
f.f g h) (((λa.a a) (λb.b)) (λc d.d)) →β
(λf.f g h) ((λb.b)
(λc d.d)) →β
β
f.f g h) (((λb.b)(λb.b))
(λc d.d))Use
→ β-reduction
(b) (5 points)
with an eager evaluation order to reduce the fo
(λf.fβ g h)
(λc d.d) →β
)f.f
Use
β-reduction
an eager
evaluation order to reduce the following term
g h)
((λb.b) (λcwith
d.d))
as fully
as possible:
(λc→d.d)
g h →β
β
sf.f
possible:
g h) (λc d.d) →
(λd.d) h →β
β
(λf.f g h) (((λa.a a) (λb.b)) (λc d.d))
c d.d) g h →
h
(λf.f g h) (((λa.a a) (λb.b)) (λc d.d))
d.d) h →β
4) calculate following formula:
Solution:
(let ((x 2) (y 3))
n:
(λf.f
a) (λb.b)) (λc d.d)) →β
(let
((x 7)g h) (((λa.a
β
) (((λa.a a) (λb.b))(λf.f
(λc d.d))
→
(z
y)))
g (+
h)xβ(((λb.b)(λb.b))
(λc d.d)) →β
) (((λb.b)(λb.b)) (λc
d.d))g h)
→ ((λb.b) (λc d.d)) →β
(* z x)))
(λf.f
β
) ((λb.b) (λc d.d)) (λf.f
→ g h) (λc d.d) →β
β
) (λc d.d) →
(λc35d.d) g h →β
β
gh →
(λd.d) h →β
β
→
h
University of Illinois at Urbana-Champaign
Illinois at Urbana-Champaign
Netid:
Netid:
Question 5:
Please refer to the C grammar program in question2 (Fibonacci.c) .
1) Please use Scheme to implement the same function recursively.
define (fib n)
(if (< n 2)
n
(+ (fib (- n 1)) (fib (- n 2)))))
2) Please answer if the stack’s change is the same as Fibonacci.c ? Sketch
stack’s change of the both program, and if they are the same, sketch one figure;
otherwise sketch both figures.
Ans: Yes
Address Variable Value
Variable
fib(3)
Address
fib(3)
0x1000 n
3
0x1004 fibn
?
0x1008 fibn1
?
Step 1
Value
Variable
Value
fib(3)
0x1000
n
3
0x1000
n
3
0x1004
fibn
?
0x1004
fibn
?
0x1008
fibn1
?
0x1008
fibn1
?
fib2(3, 0x1004, 0x1008)
fib2(3, 0x1004, 0x1008)
0x1010
n
3
0x1010
n
3
0x1014
pfibn
0x1004
0x1014
pfibn
0x1004
0x1018
pfibn1
0x1008
0x1018
pfibn1
0x1008
0x101c
fibn2
?
0x101c
fibn2
?
fib2(2, 0x1008, 0x101c)
Step 2
0x1020
n
2
0x1024
pfibn
0x1008
0x1028
pfibn1
0x101c
0x102c
fibn2
?
Step 3
Address
Variable
Value
Address
fib(3)
0x1000
n
0x1004 fibn
0x1008
fibn1
Variable
Value
Address
fib(3)
Variable
Value
fib(3)
3
0x1000
n
3
?
0x1000
n
3
0x1004
fibn
?
?
0x1004
fibn
?
0x1008
fibn1
?
0x1008
fibn1
?
fib2(3, 0x1004, 0x1008)
fib2(3, 0x1004, 0x1008)
0x1010
n
3
0x1010
n
3
0x1014
pfibn
0x1004
0x1010
n
3
0x1014
pfibn
0x1004
0x1018
pfibn1
0x1008
0x1014
pfibn
0x1004
0x1018
pfibn1
0x1008
0x101c
fibn2
?
0x1018
pfibn1
0x1008
0x101c
fibn2
1
0x101c
fibn2
1
fib2(3, 0x1004, 0x1008)
fib2(2, 0x1008, 0x101c)
fib2(2, 0x1008, 0x101c)
0x1020
n
2
0x1020
n
2
0x1024
pfibn
0x1008
0x1020
n
2
0x1024
pfibn
0x1008
0x1028
pfibn1
0x101c
0x1024
pfibn
0x1008
0x1028
pfibn1
0x101c
0x102c
fibn2
?
0x1028
pfibn1
0x101c
0x102c
fibn2
1
0x102c
fibn2
1
fib2(1, 0x101c, 0x102c)
fib2(1, 0x101c, 0x102c)
0x1030
n
2
0x1030
n
2
0x1034
pfibn
0x101c
0x1034
pfibn
0x101c
0x1038
pfibn1
0x102c
0x1038
pfibn1
0x102c
0x103c
fibn2
?
0x103c
fibn2
?
Step 4
Step 5
fib2(2, 0x1008, 0x101c)
Step 6
Address
Variable
Value
fib(3)
0x1000
n
3
0x1004
fibn
?
0x1008
fibn1
2
Address
Variable
Value
Address
fib(3)
Variable
Value
fib(3)
0x1000 n
3
0x1000
n
3
fib2(3, 0x1004, 0x1008)
0x1004 fibn
?
0x1004
fibn
3
0x1010
n
3
0x1008 fibn1
2
0x1008
fibn1
2
0x1014
pfibn
0x1004
fib2(3, 0x1004, 0x1008)
fib2(3, 0x1004, 0x1008)
0x1018
pfibn1
0x1008
0x1010 n
3
0x1010
n
3
0x101c
fibn2
1
0x1014 pfibn
0x1004
0x1014
pfibn
0x1004
fib2(2, 0x1008, 0x101c)
0x1018 pfibn1
0x1008
0x1018
pfibn1
0x1008
0x1020
n
2
0x101c fibn2
1
0x101c
fibn2
1
0x1024
pfibn
0x1008
0x1028
pfibn1
0x101c
0x102c
fibn2
1
Step 7
Step 8
Step 9
Address Variable Value
fib(3)
0x1000 n
3
0x1004 fibn
3
0x1008 fibn1
2
Step 10
3) If we implement the same program using Fortran 77, is the stack’s change
same as Fibonacci.c ?
No
4) Please convert (compile) your Scheme into MIPS assembly code
fib:
cont:
slti $t0, $a0, 2 # if i < 2 (i.e i == 1)
beq $t0, $zero, cont
# if i >= 2 go to cont
addi $v0, $zero, 1
# else make the return value 1
jr $ra
# OPERATION 1: MAKE SPACE IN STACK
addi $sp, $sp, -16
# make space for 3 elements in the stack
sw $ra, 0($sp)
# save the return address
sw $a0, 4($sp)
# OPERATION 2: RECURSIVE CALLS
addi $a0, $a0, -1
# calculate n - 1
jal fib
# calculate fib(n - 1)
sw $v0, 8($sp)
# save into the stack result of fib(n - 1)
lw $a0, 4($sp)
# load the value of n
addi $a0, $a0, -2
# calculate n - 2
jal fib
sw $v0, 12($sp)
# save into the stack the result of fib(n-2)
lw $ra, 0($sp)
# load the return address
lw $t0, 8($sp)
# load the value of fib(n - 1)
lw $t1, 12($sp)
# load the value of fib(n - 2)
addi $sp, $sp, 16
# pop from stack # OPERATION 4: OPEARATION
add $v0, $t0, $t1
# fib(n - 1) + fib(n - 2)
jr $ra
5) Briefly explain how Scheme functions handle parameter-list ?
Recall in lecture 10
!"#$%&'(')*$*(#%"+%,-+./0+%1'22#%345%
! "#$%&'()(& *+,,&-.&/+,') &
012&+,,&3+2+4)5)2(6&&&
! #7&58)&*+()&10&,9(5(:&589(&
4)+7(&58+5&58)&0124+,&
3+2+4)5)2(&;)5&+&!"#$%"&%
'()%#"*+'),%'"%'()%-*.'/&715&+&
*13.&10&58)&<81,)&,9(56&
=>)0'7&*8+7;)?&=,9(5@&
&&&&&=()A&=B2(5&,9(5@&=B2(5&=,+(5&,9(5@@@@&&
&
=>)0'7&*8+7;)C&=,9(5@&&
&&&&=*17(&=B2(5&=,+(5&,9(5@@&=2)(5&,9(5@@@&
D&
/+,')E&&
+&
6%3#*7%8% 3'%9%.55%
*8+7;)?&
,9(5E&&
-&
*8+7;)
C&
,9(5E&&
*&
!"#$%&'(')*$*(#%"+%,-+./0+%1'22#%345%
:;<,%"#%=*#$(-./>*%?????%
+",-)."%" ,!"#"$//"
"+",$0!12)3"%/"
4"50!12)3"(-)-"-).,67-899/:";0<$0"<-"=)-87($>&)9""?@"%"$0!12)-"!'-@9"
%"
&!'()*""
!"
#"
$"
$"
,=)A(1"$0!12)3",'<-8/"
""""",-).",67-8"'<-8/",67-8",'!-8"'<-8////""
"
,=)A(1"$0!12)B",'<-8/""
"""",$@1-",67-8",'!-8"'<-8//",7)-8"'<-8///"
.6'+7*8%
2"#$9""
!"#$%&'(')*$*(#%"+%,-+./0+%1'22#%345%
1?@<%"#%+0$%
:*#$(-./;*%AAAAA%
2"30)4"%" 3!"#"$55"
2"3$+!,-)."%5"
6"7+!,-)."(0)0".0+#6%78".8%"#%+0+9:*#$(-./;*8""<0%=%"#%-+.8'+>*:8"
%"
&!'()*""
!"
#"
$"
39):(,"$+!,-);"3'/015"
"""""30)4"3<=01"'/015"3<=01"3'!01"'/015555""
"
39):(,"$+!,-)."3'/015""
""""3.0+#"3<=01"3'!01"'/0155"3=)01"'/01555"
$+!,-)."
'/01*""
$"
Download