Task 1: Irvine32.inc

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

include Irvine32.

inc
.data
marks dd ?
Task 1
msg byte "please enter marks in percentage form : ",0
s1 byte "grade A",0
s2 byte "grade B ",0
s3 byte "grade C",0 ;creating required data
s4 byte "grade D",0
s5 byte "grade F",0
.code
main proc

mov edx , offset msg


call writestring
call readint ;display msg
mov marks , eax

cmp eax , 90 ; comparing values


jge l1 ; jump if eax is greater or equal then 90

cmp eax , 80
jge l2

cmp eax , 70
jge l3

cmp eax , 60
jge l4

cmp eax , 50
jge l5

l1: ;label 1 code will execute if condition is met


mov edx , offset s1
call writestring
jmp next ; use to break after successful execution

l2:
mov edx , offset s2 ; similar process for all other labels
call writestring
jmp next

l3:
mov edx , offset s3
call writestring
jmp next

l4:
mov edx , offset s4
call writestring
jmp next

l5:
mov edx , offset s5
call writestring
jmp next

next:
exit
main endp
end
include Irvine32.inc
.data
num1 dd ?
num2 dd ?
Task 2
s1 byte "enter 1st number:",0 ; asking for two numbers
s2 byte "enter 2nd number:",0
s3 byte "greater :",0
s4 byte "equal",0
.code
main proc

mov edx , offset s1 ;printing s1 and take value from user


call writestring
call readint
mov num1 , eax ;value is move to num1 variable

mov edx , offset s2 ;printing s2 and take value from user


call writestring
call readint ; value is not move so we can compare it with num1

cmp eax , num1 ;compare bother number


JG l1 ;if eax is greater then code under l1 will execute
jl nxt ;if eax is lesser then code under nxt will execute
je l3 ;if both are equal then code under l3 will execute

l1:
mov edx , offset s3 ;print s3
call writestring
call writeint ; print greater number
jmp ntt ; break after code is successfully execute

nxt:
call crlf ;mov to output to next line
mov eax , num1 ;if number 2 is lesser then num1 is moved to eax
mov edx , offset s3
call writestring
call writeint ; now eax is with greater number and it will be printed
jmp hh ; break for this code of block

l3:
mov edx , offset s4 ;this will execute If both numbers are equal
call writestring
ntt:
hh:

exit
main endp
end
include Irvine32.inc
.data
num1 dd ?
num2 dd ?
Task 3
s1 byte "enter 1st number:",0 ; asking for two numbers
s2 byte "enter 2nd number:",0
s3 byte "greater :",0
s4 byte "equal",0
.code
main proc

mov edx , offset s1 ;printing s1 and take value from user


call writestring
call readint
mov num1 , eax ;value is move to num1 variable

mov edx , offset s2 ;printing s2 and take value from user


call writestring
call readint ; value is not move so we can compare it with num1

cmp eax , num1 ;compare both number


Jl l1 ;if eax is lesser then, code under l1 will execute
jg nxt ;if eax is lesser then ,code under nxt will execute
je l3 ;if both are equal then code under l3 will execute

l1:
mov edx , offset s3 ;print s3
call writestring
call writeint ; print lesser number
jmp ntt ; break after code is successfully execute

nxt:
call crlf ;mov to output to next line
mov eax , num1 ;if number 2 is greater then num1 is moved to eax
mov edx , offset s3
call writestring
call writeint ; now eax is with lesser number and it will be printed
jmp hh ; break for this code of block

l3:
mov edx , offset s4 ;this will execute If both numbers are equal
call writestring
ntt:
hh:

exit
main endp
end

You might also like