Problem – Write an assembly language program in 8086 microprocessor to convert 8 bit BCD number to its respective ACSII Code.
Assuption –
Starting address of program: 400
Input memory location: 2000
Output memory location: 3000
Example :
Input:
DATA: 98H in memory location 2000
Output:
DATA: 38H in memory location 3000 and
39H in memory location 3001
Algorithm –
- Load contents of memory location 2000 in register AL
- Copy contents of register AL in register AH
- Perform AND operation on register AL with 0F
- Assign 04 to CL Register
- Shift the contents of AH by executing SHR instruction using CL
- Perform OR operation on register AX with 3030
- Store the content of AX in memory location 3000
Program –
| Memory Address | Mnemonics | Comments |
|---|---|---|
| 400 | MOV AL, [2000] | AL<-[2000] |
| 404 | MOV AH, AL | AH<-AL |
| 406 | AND AL, 0F | AL <- (AL AND 0F) |
| 408 | MOV CL, 04 | CL <- 04 |
| 40A | SHR AH, CL | Shift AH content Right by 4 bits(value of CL) |
| 40C | OR AX, 3030 | AX <- (AX OR 3030) |
| 40F | MOV [3000], AX | [3000]<-AX |
| 413 | HLT | Stop Execution |
Explanation –
- MOV AL, [2000]: loads contents of memory location 2000 in AL
- MOV AH, AL: copy contents of AL in AH
- AND AL, 0F: do AND operation on AL with 0F
- MOV CL, 04 assign 04 to CL register
- SHR AH, CL: shift the content of AH register right by 4 bits i.e. value of CL register
- OR AX, 3030: do OR operation on AX with 3030
- MOV [3000], AX: stores the content of AX register pair in 3000 memory address
- HLT: stops executing the program
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
Recommended Posts:
- 8086 program to convert 8 bit ASCII to BCD number
- 8085 program to convert 8 bit BCD number into ASCII Code
- 8086 program to convert an 8 bit BCD number into hexadecimal number
- 8086 program to add two 8 bit BCD numbers
- 8086 program to add two 16 bit BCD numbers with carry
- 8086 program to subtract two 8 bit BCD numbers
- 8086 program to subtract two 16 bit BCD numbers
- 8085 program to convert an 8 bit BCD number into hexadecimal number
- 8085 program to convert ASCII code into HEX code
- 8086 program to divide a 16 bit number by an 8 bit number
- 8085 program to convert a hexadecimal number into ASCII code
- 8086 program to reverse 8 bit number using 8 bit operation
- 8086 program to reverse 16 bit number using 8 bit operation
- 8085 code to convert binary number to ASCII code
- 8086 program to convert a 16 bit decimal number to binary
- 8086 program to convert a 16 bit Decimal number to Octal
- 8086 program to convert a 16 bit decimal number to Hexadecimal
- 8086 program to convert binary to Grey code
- 8085 program to convert a BCD number to binary
- 8086 program to find sum of digits of 8 bit number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

