XOR Sum in Assembly

/* uint16_t xorsum(const char *buf, int len); */

        .global xorsum
        .text     

xorsum:
        mov    $0xffffffff,%eax
        mov    %esi, %edx
        shr    %edx
        jz     loop_done
        mov    %edx, %ecx

loop_next:
        xor    (%rdi), %ax
        add    $0x2, %rdi
        dec    %ecx
        jnz    loop_next

loop_done:
        shl    %edx
        sub    %edx, %esi
        jz     done
        xor    (%rdi), %al
  
done:
        ret

 

posted @ 2021-03-27 14:01  william-cheung  阅读(49)  评论(0编辑  收藏  举报