Basic Microprocessor
-
Upload
nurul-badriah-anwar-ali -
Category
Documents
-
view
222 -
download
0
Transcript of Basic Microprocessor
-
8/18/2019 Basic Microprocessor
1/40
Saipunidzam Mahamad @ Computer Organization
TCB1043
COMPUTER ORGANISATION
Basic Microprocessor System
-
8/18/2019 Basic Microprocessor
2/40
Saipunidzam Mahamad @ Computer Organization
Leari! Topics
" Litt#e Ma Comp$ter
" T%e &etc%'E(ec$te) Cyc#e
" T%e LMC istr$ctio Set
" T%e LMC a) t%e *o Ne+ma arc%itect$re
" Comp$ter B$ses, 1-s a) 0-s coti$o$s#y ot%e mo*e
-
8/18/2019 Basic Microprocessor
3/40
Saipunidzam Mahamad @ Computer Organization
T%e Litt#e Ma Comp$ter ' LMC
" .ie+ o/ LMC
%at it is" Create) 2y r St$art
Ma)ic5 1678 o/ MIT" A a#most acc$rate
represetatio o/ t%e+or5i! o/ a comp$ter
" E*e a/ter 38 years o/
Comp$ter Io*atio
a) Creatio T%e LMC
arc%itect$re is at t%e
%eart o/ to)ay-s
comp$ter )esi!
-
8/18/2019 Basic Microprocessor
4/40
Saipunidzam Mahamad @ Computer Organization
T%e Litt#e Ma Comp$ter ' LMC
" %at are its compoet• A post room (ot too )$sty)
• A little man ( p%ysica##y /it99)
• A mailbox with many (100) pigeon holesnumbered from 00 to 99
• A calculator (/or simp#e arit%metic operatios)
• A counter
• A input booth (to iteract +it% t%e o$tsi)e +or#))
• A output booth (to iteract +it% t%e o$tsi)e+or#))
-
8/18/2019 Basic Microprocessor
5/40
Saipunidzam Mahamad @ Computer Organization
T%e Litt#e Ma Comp$ter ' LMC
" %at )oes t%e #itt#e ma )o• Tras/er or mo*e i/ormatio /rom oe part o/ t%e
post room to aot%er
• Iterpret :or )eco)e; a) Carry o$t istr$ctios t%at
i*o#*e mo*emet o/ i/ormatio or )ata
• Coti$o$s#y o t%e #oo5o$t /or e+ istr$ctios
" The little man must be very fit to do allthis running about !!!
-
8/18/2019 Basic Microprocessor
6/40
Saipunidzam Mahamad @ Computer Organization
T%e Litt#e Ma Comp$ter ' LMC
" %at are t%e pi!eo %o#es o/ t%e mai#2o( $se)
/or• A pi!eo %o#e cotais NOT #etters< 2$t istr$ctio s#ips
• Eac% pi!eo %o#e cotais oe a) o#y oe istr$ctio
s#ip at a time
• Some pi!eo %o#es may cotai )ata :ie simp#e
$m2ers; t%at )oes ot represet istr$ctios
• Eac% Pi!eo %o#e %as a $i=$e #a2e# :ca##e) a a))ress;
t%at is a $m2er /rom 00 to 66 Address Content
-
8/18/2019 Basic Microprocessor
7/40Saipunidzam Mahamad @ Computer Organization
T%e Litt#e Ma Comp$ter ' LMC
" %at )oes ca#c$#ator )o
• Some istr$ctios i*o#*e arit%metic ca#c$#atios #i5e a))itio<
s$2tractio a) )i*isio
• T%e #itt#e ca e(ec$te istr$ctios t%at i*o#*e mo*emet o/ )ataBUT T%e #itt#e ma does not per/orm ay ca#c$#atios
• T%$s +e-re $si! a ca#c$#ator
" %at is t%e co$ter $se) /or
• T%e #itt#e ma ee)s to remem2er t%e a))ress :or #a2e# o/ t%e e(t pi!eo; to c%ec5 /or ay istr$ctios
• T%e #itt#e ma remem2ers t%e current value o/ t%e co$ter a) t%e
$p)ates t%e co$ter :2y incrementing it; before %e !oes to !et
aot%er istr$ctio
-
8/18/2019 Basic Microprocessor
8/40Saipunidzam Mahamad @ Computer Organization
T%e Litt#e Ma Comp$ter ' LMC
" Ip$t a) O$tp$t Trays• Some istr$ctios or )ata may 2e o2taie) /rom
o$tsi)e t%e post room t%ro$!% t%e input tray
• T%e #itt#e ma sometimes stores )ata i a pi!eo%o#e
i t%e mai#2o( Some ot%er times< %e may %a*e to
)e#i*er )ata o$tsi)e t%e post room t%ro$!% t%e
output tray
• T%e #itt#e ma iteracts +it% t%e +or#) o$tsi)e t%e post room t%ro$!% t%e $se t%e input tray a) t%e
output tray
-
8/18/2019 Basic Microprocessor
9/40Saipunidzam Mahamad @ Computer Organization
T%e LMC Istr$ctio Set
" %at are t%e istr$ctio• 3-decimal co)e) istr$ctios
• T%e first digit represet t%e instruction code
• T%e last two digits represet a address of a pigeon %o#e it%e mai#2o(< or one of the input or output trays
• T%e istr$ctio co)e is a#so ca##e) t%e >peration ode? or
>p code?
• T%e #ast t+o )i!its are a#so ca##e) t%e >perand?
A))ress Cotet
Op co)e Opera)
-
8/18/2019 Basic Microprocessor
10/40Saipunidzam Mahamad @ Computer Organization
T%e LMC Istr$ctio Set
" Istr$ctio Str$ct$re
Arit%metic 1(( A
@(( SUB
ata Mo*emet 3(( STORE
8(( LOA
Ip$tO$tp$t 601 INPUT60@ O$tp$t
Mac%ie Cotro#:co//ee 2rea5;
000 STOP
COB
-
8/18/2019 Basic Microprocessor
11/40
Saipunidzam Mahamad @ Computer Organization
Ip$tO$tp$t
" Mo*e )ata 2et+ee ca#c$#ator a) io$t
2as5etsCotet
Op Co)e Opera)
:a))ress;
IN :ip$t; 6 01
OUT :o$tp$t; 6 0@
-
8/18/2019 Basic Microprocessor
12/40
Saipunidzam Mahamad @ Computer Organization
LMC Ip$tO$tp$t
IN
OUT
-
8/18/2019 Basic Microprocessor
13/40
Saipunidzam Mahamad @ Computer Organization
Itera# ata Mo*emet" Bet+ee mai#2o( a) ca#c$#ator
Cotet
Op Co)e Opera):a))ress;
STO :store; 3 ((
LA :#oa); 8 ((
-
8/18/2019 Basic Microprocessor
14/40
Saipunidzam Mahamad @ Computer Organization
LMC Itera# ata
LDA
STO
-
8/18/2019 Basic Microprocessor
15/40
Saipunidzam Mahamad @ Computer Organization
ata stora!e #ocatio
" P%ysica##y i)etica# to istr$ctio mai#2o(
" Not #ocate) i istr$ctio se=$ece
" I)eti/ie) 2y DAT memoic
-
8/18/2019 Basic Microprocessor
16/40
Saipunidzam Mahamad @ Computer Organization
Arit%metic Istr$ctios
" Rea) mai#2o(
" Per/orm operatio i t%e ca#c$#ator
Cotet
Op Co)e Opera)
:a))ress;
A 1 ((
SUB @ ((
-
8/18/2019 Basic Microprocessor
17/40
Saipunidzam Mahamad @ Computer Organization
LMC Arit%metic Istr$ctios
ADD
SUB
-
8/18/2019 Basic Microprocessor
18/40
Saipunidzam Mahamad @ Computer Organization
Pro!ram Cotro#
" Brac%i! :e(ec$ti! a istr$ctio o$t o/
se=$ece;
C%a!es t%e a))ress i t%e co$ter
" a#tCotet
Op Co)e Opera):a))ress;
BR :D$mp; 7 ((
BR :Brac% o 0; F ((
BRP :Brac% o ; H ((
COB :stop; 0 :i!ore;
-
8/18/2019 Basic Microprocessor
19/40
Saipunidzam Mahamad @ Computer Organization
Istr$ctio SetArit%metic 1(( A
@(( SUB
ata Mo*emet 3(( STORE
8(( LOABR 7(( DUMP
BR F(( BRANC ON 0
BRP H(( BRANC ON
Ip$tO$tp$t 601 INPUT60@ OUTPUT
Mac%ie Cotro#:co//ee 2rea5;
000 ALT
COB
-
8/18/2019 Basic Microprocessor
20/40
Saipunidzam Mahamad @ Computer Organization
T%e LMC Istr$ctio Set
S$mmary
" Istr$ctio ca 2e e(presses $si! Op Co)es
or as #itera# a22re*iatios ca## MemoicsMnemoni
cs
Op
Code
Description
LDA 5xx ;Load the content of location/pigeon-holexxinto the calculator
STO/STD 3xx ;Store the content of calculator into location/pigeon-holexx
ADD 1xx ;Add content of location/pigeon-hole xxto the current content of thecalculator
SUB 2xx ;Subtract content of location/pigeon-holexxfrom the current contenof calculator
IN 901 ;Obtain the data from the Input Trayand put it in the calculator
OUT 902 ; Send to the current data in the calculator to the Output Tray. COB or
HLT
000 ;Coffee Break or Halt i.e.Stop execution!
BRZ 7xx ;"ump to location/pigeon-holexxif the content of the calculator is #
BRP 8xx ;"ump to location/pigeon-holexxif the content of the calculator is $
BR 6xx ;"ump to location/pigeon-holexx&ithout an' conditions
DAT yyy ;(ata Storage Location
-
8/18/2019 Basic Microprocessor
21/40
Saipunidzam Mahamad @ Computer Organization
Simp#e Pro!ram, A)) @ N$m2ers
" Ass$me )ata is store)
i mai#2o(es +it%
a))resses 60" rite istr$ctios
Input a #
Store the #
Input a #
Add
Output thenumber
-
8/18/2019 Basic Microprocessor
22/40
Saipunidzam Mahamad @ Computer Organization
Pro!ram to A)) @ N$m2ers,Usi! Memoics
Mai#2o( Memoic Istr$ctio escriptio
00 IN Jip$t 1st N$m2er
01 STO 66 Jstore )ata
0@ IN Jip$t @) N$m2er
03 A 66 Ja)) 1st K to @) K
04 OUT Jo$tp$t res$#t08 COB Jstop
66 AT 00 J)ata
-
8/18/2019 Basic Microprocessor
23/40
Saipunidzam Mahamad @ Computer Organization
Pro!ram to A)) @ N$m2ers
Mai#2o( Co)e Istr$ctio escriptio
00 601 Jip$t 1st N$m2er
01 366 Jstore )ata
0@ 601 Jip$t @) N$m2er
03 166 Ja)) 1st K to @) K
04 60@ Jo$tp$t res$#t08 000 Jstop
66 000 J)ata
-
8/18/2019 Basic Microprocessor
24/40
Saipunidzam Mahamad @ Computer Organization
T%e LMC Istr$ctio Set
" Samp#e LMC pro!ram to ca#c$#ate N@'N1,
-
8/18/2019 Basic Microprocessor
25/40
Saipunidzam Mahamad @ Computer Organization
&i) Positi*e i//erece o/ @ N$m2ers
00 IN 601
01 STO 10 310
0@ IN 601
03 STO 11 311
04 SUB 10 @10
08 BRP 0H H0H Jtest
07 LA 10 810 Ji/ e!ati*e< re*erse or)er
0F SUB 11 @11
0H OUT 60@ Jprit res$#t a)
06 COB 000 Jstop
10 AT 00 000 J$se) /or )ata
11 AT 00 000 J$se) /or )ata
-
8/18/2019 Basic Microprocessor
26/40
Saipunidzam Mahamad @ Computer Organization
T%e &etc%'E(ec$te Cyc#e
• The Fetch-cycle: go and look for thenext instruction and nd out hat theinstruction means
• !efore the little man can carr" out aninstruction# he needs to nd out hichinstruction he has to carr" out$
• %e does this &" rst getting the 'alue fromthe counter# and then fetching the 'alue
from the corresponding pigeon hole inmail&ox$
• The little identies hat the instruction is$
-
8/18/2019 Basic Microprocessor
27/40
Saipunidzam Mahamad @ Computer Organization
T%e &etc%'E(ec$te Cyc#e
• The Eecute-cycle: execute the instruction• Once the little man knos hich instruction he is going to
perform# he has to start executing it$ This is the !Eecute! phaseof the "etch - eecute c"cle$
• (or each instruction# the little man ill perform a series of tasks$(or instance# for an nput instruction# the little man ill go to thenput tray# take the 'alue he nds there# and go and put it intothe calculator$ (or an add instruction# he ill take a 'alue fromthe mail&ox# and add it to the 'alue presentl" in the calculator
• Once the eecute phase is complete# the little man ill start thec"cle again# and go to the counter to get the address of the nextpigeon hole containing the next instruction he has to fetch$
-
8/18/2019 Basic Microprocessor
28/40
Saipunidzam Mahamad @ Computer Organization
T%e &etc%'E(ec$te Cyc#e
" T%e &etc%'E(ec$te cyc#es, !eera# pat%
START
&etc% Ne(t
Istr$ctio
E(ec$te
Istr$ctio ALT
&etc% Cyc#e E(ec$te Cyc#e
-
8/18/2019 Basic Microprocessor
29/40
Saipunidzam Mahamad @ Computer Organization
"igure #$%a The fetch of the
instruction cycle
:@;+a#5s o*er t%e mai#2o( t%at
correspo)s to t%e #ocatio co$ter
:1;T%e Litt#e Ma rea)s t%e
a))ress /rom t%e #ocatio co$ter
-
8/18/2019 Basic Microprocessor
30/40
Saipunidzam Mahamad @ Computer Organization
"igure #$%a The fetch of the
instruction cycle
:3;a) rea)s t%e $m2er o t%e
s#ip o/ paper :e t%e p$ts t%e s#ips
o/ paper 2ac5< i case %e s%o$#) ee)
to rea) it a!ai #ater
-
8/18/2019 Basic Microprocessor
31/40
Saipunidzam Mahamad @ Computer Organization
"igure #$%b The execute portion of the instruction cycle
(&' instruction)
-
8/18/2019 Basic Microprocessor
32/40
Saipunidzam Mahamad @ Computer Organization
"igure #$%b The execute portion of the instruction cycle
(&' instruction)
-
8/18/2019 Basic Microprocessor
33/40
Saipunidzam Mahamad @ Computer Organization
E(ercise" Co*ert t%e /o##o+i! LMC,
00 60101 366
0@ 601
03 166
04 366
08 60107 @66
0F 60@
0H 000
a Mac%ie co)e Memoic co)e a Memoic co)e Mac%ie co)e
00 IN01 ST 66
0@ IN
03 A 66
04 ST 66
08 IN
07 ST 6H0F LA 66
0H SUB 6H
06 OUT
10 COB
11 AT 01
-
8/18/2019 Basic Microprocessor
34/40
Saipunidzam Mahamad @ Computer Organization
T%e *o Ne$ma arc%itect$re
" haracteristics of the von ewman
'rchitecture• Memory %o#)s 2ot% pro!ram istr$ctios a)
pro!ram )ata T%is is 5o+ as t%e store) pro!ram
cocept
• Memory is a))resse) #iear#y I ot%er +or)s< a##
memory #ocatios are $i=$e a) %a*e $merica#
se=$etia# a))resses
• E*ery memory ce## is $i=$e#y a))resse) 2y its
#ocatio $m2er re!ar)#ess o/ i/ormatio is store)
isi)e it
-
8/18/2019 Basic Microprocessor
35/40
Saipunidzam Mahamad @ Computer Organization
T%e LMC a) t%e *o Ne+ma
arc%itect$re
" The concept of the *+ ,egisters• T%e Re!ister is a si!#e stora!e #ocatio +it%i t%e CPU
• T%ere are $s$a##y may re!isters +it%i t%e CPU
• &or e(amp#e< t%e ca#c$#ator a) t%e co$ter $se) i t%e LMC
+o$#) 2e imp#emete) isi)e t%e CPU $si! t+o separate
re!isters
• Re!isters are a))resse) 2y t%eir ames ot 2y a #ocatio
$m2er T%at is +%y t%ey )i//eret /rom or)iary memoryce##s
-
8/18/2019 Basic Microprocessor
36/40
Saipunidzam Mahamad @ Computer Organization
T%e *o Ne$ma arc%itect$re
" The *+ (entral *rocessing +nit)• T%e CPU a) memory are itimate#y re#ate)
• Ay )isc$ssio o/ oe o/ m$st ic#$)e a )isc$ssio
o/ t%e ot%er" I t%e same t%at t%e Litt#e Ma caot +or5 +it%o$t
%is mai#2o( isi)e t%e post'room
The *+ (entral
*rocessing +nit)
omponent
-
8/18/2019 Basic Microprocessor
37/40
Saipunidzam Mahamad @ Computer Organization
T%e *o Ne$ma arc%itect$re
" Simi#arities 2et+ee t%e LMC a) t%e CPU
!*+
!omponents
(escription
Cotro# $it :CU; Iterpreti! a) maa!i! t%e e(ec$tio o/ istr$ctio ic#$)es a pro!ram co$ter PC
ALU :arit%metic
#o!ic $it;
Ca#c$#atio a) temporary stora!e
IO Iter/ace Comm$icatio +it% e(tera# )e*ices
Memory Pro!ram a) )ata stora!e
Pro!ram co$ter Part o/ t%e CU $se) to store t%e #ocatio o/ t%e
e(t istr$ctio to e(ec$te
-
8/18/2019 Basic Microprocessor
38/40
Saipunidzam Mahamad @ Computer Organization
T%e *o Ne+ma arc%itect$re
" LMC
T%e post'room
T%e #itt#e ma
T%e ca#c$#ator
T%e ip$t tray
T%e o$tp$t tray
Mai#2o(
Pi!eo %o#e
T%e #ocatio co$ter
" CPU
isi)e t%e CPU
cotro# $it :CU;
ALU :arit%metic #o!ic $it;
IO iter/ace
IO iter/ace
Memory
Memory ce##s
Pro!ram co$ter :PC
imilarities between &. and the *+
-
8/18/2019 Basic Microprocessor
39/40
Saipunidzam Mahamad @ Computer Organization
T%e LMC a) t%e *o Ne+ma
arc%itect$re
" /s the &. a von ewman-based
omputer• I/ +e o+ t%i5 o/ t%e mai#2o( isi)e t%e LMC as
Memory a) t%e pi!eo %o#es as )istict #iearmemory ce##s t%at are $se) to store 2ot% istr$ctios
a) )ata t%e
• 1es! T%e LMC is )e/iite#y a !oo) e(amp#e o/ t%e
*o Ne+ma arc%itect$re
-
8/18/2019 Basic Microprocessor
40/40
S$mmary
" T%e +or5i! o/ t%e comp$ter ca 2e sim$#ate) 2y a simp#emo)e# ' T%e Litt#e Ma Comp$ter Mo)e#
" T%e LMC meets a## =$a#i/icatio o/ *o Ne$ma
comp$ter arc%itect$re" T%e e(act steps per/orme) 2y t%e LMC are importat
2eca$se t%ey re/#ect c#ose#y t%e steps per/orme) i rea#CPU i e(ec$ti! a istr$ctio
" Rea)i!, Te(t2oo5 ' C%apter 7 F