diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5e82bc0 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +## +## Makefile for in /home/le-rou_c/docs/asm_minilibc +## +## Made by Lucien Le Roux +## Login +## +## Started on Tue Feb 28 09:39:50 2017 Lucien Le Roux +## Last update Tue Feb 28 09:43:57 2017 Lucien Le Roux +## + +NAME = strlen + +SRC = strlen.s +OBJ = $(SRC:.s=.o) + +CC = nasm -f elf64 +LD = ld + +RM = rm -f + +all: $(NAME) + + +$(NAME): $(SRC) + $(CC) $(SRC) -o $(OBJ) + $(LD) $(OBJ) -o $(NAME) + +clean: + $(RM) $(OBJ) + +fclean: clean + $(RM) $(NAME) + +re: fclean all diff --git a/strlen.s b/strlen.s new file mode 100644 index 0000000..f88a661 --- /dev/null +++ b/strlen.s @@ -0,0 +1,25 @@ +section .data + + +section .text + global _start + +_printRBX: + mov rax, 1 ; sys_write + mov rdi, 1 ; stdout + mov rsi, [edi] ; argv[0] + mov r10, 1 ; longueur de la chaine + syscall + ret + +_start: + mov rbx, rsp + add rbx, 32 ; argv + + call _printRBX + + mov rax, 60 + mov rdi, 0 + syscall + ret +