blob: de2e79da4645939c10d40fcc8ef5de0fcaea120a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# Context switch
#
# void swtch(struct context **old, struct context *new);
#
# Save the current registers on the stack, creating
# a struct context, and save its address in *old.
# Switch stacks to new and pop previously-saved registers.
.globl swtch
swtch:
# Save old callee-save registers
push %rbp
push %rbx
push %r11
push %r12
push %r13
push %r14
push %r15
# Switch stacks
mov %rsp, (%rdi) # first arg is in rdi
mov %rsi, %rsp # second arg is in rsi
# Load new callee-save registers
pop %r15
pop %r14
pop %r13
pop %r12
pop %r11
pop %rbx
pop %rbp
ret
|