An Assembly Language program to convert a packed BCD into ASCII digits – IGNOU MCA Assignment 2014 – 15

By | July 18, 2014

 MASTER OF COMPUTER APPLICATIONS
Course Code : MCS-012
Course Title : Computer Organisation and Assembly Language Programming
Assignment Number : MCA(1)/012/Assign/2014-15
Maximum Marks : 100
Weightage : 25%

 

Write a program in 8086 assembly language to convert a four digit packed BCD number into equivalent ASCII digits. The packed BCD number may be assumed to be stored in memory. Your program should print the four ASCII digits.

 

DATA SEGMENT
BCD DW 1234H
ASCII DB 5 DUP (‘$’)
DATA ENDS

CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX

MOV AX,BCD
MOV BH,AH
MOV BL,AL

AND AH,0F0H
AND BH,0FH
AND AL,0F0H
AND BL,0FH

MOV CL,04H
ROL AH,CL

MOV CL,04H
ROL AL,CL

ADD AX,3030H
ADD BX,3030H

LEA SI,ASCII

MOV [SI],AH
INC SI

MOV [SI],BH
INC SI

MOV [SI],AL
INC SI

MOV [SI],BL
INC SI

LEA DX,ASCII
MOV AH,9
INT 21H

MOV AH,4CH
INT 21H
CODE ENDS

END START

program code :

  1. DATA SEGMENT
  2. BCD DW 1234H
  3. ASCII DB 5 DUP ('$')
  4. DATA ENDS
  5. CODE SEGMENT
  6. ASSUME DS:DATA,CS:CODE
  7. START:
  8. MOV AX,DATA
  9. MOV DS,AX
  10. MOV AX,BCD
  11. MOV BH,AH
  12. MOV BL,AL
  13. AND AH,0F0H
  14. AND BH,0FH
  15. AND AL,0F0H
  16. AND BL,0FH
  17. MOV CL,04H
  18. ROL AH,CL
  19. MOV CL,04H
  20. ROL AL,CL
  21. ADD AX,3030H
  22. ADD BX,3030H
  23. LEA SI,ASCII
  24. MOV [SI],AH
  25. INC SI
  26. MOV [SI],BH
  27. INC SI
  28. MOV [SI],AL
  29. INC SI
  30. MOV [SI],BL
  31. INC SI
  32. LEA DX,ASCII
  33. MOV AH,9
  34. INT 21H
  35. MOV AH,4CH
  36. INT 21H
  37. CODE ENDS
  38. END START

Screen shots :-

Asm_program_4digitBCD_2_ASCII

Before Execution :-

Asm_program_4digitBCD_2_ASCII_V1

After Execution :-

Asm_program_4digitBCD_2_ASCII_V2

Asm_program_4digitBCD_2_ASCII_Out

Leave a Reply