LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What is the rep prefix and what does rep ret mean?

rep makes a string instruction repeat %ecx times (memcpy-style); rep ret is a quirky AMD branch-prediction workaround that behaves as a plain ret.

rep with string instructions:

Instruction Action
rep movsb Copy %ecx bytes from (%rsi) to (%rdi) (like memcpy)
rep stosb Fill %ecx bytes at (%rdi) with %al (like memset)
repne scasb Scan for %al in (%rdi), up to %ecx bytes (like strchr)

rep ret: AMD CPUs had a branch prediction issue when ret immediately follows a conditional jump. rep ret is a workaround — the rep prefix is ignored on ret but prevents the CPU bug. Treat it as plain ret.

Go deeper:

From Quiz: REVE1 / Assembly Patterns & GDB | Updated: Jul 14, 2026