|
|||||||||||
Technical Support Support Resources
Product Information |
GENERAL: How to Set the Program Counter in C or Assembly?Information in this article applies to:
QUESTIONI have not found a way to set the program counter (PC) to a selected source line in a C (or assembly) file. Is there a way to do this? ANSWERIn C or assembly, there is no way to directly manipulate the program counter since it is not defined in the SFR space. However, you can use the jump instructions in assembly to change the program to any part of your code memory. In the debugger, you may set the program counter by assign a new value to $. For example:
sets the program counter to 1234h in the simulator. To set the program counter to the address of a line of C code, you may use the name of the file and the line number. For example:
sets the program counter to the address of line 34 in the main.c file. Of course, line 34 must have executable code on it. SEE ALSO
Last Reviewed: Thursday, February 25, 2021 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.