1 Ans:
The stack memory segment is an area of memory allotted for automatic variables. 16 bit data segment register. Automatic variables are allocated and de-allocated automatically when program flow enters and leaves the variable's scope. Stack memory is allocated and de-allocated at the top of the stack, using Last-In-First-Out (LIFO). PUSH stores a constant or 64-bit register out onto the stack. The 64-bit registers are the ones. POP retrieves the last value pushed from the stack. Everything push, MUST pop again at some point afterwards, or code will crash almost immediately.
2 Ans :In 8086, the main stack register is called stack pointer SP. The stack segment register (SS) is usually used to store information about the memory segment that stores the call stack of currently executed program. SP points to current stack top. By default, the stack grows downward in memory, so newer values are placed at lower memory addresses. To push a value to the stack, the PUSH instruction is used. To pop a value from the stack, the POP instruction is used. This first instruction shall push the value stored in AX (16-bit register) to the stack. This is done by subtracting a value of 2 from SP. It works running program pushes registers to the stack to make use of the registers for other purposes, like to call a routine that may change the current values of registers. To restore the values stored at the stack, the program shall contain machine instructions like:
POP BX
POP AX