A procedure in Assembly Language that accepts a 2 digit input from the keyboard to packed BCD – IGNOU MCA Assignment 2014-15

By | August 16, 2015

 MASTER OF COMPUTER APPLICATIONS

Course Code : MCS-012
Course Title : Computer Organisation and Assembly Language Programming
Assignment Number : MCA(1)/012/Assign/2015-16
Maximum Marks : 100
Weightage : 25%

 

Write a program in 8086 assembly language that accepts a 2 digit input from the keyboard (as ASCII input) into packed BCD number. The packed BCD number may be stored in memory.

 

DATA SEGMENT
MSG1 DB “ENTER NUMBER : $”
DIGIT1 DB ?
DIGIT2 DB ?
BCD 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
MOV BCD,AL

CODE ENDS

END START

Program Code :

  1. DATA SEGMENT
  2. MSG1 DB "ENTER NUMBER : $"
  3. DIGIT1 DB ?
  4. DIGIT2 DB ?
  5. BCD 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. MOV BCD,AL
  29. CODE ENDS
  30. END START

Screen shots :-

Asm_program_4digit_2_packed_BCD

Before Execution :-

Asm_program_4digit_2_packed_BCD_O1

After Execution :

-Asm_program_4digit_2_packed_BCD_O2

Asm_program_4digit_2_packed_BCD_O3