A program in Assembly language to convert two unpacked to packed BCD – IGNOU MCA Assignment 2013

By | April 14, 2014

MASTER OF COMPUTER APPLICATIONS
Course Code : MCS-012
Course Title : Computer Organisation and Assembly Language Programming
Assignment Number : MCA(1)/012/Assign/2013 and BCA(II)/012/Assign/2013

 

Write a program in 8086 assembly language to convert a two digit unpacked BCD number into equivalent ASCII digits and a packed BCD number. The packed BCD number is to be stored in BH register. Your program should print the two ASCII digits. You may assume that the unpacked BCD numbers are in the AL and BL registers

 

DATA SEGMENT
UNPACKEDBCD1 DB 05H
UNPACKEDBCD2 DB 02H
ASCII1       DB ?
ASCII2       DB ?
PACKEDBCD    DB ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX

MOV AL,UNPACKEDBCD1
MOV BL,UNPACKEDBCD2

MOV AH,AL
MOV BH,BL

ADD AH,30H
ADD BH,30H

MOV ASCII1,AH
MOV ASCII2,BH

MOV CL,04H
ROL AL,CL
OR  AL,BL

MOV BH,AL
MOV PACKEDBCD,BH

MOV DL,ASCII1
MOV AH,2
INT 21H

MOV DL,ASCII2
MOV AH,2
INT 21H

MOV AH,4CH
INT 21H
CODE ENDS
END START

program code :

  1. DATA SEGMENT
  2. UNPACKEDBCD1 DB 05H
  3. UNPACKEDBCD2 DB 02H
  4. ASCII1       DB ?
  5. ASCII2       DB ?
  6. PACKEDBCD    DB ?
  7. DATA ENDS
  8. CODE SEGMENT
  9. ASSUME DS:DATA CS:CODE
  10. START:
  11. MOV AX,DATA
  12. MOV DS,AX
  13. MOV AL,UNPACKEDBCD1
  14. MOV BL,UNPACKEDBCD2
  15. MOV AH,AL
  16. MOV BH,BL
  17. ADD AH,30H
  18. ADD BH,30H
  19. MOV ASCII1,AH
  20. MOV ASCII2,BH
  21. MOV CL,04H
  22. ROL AL,CL
  23. OR  AL,BL
  24. MOV BH,AL
  25. MOV PACKEDBCD,BH
  26. MOV DL,ASCII1
  27. MOV AH,2
  28. INT 21H
  29. MOV DL,ASCII2
  30. MOV AH,2
  31. INT 21H
  32. MOV AH,4CH
  33. INT 21H
  34. CODE ENDS
  35. END START

Screen shots :-

Asm_program_Unpacked_Packed_BCD

Output :-

Asm_program_Unpacked_Packed_BCD_Output

Variables before Execution :-

Asm_program_Unpacked_Packed_BCD_V1

Variables before Execution :-

Asm_program_Unpacked_Packed_BCD_V2

Leave a Reply