Keywords: Zstr count x86 assembly.png Uploaded with en wp UW marker 2016 01 19 zstr_count function that implemented using x86 assembly https //en wikipedia org/w/index php title Assembly_language action edit section 20 2016-01-19 OldCodger2 Original source code text <source lang objdump line start 100 > 00000030 B9FFFFFFFF 00000035 41 00000036 803C0800 0000003A 75F9 0000003C C3 </source> <source lang nasm > ;----------------------------------------------------------- ; 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 mov ecx -1 ; Init the loop counter pre-decrement ; to compensate for the increment loop inc ecx ; Add 1 to the loop counter cmp byte eax + ecx 0 ; Compare the value at the string's ; starting memory address Plus the ; loop offset to zero 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 ret ; Return to the calling program </source> OldCodger2 |