Stack is a place to save a data to whereas with process saves and takes data to apply system LIFO. For example, register SS and SP makes reference to the place by writing down command SS:SP. The code causes register SS to become segment and register SP contains offset. There are some instruction using stack, between of it is POP and PUSH. PUSH can enter a value into stack and POP will take the value from stack. In processor 8086 measures stack is word (2byte = 16 bits). There is 2 stack register that is BP and SP Stack memory applies system LIFO (Last In First Out), mean data which we save is last will become first data which we release. While, the position of stack will be show by Stack Pointer (SP).
Following is figure stack memory:
Direct related command with stack this pointer is PUSH doing storage of data and POP doing data access. So, first data for PUSH will become last data when doing POP so do on the contrary. Instruction PUSH applied saving to a data to Stack. Example: 'PUSH AX' the function "takes data from tip of stack and enters the value to AX". We need to in view of we cannot give instruction 'PUSH AL' or 'PUSH BL' because AL and BL level of 1 byte (not 1 bit).
This is the example:
MOV AX, 1234H
PUSH AX
MOV AH, 09
INT 21H
POP AX
Terminal value from code is uppers to become 1234H. Other example from code is looking like code is upper is;
MOV AX, 1234H
MOV BX, 5678H
PUSH AX
PUSH BX
POP AX
POP BX
Result of code is upper is AX=5678H and BX=1234H. Initially value 1234H is entered, then 5678H put into Stack. In sequence at order LIFO, 5678H will be released in advance and hereinafter value 1234H released at the next sequence. Address memory applied for allocation stack is in address SS : SP ( Stack Segment : Stack Pointer).
Every instruction PUSH is done, address SS:SP filled in data which will be given PUSH into register, flag or memory (this thing is depend on instruction given), automatically SP is added 2. Change of SP counted 2 because data type kept in stack is word (2 byte).