xv6-65oo2/swtch.S

30 lines
540 B
ArmAsm
Raw Normal View History

2009-07-12 02:28:29 +00:00
# Context switch
#
# void swtch(struct context **old, struct context *new);
#
2017-10-08 11:12:31 +00:00
# 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.
2007-08-28 12:48:33 +00:00
.globl swtch
swtch:
movl 4(%esp), %eax
2008-10-15 05:14:10 +00:00
movl 8(%esp), %edx
2007-08-28 12:48:33 +00:00
2008-10-15 05:14:10 +00:00
# Save old callee-save registers
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
2007-08-28 12:48:33 +00:00
2008-10-15 05:14:10 +00:00
# Switch stacks
movl %esp, (%eax)
2009-07-12 02:28:29 +00:00
movl %edx, %esp
2007-08-28 12:48:33 +00:00
2008-10-15 05:14:10 +00:00
# Load new callee-save registers
popl %edi
popl %esi
popl %ebx
popl %ebp
2007-08-28 12:48:33 +00:00
ret