A procedure in Assembly Language to convert two unpacked BCD to packed BCD – IGNOU MCA Assignment 2014-15

By | July 22, 2014

BACHELOR OF COMPUTER APPLICATIONS
Course Code : BCSL-022
Course Title : Assembly Language Programming Lab
Assignment Number : BCA(II)/BCSL022/Assign/14-15
Maximum Marks : 50
Weightage : 25%

 

Write and run (using appropriate calling program) a near procedure in assembly language that converts two unpacked BCD digits to a packed BCD digit. Both the unpacked BCD digits are passed as parameters on the stack. The packed BCD byte is returned back on the AL register itself.

 

DATA SEGMENT
BCD DB ?
DATA ENDS

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

PUSH 04H
PUSH 05H

CALL PACKBCD

MOV BCD,AL

MOV AH,4CH
INT 21H
CODE ENDS

PACKBCD PROC NEAR
POP DX

POP AX
MOV AH,AL

POP BX
MOV AL,BL

MOV CL,4
ROL AH,CL

ADD AL,AH

PUSH DX
RET
PACKBCD ENDP

END START

Program Code :

  1. DATA SEGMENT
  2. BCD DB ?
  3. DATA ENDS
  4. CODE SEGMENT
  5. ASSUME CS:CODE
  6. START:
  7. MOV AX,DATA
  8. MOV DS,AX
  9. PUSH 04H
  10. PUSH 05H
  11. CALL PACKBCD
  12. MOV BCD,AL
  13. MOV AH,4CH
  14. INT 21H
  15. CODE ENDS
  16. PACKBCD PROC NEAR
  17. POP DX
  18. POP AX
  19. MOV AH,AL
  20. POP BX
  21. MOV AL,BL
  22. MOV CL,4
  23. ROL AH,CL
  24. ADD AL,AH
  25. PUSH DX
  26. RET
  27. PACKBCD ENDP
  28. END START

Screen shots :-

Asm_program_Unpack_Pack_BCD_Ftn

Before Execution :-

Asm_program_Unpack_Pack_BCD_Ftn_v1

After Execution :-

Asm_program_Unpack_Pack_BCD_Ftn_v2

Leave a Reply