Dr.R.Hepzi Pramila Devamani , Assistant Professor of Physics, V.V.Vanniaperumal College for Women, Virudhunagar . STACK IN 8085 MICROPROCESSOR
STACK The stack is a group of memory locations in the RAM (R/W) memory that is used for temporary storage of binary information during the execution of the program. The last memory location of the occupied portion of the stack is called stacktop . The starting memory location of the stack is defined in the main program by using LXI or SPHL instruction.
STACK Data are stored in the stack on last-in-first-out (LIFO) principle and data are retrieved from the stack first-in-last-out principle. Figure shows typical stack and stack top location.
INSTRUCTIONS PUSH instruction is used to store data in stack POP instruction is to retrieve the contents A register pair is always specified along with these PUSH and POP instructions. PUSH B POP B PUSH D POP D PUSH H POP H PUSH PSW POP PSW B,D,H PSW specifies register pairs BC, DE, HL, A and Flags
PUSH INSTRUCTION PUSH Rp PUSH instruction can be explained with an example LXI SP,2605H LXI B, 2550H PUSH B Delay Counter POP B
PUSH Instruction Step 1: LXI SP, 2605 will initialize SP register 2605 Step 2: LXI B, 2550H will initialize or load BC register pair with 2550H data so B = 25 and C = 50. Step 3: The execution of PUSH b instruction will be The stack pointer is decreased by one to 2604H and the contents of the B register are copied to memory location 2604H. The stack pointer is again decreased by one to 2603H and the contents of the C register are copied to memory location 2603H. The contents of the register pair BC are not destroyed. However , BC is made available for the delay counter. The execution of PUSH operation is shown in Figure.
PUSH OPERATION
POP INSTRUCTION After the delay count, the instruction POP B restores the original contents of the register pair BC. The execution of POP B instruction will be The contents of the top of the stack location shown by the stack pointer are copied in the C register and the stack pointer is increased by one to 2604H [C] [SP], [SP] [SP] + 1 The contents of the top of the stack are copied in the B register and the stack pointer is increased by one [B] [SP], [SP] [SP] + 1 The contents of the memory locations 2603H and2604H are not destroyed until some other data bytes are stored in these locations. The execution of POP operation is shown in Figure.
POP OPERATION
REFERENCE Microprocessor , Microcomputer , Microcontroller and interfacing - M.K Gupta,Paragon International Publishers, 2 nd Edition(2007).