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 :-
After Execution :-