In the [8086](https://www.ampheo.com/search/8086) [microprocessor](https://www.ampheo.com/c/microprocessors), the stack is a special region of memory used for temporary storage of data, addresses, and status information, especially during subroutine calls, interrupts, and context switching. ![Hardware-Intel-8086](https://hackmd.io/_uploads/H1_dNJ_Egl.png) **What Is the Stack in 8086?** The stack operates on the LIFO (Last In, First Out) principle — the last item pushed onto the stack is the first to be popped off. **Structure of the Stack in 8086** * Segment Register: SS (Stack Segment) * Offset Register: SP (Stack Pointer) * Effective Address: SS:SP The physical address of the stack top = SS × 16 + SP **How the Stack Works** **PUSH instruction** * Decreases SP by 2 (8086 is a 16-bit processor). * Stores a 16-bit value at SS:SP. **POP instruction** * Retrieves the value from SS:SP. * Increases SP by 2. **CALL instruction** * PUSHes the return address onto the stack. * Jumps to the subroutine. **RET instruction** * POPs the return address from the stack. * Jumps back to that location. **Example: PUSH and POP** ``` asm MOV AX, 1234h PUSH AX ; AX is saved on the stack ; ... some code POP BX ; BX = 1234h ``` **Important Notes** * Stack grows downward in memory (SP decreases as data is pushed). * It must be initialized properly using: ``` asm MOV SS, 7000h MOV SP, 0FFF0h ``` * Stack overflows if SP moves below the reserved stack area — may corrupt program data. **Common Uses of the Stack** ![企业微信截图_20250624162958](https://hackmd.io/_uploads/H1SMGyOElg.png)