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

PC to DPTR ?

Hi,


How to move the program counter(PC) to DPTR.Can any one suggest on this.

Thanks in advance,

Regards,
Gopi

  • ....
    CALL loadPCtoDPTR


    loadPCtoDPTR:
    POP DPH
    POP DPL
    PUSH DPL
    PUSH DPH
    RET

  • Btw, it was a joke (but it works anyway :)
    In fact, PC counter is that value which command executed from. So it is not a problem just write something like next:

    .... (your code)
    MOV DPTR,#mark_pointer
    mark_pointer:
    .... (your code)

    Here you indicated a label which value is the PC counter exactly when processor executes command located at it.

    Good days!

  • Don't forget that DPTR and PC refer to different logical address spaces; thus, depending on your physical memory implementation, DPTR=0x1234 may well address a different physical address location from PC=0x1234, etc!

  • What? You are wrong here..

    MOVC A,@A+DPTR
    reads byte from program memory exactly same as it does command
    MOVC A,@A+PC
    and exactly the same as hardware fetches the command byte.
    Hardware does not do different timings/read cycles for reading both command and data bytes from program memory. When you use command MOVC A,@A+DPTR then core works like it reads just byte of command.
    So I cannot understand what do you talk about that DPTR=0x1234 may well address a different physical address location from PC=0x1234. If you use MOVC command then there is no difference. Ofcoz, if you will use MOVX... command then it will be a big difference (no PSEN signal etc).

    Good days!

  • "You are wrong here.."

    Doh!
    Sorry - still in holiday mode!

    "Ofcoz, if you will use MOVX... command then it will be a big difference"

    Yes, that's what I meant to say!