Humble Beginner's Question: How do I mul 2 dwords and display results

Quote:

> I've been beating my head in with this one.

> I'd like some kind soul to explain how to do this without using the

> 486 instruction set (No EAX). If you use 4 words to hold the product,

> how do you display the results in decimal?

OK, so only 16-bit regs, right?

src1 dw ?,?

src2 dw ?,?

; Use DI:SI:CX:BP for temp storage of 64-bit result

saveSP dw ?

mov ax,[src1]

mov bx,[src2]

mul bx

mov bp,ax

mov cx,dx

mov ax,[src1+2]

mul bx

xor si,si

xor di,di

add cx,ax

adc si,dx

mov ax,[src1]

mov bx,[src2+2]

mul bx

add cx,ax

adc si,dx

adc di,di

mov ax,[src1+2]

mul bx

add si,ax

adc di,dx ; DI:SI:CX:BP has 64-bit result

mov bx,10 ; Divisor to be able to display the result

mov [saveSP],sp ; Remember stack position!

divloop:

xor dx,dx

mov ax,di

div bx

mov di,ax

mov ax,si

div bx

mov si,ax

mov ax,cx

div bx

mov cx,ax

mov ax,bp

div bx

push dx ; DX has remainder after the (very long) division!

mov bp,ax

or ax,cx

or ax,si

or ax,di

jnz divloop

mov cx,[saveSP]

disploop:

pop dx

add dl,'0'

mov ah,2

int 21h ; Display digit in DL

cmp cx,sp

jne disploop

--

"almost all programming can be viewed as an exercise in caching"