Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

x86 Assembly Language Programming Assignment FindLargest Procedure Create a proc

ID: 642413 • Letter: X

Question

x86 Assembly Language Programming Assignment

FindLargest Procedure

Create a procedure named FindLargest that receives two parameters: a pointer to a signed doubleword array, and a count of the array's length. The procedure must return the value of the largest array member in EAX. Use the PROC directive with a parameter list when declaring the procedure. Preserve all registers (except EAX) that are modified by the procedure. Write a test program that calls FindLargest and passes three different arrays of different lengths. Be sure to include negative values in your arrays. Create a PROTO declaration for FindLargest.

Explanation / Answer

INCLUDE Irvine32.inc .data array SDWORD 10000000h,60000000h,70000000h,80000000h count DWORD LENGTHOF array FindLargest PROTO, PtrA : PTR SDWORD , countV : SDWORD tallest SDWORD 10000000h .code main PROC INVOKE FindLargest, OFFSET array , count call dumpregs call waitmsg exit main ENDP FindLargest PROC, PtrA : PTR SDWORD , countV : SDWORD push ebp push eax push edx momentv esi,ptrA momentv ebx,0 momentv ecx,countV momentv ebp,esp momentv eax,tallest momentv ebx,0 momentv edx,0 momentv edx, [esi + 4] L1: cmp eax,edx JG dontfind xchg eax,edx call dumpregs call waitmsg pop edx pop ebp loop L1 dontfind: ret FindLargest ENDP END main