Re: newbie: MUL product



Brian wrote:


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.

Sure, don't use a 16 but a 32 bit multiplication.

00000100: 66 a1 010a move.l val1,r0
00000104: 66 f7 26 010e mulu.l val2,r0,r1|r0
00000109: c3 rts.w

0000010a: 00002000 val1: dc.l $2000
0000010e: 00000100 val2: dc.l $0100



TITLE MULPract (mul.asm)
INCLUDE Irvine32.inc

.data
val1 WORD 2000h
val2 WORD 0100h

.code
main PROC
mov ax, val1
mul val2
;mov ebx, dx:ax ;<== doesn't work
shl edx, 16 ;<== this works but requires 2 instructions
mov dx, ax ; --- shl then mov
exit
main ENDP
END main
.