A near procedure in assembly lang. that converts a packed 2 digit BCD number stored in AL register to equivalent Binary number – IGNOU MCA Assignment 2015 – 16

By | August 18, 2015

BACHELOR OF COMPUTER APPLICATIONS

 

Course Code : BCSL-022
Course Title : Assembly Language Programming Lab
Assignment Number : BCA(II)/L-022/Assignment/2015
Maximum Marks : 50
Weightage : 25%

 

Write and run (using appropriate calling program) a near procedure in assembly language that converts a packed 2 digit BCD number stored in AL register to equivalent Binary number. For example, if AL contains a packed BCD number 64 as 0110 0100, then the program will convert this BCD to equivalent binary number 01000000. The binary number should be returned back in the AL register itself. 

 

DATA SEGMENT
MSG1 DB “ENTER NUMBER : $”
DIGIT1 DB ?
DIGIT2 DB ?
BINARY DB ?
DATA ENDS

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

LEA DX,MSG1
MOV AH,9
INT 21H

MOV AH,1
INT 21H
SUB AL,30H
MOV DIGIT1,AL

MOV AH,1
INT 21H
SUB AL,30H
MOV DIGIT2,AL

MOV AH,DIGIT1
MOV AL,DIGIT2

MOV CL,4
ROL AH,CL

ADD AL,AH

CALL CONVERT

MOV BINARY,AL

MOV AH,4CH
INT 21H

CODE ENDS

CONVERT PROC NEAR

MOV AH,0
MOV BL,AL

AND AL,0F0H
AND BL,0FH

MOV CL,04H
ROL AL,CL

MOV CL,10
MUL CL

ADD AL,BL
RET
CONVERT ENDP

END START

Program Code :

  1. DATA SEGMENT
  2. MSG1 DB "ENTER NUMBER : $"
  3. DIGIT1 DB ?
  4. DIGIT2 DB ?
  5. BINARY DB ?
  6. DATA ENDS
  7. CODE SEGMENT
  8. ASSUME DS:DATA,CS:CODE
  9. START:
  10. MOV AX,DATA
  11. MOV DS,AX
  12. LEA DX,MSG1
  13. MOV AH,9
  14. INT 21H
  15. MOV AH,1
  16. INT 21H
  17. SUB AL,30H
  18. MOV DIGIT1,AL
  19. MOV AH,1
  20. INT 21H
  21. SUB AL,30H
  22. MOV DIGIT2,AL
  23. MOV AH,DIGIT1
  24. MOV AL,DIGIT2
  25. MOV CL,4
  26. ROL AH,CL
  27. ADD AL,AH
  28. CALL CONVERT
  29. MOV BINARY,AL
  30. MOV AH,4CH
  31. INT 21H
  32. CODE ENDS
  33. CONVERT PROC NEAR
  34. MOV AH,0
  35. MOV BL,AL
  36. AND AL,0F0H
  37. AND BL,0FH
  38. MOV CL,04H
  39. ROL AL,CL
  40. MOV CL,10
  41. MUL CL
  42. ADD AL,BL
  43. RET
  44. CONVERT ENDP
  45. END START

Screen shots :-

Asm_program_Proc_Packed_BCD_to_AL(Binary)

After Execution :

Asm_program_Proc_Packed_BCD_to_AL(Binary)_Out