Re: newbie: MUL product




Hi Brian,

I posted this at CLAX, but it wasn't showing up, so I'll try here.

Assume a few hours delay in CLAX, it's a moderated group.

I'm a newbie using MASM on a P4 Intel processor. My tutorial says
that if I multiply AX by a 16 bit register or memory operand, the
product is DX:AX. How do I reference DX:AX if I want to store the
product in memory or to a 32 bit register?


I tried "mov ebx, dx:ax" but that doesn't work.

The CPU hasn't got this opportunity.


I can put the value in edx like this:
shl edx, 16
mov dx, ax

but I'm not sure if there is a simpler way, or a way to get to the
32-bit product with just one instruction.

The way you do it is just fine,
also the SHLD instruction is not designed for this,
as it needs Zero-extend eax,ax and edx,dx first.

But look at the other IMUL instructions which work like:

anyreg32 = anyreg32 * anyreg/mem32

ie: IMUL eax,ebx,ecx

or the immediate operand IMUL forms:

anyreg32=anyreg/mem32 * SXimm8/imm32

ie: IMUL eax,ebx,-09

perhaps this fits your goal better
(unfortunately no unsigned MUL in this forms)

You can also follow Herbert's advice
and perform a 32 by 32 bit MUL instead

__
wolfgang









.



Relevant Pages