Page 395 - FUNDAMENTALS OF COMPUTER
P. 395

NPP













                  NPP         CPU Architecture, Addressing Modes and Data Transfer Schemes         395


                      DEC m: Decrement the contents of memory     DEC m: S>mQ>m goJ_oÝQ> _| _o_moar cmoHo$eZ m Ho$
                  location m in data segment by 1 and put the  H$ÝQ>oÝQ²>g _| 1 KQ>mVm h¡ VWm n[aUm_ H$mo Cgr cmoHo$eZ
                  result in the same location:
                                                              na aIVm h¡&
                     Assembler  Directives can  be used  to  · Agoå~ca S>mBaopŠQ>ìg g§Ho$V H$aZo Ho$ {cE Cn`moJ
                      indicate whether memory points to a byte    {H$`m Om gH$Vm h¡ {H$ Š`m _o_moar EH$ ~mBQ> `m EH$
                      or to a word:
                                                                  dS>© H$mo B§{JV H$aVm h¡&
                                     e.g.      DEC   BYTE   PTR    [BX]
                                               DEC   WORD  PTR    [BX]

                     CF is not affected.                     ·   CF à^m{dV Zht hmoVm h¡&
                      SUB r , r  : Subtract contents of register r 2  SUB r , r  : a{OñQ>a r Ho$ H$ÝQ>oÝQ²>g H$mo a{OñQ>a
                                                                          2
                                                                       1
                                                                                    2
                              2
                           1
                  from r  and put the result in r . Thus r  is the  r go KQ>mVm h¡ VWm n[aUm_ H$mo r _| aIVm h¡& Bg àH$ma
                                                     1
                        1
                                             1
                                                               1
                  destination Register.                       r S>opñQ>ZoeZ a{OñQ>a h¡&  1
                                                               1
                                                (r )        (r )      (r )
                                                  1
                                                             1
                                                                       2
                     r  and r  can be any 8-bit or 16-bit General  ·  r VWm r H$moB© ^r 8 {~Q> `m 16 {~Q> OZac a{OñQ>a
                       1
                                                                        2
                                                                   1
                             2
                      registers. Neither of them can be segment   hmo gH$Vo h¢& CZ_| go H$moB© ^r goJ_oÝQ> a{OñQ>a Zht
                      register.                                   hmo gH$Vm h¡&
                     If the subtraction operation  needs a bor-  · `{X gãQ´>oŠeZ Am°naoeZ H$mo AÝV _| EH$ ~m°amo H$s
                      row at the end; CF (carry flag) is set. Thus,  Amdí`H$Vm hmoVr h¡ Vmo CF (Ho$ar âcoJ) {ZYm©[aV
                      in subtraction operation  CF  works  as a   {H$`m OmVm h¡& Bg àH$ma, gãQ´>oŠeZ Am°naoeZ _| CF
                      Borrow Flag. This condition occurs when     EH$ ~m°amo âcoJ Ho$ ê$n _| H$m`© H$aVm h¡& `h K{Q>V
                      r  < r .                                    hmoVm h¡ O~ r < r
                           2
                       1
                                                                               2
                                                                            1
                     If r  >  r  carry  flag (CF) is  reset because  · `{X r > r Vmo Ho$ar âcoJ (CF) [agoQ> hmoVm h¡ Š`m|{H$
                         1
                             2
                                                                      1
                                                                         2
                      there is no borrow needed at the end.       AÝV _| {H$gr ~m°amo H$s Amdí`H$Vm Zht hmoVr h¡&
                      If the result is negative CF is set and it is  `{X n[aUm_ G$UmË_H$ h¡ Vmo CF goQ> {H$`m OmVm h¡
                  stored in 2's complement form.
                                                              VWm Bgo 2's H$åßcr_oÝQ> ê$n _| ñQ>moa {H$`m OmVm h¡&
                      SUB r,  m  and SUB m,  r:  Contents of      SUB r, m and SUB m, r:  S>mQ>m goJ_oÝQ> _| _o_moar
                  memory m in data segment and 8-bit or 16-bit  m Ho$ H$ÝQ>oÝQ²>g VWm 8 {~Q> `m 16 {~Q> a{OñQ>g© Am°naoÝS²>g
                  registers are used as operands. Executed simi-  Ho$ ê$n _| Cn`moJ {H$`o OmVo h¢& SUB r , r Ho$ g_mZ hr
                  lar to SUB  r , r                                                        1  2
                             1
                                2
                                                              EŠOrŠ`yQ> {H$`o OmVo h¢&
                      SUB r, data: Specified data is subtracted   SUB r, data: {ZYm©[aV S>mQ>m H$mo a{OñQ>a Ho$ H$ÝQ>oÝQ²>g
                  from contents of register and the result is placed  go KQ>m`m OmVm h¡ VWm n[aUm_ H$mo {ZYm©[aV a{OñQ>a _|
                  in  the specified  register. Executed  similar to  aIm OmVm h¡& SUB r , r Ho$ g_mZ hr EŠOrŠ`yQ> {H$`m
                  SUB  r , r                                                  1  2
                           2
                        1
                                                              OmVm h¡&
                                              e.g.    SUB   AX,   4219H
   390   391   392   393   394   395   396   397   398   399   400