int&
M~tV-51 PROGRAMMER'S GUIDEANDINSTRUCTION SET
RET
Function:
Description:
Example:
Bytm
cycles:
Encoding:
Operation:
RETI
Return tlom subroutine
RET pops the high-and low-orderbytes of the PC successivelyfrom the staclGdecrementing
the Stack Pointer by two. Program executioncontinuesat the resultingaddress,generallythe
instruction immediatelyfollowingan ACALLor LCALL. No tlags are affected.
The Stack Pointer originallycontains the valueOBH.Internal RAM locationsOAHand OBH
contain the value-a 23H and OIH, respectively. T he instruction,
RET
will leave the Stack Pointer equal to the value 09H. Program executionwill continue at
Ioeation0123H.
1
2
10010100101
RET
(Pc~~-s) +-
((sP))
(SP) +(SP)
– 1
(PC74) +
((sP))
(SP) +
(SP) -1
Function:
Description:
Exemple:
Bytes:
Cyclee:
Encoding:
Operation:
Return from interrupt
RETI pops the high- and low-orderbytes of the PC successively from the stack, and reatores
the interrupt logic to accept additional interrupts at the same priority level as the one just
processed.The Stack Pointer is left decrementrdby two. No other registersare aik%sd; the
PSW is not automaticallyrestored to its pre-interruptstatus. Program executioncontinuesat
the resultingaddress, which is generallythe instructionimmediatelyafter the point at which
the interrupt requestwas detected. Ifa lower-or same-levelinterrupt had beenpendingwhen
the RETI instruction is executed, that one instruction will be executedbefore the pending
interrupt is processed.
The Stack Pointer originally contains the value OBH.An interrupt was detected during the
instruction ending at location 0122H. Internal RAM locations OAHand OBHcontain the
values 23H and OIH, reapeotively. T he instruction,
RETI
wilt leave the Stack Pointer equat to O$IH and return program executionto locationO123H.
1
2
10011
I 00101
(PCls.s) +
((sP))
(sP)+
(SP) -1
(PC74) +
((sP))
(SP) -(SP)
-1
2-65
Need help?
Do you have a question about the MCS 51 and is the answer not in the manual?