Master the fundamental concepts of x86 assembly (intel syntax) through this focused micro-challenge.
C strings end at the first 0x00 byte. strlen does not know the length upfront; it scans. That design powers every format string and buffer overflow class in the CVE database. glibc's production strlen uses SIMD to test 32 bytes per iteration. Your byte loop is the baseline it beats.
nasmLoading…
\0, return 0x86 has rep scasb to compare AL against ES:[EDI], but manual cmp/inc teaches the contract.
For this exercise, you will implement my_strlen in NASM and return the length in rax. This task asks you to handle the empty string and preserve the pointer in rdi, because every hand-tuned libc string routine starts from this scan.
Keep the relevant man page, ABI doc, or Rust reference chapter open while you work. When your output disagrees with the reference implementation on the same machine, the mismatch is usually an alignment rule, an off-by-one terminator, or a register slot you misread in GDB. Skim the official documentation for the tool or ABI named in the exercise; the prose changes, but register roles, syscall numbers, and ownership rules stay stable across releases.
Implement strlen function in x86-64 assembly.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github