This project is about creating an asm library called libasm.a.
It contains implementations of the following functions in asm with Intel syntax:
◦ ft_strlen (man 3 strlen)
◦ ft_strcpy (man 3 strcpy)
◦ ft_strcmp (man 3 strcmp)
◦ ft_write (man 2 write)
◦ ft_read (man 2 read)
◦ ft_strdup (man 3 strdup)
It also includes a main.c which contains a tester.
Another part of a calling convention is which registers are guaranteed to retain their values after a subroutine call.
- According to the Intel ABI to which the vast majority of compilers conform:
RAX, RCX, RDX, R8, R9, R10, R11 are considered volatile (caller-saved). - These registers are to be free for use within a procedure or function, and need not be preserved
- As the name implies, these general-purpose registers usually hold temporary (volatile) information, that can be overwritten by any subroutine.
- Therefore, it is the caller's responsibility to push each of these registers onto the stack, if it would like to restore their values after a subroutine call.
- The other registers are used to hold long-lived values (non-volatile), that should be preserved across calls:
RBX, RBP, RDI, RSI, RSP, R12, R13, R14, and R15 are considered nonvolatile (callee-saved). - When the caller makes a procedure call, it can expect that those registers will hold the same value after the callee returns.
- Thus, making it the callee's responsibility to both save (push at the beginning) and restore (pop accordingly) them before returning to the caller. As in the previous case, this practice should only be done on registers that the callee changes.
// Display a table listing the contents of archive
ar t libasm.a