Subroutines

SUBROUTINE:

The subroutine(function) is an important part of any computer system.

A subroutine is a group of instructions that usually performs one task, it is a reusable section of the software that is stored in memory once, but used as often as necessary.

Jump or Branch is used to call a subroutine in the Microprocessor.

The Return from Subroutine (RTS) instruction returns from the subroutine when a subroutine is completed.

The Stack is used to stores the return address whenever a subroutine is called during the execution of a programme.

The Jump or Branch to subroutine instruction pushes the address of the next instruction following it onto the Stack.

The RTS instruction removes the address from the Stack.


To call a subroutine the CALL instruction is used.

The CALL instruction interrupts the flow of a program by passing control to an internal or external subroutine. An internal subroutine is part of the calling program. An external subroutine is another program.

The RETURN instruction returns control from a subroutine back to the calling program and optionally returns a value.

 

The subroutine called can be:
      
      1)      An internal subroutine
A function or subroutine that is in the same program as the CALL instruction or function call that calls it.
      
       2)     A built-in subroutine
A subroutine that is defined as part of the REXX language.

      3)     An external subroutine
A subroutine that is neither built-in nor in the same program as the CALL instruction or function call that calls it.

LEAVE A REPLY










Related topics

Please use contact page in this website if you find anything incorrect or you want to share more information about the topic discussed above.