summaryrefslogtreecommitdiff
path: root/swtch.S
diff options
context:
space:
mode:
authorkolya <kolya>2008-10-15 05:14:10 +0000
committerkolya <kolya>2008-10-15 05:14:10 +0000
commitc100d9ee2d7d02253b55349bf55796efb3be5699 (patch)
treea26b6880767ce56d0d408226d3b67a86ff758142 /swtch.S
parent228e500a0c2b5a26492c84f73951a46c58c86509 (diff)
downloadxv6-labs-c100d9ee2d7d02253b55349bf55796efb3be5699.tar.gz
xv6-labs-c100d9ee2d7d02253b55349bf55796efb3be5699.tar.bz2
xv6-labs-c100d9ee2d7d02253b55349bf55796efb3be5699.zip
cleaner swtch.S
Diffstat (limited to 'swtch.S')
-rw-r--r--swtch.S36
1 files changed, 15 insertions, 21 deletions
diff --git a/swtch.S b/swtch.S
index 786e9ac..ada98f3 100644
--- a/swtch.S
+++ b/swtch.S
@@ -1,32 +1,26 @@
-# void swtch(struct context *old, struct context *new);
+# void swtch(struct context **old, struct context **new);
#
# Save current register context in old
# and then load register context from new.
.globl swtch
swtch:
- # Save old registers
movl 4(%esp), %eax
+ movl 8(%esp), %edx
- popl 0(%eax) # %eip
- movl %esp, 4(%eax)
- movl %ebx, 8(%eax)
- movl %ecx, 12(%eax)
- movl %edx, 16(%eax)
- movl %esi, 20(%eax)
- movl %edi, 24(%eax)
- movl %ebp, 28(%eax)
+ # Save old callee-save registers
+ pushl %ebp
+ pushl %ebx
+ pushl %esi
+ pushl %edi
- # Load new registers
- movl 4(%esp), %eax # not 8(%esp) - popped return address above
-
- movl 28(%eax), %ebp
- movl 24(%eax), %edi
- movl 20(%eax), %esi
- movl 16(%eax), %edx
- movl 12(%eax), %ecx
- movl 8(%eax), %ebx
- movl 4(%eax), %esp
- pushl 0(%eax) # %eip
+ # Switch stacks
+ movl %esp, (%eax)
+ movl (%edx), %esp
+ # Load new callee-save registers
+ popl %edi
+ popl %esi
+ popl %ebx
+ popl %ebp
ret