File:Zstr count x86 assembly.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (945 × 467 pixels, file size: 133 KB, MIME type: image/png)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: zstr_count function that implemented using x86 assembly
Date
Source https://en.wikipedia.org/w/index.php?title=Assembly_language&action=edit&section=20
Author OldCodger2

Original source code text

[edit]
                     
                     
                     
                     
                     
                     
                     
00000030 B9FFFFFFFF  
                     
                     
00000035 41          
00000036 803C0800    
                     
                     
0000003A 75F9        
                     
                     
                     
                     
                     
                     
                     
0000003C C3
;-----------------------------------------------------------
; 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

Licensing

[edit]
Public domain This work has been released into the public domain by its author, OldCodger2. This applies worldwide.

In some countries this may not be legally possible; if so:
OldCodger2 grants anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current00:23, 19 January 2016Thumbnail for version as of 00:23, 19 January 2016945 × 467 (133 KB)Cedar101 (talk | contribs){{subst:Upload marker added by en.wp UW}} {{Information |Description = {{en|zstr_count function that implemented using x86 assembly}} |Source = {{own}} |Date = 2016-01-19 |Author = Cedar101 }}

There are no pages that use this file.

Metadata