Explain call and return statements, Computer Engineering

Assignment Help:

Q. Explain Call and Return Statements?

CALL:

      CALL X    Procedure Call to procedure/function named X

  CALL instruction causes the following to happen: 

1.  Decrement the stack pointer so that we won't overwrite last thing put on stack

(SP <---SP - 1)

901_Call and Return Statements.png

Figure: Call and Return Statements

2.  The contents of PC that is pointing to NEXT instruction the one just after CALL is pushed onto stack and M [SP] <--- PC.

3.  JMP to X address of the start of subprogram is put in PC register.This is all a jump does. So we go off to the subprogram though we have to remember where we were in calling program which means that we should remember where we came from so that we can get back there again. 

PC <--- X 

RETN:

RETN      Return from procedure.   

RETN instruction causes following to happen: 

1.  Pops the stack to produce an address/label.If correctly used, the top of the stack will comprise the address of next instruction after the call from that we are returning; it's this instruction with that we want to resume in calling program.

2.  Jump to popped address it implies that put the address into PC register.

 PC <---  top of stack value; Increment SP.


Related Discussions:- Explain call and return statements

Why a linked list is called a dynamic data structure, Why a linked list is ...

Why a linked list is called a dynamic data structure? What are the advantages of using linked list over arrays?    A linked list is known as a dynamic data structure because it

What are batch systems, What are batch systems?  Batch systems are quit...

What are batch systems?  Batch systems are quite appropriate for implementing large jobs that need little interaction. The user can submit jobs and return later for the results

C++, find the minimum total number of shelves including the loading process...

find the minimum total number of shelves including the loading process

What do you mean by supercomputers, Q. What do you mean by Supercomputers? ...

Q. What do you mean by Supercomputers? The upper end of state of art mainframe machine is supercomputers. These are among the fastest machines in terms of processing speed and

Write a program to read in a positive integer, Write a program to read in a...

Write a program to read in a positive integer and check whether it is prime or not? /* Program to check whether a given number is prime or not*/] # include # include

What do you mean by instruction cycle, Q. What do you mean by instruction c...

Q. What do you mean by instruction cycle? We have considered the instruction execution in previous section. Now let's consider more about different types of instruction executi

We define our own match code id''s for sap matchcodes, Can we define our ow...

Can we define our own Match Code ID's for SAP Matchcodes? Yes, the number 0 to 9 are reserved for us to make our own Match Code Ids for a SAP described Matchcode object.

Binary tree can be converted in to its mirror image, A binary tree can be c...

A binary tree can be converted in to its mirror image By traversing it in Preorder

Explain the architectural framework for electronic commerce, Explain the Ar...

Explain the Architectural framework for electronic commerce. An application independent framework to categorize service interaction relies on four basic dimensions   1.  Ser

Classify scheduler, Classify Scheduler. Scheduler is a kernel function ...

Classify Scheduler. Scheduler is a kernel function decide which method  be  thought to be implemented by the processor: the scheduler scans the list of processes in the ready s

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd