Skip to content

deydoux/42cursus-libasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libasm

The aim of this project is to become familiar with assembly language.

About the project

This project introduces x86-64 assembly language programming by reimplementing standard C library functions. It requires writing assembly code using the Intel syntax and compiling with NASM.

Key Requirements

  • Write assembly code in 64-bit architecture
  • Use Intel syntax
  • Compile with NASM
  • Implementation of standard C library functions

Skills Learned

  • Understanding of low-level programming and CPU architecture
  • Register management and calling conventions (System V AMD64 ABI)
  • System calls in Linux
  • Memory manipulation at assembly level
  • Error handling with errno

Implementation

Mandatory functions

ft_strlen · (man 3)

Returns the length of the string s.

size_t ft_strlen(const char *s);

ft_strcpy · (man 3)

Copies the string from src to dest. Returns a pointer to dest.

char *ft_strcpy(char *dest, const char *src);

ft_strcmp · (man 3)

Compares two strings s1 and s2.

int ft_strcmp(const char *s1, const char *s2);

ft_write · (man 2)

Writes count bytes from the buffer buf to the file descriptor fd. On error, sets errno appropriately.

ssize_t ft_write(int fd, const void *buf, size_t count);

ft_read · (man 2)

Reads count bytes from the file descriptor fd into the buffer buf. On error, sets errno appropriately.

ssize_t ft_read(int fd, void *buf, size_t count);

ft_strdup · (man 3)

Duplicates the string s by allocating memory using malloc. Returns a pointer to the duplicated string.

char *ft_strdup(const char *s);

Bonus functions

The linked list functions will use the following structure:

typedef struct s_list {
	void *data;
	struct s_list *next;
} t_list;

ft_atoi_base · (man 3)

Converts a string str to an integer using the specified base. Handles leading whitespace, optional sign, and validates the base format.

int ft_atoi_base(const char *str, const char *base);

ft_list_push_front

Push a new element at the beginning of the list.

void ft_list_push_front(t_list **begin_list, void *data);

ft_list_size

Returns the size of the list.

int ft_list_size(t_list *begin_list);

ft_list_sort

Sorts the list in ascending order using the provided comparison function.

void ft_list_sort(t_list **begin_list, int (*cmp)());

ft_list_remove_if

Removes elements from the list that match the reference data using the provided comparison function.

void ft_list_remove_if(t_list **begin_list, void *data_ref, int (*cmp)(), void (*free_fct)(void *));

Getting started

Build

make

Run tests

make run

See more details on libasm-tester

References

About

The aim of this project is to become familiar with assembly language.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors