Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assembly: Do not use push or pop to loop using indirect addressing that switches

ID: 3594138 • Letter: A

Question

Assembly: Do not use push or pop to loop using indirect addressing that switches the 1st and 2nd elements of the array. Then does the same for the 3rd and 4th elements. And so on.

Your word array is named warray and has the values 3, 5, 8 , 7, 13, 19, 17, 19 in it.

need my code revised

INCLUDE Irvine32.inc

.data

warray DWORD 3, 5, 8, 7, 13, 19, 17, 19

.code

main PROC

mov esi, OFFSET warray ;point to the array

mov ecx, LENGTHOF warray ;ecx register for our counter

mov ebx, TYPE warray

  

L1:

mov eax, warray

mov edi, eax

mov eax, [esi + 4] ;8/2 =4, what we want to move by

loop L1

call DumpMem ; See the results in Array

call DumpRegs ;display registers

call WaitDec ;display output in decimal form  

call WaitMsg ;will keep window running

exit

main ENDP

end main

Explanation / Answer

I am not sure your code will work..I have written the program in a simple way with comments .cheers!!!

.code

main proc

mov esi, 0

mov edi, 0

mov eax, 0

mov ebx, 0

mov esi, OFFSET array; move first element address to esi

mov edi, OFFSET array + TYPE array ;move last element address to edi

mov ecx, LENGTHOF array ;sets the counter in the Loop

Loop1:

mov eax, [esi] ;move the element in esi to eax

mov ebx, [edi] ;move the element in edi to ebx

mov [esi], ebx ;move the element in ebx, to the address in esi

mov [edi], eax ;move the element in eax, to the address in edi

add esi, TYPE array ;increase esi to take the next element in the array

add edi, TYPE array ;increase edi to take the next element in the array

loop Loop1

invoke ExitProcess,0

main endp

end main

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote