Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

INCLUDE Irvine 3 2 . inc . data array DWORD 1 0 DUP ( ? ) ; Array to store 1 0 integers len DWORD

INCLUDE Irvine32.inc
.data
array DWORD 10 DUP(?) ; Array to store 10 integers
len DWORD 10 ; Length of the array
sum DWORD 0 ; Variable to store sum
minVal DWORD 2147483647 ; Initialize with a large value for finding minimum
str1 BYTE "Please enter a number: ",0
str2 BYTE "The sum is: ",0
str3 BYTE "The mean is: ",0
str4 BYTE "The original array: ",0
str5 BYTE "After a rotation: ",0
space BYTE "",0
.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 str1 ; 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, 4 ; Move edi to next element in array
loop inputLoop ; Loop until ecx (counter) becomes zero
; Calculate and print the sum
mov edx, OFFSET str2
call WriteString
mov eax, sum
call WriteInt
call Crlf
; Calculate and print the mean
mov edx, OFFSET str3
call WriteString
mov eax, sum
mov ebx, len
div ebx
call WriteInt
call Crlf
; Print the original array
mov edx, OFFSET str4
call WriteString
mov ecx, len
mov ebx, OFFSET array
call DisplayArray
call Crlf
; Rotate the array and display after each rotation
mov ecx, 9 ; Number of rotations
rotateLoop:
; Rotate array
mov eax, [OFFSET array] ; Save the first element
mov edx, [OFFSET array +4]
mov ecx, len -1
mov esi, OFFSET array
add esi, 4 ; Move esi to second element
rotateInnerLoop:
mov ebx, [esi] ; Move elements forward
mov [esi -4], ebx
add esi, 4
loop rotateInnerLoop
mov [OFFSET array +4*(len -1)], eax ; Move the first element to the end
; Display "After a rotation" message
mov edx, OFFSET str5
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, 0
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*4-4] ; 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

What is one of the skills required for independent learning?Explain

Answered: 1 week ago