The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: Vix on April 07, 2005, 07:33:08 PM

Title: I need help
Post by: Vix on April 07, 2005, 07:33:08 PM
Can someone please try to explain me how to add 2 32-bit numbers in 16-bit masm 
Title: Re: I need help
Post by: hitchhikr on April 07, 2005, 08:39:24 PM

nbr1 dd 1234567892
nbr2 dd 1234567892
result dd 0



mov ax, word ptr [nbr1]
add ax, word ptr [nbr2]
mov word ptr [result], ax
mov ax, word ptr [nbr1 + 2]
adc ax, word ptr [nbr2 + 2]
mov word ptr [result + 2], ax

Title: Re: I need help
Post by: Vix on April 07, 2005, 10:09:41 PM
Thanks a lot.
I am a new user of MASM and I'm not really good at this more complicated things.
Now I have general idea how to solve this problem but still I don't get it.
Can you please explain me what does this mean in few steps and is it possible to print result of adding 2 32-bit numbers.
Title: Re: I need help
Post by: hitchhikr on April 07, 2005, 10:56:42 PM
First it adds the last two words then adds the first two ones with the carry bit retrieved from the first addition (this bit is set if the result of the addition if greater than 0ffffh).

To print the result variable you need to convert it into ascii, and before you ask how to do this i suggest to use google or browse this forum to find the answer.