The following program should shift the position of an array's elements one position forward, with the fourth element wrapping around to the first position. This program's code incorrectly outputs the following: 1536 0 9 12 The output should read: 12 3 6 9 What can I do to fix the program so that it outputs the correct sequence of numbers? CODE: INCLUDE Irvine32.inc .data array1 DWORD 3, 6, 9, 12 ; declare and initialize an array of 4 double word elements .code main PROC mov edi, LENGTHOF array1 ; find the size of array and assign to edi mov eax, array1[edi - 1] ; store the value of the last element in the array in eax ; Loop to shift array elements one position to the left (forward) and wrap the last element to the first position mov ecx, edi dec ecx ; ecx = edi - 1, as we want to exclude the last element from the loop L1: mov edx, array1[ecx - 1] mov array1[ecx], edx loop L1 mov array1[0], eax ; assign the first element the value held in eax (the original value of the last element) ; Loop to print array values mov ecx, LENGTHOF array1 mov esi, OFFSET array1 L2: mov eax, [esi] call WriteDec call Crlf add esi, TYPE array1 loop L2 exit main ENDP END main
The following
1536
0
9
12
The output should read:
12
3
6
9
What can I do to fix the program so that it outputs the correct sequence of numbers?
CODE:
INCLUDE Irvine32.inc
.data
array1 DWORD 3, 6, 9, 12 ; declare and initialize an array of 4 double word elements
.code
main PROC
mov edi, LENGTHOF array1 ; find the size of array and assign to edi
mov eax, array1[edi - 1] ; store the value of the last element in the array in eax
; Loop to shift array elements one position to the left (forward) and wrap the last element to the first position
mov ecx, edi
dec ecx ; ecx = edi - 1, as we want to exclude the last element from the loop
L1:
mov edx, array1[ecx - 1]
mov array1[ecx], edx
loop L1
mov array1[0], eax ; assign the first element the value held in eax (the original value of the last element)
; Loop to print array values
mov ecx, LENGTHOF array1
mov esi, OFFSET array1
L2:
mov eax, [esi]
call WriteDec
call Crlf
add esi, TYPE array1
loop L2
exit
main ENDP
END main
![1536
Ⓒ
9
12
Microsoft Visual St
C:\Users\garci\sour
To automatically cl
le when debugging s
Press any key to cl](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0236545c-1220-486f-b1e8-12c84ce35d00%2F1a4b8eff-90fa-441a-89d1-fefae85285dc%2F801jgto_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781305480537/9781305480537_smallCoverImage.jpg)