SETP, SETM, SETE
Memory set
These instructions set a required number of bytes in memory to the value in the least significant byte of the source data register. The prologue, main, and epilogue instructions are expected to be run in succession and to appear consecutively in memory: SETP, then SETM, and then SETE.
SETP performs some preconditioning of the arguments suitable for using the SETM instruction, and sets an IMPLEMENTATION DEFINED portion of the requested number of bytes. SETM sets a further IMPLEMENTATION DEFINED portion of the remaining bytes. SETE sets any final remaining bytes.
Note
The ability to set an IMPLEMENTATION DEFINED number of bytes allows an implementation to optimize how the bytes being set are divided between the different instructions.
For more information on exceptions specific to memory set instructions, see Memory Copy and Memory Set exceptions.
The architecture supports two algorithms for the memory set: option A and option B. Which algorithm is used is IMPLEMENTATION DEFINED.
Note
Portable software should not assume that the choice of algorithm is constant.
For SETP:
- If Xn[63] == '1', the set size is saturated to 0x7FFFFFFFFFFFFFFF.
On completion of SETP, option A:
- Xn holds -1 times the number of bytes in the saturated set size remaining to be set.
- Xd holds the original Xd + saturated set size.
- PSTATE.{N,Z,C,V} are set to {0,0,0,0}.
On completion of SETP, option B:
- Xn holds the number of bytes in the saturated set size remaining to be set.
- Xd holds the lowest address that has not been set.
- PSTATE.{N,Z,C,V} are set to {0,0,1,0}.
For SETM, option A, when PSTATE.C = '0':
- Xn holds a signed 64-bit integer.
- Xn holds -1 times the number of bytes remaining to be set.
- Xd holds the lowest address to be set - Xn.
- On completion of the instruction, Xn holds -1 times the number of bytes remaining to be set.
For SETM, option B, when PSTATE.C = '1':
- Xn holds the number of bytes remaining to be set.
- Xd holds the lowest address to be set.
-
On completion of the instruction:
- Xn holds the number of bytes remaining to be set.
- Xd holds the lowest address that has not been set.
For SETE, option A, when PSTATE.C = '0':
- Xn holds a signed 64-bit integer.
- Xn holds -1 times the number of bytes remaining to be set.
- Xd holds the lowest address to be set - Xn.
- On completion of the instruction, Xn holds 0.
For SETE, option B, when PSTATE.C = '1':
- Xn holds the number of bytes remaining to be set.
- Xd holds the lowest address to be set.
-
On completion of the instruction:
- Xn holds 0.
- Xd holds the lowest address that has not been set.
Integer class
(FEAT_MOPS)
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| sz | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | Rs | x | x | 0 | 0 | 0 | 1 | Rn | Rd | |||||||||||||
| o0 | op1 | op2 | |||||||||||||||||||||||||||||
Decode (all encodings)
if !IsFeatureImplemented(FEAT_MOPS) || sz != '00' then EndOfDecode(Decode_UNDEF); end;
var memset : SETParams;
memset.d = UInt(Rd);
memset.s = UInt(Rs);
memset.n = UInt(Rn);
let options : bits(2) = op2[1:0];
let nontemporal : boolean = options[1] == '1';
case op2[3:2] of
when '00' => memset.stage = MOPSStage_Prologue;
when '01' => memset.stage = MOPSStage_Main;
when '10' => memset.stage = MOPSStage_Epilogue;
otherwise => EndOfDecode(Decode_UNDEF);
end;
For information about the CONSTRAINED UNPREDICTABLE behavior of this instruction, see Architectural Constraints on UNPREDICTABLE behaviors, and particularly Memory Copy and Memory Set SET* and Crossing a page boundary with different memory types or Shareability attributes.
Assembler Symbols
| <Xd> |
For the "Prologue" variant: is the 64-bit name of the general-purpose register that holds the destination address and is updated by the instruction, encoded in the "Rd" field. |
|
For the "Epilogue" and "Main" variants: is the 64-bit name of the general-purpose register that holds an encoding of the destination address and for option B is updated by the instruction, encoded in the "Rd" field. |
| <Xn> |
For the "Prologue" variant: is the 64-bit name of the general-purpose register that holds the number of bytes to be set and is updated by the instruction, encoded in the "Rn" field. |
|
For the "Main" variant: is the 64-bit name of the general-purpose register that holds an encoding of the number of bytes to be set and is updated by the instruction, encoded in the "Rn" field. |
|
|
For the "Epilogue" variant: is the 64-bit name of the general-purpose register that holds the number of bytes to be set and is set to zero on completion of the instruction, encoded in the "Rn" field. |
| <Xs> |
Is the 64-bit name of the general-purpose register that holds the source data, encoded in the "Rs" field. |
Operation
CheckMOPSEnabled();
CheckSETConstrainedUnpredictable(memset);
let data : bits(8) = X{}(memset.s);
var B : MOPSBlockSize = 0;
memset.is_setg = FALSE;
memset.nzcv = PSTATE.[N,Z,C,V];
memset.toaddress = X{64}(memset.d);
if memset.stage == MOPSStage_Prologue then
memset.setsize = UInt(X{64}(memset.n));
else
memset.setsize = SInt(X{64}(memset.n));
end;
memset.implements_option_a = SETOptionA();
let privileged : boolean = (if options[0] == '1' then AArch64_IsUnprivAccessPriv()
else PSTATE.EL != EL0);
let accdesc : AccessDescriptor = CreateAccDescMOPS(MemOp_STORE, privileged, nontemporal);
if memset.stage == MOPSStage_Prologue then
if memset.setsize > ArchMaxMOPSBlockSize then
memset.setsize = ArchMaxMOPSBlockSize;
end;
if memset.implements_option_a then
memset.nzcv = '0000';
memset.toaddress = memset.toaddress + memset.setsize;
memset.setsize = 0 - memset.setsize;
else
memset.nzcv = '0010';
end;
end;
memset.stagesetsize = MemSetStageSize(memset);
if memset.stage != MOPSStage_Prologue then
CheckMemSetParams(memset, options);
end;
var memaddrdesc : AddressDescriptor;
var memstatus : PhysMemRetStatus;
var memory_set : integer;
var fault : boolean = FALSE;
if memset.implements_option_a then
while memset.stagesetsize < 0 && !fault looplimit ArchMaxMOPSBlockSize do
// IMP DEF selection of the block size that is worked on. While many
// implementations might make this constant, that is not assumed.
B = SETSizeChoice(memset, 1);
assert B <= -1 * memset.stagesetsize;
(memory_set, memaddrdesc, memstatus) = MemSetBytes(memset.toaddress + memset.setsize,
data, B, accdesc);
if memory_set != B then
fault = TRUE;
else
memset.setsize = memset.setsize + B;
memset.stagesetsize = memset.stagesetsize + B;
end;
end;
else
while memset.stagesetsize > 0 && !fault looplimit ArchMaxMOPSBlockSize do
// IMP DEF selection of the block size that is worked on. While many
// implementations might make this constant, that is not assumed.
B = SETSizeChoice(memset, 1);
assert B <= memset.stagesetsize;
(memory_set, memaddrdesc, memstatus) = MemSetBytes(memset.toaddress, data, B, accdesc);
if memory_set != B then
fault = TRUE;
else
memset.toaddress = memset.toaddress + B;
memset.setsize = memset.setsize - B;
memset.stagesetsize = memset.stagesetsize - B;
end;
end;
end;
UpdateSetRegisters(memset, fault, memory_set);
if fault then
if IsFault(memaddrdesc) then
AArch64_Abort(memaddrdesc.fault);
else
let iswrite : boolean = TRUE;
HandleExternalAbort(memstatus, iswrite, memaddrdesc, B, accdesc);
end;
end;
if memset.stage == MOPSStage_Prologue then
PSTATE.[N,Z,C,V] = memset.nzcv;
end;
Version 2026.09 — Copyright © 2010-2026 Arm Limited or its affiliates.
This site is provided as a community resource and is NOT affiliated with nor endorsed by Arm Limited.