美文网首页
C++ 字符串比较 汇编代码实现

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

作者: 成都老刘 | 来源:发表于2019-06-23 22:51 被阅读0次

    前言

    导入很久很久以前写的一篇技术!缅怀下以前写 C++ 的日子

    正文

    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:
        }
    }
    

    相关文章

      网友评论

          本文标题:C++ 字符串比较 汇编代码实现

          本文链接:https://www.haomeiwen.com/subject/vpcgqctx.html