2017-04-08 9 views
0

文字列があり、長さを調べようとしています。私はrw32-2017を使用しています。 repe scasbを使用して文字列をスキャンしようとしましたが、ZFはまったく変更されません。文字列の長さを調べる簡単な方法はありますか? SCASについては文字列の長さを調べる方法

%include "rw32-2017.inc" 

section .data 
    ; write your data here 
    string1 db "how long is this string",0 

section .text 
main: 
    mov ebp, esp 

    ; write your code here 
    mov esi,string1 
    mov eax,0 
    mov ecx,50 ;max lenght of string is 50 
    mov ebx,ecx 
    cld 
    repe scasb 
    sub ebx, ecx 
    mov eax,ebx 
    call WriteUInt8 

    ret 

答えて

1

あなたはEDI内の文字列ではなく、ESIのアドレスを入れる必要があります。 私のプログラムは、このようになります。 REPEの代わりにREPNEが必要です(同じではないとecx!= 0を繰り返す)。

mov edi,string1 
mov eax,0 
mov ecx,50 ;max lenght of string is 50 
mov ebx,ecx 
cld 
repne scasb ; find AL (0), starting at [ES:EDI] 
関連する問題