-
-
Save vendethiel/08068dd076be1fdc90ab23658c4ca803 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.global _start | |
.text | |
# strcmp(rdi=str1, rsi=str2, ecx=length_of_longest): %rax | |
_start: | |
pushq %rbp | |
movq %rsp, %rbp | |
movabsq $str1, %rdi | |
movabsq $str2, %rsi | |
movl $str1_size, %ecx | |
call strcmp | |
leave | |
ret | |
strcmp: | |
pushq %rbp | |
movq %rsp, %rbp | |
cld | |
repe cmpsb # compare %rdi[n]==%rsi[n] n=0..%ecx | |
movl %ecx, %eax | |
and $1, %eax # make sure result is 0 (eq) or 1 (uneq) | |
leave | |
ret | |
str1: | |
.asciz "Hello ate" | |
.set str1_size, .-str1 | |
str2: | |
.asciz "Hello ate" | |
.set str2_size, .-str2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment