Instruction
MOVS
Copies the element at [RSI] to [RDI] and steps both pointers; REP MOVS copies RCX elements, the classic memcpy.
- Extensions
- Mnemonics
- MOVS, MOVSB, MOVSW, MOVSD, MOVSQ
- Forms
- 8 (8 Legacy)
- Data
- Intel XED v2026.08.23
MOVS copies one element, a byte, word, doubleword or quadword, from
[RSI] to [RDI] and moves both pointers to the next element: up while
the direction flag is clear, down while it is set. A REP prefix repeats
it RCX times, counting RCX down to 0, so rep movsb is a whole memcpy
in two bytes, with RDI, RSI and RCX as its arguments. GCC 14 at -O2
copies a 512-byte struct with mov ecx, 64 and rep movsq, where
Clang 23 calls memcpy.
The doubleword form shares its name with SSE2’s MOVSD, a move of one double; assemblers tell them apart by the operands.
Things to know
- Direction. System V and Microsoft x64 require the direction flag clear at calls and returns (see the registers), so code can use MOVS without a CLD; code that sets the flag with STD must clear it again.
- Overlap. The copy is defined element by element, so a destination one element above the source repeats the first element all along, as Zen 5 recorded. Copying such buffers downward, with DF set, works but is much slower on Intel’s processors, whose optimization manual suggests copying the overlapping tail first instead (Section 3.7.6.3).
- Interruptions. A REP MOVS can stop between elements for an interrupt or a page fault, with RCX, RSI and RDI describing the work left and RIP still at the instruction, which then resumes.
- Address size. With a 67 prefix it uses ESI, EDI and, under REP, ECX, and writes them as 32-bit registers, clearing their upper halves.
- F2. Neither manual lists REPNE with MOVS, but XED decodes F2 A4 as REP MOVSB, and Zen 5 repeated it the same way.
Fast strings
Processors may run a REP MOVS in groups of several elements, which Intel calls fast-string operation. The stores of one instruction may then reach other processors out of order, or repeated (Intel’s Volume 3A, Section 11.2.4). On Zen 5 too they may arrive out of order, and copies at least the size of the L3 cache use streaming stores (AMD’s guide, Section 2.13.6). Both vendors keep the instruction’s stores after older stores and before younger ones, so a flag written after the copy still publishes it. Intel’s processors report enhanced REP MOVSB and STOSB in CPUID.(EAX=7,ECX=0):EBX[9], and faster copies of 1 to 128 bytes in EDX[4] (optimization manual, Section 3.7.6).
In the optimization guide
What the optimization guide says about MOVS, a line per claim. Each links to the claim in the guide, with its sources and where they differ.
Memory
- REP MOVS and STOS: Intel’s cores made
rep movsbandrep stosbfast from Ivy Bridge, and short strings fast from Ice Lake and Golden Cove, as CPUID reports. - REP MOVS and STOS:
rep movsis not always the fastest copy: short or misaligned copies can be faster with vector registers.
Bulldozer to Excavator
- Integer execution:
rep movsandrep stoshave a fast microcode path that moves 16 bytes at a time when the direction flag is clear, the blocks do not overlap and the addresses are aligned to the operand size.
Golden Cove and Raptor Cove
- Loads, stores and caches: Short
rep movsb,rep stosb,rep cmpsbandrep scasbare fast: with the data in the L1 cache, any length up to 128 bytes takes a flat 9, 12, 15 and 15 cycles, zero included except for the compares.
Haswell and Broadwell
- Loads, stores and strings:
rep movsbcopies more than 20 bytes a cycle when the copy is long, using the 256-bit store path, but loses to SIMD code below a few hundred bytes;rep stosbfills up to 32 bytes a cycle when the count is large.
Ice Lake to Rocket Lake
- Loads, stores and caches:
rep movsbis fast for 1 to 128 bytes, reported by CPUID leaf 7, EDX bit 4, whilerep stosbis unchanged. sources differ
Sandy Bridge and Ivy Bridge
- What Ivy Bridge changed: Ivy Bridge is the first core with enhanced REP MOVSB and STOSB, flagged by CPUID leaf 7’s EBX bit 9, which make a byte-granularity REP string fast as well as flexible for memory copies and fills; on Ivy Bridge itself, though, Intel’s manual notes they may still not reach the throughput of a hand-written 128-bit or 256-bit AVX copy.
Silvermont to Goldmont Plus
- Loads, stores and caches: rep movsb and rep stosb are enhanced from Silvermont on, but rep movs suffers from line splits.
Skylake to Cooper Lake
- Loads, stores and caches:
rep movsreaches full speed only with source and destination both aligned to 32 bytes; otherwise a copy with YMM or ZMM registers is faster.
Zen 5
- Loads, stores and caches:
rep movsandrep stosof at least the size of the L3 store with streaming stores that bypass the caches, and on some systems smaller ones skip reading the lines they overwrite whole.
Vulnerability mitigations
Mitigations of these processor vulnerabilities use MOVS:
- CVE-2023-23583: Redundant Prefix Issue
Forms
| Instruction | Encoding | Requires |
|---|---|---|
MOVSB
MOVSB | A4 | Base instruction set |
MOVSW
MOVSW | 66 A5 | Base instruction set |
MOVSD
MOVSD | A5 | Base instruction set |
MOVSQ 64-bit mode only
MOVSQ | REX.W A5 | LM |
REP MOVSB
REP_MOVSB | F3 A4F2 A4 | Base instruction set |
REP MOVSW
REP_MOVSW | 66 F3 A566 F2 A5 | Base instruction set |
REP MOVSD
REP_MOVSD | F3 A5F2 A5 | Base instruction set |
REP MOVSQ 64-bit mode only
REP_MOVSQ | F3 REX.W A5F2 REX.W A5 | LM |
Latency and throughput
| Model | MOVSBMOVSB | MOVSWMOVSDMOVSQMOVSWMOVSDMOVSQ |
|---|---|---|
| Sandy Bridge | 8 / 1p0 p1 p4 p5 p23 | 8 / 1p0 p1 p4 p5 p23 |
| Haswell | 4 / 1p0123456 | 4 / 1p0123456 |
| Broadwell, Skylake, Skylake-SP, Ice Lake | 100 / 0.25p0156 | 100 / 0.25p0156 |
| Alder Lake, Sapphire Rapids | 8 / 0.8p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 | 7 / 0.8p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 |
| Lunar Lake | 8 / 0.67p0 p1 p2 p3 p4 p5 p10 p11 p20 p21 p22 p25 p26 p27 | 7 / 0.67p0 p1 p2 p3 p4 p5 p10 p11 p20 p21 p22 p25 p26 p27 |
| Bonnell | 3 / 1.5p01 | 3 / 1.5p01 |
| Silvermont | 100 / 1FPC0 | 100 / 1FPC0 |
| Piledriver | 100 / 0.5EX0 EX1 | 100 / 0.5EX0 EX1 |
| Zen, Zen 2 | 100 / 0.25 | 100 / 0.25 |
| Zen 3, Zen 4 | 100 / 25ALU0 ALU1 ALU2 ALU3 | 100 / 25ALU0 ALU1 ALU2 ALU3 |
| Jaguar | 100 / 0.5ALU0 ALU1 | 100 / 0.5ALU0 ALU1 |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
n = OSIZE // 8
step = -n if df else n # DF set: down
store(aDI, OSIZE, load(aSI, OSIZE))
aSI = low(aSI + step, ASIZE)
aDI = low(aDI + step, ASIZE)Run on AMD Zen 5 (EPYC 9645): 16 cases.
n = OSIZE // 8
step = -n if df else n
s = aSI
d = aDI
for i in range(aCX): # nothing at all when aCX is 0
# one element after the other: a destination one element
# ahead of the source repeats the first element all along
store(d, OSIZE, load(s, OSIZE))
s = low(s + step, ASIZE)
d = low(d + step, ASIZE)
aSI = s # 67 prefix: bits 63:32 cleared
aDI = d
aCX = 0Run on AMD Zen 5 (EPYC 9645): 32 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
MOVSB MOVSW MOVSD MOVSQ 64-bit mode only | ||
m8/16/32/64 at ES:[rDI] | implicit | write |
rDI | implicit | read, write |
m8/16/32/64 at [rSI] | implicit | read |
rSI | implicit | read, write |
RFLAGS | implicit | read |
REP MOVSB REP MOVSW REP MOVSD REP MOVSQ 64-bit mode only | ||
m8/16/32/64 at ES:[rDI] | implicit | conditional write |
rDI | implicit | read, conditional write |
m8/16/32/64 at [rSI] | implicit | conditional read |
rSI | implicit | read, conditional write |
rCX | implicit | read, conditional write |
RFLAGS | implicit | read |
Flags
| DF |
|---|
| All forms |
| T |
Attributes
What else XED records about the forms. How to read.
- REP forms
- repeated: count in rCX
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
| ISA set | CPUID | Processors |
|---|---|---|
I86 | No CPUID bit: part of the base instruction set. | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
I386 | No CPUID bit: part of the base instruction set. | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
LONGMODE | LM | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
More General-purpose instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - LLVM 23.1.2's x86 scheduling models (commit
85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2B, page 4-104 (MOVS/
MOVSB/ MOVSW/ MOVSD/ MOVSQ) - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3 (325384-093, September 2026)
- AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
- Intel 64 and IA-32 Architectures Optimization Reference Manual, Volume 1 (248966-051, October 2026)
- Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The timings come from LLVM's scheduling models, part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.