2. Program to convert a BCD number to ASCII
To convert packed BCD to ASCII, it must first be converted to to unpacked BCD. Then the unpacked BCD is tagged with 30h.
mov dptr,#9000h ;Load 9000h into dptr register
movx a,@dptr ;Move the content of location 9000h to a
mov r2,a ;Move the data from a to r2
anl a,#0f0h ;And a with 0f0h
swap a ;Swap a
orl a,#30h ;Or a with 30h
inc dptr ;increment dptr
movx @dptr,a ;move the data from a to memory location
mov a,r2 ; Move the data from r2 to a
anl a,#0fh ; And a with 0fh
orl a,#30h ;Or a with 30h
inc dptr ;increment dptr
movx @dptr,a ;move the data from a to memory location
here:sjmp here
end
Input: 45
Output:34 35
0 comments:
Post a Comment