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 :

[codesyntax lang=”asm” lines=”normal”]

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

[/codesyntax]

Screen shots :-

Asm_program_Return_Bit

After Execution :-

Asm_program_Return_Bit_Output

Leave a Reply