
Handshake Solutions
HT80C51 User Manual
80C51 Family Instruction Set – Instruction definitions
Page 122 of 132
© Philips Electronics N.V. 2005
RET
Function: Return from subroutine
Description: RET pops the high- and low-order bytes of the PC successively from the stack, decrementing the
Stack Pointer by two. Program execution continues at the resulting address, generally the instruc-
tion immediately following an ACALL or LCALL. No flags are affected.
Example: The Stack Pointer originally contains the value 0BH. Internal RAM locations 0AH and 0BH contain
the values 23H and 01H, respectively. The instruction,
RET
will leave the Stack Pointer equal to the value 09H. Program execution will continue at location
0123H.
Bytes: 1
Cycles: 2
Encoding:
Operation: RET
(PC15-8)
← ((SP))
(SP)
← (SP) – 1
(PC7-0)
← ((SP))
(SP)
← (SP) – 1
RETI
Function: Return from interrupt
Description: RETI pops the high- and low-order bytes of the PC successively from the stack, and restores the
interrupt logic to accept additional interrupts at the same priority level as the one just processed.
The Stack Pointer is left decremented by two. No other registers are affected; the PSW is not
automatically restored to its pre-interrupt status. Program execution continues at the resulting ad-
dress, which is generally the instruction immediately after the point at which the interrupt request
was detected. If a lower- or same-level interrupt has been pending when the RETI instruction is
executed, that one instruction will be executed before the pending interrupt is processed.
Example: The Stack Pointer originally contains the value 0BH. An interrupt was detected during the instruc-
tion ending at location 0122H. Internal RAM locations 0AH and 0BH contain the values 23H and
01H, respectively. The instruction,
RETI
will leave the Stack Pointer equal to 09H and return program execution to location 0123H.
Bytes: 1
Cycles: 2
Encoding:
Operation: RETI
(PC15-8)
← ((SP))
(SP)
← (SP) – 1
(PC7-0)
← ((SP))
(SP)
← (SP) – 1
0
0
1
0
0
0
1
0
0
0
1
1
0
0
1
0