Keil Logo

µVISION DEBUGGER: Saving and Restoring the Program Counter


Information in this article applies to:

  • µVision Version 2.23

QUESTION

In the µVision 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)\n", pc_stk);
}

func void pc_pop (void) {
  $ = pc_stk;
  printf ("Restoring PC (%8.8LX)\n", 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

Last Reviewed: Thursday, January 14, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

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.