Try   HackMD

In the 8086 microprocessor, 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.

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

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

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →