2 Copyright Oliver Kowalke 2009.
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
8 /****************************************************************************************
10 * ---------------------------------------------------------------------------------- *
11 * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
12 * ---------------------------------------------------------------------------------- *
13 * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
14 * ---------------------------------------------------------------------------------- *
15 * | R12 | R13 | R14 | R15 | *
16 * ---------------------------------------------------------------------------------- *
17 * ---------------------------------------------------------------------------------- *
18 * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
19 * ---------------------------------------------------------------------------------- *
20 * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | *
21 * ---------------------------------------------------------------------------------- *
22 * | RBX | RBP | RIP | EXIT | *
23 * ---------------------------------------------------------------------------------- *
25 ****************************************************************************************/
31 pushq %rbp /* save RBP */
32 pushq %rbx /* save RBX */
33 pushq %r15 /* save R15 */
34 pushq %r14 /* save R14 */
35 pushq %r13 /* save R13 */
36 pushq %r12 /* save R12 */
38 /* store RSP (pointing to context-data) in RAX */
41 /* restore RSP (pointing to context-data) from RDI */
44 popq %r12 /* restrore R12 */
45 popq %r13 /* restrore R13 */
46 popq %r14 /* restrore R14 */
47 popq %r15 /* restrore R15 */
48 popq %rbx /* restrore RBX */
49 popq %rbp /* restrore RBP */
51 /* restore return-address */
54 /* return transfer_t from jump */
55 /* RAX == fctx, RDX == data */
57 /* pass transfer_t as first arg in context function */
58 /* RDI == fctx, RSI == data */
61 /* indirect jump to context */