Hello, I use gcc to compile my code for STM32F407VGT6. I am trying to print the value of PC register and in order to do this I use this code: unsigned int pc_value; __asm__("mov %%R15,%0" : "=r" (pc_value)); My application crashes when it executes this line. If I replace R15 with another register (R1 for example) it does not crash anymore. Is this because I am not allowed to read the value of PC ? Thanks.
You did load the PC with some unknown register contents. While the GNU community often places the destination register last in the line, in old 68000 tradition, ARM prefers it as the left operand.
BTW: You'd better use "__asm__ volatile", or the optimizer might be tempted to move it around a little more than unavoidable.
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.