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             ________
Push   eDx          eSp->   0000000C   56785678             ________
Push   eBx                  00000008   9ABC9ABC             ________  
                            00000004   DEF0DEF0             ________     

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

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

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

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?      __________
     
  2. What are the following immediately before execution of exit?

    eBx    ________

    eCx    ________

    eDx    ________