aboutsummaryrefslogtreecommitdiff
path: root/ft_strlen.s
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-11-22 00:11:46 +0100
committerCharles <sircharlesaze@gmail.com>2019-11-22 00:11:46 +0100
commit0931febe3e178b4e484259c9cdc79ef452208ae7 (patch)
treea991e422cb6a1e98e03f951f3f3f962c3e9b5b42 /ft_strlen.s
parent3eae1d082fbd86d48a8f9ee2c57b8931a468cb59 (diff)
downloadlibasm-0931febe3e178b4e484259c9cdc79ef452208ae7.tar.gz
libasm-0931febe3e178b4e484259c9cdc79ef452208ae7.tar.bz2
libasm-0931febe3e178b4e484259c9cdc79ef452208ae7.zip
ft_strlen.s (i can kinda compile this shit)
Diffstat (limited to 'ft_strlen.s')
-rw-r--r--ft_strlen.s24
1 files changed, 12 insertions, 12 deletions
diff --git a/ft_strlen.s b/ft_strlen.s
index 32eaf0c..82c0e34 100644
--- a/ft_strlen.s
+++ b/ft_strlen.s
@@ -1,12 +1,12 @@
-ft_strlen:
- pop bx
- mov eax, 0h
-FT_STRLEN_LOOP:
- mov ecx, [ebx]
- cmp ecx, 0
- je FT_STRLEN_RET
- inc eax
- inc ebx
- jmp FT_STRLEN_LOOP
-FT_STRLEN_RET:
- ret
+.globl _ft_strlen
+
+ _ft_strlen:
+ mov rbx, rdi # first argument in rbx
+ xor rax, rax # rax = 0
+ FT_STRLEN_LOOP:
+ cmp byte ptr [rbx + rax], 0 # compare rbx[rax] and '\0'
+ je FT_STRLEN_RET
+ inc rax
+ jmp FT_STRLEN_LOOP
+ FT_STRLEN_RET:
+ ret