A procedure in Assembly Language program to that receives parameter on stack It returns 0 – IGNOU MCA Assignment 2014-15

By | July 18, 2014

 MASTER OF COMPUTER APPLICATIONS
Course Code : MCS-012
Course Title : Computer Organisation and Assembly Language Programming
Assignment Number : MCA(1)/012/Assign/2014-15
Maximum Marks : 100
Weightage : 25%

 

Write a simple near procedure in 8086 assembly language that receives one 16 bit number as parameter value on the stack from the main module. It returns 0 if the upper byte of the number is 0, else returns 1. Make suitable assumptions, if any. 

 

DATA SEGMENT
MSG DB “BIT RETURNED IS : $”
DATA ENDS

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

MOV BX,0FFFH

LEA DX,MSG
MOV AH,9
INT 21H

PUSH BX

CALL CHECK

ADD DL,30H
MOV AH,2
INT 21H

MOV AH,4CH
INT 21H
CODE ENDS

CHECK PROC NEAR
POP AX
POP BX

AND BH,11110000B

MOV CL,4
ROL BH,CL

CMP BH,0
JE SKIP

MOV DL,1
JMP DONE
SKIP:
MOV DL,0
DONE:
PUSH AX
RET
CHECK ENDP

END START

program code :

  1. DATA SEGMENT
  2. MSG DB "BIT RETURNED IS : $"
  3. DATA ENDS
  4. CODE SEGMENT
  5. ASSUME DS:DATA,CS:CODE
  6. START:
  7. MOV AX,DATA
  8. MOV DS,AX
  9. MOV BX,0FFFH
  10. LEA DX,MSG
  11. MOV AH,9
  12. INT 21H
  13. PUSH BX
  14. CALL CHECK
  15. ADD DL,30H
  16. MOV AH,2
  17. INT 21H
  18. MOV AH,4CH
  19. INT 21H
  20. CODE ENDS
  21. CHECK PROC NEAR
  22. POP AX
  23. POP BX
  24. AND BH,11110000B
  25. MOV CL,4
  26. ROL BH,CL
  27. CMP BH,0
  28. JE SKIP
  29. MOV DL,1
  30. JMP DONE
  31. SKIP:
  32. MOV DL,0
  33. DONE:
  34. PUSH AX
  35. RET
  36. CHECK ENDP
  37. END START

Screen shots :-

Asm_program_Return_Bit

After Execution :-

Asm_program_Return_Bit_Output

Leave a Reply