Search code examples
embeddedmicrocontroller8051

Why is the value of SP register 07h when 8051 is powered up?


When the 8051 is powered up, the Stack pointer register contains value 07h not 00h?


Solution

  • Because of Bank 0 is the default register bank used by 8051. This bank 0 uses registers 0 - 7.

    If the SP starts from 0 registers R0 - 7 would overwrite the SP and cause undefined behavior, at least.

    Usually the SP is set to the desired location with startup code