he following is a partial listing generated by the [[Netwide Assembler|NASM]], an assembler for 32-bit [[Intel 80386|Intel x86]] CPUs. The code is for a subroutine, not a complete program.
;-----------------------------------------------------------
; zstr_count:
; Counts a zero-terminated ASCII string to determine its size
; in: eax = start address of the zero terminated string
; out: ecx = count = the length of the string
zstr_count: ; Entry point
00000030 B9FFFFFFFF mov ecx, -1 ; Init the loop counter, pre-decrement
; to compensate for the increment
.loop:
00000035 41 inc ecx ; Add 1 to the loop counter
00000036 803C0800 cmp byte [eax + ecx], 0 ; Compare the value at the string's
; [starting memory address Plus the
; loop offset], to zero
0000003A 75F9 jne .loop ; If the memory value is not zero,
; then jump to the label called '.loop',
; otherwise continue to the next line
.done:
; We don't do a final increment,
; because even though the count is base 1,
; we do not include the zero terminator in the
; string's length
0000003C C3 ret ; Return to the calling program