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

Programming, Which is the best programming language to learn?

Which is the best programming language to learn?

What information is stored in a typical TLB table entry, In a simple paging...

In a simple paging system, what information is stored in a typical Look-aside Buffers  TLB table entry? A classical TLB table entry contains page# and frame#, while a logical

Explain the stack in digital computers, Explain the stack in digital comput...

Explain the stack in digital computers The stack in digital computers is fundamentally a memory unit with an address register which can count only (after first value is loaded

Logic gates required to build a half adder, What are the gates required to ...

What are the gates required to build a half adder ? Ans. The gates needed to build a half adder are EX-OR gate and AND gate as shown below the logic diagram of half adder:

Explain segment registers in bus interface unit, Q. Explain Segment Registe...

Q. Explain Segment Registers in bus interface unit? These are very significant registers of CPU. Why? We will answer this later. In 8086 microprocessor memory is a byte organiz

Which of the memories stores the most number of bits, Which of the memories...

Which of the memories stores the most number of bits ? Ans. most number of bits stores in 32M x 8 As 2 5 x 2 20   = 2 25 Therefore 1M = 2 20 = 1K x 1K = 2 10 x 2 10

What are the different database integrities, What are the different databas...

What are the different database integrities? Semantic Integrity. Relational Integrity. Primary Key Integrity. Value Set Integrity. Foreign Key integrity and

What are the requirements a dialog program must fulfill, What are the requi...

What are the requirements a dialog program must fulfill? A dialog program must fulfil the following requirements A user friendly user interface. - Format and consistency

Give detail explanation about arithmetic micro-operations, Give detail expl...

Give detail explanation about Arithmetic Micro-operations These micro-operations perform some essential arithmetic operations on numeric data stored in the registers. These bas

Write short notes on proton – proton fusion in sun, Q. Write short notes on...

Q. Write short notes on proton - proton fusion in sun. Proton - Proton cycle 1 H 1 + 1 H 1 → 1 H 2 + 1 e 0 + ν (emission of positron as well as neutrino) 1

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