cps

Change Processor State

CPS<effect> <iflags> {, #<mode>}

Changes the processor mode or interrupt masks.

Details

Changes the processor mode, interrupt masks (I, F, A flags in CPSR), or both based on the encoded effect (IE=enable or ID=disable) and mode field. Requires privileged execution. A32-only system instruction; modifies CPSR directly and may change interrupt masks and processor mode.

Pseudocode Operation

if (imod == 0) then // imod encodes IE/ID
  // No change to interrupt masks
else if (imod == 1) then // IE: enable specified interrupts
  if (m == 1) then CPSR.I ← 0
else if (imod == 2) then // ID: disable specified interrupts
  if (m == 1) then CPSR.I ← 1
if (m == 1) then // Mode change enabled
  CPSR.M ← mode

Example

CPSeffect iflags

Encoding

Binary Layout
111100010000
00
1
0
0
0
0
0
0
0
0
A
I
F
0
mode
 
Format System
Opcode 0xF1020000
Extension A32 (System)

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);