health

Technology

business posts

Subroutine

Stack
In 8085 microprocessor stack is a set of memory location in the read/write memory which specified by the programmer in the main program. Those memory locations are used to store binary information temporarily during execution of the program

a stack is an abstract data type that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the most recently added element that was not yet removed. The order in which elements come off a stack gives rise to its alternative name, LIFO (for last in, first out). Additionally, a peek operation may give access to the top without modifying the stack.



http://gradestack.com/Microprocessors-and/Assembly-Language/STACK/19312-3912-38120-study-wtw




Subroutine
in 8085 microprocessor a subroutine is a separate program written aside from main program ,this program is basically the program which requires to be executed several times in the main program. the microprocessor can call subroutine any time using CALL instruction . after the subroutine is executed the subbroutine hands over the program to main program using RET instruction.

Subroutines

OpcodeOperandDescription
CALL16-bitCall subroutine in conditionally located at the memory address specified by 16-bit operand.
 
This instruction places the address of the next instruction on the stack and transfers the program execution to the subroutine address.
RET Return unconditionally from the subroutine.
 
This instruction locates the return address on the top of the stack and transfers the program execution back to the calling program.

The following types of subroutines generally are used in microprocessors:
  1. Multiple call subroutines
  2. Nested subroutines
  3. Multiple Ending subroutines

No comments: