From fdc1923211171debfc65fb7670950e2914091bbe Mon Sep 17 00:00:00 2001 From: starnakin Date: Thu, 5 Sep 2024 18:39:51 +0200 Subject: [PATCH] save register --- src/ft_read.asm | 5 +++++ src/ft_strcmp.asm | 5 +++++ src/ft_strdup.asm | 7 +++++++ src/ft_write.asm | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/src/ft_read.asm b/src/ft_read.asm index f99bc5d..9e38cb4 100644 --- a/src/ft_read.asm +++ b/src/ft_read.asm @@ -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 \ No newline at end of file diff --git a/src/ft_strcmp.asm b/src/ft_strcmp.asm index 63805f1..04c6f01 100644 --- a/src/ft_strcmp.asm +++ b/src/ft_strcmp.asm @@ -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 \ No newline at end of file diff --git a/src/ft_strdup.asm b/src/ft_strdup.asm index 177eab8..4dd09f1 100644 --- a/src/ft_strdup.asm +++ b/src/ft_strdup.asm @@ -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 \ No newline at end of file diff --git a/src/ft_write.asm b/src/ft_write.asm index 4df58da..25a0e94 100644 --- a/src/ft_write.asm +++ b/src/ft_write.asm @@ -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 \ No newline at end of file