xv6-65oo2/swtch.S
Frans Kaashoek a7ef9a40c4 x
2018-10-03 21:00:32 -04:00

36 lines
631 B
ArmAsm

# 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-saved registers
push %rbp
push %rbx
push %r11
push %r12
push %r13
push %r14
push %r15
# Switch stacks
mov %rsp, (%rdi) # first arg of swtch is in rdi
mov %rsi, %rsp # second arg of swtch is in rsi
# Load new callee-saved registers
pop %r15
pop %r14
pop %r13
pop %r12
pop %r11
pop %rbx
pop %rbp
ret