swtch64.S (482B)
1 # Context switch 2 # 3 # void swtch(struct context **old, struct context *new); 4 # 5 # Save current register context in old 6 # and then load register context from new. 7 8 .globl swtch 9 swtch: 10 # Save old callee-save registers 11 push %rbp 12 push %rbx 13 push %r11 14 push %r12 15 push %r13 16 push %r14 17 push %r15 18 19 # Switch stacks 20 mov %rsp, (%rdi) 21 mov %rsi, %rsp 22 23 # Load new callee-save registers 24 pop %r15 25 pop %r14 26 pop %r13 27 pop %r12 28 pop %r11 29 pop %rbx 30 pop %rbp 31 32 ret #??