xv6-cs450/swtch.S
Robert Morris 2cf6b32d4d move jkstack to main.c
replace jstack with asm()s
2010-08-05 14:15:03 -04:00

28 lines
461 B
ArmAsm

# Context switch
#
# void swtch(struct context **old, struct context *new);
#
# Save current register context in old
# and then load register context from new.
.globl swtch
swtch:
movl 4(%esp), %eax
movl 8(%esp), %edx
# Save old callee-save registers
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
# Switch stacks
movl %esp, (%eax)
movl %edx, %esp
# Load new callee-save registers
popl %edi
popl %esi
popl %ebx
popl %ebp
ret