ࡱ> ~za߿ߝXo( UUUUzag\Oy Ek( DD`!x_؎w K`@xڕ;KP=IIk[8: ~lIE -HC?_ա&qM{ύEK+20OD2Pt10<,y6M2;?$)a3/(6bahax3ccl@f6I3SAv6~ ]|3ect2Udӿ5&,YY@"C--ۑk "ZK7(  L T/Equation Equation.30,Microsoft Equation 3.0=Equation Equation.30,Microsoft Equation 3.0x/ 0DTimes New RomanTTxܖ 0ܖDTahomaew RomanTTxܖ 0ܖ" DWingdingsRomanTTxܖ 0ܖ0De0}fԚingsRomanTTxܖ 0ܖ@DArialngsRomanTTxܖ 0ܖPDHelveticaRomanTTxܖ 0ܖ "`DArial Rounded MT Boldܖ 0ܖ"pDSymbolounded MT Boldܖ 0ܖDCourier Newd MT Boldܖ 0ܖ1 B.  @n?" dd@  @@`` x4DHA%/089.RJ($*:)4;   * A  ?]' !"#Or$߿ߝXoifr$g\Oy Ekii$2$x_؎w K <AA`29@8*g ʚ;F&y8ʚ;g4KdKd 0zppp@ <4!d!d k 0Tx<4dddd k 0Tx <4BdBd l 0Tg4(d(d 0[p@ pp80___PPT10 ___PPT9nu=!BWk@~PNG  IHDRF} PLTE3:tRNS@f cmPPJCmp0712Om9IDATc``b $<&40(Zжj˂AtM iIENDB`?B+ .cpeg323-05F\Topic3a-323O =c'TTopic 3a Two s Complement Representation :+(c$a` + 8Introduction to Computer Systems Engineering (CPEG 323)6-2 9a 9 G 2 s Complementb$  "Number and its representation are not the same thing! Representation is a convention defined for expressing the number. A number may have different representations, e.g. BCD, hexadecimal, 2 s complement, etc. 2 s complement: a kind of representation defined as follows 7PP<PPPP7fb f}b@b  = Excercises \ What is 2 s complement representation of +3 ?82 s Complement`  9>Signed Integers(2 s Complement) b(   4,2 s Complement (Cont.)b$  Representing a negative number  x From the representation of x to that of  x "P+PPP"b+fbbQ  <Why  X can be calculated from X by bit-wise complemeting X and add 1 ?GG(,  Hint : using x = +4 as an example How is +4 represented ? How to do -4 brute force from +4 s representation ? More cleverly ? (hint: negation of the most significant bit of +4 is what (in binary) ?) Try yourself !&##h"#Fit a shorter number to longer bits$$b( $ Why is it necessary? Compare an integer with a long integer: typecasting Load a byte to a word To add an immediate field to a 32-bit number MIPS ALU only works with values in 32-bit registers How to deal with smaller sizes? What about larger sizes?l x 4P9P`x`4`9 b    }1#Fit a shorter number to longer bits$$b( $ copy the sign bit into the other bits(sign extension) 0010 -> 0000 0010 1010 -> 1111 1010 Proof? (Hint ? 1x(2^(-7) + 111 1010 = ?)Da + 7`*a+`  H Addition & Subtraction  `  Addition: Just like in grade school 0110 +0001 Substraction: a-b=a+(-b) Two's complement operations easy 0111-0110= 0111 +1010 01V n! n2 n&bc ccbb1bccbbfg&=   ` 5Addition & Subtraction (Cont.) `  uWait! There is one extra bit lost! 0111-0110= 0111 +1010 10001 Why the 1 can be omitted? Because# nK n n#bbccbbffgbfbb v 6Addition & Subtraction (Cont.) `  Questions: Do you have an adder and a  subtractor ? What about unsigned numbers? (Another adder?) Advantage of using 2 s complement Sub can share the same logic as add Sign bit can be treated as a normal number bit in addition. These are the clever points!  nW n" n} n `H`b"b} ` &'    i#Overflow  `  EAddition: 0111 1111 +0110 +1000 A n n bccbbcbb F ;Overflow  `  WAddition: 0111 1111 +0110 + 1000 1101 10111B n n bccbbcbb X I Detecting Overflow `  8What about addition and subtraction of unsigned numbers?9 9` 9 J "What should CPU do about overflow?# #b( # 5Ignore it? Don't always want to detect overflow Addu, addiu, subu (MIPS: do not generate a overflow) Generate a trap so that the programmer can try to deal with it? An exception (interrupt) occurs Control jumps to predefined address for exception Interrupted address is saved for possible resumption Add, sub  ZZ Z@ Z Z bZb@b b  c Z1       k$ Instructions `  Comparison Unsigned numbers sltu: set on less than unsigned sltiu: set on less than immediate unsigned Signed numbers slt: set on less than slti: set on less than immediate  ZZKZZ8Z ``K``6 `  b t    5     : Example (cont d)`   What are the values of $s0 and $s1? $s0= 1111 1111 1111 1111 1111 1111 1111 1111 $s1= 0000 0000 0000 0000 0000 0000 0000 0001 Answer: slt $t0, $s0, $s1 -- the result of $t0 is 1 if both are signed sltu $t1, $s0, $s1 -- the result of $t1 is 0 if both are unsigned J%`.b`b .                             F  C l%Instructions (Cont.)`  'Load/Store lb: load byte lbu: load byte unsigned Example: lb $s1, 100($s2) What is the values of $s1 When memory[$s2+100] = 0000 0000? When memory[$s2+100] = 0000 0001? When memory[$s2+100] = 1111 1111? Example: lbu $s1, 100($s2) What is the values of $s1 when memory[$s2+100] = 1111 1111?0 P&PPPfPPP"P `&`` b b`b`b`b``"`@    L /KLMj    P-  0` @EoOV` @Eff؂o` MMMwww` 33f3Ƨgzf` 3ffE` JH3f̙ff` 33̙fRP` =bf>?" dd@,?wnd@ n< w_@nA``< n?" dd@   @@``PP   @ ` ` p>> @(8(CC '(   !T    "b   # " \    "B   HDA "B   HDA "B   HDA "@@B   HDA "B   HDA "B   HDA "B   HDA "@@B   HDA "B   HDA "B   HDA "B   HDA "@@B   HDA "  B   HDA "  B   HDA "  B   HDA "@ @ B   HDA "  B   HDA "  B   HDA "  B   HDA "@@B   HDA "B   HDA "B   HDA "z\    "B   HDA "B   HDA "B   HDA "@@B   HDA "B   HDA "B !  HDA "B "  HDA "@@B #  HDA "B $  HDA "B %  HDA "B &  HDA "@@B '  HDA " B (  HDA " B )  HDA " B *  HDA "@ @ B +  HDA " B ,  HDA " B -  HDA " B .  HDA "@@B /  HDA "B 0  HDA "B 1  HDA "B 2  HDA "@@B 3  HDA "B 4  HDA "B 5  HDA "B 6  HDA "@@B 7  HDA "B 8  HDA " 9  # t?A?60%"@`tB :  6D"tb `  ; # "|i4 tB < B 6D"`  tB =  6D"PP 2 > B  BCENGGHʲI[TQ zR(VzR(V[T`TzR(V[T`T" ? 6} " } X Click to edit Master title style!!  @ } Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level"0 } RClick to edit Master text styles Second level Third level Fourth level Fifth level!    S  A 6"} "`` } h*c    B 6)} "`  } j*c    C 6,} "`  } j*c   H  0޽h ?>  @Eff؂o___PPT92p22 Blueprint*  0 **@GG*(  B$T   "6b  # "  T??"@`\   "B  HDA "B  HDA "B  HDA "@@B   HDA "B   HDA "B   HDA "B   HDA "@@B   HDA "B  HDA "B  HDA "B  HDA "@@B  HDA "  B  HDA "  B  HDA "  B  HDA "@ @ B  HDA "  B  HDA "  B  HDA "  B  HDA "@@B  HDA "B  HDA "B  HDA "B  HDA "B  HDA "B  HDA "@@B  HDA "B   HDA "B ! HDA "B " HDA "@@B # HDA "B $ HDA "B % HDA "B & HDA "@@B ' HDA " B ( HDA " B ) HDA " B * HDA "@ @ B + HDA " B , HDA " B - HDA " B . HDA "@@B / HDA "B 0 HDA "B 1 HDA "B 2 HDA "@@B 3 HDA "B 4 HDA "B 5 HDA "B 6 HDA "@@B 7 HDA "B 8 HDA "tB 9 6D"$\ /c3  : "/c3 B ; 6D"/3 ,$D  0tB < 6D" tB = 6D"c2 >B  ZBCENGGHʲI[TQ zR(VzR(V[T`TzR(V[T`T"]Ft\  ? "tB @ 6D"r r tB AB 6D"442 B  ZBCENGGHʲI[TQ zR(VzR(V[T`TzR(V[T`T"   C 6 "Pp   X Click to edit Master title style!!  D t Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level"%p0u   [#Click to edit Master subtitle style$$  E 6@ "``  h*c    F 6 "`   j*c    G 6ԗ "`   j*c   H  0޽h ?/ >B @Eff؂of 0 $v(  $ $ 0  P     j*c    $ 0x       l*c   d $ c $ ?    $ 0   @   RClick to edit Master text styles Second level Third level Fourth level Fifth level!    S  $ 6@  `P    j*c    $ 6  `    l*c   H $ 0޽h ? ̙3380___PPT10.#мy 0 00(  x  c $PCX@ (  x  c $DpP?   H  0޽h ? ̙33y___PPT10Y+D='  = @B +G$  0    # (   r   S 0?       S @ <$ 0  7     #" .,$D 0`   <?i ;   bn-1 bn-2 & & b1b0b j b j b j b j    @`   <?;i   Z`  @`   <?i ; nRepresentation`   @`   <d%?i ; gNumber `   @`fB   6o ?`B   01 ?;;fB   6o ?  fB   6o ? `B   01 ?i i  fB   6o ?    c $A /??. F (8 /$D 0H   0޽h ? @Eff؂o\T___PPT104..'+LD' = @B D' = @BA?%,( < +O%,( < +D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* 7%(D' =+4 8?dCB0-#ppt_w/2BCB#ppt_xB*Y3>B ppt_x<* 7D' =+4 8?\CB#ppt_yBCB#ppt_yB*Y3>B ppt_y<* 7D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* 7y%(D' =+4 8?dCB0-#ppt_w/2BCB#ppt_xB*Y3>B ppt_x<* 7yD' =+4 8?\CB#ppt_yBCB#ppt_yB*Y3>B ppt_y<* 7yD{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* y%(D' =+4 8?dCB0-#ppt_w/2BCB#ppt_xB*Y3>B ppt_x<* yD' =+4 8?\CB#ppt_yBCB#ppt_yB*Y3>B ppt_y<* yD{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =+4 8?dCB0-#ppt_w/2BCB#ppt_xB*Y3>B ppt_x<* D' =+4 8?\CB#ppt_yBCB#ppt_yB*Y3>B ppt_y<* Dn' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =+4 8?dCB0-#ppt_w/2BCB#ppt_xB*Y3>B ppt_x<* D' =+4 8?\CB#ppt_yBCB#ppt_yB*Y3>B ppt_y<* D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* %(+8+0+ 0 +  0 ph04(  4r 4 S (?    r 4 S @ 0   4 < s  u1Answer: +3 = 0011 => + 3 = 0x(-2^3) + 0011 = 011(2)  4 <\  n>  bHow about 2 s complement representation of -3 ?  20 4 <2 68 m=Answer: -3 = -(0011) => - 3 => 1x(-2^3) + 0011 = -5 => 1101 >>H 4 0޽h ? @Eff؂o80___PPT10.G>6  0 x/p/F\ .(   r C  S B?    l P  N  #"2&@@@@@@@@` <$D  0    <M?  o 0111`   @`   <R?P  l 7`   @`   <u?T  o 0110`   @`   <f?PT   l 6`   @`   <o? T  o 0101`   @`   <x?P T  l 5`   @`   <D?   o 0100`   @`   <?P   l 4`   @`   <씫?   0011(`d   @`   <@?P  l 3`   @`   <?<  o 0010`   @`   <谫?P< l 2`   @`   <<? < o 0001`   @`   <ë?P< l 1`   @`   <̫?  o 0000`   @`   <ǫ?P l 0`   @`fB   6o ?P `B   01 ?P `B   01 ?P< <`B   01 ?P `B   01 ?P `B   01 ?P  `B   01 ?PT T `B   01 ?P fB   6o ?P fB   6o ?PP`B   01 ?fB   6o ?   ( O  #"2&@@@@@@@@` @<$D  0  5  <8ܫ?<  b1111`   @` 4  <?( < m -1`   @` 3  < ?<T   b1110`   @` 2  <?(T <  m -2`   @` 1  < ?< T  f1101d   @` 0  <?( <T  m -3`   @` /  <<?<   b1100`   @` .  <%?( <  m -4`   @` -  <H)?<  b1011`   @` ,  <8?(<  m -5`   @` +  < B?<< b1010`   @` *  <T<?(<< m -6`   @` )  <HT?<< b1001`   @` (  <]?(<< m -7`   @` '  <f?< b1000`   @` &  <o?(< m -8`   @`fB 6  6o ?(`B 7  01 ?(`B 8  01 ?(<<`B 9  01 ?(`B :  01 ?(  `B ;  01 ?(  `B <  01 ?(T T `B =  01 ?(  fB >  6o ?(fB ?  6o ?((`B @  01 ?<<fB A  6o ? P  <PvO Db ^ R  Bx?   bn-1 bn-2 & & b1b0b j b j b j b j    @` S  B|?*  Z`  @`dB V  <o ?^B W  61 ?*dB X  <o ?*dB Y @ <o ?*:^B Z @ 61 ? dB [  <o ?` \  c $A =??O  =H   0޽h ? @Eff؂o,$___PPT10.T[+&lD'  = @B D' = @BA?%,( < +O%,( < +D' =%(D' =%(D1' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*N %(D' =-m6Bbox(in)*<3<*N D' =%(D' =%(D1' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*O %(D' =-m6Bbox(in)*<3<*O +5   0L0 c[&&(  @2  C 8c7_A )   6 gh X0000$     6DY   X0111$     6D#  d  X0011$     6T ]  X1011$     6hw X1111$     6 X1110$      6m X1101$      6|td  X1100$      6ó G  X1010$      6ɳ YQ&  X1001$      6γY f^  X1000$     6Գ . & ?  X0110$     6 г m  X0101$     6L׳   X0100$     6 m X0010$     6   X0001$     6~a 4 V+0$     6D  V+1$     6a  V+2$     6U  L  V+3$     6  a   V+4$     6h   V+5$     6   /  V+6$     6  <  V+7$     6  f  V-8$     6\  A g  V-7$     6D  r  V-6$     6T    V-5$     6 @  V-4$      6H( H V-3$    ! 6, ]g V-2$    " 6P1 ~4 V-1$    # 0`6  P @ X (For 4 bits)  2 a   $ 0:   1Reference: Katz: Contemporary Logic Design, p2432 22c 2  % 04? T  ,$D  0 Why 1111 and 0000 are adjacent? What is the meaning of bit 3? What is the sign of 0? What is the smallest number? What is the biggest number?<0wnPc   & BDD  ?     H  0޽h ? a( ___PPT10+{3LD' E = @B DP' = @BA?%,( < +O%,( < +D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*% %(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*% D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*% D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*% >%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*% >D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*% >D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%>V%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*%>VD' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*%>VD{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%Vs%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*%VsD' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*%VsD{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%s%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*%sD' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*%s+8+0+%0 ++  0 @I(  x  c $N ? Y      c $O @ '<$ 0   6  &-  = #"(@z ,$D 0`  <P ?9&  bn-1 bn-2 & & b1b0b j b j b j b j    @`  <Q ?9 ax`   @`  <w ?&-  2&bn-1bn-2 & & b1b0b  j b  j b  j b  j    @`  <\j ?-  b-x`   @`  <LT ?&9 nRepresentation`   @`  <` ?9 gNumber `   @`fB  6o ?&`B  01 ?9&9fB  6o ?- &- fB  6o ?- `B  01 ?- fB  6o ?&&- `B  01 ?& - 0 p,$D 0r 1 0U] ,$D 0" 3 0  ,$D 0* 5 0   ,$ 0 Invert each bi, then add 1L 2 go g   ?   Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level~ ,$  0 64Shortcut: Invert every bit and add 1 to the least significant bit Example: - (0100) = 1011 + 1 = 1100 Example: 10010 = 01100100 10011100 = -10010C0n<PX0n<Paqai aaa ai   @    Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level f ,$  0 Proof of correctness: V0n<P0n<Pai  H  0޽h ? @Eff؂o___PPT10{..'+VDc'  = @B D' = @BA?%,( < +O%,( < +DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*"%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*"M%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*=%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*-%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*1%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*5%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*3%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*@%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*?%(++0+0 ++0+50 ++0+?0 ++0+@0 +}  0  0$(  0r 0 S  ? `    r 0 S  @    H 0 0޽h ? @Eff؂o___PPT10i.p> +D='  = @B +   0 P(  r  S  ?       S  @ <$ 0   H  0޽h ? @Eff؂o___PPT10..+cDZ'  = @B D' = @BA?%,( < +O%,( < +D' =%(D' =%(DT' =A@BBB B0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =-6B'blinds(horizontal)*<3<*D' =%(D' =%(DT' =A@BBB B0B%(D' =1:Bvisible*o3>+B#style.visibility<*I%(D' =-6B'blinds(horizontal)*<3<*ID' =%(D' =%(DT' =A@BBB B0B%(D' =1:Bvisible*o3>+B#style.visibility<*I_%(D' =-6B'blinds(horizontal)*<3<*I_D' =%(D' =%(DT' =A@BBB B0B%(D' =1:Bvisible*o3>+B#style.visibility<*_%(D' =-6B'blinds(horizontal)*<3<*_D' =%(D' =%(DT' =A@BBB B0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =-6B'blinds(horizontal)*<3<*D' =%(D' =%(DT' =A@BBB B0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =-6B'blinds(horizontal)*<3<*D' =%(D' =%(DT' =A@BBB B0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =-6B'blinds(horizontal)*<3<*+8+0+0 +  0 (  x  c $| ' ?   '    c $h ' @ {<$  0 '  C  '  Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level~h`D<4___PPT9 sExample(2-bit): 10= 1 *(-21)+0 *20=-210 Representing -210 in 4-bit word: Can you do that? What is the intuition?(0 wnL0 wnc k c k c k c k c k ck8c t H  0޽h ? @Eff؂o  ___PPT10| ..+³؁D ' ' = @B D ' = @BA?%,( < +O%,( < +D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*a%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*aD' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*aD{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*a%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*aD' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*a+8+0+0 +3*  0L0    s (  ^  6?"   f8' xaxaG  ?@ ~S <$ 0 '     `' xaxa ??   '  x   $l xaxaG  ?Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level /,$D 0 <So 0111-0110= 0001 Have you specially handled the sign bits?n=0 n<na cge*a =   084' @  ,$D 0 Q1  2f    01' 7 ~ ,$D 0 Q1  2f    0@B'  y ,$D 0 Q0  2e     05'  ,$D 0 Q0  2e     08J'   ,$D 0 c12 2ee  H  0޽h ? U>=UU(___PPT10..$`+oZD'  = @B D' = @BA?%,( < +O%,( < +DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*=%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*=V%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*Vw%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*w%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =%(D' =%(DT' =A@BBB B0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =-6B'blinds(horizontal)*<3<*D' =%(D' =%(DT' =A@BBB B0B%(D' =1:Bvisible*o3>+B#style.visibility<*=%(D' =-6B'blinds(horizontal)*<3<*=++0+0 ++0+0 ++0+0 ++0+0 ++0+0 ++0+ 0 ++0+ 0 +8(   0L0 f^(  ^  6?"   fp' xaxaG  ?@ ~Sd  '     `Dq' xaxa ??   '     $@' xaxaG  ?Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level nk,$D 0 /1-1=1+1=0 from the viewpoint of 1-bit. So as long as you do not consider the carry brought by 1+1 (the green 1), you are right!j0 n<n aeHaea    0w'  S,$ 0 Q1  2f    0' ~ J,$ 0 Q1  2f  2   0H #,$D 0   0'  2  ,$D 0 Pis 2d    @ 3 B6CDEFA6O @ - ,$D 0  0'  M o ,$D 0 -% 0*23 + 1*(-23) 1*23 0&bjbfnfb jjnf $  @ C B6CDEF6O @ $  ,$D 0  0\'   ,$D 0 nBut treated in the addition as  2f    00'  + # ,$D 0 \* 0*23 + 1*23 1*23 10+bjbfnfb jjnnnf ' H  0޽h ? U>=UU(bZ___PPT10:.$`+F[D'  = @B D' = @BA?%,( < +O%,( < +D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* %(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* %(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =%(D' =%(DT' =A@BBB B0B%(D' =1:Bvisible*o3>+B#style.visibility<*'%(D' =-6B'blinds(horizontal)*<3<*'D' =%(D' =%(DT' =A@BBB B0B%(D' =1:Bvisible*o3>+B#style.visibility<*'%(D' =-6B'blinds(horizontal)*<3<*'++0+0 ++0+ 0 ++0+0 ++0+0 ++0+0 +S$   0L0 @(  ^  6?"   f' xaxaG  ?@ S<$  0 '     `' xaxa ??   '  H  0޽h ? U>=UU(3!+!___PPT10 !..$`+³؁D ' ' = @B DV ' = @BA?%,( < +O%,( < +D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<* D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<* D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* 4%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<* 4D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<* 4D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*4b%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*4bD' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*4bD{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*b%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*bD' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*bD{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*+8+0+0 +   0L0 (  ^  6?"   f' xaxaG  ?@ n  '     `d' xaxa ??   '     $ ' xaxaG  ?Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth levelTp$D  0TL___PPT9.&  What is the sign of the input? What is the sign of the output? Can overflow occur in adding a positive and a negative number? Can overflow occur with 0? Consider the operations A + B, and A  BJ0 wnn?0 wnn0 wnP)0 n<Pccc)a  H  0޽h ? U>=UU(!___PPT10.$`+w*D' ' = @B DP' = @BA?%,( < +O%,( < +D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*%D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*%D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%J%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*%JD' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*%JD{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*J%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*JD' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*JD{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*+8+0+0 +r  0L0 (w(  (^ ( 6?" (  fh' xaxaG  ?@ n  '   (  `@' xaxa ??   '  [ (  $* xaxaG  ?Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth levelTp,$  0 G What is the sign of the input? What is the sign of the output?,H0 wnnHc&  B H ( 0޽h ? U>=UU(___PPT10.$`+΃D' * = @B DJ' = @BA?%,( < +O%,( < +D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*(%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*(D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*(D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*('%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*('D' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*('D{' =%(D#' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*('H%(D' =+4 8?\CB#ppt_xBCB#ppt_xB*Y3>B ppt_x<*('HD' =+4 8?dCB1+#ppt_h/2BCB#ppt_yB*Y3>B ppt_y<*('H+8+0+(0 +   0L0 z(  ^  6?"   f* xaxaG  ?@  w s<$ 0 *     ``* xaxa ??   *  2   $* xaxaG  ?Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth levele9 PH@___PPT9" Overflow occurs when: add two positives yields a negative add two negatives gives a positive or, subtract a negative from a positive and get a negative or, subtract a positive from a negative and get a positive l0 wnZ0 n<Zc cc   H  0޽h ? U>=UU(___PPT10n..$`+֜D'  = @B D' = @BA?%,( < +O%,( < +D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*9%(D' =-o6Bdissolve*<3<*9+8+0+0 +~  0L0 p @(   ^   6?"    f04* xaxaG  ?@ \<$ 0 *      `5* xaxa ??   *  H   0޽h ? U>=UU(^V___PPT106..$`f+֜D'  = @B D' = @BA?%,( < +O%,( < +D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*  %(D' =-o6Bdissolve*<3<*  D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*  1%(D' =-o6Bdissolve*<3<*  1D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<* 1f%(D' =-o6Bdissolve*<3<* 1fD' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<* f%(D' =-o6Bdissolve*<3<* fD' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =-o6Bdissolve*<3<* D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =-o6Bdissolve*<3<* D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<* -%(D' =-o6Bdissolve*<3<* -D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<* -6%(D' =-o6Bdissolve*<3<* -6+8+0+ 0 +  0 `(  r  S HK* ?   *  r  S  L* @ q  *  |  L^*  Rectangle: Click to edit Master text styles Second level Third level Fourth level Fifth level V&p$D 0<4___PPT9 Example: What are the values of $t0 and $t1? $s0= 1111 1111 1111 1111 1111 1111 1111 1111 $s1= 0000 0000 0000 0000 0000 0000 0000 0001 (1) slt $t0, $s0, $s1 (2) sltu $t1, $s0, $s1-0wnZ0wnZ c #cc 0acaac@     H  0޽h ? @Eff؂or j ___PPT10J .F+lۥD '  = @B D ' = @BA?%,( < +O%,( < +D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*-%(D' =-o6Bdissolve*<3<*-D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*-^%(D' =-o6Bdissolve*<3<*-^D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*^%(D' =-o6Bdissolve*<3<*^D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =-o6Bdissolve*<3<*+8+0+0 +}  0  $(   r   S o* ?   *  r   S p* @ 0 *  H   0޽h ? @Eff؂o___PPT10i.=+D='  = @B +j$  0 P\(  x  c $R?      c $S@ !<$ 0  H  0޽h ? @Eff؂oF">"___PPT10"..F+D!'  = @B Di!' = @BA?%,( < +O%,( < +D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =-o6Bdissolve*<3<* D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =-o6Bdissolve*<3<* D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*1%(D' =-o6Bdissolve*<3<*1D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*1L%(D' =-o6Bdissolve*<3<*1LD' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*Lj%(D' =-o6Bdissolve*<3<*LjD' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*j%(D' =-o6Bdissolve*<3<*jD' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =-o6Bdissolve*<3<*D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =-o6Bdissolve*<3<*D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =-o6Bdissolve*<3<*D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =-o6Bdissolve*<3<*D' =%(D' =%(D@' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<*(%(D' =-o6Bdissolve*<3<*(+8+0+0 +  0   (     Z xaxa ?$ @   @`    N1 ?$    H  0޽h ? a(80___PPT10.$`  0  `(     Z@ xaxa ?$ @   @`    N1 ?$    H  0޽h ? a(80___PPT10.$`f  0  p$(  $ $  ZX xaxa ?$ @   @`  $  N1 ?$    H $ 0޽h ? a(80___PPT10.$`f# 0  P(     Zd xaxa ?$ @   @`    N1 ?$    H  0޽h ? a(80___PPT10.$`5 0  0(     Z xaxa ?$ @   @`    N1 ?$    H  0޽h ? a(80___PPT10.$`6 0  @(     Z xaxa ?$ @   @`    N1 ?$    H  0޽h ? a(80___PPT10.$`9 0 (  ^  S $     c $8 $ @   HWhat s name of this? Number wheel??%%` % H  0޽h ? ̙3380___PPT10. 4H; 0  ,(  , ,  Z xaxa ?$ @   @`  ,  N1 ?$    H , 0޽h ? a(80___PPT10.$`exVMhA~3&O5 mCzhI0TM6T,=͛I DO7Ah 6ɺIhQQ }a|3ߛׯ+PFGA|NSC+/ .(TЁ5j~ߡaH/C [~lIb`T*ӑL<4zB]k kGLڳOv JV@"ܠإJw V.QX &͙v󢜇9:}Ь:a gq `$sa4;G]Np~Kd;8Ghjdwc|PrFak9&lʯCE ܫuZs4Xڛo秴ǔ,^K&^פ`@FX]1SH`aH f$ẅHH0li2;^j3z'ϵkUka†W0t٭ ?Yċ"> ,x@87~i/$lUf`z[^R4d?@*exVMhA~3&O5 mCzhI0TM6T,=͛I DO7Ah 6ɺIhQQ }a|3ߛׯ+PFGA|NSC+/ .(TЁ5j~ߡaH/C [~lIb`T*ӑL<4zB]k kGLڳOv JV@"ܠإJw V.QX &͙v󢜇9:}Ь:a gq `$sa4;G]Np~Kd;8Ghjdwc|PrFak9&lʯCE ܫuZs4Xڛo秴ǔ,^K&^פ`@FX]1SH`aH f$ẅHH0li2;^j3z'ϵkUka†W0t٭ ?Yċ"> ,x@87~i/$lUf`z[^R4d?@*r@S7odޕ pGp_ 1<jhP\bXm}uP.O ZskbZ%l1Oh+'0<: hp , L X dpx(Lecture 6 Instruction Set ArchitecturesPGaoPC:\Program Files\Microsoft Office\Templates\Presentation Designs\Blueprint.potGuang R. Gao597Microsoft PowerPoint@ 2W@ EZ{@OGRNG8g  U0  y--$xx--'--$:::--'-B( DD--$ --'-B( DD--$ --'-B( DD--$ --'-B( DD--$ --'-B( DD--$ --'-B( DD--$  --'-B( DD--$ $$%%%%%%%%$$--'-B( DD--$ ****++++****--'-B( DD--$ ///00000///--'-B( DD--$ 445555555544--'-B( DD--$ ::::;;;;::::--'-B( DD--$ ???@@@@@???--'-B( DD--$ DDEEEEEEEEDD--'-B( DD--$ JJJJKKKKJJJJ--'-B( DD--$ OOOPPPPPOOO--'-B( DD--$ TTUUUUUUUUTT--'-B( DD--$ ZZZZ[[[[ZZZZ--'-B( DD--$ ___`````___--'-B( DD--$ ddeeeeeeeedd--'-B( DD--$ jjjjkkkkjjjj--'-B( DD--$ ooopppppooo--'-B( DD--$ ttuuuuuuuutt--'-B( DD--$ xxxxx--'-B( DD--$ x x x x x --'-B( DD--$ xxxx--'-B( DD--$ xxxxx--'-B( DD--$ xxxxx--'-B( DD--$ x xxx --'-B( DD--$ %%x%x%x%x$x$%%%%%--'-B( DD--$ ++x+x*x*x*x***+++--'-B( DD--$ 00x0x/x/x//0000--'-B( DD--$ 55x5x5x5x4x455555--'-B( DD--$ ;;x;x:x:x:x:::;;;--'-B( DD--$ @@x@x?x?x??@@@@--'-B( DD--$ EExExExExDxDEEEEE--'-B( DD--$ KKxKxJxJxJxJJJKKK--'-B( DD--$ PPxPxOxOxOOPPPP--'-B( DD--$ UUxUxUxUxTxTUUUUU--'-B( DD--$ [[x[xZxZxZxZZZ[[[--'-B( DD--$ ``x`x_x_x__````--'-B( DD--$ eexexexexdxdeeeee--'-B( DD--$ kkxkxjxjxjxjjjkkk--'-B( DD--$ ppxpxoxoxoopppp--'-B( DD--$ uuxuxuxuxtxtuuuuu--'-B( DD--$ {{x{xzxzxzxzzz{{{--'-B( DD--$ xxxx--'-B( DD--$ xxxxx--'-B( DD--$ xxxxx--'-B( DD--$ xxxx--'-B( DD--$ xxxxx--'-B( DD--$ xxxxx--'o--%)--'o--%A--'o--%Y55--'o--%t --'o-- %     --'o--%)__--'o--%6h--'o-- %__``aaa``_^]]]--'@"Tahoma-. @E2 u 2005/9/25."System9-@"Tahoma-. @E2 uDcpeg323a.-@"Tahoma-. @E 2 uK-.-@"Tahoma-. @E 2 uL05F.-@"Tahoma-. @E 2 uO\.-@"Tahoma-. @E2 uPTopic3aa.-@"Tahoma-. @E 2 uV-.-@"Tahoma-. @E 2 uW323.-@"Tahoma-. @E 2 u1.-@Arial-. ff2 @Topic 3a.-@Arial-. ff 2 $ Two.-@Arial-. ff 2 $.-@Arial-. ff02 $s Complement Representation.-@Arial-. @E-2 C,Introduction to Computer o.-@Arial-. @E$2 L3Systems Engineering.-@Arial-. @E2 \C (CPEG 323).-Root EntrydO)NPicturesCurrent User)SummaryInformation(`l:      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|} overflow? InstructionsExample (contd)Instructions (Cont.)  Fonts Used Design TemplateEmbedded OLE Servers Slide Titles4 $, _oNEoNE$_ 0Guang R. GaoGuang R. Gao  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}Root EntrydO)PicturesCurrent UserSummaryInformation(`l:PowerPoint Document(<DocumentSummaryInformation8~Root EntrydO)rq @PicturesCurrent UserSummaryInformation(`l: ՜.+,D՜.+,    On-screen ShowUDel< Times New RomanTahoma Wingdings ¼wArial HelveticaArial Rounded MT BoldSymbol Courier New BlueprintMicrosoft Equation 3.0,Topic 3a Twos Complement Representation 2s Complement Excercises2s Complement!Signed Integers(2s Complement)2s Complement (Cont.)HWhy CX can be calculated from X by bit-wise complemeting X and add 1 ?$Fit a shorter number to longer bits$Fit a shorter number to longer bitsAddition & Subtraction Addition & Subtraction (Cont.)Addition & Subtraction (Cont.) Overflow OverflowDetecting Overflow#What should CPU do about overflow? InstructionsExample (contd)Instructions (Cont.)  Fonts Used Design TemplateEmbedded OLE Servers Slide Titles4 $, PowerPoint Document(<DocumentSummaryInformation8