cps
Change Processor State (Thumb)
CPS<effect> <iflags> {, #<mode>}
Change mode/state (Thumb).
Details
Change Processor State changes interrupt masks (I, F, A flags) and optionally changes processor mode in Thumb mode. The effect field (IE/ID) specifies whether to Enable or Disable the specified interrupt flags. This instruction does not affect condition codes and requires appropriate privilege level to change mode.
Pseudocode Operation
if effect == 'IE' then
if 'A' in iflags then CPSR.A ← 0
if 'I' in iflags then CPSR.I ← 0
if 'F' in iflags then CPSR.F ← 0
elsif effect == 'ID' then
if 'A' in iflags then CPSR.A ← 1
if 'I' in iflags then CPSR.I ← 1
if 'F' in iflags then CPSR.F ← 1
if mode_specified then
CPSR.M ← mode
Example
CPSeffect iflags
Encoding
Binary Layout
111100111010
1
1
1
1
10
0
0
0
00
1
A
I
F
mode
Operands
-
effect
IE/ID -
mode
Mode
Reference (Arm AArch32 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0xF1020000 | CPS{<q>} #<mode> | A32 | 111100010000 | 00 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | A | I | F | 0 | mode | ||
| 0xF3AF8100 | CPS{<q>} #<mode> | T32 | 111100111010 | 1 | 1 | 1 | 1 | 10 | 0 | 0 | 0 | 00 | 1 | A | I | F | mode |
Description
Change PE State changes one or more of the PSTATE.{A, I, F} interrupt mask bits and, optionally, the PSTATE.M mode field, without changing any other PSTATE bits.
CPS is treated as NOP if executed in User mode unless it is defined as being constrained unpredictable elsewhere in this section.
The PE checks whether the value being written to PSTATE.M is legal. See Illegal changes to PSTATE.M.
Operation
if CurrentInstrSet() == InstrSet_A32 then
EncodingSpecificOperations();
if PSTATE.EL != EL0 then
if enable then
if affectA then PSTATE.A = '0';
if affectI then PSTATE.I = '0';
if affectF then PSTATE.F = '0';
if disable then
if affectA then PSTATE.A = '1';
if affectI then PSTATE.I = '1';
if affectF then PSTATE.F = '1';
if changemode then
// AArch32.WriteModeByInstr() sets PSTATE.IL to 1 if this is an illegal mode change.
AArch32.WriteModeByInstr(mode);
else
EncodingSpecificOperations();
if PSTATE.EL != EL0 then
if enable then
if affectA then PSTATE.A = '0';
if affectI then PSTATE.I = '0';
if affectF then PSTATE.F = '0';
if disable then
if affectA then PSTATE.A = '1';
if affectI then PSTATE.I = '1';
if affectF then PSTATE.F = '1';
if changemode then
// AArch32.WriteModeByInstr() sets PSTATE.IL to 1 if this is an illegal mode change.
AArch32.WriteModeByInstr(mode);