Everything is open source when you speak assembly
Welcome to the Libasm project! This project is designed to help you get familiar with assembly language by implementing various functions in x86_64 assembly. The project includes a mix of C and assembly code to demonstrate the power and efficiency of low-level programming.
• You must write 64 bits ASM. Beware of the "calling convention". • You can’t do inline ASM, you must do ’.s’ files. • You must compile your assembly code with nasm. • You must use the Intel syntax, not the AT&T.
| Function | Description | Status |
|---|---|---|
ft_strlen |
Calculate the length of a string. | ✅ |
ft_strcpy |
Copy a string to another buffer. | ✅ |
ft_strcmp |
Compare two strings. | ✅ |
ft_strdup |
Duplicate a string. | ✅ |
ft_atoi_base |
Convert a string to an integer with a given base. | ✅ |
| Function | Description | Status |
|---|---|---|
ft_write |
Write data to a file descriptor. | ✅ |
ft_read |
Read data from a file descriptor. | ✅ |
| Function | Description | Status |
|---|---|---|
ft_list_push_front |
Add an element to the front of the list. | ✅ |
ft_list_size |
Get the size of the list. | ✅ |
ft_list_sort |
Sort the list using a comparison function. | ✅ |
ft_list_remove_if |
Remove elements from the list based on a comparison function. | ✅ |
The project is tested on Ubuntu Linux 24.04 LTS.
In the mac_silicon branch you can find a version working on Mac Silicon with Rosetta.
- nasm: The Netwide Assembler, used to assemble the assembly code.
- GCC: The GNU Compiler Collection, used to compile the C code.
- Make: A build automation tool to compile the project.
-
Clone the repository:
git clone https://github.com/timotif/libasm.git cd libasm -
Build the project:
make
-
Follow the instructions on the screen to run the tests or just use the static library
libasm_bonus.ain your project.
Check make help for more options.
- Unit test: A test suite to verify the functionality of the implemented functions.
- Call
./test [mandatory | bonus | <function_name>]to run the desired test. - Debug and Profile mode:
make debugto see the output of each test andmake profileto get the function's performance compared to its libc equivalent (implemented for some).
- Call
- String generator functions: Utility functions to generate random strings for testing purposes.
- Long string generator
- Random string generator
- Random printable string generator This makes the tests fairer by randomizing the input data.
- Base case string collection: An array of strings to test the functions with common edge cases. You can find it and edit it in
test_unit\src\main.c. You can add your own test cases to it. NB: make sure to keep the aray NULL-terminated! - List utility functions: the file
test_unit/src/test_list_helpers.ccontains utility functions to create, print, compare and free linked lists and streamline the tests.