Write an assembly language to determine whether a number is odd or even.
Experiment
Name:
Write an assembly language to determine whether a number is odd or even.
Objective:
(i)
To
know about several command in the Assembly language.
(ii)
Input
a Character.
(iii)
Output
a Character.
Source
Code:
.model small
print macro msg
lea
dx,msg
mov
ah,09h
int
21h
endm ;end
of macro
.data
msg1db0dh,0ah, ‘Enter the number:$’
msg2 db0dh,0ah, ‘It is an even number. $’
msg3 db 0dh,0ah, ‘It is an odd number. $’
.code
main proc
mov
ax,@data
mov
ds,ax
print
msg1
mov
ah,01h
int
21h
sub
al,30h
mov
bl,02
div
bl
cmp
ah,00
jz
s2
print
msg3
jmp
l4
s2:
print
msg2
l4:
mov
ah,4ch
int
21h
main endp
end main
Input/output:
Enter
the number:3
It
is an odd number.
Enter
the number:4
It
is an even number.
No comments
Dear Members, Thanks for Your Comments. We must be reply your comment answer as soon as possible. Please Stay with us.....