The Behavior Of The Program Counter During Debug - ARM ARM9TDMI Technical Reference Manual

General-purpose microprocessors
Table of Contents

Advertisement

5.12

The behavior of the program counter during debug

5.12.1
Breakpoint
5.12.2
Watchpoint
ARM DDI0145B
To force the ARM9TDMI to branch back to the place at which program flow was
interrupted by debug, the debugger must keep track of what happens to the PC. There
are six cases:
Breakpoint.
Watchpoint.
Watchpoint with another exception on page 5-36.
Watchpoint and breakpoint on page 5-36.
Debug request on page 5-36.
System speed accesses on page 5-37.
In each case the same equation is used to determine where to resume execution. These
are explained below.
Entry to debug state from a breakpointed instruction advances the PC by 16 bytes in
ARM state, or 8 bytes in Thumb state. Each instruction executed in debug state
advances the PC by one address. The normal way to exit from debug state after a
breakpoint is to remove the breakpoint, and branch back to the previously breakpointed
address.
For example, if the ARM9TDMI entered debug state from a breakpoint set on a given
address and two debug speed instructions were executed, a branch of 7 addresses must
occur (four for debug entry, plus two for the instructions, plus one for the final branch).
The following sequence shows ARM instructions scanned into scan chain 1. This is the
Most Significant Bit (MSB) first, so the first digit represents the value to be scanned into
the SYSSPEED bit, followed by the instruction.
0 EAFFFFF9 ; B -7 addresses (two's complement)
1 E1A00000 ; NOP (MOV R0, R0), SYSSPEED bit is set
For small branches, the final branch could be replaced with a subtract with the PC as the
destination. For example,
Returning to the program execution after entering debug state from a watchpoint is done
in the same way as the procedure described in Breakpoint above. Debug entry adds four
addresses to the PC, and every instruction adds one address. Since the instruction after
that which caused the watchpoint has executed, instruction execution will resume at the
one after that.
Copyright © 1998, 1999 ARM Limited. All rights reserved.
for ARM code.
SUB PC, PC, #28
Debug Support
5-35

Advertisement

Table of Contents
loading

Table of Contents