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

MASM Create a new project and copy and paste the following code into main.asm. I

ID: 3800217 • Letter: M

Question

MASM

Create a new project and copy and paste the following code into main.asm.

INCLUDE Irvine32.inc

.data

word1 WORD 10

word2 WORD 20

.code

main PROC

      

       movzx eax,word1

       push   eax

       movzx eax,word2

       push   eax

       call   AddTwoArgs

       call   WriteInt

       exit

main ENDP

AddTwoArgs PROC

; Adds two integers, returns sum in EAX.

    push ebp                      ; save stack base pointer

    mov ebp,esp                  ; copy current stack pointer to base

    mov eax,[ebp + 12]          ; first parameter

    add eax,[ebp + 8]            ; second parameter

    pop ebp                      ; restore base pointer

    ret 8                        ; clean up the stack

AddTwoArgs ENDP

END main

At the add eax, [ebp+8] instruction what values are on the stack. Complete the following table.

Displacement

Value Address

+0

+4

+8

+12

Displacement

Value Address

+0

+4

+8

+12

Explanation / Answer

MOV AX #0

MOV bx #4

MOV CX #8

MOV DX #1

Reg MX

Add AX,bx

Add bx,CX

Add CX,DX

Add DX,AX

S

CMP AX,bx

CMP bx,CX

CMP CX,DX

Add AX,CX,4

Add CX,dx,8

Add AX,CX,12

CMP AX,dx