Mutiply 8-bit numbers in Assembly -masm 8086

Mutiply 8-bit numbers in Assembly -masm 8086

org 100h
.stack 100h
.data
A DB 40
B DB 20
.code
;Initilization of Data Segment
mov ax,@DATA
mov DS,ax
; Addition of Two Numbers
mov al,A
mov ah,00h
mov dh,B
mul dh
mov cx,ax
;SHR 4 bits
mov bl,ch
shr bl,4
and bl,0fh
cmp bl,9
jle ad
add bl,07h
ad: add bl,30h
mov dl,bl
;function to print ascii of dl register content
mov ah,02h
int 21h
mov bl,ch
; rotate left 4 bits first nibble comes at second nibble
rol bl,4
shr bl,4
and bl,0fh
cmp bl,9
jle ad1
add bl,07h
ad1: add bl,30h
mov dl,bl
mov ah,02h
int 21h
;===========================================
;SHR 4 bits
mov bl,cl
shr bl,4
and bl,0fh
cmp bl,9
jle ad2
add bl,07h
ad2: add bl,30h
mov dl,bl
;function to print ascii of dl register content
mov ah,02h
int 21h
mov bl,cl
; rotate left 4 bits first nibble comes at second nibble
rol bl,4
shr bl,4
and bl,0fh
cmp bl,9
jle ad3
add bl,07h
ad3: add bl,30h
mov dl,bl
mov ah,02h
int 21h
;to terminate program
mov ah,4ch
int 21h
ret

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s