Re: Reading power PC MPC 8260 program counter (Next Instruction address)



On February 8, 2011 13:16, in comp.os.linux.embedded, rajesha@xxxxxxxxxxxxx
wrote:

Hello,

Please can somebody let me know how to read power PC 8260 program counter
using C program (Using asm directive).

That seems to me to be a "fools errand". By the time you've read the program
counter, the program counter has changed. Each instruction executed changes
the program counter, and in a multi-processing architecture like Linux,
each context switch changes the program counter as well. By the time your
code has retrieved the counter, the counter has changed.

Anyway, it's a trivial thing to get the PC (or reasonable facsimile) in C
code:

void dummy(void)
{
void (*pc)() = &dummy; /* got the PC on entry to the function */
/*
...
*/
}

--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
Me: http://pitcher.digitalfreehold.ca/ | Just Linux: http://justlinux.ca/
---------- Slackware - Because I know what I'm doing. ------


.



Relevant Pages