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.
- ~35 minreading and coding
- 4missions
- membersaccess
- x64 Assemblylanguage
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
- Instructions that walk memory by themselves
- The rep prefixes
- The direction flag
- The catch on Windows: rsi and rdi are callee-saved
- Working out a length from rcx
Missions
- memset in one instruction
- memcpy
- strlen with repne scasb
- memcmp with repe cmpsb