… | |
… | |
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 |
|
|
129 | /* TODO: xmm6..15 also would need to be saved. sigh. */ |
|
|
130 | #define NUM_SAVED 8 |
|
|
131 | #undef CORO_WIN_TIB |
|
|
132 | "\tpushq %rsi\n" |
|
|
133 | "\tpushq %rdi\n" |
|
|
134 | "\tpushq %rbp\n" |
|
|
135 | "\tpushq %rbx\n" |
|
|
136 | "\tpushq %r12\n" |
|
|
137 | "\tpushq %r13\n" |
|
|
138 | "\tpushq %r14\n" |
|
|
139 | "\tpushq %r15\n" |
|
|
140 | "\tmovq %rsp, (%rcx)\n" |
|
|
141 | "\tmovq (%rdx), %rsp\n" |
|
|
142 | "\tpopq %r15\n" |
|
|
143 | "\tpopq %r14\n" |
|
|
144 | "\tpopq %r13\n" |
|
|
145 | "\tpopq %r12\n" |
|
|
146 | "\tpopq %rbx\n" |
|
|
147 | "\tpopq %rbp\n" |
|
|
148 | "\tpopq %rdi\n" |
|
|
149 | "\tpopq %rsi\n" |
|
|
150 | #else |
128 | #define NUM_SAVED 6 |
151 | #define NUM_SAVED 6 |
129 | "\tpush %rbp\n" |
152 | "\tpushq %rbp\n" |
130 | "\tpush %rbx\n" |
153 | "\tpushq %rbx\n" |
131 | "\tpush %r12\n" |
154 | "\tpushq %r12\n" |
132 | "\tpush %r13\n" |
155 | "\tpushq %r13\n" |
133 | "\tpush %r14\n" |
156 | "\tpushq %r14\n" |
134 | "\tpush %r15\n" |
157 | "\tpushq %r15\n" |
135 | #if CORO_WIN_TIB |
158 | "\tmovq %rsp, (%rdi)\n" |
|
|
159 | "\tmovq (%rsi), %rsp\n" |
|
|
160 | "\tpopq %r15\n" |
|
|
161 | "\tpopq %r14\n" |
|
|
162 | "\tpopq %r13\n" |
|
|
163 | "\tpopq %r12\n" |
136 | "\tpush %gs:0x0\n" |
164 | "\tpopq %rbx\n" |
137 | "\tpush %gs:0x8\n" |
165 | "\tpopq %rbp\n" |
138 | "\tpush %gs:0xc\n" |
|
|
139 | #endif |
166 | #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 |
167 | #elif __i386 |
154 | #define NUM_SAVED 4 |
168 | #define NUM_SAVED 4 |
155 | "\tpush %ebp\n" |
169 | "\tpushl %ebp\n" |
156 | "\tpush %ebx\n" |
170 | "\tpushl %ebx\n" |
157 | "\tpush %esi\n" |
171 | "\tpushl %esi\n" |
158 | "\tpush %edi\n" |
172 | "\tpushl %edi\n" |
159 | #if CORO_WIN_TIB |
173 | #if CORO_WIN_TIB |
160 | "\tpush %fs:0\n" |
174 | "\tpushl %fs:0\n" |
161 | "\tpush %fs:4\n" |
175 | "\tpushl %fs:4\n" |
162 | "\tpush %fs:8\n" |
176 | "\tpushl %fs:8\n" |
163 | #endif |
177 | #endif |
164 | "\tmov %esp, (%eax)\n" |
178 | "\tmovl %esp, (%eax)\n" |
165 | "\tmov (%edx), %esp\n" |
179 | "\tmovl (%edx), %esp\n" |
166 | #if CORO_WIN_TIB |
180 | #if CORO_WIN_TIB |
167 | "\tpop %fs:8\n" |
181 | "\tpopl %fs:8\n" |
168 | "\tpop %fs:4\n" |
182 | "\tpopl %fs:4\n" |
169 | "\tpop %fs:0\n" |
183 | "\tpopl %fs:0\n" |
170 | #endif |
184 | #endif |
171 | "\tpop %edi\n" |
185 | "\tpopl %edi\n" |
172 | "\tpop %esi\n" |
186 | "\tpopl %esi\n" |
173 | "\tpop %ebx\n" |
187 | "\tpopl %ebx\n" |
174 | "\tpop %ebp\n" |
188 | "\tpopl %ebp\n" |
175 | #else |
189 | #else |
176 | #error unsupported architecture |
190 | #error unsupported architecture |
177 | #endif |
191 | #endif |
178 | "\tret\n" |
192 | "\tret\n" |
179 | ); |
193 | ); |