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 and HO in word 2. similar to below code
but i dont have any idea to do next, can any body suggest me algorithm for next operations?
Thnx
x dd(?)
next_no:
mov cl,2
mov ch,4
two_bit:
getch
sub al,30h
mov bl,10
mul bl
mov di,ax
add word ptr x+2,di
dec cl
jnz two_bit
fourbit:
getch
sub al,30h
mov bl,10
mul bl
mov di,ax
add word ptr x,di
dec ch
jnz fourbit
in this program
di is a place to storing the number made through the loop
when user enter a number
di will multiple to 10 and the new digit will add to di
like:
proccess of getting 28
di=0*10+2=2
di=2*10*+8=28
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:
The
addinstruction adds the two values and sets the C (carry) bit to 1 or 0 depending on whether there was a carry or not. Theadcinstruction 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 moreadcinstructions.