Iret — Interrupt Return - Samsung S3F84B8 User Manual

8-bit cmos
Hide thumbs Also See for S3F84B8:
Table of Contents

Advertisement

S3F84B8_UM_REV 1.00
6.3.32 IRET — INTERRUPT RETURN
IRET (Normal)
IRET
FLAGS  @SP
Operation:
SP  SP + 1
PC  @SP
SP  SP + 2
SYM(0)  1
This instruction is used at the end of an interrupt service routine. It restores the flag register and
program counter, and enables the global interrupt again. A "normal IRET" is executed only if the
fast interrupt status bit (FIS, bit one of the FLAGS register, 0D5H) is cleared ("0"). If a fast
interrupt occurred, IRET clears the FIS bit that was set at the beginning of the service routine.
All flags are restored to their original settings (that is, the settings before the interrupt occurred).
Flags:
Format:
IRET (Normal)
IRET (Fast)
In
Example:
Figure
interrupts are enabled. When an interrupt occurs, the program counter and instruction pointer are
swapped. This causes the PC to jump to address 100H and the IP to keep the return address.
Typically, the last instruction in service routine is a jump to IRET at address FFH. This causes the
instruction pointer to be loaded with 100H again and the program counter to jump back to the
main program. Now, the next interrupt can occur and the IP is still correct at 100H.
NOTE: In the fast interrupt example above, if the last instruction is not a jump to IRET, you must pay attention to the order of
last two instructions. The IRET cannot proceed immediately by clearing of the interrupt status (ditto with a reset of the
IPR register).
opc
opc
6-4, the instruction pointer is initially loaded with 100H in the main program before
100H
FFFFH
Figure 6-4
IRET (Fast)
PC  IP
FLAGS  FLAGS'
FIS  0
Bytes
1
Bytes
1
0H
FFH
IRET
Interrupt
Service
Routine
JP to FFH
Fast interrupt Service Routine
6-45
6 INSTRUCTION SET
Cycles
10 (internal stack)
12 (internal stack)
Cycles
6
Opcode (Hex)
BF
Opcode (Hex)
BF

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents