Sunday, January 16, 2022

Write a program to find max and min numbers from an array of [5] by taking value from the user.

INCLUDE C:\IRVINE\IRVINE32.INC

.386

.STACK 4096

EXITPROCESS PROTO,DWEXITCODE:DWORD

.DATA                                             

array dword  4,6,3,5,2

max dword ?

min dword ?

str1 BYTE "Maximum Number in This Array is :  ",0

str2 BYTE "Minimum Number in This Array is :  ",0

.CODE

MAIN PROC 

mov edx,OFFSET array

mov ecx,LENGTHOF array

 mov esi,0                                        

mov eax,array[esi]

mov max,eax

mov ebx, array[esi]

mov min,ebx

 l1::

 cmp ecx,0

 je next

 cmp eax,array[esi]

 ja next1

 mov eax,array[esi]

 add esi ,4

 loop l1

 jmp next

 next1:

 cmp ebx,array[esi]

 jb again

 mov ebx,array[esi]

 add esi,4

 dec ecx

 jmp l1

 again:

 add esi,4

 dec ecx

 jmp l1

 next:

 mov max,eax

 mov edx,OFFSET str1

 call WriteString

 call WriteInt

 call crlf

 mov edx,OFFSET str2

 call WriteString

 mov eax,ebx

 call WriteInt

INVOKE EXITPROCESS,0

MAIN ENDP

END MAIN 

No comments:

Post a Comment