diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | ft_read.s | 0 | ||||
| -rw-r--r-- | ft_strcmp.s | 12 | ||||
| -rw-r--r-- | ft_strcpy.s | 11 | ||||
| -rw-r--r-- | ft_strdup.s | 11 | ||||
| -rw-r--r-- | ft_strlen.s | 12 | ||||
| -rw-r--r-- | ft_write.s | 4 | ||||
| -rw-r--r-- | main.c | 12 | ||||
| -rw-r--r-- | subject.en.pdf | bin | 0 -> 1305522 bytes |
9 files changed, 64 insertions, 0 deletions
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 --- /dev/null +++ b/ft_read.s 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 @@ -0,0 +1,12 @@ +#include <stdio.h> + +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 Binary files differnew file mode 100644 index 0000000..ead704a --- /dev/null +++ b/subject.en.pdf |
