Sunday, January 16, 2022

Write instructions that and pop the largest number of array, after pop again print to array.

 INCLUDE C:\IRVINE\IRVINE32.INC

.386

.STACK 4096

EXITPROCESS PROTO,DWEXITCODE:DWORD

.DATA                                              

array dword 6,6,78,1,3,56,54,53,85,100

max dword ?

str1 BYTE "Largest Number is :  ",0

.CODE

MAIN PROC

mov edx,OFFSET array

mov ecx,LENGTHOF array

 mov esi,0

l1:

mov eax,array[esi]

push eax

add esi,4

loop l1

mov edx,OFFSET array

mov ecx,LENGTHOF array

 mov esi,0

L2:

pop eax

mov max,eax

l3::

 cmp ecx,0

 je last

 cmp eax,array[esi]

 ja again

 mov eax,array[esi]

 add esi ,4

 loop l3

 jmp last

 again:

 add esi,4

 dec ecx

 jmp l3

mov array[esi],eax

add esi,4

loop l2

 last:

 mov max,eax

 mov edx,OFFSET str1

 call WriteString

 call WriteInt

 call crlf

INVOKE EXITPROCESS,0

MAIN ENDP

END MAIN

No comments:

Post a Comment