polish mandatory

This commit is contained in:
Xamora 2026-09-20 03:50:53 +02:00
parent 510ab19fd2
commit 0247990d2b
5 changed files with 19 additions and 12 deletions

View file

@ -12,10 +12,14 @@ section .text
mov rdi, rbx
call malloc wrt ..plt
cmp rax, 0
je end
mov rdi, rax
mov rsi, rbx
call bzero wrt ..plt
end:
pop rbx
ret

View file

@ -6,8 +6,8 @@ section .text
global ft_strcmp
; rdi = s1, rsi = s2
ft_strcmp:
mov rax, -1 ; counter
mov rax, -1
loop:
inc rax
mov cl, [rdi + rax] ; cl = s1[rax]

View file

@ -7,11 +7,10 @@ section .text
; rdi = dst, rsi = src
ft_strcpy:
mov rax, 0 ; counter
mov rcx, 0
mov rdx, 0
loop:
mov dl, [rsi + rax]
mov dl, [rsi + rax] ; get char from src
mov [rdi + rax], dl ; replace char by char
inc rax

View file

@ -14,9 +14,13 @@ section .text
inc rdi
call malloc wrt ..plt
cmp rax, 0
je end
mov rdi, rax ; put malloc result in dest
mov rsi, rbx ; put s in src
call ft_strcpy
end:
pop rbx
ret

View file

@ -2,18 +2,18 @@ bits 64
section .text
global ft_strlen
; rdi = str
ft_strlen:
; code
mov rbx, rdi
mov rsi, -1
mov rcx, -1 ; counter
loop:
inc rsi
mov al, [rbx + rsi]
inc rcx
mov al, [rdi + rcx]
cmp al, 0
jne loop
; return
mov rax, rsi
mov rax, rcx
ret