manipulating 32 bit numbers with 16 bit registers in 8086

前端 未结 1 1595
半阙折子戏
半阙折子戏 2021-01-05 13:31

Im trying to write a program which get two 6-digit decimal numbers and show the addition of them, but in 16 bit 8086 i defined numbers as double word and put LO in WORD 1

相关标签:
1条回答
  • 2021-01-05 14:13

    Rather than follow your uncommented code, I'll present an independent example.

    Suppose you have one 32-bit number in DX:AX and one 32-bit number in CX:BX (this notation means that the high 16 bites are stored in DX for example, and the low 16 bits in AX). To add these values and leave the result in DX:AX, you would:

        add ax,bx
        adc dx,cx
    

    The add instruction adds the two values and sets the C (carry) bit to 1 or 0 depending on whether there was a carry or not. The adc instruction adds the two values plus the value of the carry bit (and then sets the carry bit again). In this way, you can add values of any size by continuing with more adc instructions.

    0 讨论(0)
提交回复
热议问题