GENERAL: HOW CAN I SET THE PROGRAM COUNTER IN C OR ASSEMBLY?
Information in this article applies to:
I 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?
In 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:
$ = 0x1234
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:
$ = \main\34
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.
Last Reviewed: Wednesday, March 20, 2002
of your data.