I\'m learning Assembly Language for x86 Processors <Question> Use a loop with in
ID: 3853288 • Letter: I
Question
I'm learning Assembly Language for x86 Processors
<Question>
Use a loop with indirect or indexed addressing to reverse the elements of the integer array in place. Do not copy the elements to any other array. Use the SIZEOF, TYPEOF, and LENGHTOF operators to make the program as flexible as possible if the array size and type should be changed in the future. Optionally, you may display the modified array by calling the DumpMem method from the Irvine32 library. See chapter 5 for details.
Please also attach a screenshot of your output when running on Visual Studio 2015
Thank you!
Explanation / Answer
Hello
Try to execute the below code
If an infinite loop occurs then try to change the instruction in L1
jb L1
to
loop L1
CODE
INCLUDE Irvine32.inc
.DATA
intarray DWORD 20d,30d,90d,40d,70d,60d,10d
.CODE
main PROC
mov esi, offset intarray
mov ecx, lengthof intarray
lea edi,[esi+(lengthof intarray*sizeof intarray)-sizeof intarray]
L1:
mov eax,[esi]
mov ebx,[edi]
mov [edi],eax
mov [esi],ebx
add esi,sizeof intarray
sub edi,sizeof intarray
cmp esi,edi
jb L1
call DumpRegs
call WriteInt
ret
;call DumpMem
exit
main ENDP
END main
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.