style: fix indentation to 8 space tab
This commit is contained in:
parent
fb49a1b217
commit
e9bae396ca
8 changed files with 53 additions and 51 deletions
|
|
@ -6,12 +6,12 @@ section .text
|
||||||
; rdx: len
|
; rdx: len
|
||||||
|
|
||||||
ft_memcpy:
|
ft_memcpy:
|
||||||
mov rax, rdi
|
mov rax, rdi
|
||||||
test rdx, rdx
|
test rdx, rdx
|
||||||
je .done
|
je .done
|
||||||
|
|
||||||
cld
|
cld
|
||||||
mov rcx, rdx
|
mov rcx, rdx
|
||||||
rep movsb
|
rep movsb
|
||||||
.done:
|
.done:
|
||||||
ret
|
ret
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,17 @@ section .text
|
||||||
|
|
||||||
|
|
||||||
ft_read:
|
ft_read:
|
||||||
mov eax, 0
|
mov eax, 0
|
||||||
syscall
|
syscall
|
||||||
|
|
||||||
test rax, rax
|
test rax, rax
|
||||||
js .done
|
js .done
|
||||||
|
|
||||||
neg rax
|
neg rax
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
call __errno_location wrt ..plt
|
call __errno_location wrt ..plt
|
||||||
mov dword [rax], edi
|
mov dword [rax], edi
|
||||||
mov eax, -1
|
mov eax, -1
|
||||||
|
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,18 @@ ft_strcmp:
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
movzx r10, byte [rdi]
|
movzx r10, byte [rdi]
|
||||||
inc rdi
|
inc rdi
|
||||||
movzx r11, byte [rsi]
|
movzx r11, byte [rsi]
|
||||||
inc rsi
|
inc rsi
|
||||||
|
|
||||||
cmp r10, 0x0
|
cmp r10, 0x0
|
||||||
je .done
|
je .done
|
||||||
|
|
||||||
|
|
||||||
cmp r10, r11
|
cmp r10, r11
|
||||||
je .loop
|
je .loop
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
mov rax, r10
|
mov rax, r10
|
||||||
sub rax, r11
|
sub rax, r11
|
||||||
ret
|
ret
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,21 @@ section .text
|
||||||
; rax = return value
|
; rax = return value
|
||||||
; should copy src in dest and return dest
|
; should copy src in dest and return dest
|
||||||
ft_strcpy:
|
ft_strcpy:
|
||||||
mov rax, rdi
|
mov rax, rdi
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
mov dl, byte [rsi]
|
mov dl, byte [rsi]
|
||||||
test dl, dl
|
test dl, dl
|
||||||
je .done
|
je .done
|
||||||
|
|
||||||
mov byte [rdi], dl
|
mov byte [rdi], dl
|
||||||
|
|
||||||
inc rsi
|
inc rsi
|
||||||
inc rdi
|
inc rdi
|
||||||
|
|
||||||
jmp .loop
|
jmp .loop
|
||||||
.done:
|
.done:
|
||||||
|
|
||||||
mov byte [rdi], 0x0
|
mov byte [rdi], 0x0
|
||||||
mov rdi, rax
|
mov rdi, rax
|
||||||
ret
|
ret
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,16 @@ section .text
|
||||||
|
|
||||||
ft_strdup:
|
ft_strdup:
|
||||||
call ft_strlen wrt ..plt
|
call ft_strlen wrt ..plt
|
||||||
inc rax
|
inc rax
|
||||||
mov r10, rdi
|
mov r10, rdi
|
||||||
mov rdi, rax
|
mov rdi, rax
|
||||||
|
|
||||||
call malloc wrt ..plt
|
call malloc wrt ..plt
|
||||||
test rax, rax
|
test rax, rax
|
||||||
je .done
|
je .done
|
||||||
|
|
||||||
mov rdi, rax
|
mov rdi, rax
|
||||||
mov rsi, r10
|
mov rsi, r10
|
||||||
call ft_strcpy wrt ..plt
|
call ft_strcpy wrt ..plt
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,16 @@ global ft_strlen
|
||||||
section .text
|
section .text
|
||||||
|
|
||||||
ft_strlen:
|
ft_strlen:
|
||||||
mov rax, rdi
|
mov rax, rdi
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
mov dl, byte [rax]
|
mov dl, byte [rax]
|
||||||
test dl, dl
|
test dl, dl
|
||||||
je .done
|
je .done
|
||||||
|
|
||||||
inc rax
|
inc rax
|
||||||
|
|
||||||
jmp .loop
|
jmp .loop
|
||||||
.done:
|
.done:
|
||||||
sub rax, rdi
|
sub rax, rdi
|
||||||
ret
|
ret
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,18 @@ extern __errno_location
|
||||||
section .text
|
section .text
|
||||||
|
|
||||||
ft_write:
|
ft_write:
|
||||||
mov eax, 1
|
mov eax, 1
|
||||||
syscall
|
syscall
|
||||||
|
|
||||||
; if rax >= 0
|
; if rax >= 0
|
||||||
test rax, rax
|
test rax, rax
|
||||||
jns .done
|
jns .done
|
||||||
|
|
||||||
neg rax
|
neg rax
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
call __errno_location wrt ..plt
|
call __errno_location wrt ..plt
|
||||||
mov dword [rax], edi
|
mov dword [rax], edi
|
||||||
mov eax, -1
|
mov eax, -1
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
ret
|
ret
|
||||||
|
|
|
||||||
12
src/libasm.h
12
src/libasm.h
|
|
@ -7,13 +7,15 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t ft_strlen(const char *str);
|
size_t ft_strlen(const char *str);
|
||||||
char *ft_strcpy(char *dest, const char *src);
|
char *ft_strcpy(char *dest, const char *src);
|
||||||
int ft_strcmp (const char *p1, const char *p2);
|
int ft_strcmp (const char *p1, const char *p2);
|
||||||
ssize_t ft_write(int fildes, const void *buf, size_t nbyte);
|
ssize_t ft_write(int fildes, const void *buf, size_t nbyte);
|
||||||
char *strdup(const char *s);
|
char *strdup(const char *s);
|
||||||
ssize_t ft_read(int fd, void *buf, size_t count);
|
ssize_t ft_read(int fd, void *buf, size_t count);
|
||||||
void *ft_memcpy(void *dest, const void *src, size_t n);
|
void *ft_memcpy(void *dest, const void *src, size_t n);
|
||||||
void ft_bzero(void *s, size_t n);
|
void ft_bzero(void *s, size_t n);
|
||||||
|
int ft_atoibase(char *str, char *base);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue