Use a loop with indirect addressing to reverse the elements of an integer array
ID: 3803722 • Letter: U
Question
Use a loop with indirect addressing to reverse the elements of an integer array in place. - Do not copy the elements to any other array. - Use the SIZEOF, TYPE, and LENGTHOF operators to make the program as flexible as possible if the array size and type should be changed in the future. - Use the XCHG instruction. - The array is a 32-bit variable. - The array's elements are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12. - The array's elements after running the program should look like: 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11. Submit the following: Lastname2.asmExplanation / Answer
.DATA
array dword 1, 2, 3, 4,5,6,7,8,9,10,11,12
.CODE
main PROC
mov ecx, 2
mov esi, 3
mov edi, 0
L1:
mov eax, array[esi * type array ]
xchg eax, array[edi]
mov array[esi * lengthof array ], eax
mov edi, type array
mov esi, 2
loop L1
call dumpregs
; check
mov eax, array
mov ebx, array[4]
mov ecx, array[8]
mov edx, array[12]
call dumpregs
exit
main ENDP
END main
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.