32-bit multiplication with 16-bit registers - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# 32-bit multiplication with 16-bit registers

Posts: 31Member
Not sure how to preceed with this program. Its a program that will multiply 2 32-bit numbers on 16-bit registers. The final outcome will be that registers AX BX CX DX will hold the 32-bit solution. This is what I have so far....Thanks for your help!!
[code]

; num1 Low * num2 Low
mov ax, [num2]
mov bx, [num4]
mul bx
mov [temp], ax
mov [temp1], dx

; num2 low * num1 high
mov ax, [num1]
mov bx, [num4]
mul bx
mov [temp2], ax
mov [temp+6], dx

; num1 low * num2 high
mov ax, [num2]
mov bx, [num3]
mul bx
mov [temp3+3], ax
mov [temp+10], dx

; num1 high * num2 high
mov ax, [num1]
mov bx, [num3]
mul bx
mov [temp4+4]. ax
mov [temp+14], dx

mov ax, [temp1]
mov bx, [temp+6]
mov cx, 0
mov dx, 0
mov word [result], ax

mov ax, [result]
mov bx, [temp+10]
mov cx, 0
mov dx, 0
mov word [result+4], ax

mov dx, [result+8]
Data:
num1 dw 0xFE1F
num2 dw 0x3699
num3 dw 0x0987
num4 dw 0x6543
result times 20 dw 0x00000000
temp dw 0x00000000
temp1 dw 0x00000000
temp2 dw 0x00000000
temp3 dw 0x00000000
temp4 dw 0x00000000
temp5 dw 0x00000000
[/code]

• Posts: 84Member
: Not sure how to preceed with this program. Its a program that will multiply 2 32-bit numbers on 16-bit registers. The final outcome will be that registers AX BX CX DX will hold the 32-bit solution. This is what I have so far....Thanks for your help!!
: [code]
:
: ; num1 Low * num2 Low
: mov ax, [num2]
: mov bx, [num4]
: mul bx
: mov [temp], ax
: mov [temp1], dx
:
: ; num2 low * num1 high
: mov ax, [num1]
: mov bx, [num4]
: mul bx
: mov [temp2], ax
: mov [temp+6], dx
:
: ; num1 low * num2 high
: mov ax, [num2]
: mov bx, [num3]
: mul bx
: mov [temp3+3], ax
: mov [temp+10], dx
:
: ; num1 high * num2 high
: mov ax, [num1]
: mov bx, [num3]
: mul bx
: mov [temp4+4]. ax
: mov [temp+14], dx
:
:
: mov ax, [temp1]
: mov bx, [temp+6]
: mov cx, 0
: mov dx, 0
: mov word [result], ax
:
: mov ax, [result]
: mov bx, [temp+10]
: mov cx, 0
: mov dx, 0
: mov word [result+4], ax
:
: mov dx, [result+8]
: Data:
: num1 dw 0xFE1F
: num2 dw 0x3699
: num3 dw 0x0987
: num4 dw 0x6543
: result times 20 dw 0x00000000
: temp dw 0x00000000
: temp1 dw 0x00000000
: temp2 dw 0x00000000
: temp3 dw 0x00000000
: temp4 dw 0x00000000
: temp5 dw 0x00000000
: [/code]
:

If you mul a word register the value is stored at DX:AX.

• Posts: 31Member
: : Not sure how to preceed with this program. Its a program that will multiply 2 32-bit numbers on 16-bit registers. The final outcome will be that registers AX BX CX DX will hold the 32-bit solution. This is what I have so far....Thanks for your help!!
: : [code]
: :
: : ; num1 Low * num2 Low
: : mov ax, [num2]
: : mov bx, [num4]
: : mul bx
: : mov [temp], ax
: : mov [temp1], dx
: :
: : ; num2 low * num1 high
: : mov ax, [num1]
: : mov bx, [num4]
: : mul bx
: : mov [temp2], ax
: : mov [temp+6], dx
: :
: : ; num1 low * num2 high
: : mov ax, [num2]
: : mov bx, [num3]
: : mul bx
: : mov [temp3+3], ax
: : mov [temp+10], dx
: :
: : ; num1 high * num2 high
: : mov ax, [num1]
: : mov bx, [num3]
: : mul bx
: : mov [temp4+4]. ax
: : mov [temp+14], dx
: :
: :
: : mov ax, [temp1]
: : mov bx, [temp+6]
: : mov cx, 0
: : mov dx, 0
: : mov word [result], ax
: :
: : mov ax, [result]
: : mov bx, [temp+10]
: : mov cx, 0
: : mov dx, 0
: : mov word [result+4], ax
: :
: : mov dx, [result+8]
: : Data:
: : num1 dw 0xFE1F
: : num2 dw 0x3699
: : num3 dw 0x0987
: : num4 dw 0x6543
: : result times 20 dw 0x00000000
: : temp dw 0x00000000
: : temp1 dw 0x00000000
: : temp2 dw 0x00000000
: : temp3 dw 0x00000000
: : temp4 dw 0x00000000
: : temp5 dw 0x00000000
: : [/code]
: :
:
: If you mul a word register the value is stored at DX:AX.
:
:
Actually I figured it out. You don't declare the data values as dw, but as dd that way the data is stored as 8-bits. Then you just have to multiply then add. Pretty Simple :P Thanks for the help!