Multiplication in Assembly Language
Multiplication in Assembly Language
Theory :
There are two instructions for multiplying binary data. The MUL (Multiply) instruction handles unsigned
data and the IMUL (Integer Multiply) handles signed data. Both instructions affect the Carry and
Overflow flag.
Syntax
The syntax for the MUL/IMUL instructions is as follows −
MUL/IMUL multiplier
Multiplicand in both cases will be in an accumulator, depending upon the size of the multiplicand and
the multiplier and the generated product is also stored in two registers depending upon the size of the
operands.
The multiplicand is in the AL register, and the multiplier is a byte in the memory or in another register.
The product is in AX. High-order 8 bits of the product is stored in AH and the low-order 8 bits are stored
in AL.
Code :
.model small
.stack 100h
.data
.code
Main proc
Mov ax,@data
Mov ds,ax
Mov ah,9
Lea dx,msg1
int 21h
Mov ah,1
Int 21h
Sub al,48
Mov cl,al
Mov ah,2
Mov dl,0dh
Int 21h
Mov dl,0ah
Int 21h
Mov ah,9
Lea dx,msg2
Int 21h
Mov ah,1
Int 21h
Sub al,48
Mul cl
Mov cl,al
Add cl,48
Mov ah,2
Mov dl,0dh
Int 21h
Mov dl,0ah
Int 21h
Mov ah,9
Lea dx,msg3
Int 21h
Mov ah,2
Mov dl,cl
Int 21h
Main endp
End main
Output:
Discussion :