This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How can I read out the PC?

Hi all!

I need to read out the actuall value of the program counter (PC). How can I do that?
I use the Keil uVision environment with an 8051 based controller!

Thanks for your help!

Parents Reply Children
  • I am not allowed to use a "call" function because I am not allowed to alter the stack pointer (SP). Instead of using the "call" command I want to use a "jmp". Before I perform the jump command I need to have the return address from the program counter, so that I can return back to the source of the jump command. That is like I would use a call function, but without altering the SP!

  • Are you out of stack space, or did someone give you some arbitrary "don't change the SP" directive ?

    You could recova a few bytes from the stack by popping into unused registers.

  • I am not allowed to use a "call" function because I am not allowed to alter the stack pointer (SP).

    Huh, "not allowed"? Pray tell: who or what is stopping you?

    That restriction seems outright ridiculous. Does "making an omelett without breaking an egg" ring any bell to you?

  • hi,
    I want to use a "jmp". ...so that I can return back to the source of the jump command. That is like I would use a call function, but without altering the SP!

    Sorry? Why not simple:

    ; main stream
    ; ....
    JMP MY_TASK ; go to your "subroutine"
    L_CONTINUE:
    ; contunue main stream
    
    MY_TASK:
    ; your piece of code
    JMP L_CONTINUE ; return to main stream
    

    Regards,
    Oleg