Page 151 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 151

Unit 10: Programming Techniques with Additional Instructions


                                                                                                  Notes
               DCR            M              Decrements memory contents
                                             (a) It is a 1-byte instruction
                                             (b) Decrements the contents of memory by 1, not
                                                 the memory address
                                             (c) (HL) register specifies the memory location.


            INR and DCR instructions affect all the flags except the carry (CY) flag. As all these instructions
            involve a memory location and a register and so uses register indirect addressing more.

                  Example: Write instructions to add the contents of the memory location 8000H to (A) and
            subtract the contents of the memory 8001H from the first sum. Assume the Accumulator has 68H
            the memory location 8000H has 30H, and the location 8001H has 7FH.
            Solution: The contents of HL pair 8000H specify the memory location. The instruction ADD M
            adds 30H the contents of memory location 8000H, to the contents of the Accumulator (68H) the
            instruction INX H points to the next memory location 8001H and the instruction SUB M subtracts
            the contents (7FH) of memory location 8001 from the previous sum. The assembly language
            program is as follows:
                    Machine code       Opcode         Operands
                        (Hex)
                        21              LXI           H, 8000H
                        00
                        80
                        86              ADD           M
                        23              INX           H
                        96              SUB           M


            10.3.2 Related to 16-bits (Register Pairs)
            The instructions related to incrementing/ decrementing 16-bit contents in a register pair are listed
            in Table 10.5. These instructions do not affect any of the status of flags.

                          Table 10.5: List of Arithmetic Operations Related to 16-bit.

               Opcode         Operands       Description

               INX            R              Increments register pairs
               INX            B              (a) It is a 1-byte instruction.
               INX            D              (b) Assumes the contents of two registers as one
               INX            H                  16-bit number
               INX            SP             (c) Increments the contents by 1
               DCX            R              Decrements register pairs
               DCX            B              (a) It is a 1-byte instruction
               DCX            D              (b) Assumes the contents of two registers as one
               DCX            H                  16-bit number.
               DCX            SP             (c) Decreases the contents of registers pair by 1





                                             LOVELY PROFESSIONAL UNIVERSITY                                   145
   146   147   148   149   150   151   152   153   154   155   156