cps

Change Processor State (Thumb)

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

Change mode/state (Thumb).

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

Operands

  • effect
    IE/ID
  • mode
    Mode

Related

Other forms of cps

  • cps Change Processor State

More in T32 (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);