The calling convention

A calling convention dictates which registers are volatile, which registers are non-volatile, which registers are used for parameter passing and in which order, and which register is used to return the result of a function.

A non-volatile register is a register that is restored to its original value just prior to a function leave (that is, in its epilog). The System V ABI defines rbx, rbp, r12, r13, r14, and r15 as non-volatile. By contrast, a volatile register is one that a called function can change at will, without having to restore its value on return.

To demonstrate this, let's look at the following example:

0000000000000630 <__libc_csu_init>:push %r15push %r14mov %rdx,%r15push %r13push %r12

As shown in the previous ...

Get Hands-On System Programming with C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.