8051 - RET instruction and the number of bytes popped off the stack

Discussion in 'Embedded Systems and Microcontrollers' started by PG1995, Apr 21, 2012.

  1. PG1995

    Thread Starter Active Member

    Apr 15, 2011
    753
    5
    Hi

    Please help me with the query given in the attachment. Thank you.

    Regards
    PG
     
  2. BillO

    Well-Known Member

    Nov 24, 2008
    985
    136
    When you execute a call, what is saved on the stack is an address, not an instruction.

    Specifically, the address of the next instruction to be executed on return is saved, not the next instruction itself.

    Then when the RET is executed, it restores the address that was saved when the call was made and begins execution at that address.

    Address are always two bytes.
     
    PG1995 likes this.
  3. PG1995

    Thread Starter Active Member

    Apr 15, 2011
    753
    5
    Thanks a lot, BillO.

    Regards
    PG
     
Loading...