Search code examples
assemblyx86-16cpu-registersbootstack-pointer

What Is The Initial Value of Stack Pointer of 8086 (x86-16) CPU?


  1. What is the initial value of SS, SP, BP? Are they null (0x0) or for example does SP immediately set to 0xFFFE?

  2. When we write an assembly code without using pop and push statements does stack pointer set to a value?


Solution

  • For the original 8086, see The 8086 Family Users Manual. Table 2-4 defines "CPU State Following RESET"; it shows that SS is set to 0000H. The state of general-purpose registers including SP and BP is not documented, so presumably the programmer is supposed to consider them undefined and initialize them manually.

    For recent CPUs, see Intel's Software Developer's Manual, Volume 3A. Table 9-1 defines Processor State After Reset. SS is set to 0000H, with a base address of 00000000H, limit of FFFFH, access rights of Present, R/W, Accessed. EBP and ESP are set to 00000000H.

    If you do not write any instructions that modify the stack pointer, it does not change.