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

Convert the decimal to hexadecimal equivalent number, Convert the decimal n...

Convert the decimal number 45678 to its hexadecimal equivalent number. Ans: (45678) 10 =(B26E) 16 (45678) 10 =(B26E) 16

Iscuss the various functions of telephone switching systems, Discuss the va...

Discuss the various functions of telephone switching systems. Telephone switching system's functions are as follows: (i) Attending: The system should be continually monito

Dynamic programming, The fi rst task will involve doing a little background...

The fi rst task will involve doing a little background reading on Dynamic Programming to get up to speed. The second task is to write the code: Search Space Write a function whi

Which device changes from serial data to parallel data, Which device change...

Which device changes from serial data to parallel data ? Ans. Demultiplexer is the device that changes from serial data to parallel data. Demultiplexer takes data in from on

Simplified boolean expression, Simplified the Boolean Algebra (x + y)(x + z...

Simplified the Boolean Algebra (x + y)(x + z) simplifies to ? Ans. x + yz as simplified the Boolean Algebra expression. [(x + y) (x + z)] = xx + xz + xy + yz = x + xz + xy + y

Explain the working of a 2-bit digital comparator, Explain the working of a...

Explain the working of a 2-bit digital comparator with the help of Truth Table. Ans. Digital comparator is a combinational circuit which compares two numbers, A and B; and

Write a program to input an address, Write a program to input an address i....

Write a program to input an address i.e. 20 Hex and read the byte (char) contents of that address   Answer   include void main() { char prompt; Date: 26th August 2012

What do you mean by interrupts, Q. What do you mean by Interrupts? The ...

Q. What do you mean by Interrupts? The term interrupt is an exceptional event which causes CPU to temporarily transfer its control from presently executing program to a separat

Computer architecture, describe the block diagram of a system showing the f...

describe the block diagram of a system showing the following microprocessor memory system buses

State about the object models, State about the Object models Object mo...

State about the Object models Object models are used for explaining the objects in the system and their connection with each other in the system. The dynamic model explains in

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