Professional Documents
Culture Documents
Block dia ram The 80c196 is mainly based on ( + C4: %hich is turn com#osed o$ a 16-bit +;: %ith tem#orary registers2 a )36byte 5+M used as )1 s#ecial registers and )*) general registers2 and a micro#rogrammed se7uencer" + memory controller %ith a 1-byte <I< 7ueue to #re$etch instructions and data $rom the #rogram memory" + set o$ I' inter$aces" The C4: gets his in$ormation only through the memory controller and the s#ecial registers also called !#ecial <unction 5egisters .!<5s0" The +;:2 is associated to a set o$ tem#orary registers .%ith shi$ter2 counter2 constants0 and thus called 5+;: .5egister +;:0" The 5+;: doesn=t use an accumulator but instead is ablt to directly %or8 %ith any o$ the )36 s#ecial or general registers +ll I' o#erations are controlled through the !<5s"
Memory controller +ll o$ the #rogram memory and e-ternal data memory are trans$erred to the C4: through the memory controller" The memory controller consists o$ a sla&e #rogram counter2 an instruction 7ueue and a bus controller" The sla&e #rogram counter 8ee#s trac8 o$ the instructions $etched $rom the #rogram memory" Instructions $etched by the memory controller are stored in the 7ueue" The sla&e #rogram counter may be u# to $our bytes ahead o$ the main #rogram counter .%hich is located in the 5+;:02 because it is #re-$etching the instructions" The bus controller accesses #rogram memory .on-chi# 945 M0 and e-ternal data memory and arbitrates bet%een instruction $etches and data reads and %rites" The bus controller su##orts both 8-bit and 16-bit e-ternal bus modes" Memory access re7uests to the bus controller can come $rom either the 5+;: or the 7ueue2 %ith #riority gi&en to the 7ueue accesses" I$ the address se7uence changes because o$ a >um#2 interru#t2 call or return2 the sla&e 4C is loaded %ith a ne% &alue2 and the 7ueue is $lushed" 5eloading the sla&e 4C2 $lushing the 7ueue and $etching the the $irst byte o$ the ne% instruction stream ta8es 1 state times" This is re$lected in the conditional >um# ta8en'not-ta8en e-ecution times" The !"# The C4: is controlled by a microcode se7uencer and can #er$orm o#erations on any byte2 %ord or double-%ord in the )36-byte register s#ace" Instructions to the C4: are ta8en $rom the #re-$etch 7ueue and tem#orarily stored in the instruction register" The se7uencer decodes the instruction and generates the correct se7uence o$ e&ents to ha&e the 5+;: #er$orm the desired o#eration" The $%&# Most calculations #er$ormed by the 80c196 ta8e #lace in the 5+;:" The 5+;: contains a 16-bit +;: - +rithmetic and ;ogic :nit2 the $lag register also called 4!? 4rogram !tatus ?ord2 the main 4C - 4rogram Counter2 a loo# counter and three tem#orary registers" +ll registers are 16-bits or 16-bits %ide"
The 4C has a se#arate incrementor as to access o#erands" Ho%e&er2 4C changes due to >um#s2 interru#ts2 calls and returns are handled through the +;:" T%o o$ the tem#orary registers ha&e their o%n shi$t logic" These registers are used $or the instructions %hich re7uire logical shi$ts2 including @ormali/e2 Multi#ly and ,i&ide" The u##er %ord and lo%er %ord registers are used together $or the *)-bit instructions and as tem#orary registers $or many other instuctions" 5e#etiti&e shi$ts are counted by the 6-bit loo# counter" + third tem#orary register stores the second o#erand o$ t%o-o#erand instructions" To #er$orm subtractions the out#ut o$ this register can be com#lemented be$ore being #laced into the in#ut o$ the +;:" The 5+;: also stores se&eral constants such as 021 and ) to s#eed u# certain o#erations li8e getting a )=s com#lement2 incrementing or decrementing"
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 11(16(39 M9T 1996
$e isters .internal 5+M0 ;ocations 00H through OFFH contain the )*) general registers and the )1 !<5s !#ecial <unction 5egisters" The 5+;: can o#erate on any o$ these )36 internal register locations2 but code cannot be e-ecuted $rom them" I$ attem#t is made to e-ecute instructions $rom locations 00H through OFFH2 the instructions %ill be $etched $rom e)ternal memory" This section o$ e-ternal memory is generally used by the Intel de&elo#ment tools" ;ocations 018H through OFFH are the general registers" These locations can be accessed as byte2 %ord ou double-%ord registers2 and can be essentially considered as )*) accumulators" ;ocations 018H and O1'H contain the stac8 #ointer" #erations to the stac8 cause it to be built do%n and the stac8 #ointer is #re-decremented2 so the stac8 must be initiali/ed by the user #rogram to ) bytes abo&e the highest stac8 location" The stac8 #ointer must #oint to a %ord .e&en0 address" *(ecial +unction $e isters .!<5s0 ;ocations 00H through O17H are the I' control registers or !<5s" +ll o$ the #eri#heral de&ices o$ the 80c196 e-ce#t #orts * and 1 are controlled through these registers" !<5 $unctions are controlled through * %indo%s" !%itching bet%een the %indo%s is done using the ?!5 - ?indo% !elect 5egister located at address 011H" !<5 %indo%s other than 10R 2 0 are out o$ the sco#e o$ this course" !ome o$ the !#ecial <untion 5egisters ha&e di$$erent meanings i$ read $rom or %ritten to" $eser,ed memory locations ;ocations 1FFEH and O1FFFH are used $or 4orts * and 1 res#ecti&ely" Many reser&ed and s#ecial locations are in the memory area bet%een 2000H and 2080H" The 18 interru#t &ectors2 the chi# con$iguration byte and the security 8ey are located in this area" +ll the addresses mar8ed Reserved in this area ha&e to be #rogrammed %ith &alue 0FFH"
2080H !s t)e normal #ro+ram start a t)e #ro+ram at a ress 2080H3 ress3 / reset !nterr"#t restarts
-)ternal memory There are se&eral modes o$ system bus o#eration on the 80c196" The standard bus mode uses a 16-bit multi#le-ed address'data bus" ther bus modes include an 8-bit mode and a mode in %hich the bus si/e can be dynamically s%itched bet%een 8-bits and 16-bits" In addition2 there are se&eral o#tions a&ailable on the ty#e o$ bus control signals %hich ma8e an e-ternal bus sim#le to design" In the standard mode2 e-ternal memory is addressed through lines /40-/415 %hich $orm a 16-bit multi#le-ed bus" The ideali/ed bus timings are re#resented belo% (
The /6E - +ddress ;atch 9nable signal #ro&ides a strobe $or $li#-$lo#s .e"g" 61-*6*s0 to demulti#le- the bus by latching the address" ,emulti#le-ed address signals %ill be called M/0-M/15" The data returned $rom e-ternal memory must be on the bus and stable $or a s#eci$ied setu# time be$ore the rising edge o$ 7R4 .5ead0" The rising edge o$ 7R4 signals the end o$ the sam#ling %indo%" ?riting to e-ternal memory is controlled %ith the 71R .?rite0 #in" ,ata is &alid on /40-15 on the rising edge o$ 71R" +t this time data must be latched by the e-ternal system" In standard 16-bit mode2 the e-ternal memory is com#osed o$ t%o #arallel 8-bit memory ban8s" !ince a gi&en address selects one byte2 the 16-bit data bus has to be reconstructed $rom the lo%-order byte located at the e&en address2 and the high-order byte located at the odd address .see <igure0" The 78HE signal is #ro&ided $or 16-bit bus accesses" Together %ith M/02 this signal allo%s to select either the lo%-order byte2 the high order-byte2 or both bytes during a 16-bit bus access ( Memory bank selection .B/0 %0 0 selected bank high order A lo% order
0 1
1 0
+ctually2 %hen a bloc8 o$ memory is decoded $or reads only2 %hich is ty#ically the case o$ 945 M!2 the system does not ha&e to decode 78HE and M/0 ( the 80c196 %ill discard the byte it does not need" But $or systems that %rite to e-ternal memory2 se#arate %rite strobes must be generated $or both the high and lo% bytes o$ memory"
The system abo&e adds 88-bytes o$ memory .e"g" a )6610 to a 86c196" This #rocessor already has 88 o$ internal 945 M2 seen at locations 2000H through %FFFH" The system abo&e decodes M/14 to select the e-ternal memories2 resulting in the microcontroller seeing them at locations 4000H through 7FFFH2 >ust a$ter the internal memory (
15 14 1% 12 11 10 9 1 - - - ' 8 7 5 4 % 2 1 0 -
To connect )61)8 .168-bytes0 e-ternal memories the system should select them %ith /15 9OR /14 to #lace them at locations 4000H through 08FFFH" To connect 945 M to a 80c1962 %ithout internal memory2 the system is e&en sim#ler" The memory chi#s can be connected %ithout decoding any address line" This means that an 88-bytes chi# %ill be seen at locations 0000H through 0%FFFH" Ho%e&er2 most o$ the locations $rom 0000H through 01FFFH are reser&ed $or internal registers and 5+M" This is hal$ o$ the address s#ace o$ the memories B The tric8 consists in normally #rogramming the u##er hal$ o$ the memories2 and #rogramming their lo%er hal$ .addresses 0000H through 01FFFH0 as corres#onding to locations 4000H through 05FFFH" !ince M/14 is not decoded2 %hen the #rocessor
accesses the cells 4000H through 05FFFH the memories are actually selected %ith an address corres#onding to their lo%er hal$ B
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 11(31()0 M9T 1996
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 11(31(*6 M9T 1996
Im(ortant note 6 +n instruction can contain only one non-direct o#erand re$erence"
+ll other o#erands o$ the instruction must be register-direct re$erences" Indirect addressin The indirect mode is used to access an o#erand ha&ing its address in a %ord register" The indirect address may #oint any%here into the address s#ace2 but must con$orm to the o#erand=s ty#e alignment rules" The register %hich contains the indirect address is selected by an 8-bit $ield %ithin the instruction" -)am(les
64 /448 POP 89:@/9A /6:86:@(9A @/9A ; ; ; ; <89=1- >-- <</9=1-=1</6=8 >-- <86=8 + <<(9=1-=8 <</9=1-=1- >-- <<0P=1-=1<0P=1- >-- <0P=1- + 2
Indirect addressin 3ith (ost-increment This addressing mode is the same as the indirect mode e-ce#t that the %ord %hich contains the address is incremented after it is used to address the o#erand" I$ the o#erand is a byte the address %ill be incremented by 12 i$ it is a %ord the address %ill be incremented by )" -)am(les
64 /448 PB0H /9:@89A+ /6:86:@(9A+ @/9A+ ; ; ; ; ; ; ; </9=1- >-- <<89=1-=1<89=1- >-- <89=1- + 2 </6=8 >-- <86=8 + <<(9=1-=8 <(9=1- >-- <(9=1- + 2 <0P=1- >-- <0P=1- - 2 <<0P=1-=1- >-- <</9=1-=1</9=1- >-- </9=1- + 2
Immediate addressin This addressing mode allo%s an o#erand to ta8en directly $rom a $ield in the instruction" <or o#erations on bytes this $ield is 8-bit %ide2 $or o#erations on %ords it is 16-bit %ide" -)am(les
/44 PB0H 4ID8 /9:C%40 C12%4H /9:C10 ; ; ; ; ; </9=1- >-- </9=1- + %40 <0P=1- >-- <0P=1- - 2 <<0P=1-=1- >-- 12%4H </6=8 >-- </9=1- / 10 </H=8 >-- </9=1- E 10
*hort inde)ed addressin In this addressing mode an 8-bit $ield in the instruction selects a %ord register %hich contains an address" + second 8-bit $ield in the instruction stream .dis#lacement0 is sign-e-tended and summed %ith the register &alue to $orm the address o$ the o#erand" !ince the dis#lacement is sign-e-tended2 the e$$ecti&e address can be u# to 1)8 bytes be$ore the address in the register2 or u# to 1)6 bytes a$ter it" -)am(les
64 MB68 /9:12@89A /9:86:%@(9A ; </9=1- >-- <<89=1- + 12=1; </9=1- >-- <86=8 F <<(9=1- + %=8
&on inde)ed addressin This addressing mode is li8e short inde-ed addressing e-ce#t that the dis#lacement is a 16-bit $ield ta8en $rom the instruction stream to $orm the address o$ the o#erand" @o sign e-tension is necessary" -)am(les
<(9=1-=1</9=1<(9=1-=8 /?4 0G /448 /9:89:G/86E@(9A ; </9=1- >-- <89=1- 3 <G/86E1- + /9:G/86E@89A ; </9=1- >-- <G/86E1- + <89=1-=1- >--
These are the si- basic address modes the 80c196 uses $or accessing o#erands" Ho%e&er2 se&eral other use$ul addressing o#erations can be achie&ed by combining these basic modes %ith s#eci$ic registers such as C95 or the stac8 #ointer ( Memory direct addressin This mode o$ addressing is obtained by inde-ing !<5 C95 2 located at address 0 %hich is $i-ed to &alue 0" In addition to #ro&iding a $i-ed source o$ the constant 0 $or calculations and com#arisons2 this register can be used as the inde- in a long-inde-ed re$erence" This combination o$ register selection and address mode allo%s any location in memory to be addressed directly" -)am(les
/44 POP /9:12%4@0A 5-78@0A ; </9=1- >-- </9=1- + <12%4=1; <5-78=1- >-- <<0P=1-=1; <0P=1- >-- <0P=1- + 2
The system stac8 #ointer is accessed as register 18H o$ the !<5s" In addition to #ro&iding $or con&enient mani#ulation o$ the stac8 #ointer2 this also $acilitates accessing o#erands in the stac8" The to# o$ the stac82 $or e-am#le2 can be accessed by using the stac8 #ointer as the register in an indirect re$erence" In a similar $ashion2 the stac8 #ointer can be used in the sort inde-ed mode to access data %ithin te stac8" -)am(les
64 PB0H 64 !nto 89 /9:@0PA @0PA 89:2@0PA ; ; ; ; ; ; $o#y to# o* sta$& !nto /9 </9=1- >-- <<0P=1-=1"#l!$ate to# o* sta$& <0P=1- >-- <0P=1- - 2 <<0P=1-=1- >-- <<0P=1- + 2=1- >-$o#y next to last ata on sta$& <<0P=1- + 2=1-
; <89=1- >--
!ome o$ the details o$ these addressing modes are hidden by the assembler language2 %hich sim#li$ies the choice o$ the correct mode in se&eral as#ects ( The assembler %ill automatically choose bet%een register-direct addressing and longinde-ed addressing %ith regster C95 2 de#ending on %here the o#erand is located in memory" The #rogrammer can sim#ly re$er to the o#erand by its symbolic name" I$ the o#erand is %ithin the )36 registers a register-direct re$erence %ill be used2 i$ the o#erand is else%here in memory a long-inde-ed re$erence %ill be generated" The assembler %ill choose bet%een short and long inde-ing de#ending on the &alue o$ the dis#lacement" I$ the &alue can be e-#ressed in 8 bits then short inde-ing %ill be used2 i$ cannot then long inde-ing %ill be generated"
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 06(18(0) M9T 1996
!onditions fla s
7 ( The Cero $lag is set to indicate that the o#eration generated a result e7ual to /ero" <or the add-%ith-carry .+,,C0 and subtract-%ith-borro% .!:BB0 o#erations the 7 $lag is cleared i$ the result is not /ero2 but is ne&er set" These t%o instructions are normally used on con>unction %ith the +,, and !:B instructions to #er$orm multi#le #recision arithmetic" Theo#eration o$ the 7 $lag $or these o#erations lea&es it indicating the #ro#er result $or the entire multi#le #recision calculation" 8 ( The @egati&e $lag is set to indicate that the o#eration generated a negati&e result" The 8 $lag %ill be in the algebraically correct state e&en i$ an o&er$lo% occurs" <or shi$t o#erations the 8 $lag %ill be set to the same &alue as the most signi$icant bit o$ the result" This is true e&en i$ the shi$t count is 0" 9 ( The oDer$lo% $lag is set to indicate that the o#eration generated a result %hich is outside the range $or the destination data ty#e" <or the le$t shi$t o#erations the 9 $lag %ill be set i$ the most signi$icant bit changes at any time during the shi$t" 9T ( The oDer$lo% Tra# $lag is set %hen the 9 $lag is set2 but is only cleared by the C;5DT2 EDT and E@DT instructions" The o#eration o$ the 9T $lag allo%s testing $or a #ossible o&er$lo% condition at the end o$ a se7uence o$ related arithmetic o#erations" This is generally more e$$icient than testing the 9T $lag a$ter each instruction" ! ( The Carry $lag is set to indicate the state o$ the arithmetic carry $rom the most signi$icant bit o$ the +;: $or arithmetic o#erations2 or the state o$ the last bit shi$ted out o$ an o#erand $or shi$t o#erations" +rithmetic borro% a$ter a subtract o#eration is the com#lement o$ the ! $lag .i"e" i$ the o#eration generated a borro% the ! $lag is
cleared0" 4 ( 5eser&ed" !hould al%ays be cleared %hen %riting to the 4!? .c$" 4 4< instruction0" I ( The global Interru#t disable bit disables all interru#ts e-ce#t 8MI %hen cleared" *T ( The !Tic8y bit $lag is set to indicate that during a shi$t a 1 has $irst been shi$ted into the ! $lag2 and then shi$ted out" The *T $lag is unde$ined a$ter a multi#ly o#eration" The *T $lag can be used along %ith the ! $lag to control rounding a$ter a right shi$t" Consider multi#lying to 8-bit 7uantities and then scaling the result do%n to 1) bits (
MB6B8 0HR /9:(6:46 /9:C4 ; /9 >-- (6F46 ; s)!*t r!+)t 4 #la$es
I$ the ! $lag is set a$ter the shi$t2 it indicates that the bits shi$ted o$$ the end o$ the o#erand %ere greater-than or e7ual-to hal$ the ;!B o$ the result" ?ithout the *T $lag2 the rounding decision must be made on the basis o$ the ! $lag alone" The *T $lag allo%s a $iner resolution in the rounding decision ( ! *T 9alue of the bits shifted off 0 0 1 1 0 1 0 1 &alue F 0 0 G &alue 1') ;!B &alue F 1') ;!B &alue H 1') ;!B
Muller
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 11(31(13 M9T 1996
!&$ - Clear ?ord !&$B - Clear Byte !&$! - Clear Carry <lag !&$9T - Clear &er$lo% Tra# *-T! - !et Carry <lag
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 06(16(** M9T 1996
&2 - ;oad ?ord &2B - ;oad Byte &2B*- - ;oad Integer %ith !hort-Integer &2B7- - ;oad ?ord %ith Byte *T - !tore ?ord *TB - !tore Byte
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 06(16(10 M9T 1996
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 06(16(09 M9T 1996
-4T - !ign 9-tend Integer into ;ong-Integer -4TB - !ign 9-tend !hort-Integer into Integer I8! - Increment ?ord I8!B - Increment Byte M#& - Multi#ly Integers .signed0 M#&B - Multi#ly !hort Integers .signed0 M#&# - Multi#ly ?ords .unsigned M#&#B - Multi#ly Bytes .unsigned 8-< - @egate Integer 8-<B - @egate !hort-Integer 80$M& - @ormali/e ;ong-Integer *#B - !ubtract ?ords *#BB - !ubtract Bytes *#B! - !ubtract ?ords ?ith Borro% *#B!B - !ubtract ?ords ?ith Borro%
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 06(16(31 M9T 1996
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 06(16()) M9T 1996
2.:.6 *hifts
*/& - ;e$t !hi$t ?ord */&B - ;e$t !hi$t Byte */&& - ;e$t !hi$t ,ouble-?ord */$ - ;ogical 5ight !hi$t ?ord */$% - +rithmetic 5ight !hi$t ?ord */$%B - +rithmetic 5ight !hi$t Byte */$%& - +rithmetic 5ight !hi$t ,ouble-?ord */$B - ;ogical 5ight !hi$t Byte */$& - ;ogical 5ight !hi$t ,ouble-?ord
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 06(16(1* M9T 1996
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 06(16(31 M9T 1996
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 06(16()6 M9T 1996
@8*T - Eum# i$ @o !tic8y bit @89 - Eum# i$ @o &er$lo% @89T - Eum# i$ @o &er$lo% Tra# @*T - Eum# i$ !tic8y bit @9 - Eum# i$ &er$lo% @9T - Eum# i$ &er$lo% Tra#
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 06(16(16 M9T 1996
+ll rights reser&ed <or more in$ormation #lease contact ,aniel Muller
;ast u#dated ( <ri ,ec 3 06(16(1* M9T 1996
J?( 6JMP
K+5 myHla,el
In a li8e manner 2 a B$ %ill cause a *@M" or &@M" to be generated as a##ro#riate2 and a !%&& %ill cause a *!%&& or a &!%&& to be generated"
Muller