PUSH & POP
STACK:
it s part of RAM in which data will store temporary during execution of program.
STACK work on last in first out principal.to store and retrieve data during program execution in stack push and pop instruction work for it.
PUSH:
its used to store data into stack.
POP:
to retrieve data from stack.
SP:
stack pointer is 8 bit register which store value of top of the stack.
by default stack pointer contain 07h.
PUSH AND POP OPERATION:
PUSH:
using push operation stack pointer increased first and then content of register or memory will store on that stack location which stored in SP.
here SP contain =07h
PUSH R6;SP increased by one and contain of R6 store into 08 location.
PUSH R1;SP increased again by one and contain of R1 stored into 09 location.
PUSH R4;SP increased again by one and contain of R4 stored into 0A location.
POP:
In this retrieve data first and then stack pointer decreased by one.
if we write
POP 20h;then content at 0Ah location will copy into 20h then stack pointer decrease by 1.
POP 21h;then content at 09h location will copy into 21h then stack pointer decrease by 1.
-----------------------------------------------------------------------------------------------------------------------
NEXT: serial communication PREVIOUS:how to access external memory
if we write
POP 20h;then content at 0Ah location will copy into 20h then stack pointer decrease by 1.
POP 21h;then content at 09h location will copy into 21h then stack pointer decrease by 1.
-----------------------------------------------------------------------------------------------------------------------
NEXT: serial communication PREVIOUS:how to access external memory