You are on page 1of 2

Question No 1:

When we call a procedure in assembly, the address of next line is stored in stack and the control is
shifted towards the procedure. When procedure complete the task it return back the control to the
next line address stored in stack. Stack is a one dimensional data structure which works on the rule of
LIFO means last in first out. The w value that is inserted in the last will b removed first from the stack.
Problem: You are required to discuss.

a. How address of next line is stored in stack when procedure is called.

When we call a procedure in assembly, the address of next line is stored in stack and the control
is shifted towards the procedure. When procedure complete the task it return back the control
to the next line address stored in stack.
b. How the control is transferred back when procedure ends.

When a procedure is called the control is shifted toward the procedure address.The current
instruction address is stored in stack
When the procedure finished the control is shifted back to the normal instruction execution.
RET is used to transfer back the controller to normal execution.

c. How stack will manage the nested procedure calls?

Stack is a one dimensional data structure which works on the rule of LIFO means last in first out.
The w value that is inserted in the last will b removed first from the stack.

A nested procedure call occurs when a called procedure calls another procedure before the first
procedure returns. Suppose that main calls a procedure named Sub1. While Sub1 is executing, it
calls the Sub2 procedure. While Sub2 is executing, it calls the Sub3 procedure.
The process is shown in following figure:
The following diagram shows the stack just before the return from Sub3 is executed:

 Note that the procedure call/return sequence is a LIFO process: the last procedure called is
the first to return

You might also like