Question: Write the following programs in the lab: 1. Create a procedure named FindSmallest that receives two parameters: a pointer to a signed doubleword array, and

 Write the following programs in the lab: 1. Create a procedurenamed FindSmallest that receives two parameters: a pointer to a signed doubleword

Write the following programs in the lab: 1. Create a procedure named FindSmallest 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 smallest array member in EAX. o Use the PROC directive with a parameter list when declaring the procedure. Preserve all registers (except EAX) that are modified by the procedure. o Write a test program that calls FindSmallest and passes three different arrays of different lengths. Be sure to include negative values in your arrays. Create a PROTO declaration for FindSmallest. 2. Create an array of randomly ordered integers. Using the Swap procedure from the Demo Program 1 as a tool, write a loop that exchanges each consecutive pair of integers in the array. Demo Program 1 Swap Procedure Example (Swap.asm). INCLUDE Irvine 32.inc Swap PROTO, pValX: PTR DWORD, pValY:PTR DWORD Swap2 PROTO, pValX:PTR DWORD, pValy:PTR DWORD . data Array DWORD 10000h, 20000h . code main PROC Display the array before the exchange: mov esi,OFFSET Array mov ecx, 2 ; count = 2 mov ebx, TYPE Array call DumpMem dump the array values INVOKE Swap, ADDR Array, ADDR [Array+4] Display the array after the exchange: call DumpMem exit main ENDP Swap PROC USES eax esi edi, pValX:PTR DWORD, pointer to first integer pValY:PTR DWORD ; pointer to second integer ; Exchange the values of two 32-bit integers Returns: nothing i get pointers mov esi, pValx mov edi, paly mov eax, fesi) xchg eax, [edil mov [esil, eax ret Swap ENDP ; get first integer ; exchange with second ; replace first integer ; PROC generates RET 8 here Swap2 PROC USES eax esi edi, pValx:PTR DWORD, ; pointer to first integer pValy:PTR DWORD ; pointer to second integer LOCAL Temp: DWORD ;local doubleword variable named Temp ; Exchange the values of two 32-bit integers ; Returns: nothing movesi, pValx ; get pointers mov edi, pValy mov eax, [esi) ; get first integer mov Temp, eax ; save a copy of the first integer mov eax, [edi] ; exchange with second mov (esi), eax mov eax, Temp mov [edi], eax ret ; PROC generates RET 8 here Swap2 ENDP END main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!