ARM Technical Support Knowledge Articles

SAVING AND RESTORING THE PROGRAM COUNTER

Applies to: uVision Debugger

Answer


Information in this article applies to:


QUESTION

In the uVision Debugger, I would like to save the program counter and restore it later. Is there a way to do this?

ANSWER

Yes. You may create debugger functions that save and restore the program counter. The following example shows how to save the current program counter in a debugger variable:

define long pc_stk

func void pc_push (void) {
  pc_stk = $;
  printf ("Saving PC (%8.8LX)
", pc_stk);
}

func void pc_pop (void) {
  $ = pc_stk;
  printf ("Restoring PC (%8.8LX)
", pc_stk);
}

define button "Push PC" , "pc_push ()"
define button "Pop  PC" , "pc_pop ()"

This code also creates two buttons in the toolbox that you can click.

You may wish to extend this example to save more than one program counter location. To do that, you need to have an index and create multiple variables for the program counters.

SEE ALSO

Article last edited on: 2004-06-29 15:20:59

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