MOVSP — Move to Stack Pointer

Instruction Word

Slot
Inst
6
3
6
2
6
1
6
0
5
9
5
8
5
7
5
6
5
5
5
4
5
3
5
2
5
1
5
0
4
9
4
8
4
7
4
6
4
5
4
4
4
3
4
2
4
1
4
0
3
9
3
8
3
7
3
6
3
5
3
4
3
3
3
2
3
1
3
0
2
9
2
8
2
7
2
6
2
5
2
4
2
3
2
2
2
1
2
0
1
9
1
8
1
7
1
6
1
5
1
4
1
3
1
2
1
1
1
0
9876543210
Format x24 - 24 bit(s) 0
MOVSP 000000000001 0000
t 3210
s 3210

Assembler Syntax

MOVSP at, as

C Syntax

#include <xtensa/tie/xt_regwin.h>

extern int XT_MOVSP(int s);

Description

(please consult the Xtensa ® Instruction Set Architecture Reference Manual for any cross references and additional information)

MOVSP provides an atomic window check and register-to-register move. If the caller's registers are present in the register file, this instruction simply moves the contents of address register as to address register at. If the caller's registers are not present, MOVSP raises an Alloca exception.

MOVSP is typically used to perform variable-size stack frame allocation. The Xtensa Windowed Register ABI specifies that the caller's a0-a3 may be stored just below the callee's stack pointer. When the stack frame is extended, these values may need to be moved. They can only be moved with interrupts and exceptions disabled. This instruction provides a mechanism to test if they must be moved, and if so, to raise an exception to move the data with interrupts and exceptions disabled. The Xtensa ABI also requires that the caller's return address be in a0 when MOVSP is executed.

Operation

if WindowStartWindowBase-0011..WindowBase-0001 = 03 then
	Exception (AllocaCause)
else
	AR[t] ← AR[s]
endif

Exceptions

EveryInstR Group (see EveryInstR Group:)GenExcep(AllocaCause) if Windowed Register Option

Implementation Pipeline

In Out
WindowBase Rstage, WindowStart Rstage, ars Estage art Estage

Protos that use MOVSP

proto MOVSP { out int32 t, in int32 s }{}{
MOVSP t, s;
}