Digi NS7520 manual Entering and exiting an exception software action, Entering an exception

Models: NS7520

1 332
Download 332 pages 47.95 Kb
Page 51
Image 51

W o r k i n g w i t h t h e C P U

Entering and exiting an exception (software action)

The ARM7TDMI performs specific steps when handling exceptions.

Entering an exception

When handling an exception, ARM7TDMI does this:

1Preserves the address of the next instruction in the appropriate Link register.

If the exception has been entered from the ARM state, the address of the next instruction is copied into the Link register. The address is either current PC + 4 or PC + 8, depending on the exception. (See Table 18: "Exception entry/exit by exception type" on page 38.)

If the exception has been entered from Thumb state, the value written into the Link register is the current PC offset by a value that lets the program continue from the correct place on return from the exception.

The exception handler does not need to determine from which state the exception was entered. With an SWI, for example, MOVS PC, R14_SVC always returns to the next instruction whether executed in ARM or Thumb state.

2Copies the CPSR into the appropriate SPSR.

3Forces the CPSR mode bits to a value that depends on the exception.

4Forces the PC to fetch the next instruction from the relevant exception vector.

5Sets the I (for IRQ interrupts) or F (for FIRQ interrupts) bits to disable interrupts to prevent unmanageable nesting of exceptions.

Note: If the processor is in Thumb state when an exception occurs, it automatically switches into ARM state when the PC is loaded with the exception vector address.

Exiting an exception

On completion, ARM7TDMI does this:

1Moves the Link register, minus the offset where appropriate, to the PC. The offset value varies depending on the type of exception.

2Copies the SPSR back to the CPSR.

3Clears the interrupt disable flags, if they were set on entry.

w w w . d i g i . c o m

3 7

Page 51
Image 51
Digi NS7520 manual Entering and exiting an exception software action, Entering an exception, Exiting an exception