Create a block of assembly code which will perform a 16-bit unsigned binary mult
ID: 3587076 • Letter: C
Question
Create a block of assembly code which will perform a 16-bit unsigned binary multiplication. Remember that binary multiplication is just the addition of multiple partial products. For example, 5 x 7 in binary would be: 0101 (5) x 0111 (7)- 0000000000000101 (5-multiplier) X0000000000000111 (7-multiplicand) 0000000000000101 (5&1 This is 7) 0000000000000101 (5&1 transposed with) 0000000000000101 (5&1 each bit ANDed) (5&0 with 5.) Note: I didn't show all of the 0&0 partial product operations, but there are 16 partial products in al1, and the answer should be 32-bits long.> (0&0) 00000000000000000000000000100011 (35) The partial products were created by ANDing each of the individual bits of 7 by the value of 5, shifted to the left to match the power of the bit position being ANDed with it.Explanation / Answer
Here i am writing code for multiplication in 8086 assembly language.
source code:
code segment
assume ds:data, cs:code
start:
mov ax,data
mov ds,ax
mov ax,p
mov bx,q
mul bx
mov word ptr r,ax
mov word ptr r+2,dx
int 3
code ends
end start
data segment
p dw 0005h
q dw 0007h
r dd ?
data ends
here by multiplying two 16 bit numbers we'll get a 32 bit number but our internal registers are only 16 bit so the upper 16 bit of the result will be stored in the regidter dx and the lower 16 bits of the result will be stored in the register bx.