Answered step by step
Verified Expert Solution
Question
1 Approved Answer
INCLUDE Irvine 3 2 . inc . data array DWORD 1 0 DUP ( ? ) ; Array to store 1 0 integers len DWORD
INCLUDE Irvineinc
data
array DWORD DUP ; Array to store integers
len DWORD ; Length of the array
sum DWORD ; Variable to store sum
minVal DWORD ; Initialize with a large value for finding minimum
str BYTE "Please enter a number:
str BYTE "The sum is:
str BYTE "The mean is:
str BYTE "The original array:
str BYTE "After a rotation:
space BYTE
code
main PROC
mov ecx, len ; Set loop counter to length of array
mov edi, OFFSET array ; Initialize edi to point to the beginning of array
; Input loop
inputLoop:
mov edx, OFFSET str ; Prompt for input
call WriteString
call ReadInt ; Read integer from user
add sum, eax ; Add entered number to sum
mov edi eax ; Store entered number in array
; Check for minimum value
cmp eax, minVal ; Compare with current minimum
jl updateMin ; Jump to updateMin if new minimum found
jmp continueLoop ; Continue loop if not
updateMin:
mov minVal, eax ; Update minimum value
continueLoop:
add edi, ; Move edi to next element in array
loop inputLoop ; Loop until ecx counter becomes zero
; Calculate and print the sum
mov edx, OFFSET str
call WriteString
mov eax, sum
call WriteInt
call Crlf
; Calculate and print the mean
mov edx, OFFSET str
call WriteString
mov eax, sum
mov ebx, len
div ebx
call WriteInt
call Crlf
; Print the original array
mov edx, OFFSET str
call WriteString
mov ecx, len
mov ebx, OFFSET array
call DisplayArray
call Crlf
; Rotate the array and display after each rotation
mov ecx, ; Number of rotations
rotateLoop:
; Rotate array
mov eax, OFFSET array ; Save the first element
mov edx, OFFSET array
mov ecx, len
mov esi, OFFSET array
add esi, ; Move esi to second element
rotateInnerLoop:
mov ebx, esi ; Move elements forward
mov esi ebx
add esi,
loop rotateInnerLoop
mov OFFSET array len eax ; Move the first element to the end
; Display "After a rotation" message
mov edx, OFFSET str
call WriteString
call Crlf
; Display the array after rotation
mov ecx, len
mov ebx, OFFSET array
call DisplayArray
call Crlf
; Decrease rotation count
loop rotateLoop
call Crlf
INVOKE ExitProcess,
main ENDP
DisplayArray PROC
; Display array
mov esi, ebx ; Set esi to point to the beginning of array
mov ecx, ebx ; Load array length
displayLoop:
mov eax, esi ecx ; Load current element
call WriteInt
mov edx, OFFSET space
call WriteString
loop displayLoop ; Loop until ecx counter becomes zero
ret
DisplayArray ENDP
END main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started