1.8 KiB
libasm
Why I did this project
I wanted to do this project for a while because I am interested in low level programming and assembly seemed very interesting. I had a lot of fun doing it, learning about function calling conventions, x86_64 architecture and other things.
How to compile it
To compile the project, you'll need nasm
and make
. Optionally, if you want to compile the tests,
you will need clang
.
Once you have these requirements, simply run the command make
and the project should compile.
The result is a library that you can add to your project with -L<folder> -lasm
, folder being the folder where the file libasm.a
is located
test the project
for every function asked for by the subject, there is a testing function in the file test.c
To compile the tests run the command make tests
. Then run the resulting executable with ./test
Useful documentation
While doing this project, since I had never programmed in x86_64 assembly before, I had to find some basic documentation.
I mostly had trouble with remembering the order of the functions parameters in the registers, I kept going back to
this stackoverflow thread
provided the order I needed. And in this thread I found information about the System V calling convention.
The order I needed was : rdi, rsi, rdx, rcx, r8, r9
During this project, I also needed to make system calls. To their parameters and numbers, I used this page which has a table of all the system calls.
Finally I also used this website to find more info about some instructions I didn't understand. It was also a useful resource for finding the appropriate jump instructions based on my needs.