C++ 字符串比较 汇编代码实现

来源:互联网 发布:程序员在北京能挣多少 编辑:程序博客网 时间:2024/05/21 07:58

int asmCmp(char* str1, char*str2){

    _asm{

        mov eax, str1

            mov ebx, str2

s1:

        mov cl, [ebx]

        cmp [eax], cl

            jne ret2

            cmp cl, 0

            je ret1

            add eax, 1

            add ebx, 1

            jmp s1

ret1:

        mov eax, 0

            jmp end1;

ret2:

        mov eax, 1//这里可能不同的编译器需要不同的代码

end1:

    }

}

原创粉丝点击