1
2/*
3            Copyright Oliver Kowalke 2009.
4   Distributed under the Boost Software License, Version 1.0.
5      (See accompanying file LICENSE_1_0.txt or copy at
6          http://www.boost.org/LICENSE_1_0.txt)
7*/
8
9.align 2
10.globl .jump_fcontext
11.jump_fcontext:
12    # reserve space on stack
13    subi  1, 1, 184
14
15    std  13, 0(1)  # save R13
16    std  14, 8(1)  # save R14
17    std  15, 16(1)  # save R15
18    std  16, 24(1)  # save R16
19    std  17, 32(1)  # save R17
20    std  18, 40(1)  # save R18
21    std  19, 48(1)  # save R19
22    std  20, 56(1)  # save R20
23    std  21, 64(1)  # save R21
24    std  22, 72(1)  # save R22
25    std  23, 80(1)  # save R23
26    std  24, 88(1)  # save R24
27    std  25, 96(1)  # save R25
28    std  26, 104(1)  # save R26
29    std  27, 112(1)  # save R27
30    std  29, 120(1)  # save R28
31    std  29, 128(1)  # save R29
32    std  30, 136(1)  # save R30
33    std  31, 144(1)  # save R31
34    std  3,  152(1)  # save hidden
35
36    # save CR
37    mfcr  0
38    std  0, 160(1)
39    # save LR
40    mflr  0
41    std  0, 168(1)
42    # save LR as PC
43    std  0, 176(1)
44
45    # store RSP (pointing to context-data) in R6
46    mr  6, 1
47
48    # restore RSP (pointing to context-data) from R4
49    mr  1, 4
50
51    ld  13, 0(1)  # restore R13
52    ld  14, 8(1)  # restore R14
53    ld  15, 16(1)  # restore R15
54    ld  16, 24(1)  # restore R16
55    ld  17, 32(1)  # restore R17
56    ld  18, 40(1)  # restore R18
57    ld  19, 48(1)  # restore R19
58    ld  20, 56(1)  # restore R20
59    ld  21, 64(1)  # restore R21
60    ld  22, 72(1)  # restore R22
61    ld  23, 80(1)  # restore R23
62    ld  24, 88(1)  # restore R24
63    ld  25, 96(1)  # restore R25
64    ld  26, 104(1)  # restore R26
65    ld  27, 112(1)  # restore R27
66    ld  28, 120(1)  # restore R28
67    ld  29, 128(1)  # restore R29
68    ld  30, 136(1)  # restore R30
69    ld  31, 144(1)  # restore R31
70    ld  3,  152(1)  # restore hidden
71
72    # restore CR
73    ld  0, 160(1)
74    mtcr  0
75    # restore LR
76    ld  0, 168(1)
77    mtlr  0
78
79    # load PC
80    ld  0, 176(1)
81    # restore CTR
82    mtctr  0
83
84    # adjust stack
85    addi  1, 1, 184
86
87    # return transfer_t
88    std  6, 0(3)
89    std  5, 8(3)
90
91    # jump to context
92    bctr
93