ARM Technical Support Knowledge Articles

HOW CAN I SET THE PROGRAM COUNTER IN C OR ASSEMBLY?

Applies to: General Topics

Answer


Information in this article applies to:


QUESTION

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?

ANSWER

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:

$ = main34

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

Article last edited on: 2002-03-20 00:00:00

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential