Master the fundamental concepts of x86 assembly (intel syntax) through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksC 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.
Write strlen in x86-64 NASM:
nasmLoading…
The harness reads one line, passes it to my_strlen as a NUL-terminated string without its line break, and prints the length.
One line of text, possibly empty, possibly containing spaces.
Its length in bytes: 5 for hello, 0 for an empty line.