RETI

From SEGGER Knowledge Base
Jump to navigation Jump to search

RETI is short for RETurn from Interrupt. It is the name of the instruction that many CPUs use as a last instruction in an Interrupt Service Routine (ISR). RETI does not exist on all CPUs, or it has a different name, but RETI seems most common. What it does is usually restore the Program Counter (PC) and the status register (SR). It usually does the exact opposite of what happens when entering an ISR. So if the CPU saves 8 registers when entering the ISR (as Cortex-M processors do), then it restores these exact same registers.