Professional Documents
Culture Documents
Lab Task 6
Lab Task 6
COAL-255
Submitted To
Mr. Muhammad Jabbar
Submitted By
Muhammad Uzair Zafar
Roll Number
21011519-051
Section
A
Task 1:
Get the two numbers from user and perform comparison between them and show
greatest number.
Hint: Use CMP and JMP and JG commands.
Code:
include irvine32.inc
.data
num1 dd ?
.code
main proc
mov edx,offset s1
call writestring
call readint
mov num1,eax
mov edx,offset s2
call writestring
call readint
cmp eax,num1
jg l1
mov edx,offset s3
call writestring
mov eax,num1
call writedec
jmp next
l1:
mov edx,offset s3
call writestring
call writedec
call crlf
next:
call crlf
exit
main endp
end
Output Snip:
Task 2:
Get the two numbers from user and perform comparison between them and show
smallest number.
Hint: Use CMP and JMP and JL commands.
Code:
include irvine32.inc
.data
num1 dd ?
.code
main proc
mov edx,offset s1
call writestring
call readint
mov num1,eax
mov edx,offset s2
call writestring
call readint
cmp eax,num1
jl l1
mov edx,offset s3
call writestring
mov eax,num1
call writedec
jmp next
l1:
mov edx,offset s3
call writestring
call writedec
call crlf
next:
call crlf
exit
main endp
end
Output Snip:
Task 3:
Get the marks from user in percentage, perform comparison and show grade
80 or above show A grade
70 or above show B grade
60 or above show C grade
50 or above show D grade
Less than 50 show F grade
Code:
include irvine32.inc
.data
.code
main proc
continue:
mov edx,offset s1
call writestring
call readint
cmp eax,0
jl error
jge L1
jge L2
jge L3
jge L5
cmp eax,49 ;comparing for Fail grade if marks are less then 49
jle L6
; Lables
mov edx,offset s2
call writestring
call crlf
jmp next
L2: ; L2 display Grade B if marks are between 70-79
mov edx,offset s3
call writestring
call crlf
jmp next
mov edx,offset s4
call writestring
call crlf
jmp next
mov edx,offset s5
call writestring
call crlf
jmp next
mov edx,offset s6
call writestring
call crlf
jmp next
error: ;error displayed if Marks are Greater then 100 or less then 0
mov edx,offset s7
call writestring
call crlf
jmp continue
next:
exit
main endp
end
Error if Input is Greater then 100 or less then 0 how program behaves:
Grade A:
Grade B:
Grade C:
Grade D:
Grade Fail: