Thursday, May 14, 2015

.IF statement in Assembly Language

Write an assembly program that take age of 50 people and count the number of people lives in the age group given below ? Also print the age
 20 - 30 years
 40 - 50 years
 35 - 45 years
 25 - 45 years

include irvine32.inc

.data
msg byte ":  Enter a No: ",0
msg2 byte " Sory Range Not Found ",0
r1 byte "  --Range 20 - 30 years--  ",0
r2 byte "  --Range 40 - 50 years--  ",0
r3 byte "  --Range 35 - 45 years--  ",0
r4 byte "  --Range 25 - 45 years--  ",0

rr1 dword 0
rr2 dword 0
rr3 dword 0
rr4 dword 0

num dword 0
i dword 0

.code
Main proc
call clrscr
call crlf

.while i != 50
call crlf
call crlf

mov eax,i
call writedec
mov edx,offset msg
call writestring
call readint
mov num,eax

.if eax < 20 || eax > 50
call crlf
mov edx,offset msg2
call writestring
.endif

.if eax >= 20 && eax <=30
inc rr1
call crlf
mov edx,offset r1
call writestring

.endif

.if eax >= 40 && eax <= 50
inc rr2
call crlf
mov edx,offset r2
call writestring

.endif

.if eax >= 35 && eax <= 45
inc rr3
call crlf
mov edx,offset r3
call writestring

.endif

.if eax >= 25 && eax <= 45
inc rr4
call crlf
mov edx,offset r4
call writestring

.endif
inc i
.endw

call crlf
call crlf
mov edx,offset r1
call writestring
mov eax,rr1
call writedec
call crlf

mov edx,offset r2
call writestring
mov eax,rr2
call writedec
call crlf

mov edx,offset r3
call writestring
mov eax,rr3
call writedec
call crlf

mov edx,offset r3
call writestring
mov eax,rr3
call writedec
call crlf
exit
main endp
end main


Share this

0 Comment to ".IF statement in Assembly Language "