Nasar Ali F21605044

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Name: Nasar Ali

Id: F21605044

Course: Coal Lab

Examination Type: ESE

Question#5:

Code:

.686

.MODEL flat,stdcall

.STACK

INCLUDE Irvine32.inc

.data

arr byte 10 dup(0)

max byte ?

min byte ?

string1 byte "Maximum element is:",0

string2 byte "Minimum element is:",0

.code

main PROC

mov ecx ,10

mov esi,offset arr

input:

call readdec

mov [esi],eax

inc esi

loop input
mov ecx ,10

mov esi,offset arr

display:

mov al,[esi]

call writedec

inc esi

loop display

;finding minimum element

mov ecx ,10

mov esi,0

mov al,[arr+esi]

mov min,al

min_ele:

inc esi

mov al,[arr+esi]

cmp min,al

jg L1

cmp ecx,esi

jge pr

loop min_ele

L1:

mov min, al

loop min_ele
pr:

call crlf

lea edx,string2

call writestring

movzx eax,min

call writedec

;finding minimum element

mov ecx ,10

mov esi,0

mov al,[arr+esi]

mov max,al

max_ele:

inc esi

mov al,[arr+esi]

cmp max,al

jl L2

cmp ecx,esi

jge pr2

jmp max_ele

L2:

mov max, al

loop max_ele

pr2:
call crlf

lea edx,string1

call writestring

movzx eax,max

call writedec

exit

main ENDP

end main

Output:
Question#6

Code:

.686

.MODEL flat,stdcall

.STACK

INCLUDE Irvine32.inc

.code

main PROC

mov ecx,15

L1:

mov eax,11

call randomrange

add eax,10

call writedec

call crlf

loop L1

exit

main ENDP

end main

Output:

You might also like