fix issue with null send to asm function

This commit is contained in:
Xamora 2026-09-20 16:11:56 +02:00
parent a133be704d
commit 7b6978c9e2
2 changed files with 14 additions and 0 deletions

8
main.c
View file

@ -77,12 +77,20 @@ test_strcpy() {
{
printf("ft_strcpy:\n");
ft_strcpy(NULL, NULL);
char src_empty[] = "";
char dst_empty[] = "";
char *ret = ft_strcpy(dst_empty, src_empty);
printf ("ret: %s_%p, src: %s_%p, dest: %s_%p\n",
ret, ret, src_empty, src_empty, dst_empty, dst_empty);
char null_char[0];
ft_strcpy(null_char, NULL);
ft_strcpy(dst_empty, NULL);
ft_strcpy(NULL, src_empty);
char src[10] = "src";
char dst[10] = "dst";
printf ("src: %s, dest: %s\n", src, dst);

View file

@ -9,6 +9,11 @@ section .text
mov rax, 0 ; counter
mov rdx, 0
cmp rdi, 0
je endloop
cmp rsi, 0
je endloop
loop:
mov dl, [rsi + rax] ; get char from src
mov [rdi + rax], dl ; replace char by char
@ -17,6 +22,7 @@ section .text
cmp dl, 0
jne loop
endloop:
mov rax, rdi
ret