Tuesday 27 December 2016

Addition of two 16-bit numbers with carry

Here is an example of Assembly Language code for 8086. This example illustrates how the addition of two 16 bit numbers using Direct Addressing Mode is done.


CODE  SEGMENT                                            // start of the logical code segment
          ASSUME CS:CODE                               // this instruction will inform
                                                                           the assembler the assumed name of CS.              START: MOV  AL, 99H                             // this instruction will move
                                                                              the operand 99H to the accumulator.
              MOV BL, 90H                                    // this instruction will move
                                                                              the operand 90H to the Register B.
              ADC  AL, BL                                             // this instruction will add the
                                                                              content of the Register B with the
                                                                              content of the accumulator, the result
                                                                               would be stored in AL and the carry
                                                                                bit would be stored in AH.
              MOV [2035H], AL                               // the result would be moved to
                                                                                the memory location 2035H.
CODE  ENDS                                                    // end of the logical code segment
     END START                                                // end of the program
          

No comments:

Post a Comment