Exercise 4      Name       ____________________   Points __/20

1. (4 points) Show the stack after the execution of the instructions at left.

Mov    eDx, 12345678h        Address Stack Before      Stack After Pushes
Mov    eBx, 56789ABCh       00000010   12341234             ___NC___
Push   eDx          eSp->   0000000C   56785678             ___NC___
Push   eBx           :      00000008   9ABC9ABC             12345678  
                    eSp->   00000004   DEF0DEF0             56789ABC     

2. (6 points) Show the stack, eBx, and eDx after the execution of the instructions at left.

Mov    eDx, 0000h          Address Stack Before      Stack After Pops
Mov    eBx, 0000h  eSp->   00000010   12341234             12341234
Pop    eDx           :     0000000C   56785678             ___NC___     
Pop    eBx         eSp->   00000008   9ABC9ABC             ___NC___
                           00000004   DEF0DEF0             ___NC___
eDx = 9ABC9ABC  
eBx = 56785678

3.    (6 points) Trace the execution of the following. What is the specific output?

+10

+20

+30

+40

INCLUDE Irvine32.inc

.data
array		dword	10, 20, 30, 40

.code
p		PROC
  @do:	
		mov	eAx, [ eSi ]
		call	WriteInt
		call	CrLf
		add	eSi, 4
@while:
		loop	@do
		ret
p		ENDP

main	PROC
		mov	eCx, 4
		mov	eSi, OFFSET array
		call	p
		exit
main	ENDP

END main

4.    (4 points) Trace the execution of the following.

INCLUDE Irvine32.inc

.code
f		PROC
		push		eDx
		mov		eDx, eBx
		mov		eBx, eCx
		mov		eCx, eDx
		pop		eDx
		ret
f		ENDP

main	PROC
		mov		eBx, 1
		mov		eCx, 2
		mov		eDx, 3
		call		f
		exit
main	ENDP

END main
  1. Assume eSp = 0000000C immediately before execution of call f. What is eSp immediately before execution of pop eDx?      00000004
     
  2. What are the following immediately before execution of exit?

    eBx    00000002

    eCx    00000001

    eDx    00000003