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