Lines 92-117
Link Here
|
92 |
.type .make_fcontext,@function |
92 |
.type .make_fcontext,@function |
93 |
.globl .make_fcontext |
93 |
.globl .make_fcontext |
94 |
.make_fcontext: |
94 |
.make_fcontext: |
95 |
mflr %r0 # save return address into R0 |
95 |
mflr %r6 # save return address into R6 |
96 |
std %r0, 8(%r1) # save return address on stack, set up stack frame |
|
|
97 |
stdu %r1, -96(%r1) # allocate stack space, SP % 16 == 0 |
98 |
|
99 |
std %r5, 64(%r1) # save 3. arg of make_fcontext, pointer to context function |
100 |
std %r4, 56(%r1) # save 2. arg of make_fcontext, context stack size |
101 |
std %r3, 48(%r1) # save 1. arg of make_fcontext, pointer to context stack (base) |
102 |
|
96 |
|
|
|
97 |
mr %r0, %r3 |
103 |
subi %r3, %r3, 352 # reserve space for fcontext_t at top of context stack |
98 |
subi %r3, %r3, 352 # reserve space for fcontext_t at top of context stack |
104 |
bl align_stack@plt # call align_stack, R3 contains address at 16 byte boundary after return |
|
|
105 |
# == pointer to fcontext_t and address of context stack |
106 |
ld %r4, 48(%r1) # restore pointer to context stack (base) |
107 |
ld %r5, 56(%r1) # restore context stack size |
108 |
ld %r6, 64(%r1) # restore pointer to context function |
109 |
|
99 |
|
110 |
std %r4, 184(%r3) # save address of context stack (base) in fcontext_t |
100 |
# call align_stack, R3 contains address at 16 byte boundary after return |
|
|
101 |
# == pointer to fcontext_t and address of context stack |
102 |
clrrdi %r3, %r3, 4 |
103 |
|
104 |
std %r0, 184(%r3) # save address of context stack (base) in fcontext_t |
111 |
std %r5, 192(%r3) # save context stack size in fcontext_t |
105 |
std %r5, 192(%r3) # save context stack size in fcontext_t |
112 |
std %r6, 176(%r3) # save address of context function in fcontext_t |
106 |
std %r6, 176(%r3) # save address of context function in fcontext_t |
113 |
|
107 |
|
114 |
subf %r0, %r3, 64 # 64 bytes on stack for parameter area (== 8 registers) |
108 |
subi %r0, %r3, 64 # 64 bytes on stack for parameter area (== 8 registers) |
115 |
std %r0, 152(%r3) # save the stack base |
109 |
std %r0, 152(%r3) # save the stack base |
116 |
|
110 |
|
117 |
mflr %r0 # load LR |
111 |
mflr %r0 # load LR |
Lines 123-131
Link Here
|
123 |
std %r4, 168(%r3) # save address of finish as return address for context function |
117 |
std %r4, 168(%r3) # save address of finish as return address for context function |
124 |
# entered after context function returns |
118 |
# entered after context function returns |
125 |
|
119 |
|
126 |
addi %r1, %r1, 64 # deallocate stack space |
120 |
mtlr %r6 # restore return address |
127 |
lwz %r0, 8(%r1) # load return address from stack, destroy stack frame |
|
|
128 |
mtlr %r0 # restore return address |
129 |
|
121 |
|
130 |
blr |
122 |
blr |
131 |
|
123 |
|
Lines 136-140
Link Here
|
136 |
stwu %r1, -32(%r1) # allocate stack space, SP % 16 == 0 |
128 |
stwu %r1, -32(%r1) # allocate stack space, SP % 16 == 0 |
137 |
|
129 |
|
138 |
li %r3, 0 # set return value to zero |
130 |
li %r3, 0 # set return value to zero |
139 |
bl _exit@plt # exit application |
131 |
bl _exit # exit application |
|
|
132 |
nop |
140 |
.size .make_fcontext, .-.make_fcontext |
133 |
.size .make_fcontext, .-.make_fcontext |
|
|
134 |
|
135 |
.section .note.GNU-stack,"",%progbits |