RTSD

Releasing stack frame and returning from subroutine

RTSD

ReTurn from Subroutine and Deallocate stack frame


[Syntax]

(1)RTSD src

(2)RTSD src, dest-dest2

 

[Operation]

(1)SP = SP + src;

PC = *SP;

SP = SP + 4;

 

(2)signed char i;

SP = SP + ( src - ( register_num(dest2) - register_num(dest) +1 ) * 4 );

for ( i = register_num(dest); i <= register_num(dest2); i++ ) {

tmp = *SP;

SP = SP + 4;

register(i) = tmp;

}

PC = *SP;

SP = SP + 4;

 

[Function]

-

This instruction rotates dest one bit to the right including the C flag.

-

This instruction restores values for the block of registers in the range specified by dest and dest2 from the stack.

-

The range is specified by first and last register numbers. Note that the condition (first register number ≤ last register number) must be satisfied.

-

R0 cannot be specified.

-

The stack pointer in use is specified by the U bit in the PSW.

-

Registers are restored from the stack from R1 to R15:

 

[Instruction Format]

Syntax

Operand

Code Size

(Byte)

src

dest

dest2

(1)RTSD src

#UIMM:8

2

(2)RTSD src, dest-dest2

#UIMM:8

Rd (Rd=R1~R15)

Rd2 (Rd=R1~R15)

3

 

[Flag Change]

-

This instruction does not affect the states of flags.

 

[Description Example]

RTSD #4

RTSD #16, R5-R7