as part of an assignment i have been trying to multiply two 32 bit numbers and store the result in a 64bit place. However, my result is incorrect. please help me figure why
[org 0x0100]
jmp start
multiplicand: dd 100122,0
multiplier: dd 66015
result: dd 0,0
start:
initialize: mov cl,16
mov bl,1
checkbit: test bl,[multiplier]
jz decrement
multiply: mov ax, [multiplicand]
add [result],ax
mov ax, [multiplicand+2]
adc [result+2], ax
mov ax, [multiplicand+4]
adc [result+4], ax
decrement: shl bl,1
shl [multiplicand],1
rcl [multiplicand+2],1
rcl [multiplicand+4],1
dec cl
jnz checkbit
mov ax, 0x4c00
int 0x21
the answer in afd debugger is F6B3A6 (16587802 IN DEC) whereas it should be 189F5C9A6 (6609553830 in dec). I have gone through the debugger but am unable to find anything wrong with the code.
Replace
mov cl,16
bymov cl,32
.Don't forget
[multiplicand+6]
.See the comments for a few d'oh's: