… | |
… | |
123 | ".type coro_transfer, @function\n" |
123 | ".type coro_transfer, @function\n" |
124 | "coro_transfer:\n" |
124 | "coro_transfer:\n" |
125 | /* windows, of course, gives a shit on the amd64 ABI and uses different registers */ |
125 | /* windows, of course, gives a shit on the amd64 ABI and uses different registers */ |
126 | /* http://blogs.msdn.com/freik/archive/2005/03/17/398200.aspx */ |
126 | /* http://blogs.msdn.com/freik/archive/2005/03/17/398200.aspx */ |
127 | #if __amd64 |
127 | #if __amd64 |
|
|
128 | #ifdef _WIN32 |
128 | #define NUM_SAVED 6 |
129 | #define NUM_SAVED 8 |
|
|
130 | "\tpush %rsi\n" |
|
|
131 | "\tpush %rdi\n" |
129 | "\tpush %rbp\n" |
132 | "\tpush %rbp\n" |
130 | "\tpush %rbx\n" |
133 | "\tpush %rbx\n" |
131 | "\tpush %r12\n" |
134 | "\tpush %r12\n" |
132 | "\tpush %r13\n" |
135 | "\tpush %r13\n" |
133 | "\tpush %r14\n" |
136 | "\tpush %r14\n" |
134 | "\tpush %r15\n" |
137 | "\tpush %r15\n" |
135 | #if CORO_WIN_TIB |
138 | #if CORO_WIN_TIB |
136 | "\tpush %gs:0x0\n" |
139 | "\tpush %gs:0x0\n" |
137 | "\tpush %gs:0x8\n" |
140 | "\tpush %gs:0x8\n" |
138 | "\tpush %gs:0xc\n" |
141 | "\tpush %gs:0xc\n" |
|
|
142 | #endif |
|
|
143 | "\tmov %rsp, (%rcx)\n" |
|
|
144 | "\tmov (%rdx), %rsp\n" |
|
|
145 | #if CORO_WIN_TIB |
|
|
146 | "\tpop %gs:0xc\n" |
|
|
147 | "\tpop %gs:0x8\n" |
|
|
148 | "\tpop %gs:0x0\n" |
|
|
149 | #endif |
|
|
150 | "\tpop %r15\n" |
|
|
151 | "\tpop %r14\n" |
|
|
152 | "\tpop %r13\n" |
|
|
153 | "\tpop %r12\n" |
|
|
154 | "\tpop %rbx\n" |
|
|
155 | "\tpop %rbp\n" |
|
|
156 | "\tpop %rdi\n" |
|
|
157 | "\tpop %rsi\n" |
|
|
158 | #else |
|
|
159 | #define NUM_SAVED 6 |
|
|
160 | "\tpush %rbp\n" |
|
|
161 | "\tpush %rbx\n" |
|
|
162 | "\tpush %r12\n" |
|
|
163 | "\tpush %r13\n" |
|
|
164 | "\tpush %r14\n" |
|
|
165 | "\tpush %r15\n" |
|
|
166 | "\tmov %rsp, (%rdi)\n" |
|
|
167 | "\tmov (%rsi), %rsp\n" |
|
|
168 | "\tpop %r15\n" |
|
|
169 | "\tpop %r14\n" |
|
|
170 | "\tpop %r13\n" |
|
|
171 | "\tpop %r12\n" |
|
|
172 | "\tpop %rbx\n" |
|
|
173 | "\tpop %rbp\n" |
139 | #endif |
174 | #endif |
140 | "\tmov %rsp, (%rdi)\n" |
|
|
141 | "\tmov (%rsi), %rsp\n" |
|
|
142 | #if CORO_WIN_TIB |
|
|
143 | "\tpop %gs:0xc\n" |
|
|
144 | "\tpop %gs:0x8\n" |
|
|
145 | "\tpop %gs:0x0\n" |
|
|
146 | #endif |
|
|
147 | "\tpop %r15\n" |
|
|
148 | "\tpop %r14\n" |
|
|
149 | "\tpop %r13\n" |
|
|
150 | "\tpop %r12\n" |
|
|
151 | "\tpop %rbx\n" |
|
|
152 | "\tpop %rbp\n" |
|
|
153 | #elif __i386 |
175 | #elif __i386 |
154 | #define NUM_SAVED 4 |
176 | #define NUM_SAVED 4 |
155 | "\tpush %ebp\n" |
177 | "\tpush %ebp\n" |
156 | "\tpush %ebx\n" |
178 | "\tpush %ebx\n" |
157 | "\tpush %esi\n" |
179 | "\tpush %esi\n" |
… | |
… | |
159 | #if CORO_WIN_TIB |
181 | #if CORO_WIN_TIB |
160 | "\tpush %fs:0\n" |
182 | "\tpush %fs:0\n" |
161 | "\tpush %fs:4\n" |
183 | "\tpush %fs:4\n" |
162 | "\tpush %fs:8\n" |
184 | "\tpush %fs:8\n" |
163 | #endif |
185 | #endif |
164 | "\tmov %esp, (%eax)\n" |
186 | "\tmov %esp, (%eax)\n" |
165 | "\tmov (%edx), %esp\n" |
187 | "\tmov (%edx), %esp\n" |
166 | #if CORO_WIN_TIB |
188 | #if CORO_WIN_TIB |
167 | "\tpop %fs:8\n" |
189 | "\tpop %fs:8\n" |
168 | "\tpop %fs:4\n" |
190 | "\tpop %fs:4\n" |
169 | "\tpop %fs:0\n" |
191 | "\tpop %fs:0\n" |
170 | #endif |
192 | #endif |
171 | "\tpop %edi\n" |
193 | "\tpop %edi\n" |
172 | "\tpop %esi\n" |
194 | "\tpop %esi\n" |
173 | "\tpop %ebx\n" |
195 | "\tpop %ebx\n" |
174 | "\tpop %ebp\n" |
196 | "\tpop %ebp\n" |
175 | #else |
197 | #else |
176 | #error unsupported architecture |
198 | #error unsupported architecture |
177 | #endif |
199 | #endif |
178 | "\tret\n" |
200 | "\tret\n" |
179 | ); |
201 | ); |