Question: extern printf ; We will use this external function section . data ; Data section, initialized variables mystr: db % d , 1

extern printf ; We will use this external function
section .data ; Data section, initialized variables
mystr: db "%d",10,0 ; String format to use (decimal), followed by NL
myarr: dd 10,20,30,40,50,60
temp: dd 0
section .text
global main
main:
xor eax, eax ; A =0
mov ecx, myarr ; C points to myarr
myloop:
mov ebx, DWORD [ecx+4*eax] ; Get the value B = myarr[A]
mov [temp], ebx
push rax
push rcx
; Now print the result out
mov rdi, mystr ; Format of the string to print
mov rsi, [temp] ; Value to print
mov rax, 0
call printf
pop rcx
pop rax
add eax, 1 ; A++
cmp eax, 6 ; Does A ==6?
jl myloop ; if less, jump to myloop
mov rax, 0
ret
The objective for this lab is to add to the code, to determine the minimum value, the maximum value, and the average value. You will need to define storage for each of these in the .data section (or the .bss section).
Keep the part that prints each value in the array, only alter it to print the values on a single line. Also, have the program print something before the values, like "The array has the following values:".It should initialize the minimum and maximum with the first value of the array, then examine each value in the array then examine each value in the array (starting with the second value), and update the minimum and maximum as needed.To find the average, we can make a sum of the values. Then divide the sum by the number of values. Have the problem print "max:","min:""averg" this is being compiled with nasm -f elf 64 and gcc on snowball . assembly x86

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!