Step Into Labs

Step Into x64 Assembly · Lesson 7 · Memory & the Stack

String Instructions: rep movs, stos, scas, cmps

The instructions behind memcpy, memset, strlen and memcmp, and the registers they borrow.

Part of Step Into x64 Assembly. The full lesson, its missions and the real compiler and debugger are in the course. Try a free lesson first to see how it works.

x64 has a family of string instructions that work on memory through two fixed registers: rsi (the source index) and rdi (the destination index). Each one does one step and then moves the pointers forward:

In this lesson

Missions

  1. memset in one instruction
  2. memcpy
  3. strlen with repne scasb
  4. memcmp with repe cmpsb