aboutsummaryrefslogtreecommitdiff
path: root/ft_strcpy.s
blob: d7cfac76803d611fbe2cc70cc50a7f0a8267233b (plain)
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
; **************************************************************************** ;
;                                                                              ;
;                                                         :::      ::::::::    ;
;    ft_strcpy.s                                        :+:      :+:    :+:    ;
;                                                     +:+ +:+         +:+      ;
;    By: cacharle <marvin@42.fr>                    +;+  +:+       +;+         ;
;                                                 +;+;+;+;+;+   +;+            ;
;    Created: 2019/11/22 03:04:28 by cacharle          ;+;    ;+;              ;
;    Updated: 2019/11/22 21:18:38 by cacharle         ;;;   ;;;;;;;;.fr        ;
;                                                                              ;
; **************************************************************************** ;

%ifdef __LINUX__
    %define M_FT_STRCPY ft_strcpy
%else
    %define M_FT_STRCPY _ft_strcpy
%endif

global M_FT_STRCPY

section .text
; char *ft_strcpy(char *dst, const char *src);
M_FT_STRCPY:
    push rbx
    push rcx
    mov  rax, rdi  ; dst
    mov  rbx, rsi  ; src
    mov  rcx, -1
FT_STRCPY_LOOP:
    inc  rcx
    mov  dl, byte [rbx + rcx]
    mov  byte [rax + rcx], dl
    cmp  byte [rbx + rcx], 0
    jne  FT_STRCPY_LOOP
    pop  rcx
    pop  rbx
    ret