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

In Assembly Language (MASM613 or MASM615), write a program to print the original

ID: 3720685 • Letter: I

Question

In Assembly Language (MASM613 or MASM615), write a program to print the original array and reversed array using PUSH and POP.

I have the initial program setup already, but I can't figure out how to do it using PUSH and POP.

This is the template to use:____________________________

TITLE Orig & Reversed Array

INCLUDE Irvine32.inc

.data

a1 DWORD 1, 3, 6, 9, 15, 28, 44

.code

main PROC

MOV esi, OFFSET a1

MOV ecx, LENGTHOF a1

MOV eax, 0

CALL Loops

exit

main ENDP

Loops PROC

L1:

MOV eax, [esi]

ADD esi, TYPE a1

CALL WRITEINT

loop L1

CALL crlf

MOV ecx, LENGTHOF a1

L2:  

MOV eax, [esi-4]

CALL WRITEINT

SUB esi, TYPE a1

loop L2

ret

Loops ENDP

END main

___________________________________________________

This code works the way it is. The only thing that needs to be added is push and pop commands. Can you also comment explaining how the push and pop works inside this program as well please.

So what needs to be done: Program needs to display the original array forward and backwords using push and pop. Need help withe push and pop part.

Explanation / Answer

//After this initial setup you have to just add following code.

//If we push all array data and pop it one by one we will get reverse array

Loops proc

L3: mov eax, [esi]

Add esi, type a1

Call writeint // for printing original array

Push eax

Loop l3

Call crif

Mov ecx, lengthof a1

L4:pop eax

Call writeint // for printing reverse array

Loop l4

Call crif

Mov ecx, lengthof A1

Ret

Loops endp

End main