From 3eae1d082fbd86d48a8f9ee2c57b8931a468cb59 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 21 Nov 2019 05:04:37 +0100 Subject: Initial commit (i cant even compile this shit) --- .gitignore | 2 ++ ft_read.s | 0 ft_strcmp.s | 12 ++++++++++++ ft_strcpy.s | 11 +++++++++++ ft_strdup.s | 11 +++++++++++ ft_strlen.s | 12 ++++++++++++ ft_write.s | 4 ++++ main.c | 12 ++++++++++++ subject.en.pdf | Bin 0 -> 1305522 bytes 9 files changed, 64 insertions(+) create mode 100644 .gitignore create mode 100644 ft_read.s create mode 100644 ft_strcmp.s create mode 100644 ft_strcpy.s create mode 100644 ft_strdup.s create mode 100644 ft_strlen.s create mode 100644 ft_write.s create mode 100644 main.c create mode 100644 subject.en.pdf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a687bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.o +a.out diff --git a/ft_read.s b/ft_read.s new file mode 100644 index 0000000..e69de29 diff --git a/ft_strcmp.s b/ft_strcmp.s new file mode 100644 index 0000000..4c5aee7 --- /dev/null +++ b/ft_strcmp.s @@ -0,0 +1,12 @@ +_ft_strcmp: + mov eax, sp + mov ebx, sp + 8 + FT_STRCMP_LOOP: + cmp eax, 0 + jneq FT_STRCMP_LOOP + cmp ebx, 0 + jneq FT_STRCMP_LOOP + cmp eax, ebx + jeq FT_STRCMP_LOOP + sub eax, ebx + ret diff --git a/ft_strcpy.s b/ft_strcpy.s new file mode 100644 index 0000000..44a098d --- /dev/null +++ b/ft_strcpy.s @@ -0,0 +1,11 @@ +_ft_strcpy: + pop ax + pop bx + mov ecx, eax ; copy + FT_STRCPY_LOOP: + mov [ecx], ebx + inc ebx + inc ecx + cmp ebx, 0 + jneq FT_STRCPY_LOOP + ret diff --git a/ft_strdup.s b/ft_strdup.s new file mode 100644 index 0000000..a10f383 --- /dev/null +++ b/ft_strdup.s @@ -0,0 +1,11 @@ +_ft_strdup: + pop eax + push eax + call _ft_strlen + inc eax + push eax + call _malloc + call _ft_strcpy + ret + + diff --git a/ft_strlen.s b/ft_strlen.s new file mode 100644 index 0000000..32eaf0c --- /dev/null +++ b/ft_strlen.s @@ -0,0 +1,12 @@ +ft_strlen: + pop bx + mov eax, 0h +FT_STRLEN_LOOP: + mov ecx, [ebx] + cmp ecx, 0 + je FT_STRLEN_RET + inc eax + inc ebx + jmp FT_STRLEN_LOOP +FT_STRLEN_RET: + ret diff --git a/ft_write.s b/ft_write.s new file mode 100644 index 0000000..a21ec45 --- /dev/null +++ b/ft_write.s @@ -0,0 +1,4 @@ +_ft_write: + mov eax, 4 + int 0x80 + ret diff --git a/main.c b/main.c new file mode 100644 index 0000000..b1c30b7 --- /dev/null +++ b/main.c @@ -0,0 +1,12 @@ +#include + +int ft_strlen(char *); + + +int main() +{ + + /* extern ft_strlen("bonjour"); */ + printf("%d\n", ft_strlen("bonjour")); + return 0; +} diff --git a/subject.en.pdf b/subject.en.pdf new file mode 100644 index 0000000..ead704a Binary files /dev/null and b/subject.en.pdf differ -- cgit