1# void swtch(struct context **old, struct context **new); 2# 3# Save current register context in old 4# and then load register context from new. 5 6.globl swtch 7swtch: 8 movl 4(%esp), %eax 9 movl 8(%esp), %edx 10 11 # Save old callee-save registers 12 pushl %ebp 13 pushl %ebx 14 pushl %esi 15 pushl %edi 16 17 # Switch stacks 18 movl %esp, (%eax) 19 movl (%edx), %esp 20 21 # Load new callee-save registers 22 popl %edi 23 popl %esi 24 popl %ebx 25 popl %ebp 26 ret 27