Hello,

I need a little help for word multiplication, according to my notes, to multiply a word, we should put the multiplicand in AX, the multiplier in a register or memory variable and the result should appears in AX(low) and DX(high).

The problem is how to get the product ? It is found in two seperate registers, how to merge them together.

This is a simple example:

call GetDec
		        mov bx, ax
                        dec bx
			cwd
			imul bx

From the example above, the product is in AX and DX but how to access the product and save it in a memory variable?

Thanks in advance for your answer.

Recommended Answers

All 2 Replies

If you have a 32 bit system you could just do something like

Either checking if it overflowed into dx or just zeroing everything out before hand

mov cx, dx
shl ecx, 16
mov cx, ax

Or you could set aside space on the stack something along the lines of

enter 0,4
....code goes here...
....multiplication code.....
mov [ebp - 2], dx
mov [ebp - 4], ax

And now your number resides at [ebp - 4]

Hello, thanks for the answer, I have not tested your solution, because I got the solution by myself.

Solution:
Move 0 in eax
push ax
mov ax, dx
Make 16 left shift in eax, to push ax to the end
pop ax
move ax, in eax

Voila.

Anyway, thanks for the answer dude.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.