Skip to content

Instantly share code, notes, and snippets.

@NikhilAshodariya
Created August 29, 2017 17:27
Show Gist options
  • Select an option

  • Save NikhilAshodariya/18e6a8b93f9509ccce693cd1bc4154fd to your computer and use it in GitHub Desktop.

Select an option

Save NikhilAshodariya/18e6a8b93f9509ccce693cd1bc4154fd to your computer and use it in GitHub Desktop.
Assembly language program to multiply two 16-bit nos
store macro res
div x
mov res,dl;dividing and storing the last bit in dl i.e. is the remainder
mov dx,0
endm
ansprint macro res
mov dl,res
add dl,30h
mov ah,02h
int 21h
endm
messageprint macro msg
mov dx,offset msg
mov ah,09h
int 21h
endm
input macro variable
mov ah,01h
int 21h
sub al,30h
mov bh,al
mov ah,01h
int 21h
sub al,30h
mov bl,al
mov variable,bx
endm
data segment
msg1 db "Enter one number $"
msg2 db 10,13,"Enter second number $"
msg3 db 10,13,"result = $"
number1 dw 0
number2 dw ?
ans dw ?
carry dw ?
res db 8 dup(0)
x dw 10
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
;displaying the message
messageprint msg1
;taking 8 bit of the 1st input number
input bx
;combing two numbers
mov ax,bx
aad
mov bx,0100
mul bx
mov bx,ax;number is in ax and storing it in bx
mov number1,bx
;takin remaing 8bit of 1st number
input bx
;combing two number
mov ax,bx
aad
mov bx,ax
mov ax,number1
add ax,bx
mov number1,ax;storing the first number in number1
;taking second number
;displaying the message
messageprint msg2
;taking 8 bit of the 2nd input number
input bx
;combing two numbers
mov ax,bx
aad
mov bx,0100
mul bx
mov bx,ax;number is in ax and storing it in bx
mov number2,bx
;takin remaing 8bit of 1st number
input bx
;combing two number
mov ax,bx
aad
mov bx,ax
mov ax,number2
add ax,bx
mov number2,ax ;the second number is stored in number2
;multiplying the two number
mov ax,number1
mov cx,number2
mul cx
mov ans,ax
mov carry,dx
;storing the answer
store res+7
store res+6
store res+5
store res+4
store res+3
store res+2
store res+1
store res+0
;displaying the ans message
messageprint msg3
;displaying the answer
ansprint res+0
ansprint res+1
ansprint res+2
ansprint res+3
ansprint res+4
ansprint res+5
ansprint res+6
ansprint res+7
;terminate the program
mov ax,4c00h
int 21h
code ends
end start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment