save register

This commit is contained in:
starnakin 2024-09-05 18:39:51 +02:00
parent cbed6c468f
commit fdc1923211
4 changed files with 22 additions and 0 deletions

View File

@ -15,6 +15,8 @@ section .text
syscall_failed:
push rbx
neg rax
mov rbx, rax
@ -22,4 +24,7 @@ section .text
mov [rax], rbx
mov rax, -1
pop rbx
ret

View File

@ -2,6 +2,8 @@ section .text
global ft_strcmp
ft_strcmp:
push rbx
xor rcx, rcx
loop:
@ -20,4 +22,7 @@ section .text
out:
sub bl, dl
movsx rax, bl
pop rbx
ret

View File

@ -5,6 +5,8 @@ extern ft_strcpy
section .text
global ft_strdup
ft_strdup:
push rbx
call ft_strlen
mov rbx, rdi
@ -20,8 +22,13 @@ section .text
call ft_strcpy
pop rbx
ret
error:
xor rax, rax
pop rbx
ret

View File

@ -14,10 +14,15 @@ section .text
syscall_failed:
push rbx
neg rax
mov rbx, rax
call __errno_location wrt ..plt
mov [rax], rbx
mov rax, -1
pop rbx
ret