You are on page 1of 2

ABDULLAH HASAN

Lecturer, FOIT

COAL Practice Problems-3

Stack & Procedures


P1: Develop a far procedure that copies contents of the word-sized memory location DS:DATA4
into AX, BX, CX, DX, and SI.
P2: Develop a near procedure that stores AL in four consecutive memory locations within the
data segment, as addressed by the DI register.
P3: Write a procedure to find factorial of 5 using loops.
P4: Write a procedure to find whether the number is prime or not.
P5: Assume that SP = 0x1478 is before the procedure CALL. Show that contents of the stack
pointer and the exact memory contents of the stack after PUSHF for the following:
… STACK
CALL PROC1
INC BX
PROC1 PROC
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSHF
….
PROC1 ENDP

1
ABDULLAH HASAN
Lecturer, FOIT

P6: Write some code to


a) place the top of the stack into AX, without changing the stack contents.
b) place the word that is below the stack top into CX, without changing the stack contents.
You may use AX.
c) exchange the top two words on the stack. You may use AX and BX.

P7: Suppose SP= 0x0200, pointing the top of stack = 0x012A. What are the contents of IP and SP
a) after RET is executed, where RET appears in a NEAR procedure?
b) after RET 4 is executed, where RET appears in a NEAR procedure?

You might also like