Following program is for conversion of ASCII to packed BCD numbers
For execution of this program, we load the 1st ASCII digit into BL and the second ASCII number into the second AL. Then we mask the upper 4 bits of 1st digit and load CL for 4 rotate required. ROtate BL 4 bit position and combine nibbles, result in AL and finally we HALT the program.
CODE:
MOV BL,35H
MOV AL,39H
AND BL,0F
AND AL,0F
MOV CL,04
ROL BL,CL
OR AL,BL
INT A5
OUTPUT: 59 Packed BCD Number
Showing posts with label bcd to ascii. Show all posts
Showing posts with label bcd to ascii. Show all posts
Dec 5, 2008
Sep 11, 2008
Assembly program to convert BCD to ASCII
Assembly program to convert BCD to ASCII
Initially the input is moved in SI register , then its divided by 10 and then 30 is added to the number for both AH, AL i.e. the 8 bit higher and lower registers. Then the output is moved to the destination index register.
Following is the program code in assembly language to convert a BCD number to ASCII.
MOV SI,2000
MOV DI,4000
MOV AX,[SI]
MOV BL,10
DIV BL
MOV DL,30
ADD AL,DL
ADD AH,DL
MOV [DI],AX
INT A5
Example Input: 08 , Output: 30 38
You might be also interested in:
:: Interfacing Analog-to-Digital converter to 8086 using 8255
:: Interfacing Digital-To-Analog converter to 8086 using 8255
Initially the input is moved in SI register , then its divided by 10 and then 30 is added to the number for both AH, AL i.e. the 8 bit higher and lower registers. Then the output is moved to the destination index register.
Following is the program code in assembly language to convert a BCD number to ASCII.
MOV SI,2000
MOV DI,4000
MOV AX,[SI]
MOV BL,10
DIV BL
MOV DL,30
ADD AL,DL
ADD AH,DL
MOV [DI],AX
INT A5
Example Input: 08 , Output: 30 38
You might be also interested in:
:: Interfacing Analog-to-Digital converter to 8086 using 8255
:: Interfacing Digital-To-Analog converter to 8086 using 8255
Labels:
bcd to ascii
Subscribe to:
Posts (Atom)