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
  • So far, I have a first solution on my own:

    mov r0, #high(return_label)
    mov r1, #low(return_label)
    
    ljmp sub_function
    
    return_label:
    ; any code here
    
    sub_function:
    clr a
    mov DPH, r0
    mov DPL, r1
    jmp @a+DPTR 

    I can exchange the label in the first two lines with $. That saves a label name.
    The only thing that disturbes me is that I need the DPTR. Does anyone has an idea with that?