how can i obtain the current values of registers like accumulator,B,stack pointer,PSW,DPTR,etc in C?? i am currently working on a trainer/development kit for 8051..One of the commands to be executed is R<CR> Once this command is executed,the values of all the registers like A,B,SP,PSW,DPH,DPL,R0,R1,R7 should be displayed on screen...how do i retrieve these register values in C?
But accessing PC - what PC? Your program will get the PC value of the code that retrieves the PC, since that is where the processor will always be when you try to read out PC.
That was one reason why I said you should consider handling all this in an ISR. Then the ISR code can check what return address the ISR will use - that is the PC of the program that was running when the ISR picked up the serial character.