1.8.2. Patching example to jump over lines of source code

You can also use a similar approach to jump over or skip lines of source code:

  1. Define a macro to set the PC to a point beyond the lines that are not executed.

  2. Start a debugging session and set a breakpoint on the first line to be skipped.

  3. Attach your macro to this breakpoint.

  4. Run the program until execution stops at the breakpoint.

  5. The source statements in your macro are interpreted and executed. The macro completes.

  6. Program execution continues normally from the new position of the PC.

You can also use the JUMP command for looping and skipping over commands. The JUMP command takes a label and an expression. If the expression evaluates to True then control jumps to the specified label. If the label is positioned earlier in the file, this loops. If the label is positioned later in the file, all intermediate commands are skipped.

The expression can test:

Example 1.5 shows a script command fragment containing the JUMP command.

Example 1.5. Using the JUMP command

add int cnt = 20
initialize 
:repeat                             /* loop 20 times */
some_commands 
jump repeat,cnt                     /* repeat until cnt==0 */
;
; define some local vars if not defined.
;
jump nodefine,isalive(cnt)==1
some_commands 
:nodefine

See also

Copyright © 2002-2011 ARM. All rights reserved.ARM DUI 0175N
Non-ConfidentialID052111