You are on page 1of 21
Microprocessor & Microcontroller System 3-25 8085 Instruction Set and ALP ee een ee eee 3.4.5 Stack Operations The stack is a portion of read/write memory set aside by the user for the purpose of storing information temporarily. When the information is written on the stack, the operation is called PUSH. When the information is read from stack, the operation is called POP. The microprocessor stores the information, much like stacking plates. Using this analogy of stacking plates it is easy to illustrate the stack operation. Fig. 3.4 shows the stacked plates. Here, we realize that if it 3 is desired to take out the first stacked plate we will have to 2 remove all plates above the first plate in the reverse order. This i means that to remove first plate we will have to remove the third plate, then the second plate and finally the first plate. ‘This means that, the first information pushed on to the stack is Fig. 3.4 Stacked plates the last information popped off from the stack. This type of operation is known as a first in, last out (FILO). This stack is implemented with the help of special memory pointer register. The special pointer register is called the stack pointer, During PUSH and POP operation, stack pointer register gives the address of memory where the information is to be stored or to be read. The stack pointer’s contents are automatically manipulated to point to stack top. The memory location currently pointed by stack pointer is called top of stack. 4. PUSH rp This instruction decrements stack pointer by one and copies the higher byte of the register pair into the memory location pointed by stack pointer. It then decrements the stack pointer again by one and copies the lower byte of the register pair into the memory location pointed by stack pointer. The rp is 16-bit register pair such as BC, DE, HL, Only higher order register is to be specified within the instruction. ‘(Microprocessor & Microcontroller System 3 - 26 ) 8085 Instruction Set and ALP Operation =: SP «-SP~1, (SP) ~rpH, SP —SP-1, (SP)

You might also like