8086 Program To Convert An 8 Bit BCD Number Into Hexadecimal Number
The document describes an 8086 assembly language program that converts an 8-bit BCD number to hexadecimal. The program stores the BCD number in memory location 500, retrieves the upper and lower nibbles separately using AND instructions, rotates the lower nibble, multiplies it by 10 and adds the upper nibble to calculate the hexadecimal equivalent, which is stored in memory location 600. The program uses registers SI, DI, AL, BL, CL and DL and ends with an HLT instruction.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100%(1)100% found this document useful (1 vote)
1K views
8086 Program To Convert An 8 Bit BCD Number Into Hexadecimal Number
The document describes an 8086 assembly language program that converts an 8-bit BCD number to hexadecimal. The program stores the BCD number in memory location 500, retrieves the upper and lower nibbles separately using AND instructions, rotates the lower nibble, multiplies it by 10 and adds the upper nibble to calculate the hexadecimal equivalent, which is stored in memory location 600. The program uses registers SI, DI, AL, BL, CL and DL and ends with an HLT instruction.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4
8086 program to convert an 8 bit BCD number into
hexadecimal number
Problem – Write an assembly language program in 8086 microprocessor to convert
an 8 bit BCD number into hexadecimal number.
Example –
Assumption –
Initial value of segment register is 00000.
Calculation of physical memory address: Memory Address = Segment Register * 10(H) + Offset where Segment Register is 00000 (Assumption) and Offset is given in the program. Algorithm
1. Assign value 500 in SI and 600 in DI.
2. Move the contents of [SI] in BL.
3. Use AND instruction to calculate AND between 0F and
contents of BL.
4. Move the contents of [SI] in AL.
5. Use AND instruction to calculate AND between F0 and
contents of AL.
6. Move 04 in CL.
7. Use ROR instruction on AL.
8. Move 0A in DL.
9. Use MUL instruction to multiply AL with DL.
10. Use ADD instruction to add AL with BL.
11. Move the contents of AL in [DI].
12. Halt the program.
Program –
MEMORY ADDRESS MNEMONICS COMMENT
0400 MOV SI, 500 SI <- 500
0403 MOV DI, 600 DI <- 600
0406 MOV BL, [SI] BL <- [SI]
0408 AND BL, 0F BL = BL AND 0F
040A MOV AL, [SI] AL <- [SI]
040C AND AL, F0 BL = AL AND F0
040E MOV CL, 04 CL = 04
0410 ROR AL, CL Rotate AL
0412 MOV DL, 0A DL = 0A
0414 MUL DL AX = AL * DL
0416 ADD AL, BL AL = AL + BL
0418 MOV [DI], AL [DI] <- AL
041A HLT End of Program
Explanation – Registers used SI, DI, AL, BL, CL, DL.
1. MOV SI,500 is used to move offset 500 to Starting Index(SI)
2. MOV DI,600 is used to move offset 600 to Destination
Index(DI)
3. MOV BL,[SI] is used to move the contents of [SI] to BL
4. AND BL,0F is used to mask the higher order nibble
5. from BL
6. MOV AL,[SI] is used to move the contents of [SI] to AL
7. AND AL,F0 is used to mask the lower order nibble from BL
8. MOV CL,04 is used to move 04 to CL
9. ROR AL,CL is used to reverse the contents of AL
10. MOV DL,0A is used to move 0A to DL
11. MUL DL is used to multiply contents of AL with DL
12. ADD AL,BL is used to add contents of AL and BL
13. MOV [DI],AL is used to move the contents of AL to [DI]
14. HLT stops executing the program and halts any further execution