XRET
6-391
XRET C2xLP Source-Compatible Return
SYNTAX OPTIONS OPCODE OBJMODE RPT CYC
XRET 0101 0110 1111 1111 1 − 7
Note: XRET is an alias for RETC unconditional.
Operands None
Description Return conditionally. If the specified condition is true, a 16-bit value is
popped from the stack and stored into the low 16 bits of the PC while the
upper 6 bits of the PC are forced to 0x3F; Otherwise, execution continues
with the instruction following the XRETC operation:
if(COND = true)
SP = SP − 1;
PC = 0x3F:[SP];
Note: This instruction can transfer program control only to a location located in the upper 64K
range of program space (0x3F0000 to 0x3FFFFF). To return from a call made by
XCALL, the XRET instruction must be used.
Flags and
Modes
V
If the V flag is tested by the condition, then V is cleared.
Repeat This instruction is not repeatable. If this instruction follows the RPT
instruction, it resets the repeat counter (RPTC) and executes only once.
Example
; Return from FuncA if VarA does not equal zero, else set VarB
; to zero and return. This example only works for code located
; in upper 64K of program space:
XCALL FuncA ; Call FuncA
.
FuncA: ; Function A:
.
.
.
.
MOV AL,@VarA ; Load AL with contents of VarA
XRET NEQ ; Return if VarA does not equal 0
MOV @VarA,#0 ; Store 0 into VarB
XRETC UNC ; Return unconditionally