The context of this problem is the AVR Microcontroller Write
The context of this problem is the AVR Microcontroller. Write a program to convert the following packed BCD numbers to ASCII. Place the ASCII codes into R20 and R21. This must be done in assembly language
Solution
Here Assume the Packed BCD Number 29H
.INCLUDE \"M32DEF.INC\"
LDI R19,0x29 ;the packed bcd to be converted 29
MOV R20,R19 ;R20=R19=29H
ANDI R20,0x0F ;mask the upper nibble (R20=09H)
ORI R20,0x30 ;make it ASCII (R20=39H)
MOV R21,R19 ;R21=R19=29H
SWAP R21 ;swap nibbles (R21=92H)
ANDI R21,0x0F ;mask the upper nibble (R21=02)
ORI R21,0x30 ;make it ASCII (R22=32H)
HERE: JMP HERE
