-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strcpy.s
39 lines (34 loc) · 1.56 KB
/
ft_strcpy.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
; **************************************************************************** ;
; ;
; ::: :::::::: ;
; ft_strcpy.s :+: :+: :+: ;
; +:+ +:+ +:+ ;
; By: apuchill <[email protected]> +#+ +:+ +#+ ;
; +#+#+#+#+#+ +#+ ;
; #+# #+# ;
; ### ########.fr ;
; ;
; **************************************************************************** ;
; ------------------------------------------------------------------------------
; FUNCTION PROTOTYPE (man 3 strcpy)
; char *ft_strcpy(char *dst, const char *src)
;
; INPUT
; 1st argument: rdi -> char *dst
; 2nd argument: rsi -> const char *src
;
; OUTPUT
; return: rax -> char *dst
; ------------------------------------------------------------------------------
global ft_strcpy
section .text
ft_strcpy:
mov rax, rdi ; char *ret = &dst
mov rcx, -1 ; i = -1
.while_loop:
inc rcx ; i++
mov dh, byte[rsi + rcx] ; char tmp = src[i]
mov byte[rdi + rcx], dh ; dst[i] = tmp
cmp byte [rsi + rcx], 0
jne .while_loop ; while (s[i] != 0)
ret ; return (ret)