该过程返回字符串长度到EAX寄存器中,调用该过程时需要传递字符串的偏移
INVOKE Str_length,ADDR myString
Str_length过程代码如下:
Str_length PROC USES edi,
pString : PTR BYTE ; pointer to string
mov edi,pString
mov eax,0 ; character count
L1: cmp byte ptr [edi],0 ; end of string?
je L2 ; yes : quit
inc edi ; no : point to next
inc eax ; add 1 to count
jmp L1
L2: ret
Str_length ENDP
结果存放在eax中