CPYFPTRN, CPYFMTRN, CPYFETRN
Memory copy forward-only, reads and writes unprivileged, reads non-temporal
These instructions copy a requested number of bytes in memory from a source address to a destination address in a forward direction. The prologue, main, and epilogue instructions are expected to be run in succession and to appear consecutively in memory: CPYFPTRN, then CPYFMTRN, and then CPYFETRN.
CPYFPTRN performs some preconditioning of the arguments suitable for using the CPYFMTRN instruction, and copies an IMPLEMENTATION DEFINED portion of the requested number of bytes. CPYFMTRN copies a further IMPLEMENTATION DEFINED portion of the remaining bytes. CPYFETRN copies any final remaining bytes.
Note
The ability to copy an IMPLEMENTATION DEFINED number of bytes allows an implementation to optimize how the bytes being copied are divided between the different instructions.
For more information on exceptions specific to memory copy instructions, see Memory Copy and Memory Set exceptions.
The memory copy performed by these instructions is in the forward direction only, so the instructions are suitable for a memory copy only where there is no overlap between the source and destination locations, or where the source address is greater than or equal to the destination address.
The architecture supports two algorithms for the memory copy: 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 CPYFPTRN:
- If Xn[63] == '1', the copy size is saturated to 0x7FFFFFFFFFFFFFFF.
On completion of CPYFPTRN, option A:
- Xn holds -1 times the number of bytes in the saturated copy size remaining to be copied.
- Xs holds the original Xs + saturated copy size.
- Xd holds the original Xd + saturated copy size.
- PSTATE.{N,Z,C,V} are set to {0,0,0,0}.
On completion of CPYFPTRN, option B:
- Xn holds the number of bytes in the saturated copy size remaining to be copied.
- Xs holds the lowest address that has not been copied from.
- Xd holds the lowest address that has not been copied to.
- PSTATE.{N,Z,C,V} are set to {0,0,1,0}.
For CPYFMTRN, option A, when PSTATE.C = '0':
- Xn holds a signed 64-bit integer.
- Xn holds -1 times the number of bytes remaining to be copied.
- Xs holds the lowest address to be copied from - Xn.
- Xd holds the lowest address to be copied to - Xn.
- On completion of the instruction, Xn holds -1 times the number of bytes remaining to be copied.
For CPYFMTRN, option B, when PSTATE.C = '1':
- Xn holds the number of bytes remaining to be copied.
- Xs holds the lowest address to be copied from.
- Xd holds the lowest address to be copied to.
-
On completion of the instruction:
- Xn holds the number of bytes remaining to be copied.
- Xs holds the lowest address that has not been copied from.
- Xd holds the lowest address that has not been copied to.
For CPYFETRN, option A, when PSTATE.C = '0':
- Xn holds a signed 64-bit integer.
- Xn holds -1 times the number of bytes remaining to be copied.
- Xs holds the lowest address to be copied from - Xn.
- Xd holds the lowest address to be copied to - Xn.
- On completion of the instruction, Xn holds 0.
For CPYFETRN, option B, when PSTATE.C = '1':
- Xn holds the number of bytes remaining to be copied.
- Xs holds the lowest address to be copied from.
- Xd holds the lowest address to be copied to.
-
On completion of the instruction:
- Xn holds 0.
- Xs holds the lowest address that has not been copied from.
- Xd holds the lowest address that has not been copied to.
Explicit Memory effects produced by the instruction behave as if the instruction was executed at EL0 if the Effective value of PSTATE.UAO is 0 and either:
- The instruction is executed at EL1.
- The instruction is executed at EL2 when the Effective value of HCR_EL2().{E2H, TGE} is '11'.
Otherwise, the Explicit Memory effects operate with the restrictions determined by the Exception level at which the instruction is executed.
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 | op1 | 0 | Rs | 1 | 0 | 1 | 1 | 0 | 1 | Rn | Rd | ||||||||||||||
| o0 | op2 | ||||||||||||||||||||||||||||||
Decode (all encodings)
if !IsFeatureImplemented(FEAT_MOPS) || sz != '00' then EndOfDecode(Decode_UNDEF); end;
var memcpy : CPYParams;
memcpy.d = UInt(Rd);
memcpy.s = UInt(Rs);
memcpy.n = UInt(Rn);
let options : bits(4) = op2;
let rnontemporal : boolean = options[3] == '1';
let wnontemporal : boolean = options[2] == '1';
case op1 of
when '00' => memcpy.stage = MOPSStage_Prologue;
when '01' => memcpy.stage = MOPSStage_Main;
when '10' => memcpy.stage = MOPSStage_Epilogue;
end;
For information about the CONSTRAINED UNPREDICTABLE behavior of this instruction, see Architectural Constraints on UNPREDICTABLE behaviors, and particularly Memory Copy and Memory Set CPY* 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, encoded in the "Rd" field. |
| <Xs> |
For the "Prologue" variant: is the 64-bit name of the general-purpose register that holds the source address and is updated by the instruction, encoded in the "Rs" field. |
|
For the "Epilogue" and "Main" variants: is the 64-bit name of the general-purpose register that holds an encoding of the source address, encoded in the "Rs" field. |
| <Xn> |
For the "Prologue" variant: is the 64-bit name of the general-purpose register that holds the number of bytes to be transferred and is updated by the instruction to encode the remaining size and destination, 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 transferred, encoded in the "Rn" field. |
|
|
For the "Epilogue" variant: is the 64-bit name of the general-purpose register that holds an encoding of the number of bytes to be transferred and is set to zero on completion of the instruction, encoded in the "Rn" field. |
Operation
CheckMOPSEnabled();
CheckCPYConstrainedUnpredictable(memcpy.n, memcpy.d, memcpy.s);
memcpy.nzcv = PSTATE.[N,Z,C,V];
memcpy.toaddress = X{64}(memcpy.d);
memcpy.fromaddress = X{64}(memcpy.s);
memcpy.cpysize = SInt(X{64}(memcpy.n));
memcpy.implements_option_a = CPYFOptionA();
let rprivileged : boolean = (if options[1] == '1' then AArch64_IsUnprivAccessPriv()
else PSTATE.EL != EL0);
let wprivileged : boolean = (if options[0] == '1' then AArch64_IsUnprivAccessPriv()
else PSTATE.EL != EL0);
let raccdesc : AccessDescriptor = CreateAccDescMOPS(MemOp_LOAD, rprivileged, rnontemporal);
let waccdesc : AccessDescriptor = CreateAccDescMOPS(MemOp_STORE, wprivileged, wnontemporal);
if memcpy.stage == MOPSStage_Prologue then
if memcpy.cpysize[63] == '1' then memcpy.cpysize = ArchMaxMOPSBlockSize; end;
if memcpy.implements_option_a then
memcpy.nzcv = '0000';
// Copy in the forward direction offsets the arguments.
memcpy.toaddress = memcpy.toaddress + memcpy.cpysize;
memcpy.fromaddress = memcpy.fromaddress + memcpy.cpysize;
memcpy.cpysize = 0 - memcpy.cpysize;
else
memcpy.nzcv = '0010';
end;
end;
memcpy.stagecpysize = MemCpyStageSize(memcpy);
if memcpy.stage != MOPSStage_Prologue then
CheckMemCpyParams(memcpy, options);
end;
var copied : integer;
var iswrite : boolean;
var memaddrdesc : AddressDescriptor;
var memstatus : PhysMemRetStatus;
memcpy.forward = TRUE;
var fault : boolean = FALSE;
var B : MOPSBlockSize = 0;
if memcpy.implements_option_a then
while memcpy.stagecpysize != 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 = CPYSizeChoice(memcpy);
assert B <= -1 * memcpy.stagecpysize;
(copied, iswrite, memaddrdesc, memstatus) = MemCpyBytes(
memcpy.toaddress + memcpy.cpysize,
memcpy.fromaddress + memcpy.cpysize,
memcpy.forward, B,
raccdesc, waccdesc);
if copied != B then
fault = TRUE;
else
memcpy.cpysize = memcpy.cpysize + B;
memcpy.stagecpysize = memcpy.stagecpysize + B;
end;
end;
else
while memcpy.stagecpysize > 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 = CPYSizeChoice(memcpy);
assert B <= memcpy.stagecpysize;
(copied, iswrite, memaddrdesc, memstatus) = MemCpyBytes(memcpy.toaddress,
memcpy.fromaddress,
memcpy.forward, B,
raccdesc, waccdesc);
if copied != B then
fault = TRUE;
else
memcpy.fromaddress = memcpy.fromaddress + B;
memcpy.toaddress = memcpy.toaddress + B;
memcpy.cpysize = memcpy.cpysize - B;
memcpy.stagecpysize = memcpy.stagecpysize - B;
end;
end;
end;
UpdateCpyRegisters(memcpy, fault, copied);
if fault then
if IsFault(memaddrdesc) then
AArch64_Abort(memaddrdesc.fault);
end;
if IsFault(memstatus) then
let accdesc : AccessDescriptor = if iswrite then waccdesc else raccdesc;
HandleExternalAbort(memstatus, iswrite, memaddrdesc, B, accdesc);
end;
end;
if memcpy.stage == MOPSStage_Prologue then
PSTATE.[N,Z,C,V] = memcpy.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.