An Assembly Language program to convert packed BCD to equivalent binary – IGNOU MCA Assignment 2013

By | April 15, 2014

BACHELOR  OF COMPUTER APPLICATIONS
Course Code : BCSL-022
Course Title : Assembly Language Programming Lab
Assignment Number : BCA(II)/BCSL022/Assign/13

 

Write and run an assembly language program that converts a packed two digit BCD number in AL register to equivalent binary number. The binary number is stored in the AH register

 

DATA SEGMENT
     PACKEDBCD DB 52H
     BINARY    DB ?
DATA ENDS
CODE SEGMENT
    ASSUME DS:DATA CS:CODE
START:
      MOV AX,DATA
      MOV DS,AX
    
      MOV AH,0
      MOV AL,PACKEDBCD
      MOV BL,AL
     
      AND AL,0F0H
      AND BL,0FH
     
      MOV CL,04H
      ROL AL,CL
     
      MOV CL,10
      MUL CL
     
      ADD AL,BL
     
      MOV AH,AL
      MOV BINARY,AH    
          
      MOV AH,4CH
      INT 21H    
CODE ENDS
END START

 

program code :

  1. DATA SEGMENT
  2.      PACKEDBCD DB 52H
  3.      BINARY    DB ?
  4. DATA ENDS
  5. CODE SEGMENT
  6.     ASSUME DS:DATA CS:CODE
  7. START:
  8.       MOV AX,DATA
  9.       MOV DS,AX
  10.     
  11.       MOV AH,0
  12.       MOV AL,PACKEDBCD
  13.       MOV BL,AL
  14.      
  15.       AND AL,0F0H
  16.       AND BL,0FH
  17.      
  18.       MOV CL,04H
  19.       ROL AL,CL
  20.      
  21.       MOV CL,10
  22.       MUL CL
  23.      
  24.       ADD AL,BL
  25.      
  26.       MOV AH,AL
  27.       MOV BINARY,AH    
  28.           
  29.       MOV AH,4CH
  30.       INT 21H    
  31. CODE ENDS
  32. END START

Screen shots :-

Asm_program_Packed_BCD_to_Binary

Before Execution :-

Asm_program_Packed_BCD_to_Binary_V1

After Execution :-

 Asm_program_Packed_BCD_to_Binary_V2

Leave a Reply