Write a program in assembly language to check whether a number is even or odd – IGNOU MCA Assignment 2017 – 18

By | December 7, 2017

MASTER OF COMPUTER APPLICATIONS

Course Code : MCSL-017
Course Title : C and Assembly Language Programming (Lab Course)
Assignment Number : MCA(1)/L-017/Assignment/17-18
Maximum Marks : 50
Weightage : 25%

Write a program in assembly language to check whether a number is even or odd – IGNOU MCA Assignment 2017 – 18

Code:-

DATA SEGMENT
MSG1 DB 10,13,’ENTER NUMBER HERE :- $’
MSG2 DB 10,13,’ENTERED VALUE IS EVEN$’
MSG3 DB 10,13,’ENTERED VALUE IS ODD$’

DATA ENDS

DISPLAY MACRO MSG
MOV AH,9
LEA DX,MSG
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX

DISPLAY MSG1

MOV AH,1
INT 21H
MOV AH,0

CHECK: MOV DL,2
DIV DL
CMP AH,0
JNE ODD

EVEN:
DISPLAY MSG2
JMP DONE

ODD:
DISPLAY MSG3

DONE:
MOV AH,4CH
INT 21H
CODE ENDS

END START

DATA SEGMENT
MSG1 DB 10,13,'ENTER NUMBER HERE :- $'
MSG2 DB 10,13,'ENTERED VALUE IS EVEN$'
MSG3 DB 10,13,'ENTERED VALUE IS ODD$'
DATA ENDS
DISPLAY MACRO MSG
MOV AH,9
LEA DX,MSG
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
DISPLAY MSG1
MOV AH,1
INT 21H
MOV AH,0
CHECK: MOV DL,2
DIV DL
CMP AH,0
JNE ODD
EVEN:
DISPLAY MSG2
JMP DONE
ODD:
DISPLAY MSG3
DONE:
MOV AH,4CH
INT 21H
CODE ENDS
END START

Screen Shots :-

Asm_program_Check_Even_Odd

After Execution :-

Asm_program_Check_Even_Odd_Output

Note :- To see the variable and its value you have to click vars button in the emulator.