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

What are the components of i-way infrastructure, What are the components of...

What are the components of I-way Infrastructure? There are three components of the I-way infrastructure: • Consumer access equipment • Local on-Ramps • Global informat

Observed speedup and parallel overhead, Observed Speedup Observed speed...

Observed Speedup Observed speedup of a system which has been parallelized, is defined as:                             Granularity is one of the easiest and most extensi

Automated reasoning - first-order logic, Automated Reasoning - first-order ...

Automated Reasoning - first-order logic: The topic known as "Automated Reasoning" in "AI"concentrates mostly on deductive reasoning, here new facts are logically deduced from

Sort Wars, If quicksort is so quick, why bother with anything else? If bubb...

If quicksort is so quick, why bother with anything else? If bubble sort is so bad, why even mention it? For that matter, why are there so many sorting algorithms?

Differentiate between exception and validation testing, Differentiate betwe...

Differentiate between exception and validation testing. - Validation testing is done to test the software in conformance to the needs specified. It aims to demonstrate that the

Ready to help students, What is the process to register as expert in comput...

What is the process to register as expert in computer science

How would you kill a process, How would you kill a process? The "kill" ...

How would you kill a process? The "kill" command takes the PID as one argument; this signifies which process to terminate. The PID of a process can be got using "ps" command

Using the editor or debugger, Write a script that will read from a file x a...

Write a script that will read from a file x and y data points in the following format: x   0    y  1 x  1.3  y  2.2 x  2.2  y  6 x  3.4  y  7.4 The format of each line in the

Challenges facing operations managers - information systems, Challenges Fac...

Challenges Facing Operations Managers - Information Systems While information systems should be seen as tools that enable better performance their implementation also brings a

E-r diagrams, for ticket reservation in trains for payroll processing for i...

for ticket reservation in trains for payroll processing for insurance database

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