58 Program to convert BCD Number to Hexadecimal Number in 8086 Microprocessor

Code:

; Program to convert BCD Number to Hexadecimal Number
.MODEL SMALL
.STACK 100H
.DATA
BCD DB '1234'
HEX_NUM DW 0
MULT_FACTOR DW 1000
DIGIT_COUNT DW 4
.CODE
MOV AX , @DATA ; Initializing Data Segment
MOV DS , AX

MOV BX , 10 ; Initialize Division Factor

MOV CX , DIGIT_COUNT ; Initialize memory pointer
LEA SI , BCD

  UP:
MOV AL , [SI] ;Read digit from BCD
AND AX , 000FH ;Mask required digit
MUL MULT_FACTOR ; Multiply by multiplication factor
ADD HEX_NUM , AX ; Add to HEX Number
MOV AX , MULT_FACTOR ; Change Multiplication Factir
MOV DX , 00
DIV BX
MOV MULT_FACTOR , AX
INC SI
LOOP UP ; Is a last digit if no jump to up

MOV AX , HEX_NUM

MOV AH , 4CH ; Service Routine for Exit
INT 21H
END




Output:

 Program to convert BCD Number to Hexadecimal Number in 8086 Microprocessor

Previous
Next Post »