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

Accesing R15 (PC)

Using the GNU Tools, i can output the value of PC (R15) using the following code:

//Declaring Variable
register unsigned int R15 asm ("pc");

//Outputing the value
printf("The Current location of the Program Counter is : 0x%08X\n","PC");

When I change to using Keil Tools however, this no longer works, I get errors with the variable definition. Does anyone know how I can make this work using the Keil compiler Tools?

Parents
  • I can't help you with any ARM specific stuff, but I can tell you that this doesn't seem right (unless it is some kind of bizarre extension to ANSI 'C'):

    printf("The Current location of the Program Counter is : 0x%08X\n","PC");

    You are passing printf() a string when it expects an unsigned int.

Reply
  • I can't help you with any ARM specific stuff, but I can tell you that this doesn't seem right (unless it is some kind of bizarre extension to ANSI 'C'):

    printf("The Current location of the Program Counter is : 0x%08X\n","PC");

    You are passing printf() a string when it expects an unsigned int.

Children