Stack Subroutines is the important topic of the Microprocessor. It is the Important subject of the Computer Science & Technological field.
A stack is a group of a memory location in the R/W memory that is used for temporary storage of binary information during execution of a program.
The starting memory location of the stack defined in program and space reserved usually at the high end of the memory map.
Moreover, The beginning of the stack defined in the program by using instruction LXI SP, a 16-bit memory address. Which loads a 16-bit memory address in stack pointer register of the microprocessor.
Once stack location is defined storing of data bytes begins at the memory address that is one less than the address in stack pointer register. LXI SP, 2099h the storing of data bytes, begins at 2098H and continues in reversed numerical order.
Also, Data bytes in register pair of the microprocessor can store on the stack in reverse order by using the PUSH instruction.
PUSH B instruction sore data to register pair BC on a stack.
Moreover, Data bytes can transfer from the stack to respective registers by using instruction POP.
Instruction necessary for stack in 8085
LXI SP, 2095
- Load the stack pointer register with a 16-bit address.
- It copies contents of B-C/D-E/H-L register pair on the stack.
- Also, Operand PSW represents Program status word meaning contents of accumulator and flags.
- Also, It copies the content of top two memory locations of the stack into specified register pair.
- It copies content of top two memory locations of the stack into B-C accumulator and flags