Several situations returned by arm exception interruptions

Source: Internet
Author: User

Several situations returned by arm exception interruptions
Important basic knowledge: R15 (PC) always points to the instruction that is taking the finger, instead of the instruction that is executing or decoding. In general, it is customary to refer to the first instruction as a reference point, so PC always points to the third instruction. When the arm status is set, each command is 4 bytes long, so the PC always points to the command address plus an 8-byte address, that is, the PC value = the current program execution Position + 8;
The PC in ads is modified to debug and look at convenience, it points to the instructions being executed, that is, "Real pc-8 "!

1. Return of abnormal interruptions of SWI and undefined commands:
Command address
A PC-8 current command is SWI or undefined command at this time the interrupt. PC value has not been updated.
The processor saves the PC-4 to LR during a + 4 PC-4 interrupt. ; LR!
A + 8 PC

When returned, the execution starts from the next instruction A + 4 (PC-8) of the interrupted instruction A (PC-4), so just assign the LR value to the PC, specific commands are mov PC and LR (Pc = a + 4 = LR)
Vernacular explanation: SWI and undefined command exceptions: The PC is not updated when an exception occurs. According to the principle of the three-level assembly line of arm, the PC is not updated and is still equal to (a + 8 ); LR = pc-4 (this is determined by the processor and cannot be changed !) That is, A + 4.
Since the next command (a + 4) should be executed after the return of such exceptions, Pc = LR is enough.

2. Return of IRQ and FIQ exception interrupt handling:
Command address corresponds to PC
A PC-8 after executing this command (!) Query IRQ and FIQ. If a request is interrupted, the request is interrupted.
A + 4 PC-4
A + 8 PC; LR!
(Now the Pc value has been updated, pointing to a + 12. Moving the current PC-4, that is, a + 8 ).
Save to LR. Return, and then execute the command at a + 4 (LR-4), so the return command is
Subs PC, LR, #4 (Pc = a + 4 = LR-4)
Vernacular explanation: for general interruption and fast interruption exceptions, the interruption must be detected after an instruction is executed. For example, an interruption occurs when instruction A is being executed, the interrupt will not be handled after instruction A is executed. When an exception occurs, the PC has been updated (a + 12); LR = pc-4 (this is determined by the processor and cannot be changed !) That is, after a + 8 is returned, the command that is interrupted but not executed (a + 4 above) should be executed, so when returned, Pc = lr-4

3. Command prefetch:
Command address
A PC-8 was interrupted when executing this command,
A + 4 PC-4 processor saves a + 4 (PC-4) to LR.; LR!
A + 8 PC

The returned command is
Subs PC, LR, #4 (Pc = A = LR-4)
Vernacular explanation: For an exception in prefetch command suspension, the exception occurs when the prefetch command is abnormal. The PC is not updated, that is, Pc = a + 8; LR = pc-4 (this is determined by the processor and cannot be changed !) That is, A + 4.
Since this type of exception returns the instruction that should re-execute the exception (a), so when it returns, Pc = lr-4

4. Data Access abort exception and interrupt handling return:

Command address
A PC-8 this directive accesses problematic data and generates interruptions when the Pc value has been updated

A + 4 PC-4 interrupt occurs when Pc = a + 12, the processor saves a + 8 (PC-4) to LR.
A + 8 PC; LR!

Return to a to continue execution, so the command is subs PC, LR, #8. (Pc = A = LR-8)
Vernacular explanation: For an exception in Data Access suspension, when an exception occurs in Data Access suspension, it is an exception caused by an access data error during execution. The PC has been updated, that is, Pc = a + 12
LR = pc-4 (this is determined by the processor and cannot be changed !) That is, A + 8.
Since this type of exception returns the instruction that should re-execute the exception (a), so when it returns, Pc = lr-8

Section:
? One reason for PC update is data suspension and interruption.
? Interruption can only be detected after a command is executed. Therefore, it interrupts only the unexecuted command (PC-8), so PC = LR-4;
? Similar to the interrupt, SWI and undefined command exceptions are returned to the next command (PC-4), but the Pc value is not updated during execution, so PC = LR;
? The prefetch command aborts an exception and does not have a PC update, but it has to re-execute the exception command, so PC = LR-4;
? An exception occurs when data access is aborted. a pc update occurs and the exception Command needs to be re-executed. Therefore, Pc = LR-8.
More information qq2825915309 Tel: 18336308250

Several situations returned by arm exception interruptions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.