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

could somebody give me an explanation on how to do this or at least offer some p

ID: 3828562 • Letter: C

Question

could somebody give me an explanation on how to do this or at least offer some psuedo code to help me figure it out on my own? This is assembly language for x86 processors and I use visual studio to write my code.

Create a procedure that fills an array of doublewords with N random integers, making sure the values fall within the range j...k, inclusive. When calling the procedure, pass a pointer to the array that will hold the data, pass N, and pass the values of j and k. Preserve all register values between calls to the procedure. Write a test program that calls the procedure twice, using different values for j and k. Verify your results using a debugger.

Explanation / Answer

Ans

FillArray PROC,
   j equ 1
   k equ 100
   n =10
   pArray:PTR BYTE, fillVal:BYTE
   arraySize:DWORD

   Rand();
   mov ecx,arraySize
   mov esi,pArray
   mov al,fillVal
L1:  
   mov eax,k+j
    call randomrange
   mov pArray[esi*4],eax
   inc esi
   loop L1
   ret
L2:  
   mov eax,k+j
    call randomrange
   mov pArray[esi*4],eax
   inc esi
   loop L2
   ret
L3:
mov eax,pArray[esi*4]
call writeInt
mov al,20h
call writechar
inc esi
loop L3
FillArray ENDP