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

Rdbms relational database system, RDBMS relational database system - Re...

RDBMS relational database system - Relational databases are composed of relations and managed through relational operations, and governed through data integrity constraints.

What are threads, What are threads? A thread, sometimes termed as a lig...

What are threads? A thread, sometimes termed as a lightweight process (LWP), is a fundamental unit of CPU utilization; this comprises a thread ID a register set and a stack and

Explain branch instruction with control signals, Explain BRANCH instruction...

Explain BRANCH instruction with Control Signals. and explain SHIFT instruction with Control Signals.  Explain Register Transfer Language. What do you mean by Addressing Techn

Digital systems and microprocessors, Your logic function for this assignmen...

Your logic function for this assignment is to be derived from your own student number. The number 1224583 will be used as an example as to how you should derive your function and e

Superscalar processors, Superscalar Processors In scalar processors, on...

Superscalar Processors In scalar processors, only one instruction is implemented per cycle. That means only single instruction is issued per cycle and only single instruction i

Connectives in first-order logic sentences, Connectives in first-order logi...

Connectives in first-order logic sentences - Artificial intelligence We may string predicates together into a sentence in the same way by utilising connectives that we did for

How to clear a datagrid on a button click, How to clear a datagrid on a but...

How to clear a datagrid on a button click? You require to Clear the DataSource of the dataGrid. So try this: dataSet1.Clear(); dataGrid1.DataSource = dataSet1.TableNam

Computer Graphics , What do you mean by ‘Bresenham’s him Algorithm?

What do you mean by ‘Bresenham’s him Algorithm?

Vliw instruction word, VLIW instruction word is compacted to have floating-...

VLIW instruction word is compacted to have floating-point addition, one branch, floating point multiply, and one integer arithmetic and load/store operation as displayed in Figure

Security, We now consider the relation between passwords and key size. For ...

We now consider the relation between passwords and key size. For this purpose consider a cryptosystem where the user enters a key in the form of a password. Assume a password consi

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