Conversion of BCD to HEX in Assembly – masm 8086

Conversion of BCD to HEX in Assembly – masm 8086

org 100h
.model small
.data
Var DW 9999d
.code
;Initlize Data Segment
mov ax,@DATA
mov DS,ax
mov bx,Var
mov al,bh
mov ah,00h
mov cl,10h
div cl
mov dh,ah
mov cl,al
CALL PRINT
mov dl,dh
mov cl,dl
CALL PRINT
mov al,bl
mov ah,00h
mov cl,10h
div cl
mov dh,ah
mov cl,al
CALL PRINT
mov cl,dh
CALL PRINT
;to terminate program
mov ah, 4ch
int 21h
ret
PRINT PROC ;print procedure to print
;number
cmp cl,09
jle ad
add cl,07h ;if less than 9 ,add 30h
ad: add cl,30h ;if greater than 9,add 37h
mov dl,cl
mov ah,02h
int 21h
ret
PRINT ENDP

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