cps

Change Processor State

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

Changes the processor mode or interrupt masks.

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
31:20
00
19:18
1
17
0
16
0
15
0
14
0
13
0
12
0
11
0
10
0
9
A
8
I
7
F
6
0
5
mode
4:0
 
Format System
Opcode 0xF1020000
Extension A32 (System)

Operands

  • effect
    IE/ID
  • mode
    Mode

Related

Other forms of cps

  • cps Change Processor State (Thumb)

More in A32 (System)

Reference

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