feat: ft_strcmp
This commit is contained in:
parent
1a34f9a5e1
commit
274cf8281e
3 changed files with 26 additions and 1 deletions
1
Makefile
1
Makefile
|
|
@ -12,6 +12,7 @@ SHARED_LIB=lib$(LIB_NAME).so
|
|||
|
||||
SRCS=$(SRC_DIR)/ft_strlen.asm \
|
||||
$(SRC_DIR)/ft_strcpy.asm \
|
||||
$(SRC_DIR)/ft_strcmp.asm
|
||||
|
||||
OBJS=$(patsubst $(SRC_DIR)/%.asm,$(OBJ_DIR)/%.o,$(SRCS))
|
||||
DEPS=$(OBJS:.o=.d)
|
||||
|
|
|
|||
24
src/ft_strcmp.asm
Normal file
24
src/ft_strcmp.asm
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
global ft_strcmp
|
||||
section .text
|
||||
|
||||
;rdi: const char *p1
|
||||
;rsi: const char *p2
|
||||
ft_strcmp:
|
||||
|
||||
.loop
|
||||
movzx r10, byte [rdi]
|
||||
inc rdi
|
||||
movzx r11, byte [rsi]
|
||||
inc rsi
|
||||
|
||||
cmp r10, 0x0
|
||||
je .done
|
||||
|
||||
|
||||
cmp r10, r11
|
||||
je .loop
|
||||
|
||||
.done:
|
||||
mov rax, r10
|
||||
sub rax, r11
|
||||
ret
|
||||
|
|
@ -8,7 +8,7 @@ extern "C" {
|
|||
|
||||
size_t ft_strlen(char *str);
|
||||
char *ft_strcpy(char *dest, const char *src);
|
||||
|
||||
int ft_strcmp (const char *p1, const char *p2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue